gm-skill 2.0.1147 → 2.0.1149

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/README.md CHANGED
@@ -35,7 +35,7 @@ An earlier generation fanned out fifteen per-platform downstream repos (gm-cc, g
35
35
 
36
36
  ## Version
37
37
 
38
- `2.0.1147` — auto-bumped from the canonical `gm` repo. Every push to `AnEntrypoint/gm` (or any cascading sibling crate) republishes this package.
38
+ `2.0.1149` — auto-bumped from the canonical `gm` repo. Every push to `AnEntrypoint/gm` (or any cascading sibling crate) republishes this package.
39
39
 
40
40
  ## Source of truth
41
41
 
@@ -1 +1 @@
1
- 0.1.413
1
+ 0.1.414
package/bin/plugkit.wasm CHANGED
Binary file
@@ -1 +1 @@
1
- 4032ac9258c6fb79106ef9e02a40c9cba7a509a6e0507d4d0c062645b25799a6 plugkit.wasm
1
+ 74a7d080de71336c5d7c56a0edd4936c853259a21323c0ab797ce9a3782f5dac plugkit.wasm
package/gm-plugkit/cli.js CHANGED
@@ -1,18 +1,52 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- const { ensureReady, startSpoolDaemon, getBinaryPath, isReady } = require('./bootstrap');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { ensureReady, startSpoolDaemon } = require('./bootstrap');
5
7
 
6
8
  const usage = `gm-plugkit — Bootstrap and daemon-spawn for gm plugkit binary.
7
9
 
8
10
  Usage:
9
11
  bun x gm-plugkit@latest Bootstrap + start spool daemon
10
- bun x gm-plugkit@latest --daemon Same as default
11
- bun x gm-plugkit@latest --binary Print binary path only
12
- bun x gm-plugkit@latest --status JSON status check
13
- bun x gm-plugkit@latest --help Show this help
12
+ bun x gm-plugkit@latest spool Same as default (explicit)
13
+ bun x gm-plugkit@latest --daemon Same as default
14
+ bun x gm-plugkit@latest --binary Print binary path only
15
+ bun x gm-plugkit@latest --status JSON status check
16
+ bun x gm-plugkit@latest --help Show this help
14
17
  `;
15
18
 
19
+ function spoolDir() {
20
+ const projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
21
+ return path.join(projectDir, '.gm', 'exec-spool');
22
+ }
23
+
24
+ function ensureSpoolDir() {
25
+ try { fs.mkdirSync(spoolDir(), { recursive: true }); } catch (_) {}
26
+ }
27
+
28
+ function writeCliStatus(spec) {
29
+ try {
30
+ ensureSpoolDir();
31
+ fs.writeFileSync(
32
+ path.join(spoolDir(), '.cli-status.json'),
33
+ JSON.stringify({ ts: new Date().toISOString(), pid: process.pid, ...spec }, null, 2)
34
+ );
35
+ } catch (_) {}
36
+ }
37
+
38
+ function writeCliError(phase, err) {
39
+ try {
40
+ ensureSpoolDir();
41
+ const msg = err && err.message ? err.message : String(err);
42
+ const stack = err && err.stack ? err.stack : null;
43
+ fs.writeFileSync(
44
+ path.join(spoolDir(), '.bootstrap-error.json'),
45
+ JSON.stringify({ ts: new Date().toISOString(), pid: process.pid, error_phase: phase, error_message: msg, stack }, null, 2)
46
+ );
47
+ } catch (_) {}
48
+ }
49
+
16
50
  (async () => {
17
51
  const args = process.argv.slice(2);
18
52
 
@@ -21,28 +55,54 @@ Usage:
21
55
  process.exit(0);
22
56
  }
23
57
 
58
+ ensureSpoolDir();
59
+ writeCliStatus({ phase: 'starting', args });
60
+
61
+ let bootstrapResult;
24
62
  try {
25
- const result = await ensureReady();
26
- if (!result.ok) {
27
- console.error('Bootstrap failed:', result.error);
28
- process.exit(1);
29
- }
30
-
31
- const daemon = startSpoolDaemon();
32
- if (!daemon.ok) {
33
- console.error('Daemon start failed:', daemon.error);
34
- process.exit(1);
35
- }
36
-
37
- console.log(JSON.stringify({
38
- ok: true,
39
- binary: result.binaryPath,
40
- daemon: daemon,
41
- message: 'plugkit ready, spool watcher running'
42
- }));
43
- process.exit(0);
63
+ bootstrapResult = await ensureReady();
64
+ } catch (err) {
65
+ writeCliError('ensure-ready', err);
66
+ console.error('Bootstrap failed:', err.message);
67
+ process.exit(1);
68
+ }
69
+
70
+ if (!bootstrapResult || !bootstrapResult.ok) {
71
+ const errMsg = (bootstrapResult && bootstrapResult.error) || 'ensureReady returned non-ok';
72
+ writeCliError('ensure-ready', new Error(errMsg));
73
+ console.error('Bootstrap failed:', errMsg);
74
+ process.exit(1);
75
+ }
76
+
77
+ writeCliStatus({ phase: 'bootstrapped', version: bootstrapResult.version, binary: bootstrapResult.binaryPath });
78
+
79
+ let daemon;
80
+ try {
81
+ daemon = startSpoolDaemon();
44
82
  } catch (err) {
45
- console.error('gm-plugkit failed:', err.message);
83
+ writeCliError('start-daemon', err);
84
+ console.error('Daemon start failed:', err.message);
46
85
  process.exit(1);
47
86
  }
48
- })();
87
+
88
+ if (!daemon || !daemon.ok) {
89
+ const errMsg = (daemon && daemon.error) || 'startSpoolDaemon returned non-ok';
90
+ writeCliError('start-daemon', new Error(errMsg));
91
+ console.error('Daemon start failed:', errMsg);
92
+ process.exit(1);
93
+ }
94
+
95
+ writeCliStatus({ phase: 'ready', version: bootstrapResult.version, daemon_pid: daemon.pid, log: daemon.logPath });
96
+
97
+ console.log(JSON.stringify({
98
+ ok: true,
99
+ binary: bootstrapResult.binaryPath,
100
+ daemon,
101
+ message: 'plugkit ready, spool watcher running'
102
+ }));
103
+ process.exit(0);
104
+ })().catch((err) => {
105
+ writeCliError('uncaught', err);
106
+ console.error('gm-plugkit failed:', err && err.message ? err.message : err);
107
+ process.exit(1);
108
+ });
package/gm.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm",
3
- "version": "2.0.1147",
3
+ "version": "2.0.1149",
4
4
  "description": "Spool-dispatch orchestration engine with unified state machine, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
@@ -17,5 +17,5 @@
17
17
  "publishConfig": {
18
18
  "access": "public"
19
19
  },
20
- "plugkitVersion": "0.1.413"
20
+ "plugkitVersion": "0.1.414"
21
21
  }
@@ -1,6 +1,33 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
  const os = require('os');
4
+ const { spawnSync } = require('child_process');
5
+
6
+ function isWorktreeDirty(cwd) {
7
+ try {
8
+ const r = spawnSync('git', ['status', '--porcelain'], {
9
+ cwd: cwd || process.cwd(), encoding: 'utf8', timeout: 1500, windowsHide: true
10
+ });
11
+ if (r.status !== 0) return { dirty: false, files: [], available: false };
12
+ const lines = r.stdout.split('\n').filter(l => l.length > 0);
13
+ return { dirty: lines.length > 0, files: lines, available: true };
14
+ } catch (_) {
15
+ return { dirty: false, files: [], available: false };
16
+ }
17
+ }
18
+
19
+ function hasUnpushedCommits(cwd) {
20
+ try {
21
+ const r = spawnSync('git', ['log', '@{u}..HEAD', '--oneline'], {
22
+ cwd: cwd || process.cwd(), encoding: 'utf8', timeout: 1500, windowsHide: true
23
+ });
24
+ if (r.status !== 0) return { unpushed: false, count: 0, available: false };
25
+ const lines = r.stdout.split('\n').filter(l => l.length > 0);
26
+ return { unpushed: lines.length > 0, count: lines.length, available: true };
27
+ } catch (_) {
28
+ return { unpushed: false, count: 0, available: false };
29
+ }
30
+ }
4
31
 
5
32
  async function dispatchSpool(cmd, lang, body, timeoutMs, sessionId) {
6
33
  const taskId = `${Date.now()}-${Math.random().toString(16).slice(2, 8)}`;
@@ -73,12 +100,45 @@ async function pollForCompletion(jsonFile, timeoutMs, taskId) {
73
100
  }
74
101
 
75
102
  function checkDispatchGates(sessionId, operation) {
76
- const gm = path.join(process.cwd(), '.gm');
103
+ const cwd = process.cwd();
104
+ const gm = path.join(cwd, '.gm');
77
105
  const prdPath = path.join(gm, 'prd.yml');
78
106
  const mutsPath = path.join(gm, 'mutables.yml');
79
107
  const needsGmPath = path.join(gm, 'needs-gm');
80
108
  const gmFiredPath = path.join(gm, `gm-fired-${sessionId}`);
81
109
 
110
+ if (['stop', 'complete'].includes(operation)) {
111
+ const residuals = [];
112
+ if (fs.existsSync(prdPath)) {
113
+ try {
114
+ const content = fs.readFileSync(prdPath, 'utf8');
115
+ if (content.includes('status: pending') || content.includes('status: in_progress')) {
116
+ residuals.push('PRD has open items — resolve or name-and-stop before declaring done');
117
+ }
118
+ } catch (_) {}
119
+ }
120
+ if (fs.existsSync(mutsPath)) {
121
+ try {
122
+ const content = fs.readFileSync(mutsPath, 'utf8');
123
+ if (content.includes('status: unknown')) {
124
+ residuals.push('unresolved mutables present — resolve with witness_evidence before declaring done');
125
+ }
126
+ } catch (_) {}
127
+ }
128
+ const dirty = isWorktreeDirty(cwd);
129
+ if (dirty.available && dirty.dirty) {
130
+ residuals.push(`worktree dirty (${dirty.files.length} file${dirty.files.length === 1 ? '' : 's'}) — commit and push before declaring done`);
131
+ }
132
+ const unpushed = hasUnpushedCommits(cwd);
133
+ if (unpushed.available && unpushed.unpushed) {
134
+ residuals.push(`${unpushed.count} unpushed commit${unpushed.count === 1 ? '' : 's'} — push to remote before declaring done`);
135
+ }
136
+ if (residuals.length > 0) {
137
+ return { allowed: false, reason: `stop-gate residuals: ${residuals.join('; ')}`, residuals };
138
+ }
139
+ return { allowed: true };
140
+ }
141
+
82
142
  if (!['write', 'edit', 'git'].includes(operation)) return { allowed: true };
83
143
 
84
144
  if (fs.existsSync(prdPath) && fs.existsSync(needsGmPath) && !fs.existsSync(gmFiredPath)) {
@@ -97,4 +157,4 @@ function checkDispatchGates(sessionId, operation) {
97
157
  return { allowed: true };
98
158
  }
99
159
 
100
- module.exports = { dispatchSpool, checkDispatchGates };
160
+ module.exports = { dispatchSpool, checkDispatchGates, isWorktreeDirty, hasUnpushedCommits };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-skill",
3
- "version": "2.0.1147",
3
+ "version": "2.0.1149",
4
4
  "description": "Canonical universal harness — AI-native software engineering via skill-driven orchestration; bootstraps plugkit for task execution and session isolation. Install in any AI coding agent host.",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
@@ -39,7 +39,7 @@
39
39
  "gm.json"
40
40
  ],
41
41
  "dependencies": {
42
- "gm-plugkit": "^2.0.1147"
42
+ "gm-plugkit": "^2.0.1149"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=16.0.0"
@@ -6,6 +6,14 @@ allowed-tools: Skill, Read, Write, Bash(node *), Bash(bun *)
6
6
 
7
7
  # gm — single entry point
8
8
 
9
+ Every turn begins with `instruction`. Write `.gm/exec-spool/in/instruction/<N>.txt` (empty body) and read the response — its `instruction` field is the active phase prose, its `prd_items` is the live work plan, its `mutables_pending` is what blocks the EMIT gate, its `recall_hits` is the prior memory already loaded for you. Follow that prose imperatively until the phase's exit condition is met, then `transition`. The user's request is the authorization; the PRD is the receipt; the chain runs PLAN → EXECUTE → EMIT → VERIFY → COMPLETE without re-asking between phases.
10
+
11
+ Direct Read/Edit/Bash before the first `instruction` dispatch is the failure mode this skill prevents. If you find yourself reaching for a tool to "just take a quick look", you have already dropped the loop — dispatch `instruction` first, then act on its prose.
12
+
13
+ Fix on Sight. Every unexpected output, broken neighbor, lockfile drift, suppressed error, or stale generated file surfaced during work becomes a PRD item the same turn and is executed before COMPLETE. Surprise is a new mutable, not noise to absorb. Stubs, mocks, placeholder returns, fixture-only paths, and "always succeeds" code paths are forbidden in shipped material; acceptance is real input through real code into real output, witnessed. Edits to code that runs in a browser require a live `browser` verb witness in the same turn — Browser Witness is non-negotiable.
14
+
15
+ Before any apparent stop, dispatch `residual-scan`. If it returns work that fits the spirit of the original ask and is reachable from this session, expand the PRD and execute; only residuals genuinely out-of-spirit or out-of-reach are name-and-stop. A turn that ends with uncommitted changes, an open PRD slice, or unresolved mutables has not actually stopped — it has stalled the chain.
16
+
9
17
  The wasm artifact lives at `~/.claude/gm-tools/plugkit.wasm`; the spool watcher runs it. The watcher's own stdout/stderr is appended to `.gm/exec-spool/.watcher.log` — Read it to see plugkit's internal trace, dispatch timings, sweep actions, errors.
10
18
 
11
19
  ## Boot the spool watcher (first turn only)
@@ -18,7 +26,11 @@ bun x gm-plugkit@latest spool > /dev/null 2>&1 &
18
26
 
19
27
  If `bun` is not available, fall back to `npx -y gm-plugkit@latest spool > /dev/null 2>&1 &` or to the local wrapper if it's already installed: `node ~/.claude/gm-tools/plugkit-wasm-wrapper.js spool > /dev/null 2>&1 &`. The wrapper has a self-heal: if it detects a `LinkError` or missing wasm at instantiation, it re-runs bootstrap automatically and retries.
20
28
 
21
- Wait 2 seconds, verify `.status.json` is fresh. Then proceed.
29
+ Wait 2 seconds, then verify boot:
30
+
31
+ - Read `.gm/exec-spool/.cli-status.json` — the launcher writes its phase here (`starting` → `bootstrapped` → `ready`). Present with `phase: "ready"` = good.
32
+ - Read `.gm/exec-spool/.status.json` — the watcher writes its heartbeat here every 5s. Fresh `ts` (within 15s) = watcher alive.
33
+ - If neither file exists or `.cli-status.json` is stuck at an earlier phase, read `.gm/exec-spool/.bootstrap-error.json` — the launcher writes `{error_phase, error_message, stack}` on any failure even when stdout/stderr were redirected to `/dev/null`. Also read `.gm/exec-spool/.watcher.log` for the post-spawn trace. Surface the error to the user; do not retry blindly.
22
34
 
23
35
  ## Plugkit version updates
24
36
 
@@ -80,11 +92,11 @@ The log is rotated at 10MB (older content moves to `.watcher.log.1`).
80
92
 
81
93
  ## The loop
82
94
 
83
- Dispatch `instruction` with empty body to get current-phase guidance + full state snapshot. Follow the `instruction` prose imperatively. Add PRD items via `prd-add` (JSON body), resolve via `prd-resolve` (id as body). Add mutables via `mutable-add`, resolve via `mutable-resolve` once `witness_evidence` is filled. Every resolve auto-fires `memorize-fire` so the evidence becomes recall-able.
95
+ Add PRD items via `prd-add` (JSON body), resolve via `prd-resolve` (id as body). Add mutables via `mutable-add`, resolve via `mutable-resolve` once `witness_evidence` is filled — narrative resolution is rejected; only file:line, codesearch hit, or exec output snippet counts. Every `mutable-resolve` auto-fires memorize so the witness becomes recall-able next session.
84
96
 
85
97
  Resolve every entry in `mutables_pending` before transitioning. When the phase's exit condition is met, dispatch `transition` with the next phase name (or empty for auto-advance). Each transition response embeds `recall_hits` automatically — relevant prior memos surface without you asking.
86
98
 
87
- Stop when `next_phase_hint` is null or phase is `COMPLETE`.
99
+ Stop only when `phase` is `COMPLETE` AND `residual-scan` returns empty AND the worktree is clean AND CI is green. Any of those false means the chain has not finished.
88
100
 
89
101
  ## Orchestrator verbs
90
102
 
@@ -100,8 +112,8 @@ Stop when `next_phase_hint` is null or phase is `COMPLETE`.
100
112
 
101
113
  ### Browser
102
114
 
103
- Dispatch `.gm/exec-spool/in/browser/<N>.txt` with raw JavaScript as the body. The wrapper spawns Chrome (managed profile at `<cwd>/.gm/browser-profile/`) and runs the JS via playwriter. Globals available inside the body: `page` (playwright Page), `snapshot` (accessibility snapshot), `screenshotWithAccessibilityLabels` (screenshot helper), `state` (per-session state object).
115
+ The `browser` verb is the only sanctioned way to drive a live page. Do not reach for any other browser tool, library, or skill — the host owns the managed session and a parallel surface fragments witness state. Dispatch `.gm/exec-spool/in/browser/<N>.txt` with raw JavaScript as the body. The host runs Chrome under a project-scoped profile at `<cwd>/.gm/browser-profile/` (cookies/login persist per project) and exposes the body to four globals: `page` (the live page handle — `await page.goto(...)`, `await page.evaluate(...)`, etc.), `snapshot` (accessibility-tree snapshot), `screenshotWithAccessibilityLabels` (annotated screenshot helper), and `state` (a per-session object that persists across dispatches within the same session).
104
116
 
105
- Special commands (body starts with `session `): `session new`, `session list`, `session close <id>` pass through to playwriter directly.
117
+ Special commands (body starts with `session `): `session new`, `session list`, `session close <id>` manage session lifecycle.
106
118
 
107
- Chrome is detected from system install paths; profile dir is project-scoped so cookies/login persist per project. The wrapper writes the managed gitignore block (which includes `.gm/browser-profile/`) on first launch.
119
+ Required for any edit to code that runs in a browser — Browser Witness is non-negotiable. A `node test.js passes` does not substitute for a live `page.evaluate` asserting the invariant the edit was supposed to change.