Snow Gloves catalog: /sg-catalog browses the module catalog and enables a card for a tenant after you confirm; /sg-mod-review drafts a hold card for a…

<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 174 lines1// sg-catalog: the catalog browser and the intake for third-party mods.
2// /sg-catalog a pane over catalog/modules.json with category and disposition filters. Enable runs
3// scripts/onboard.py --tenant T --enable ID after a confirmation. hold and refuse cards
4// show their refusal and no button, so the connector gate's rule is visible here too.
5// /sg-mod-review PATH runs `claude plugin validate --json` on a third-party mod and has sg_mods.py draft-card
6// write a hold card with what the mod hooks and calls. Nothing is installed or enabled.
7import { atom, read, update } from 'claude-code'
8import type { EngineInterface, PluginOptions, Register } from 'claude-code'
9
10import type { Card } from '../types'
11import { ALL, SHOWN, canEnable, cardIdFor, cardLine, distinct, draftResult, filterCards, listText, platformRootFrom, refusal, tableFrom } from './lib'
12
13const PANE = 'sg-catalog'
14const RUN_TIMEOUT_MS = 30_000
15
16const cards = atom({ plugin: 'sg-catalog', key: 'cards' } as const, [])
17const enabled = atom({ plugin: 'sg-catalog', key: 'enabled' } as const, [])
18const tenantName = atom({ plugin: 'sg-catalog', key: 'tenant' } as const, null)
19const category = atom({ plugin: 'sg-catalog', key: 'category' } as const, 'all')
20const disposition = atom({ plugin: 'sg-catalog', key: 'disposition' } as const, 'all')
21const error = atom({ plugin: 'sg-catalog', key: 'error' } as const, null)
22const note = atom({ plugin: 'sg-catalog', key: 'note' } as const, null)
23
24let pluginOptions: PluginOptions = {}
25let isWorking = false
26
27async function settingsOf($: EngineInterface) {
28 const root = String(pluginOptions.platformRoot || '') || platformRootFrom($.plugin.root)
29 const dataRoot = String(pluginOptions.dataRoot || '') || (await $.env.get('SNOWGLOVES_DATA')) || ''
30 const tenant = String(pluginOptions.tenant || '') || (await $.env.get('SNOWGLOVES_TENANT')) || ''
31 const venv = root + '/.venv/bin/python'
32 const python = (await $.fs.exists(venv)) ? venv : 'python3'
33 return { root, dataRoot, tenant, python }
34}
35
36// Never rejects
37async function load($: EngineInterface) {
38 try {
39 const cfg = await settingsOf($)
40 const argv = [cfg.python, cfg.root + '/scripts/sg_mods.py', 'catalog']
41 if (cfg.tenant) argv.push('--tenant', cfg.tenant)
42 if (cfg.dataRoot) argv.push('--data-root', cfg.dataRoot)
43 const run = await $.process.run(argv, { cwd: cfg.root, timeoutMs: RUN_TIMEOUT_MS })
44 const table = tableFrom(run.stdout)
45 if (table === null) {
46 await update($, error, () => run.stdout.trim() || run.stderr.trim().split('\n').pop() || 'exit ' + run.exitCode)
47 return
48 }
49 await update($, cards, () => table.cards)
50 await update($, enabled, () => table.enabled)
51 await update($, tenantName, () => table.tenant)
52 await update($, error, () => null)
53 } catch (err) {
54 await update($, error, () => String(err instanceof Error ? err.message : err)).catch(() => undefined)
55 }
56}
57
58async function enable($: EngineInterface, card: Card) {
59 if (isWorking) return
60 isWorking = true
61 try {
62 const cfg = await settingsOf($)
63 if (!cfg.tenant) {
64 await update($, note, () => 'No tenant: set SNOWGLOVES_TENANT or the tenant option')
65 return
66 }
67 let answer: string | undefined
68 try {
69 answer = await $.ui.ask('Enable ' + card.id + ' (risk ' + card.risk + ') for ' + cfg.tenant + '?', ['Enable', 'Cancel'])
70 } catch {
71 answer = undefined
72 }
73 if (answer !== 'Enable') {
74 await update($, note, () => 'Left ' + card.id + ' disabled')
75 return
76 }
77 const argv = [cfg.python, cfg.root + '/scripts/onboard.py', '--tenant', cfg.tenant, '--enable', card.id]
78 if (cfg.dataRoot) argv.push('--data', cfg.dataRoot)
79 const run = await $.process.run(argv, { cwd: cfg.root, timeoutMs: RUN_TIMEOUT_MS })
80 const text = run.exitCode === 0 ? 'Enabled ' + card.id + ' for ' + cfg.tenant : 'Could not enable ' + card.id + ': ' + (run.stderr.trim().split('\n').pop() || run.stdout.trim().split('\n').pop() || 'exit ' + run.exitCode)
81 await update($, note, () => text)
82 if (run.exitCode === 0) $.ui.toast(text)
83 await load($)
84 } catch (err) {
85 await update($, note, () => 'Could not enable ' + card.id + ': ' + String(err instanceof Error ? err.message : err))
86 } finally {
87 isWorking = false
88 }
89}
90
91async function review($: EngineInterface, path: string): Promise<string> {
92 const target = path.trim()
93 if (!target) return 'Usage: /sg-mod-review <path to a mod folder>'
94 const id = cardIdFor(target)
95 if (!id) return 'Cannot name a card from that path.'
96 const cfg = await settingsOf($)
97 const validate = await $.process.run(['claude', 'plugin', 'validate', '--json', target], { cwd: cfg.root, timeoutMs: RUN_TIMEOUT_MS })
98 if (!validate.stdout.trim().startsWith('{')) return 'Validate printed no report: ' + (validate.stderr.trim().split('\n').pop() || 'exit ' + validate.exitCode)
99 const run = await $.process.run([cfg.python, cfg.root + '/scripts/sg_mods.py', 'draft-card', '--id', id, '--source', target], {
100 cwd: cfg.root,
101 stdin: validate.stdout,
102 timeoutMs: RUN_TIMEOUT_MS,
103 })
104 const drafted = draftResult(run.stdout)
105 if ('error' in drafted) return 'No card drafted: ' + drafted.error
106 const flags = drafted.flags.length ? 'Flags: ' + drafted.flags.join(', ') + '.' : 'No rule flags.'
107 return 'Drafted a hold card: ' + drafted.card + '. ' + flags + ' Nothing was installed or enabled; review the card, then run scripts/build_catalog.py.'
108}
109
110export const register: Register = (on, options) => {
111 pluginOptions = options
112
113 on('session.start', async ($, e, next) => {
114 await $.command.register({ name: 'sg-catalog', description: 'Browse the Snow Gloves catalog and enable a card', immediate: true })
115 await $.command.register({ name: 'sg-mod-review', description: 'Draft a hold card for a third-party mod folder', argumentHint: '<path>', immediate: false })
116 return next(e)
117 })
118
119 on('command.run', { command: 'sg-catalog' }, async ($) => {
120 await load($)
121 const drawn = (await $.session.surfaces()).length > 0
122 const placed = drawn ? await $.ui.open({ id: PANE, title: 'Catalog', focus: true, closeOnEscape: true }) : null
123 if (placed && placed.isPlaced) return {}
124 const reason = await read($, error)
125 if (reason !== null) return { text: 'Catalog unavailable: ' + reason }
126 return { text: listText(await read($, cards), await read($, enabled), await read($, tenantName)) }
127 })
128
129 on('command.run', { command: 'sg-mod-review' }, async ($, e) => {
130 try {
131 return { text: await review($, e.args) }
132 } catch (err) {
133 return { text: 'Review failed: ' + String(err instanceof Error ? err.message : err) }
134 }
135 })
136
137 on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
138 const { Box, Button, Select, Text } = $.ui.resolve(e)
139 const all: Card[] = await read($, cards)
140 const on_ = await read($, enabled)
141 const tenant = await read($, tenantName)
142 const cat = await read($, category)
143 const disp = await read($, disposition)
144 const reason = await read($, error)
145 const last = await read($, note)
146 const shown = filterCards(all, cat, disp)
147 return (
148 <Box flexDirection="column">
149 <Box flexDirection="row" columnGap={2}>
150 <Text bold>{'Catalog' + (tenant ? ' for ' + tenant : '') + ': ' + shown.length + ' of ' + all.length + ' cards, ' + on_.length + ' enabled'}</Text>
151 <Button key="reload" label="reload" hotkey="r" plain onPress={() => load($)} />
152 </Box>
153 <Box flexDirection="row" columnGap={2}>
154 <Select key="filter-category" label="category" value={cat} options={distinct(all, 'category').map((v) => ({ value: v, label: v }))} onSelect={(v) => update($, category, () => v)} />
155 <Select key="filter-disposition" label="disposition" value={disp} options={distinct(all, 'disposition').map((v) => ({ value: v, label: v }))} onSelect={(v) => update($, disposition, () => v)} />
156 </Box>
157 {reason !== null && <Text color="red">{'Catalog unavailable: ' + reason}</Text>}
158 {shown.slice(0, SHOWN).map((card) => (
159 <Box flexDirection="column" key={'card-' + card.id}>
160 <Text wrap="truncate-end">{cardLine(card, on_)}</Text>
161 <Box flexDirection="row" columnGap={2}>
162 <Text dimColor wrap="truncate-end">{' ' + card.summary}</Text>
163 {canEnable(card, on_) && <Button key={'enable-' + card.id} label="enable" onPress={() => enable($, card)} />}
164 {refusal(card) !== null && !on_.includes(card.id) && <Text color="yellow">{refusal(card)}</Text>}
165 </Box>
166 </Box>
167 ))}
168 {shown.length > SHOWN && <Text dimColor>{shown.length - SHOWN + ' more: narrow the filters'}</Text>}
169 {last !== null && <Text dimColor>{last}</Text>}
170 </Box>
171 )
172 })
173}
174hooks/lib.ts 69 lines1// Pure helpers for sg-catalog. No $ here.
2import type { Card } from '../types'
3
4export const ALL = 'all'
5export const SHOWN = 40
6
7export function platformRootFrom(pluginRoot: string): string {
8 return pluginRoot.split('/').slice(0, -2).join('/')
9}
10
11export type Table = { cards: Card[]; enabled: string[]; tenant: string | null }
12
13export function tableFrom(stdout: string): Table | null {
14 try {
15 const data = JSON.parse(stdout)
16 if (!data || !Array.isArray(data.cards)) return null
17 return { cards: data.cards, enabled: Array.isArray(data.enabled) ? data.enabled : [], tenant: typeof data.tenant === 'string' ? data.tenant : null }
18 } catch {
19 return null
20 }
21}
22
23export function filterCards(cards: Card[], category: string, disposition: string): Card[] {
24 return cards.filter((c) => (category === ALL || c.category === category) && (disposition === ALL || c.disposition === disposition))
25}
26
27export function distinct(cards: Card[], field: 'category' | 'disposition'): string[] {
28 return [ALL, ...[...new Set(cards.map((c) => c[field]))].sort()]
29}
30
31// hold and refuse cards are never enabled; a card the catalog marks not enableable (pointers, playbooks) has no button either.
32export function canEnable(card: Card, enabled: string[]): boolean {
33 return card.enableable && (card.disposition === 'add') && !enabled.includes(card.id)
34}
35
36export function refusal(card: Card): string | null {
37 if (card.disposition === 'refuse') return 'refused: the platform never enables this'
38 if (card.disposition === 'hold') return 'on hold: review the card first; it is not enabled'
39 if (card.disposition === 'pointer') return 'pointer only: nothing to enable'
40 if (!card.enableable) return 'not enableable'
41 return null
42}
43
44export function cardLine(card: Card, enabled: string[]): string {
45 const mark = enabled.includes(card.id) ? '● ' : ' '
46 return mark + card.id + ' ' + card.disposition + ' ' + card.category + ' risk ' + card.risk + (card.approval === 'yes' ? ' approval' : '')
47}
48
49export function listText(cards: Card[], enabled: string[], tenant: string | null): string {
50 const head = 'Catalog' + (tenant ? ' for ' + tenant : '') + ': ' + cards.length + ' cards, ' + enabled.length + ' enabled'
51 return [head, ...cards.slice(0, SHOWN).map((c) => cardLine(c, enabled))].join('\n')
52}
53
54// A card id for a third-party mod folder: its basename, lower-cased, safe characters only.
55export function cardIdFor(path: string): string {
56 const base = path.replace(/\/+$/, '').split('/').pop() || ''
57 return base.toLowerCase().replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '')
58}
59
60export function draftResult(stdout: string): { card: string; flags: string[] } | { error: string } {
61 try {
62 const out = JSON.parse(stdout)
63 if (typeof out.card === 'string') return { card: out.card, flags: Array.isArray(out.flags) ? out.flags : [] }
64 return { error: String(out.error || 'draft-card returned no card') }
65 } catch {
66 return { error: 'draft-card printed no JSON' }
67 }
68}
69types/index.d.ts 28 lines1// One catalog card as scripts/sg_mods.py catalog lists it (no body).
2export type Card = {
3 id: string
4 name: string
5 category: string
6 kind: string
7 disposition: string
8 risk: string
9 approval: string
10 agents: string[]
11 summary: string
12 enableable: boolean
13}
14
15declare module 'claude-code' {
16 interface PluginState {
17 'sg-catalog': {
18 cards: Card[]
19 enabled: string[]
20 tenant: string | null
21 category: string
22 disposition: string
23 error: string | null
24 note: string | null
25 }
26 }
27}
28