gm-skill 2.0.1271 → 2.0.1273

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.1271` — auto-bumped from the canonical `gm` repo. Every push to `AnEntrypoint/gm` (or any cascading sibling crate) republishes this package.
38
+ `2.0.1273` — 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.468
1
+ 0.1.469
package/bin/plugkit.wasm CHANGED
Binary file
@@ -1 +1 @@
1
- 89f0141b6e50ced98a5216b7ed553da3f529bac96f6d9e2927a1ed1737223d62 plugkit.wasm
1
+ 9067bff0bc3048f8f49179b62920b87eca4cc67dd6d339491f42b7c47e44f93f plugkit.wasm
@@ -27,11 +27,20 @@ const ORCHESTRATOR_VERBS = new Set(['instruction', 'transition', 'phase-status',
27
27
  const TURN_IDLE_MS = 30_000;
28
28
  const _turns = new Map();
29
29
 
30
+ let __shutdownReasonWritten = false;
31
+ let __currentVerbContext = null;
32
+
33
+ function spoolDirForSentinel() {
34
+ return process.env.CLAUDE_PROJECT_DIR
35
+ ? path.join(process.env.CLAUDE_PROJECT_DIR, '.gm', 'exec-spool')
36
+ : path.join(process.cwd(), '.gm', 'exec-spool');
37
+ }
38
+
30
39
  function emitShutdownReason(reason, err) {
40
+ if (__shutdownReasonWritten) return;
41
+ __shutdownReasonWritten = true;
31
42
  try {
32
- const spoolDir = process.env.CLAUDE_PROJECT_DIR
33
- ? path.join(process.env.CLAUDE_PROJECT_DIR, '.gm', 'exec-spool')
34
- : path.join(process.cwd(), '.gm', 'exec-spool');
43
+ const spoolDir = spoolDirForSentinel();
35
44
  fs.mkdirSync(spoolDir, { recursive: true });
36
45
  const body = {
37
46
  reason,
@@ -40,12 +49,28 @@ function emitShutdownReason(reason, err) {
40
49
  message: err && (err.message || String(err)),
41
50
  stack: err && err.stack ? String(err.stack).slice(0, 4000) : null,
42
51
  version: typeof PLUGKIT_VERSION !== 'undefined' ? PLUGKIT_VERSION : null,
52
+ verb_in_flight: __currentVerbContext,
43
53
  };
44
54
  fs.writeFileSync(path.join(spoolDir, '.shutdown-reason.json'), JSON.stringify(body, null, 2));
45
55
  try { fs.unlinkSync(path.join(spoolDir, '.boot-active.json')); } catch (_) {}
56
+ try { fs.unlinkSync(path.join(spoolDir, '.verb-active.json')); } catch (_) {}
57
+ } catch (_) {}
58
+ }
59
+
60
+ function writeVerbActive(verb, task) {
61
+ __currentVerbContext = { verb, task, started_at_ms: Date.now(), pid: process.pid };
62
+ try {
63
+ const spoolDir = spoolDirForSentinel();
64
+ fs.mkdirSync(spoolDir, { recursive: true });
65
+ fs.writeFileSync(path.join(spoolDir, '.verb-active.json'), JSON.stringify(__currentVerbContext));
46
66
  } catch (_) {}
47
67
  }
48
68
 
69
+ function clearVerbActive() {
70
+ __currentVerbContext = null;
71
+ try { fs.unlinkSync(path.join(spoolDirForSentinel(), '.verb-active.json')); } catch (_) {}
72
+ }
73
+
49
74
  process.on('uncaughtException', (err) => {
50
75
  try { console.error('[plugkit-wasm] uncaught:', err && err.stack || err); } catch (_) {}
51
76
  emitShutdownReason('uncaughtException', err);
@@ -58,6 +83,22 @@ process.on('unhandledRejection', (reason) => {
58
83
  process.exit(1);
59
84
  });
60
85
 
86
+ process.on('exit', (code) => {
87
+ if (__shutdownReasonWritten) return;
88
+ try {
89
+ const spoolDir = spoolDirForSentinel();
90
+ fs.mkdirSync(spoolDir, { recursive: true });
91
+ fs.writeFileSync(path.join(spoolDir, '.shutdown-reason.json'), JSON.stringify({
92
+ reason: 'process-exit',
93
+ exit_code: code,
94
+ ts: Date.now(),
95
+ pid: process.pid,
96
+ verb_in_flight: __currentVerbContext,
97
+ }, null, 2));
98
+ __shutdownReasonWritten = true;
99
+ } catch (_) {}
100
+ });
101
+
61
102
  function applyDisciplineSigil(rawBody) {
62
103
  let parsed;
63
104
  try { parsed = JSON.parse(rawBody); } catch (_) { return rawBody; }
@@ -1556,7 +1597,32 @@ async function runSpoolWatcher(instance, spoolDir) {
1556
1597
  setInterval(refreshLock, 5000);
1557
1598
 
1558
1599
  const BOOT_ACTIVE_PATH = path.join(spoolDir, '.boot-active.json');
1600
+ const VERB_ACTIVE_PATH = path.join(spoolDir, '.verb-active.json');
1601
+ const STATUS_PATH_FOR_VERB_ABORT = path.join(spoolDir, '.status.json');
1559
1602
  const SHUTDOWN_REASON_PATH_EARLY = path.join(spoolDir, '.shutdown-reason.json');
1603
+ try {
1604
+ let priorVerb = null;
1605
+ let priorStatusForVerb = null;
1606
+ try { priorVerb = JSON.parse(fs.readFileSync(VERB_ACTIVE_PATH, 'utf-8')); } catch (_) {}
1607
+ try { priorStatusForVerb = JSON.parse(fs.readFileSync(STATUS_PATH_FOR_VERB_ABORT, 'utf-8')); } catch (_) {}
1608
+ if (priorVerb && priorVerb.pid && priorVerb.pid !== process.pid) {
1609
+ const statusAge = priorStatusForVerb && Number.isFinite(priorStatusForVerb.ts) ? Date.now() - priorStatusForVerb.ts : null;
1610
+ const statusFresh = statusAge !== null && statusAge < 30_000;
1611
+ if (!statusFresh) {
1612
+ logEvent('plugkit', 'watcher.verb-abort', {
1613
+ prior_pid: priorVerb.pid,
1614
+ verb: priorVerb.verb,
1615
+ task: priorVerb.task,
1616
+ started_at_ms: priorVerb.started_at_ms,
1617
+ dur_ms_at_death: priorVerb.started_at_ms ? Date.now() - priorVerb.started_at_ms : null,
1618
+ status_age_ms: statusAge,
1619
+ detected_at: Date.now(),
1620
+ });
1621
+ try { console.error(`[plugkit-wasm] VERB ABORT detected: prior watcher pid=${priorVerb.pid} died inside verb=${priorVerb.verb} task=${priorVerb.task}`); } catch (_) {}
1622
+ }
1623
+ try { fs.unlinkSync(VERB_ACTIVE_PATH); } catch (_) {}
1624
+ }
1625
+ } catch (_) {}
1560
1626
  try {
1561
1627
  let priorBoot = null;
1562
1628
  let priorShutdownForAbort = null;
@@ -1693,6 +1759,7 @@ async function runSpoolWatcher(instance, spoolDir) {
1693
1759
 
1694
1760
  try { fs.unlinkSync(STATUS_PATH_FOR_TEARDOWN); } catch (_) {}
1695
1761
  try { clearBootActive(); } catch (_) {}
1762
+ try { clearVerbActive(); } catch (_) {}
1696
1763
  try { releaseLock(); } catch (_) {}
1697
1764
  process.exit(0);
1698
1765
  }
@@ -1949,7 +2016,9 @@ async function runSpoolWatcher(instance, spoolDir) {
1949
2016
  new Uint8Array(instance.exports.memory.buffer, verbPtr, verbBytes.length).set(verbBytes);
1950
2017
  new Uint8Array(instance.exports.memory.buffer, bodyPtr, bodyBytes.length).set(bodyBytes);
1951
2018
 
2019
+ writeVerbActive(verb, taskBase);
1952
2020
  const result = dispatch(verbPtr, verbBytes.length, bodyPtr, bodyBytes.length);
2021
+ clearVerbActive();
1953
2022
 
1954
2023
  const ptr = Number(result & 0xffffffffn);
1955
2024
  const len = Number(result >> 32n);
@@ -1996,6 +2065,7 @@ async function runSpoolWatcher(instance, spoolDir) {
1996
2065
  try { if (fs.existsSync(filePath)) fs.unlinkSync(filePath); } catch (_) {}
1997
2066
  unmarkProcessed(key);
1998
2067
  } catch (e) {
2068
+ try { clearVerbActive(); } catch (_) {}
1999
2069
  console.error(`[plugkit-wasm] error processing ${key}: ${e.message}`);
2000
2070
  const taskBase = path.basename(filePath, path.extname(filePath));
2001
2071
  const relPath = path.relative(inDir, filePath);
package/gm.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm",
3
- "version": "2.0.1271",
3
+ "version": "2.0.1273",
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.468"
20
+ "plugkitVersion": "0.1.469"
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-skill",
3
- "version": "2.0.1271",
3
+ "version": "2.0.1273",
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.1271"
42
+ "gm-plugkit": "^2.0.1273"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=16.0.0"