gm-copilot-cli 2.0.727 → 2.0.1064
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/gm.md +1 -3
- package/agents/memorize.md +22 -2
- package/copilot-profile.md +1 -1
- package/hooks/hooks.json +10 -8
- package/hooks/hooks.spec.json +65 -0
- package/index.html +5 -3
- package/manifest.yml +1 -1
- package/package.json +2 -2
- package/skills/browser/SKILL.md +18 -16
- package/skills/code-search/SKILL.md +15 -15
- package/skills/create-lang-plugin/SKILL.md +22 -26
- package/skills/gm/SKILL.md +31 -66
- package/skills/gm-cc/SKILL.md +19 -0
- package/skills/gm-codex/SKILL.md +19 -0
- package/skills/gm-complete/SKILL.md +52 -69
- package/skills/gm-copilot-cli/SKILL.md +19 -0
- package/skills/gm-cursor/SKILL.md +19 -0
- package/skills/gm-emit/SKILL.md +44 -61
- package/skills/gm-execute/SKILL.md +42 -84
- package/skills/gm-gc/SKILL.md +19 -0
- package/skills/gm-jetbrains/SKILL.md +19 -0
- package/skills/gm-kilo/SKILL.md +19 -0
- package/skills/gm-oc/SKILL.md +19 -0
- package/skills/gm-vscode/SKILL.md +19 -0
- package/skills/gm-zed/SKILL.md +19 -0
- package/skills/governance/SKILL.md +24 -23
- package/skills/pages/SKILL.md +42 -92
- package/skills/planning/SKILL.md +83 -80
- package/skills/research/SKILL.md +43 -0
- package/skills/ssh/SKILL.md +15 -9
- package/skills/textprocessing/SKILL.md +40 -0
- package/skills/update-docs/SKILL.md +27 -21
- package/tools.json +1 -1
- package/.github/workflows/publish-npm.yml +0 -44
- package/hooks/post-tool-use-hook.js +0 -34
- package/hooks/pre-tool-use-hook.js +0 -45
- package/hooks/prompt-submit-hook.js +0 -19
package/skills/planning/SKILL.md
CHANGED
|
@@ -1,92 +1,97 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: planning
|
|
3
3
|
description: State machine orchestrator. Mutable discovery, PRD construction, and full PLAN→EXECUTE→EMIT→VERIFY→COMPLETE lifecycle. Invoke at session start and on any new unknown.
|
|
4
|
-
allowed-tools:
|
|
4
|
+
allowed-tools: Skill
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
# Planning —
|
|
7
|
+
# Planning — PLAN phase
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Translate the request into `.gm/prd.yml` and hand to `gm-execute`. Re-enter on any new unknown in any phase.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
A `@<discipline>` sigil in the request scopes recall, codesearch, and memorize calls during PLAN to that discipline's store. Without one, retrievals fan across default plus enabled disciplines and writes land in default only.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Cross-cutting dispositions (autonomy, fix-on-sight, nothing-fake, browser-witness, scope, recall, memorize) live in `gm` SKILL.md; this skill only carries what is unique to PLAN.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
exec:recall
|
|
17
|
-
<2-6 word query>
|
|
18
|
-
```
|
|
15
|
+
## Transitions
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
- PLAN done → `gm-execute`
|
|
18
|
+
- New unknown anywhere in chain → re-enter PLAN
|
|
19
|
+
- EXECUTE unresolvable after 2 passes → PLAN
|
|
20
|
+
- VERIFY: `.prd` empty + git clean + pushed → `update-docs`; else → `gm-execute`
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Cannot stop while `.gm/prd.yml` has items, git is dirty, or commits are unpushed.
|
|
23
23
|
|
|
24
|
-
##
|
|
24
|
+
## Session start: restart spool watcher
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
Before any orient or PRD work, ensure the spool watcher is running. Check `.gm/exec-spool/.watcher.heartbeat` — if older than 30s, the watcher is dead. Restart it:
|
|
27
27
|
|
|
28
28
|
```
|
|
29
|
-
|
|
29
|
+
# write .gm/exec-spool/in/nodejs/restart-watcher.js
|
|
30
|
+
const { spawn, spawnSync } = require('child_process');
|
|
31
|
+
const fs = require('fs');
|
|
32
|
+
const path = require('path');
|
|
33
|
+
const os = require('os');
|
|
34
|
+
const bin = path.join(os.homedir(), '.claude', 'gm-tools', process.platform === 'win32' ? 'plugkit.exe' : 'plugkit');
|
|
35
|
+
const root = process.cwd();
|
|
36
|
+
const spoolIn = path.join(root, '.gm', 'exec-spool', 'in');
|
|
37
|
+
const spoolOut = path.join(root, '.gm', 'exec-spool', 'out');
|
|
38
|
+
const pidFile = path.join(os.tmpdir(), 'gm-plugkit-spool.pid');
|
|
39
|
+
if (fs.existsSync(pidFile)) {
|
|
40
|
+
const pid = parseInt(fs.readFileSync(pidFile, 'utf8').trim(), 10);
|
|
41
|
+
if (Number.isFinite(pid)) { try { process.kill(pid); } catch (_) {} }
|
|
42
|
+
try { fs.unlinkSync(pidFile); } catch (_) {}
|
|
43
|
+
}
|
|
44
|
+
if (process.platform === 'win32') {
|
|
45
|
+
try { spawnSync('taskkill', ['/F', '/IM', 'plugkit.exe'], { windowsHide: true, timeout: 3000, stdio: 'ignore' }); } catch (_) {}
|
|
46
|
+
} else {
|
|
47
|
+
try { spawnSync('pkill', ['-f', 'plugkit'], { timeout: 3000, stdio: 'ignore' }); } catch (_) {}
|
|
48
|
+
}
|
|
49
|
+
fs.mkdirSync(spoolIn, { recursive: true });
|
|
50
|
+
fs.mkdirSync(spoolOut, { recursive: true });
|
|
51
|
+
const proc = spawn(bin, ['runner', '--watch', spoolIn, '--out', spoolOut], {
|
|
52
|
+
detached: true, stdio: 'ignore', windowsHide: true, cwd: root,
|
|
53
|
+
});
|
|
54
|
+
proc.unref();
|
|
55
|
+
fs.writeFileSync(pidFile, String(proc.pid));
|
|
30
56
|
```
|
|
31
57
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
N facts → N parallel Agent calls in ONE message.
|
|
35
|
-
|
|
36
|
-
## STATE MACHINE
|
|
37
|
-
|
|
38
|
-
**FORWARD**: PLAN → `gm-execute` | EXECUTE → `gm-emit` | EMIT → `gm-complete` | VERIFY .prd remains → `gm-execute` | VERIFY .prd empty+pushed → `update-docs`
|
|
39
|
-
|
|
40
|
-
**REGRESSIONS**: new unknown anywhere → `planning` | EXECUTE unresolvable 2 passes → `planning` | EMIT logic error → `gm-execute` | VERIFY broken output → `gm-emit` | VERIFY logic wrong → `gm-execute`
|
|
41
|
-
|
|
42
|
-
Runs until: .gm/prd.yml empty AND git clean AND all pushes confirmed AND CI green.
|
|
43
|
-
|
|
44
|
-
## AUTONOMY — HARD RULE
|
|
45
|
-
|
|
46
|
-
PRD written → execute to COMPLETE without asking the user. No "should I continue", no "want me to do X next", no offering to split work.
|
|
47
|
-
|
|
48
|
-
Asking permitted only as last resort: destructive-irreversible with no PRD coverage, OR user intent unrecoverable from PRD/memory/code. Channel: `exec:pause` (renames prd.yml → prd.paused.yml; question in header). In-conversation asking last-resort.
|
|
49
|
-
|
|
50
|
-
**Cannot stop while**: .gm/prd.yml has items | git uncommitted | git unpushed.
|
|
58
|
+
Wait 2s for watcher to initialize, then proceed with orient.
|
|
51
59
|
|
|
52
|
-
##
|
|
60
|
+
## Orient
|
|
53
61
|
|
|
54
|
-
|
|
62
|
+
Open every plan with one parallel pack of recall + codesearch against the request's nouns. Write queries to `.gm/exec-spool/in/recall/<N>.txt` and `.gm/exec-spool/in/codesearch/<N>.txt`. Read results from `.gm/exec-spool/out/<N>.out`. Hits land as `weak_prior`; misses confirm the unknown is fresh. The pack runs in one message.
|
|
55
63
|
|
|
56
|
-
|
|
64
|
+
**Auto-recall injection (skills-only platforms)**: derive a 2–6 word query from the request's nouns (subject, verb objects, key domain terms). Write recall query to `.gm/exec-spool/in/recall/<N>.txt` at PLAN start before writing `.gm/prd.yml`. Read result from `.gm/exec-spool/out/<N>.out`. This replaces the prompt-submit hook's auto-recall for platforms without hook infrastructure. Recall hits are injected as context into mutable discovery and PRD item acceptance criteria.
|
|
57
65
|
|
|
58
|
-
|
|
66
|
+
## Mutable discovery
|
|
59
67
|
|
|
60
|
-
|
|
68
|
+
For each aspect of the work, ask: what do I not know, what could go wrong, what depends on what, what am I assuming. Unwitnessed assumptions are mutables.
|
|
61
69
|
|
|
62
|
-
|
|
70
|
+
Fault surfaces to scan: file existence, API shape, data format, dep versions, runtime behavior, env differences, error conditions, concurrency, integration seams, backwards compat, rollback paths, CI correctness.
|
|
63
71
|
|
|
64
|
-
|
|
72
|
+
Tag every item with a route family (grounding | reasoning | state | execution | observability | boundary | representation) and cross-reference the 16-failure taxonomy. `governance` skill holds the table.
|
|
65
73
|
|
|
66
|
-
|
|
74
|
+
`existingImpl=UNKNOWN` is the default; resolve via codesearch (write to `.gm/exec-spool/in/codesearch/<N>.txt`) before adding the item. An existing concern routes to consolidation, not addition.
|
|
67
75
|
|
|
68
|
-
|
|
76
|
+
Plan exits when zero new unknowns surfaced last pass AND every item has acceptance criteria AND deps are mapped.
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
## .gm/mutables.yml — co-equal with .gm/prd.yml
|
|
71
79
|
|
|
72
|
-
|
|
80
|
+
Every unknown surfaced during PLAN lands as an entry in `.gm/mutables.yml` the same pass. Live during work, deleted when empty. Hook-gated: Write/Edit/NotebookEdit and `git commit`/`git push` are hard-blocked while any entry has `status: unknown`; turn-stop is hard-blocked the same way.
|
|
73
81
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
Client: `window.__debug` live registry; modules register on mount.
|
|
82
|
-
|
|
83
|
-
`console.log` ≠ observability. Discovery of gap → add .prd item immediately, never deferred.
|
|
82
|
+
```yaml
|
|
83
|
+
- id: kebab-id
|
|
84
|
+
claim: One-line statement of what is assumed
|
|
85
|
+
witness_method: codesearch <query> | nodejs import | recall <query> | Read <path>
|
|
86
|
+
witness_evidence: ""
|
|
87
|
+
status: unknown
|
|
88
|
+
```
|
|
84
89
|
|
|
85
|
-
|
|
90
|
+
`status: unknown` → `witnessed` only when `witness_evidence` is filled with concrete proof (file:line, codesearch hit, dispatched test output). Resolution lives in gm-execute. PRD items reference mutables via optional `mutables: [id1, id2]` field; an item is blocked while any referenced mutable is unresolved.
|
|
86
91
|
|
|
87
|
-
## .
|
|
92
|
+
## .prd format
|
|
88
93
|
|
|
89
|
-
Path: `./.gm/prd.yml`. Write via `
|
|
94
|
+
Path: `./.gm/prd.yml`. Write via the Write tool or by emitting a nodejs spool file (`in/nodejs/<N>.js`) that calls `fs.writeFileSync`. Delete the file when empty.
|
|
90
95
|
|
|
91
96
|
```yaml
|
|
92
97
|
- id: kebab-id
|
|
@@ -108,44 +113,42 @@ Path: `./.gm/prd.yml`. Write via `exec:nodejs` + `fs.writeFileSync`. Delete when
|
|
|
108
113
|
- failure mode
|
|
109
114
|
```
|
|
110
115
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
Status: pending → in_progress → completed (remove). Effort: small <15min | medium <45min | large >1h.
|
|
114
|
-
|
|
115
|
-
## PARALLEL SUBAGENT LAUNCH
|
|
116
|
+
`load` is consequence-if-wrong: 0.9 = headline collapses, 0.7 = sub-argument rebuilt, 0.4 = local patch, 0.1 = nothing breaks. Verification budget = `load × (1 − tier_confidence)`. λ>0.75 must reach witnessed before EMIT.
|
|
116
117
|
|
|
117
|
-
|
|
118
|
+
`status`: pending → in_progress → completed (then remove). `effort`: small <15min | medium <45min | large >1h.
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
## Parallel subagent launch
|
|
120
121
|
|
|
121
|
-
|
|
122
|
+
After `.prd` is written, up to 3 parallel `gm:gm` subagents for independent items in one message. Browser tasks serialize.
|
|
122
123
|
|
|
123
|
-
|
|
124
|
+
```
|
|
125
|
+
Agent(subagent_type="gm:gm", prompt="Work on .prd item: <id>. .prd path: <path>. Item: <full YAML>.")
|
|
126
|
+
```
|
|
124
127
|
|
|
125
|
-
|
|
128
|
+
Items not parallelizable → invoke `gm-execute` directly.
|
|
126
129
|
|
|
127
|
-
|
|
130
|
+
## Observability gates in the plan
|
|
128
131
|
|
|
129
|
-
|
|
132
|
+
Server: every subsystem exposes `/debug/<subsystem>`; structured logs `{subsystem, severity, ts}`. Client: `window.__debug` live registry; modules register on mount. `console.log` is not observability. Discovery of a gap during PLAN adds a `.prd` item the same pass — never deferred.
|
|
130
133
|
|
|
131
|
-
|
|
134
|
+
`window.__debug` is THE in-page registry; `test.js` at project root is the sole out-of-page test asset. Any new file whose purpose is to exercise, smoke-test, demo, or sandbox in-page behavior outside that registry fights the discipline — extend the registry instead.
|
|
132
135
|
|
|
133
|
-
|
|
136
|
+
## Test discipline encoded in the plan
|
|
134
137
|
|
|
135
|
-
|
|
138
|
+
One `test.js` at project root, 200-line hard cap, real data, real system. No fixtures, mocks, or scattered tests. A second test runner under any name in any directory is a smuggled parallel surface.
|
|
136
139
|
|
|
137
|
-
|
|
140
|
+
The 200 lines are a *budget* for maximum surface coverage, not a target. Subsystems get one combined group each — names joined with `+` (`home+config+skin`, `mcp+swe+distributions+account+credpool`). When a new subsystem's failure mode overlaps an existing group's side-effects, fold the assertion in rather than creating a new group. When `wc -l test.js > 200`, the discipline is *merge groups + drop redundancy*, never split.
|
|
138
141
|
|
|
139
|
-
|
|
142
|
+
## Execution norms encoded in the plan
|
|
140
143
|
|
|
141
|
-
|
|
144
|
+
Code execution AND utility verbs both write to `.gm/exec-spool/in/<lang-or-verb>/<N>.<ext>`. Languages live under `in/<lang>/` (nodejs, python, bash, typescript, go, rust, c, cpp, java, deno); verbs live under `in/<verb>/` (codesearch, recall, memorize, wait, sleep, status, close, browser, runner, type, kill-port, forget, feedback, learn-status, learn-debug, learn-build, discipline, pause, health). The spool watcher runs the file and streams to `out/<N>.out` (stdout) + `out/<N>.err` (stderr) line-by-line, then writes `out/<N>.json` metadata (exitCode, durationMs, timedOut, startedAt, endedAt) at completion. Both streams return as systemMessage with `--- stdout ---` / `--- stderr ---` separators. `in/` and `out/` are wiped at session start and at real-exit session end. Only `git` (and `gh`) run directly via Bash; never `Bash(node/npm/npx/bun)`, never `Bash(exec:<anything>)`. Spool paths in nodejs files are platform-literal — use `os.tmpdir()` and `path.join`. The spool enforces per-task timeouts; on timeout, partial output is preserved and the watcher emits `[exec timed out after Nms; partial output above]`.
|
|
142
145
|
|
|
143
|
-
|
|
146
|
+
Codesearch only — Grep/Glob/Find/Explore are hook-blocked. Write to `.gm/exec-spool/in/codesearch/<N>.txt`. Start two words, change/add one per pass, minimum four attempts before concluding absent.
|
|
144
147
|
|
|
145
|
-
|
|
148
|
+
Pack runs use `Promise.allSettled`, each idea its own try/catch, under 12s per call.
|
|
146
149
|
|
|
147
|
-
##
|
|
150
|
+
## Dev workflow encoded in the plan
|
|
148
151
|
|
|
149
|
-
|
|
152
|
+
No comments. 200-line per-file cap. Fail loud. No duplication. Scan before edit. AGENTS.md edits route through the memorize sub-agent only. CHANGELOG.md gets one entry per commit.
|
|
150
153
|
|
|
151
|
-
|
|
154
|
+
Minimal-code process, stop at the first that resolves: native → library → structure (map / pipeline) → write.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: research
|
|
3
|
+
description: Web research via parallel subagent fan-out. Use when a question needs the live web, spans multiple sources, requires comparison across vendors/papers/repos, or would saturate a single context window. Skip for one-page lookups answerable by a single WebFetch.
|
|
4
|
+
allowed-tools: Skill
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Research
|
|
8
|
+
|
|
9
|
+
Declare the discipline before fetching anything. The first line of work names the `@<discipline>` the corpus belongs to — fresh material lives at `.gm/disciplines/<name>/corpus/raw/`, concise rewrites at `.gm/disciplines/<name>/corpus/concise/<chunk-id>.md`, the merged synthesis at `.gm/disciplines/<name>/deep-understanding.md`. A run without a discipline declaration falls back to the default store and the orchestrator says so in one line.
|
|
10
|
+
|
|
11
|
+
Lead orchestrates. Workers fetch. Findings converge on disk. The lead never reads pages — workers do.
|
|
12
|
+
|
|
13
|
+
Treat a thousand-document corpus with the same care as a codebase. Material above roughly ten pages — about eight thousand tokens — splits at paragraph boundaries into chunks each owned by one parallel `gm:research-worker` (haiku model). Each worker emits a fact-preserving concise rewrite to `corpus/concise/<chunk-id>.md` — every claim, number, name, caveat from the source survives, prose density rises, citations stay attached. Once every chunk returns, the lead merges into `deep-understanding.md` enumerating the opportunities the corpus opens and the reasonable opinionations it forces. Concise files and the merged document auto-ingest via `exec:memorize @<name>` so the next pass recalls instead of re-fetching.
|
|
14
|
+
|
|
15
|
+
Effort matches stakes. A single fact is one short fetch. A vendor comparison is a handful of workers, each owning one vendor. A landscape survey is ten or more, each owning one axis. Spending a fan-out on a fact wastes tokens; spending a fact-fetch on a landscape under-delivers.
|
|
16
|
+
|
|
17
|
+
Breadth first, depth on demand. Open with a wide sweep that maps the terrain, then commit deep dives only where the sweep surfaces something load-bearing. A narrow opening misses the alternative the user actually needed.
|
|
18
|
+
|
|
19
|
+
## Worker contract
|
|
20
|
+
|
|
21
|
+
Each worker receives the precise question it owns, the shape of the answer (bullets, table row, prose paragraph), the boundary of what it must not pursue, and the destination path under `.gm/research/<slug>/<worker-id>.md`. Workers write structured findings to disk and return only a path plus a one-line summary. The lead reads the paths it cares about; the rest stay on disk. Returning full prose through the agent boundary burns context that the synthesis pass needs.
|
|
22
|
+
|
|
23
|
+
Workers run in parallel — independent questions launch in one message, never serialized.
|
|
24
|
+
|
|
25
|
+
## Citations
|
|
26
|
+
|
|
27
|
+
A claim without a source URL is a hallucination waiting to be quoted. Workers attach the URL and the quoted span beside every non-trivial assertion. The lead refuses to lift a claim into the final answer if its citation field is empty.
|
|
28
|
+
|
|
29
|
+
## Source quality
|
|
30
|
+
|
|
31
|
+
Vendor docs, RFCs, primary repos, dated blog posts from named authors, and academic preprints beat aggregator pages. When two sources disagree, the older primary usually beats the newer aggregator.
|
|
32
|
+
|
|
33
|
+
## Convergence
|
|
34
|
+
|
|
35
|
+
Synthesis happens once, after all workers return. Mid-flight summarisation truncates findings the next worker would have built on. If a worker's return reveals a new axis the original plan missed, expand the fan-out — do not stretch an existing worker past its brief.
|
|
36
|
+
|
|
37
|
+
## When not to fan out
|
|
38
|
+
|
|
39
|
+
One question, one page, one fetch. A single `WebFetch` answers it. The fan-out machinery has overhead; spending it on a lookup is the same mistake as skipping it on a survey.
|
|
40
|
+
|
|
41
|
+
## Handoff
|
|
42
|
+
|
|
43
|
+
Final answer cites every load-bearing claim, names the workers' output paths for audit, and surfaces disagreements rather than averaging them away.
|
package/skills/ssh/SKILL.md
CHANGED
|
@@ -3,13 +3,14 @@ name: ssh
|
|
|
3
3
|
description: Run shell commands on remote SSH hosts via exec:ssh. Reads targets from ~/.claude/ssh-targets.json. Use for deploying, monitoring, or controlling remote machines.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# exec:ssh — Remote SSH
|
|
6
|
+
# exec:ssh — Remote SSH execution
|
|
7
7
|
|
|
8
|
-
Runs shell commands on remote host. No manual connection needed.
|
|
8
|
+
Runs shell commands on a remote host. No manual connection needed.
|
|
9
9
|
|
|
10
10
|
## Setup
|
|
11
11
|
|
|
12
12
|
`~/.claude/ssh-targets.json`:
|
|
13
|
+
|
|
13
14
|
```json
|
|
14
15
|
{
|
|
15
16
|
"default": { "host": "192.168.1.10", "port": 22, "username": "pi", "password": "pass" },
|
|
@@ -17,7 +18,7 @@ Runs shell commands on remote host. No manual connection needed.
|
|
|
17
18
|
}
|
|
18
19
|
```
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
`host` and `username` required. `port` defaults to 22. Auth: `password` OR `keyPath` + optional `passphrase`.
|
|
21
22
|
|
|
22
23
|
## Usage
|
|
23
24
|
|
|
@@ -26,28 +27,32 @@ exec:ssh
|
|
|
26
27
|
<shell command>
|
|
27
28
|
```
|
|
28
29
|
|
|
29
|
-
Named host with `@name` on first line:
|
|
30
|
+
Named host with `@name` on the first line:
|
|
31
|
+
|
|
30
32
|
```
|
|
31
33
|
exec:ssh
|
|
32
34
|
@prod
|
|
33
35
|
sudo systemctl restart myapp
|
|
34
36
|
```
|
|
35
37
|
|
|
36
|
-
## Process
|
|
38
|
+
## Process persistence
|
|
39
|
+
|
|
40
|
+
SSH kills child processes on close. To survive disconnect:
|
|
37
41
|
|
|
38
|
-
SSH kills child processes on close. To persist:
|
|
39
42
|
```
|
|
40
43
|
exec:ssh
|
|
41
44
|
sudo systemctl reset-failed myunit 2>/dev/null; systemd-run --unit=myunit bash -c 'your-command'
|
|
42
45
|
```
|
|
43
46
|
|
|
44
|
-
Unique name:
|
|
47
|
+
Unique unit name per launch:
|
|
48
|
+
|
|
45
49
|
```
|
|
46
50
|
exec:ssh
|
|
47
51
|
systemd-run --unit=job-$(date +%s) bash -c 'nohup myprogram &'
|
|
48
52
|
```
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
No-systemd fallback:
|
|
55
|
+
|
|
51
56
|
```
|
|
52
57
|
exec:ssh
|
|
53
58
|
setsid nohup bash -c 'myprogram > /tmp/out.log 2>&1' &
|
|
@@ -55,7 +60,8 @@ setsid nohup bash -c 'myprogram > /tmp/out.log 2>&1' &
|
|
|
55
60
|
|
|
56
61
|
## Dependency
|
|
57
62
|
|
|
58
|
-
Requires `ssh2`
|
|
63
|
+
Requires `ssh2` in `~/.claude/gm-tools`:
|
|
64
|
+
|
|
59
65
|
```
|
|
60
66
|
exec:bash
|
|
61
67
|
cd ~/.claude/gm-tools && npm install ssh2
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: textprocessing
|
|
3
|
+
description: The required surface for any text task whose correctness depends on understanding. Code does mechanics; this skill does meaning. Invoked via Agent(subagent_type='gm:textprocessing', model='haiku', ...).
|
|
4
|
+
allowed-tools: Skill
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Textprocessing — Meaning goes through Haiku
|
|
8
|
+
|
|
9
|
+
## Invocation
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Agent(subagent_type='gm:textprocessing', model='haiku', prompt='## INPUT\n<body>\n\n## INSTRUCTION\n<task>')
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Background fire-and-forget: add `run_in_background=true`. Batch: N parallel `Agent` calls in one message, one per item.
|
|
16
|
+
|
|
17
|
+
## The split
|
|
18
|
+
|
|
19
|
+
Mechanics stay in code: char/word/token/line counts, byte length, split on delimiter, exact-string find/replace, regex match/extract, sort, group-by-key, dedup-by-equality, lower/uppercase, JSON parse/stringify, base64, URL encode, hash, diff, format/pretty-print.
|
|
20
|
+
|
|
21
|
+
Meaning goes through this skill: summarize, classify, extract entities or intents, rewrite for tone or audience, translate, semantic dedup (same meaning, different words), rank or score by quality, label by topic, decide whether two texts are about the same thing, paraphrase, simplify, expand outline → prose, headline-from-body, body-from-headline, fact-from-passage, sentiment, toxicity, relevance, similarity-by-meaning.
|
|
22
|
+
|
|
23
|
+
The bar: would a human have to *read and understand* the text to do this correctly? Yes → skill. No → code. A keyword-list, a regex on phrases like "important", or a string-similarity ratio loop deciding meaning is a stub of this skill. Replace it with one (or N parallel) Agent calls.
|
|
24
|
+
|
|
25
|
+
## Batch
|
|
26
|
+
|
|
27
|
+
Independent items run in parallel — one Agent call per item, all in one message. The runner Promise-allSettles. Sequential calls are wasteful when items don't depend on each other.
|
|
28
|
+
|
|
29
|
+
For one large body exceeding a single-prompt budget, the *caller* chunks deterministically (paragraph, section, fixed token count), fans out one Agent per chunk, and merges with a final reducer Agent if cross-chunk synthesis is needed. The agent itself never chunks — it processes whatever it receives in one shot.
|
|
30
|
+
|
|
31
|
+
## Output contract
|
|
32
|
+
|
|
33
|
+
Plain-text instruction → plain-text output, no fences, no labels. JSON instruction → exactly that JSON, parseable by `JSON.parse`. Multi-document input requested as a list → one entry per input doc in the same order. Ambiguous shape → defaults to plain text. Empty input → empty output.
|
|
34
|
+
|
|
35
|
+
## Constraints
|
|
36
|
+
|
|
37
|
+
- Model fixed at `haiku`. Escalate to opus only when haiku output fails an acceptance check.
|
|
38
|
+
- One transform per call. Three parallel calls beats one prompt asking for "summarize AND classify AND translate".
|
|
39
|
+
- Idempotent: same input + same instruction → same output, modulo sampling. Strict determinism callers specify `temperature=0` in the prompt.
|
|
40
|
+
- Output is the deliverable. No commentary, no "here is your output".
|
|
@@ -5,24 +5,22 @@ description: UPDATE-DOCS phase. Refresh README.md, AGENTS.md, and docs/index.htm
|
|
|
5
5
|
|
|
6
6
|
# GM UPDATE-DOCS
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
Entry: feature verified, committed, pushed. From `gm-complete`.
|
|
8
|
+
Entry: feature verified, committed, pushed. Exit: docs match disk, committed, pushed → COMPLETE. Unknown architecture change → `planning`.
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
**BACKWARD**: unknown architecture change → `planning`
|
|
10
|
+
Every claim in docs is verifiable against disk. Phase names match frontmatter, platform names match `platforms/`, file paths exist, constraint counts are accurate. An unverifiable section is removed, not speculated.
|
|
13
11
|
|
|
14
12
|
## Sequence
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
What changed — run directly via Bash:
|
|
15
|
+
|
|
17
16
|
```
|
|
18
|
-
exec:bash
|
|
19
17
|
git log -5 --oneline
|
|
20
18
|
git diff HEAD~1 --stat
|
|
21
19
|
```
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
Read current docs via Read tool, or via a nodejs spool file (`in/nodejs/<N>.js`):
|
|
22
|
+
|
|
24
23
|
```
|
|
25
|
-
exec:nodejs
|
|
26
24
|
const fs = require('fs');
|
|
27
25
|
['README.md', 'AGENTS.md', 'docs/index.html', 'gm-starter/agents/gm.md'].forEach(f => {
|
|
28
26
|
try { console.log(`=== ${f} ===\n` + fs.readFileSync(f, 'utf8')); }
|
|
@@ -30,31 +28,39 @@ const fs = require('fs');
|
|
|
30
28
|
});
|
|
31
29
|
```
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
Write changed sections only:
|
|
32
|
+
|
|
33
|
+
- **README.md** — platform count, skill tree diagram, quick-start commands
|
|
34
|
+
- **AGENTS.md** — via `Agent(subagent_type='gm:memorize', model='haiku', run_in_background=true, prompt='## CONTEXT TO MEMORIZE\n<learnings>')`. Never inline-edit.
|
|
35
|
+
- **docs/index.html** — `PHASES` array, platform lists, state machine diagram
|
|
36
|
+
- **gm-starter/agents/gm.md** — skill chain line if new skills added
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
- **AGENTS.md**: via memorize sub-agent only — never inline-edit. `Agent(subagent_type='gm:memorize', model='haiku', run_in_background=true, prompt='## CONTEXT TO MEMORIZE\n<learnings>')`
|
|
37
|
-
- **docs/index.html**: `PHASES` array, platform lists, state machine diagram
|
|
38
|
-
- **gm-starter/agents/gm.md**: skill chain line if new skills added
|
|
38
|
+
Verify from disk (Read tool, or a nodejs spool file):
|
|
39
39
|
|
|
40
|
-
**4 — Verify from disk**:
|
|
41
40
|
```
|
|
42
|
-
exec:nodejs
|
|
43
41
|
const content = require('fs').readFileSync('/abs/path/file.md', 'utf8');
|
|
44
42
|
console.log(content.includes('expectedString'), content.length);
|
|
45
43
|
```
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
Commit and push directly via Bash:
|
|
46
|
+
|
|
48
47
|
```
|
|
49
|
-
exec:bash
|
|
50
48
|
git add README.md docs/index.html gm-starter/agents/gm.md
|
|
51
49
|
git commit -m "docs: update documentation to reflect session changes"
|
|
52
50
|
git push -u origin HEAD
|
|
53
51
|
```
|
|
54
52
|
|
|
55
|
-
##
|
|
53
|
+
## Exit: browser cleanup
|
|
54
|
+
|
|
55
|
+
After docs push succeeds, close any browser sessions spawned during this or prior skill phases. Write a nodejs spool file calling rs-exec:
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
```javascript
|
|
58
|
+
const sessionId = process.env.CLAUDE_SESSION_ID;
|
|
59
|
+
if (!sessionId) return;
|
|
60
|
+
const rs = require('rs-exec');
|
|
61
|
+
try {
|
|
62
|
+
rs.client().close_sessions_for(sessionId).catch(() => {});
|
|
63
|
+
} catch (e) {}
|
|
64
|
+
```
|
|
58
65
|
|
|
59
|
-
|
|
60
|
-
**Always**: git diff first | read before overwriting | verify after write | push
|
|
66
|
+
Best-effort: session context or rs-exec unavailable → skip gracefully. No error thrown.
|
package/tools.json
CHANGED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
name: Publish to npm
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
workflow_dispatch:
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
publish:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
steps:
|
|
13
|
-
- uses: actions/checkout@v4
|
|
14
|
-
|
|
15
|
-
- uses: actions/setup-node@v4
|
|
16
|
-
with:
|
|
17
|
-
node-version: '22'
|
|
18
|
-
registry-url: 'https://registry.npmjs.org'
|
|
19
|
-
|
|
20
|
-
- name: Publish to npm
|
|
21
|
-
run: |
|
|
22
|
-
PACKAGE=$(jq -r '.name' package.json)
|
|
23
|
-
VERSION=$(jq -r '.version' package.json)
|
|
24
|
-
echo "Package: $PACKAGE@$VERSION"
|
|
25
|
-
|
|
26
|
-
# Skip if this exact version is already on npm
|
|
27
|
-
PUBLISHED=$(npm view "$PACKAGE@$VERSION" version 2>/dev/null || echo "")
|
|
28
|
-
if [ "$PUBLISHED" = "$VERSION" ]; then
|
|
29
|
-
echo "✅ $PACKAGE@$VERSION already published - skipping"
|
|
30
|
-
exit 0
|
|
31
|
-
fi
|
|
32
|
-
|
|
33
|
-
echo "Publishing $PACKAGE@$VERSION..."
|
|
34
|
-
npm publish --access public 2>&1 | tee /tmp/npm-out.log; EXIT=${PIPESTATUS[0]}
|
|
35
|
-
if [ "$EXIT" != "0" ]; then
|
|
36
|
-
if grep -q "cannot publish over\|previously published" /tmp/npm-out.log; then
|
|
37
|
-
echo "⚠️ Version already published, skipping"
|
|
38
|
-
else
|
|
39
|
-
exit "$EXIT"
|
|
40
|
-
fi
|
|
41
|
-
fi
|
|
42
|
-
echo "✅ Published $PACKAGE@$VERSION"
|
|
43
|
-
env:
|
|
44
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
let raw = '';
|
|
5
|
-
try { raw = fs.readFileSync(0, 'utf8'); } catch (_) {}
|
|
6
|
-
if (!raw.trim()) raw = process.env.CLAUDE_HOOK_INPUT || '{}';
|
|
7
|
-
const input = JSON.parse(raw);
|
|
8
|
-
const toolName = input.tool_name || input.tool_use?.name || '';
|
|
9
|
-
const toolOutput = input.tool_result || input.output || '';
|
|
10
|
-
const gmDir = path.join(process.cwd(), '.gm');
|
|
11
|
-
const tsPath = path.join(gmDir, 'turn-state.json');
|
|
12
|
-
const readState = () => { try { return JSON.parse(fs.readFileSync(tsPath, 'utf8')); } catch (_) { return { firstToolFired: false, execCallsSinceMemorize: 0, recallFiredThisTurn: false }; } };
|
|
13
|
-
const writeState = (s) => { try { if (!fs.existsSync(gmDir)) fs.mkdirSync(gmDir, { recursive: true }); fs.writeFileSync(tsPath, JSON.stringify(s), 'utf8'); } catch (_) {} };
|
|
14
|
-
const state = readState();
|
|
15
|
-
const messages = [];
|
|
16
|
-
if (!state.firstToolFired) {
|
|
17
|
-
state.firstToolFired = true;
|
|
18
|
-
state.firstToolName = toolName;
|
|
19
|
-
}
|
|
20
|
-
const isMemorize = toolName === 'Agent' && /memorize/i.test(JSON.stringify(input.tool_input || input.tool_use?.input || {}));
|
|
21
|
-
if (isMemorize) {
|
|
22
|
-
state.execCallsSinceMemorize = 0;
|
|
23
|
-
try { fs.unlinkSync(path.join(gmDir, 'no-memorize-this-turn')); } catch (_) {}
|
|
24
|
-
}
|
|
25
|
-
if (toolName === 'Bash') {
|
|
26
|
-
const cmd = (input.tool_input && input.tool_input.command) || (input.tool_use && input.tool_use.input && input.tool_use.input.command) || '';
|
|
27
|
-
if (/^\s*exec:recall\b/.test(cmd)) state.recallFiredThisTurn = true;
|
|
28
|
-
if (toolOutput && typeof toolOutput === 'string' && toolOutput.length > 20 && !/^\s*exec:(recall|memorize|codesearch|wait|sleep|status|runner|type|kill-port|close|pause)/.test(cmd)) {
|
|
29
|
-
state.execCallsSinceMemorize = (state.execCallsSinceMemorize || 0) + 1;
|
|
30
|
-
messages.push('exec: run completed. MEMORIZE CHECK: did this output resolve any prior unknown? If YES → spawn Agent(subagent_type=\'gm:memorize\', model=\'haiku\', run_in_background=true, prompt=\'## CONTEXT TO MEMORIZE\\n<fact>\') NOW. Skipping = memory leak. (Counter: ' + state.execCallsSinceMemorize + '/3 before hard block.)');
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
writeState(state);
|
|
34
|
-
if (messages.length) process.stdout.write(JSON.stringify({ systemMessage: messages.join('\n\n') }));
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
let raw = '';
|
|
5
|
-
try { raw = fs.readFileSync(0, 'utf8'); } catch (_) {}
|
|
6
|
-
if (!raw.trim()) raw = process.env.CLAUDE_HOOK_INPUT || '{}';
|
|
7
|
-
const input = JSON.parse(raw);
|
|
8
|
-
const toolName = input.tool_name || input.tool_use?.name || '';
|
|
9
|
-
const toolInput = input.tool_input || input.tool_use?.input || {};
|
|
10
|
-
const skillName = toolInput.skill || toolInput.name || '';
|
|
11
|
-
const gmDir = path.join(process.cwd(), '.gm');
|
|
12
|
-
const needsGmPath = path.join(gmDir, 'needs-gm');
|
|
13
|
-
const lastskillPath = path.join(gmDir, 'lastskill');
|
|
14
|
-
const isSkillTool = toolName === 'Skill' || toolName === 'skill';
|
|
15
|
-
if (isSkillTool && skillName) {
|
|
16
|
-
try {
|
|
17
|
-
if (!fs.existsSync(gmDir)) fs.mkdirSync(gmDir, { recursive: true });
|
|
18
|
-
fs.writeFileSync(lastskillPath, skillName, 'utf8');
|
|
19
|
-
if (skillName === 'gm' || skillName === 'gm:gm') {
|
|
20
|
-
try { fs.unlinkSync(needsGmPath); } catch (_) {}
|
|
21
|
-
}
|
|
22
|
-
} catch (_) {}
|
|
23
|
-
process.exit(0);
|
|
24
|
-
}
|
|
25
|
-
if (fs.existsSync(needsGmPath)) {
|
|
26
|
-
process.stdout.write(JSON.stringify({ decision: 'block', reason: 'HARD CONSTRAINT: invoke the Skill tool with skill: "gm:gm" before any other tool. The gm:gm skill must be the first action after every user message.' }));
|
|
27
|
-
process.exit(0);
|
|
28
|
-
}
|
|
29
|
-
const turnStatePath = path.join(gmDir, 'turn-state.json');
|
|
30
|
-
const noMemoPath = path.join(gmDir, 'no-memorize-this-turn');
|
|
31
|
-
const turnState = (() => { try { return JSON.parse(fs.readFileSync(turnStatePath, 'utf8')); } catch (_) { return null; } })();
|
|
32
|
-
if (turnState && (turnState.execCallsSinceMemorize || 0) >= 3 && !fs.existsSync(noMemoPath)) {
|
|
33
|
-
const isMemAgent = toolName === 'Agent' && /memorize/i.test(JSON.stringify(toolInput || {}));
|
|
34
|
-
if (!isMemAgent) {
|
|
35
|
-
process.stdout.write(JSON.stringify({ decision: 'block', reason: '3+ exec results have resolved unknowns without a memorize call. HARD BLOCK until you spawn at least one Agent(subagent_type=\'gm:memorize\', model=\'haiku\', run_in_background=true, prompt=\'## CONTEXT TO MEMORIZE\\n<fact>\') OR write file .gm/no-memorize-this-turn (containing reason) to declare nothing memorable. Saying "I will memorize" is NOT a memorize call — only the Agent tool counts.' }));
|
|
36
|
-
process.exit(0);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const lastSkill = (() => { try { return fs.readFileSync(lastskillPath, 'utf8').trim(); } catch (_) { return ''; } })();
|
|
40
|
-
const isFileEdit = ['Write', 'Edit', 'NotebookEdit'].includes(toolName);
|
|
41
|
-
const WRITE_BLOCKED_PHASES = new Set(['gm-complete', 'update-docs']);
|
|
42
|
-
if (isFileEdit && WRITE_BLOCKED_PHASES.has(lastSkill)) {
|
|
43
|
-
process.stdout.write(JSON.stringify({ decision: 'block', reason: 'File edits are not permitted in ' + lastSkill + ' phase. Regress to gm-execute if changes are needed, or invoke gm-emit to re-emit.' }));
|
|
44
|
-
process.exit(0);
|
|
45
|
-
}
|