Snow Gloves status band above the prompt (tenant, data root, Hermes, OmniRoute, approvals, graph walk, ISA, Temperance rail) and a /sg command

<img src="docs/assets/snowgloves-hero.png" width="100%" alt="Snow Gloves OS — Hand-In-Glove Business Operations Platform" />
Hand-In-Glove Business Operations Platform
<!-- og:image: docs/assets/snowgloves-og.png (upload via repo Settings → Social preview) -->
<!-- readme-gen:start:badges -->
<!-- readme-gen:end:badges -->
<!-- readme-gen:start:tech-stack --> <img src="https://skillicons.dev/icons?i=py,bash,yaml,rust,tauri,github,githubactions&theme=dark" alt="Tech Stack" /> <!-- readme-gen:end:tech-stack -->
<!-- readme-gen:start:social -->
<!-- readme-gen:end:social -->
Run a business as if a senior team were watching it 24/7. Snow Gloves OS is a reusable, tenant-scoped operations platform. It wraps your tools (G-Stack connectors), your knowledge (NVIDIA embeddings), your judgement (an interpretation layer), and your actions (Hermes + Paperclip orchestration), so events don't get dropped, decisions are auditable, and risky actions are gated. It is agent-agnostic: you pick the runtime (Claude Code, Codex, Cursor, OpenCode, Grok, Hermes, OpenClaw, or any other agent), and Snow Gloves renders its skills, MCP servers, and rules into that runtime's own format.
Docs for new users: snow-gloves-wiki — how to use the app and the ecosystem (install, pick a runtime, onboard, modules, a quiet week). Slides, audio, and video live there. The modules dashboard is the catalog, not the human guide.
The Infrastructure cockpit connects the playable Infra Block city to catalog, agent routing, runtime adapters, connector gates, scoped tenant metadata, wing profiles, activity records and acceptance evidence. Run python3 scripts/infra_cockpit.py and npm --prefix apps/infra-block run dev, then open http://127.0.0.1:18760/. The workspace supports source inspection and gate-checked proposal exports. Private instance metadata requires an explicit --data-root; execution and enablement remain outside this read-only interface.
<img src="https://capsule-render.vercel.app/api?type=rect&color=gradient&customColorList=12,13,14&height=2" width="100%" />
<table> <tr> <td width="50%" valign="top">
Seven specialized agents (CEO, CTO, Chief of Staff, Librarian, Interpreter, Dispatcher, Sentinel) work as one operations team, each with IDENTITY · SOUL · TOOLS · SKILLS · HEARTBEAT · MEMORY · EVOLUTION.
</td> <td width="50%" valign="top">
A dedicated Chief of Staff routes four native snowgloves: skills via glob-matched hooks so CEO/CTO stay strategic. inference-sh and Explee are catalog packs, not core. Enable a module and it is callable across agents.
</td> </tr> <tr> <td width="50%" valign="top">
132 catalog cards (skills, MCP servers, plugins, playbooks, connectors) harvested from X, Instagram, Field Theory, founders-kit, and marketingskills — including optional inference-sh and Explee packs. Every card is a pointer with a disposition: add, pointer, hold, or refuse.
</td> <td width="50%" valign="top">
One adapter.yaml per runtime says where skills, MCP config, and rules live and which question tool drives plan mode. The founder picks the runtime; nothing is hard-wired to one agent.
</td> </tr> <tr> <td width="50%" valign="top">
Composio-like scoped connectors (Gmail, Calendar, Drive, Slack, PMS, Accounting, HRIS). Per-capability risk + approval flags. Webhooks signed and verified.
</td> <td width="50%" valign="top">
Tenant-isolated vector index (nv-embedqa-e5-v5, 1024-dim). Plug into NVIDIA NIM with NVIDIA_API_KEY, or run offline with the deterministic stub backend.
</td> </tr> <tr> <td width="50%" valign="top">
Minimal HTTP listener on port 4100 (scripts/hermes.py). POST /publish, GET /events, POST /test/e2e for end-to-end smoke. Every event is append-logged to _audit/hermes-events.jsonl.
</td> <td width="50%" valign="top">
Daily aggregation of hook usage, fallbacks, escalations, and top skills per agent. Auto-appended to each agent's EVOLUTION.md for self-improving loops.
</td> </tr> </table>
<img src="https://capsule-render.vercel.app/api?type=rect&color=gradient&customColorList=12,13,14&height=2" width="100%" />
git clone https://github.com/Sheshiyer/snow-gloves-os.git
cd snow-gloves-os
./scripts/install.sh # deps + print next steps (does not go live)
make doctor # pre-flight
make smoke # bus up, test event, stub embed, Sentinel
make walk # machine-check CoS graph + native inner loops
make graph-upgrade # learning-edge dry-run (constraints; hooks gated)
make onboard-prompt R=claude # print the plan-mode interview for your runtime
make test # pytest
Snow Gloves runs on three office Mac minis by function (marketing, design, coding) over Tailscale. The Coding Mac hosts OmniRoute :20128 and Hermes :4100 for the whole fleet. A brand (tenant) is enabled on a wing (node), and make fleet-render W=<wing> T=<tenant> R=<runtime> writes that brand's modules and the wing's MCPs into the runtime's own files. Start with docs/fleet/README.md; make fleet-doctor tells a mini whether it is wired as its wing says.
New Mac Mini (use the product, do not compile Tauri): docs/MAC-MINI-SETUP.md. Emulate the desktop wizard on a dev Mac with make app-install then make app-dev — apps/onboarding/README.md. The fleet inventory is fleet.yaml in your private data checkout (template: fleet.example.yaml), and each wing's machine profile lives in nodes/ (nodes/<wing>/node.yaml; templates here, the instance copy in the data checkout wins).
This repository is the platform. Instance data (brand tenants, the fleet inventory and wing profiles, receipts, decisions, planning state) lives in a separate private checkout, snow-gloves-ops. Point the scripts at it:
export SNOWGLOVES_DATA=/path/to/snow-gloves-ops # tenants/, fleet.yaml, nodes/, _audit/
Unset, everything resolves to this checkout and its public fixtures (_demo, acme, tryambakam-noesis), which the local validation commands use; make smoke and make walk always use the fixtures. The resolver is scripts/lib/paths.py; scripts/onboard.py, node_profile.py, graph_upgrade.py and upgrade.py also take --data DIR. Never commit tenants, fleet.yaml, receipts or planning state here.
Planned fresh-node CLI onboarding: layered setup plan and Claude start prompt. This covers an always-on Mac mini workspace, developer tooling, Temperance/OmniRoute, secrets, and selected brand capabilities. It is a planning candidate; the node bootstrap CLI is not implemented yet.
| Target | Purpose |
|---|---|
make install | Bootstrap (paperclipai + python deps) |
make doctor | Pre-flight diagnostic |
make onboard | Interactive tenant + sources prompt (legacy flow) |
make onboard-prompt R=<runtime> | Print the plan-mode interview prompt for a runtime |
make catalog / make catalog-check | Rebuild catalog/modules.json + registry.yaml / fail if stale |
make legacy-check | Fail if pre-Hermes bus names remain (skips .bak-*) |
make site | Build the static dashboard site (npm run build:site) |
make hermes | Foreground Hermes listener on :4100 |
make smoke | Hermes → e2e → bridge dry-run → embed stub → sentinel |
make walk | Route fixtures through CoS; native produce/check/correct; receipt JSON |
make tui | Onboarding TUI (agent vs manual; --headless for agents) |
make graph-upgrade [T=<slug>] [WRITE=1] | Learning edge dry-run (or apply constraints; hook diffs need approval) |
make embed T=<tenant> | Run NVIDIA embed worker (QUIET=1 for cron) |
make sentinel | Daily drift sweep |
make release-dry V=x.y.z | Preview a platform version bump |
make release V=x.y.z | Bump every version file, rebuild catalog, commit, tag (no push) |
make release-push V=x.y.z | Push HEAD + tag; signing and publication require explicit manual steps |
make release-check | Verify all version files agree with VERSION |
make upgrade [T=<slug>] [WRITE=1] | Dry-run (or apply) tenant platform migrations |
make kill-hermes | Free port 4100 |
make fleet-doctor [W=<wing>] / fleet-render W= T= R= / fleet-enable W= T= / fleet-connect W= / fleet-kit-export / fleet-remote-access W= | Three-mini fleet: wing diagnostics, brand x wing x runtime render, enable, Tailscale shell, gateway kit, remote-access plan (docs/fleet/README.md) |
make app-install / app-dev / app-build | Tauri onboarding app: npm install, tauri dev (GUI), release bundle |
<img src="https://capsule-render.vercel.app/api?type=rect&color=gradient&customColorList=12,13,14&height=2" width="100%" />
<!-- readme-gen:start:architecture -->
graph TD
subgraph Runtime layer
Ext[3rd-party app] -- signed webhook --> GS[G-Stack /webhook]
GS -- normalized envelope --> Her[Hermes :4100]
Her --> CoS[Chief of Staff<br/>skill-hooks.yaml]
CoS -->|strategy| CEO
CoS -->|technical| CTO
CoS --> Lib[Librarian]
CoS --> Int[Interpreter]
CoS --> Dis[Dispatcher]
CoS --> Sen[Sentinel]
Dis --> PB[Paperclip Bridge<br/>:3100/api/tasks]
Lib --> EW[NVIDIA Embed Worker]
EW --> VI[(tenant vector-index.jsonl)]
Her -- audit --> Log[(_audit/hermes-events.jsonl)]
Log --> SS[Sentinel Sweep<br/>daily]
SS --> Evo[(agents/*/EVOLUTION.md)]
end
subgraph Catalog and adapter layer
Cards[catalog/cards/*.md] --> BC[build_catalog.py]
Agents[agents/*/MANIFEST.yaml] --> BC
Ad[adapters/*/adapter.yaml] --> BC
BC --> MJ[(catalog/modules.json)]
MJ --> Prompt[onboard.py --prompt runtime]
Prompt --> Harvest[snowgloves-harvest.md]
Harvest --> Apply[onboard.py --apply-harvest]
Apply --> En[(tenants/slug/enabled.yaml<br/>runtime.yaml)]
En --> Render[onboard.py --render-adapter]
Ad --> Render
Render --> RT[Runtime files:<br/>skills, MCP config, rules block]
MJ --> Dash[Tauri dashboard + Pages site]
En --> Gate[connector-gate]
end
| Engine | Owns | Files |
|---|---|---|
| Connector | G-Stack fabric, scopes, webhooks | connectors/g-stack/, skills/connector-gate/ |
| Knowledge | Ingest, chunk, embed, retrieve | scripts/ingest.py, scripts/embed_worker.py |
| Interpretation | Skill routing, escalation | workflows/skill-hooks.yaml, agents/chief-of-staff/ |
| Orchestration | Event bus + Paperclip bridge | scripts/hermes.py, scripts/paperclip_bridge.py |
More detail: docs/architecture-overview.md.
<!-- readme-gen:end:architecture -->
catalog/cards/<id>.md holds one card per third-party skill, MCP server, plugin, connector, or playbook. A card is a pointer, never a copy of upstream code. scripts/build_catalog.py compiles the cards, the agent manifests, the adapters, and the G-Stack connectors into catalog/registry.yaml and catalog/modules.json (schema snowgloves.modules.v1). Run make catalog-check locally to reject stale generated output.
| Disposition | Count | Meaning |
|---|---|---|
add | 61 | Tenant can enable it |
pointer | 45 | Tenant can enable it as a reference; the host already provides it |
hold | 14 | Visible, not enableable until the founder picks it and it passes review |
refuse | 12 | Visible, never enableable |
By category: skills 79, playbook 36, plugin 13, mcp 3, connector 1. Optional packs inference-sh-agent-skills and explee-skills are add cards, not core hooks. Card schema: docs/catalog.md. Harvest notes: docs/research/2026-09-29-ecosystem-review.md.
Snow Gloves does not assume an agent. Each runtime has adapters/<runtime>/adapter.yaml (schema snowgloves.adapter.v1): skill, MCP, and rules paths; file formats; the runtime's question tool; and how to enter plan mode. Shipped adapters: hermes, claude, codex, cursor, opencode, grok, openclaw, muse, generic. Fields nobody has confirmed against the real runtime are marked verify: true and reported on every render. The Muse adapter is a guess throughout.
Onboarding is a plan-mode interview run inside the project the founder has been building:
make onboard-prompt R=cursor # 1. interview → snowgloves-harvest.md
python3 scripts/onboard.py --apply-harvest snowgloves-harvest.md --tenant acme # 2. apply
python3 scripts/onboard.py --list --category skills # 3. adjust
python3 scripts/onboard.py --enable ms-copywriting --tenant acme
python3 scripts/onboard.py --render-adapter cursor --tenant acme # 4. render (dry run)
python3 scripts/onboard.py --render-adapter cursor --tenant acme --write
The agent asks one decision at a time, takes options only from modules.json, and writes FILL: instead of guessing. See docs/onboarding.md and docs/adapters.md.
The native Tauri v2 app in apps/onboarding/ gains a Modules dashboard and a guided onboarding flow. Both read the same catalog/modules.json plus each tenant's enabled.yaml. The same data is published as a static site, built with make site (npm run build:site) previously published by GitHub Pages. Automatic publishing is retired; this URL retains its last published content until a separate local publisher is selected:
https://sheshiyer.github.io/snow-gloves-os/
make app-install # one-time: npm install
make app-dev # launch in dev mode (hot-reload frontend)
make app-build # produce a signable release bundle
make site # build the static Pages site locally
See its README for the IPC surface and capability list.
The root VERSION file (currently 0.2.1) is the platform version. The app's package.json, tauri.conf.json, Cargo.toml, both lockfiles, and distribution.yaml are kept in lockstep with it, and catalog/modules.json embeds it.
make release-dry V=0.2.1 # show every file that would change
make release V=0.2.1 # bump, rebuild catalog, finalize CHANGELOG, commit, tag v0.2.1
make release-push V=0.2.1 # push only; no automatic signing or publication
make upgrade # dry-run tenant migrations to VERSION
make upgrade T=acme WRITE=1 # apply, rebuild catalog, re-render acme's adapters
The retired hosted release built signed Tauri installers and attached source, catalog, adapter, and checksum assets. Those publication jobs are no longer active. make app-build remains the local app build entry point; signing, cross-platform builds, updater latest.json, and publication require a separately reviewed local procedure. v0.2.0 is a reinstall for 0.1.x (new bundle id). See docs/RELEASING.md and docs/UPGRADING.md.
<!-- readme-gen:start:tree -->
📦 snow-gloves-os
├── 📄 VERSION # platform version (0.2.1)
├── 📄 distribution.yaml # what the platform owns vs what tenants own
├── 📂 .local-jobs/ # explicit local checks; schedules disabled
├── 📂 .specify/ # Spec-Kit templates + workflows
├── 📂 .planning/ # GSD state: local symlink into the private data checkout (gitignored)
├── 📂 agents/ # 7 agents, each with 8+ md files + MANIFEST
├── 📂 adapters/ # one adapter.yaml per runtime (9)
├── 📂 catalog/ # SCHEMA.md · cards/ (132) · registry.yaml · modules.json (generated)
├── 📂 prompts/ # onboard-interview.md (plan-mode interview template)
├── 📂 migrations/ # v0_1_to_v0_2.py (bus rename to Hermes)
├── 📂 apps/onboarding/ # Tauri v2 app: onboarding + Modules dashboard, Pages site
├── 📂 connectors/g-stack/ # Capability registry + auth + webhooks
├── 📂 scripts/ # hermes · ingest · embed · bridge · sentinel · build_catalog · onboard · release · upgrade
├── 📂 skills/ # registry.yaml (4 native skills) · connector-gate · sg-onboard · tn-seed · gtm-brief-synthesis
├── 📂 workflows/ # skill-hooks.yaml — Chief of Staff graph
├── 📂 specs/ # Spec-Kit features
├── 📂 docs/ # architecture, catalog, adapters, onboarding, releasing, upgrading, research, runbooks
├── 📂 tenants/ # Fixture tenants only; real tenants live in $SNOWGLOVES_DATA/tenants
├── 📂 nodes/ # Wing profile templates (marketing, design, coding)
├── 📄 fleet.example.yaml # Fleet inventory template (the real fleet.yaml is private)
├── 📂 tests/ # pytest suite
├── 📂 _audit/ # Append-only event log
├── 📄 config/snowgloves.yaml # Runtime config (ports, embeddings, scopes)
└── 📄 Makefile # make smoke runs the whole loop
<!-- readme-gen:end:tree -->
<img src="https://capsule-render.vercel.app/api?type=rect&color=gradient&customColorList=12,13,14&height=2" width="100%" />
<!-- readme-gen:start:health -->
| Category | Status | Score |
|---|---|---|
| Spec coverage | ████████████████████ | 100% |
| Agents wired | ████████████████████ | 100% |
| End-to-end smoke | ████████████████████ | 100% |
Local validation (pytest, version + catalog, make walk, smoke; execution is opt-in) | ████████████████████ | 100% |
Catalog (132 cards, --check in CI) | ████████████████████ | 100% |
Runtime adapters (9 shipped; several fields still verify: true) | ██████████░░░░░░░░░░ | 50% |
| Release + upgrade tooling (v0.2.1 stable) | ████████████████░░░░ | 80% |
| Real NVIDIA NIM integration | ████░░░░░░░░░░░░░░░░ | 20% |
| Live Paperclip wiring | ████░░░░░░░░░░░░░░░░ | 20% |
| Production hardening | ████░░░░░░░░░░░░░░░░ | 20% |
Overall: 70% — Stable v0.2.1 platform. Before a live pilot: confirm unverified adapter fields, and wire real connectors, NIM, and Paperclip.
<!-- readme-gen:end:health -->
com.tryambakam.snowgloves.onboarding (was com.thoughtseed.snowgloves.onboarding). v0.2.0 is a new app: existing 0.1.x users must reinstall from the DMG/MSI; OTA will not find 0.2.0.distribution.yaml lacks hermes_requires. Nothing declares which Hermes version or port a distribution needs yet. Do not set it in this release./plan, are unconfirmed. See docs/adapters.md.This repo uses GitHub Spec-Kit. Available slash commands (in Copilot/Codex chat):
/speckit.constitution /speckit.specify /speckit.clarify
/speckit.plan /speckit.tasks /speckit.analyze
/speckit.checklist /speckit.implement /speckit.taskstoissues
Active feature: specs/001-hand-in-glove-platform.
7 principles govern every change:
See .specify/memory/constitution.md.
<!-- readme-gen:start:footer -->
<img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&customColorList=12,13,14&height=110§ion=footer" width="100%" />
Built with ❤️ by Mage Narayan · Tryambakam Noesis
<!-- readme-gen:end:footer -->
hooks/register.tsx 161 lines1// sg-rail: the Snow Gloves status band above the prompt, and /sg.
2// It reads scripts/sg_mods.py snapshot every 30 seconds, probes Hermes and OmniRoute,
3// and shows the Temperance rail that PromptProcessing writes to a file while this mod sets
4// TEMPERANCE_RAIL_SINK=file. It changes nothing on disk.
5import { atom, read, update } from 'claude-code'
6import type { EngineInterface, PluginOptions, Register } from 'claude-code'
7
8import { asRailUi, asSnapshot, bandLines, parseJson, platformRootFrom, summaryText } from './lib'
9
10const snapshot = atom({ plugin: 'sg-rail', key: 'snapshot' } as const, null)
11const health = atom({ plugin: 'sg-rail', key: 'health' } as const, { hermes: null, omniroute: null })
12const rail = atom({ plugin: 'sg-rail', key: 'rail' } as const, null)
13const error = atom({ plugin: 'sg-rail', key: 'error' } as const, null)
14const isHidden = atom({ plugin: 'sg-rail', key: 'isHidden' } as const, false)
15
16const REFRESH_MS = 30_000
17const PROBE_MS = 2_500
18const SNAPSHOT_TIMEOUT_MS = 15_000
19
20// One refresh at a time: a caller that arrives mid-refresh waits for the one in flight
21let inflight: Promise<void> | null = null
22
23async function settingsOf($: EngineInterface, options: PluginOptions) {
24 const root = String(options.platformRoot || '') || platformRootFrom($.plugin.root)
25 const tenant = String(options.tenant || '') || (await $.env.get('SNOWGLOVES_TENANT')) || ''
26 const dataRoot = String(options.dataRoot || '') || (await $.env.get('SNOWGLOVES_DATA')) || ''
27 const venv = root + '/.venv/bin/python'
28 const python = (await $.fs.exists(venv)) ? venv : 'python3'
29 return { root, tenant, dataRoot, python }
30}
31
32async function probe($: EngineInterface, url: string): Promise<boolean> {
33 const answered = $.http.fetch(url).then(
34 (response) => response.ok,
35 () => false,
36 )
37 const timedOut = $.clock.sleep(PROBE_MS).then(() => false)
38 return Promise.race([answered, timedOut])
39}
40
41function refresh($: EngineInterface, options: PluginOptions): Promise<void> {
42 if (!inflight) inflight = refreshOnce($, options).finally(() => (inflight = null))
43 return inflight
44}
45
46// Never rejects: it runs from timers and unawaited calls, where nothing would handle a rejection
47async function refreshOnce($: EngineInterface, options: PluginOptions) {
48 try {
49 const cfg = await settingsOf($, options)
50 const argv = [cfg.python, cfg.root + '/scripts/sg_mods.py', 'snapshot', '--cwd', await $.session.cwd()]
51 if (cfg.tenant) argv.push('--tenant', cfg.tenant)
52 if (cfg.dataRoot) argv.push('--data-root', cfg.dataRoot)
53 const run = await $.process.run(argv, { cwd: cfg.root, timeoutMs: SNAPSHOT_TIMEOUT_MS })
54 const snap = asSnapshot(parseJson(run.stdout))
55 await update($, error, () => (snap ? null : run.stderr.trim().split('\n').pop() || 'exit ' + run.exitCode))
56 if (snap) {
57 await update($, snapshot, () => snap)
58 const [hermes, omniroute] = await Promise.all([
59 probe($, snap.endpoints.hermes + '/healthz'),
60 probe($, snap.endpoints.omniroute + '/healthz'),
61 ])
62 await update($, health, () => ({ hermes, omniroute }))
63 }
64 } catch (err) {
65 const reason = String(err instanceof Error ? err.message : err)
66 await update($, error, () => reason).catch(() => undefined)
67 }
68}
69
70// Never rejects, for the same reason as refresh
71async function readRail($: EngineInterface) {
72 try {
73 const home = await $.env.get('HOME')
74 if (!home) return
75 const path = home + '/.claude/MEMORY/STATE/rail/' + (await $.session.id()) + '.ui.json'
76 if (!(await $.fs.exists(path))) return
77 const ui = asRailUi(parseJson(await $.fs.read(path)))
78 if (ui) await update($, rail, () => ui)
79 } catch {
80 // An unreadable sink leaves the last rail on screen
81 }
82}
83
84async function openApprovals($: EngineInterface) {
85 const commands = await $.command.list()
86 if (!commands.some((command) => command.name === 'approvals')) {
87 $.ui.toast('Install sg-approvals for /approvals')
88 return
89 }
90 await $.command.run({ command: 'approvals' })
91}
92
93export const register: Register = (on, options) => {
94 on('session.start', async ($, e, next) => {
95 // PromptProcessing writes the rail to a file instead of Claude's context while this is set
96 await $.env.set('TEMPERANCE_RAIL_SINK', 'file')
97 $.clock.every(REFRESH_MS, async () => {
98 await refresh($, options)
99 await readRail($)
100 })
101 void refresh($, options)
102 void readRail($)
103 await $.command.register({
104 name: 'sg',
105 description: 'Snow Gloves status: tenant, data root, services, approvals, rail',
106 argumentHint: '[show|hide]',
107 immediate: true,
108 })
109 return next(e)
110 })
111
112 // /clear, /resume and /branch reset $.state, so read everything again
113 on('classic.SessionStart', { source: ['clear', 'resume', 'fork'] }, async ($, e, next) => {
114 void refresh($, options)
115 void readRail($)
116 return next(e)
117 })
118
119 // PromptProcessing writes the sink while the prompt is submitted
120 on('turn.start', async ($, e, next) => {
121 void readRail($)
122 return next(e)
123 })
124
125 on('command.run', { command: 'sg' }, async ($, e) => {
126 const arg = e.args.trim()
127 if (arg === 'hide' || arg === 'show') {
128 await update($, isHidden, () => arg === 'hide')
129 return { text: 'Band ' + (arg === 'hide' ? 'hidden' : 'shown') }
130 }
131 await refresh($, options)
132 await readRail($)
133 return {
134 text: summaryText(await read($, snapshot), await read($, health), await read($, rail), await read($, error)),
135 }
136 })
137
138 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
139 const snap = await read($, snapshot)
140 const reason = await read($, error)
141 if (e.props.hasSurvey || (await read($, isHidden)) || (snap === null && reason === null)) return next(e)
142 const lines = bandLines(snap, await read($, health), await read($, rail), reason, e.props.bodyColumns)
143 const { Box, Button, Text } = $.ui.resolve(e)
144 const theirs = await next(e)
145 return (
146 <Box flexDirection="column">
147 {lines.map((line, i) => (
148 <Text dimColor={i > 0} wrap="truncate-end">
149 {line}
150 </Text>
151 ))}
152 <Box flexDirection="row" columnGap={2}>
153 <Button key="sg-approvals" label="approvals" hotkey="a" plain onPress={() => openApprovals($)} />
154 <Button key="sg-hide" label="hide" hotkey="h" plain onPress={() => update($, isHidden, () => true)} />
155 </Box>
156 {theirs}
157 </Box>
158 )
159 })
160}
161hooks/lib.ts 131 lines1// Pure helpers for sg-rail. Nothing here calls the mods API, so tests can import them directly.
2import type { Health, RailUi, Snapshot } from '../types'
3
4export const SNAPSHOT_SCHEMA = 'snowgloves.mods-snapshot.v1'
5export const RAIL_UI_SCHEMA = 'temperance.rail-ui.v1'
6
7// mods/<name> sits two folders under the platform checkout
8export function platformRootFrom(pluginRoot: string): string {
9 const parts = pluginRoot.replace(/\/+$/, '').split('/')
10 return parts.slice(0, -2).join('/') || '/'
11}
12
13export function parseJson(text: string): unknown {
14 try {
15 return JSON.parse(text)
16 } catch {
17 return null
18 }
19}
20
21export function asSnapshot(value: unknown): Snapshot | null {
22 if (!value || typeof value !== 'object') return null
23 const snap = value as Snapshot
24 return snap.schema === SNAPSHOT_SCHEMA && typeof snap.endpoints === 'object' ? snap : null
25}
26
27export function asRailUi(value: unknown): RailUi | null {
28 if (!value || typeof value !== 'object') return null
29 const ui = value as Record<string, unknown>
30 if (ui.schema !== RAIL_UI_SCHEMA) return null
31 return {
32 rail: typeof ui.rail === 'string' ? ui.rail : '',
33 manifest: typeof ui.manifest_runtime === 'string' ? ui.manifest_runtime : '',
34 updatedAt: typeof ui.updated_at === 'string' ? ui.updated_at : '',
35 }
36}
37
38function field(text: string, name: string): string | null {
39 const match = new RegExp('^\\s*·\\s*' + name + '\\s+(.+?)\\s*$', 'm').exec(text)
40 return match ? match[1] : null
41}
42
43// "♄ RAIL · NIGREDO · OBSERVE · 1/7" plus mode, combo and head, on one line
44export function railLine(text: string): string | null {
45 const header = /RAIL\s*·\s*(.+?)\s*$/m.exec(text)
46 if (!header) return null
47 const bits = ['♄ ' + header[1]]
48 const mode = field(text, 'mode')
49 const combo = field(text, 'combo')
50 const head = field(text, 'head')
51 if (mode) bits.push(mode)
52 if (combo) bits.push('combo ' + combo)
53 if (head) bits.push('head ' + head)
54 return bits.join(' · ')
55}
56
57// "☿ MANIFEST · OFFLINE" plus the omniroute row, on one line
58export function manifestLine(text: string): string | null {
59 const header = /MANIFEST\s*·\s*(\S+)/.exec(text)
60 if (!header) return null
61 const omniroute = field(text, 'omniroute')
62 const route = omniroute ? ' · omniroute ' + omniroute.split(' ')[0] : ''
63 return '☿ manifest ' + header[1].toLowerCase() + route
64}
65
66export function dot(ok: boolean | null): string {
67 return ok === null ? '·' : ok ? '●' : '○'
68}
69
70export function dataLabel(snap: Snapshot): string {
71 if (snap.data_root_source === 'code-fallback') return 'fixtures'
72 return snap.data_root.split('/').filter(Boolean).pop() || snap.data_root
73}
74
75export function fit(text: string, columns: number): string {
76 if (!(columns > 1) || text.length <= columns) return text
77 return text.slice(0, columns - 1) + '…'
78}
79
80export function statusLine(snap: Snapshot, health: Health): string {
81 const bits = [
82 'SG ' + (snap.tenant ?? 'no tenant'),
83 'data ' + dataLabel(snap),
84 'hermes ' + dot(health.hermes),
85 'omniroute ' + dot(health.omniroute),
86 'approvals ' + snap.approvals.pending_total,
87 ]
88 if (snap.walk) bits.push('walk ' + snap.walk.verdict)
89 if (snap.isa) bits.push('ISA ' + snap.isa.checked + '/' + snap.isa.total)
90 return bits.join(' · ')
91}
92
93export function bandLines(
94 snap: Snapshot | null,
95 health: Health,
96 rail: RailUi | null,
97 error: string | null,
98 columns: number,
99): string[] {
100 const lines: string[] = []
101 if (snap) lines.push(statusLine(snap, health))
102 else if (error) lines.push('SG snapshot failed: ' + error)
103 const railText = rail ? railLine(rail.rail) : null
104 const manifestText = rail ? manifestLine(rail.manifest) : null
105 if (railText) lines.push(railText)
106 if (manifestText) lines.push(manifestText)
107 return lines.map((line) => fit(line, columns))
108}
109
110export function summaryText(
111 snap: Snapshot | null,
112 health: Health,
113 rail: RailUi | null,
114 error: string | null,
115): string {
116 if (!snap) return 'Snapshot unavailable' + (error ? ': ' + error : '')
117 const lines = [
118 statusLine(snap, health),
119 'tenant: ' + (snap.tenant ?? 'none') + ' (' + snap.tenant_source + ')',
120 'data root: ' + snap.data_root + ' (' + snap.data_root_source + ')',
121 'hermes: ' + snap.endpoints.hermes + ' ' + dot(health.hermes),
122 'omniroute: ' + snap.endpoints.omniroute + ' ' + dot(health.omniroute),
123 ]
124 const byTenant = Object.entries(snap.approvals.by_tenant)
125 if (byTenant.length > 0) lines.push('pending approvals: ' + byTenant.map(([t, n]) => t + ' ' + n).join(', '))
126 const railText = rail ? railLine(rail.rail) : null
127 if (railText) lines.push(railText)
128 for (const warning of snap.warnings) lines.push('warning: ' + warning)
129 return lines.join('\n')
130}
131types/index.d.ts 33 lines1// What scripts/sg_mods.py snapshot prints (schema snowgloves.mods-snapshot.v1), trimmed to what the band reads.
2export type Snapshot = {
3 schema: 'snowgloves.mods-snapshot.v1'
4 data_root: string
5 data_root_source: 'flag' | 'env' | 'code-fallback'
6 tenant: string | null
7 tenant_source: 'flag' | 'project-match' | 'none'
8 tenants: string[]
9 approvals: { pending_total: number; by_tenant: Record<string, number> }
10 walk: { verdict: string; events: number; loops: number } | null
11 isa: { checked: number; total: number } | null
12 endpoints: { hermes: string; omniroute: string }
13 warnings: string[]
14}
15
16// null until probed, then whether /healthz answered ok
17export type Health = { hermes: boolean | null; omniroute: boolean | null }
18
19// The Temperance rail, read from ~/.claude/MEMORY/STATE/rail/<session>.ui.json (schema temperance.rail-ui.v1)
20export type RailUi = { rail: string; manifest: string; updatedAt: string }
21
22declare module 'claude-code' {
23 interface PluginState {
24 'sg-rail': {
25 snapshot: Snapshot | null
26 health: Health
27 rail: RailUi | null
28 error: string | null
29 isHidden: boolean
30 }
31 }
32}
33