gm-skill 2.0.1213 → 2.0.1214
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 +1 -1
- package/gm-plugkit/plugkit-wasm-wrapper.js +128 -0
- package/gm.json +1 -1
- package/package.json +2 -2
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.
|
|
38
|
+
`2.0.1214` — 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
|
|
|
@@ -27,6 +27,134 @@ 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
|
+
const SPOOL_POLL_GATE_MARK = '__gm_spool_poll_gate__';
|
|
31
|
+
|
|
32
|
+
function spoolPollGateScript() {
|
|
33
|
+
return `#!/usr/bin/env node
|
|
34
|
+
// ${SPOOL_POLL_GATE_MARK}
|
|
35
|
+
// PreToolUse hook that blocks bash polling of .gm/exec-spool.
|
|
36
|
+
// Plugkit is synchronous from the agent's view; the Read tool is the canonical
|
|
37
|
+
// way to inspect response files. This hook denies Bash commands that try to
|
|
38
|
+
// poll or shell-read the spool directory.
|
|
39
|
+
|
|
40
|
+
const SPOOL_POLL_PATTERNS = [
|
|
41
|
+
/\\bsleep\\s+\\d+(?:\\.\\d+)?\\s*[;&]+\\s*(?:cat|ls|tail|head|find|test|grep)\\b[^|]*\\.gm[\\\\/](?:exec-spool|spool)/i,
|
|
42
|
+
/\\bStart-Sleep\\b[^;|]*?[;|]\\s*(?:Get-Content|Test-Path|Get-ChildItem|cat|ls|gci|gc|tp)\\b[^|]*\\.gm[\\\\/](?:exec-spool|spool)/i,
|
|
43
|
+
/\\b(?:cat|ls|tail|head|Get-Content|Test-Path|Get-ChildItem)\\b[^|]*\\.gm[\\\\/](?:exec-spool|spool)[^|]*?[;&|]+\\s*(?:sleep|Start-Sleep)\\b/i,
|
|
44
|
+
/\\bwhile\\b[^;]*?(?:!|-not)\\s*(?:-(?:f|e)\\s+|Test-Path\\s+)[^;]*?\\.gm[\\\\/](?:exec-spool|spool)/i,
|
|
45
|
+
/\\buntil\\b[^;]*?(?:-f|-e|Test-Path)\\s+[^;]*?\\.gm[\\\\/](?:exec-spool|spool)/i,
|
|
46
|
+
/\\bfor\\s+i\\s+in\\b[^;]*?;\\s*do\\b[^;]*?(?:sleep|Start-Sleep)[^;]*?\\.gm[\\\\/](?:exec-spool|spool)/i,
|
|
47
|
+
/\\b(?:cat|head|tail|less|more|type|Get-Content|gc)\\s+(?:-[A-Za-z]+\\s+)*['"]?[^'"|;&]*\\.gm[\\\\/](?:exec-spool|spool)[\\\\/]/i,
|
|
48
|
+
/\\b(?:ls|dir|Get-ChildItem|gci)\\s+(?:-[A-Za-z]+\\s+)*['"]?[^'"|;&]*\\.gm[\\\\/](?:exec-spool|spool)[\\\\/]/i,
|
|
49
|
+
/\\b(?:test|Test-Path|tp)\\s+(?:-[A-Za-z]+\\s+)?['"]?[^'"|;&]*\\.gm[\\\\/](?:exec-spool|spool)[\\\\/]/i,
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const SPOOL_POLL_REASON = 'spool polling and bash-reads of .gm/exec-spool/ are forbidden — plugkit is synchronous from your view, and the canonical way to inspect spool files is the Read tool. Use Read on .gm/exec-spool/out/<verb>-<N>.json directly. If the response file does not exist, the watcher is either dead (Read .gm/exec-spool/.status.json and check its mtime against now) or the verb is genuinely slow (Read .gm/exec-spool/.watcher.log for the dispatch trace). You are the state machine; plugkit serves the response the moment you write the request, and Read is how you observe the result.';
|
|
53
|
+
|
|
54
|
+
function stripHeredocsAndStringLiterals(command) {
|
|
55
|
+
let s = String(command);
|
|
56
|
+
s = s.replace(/<<-?\\s*'([A-Z_]+)'[\\s\\S]*?\\n\\1/g, '');
|
|
57
|
+
s = s.replace(/<<-?\\s*"?([A-Z_]+)"?[\\s\\S]*?\\n\\1/g, '');
|
|
58
|
+
s = s.replace(/\\$\\(cat\\s+<<-?\\s*'?([A-Z_]+)'?[\\s\\S]*?\\n\\1\\s*\\)/g, '');
|
|
59
|
+
s = s.replace(/-m\\s+(['"])(?:\\\\.|(?!\\1)[^\\\\])*\\1/g, '-m STR');
|
|
60
|
+
s = s.replace(/--message[= ]+(['"])(?:\\\\.|(?!\\1)[^\\\\])*\\1/g, '--message STR');
|
|
61
|
+
return s;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function isSpoolPollCommand(command) {
|
|
65
|
+
if (!command) return null;
|
|
66
|
+
const stripped = stripHeredocsAndStringLiterals(command);
|
|
67
|
+
for (const re of SPOOL_POLL_PATTERNS) {
|
|
68
|
+
if (re.test(stripped)) return re.source;
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let raw = '';
|
|
74
|
+
process.stdin.setEncoding('utf8');
|
|
75
|
+
process.stdin.on('data', (chunk) => { raw += chunk; });
|
|
76
|
+
process.stdin.on('end', () => {
|
|
77
|
+
let event = {};
|
|
78
|
+
try { event = JSON.parse(raw || '{}'); } catch (_) { event = {}; }
|
|
79
|
+
const tool = event.tool_name || event.tool || '';
|
|
80
|
+
const input = event.tool_input || event.input || {};
|
|
81
|
+
if (tool !== 'Bash') {
|
|
82
|
+
process.stdout.write(JSON.stringify({ continue: true }));
|
|
83
|
+
process.exit(0);
|
|
84
|
+
}
|
|
85
|
+
const command = input.command || input.cmd || '';
|
|
86
|
+
const pattern = isSpoolPollCommand(command);
|
|
87
|
+
if (!pattern) {
|
|
88
|
+
process.stdout.write(JSON.stringify({ continue: true }));
|
|
89
|
+
process.exit(0);
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const fs = require('fs');
|
|
93
|
+
const path = require('path');
|
|
94
|
+
const os = require('os');
|
|
95
|
+
const day = new Date().toISOString().slice(0, 10);
|
|
96
|
+
const dir = path.join(process.env.GM_LOG_DIR || path.join(os.homedir(), '.claude', 'gm-log'), day);
|
|
97
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
98
|
+
fs.appendFileSync(path.join(dir, 'hook.jsonl'), JSON.stringify({
|
|
99
|
+
ts: new Date().toISOString(),
|
|
100
|
+
sub: 'hook',
|
|
101
|
+
event: 'deviation.spool-poll',
|
|
102
|
+
pid: process.pid,
|
|
103
|
+
sess: process.env.CLAUDE_SESSION_ID || process.env.GM_SESSION_ID || '',
|
|
104
|
+
cwd: process.cwd(),
|
|
105
|
+
operation: 'bash',
|
|
106
|
+
pattern,
|
|
107
|
+
command_excerpt: String(command).slice(0, 200),
|
|
108
|
+
via: 'pre-tool-use-hook',
|
|
109
|
+
}) + '\\n');
|
|
110
|
+
} catch (_) {}
|
|
111
|
+
process.stdout.write(JSON.stringify({
|
|
112
|
+
decision: 'block',
|
|
113
|
+
reason: SPOOL_POLL_REASON,
|
|
114
|
+
}));
|
|
115
|
+
process.exit(2);
|
|
116
|
+
});
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function ensureSpoolPollGate(cwd) {
|
|
121
|
+
try {
|
|
122
|
+
const gmHooks = path.join(cwd, '.gm', 'hooks');
|
|
123
|
+
fs.mkdirSync(gmHooks, { recursive: true });
|
|
124
|
+
const gateScript = path.join(gmHooks, 'spool-poll-gate.js');
|
|
125
|
+
const want = spoolPollGateScript();
|
|
126
|
+
let need = true;
|
|
127
|
+
try {
|
|
128
|
+
const existing = fs.readFileSync(gateScript, 'utf8');
|
|
129
|
+
if (existing === want) need = false;
|
|
130
|
+
} catch (_) {}
|
|
131
|
+
if (need) fs.writeFileSync(gateScript, want);
|
|
132
|
+
|
|
133
|
+
const claudeDir = path.join(cwd, '.claude');
|
|
134
|
+
fs.mkdirSync(claudeDir, { recursive: true });
|
|
135
|
+
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
136
|
+
let settings = {};
|
|
137
|
+
try {
|
|
138
|
+
const rawSettings = fs.readFileSync(settingsPath, 'utf8');
|
|
139
|
+
settings = JSON.parse(rawSettings || '{}');
|
|
140
|
+
} catch (_) { settings = {}; }
|
|
141
|
+
if (!settings.hooks || typeof settings.hooks !== 'object') settings.hooks = {};
|
|
142
|
+
if (!Array.isArray(settings.hooks.PreToolUse)) settings.hooks.PreToolUse = [];
|
|
143
|
+
const wantCommand = `node "\${CLAUDE_PROJECT_DIR}/.gm/hooks/spool-poll-gate.js"`;
|
|
144
|
+
let bashEntry = settings.hooks.PreToolUse.find(e => e && e.matcher === 'Bash');
|
|
145
|
+
if (!bashEntry) {
|
|
146
|
+
bashEntry = { matcher: 'Bash', hooks: [] };
|
|
147
|
+
settings.hooks.PreToolUse.push(bashEntry);
|
|
148
|
+
}
|
|
149
|
+
if (!Array.isArray(bashEntry.hooks)) bashEntry.hooks = [];
|
|
150
|
+
const already = bashEntry.hooks.some(h => h && typeof h.command === 'string' && h.command.includes('spool-poll-gate.js'));
|
|
151
|
+
if (!already) {
|
|
152
|
+
bashEntry.hooks.push({ type: 'command', command: wantCommand });
|
|
153
|
+
}
|
|
154
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
|
|
155
|
+
} catch (_) {}
|
|
156
|
+
}
|
|
157
|
+
|
|
30
158
|
function applyDisciplineSigil(rawBody) {
|
|
31
159
|
let parsed;
|
|
32
160
|
try { parsed = JSON.parse(rawBody); } catch (_) { return rawBody; }
|
package/gm.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gm-skill",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1214",
|
|
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.
|
|
42
|
+
"gm-plugkit": "^2.0.1214"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=16.0.0"
|