create-pmos 0.449.0 → 0.450.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.449.0",
3
+ "version": "0.450.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -32,6 +32,18 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.450.0",
37
+ "at": "2026-10-29T08:31:57.056Z",
38
+ "f": 2,
39
+ "prs": [
40
+ {
41
+ "n": 1096,
42
+ "t": "Grill runs go to the Claude API; --changed narrows further",
43
+ "s": "Grill runs go to the Claude API; --changed narrows further"
44
+ }
45
+ ]
46
+ },
35
47
  {
36
48
  "v": "0.449.0",
37
49
  "at": "2026-10-29T08:16:15.214Z",
@@ -259,18 +271,6 @@
259
271
  "s": "A milestone on the Board timeline says its own name and date."
260
272
  }
261
273
  ]
262
- },
263
- {
264
- "v": "0.430.0",
265
- "at": "2026-10-28T00:05:38.060Z",
266
- "f": 2,
267
- "prs": [
268
- {
269
- "n": 1073,
270
- "t": "Feedback batch 16",
271
- "s": "Feedback batch 16"
272
- }
273
- ]
274
274
  }
275
275
  ]
276
276
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@1d705eff
1
+ kernel-source: pmos@07f13caa
2
2
  assembled: 2026-10-29
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-10-29T08:16:11Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-29T08:31:54Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-10-29T08:16:11Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-29T08:31:54Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-10-29T08:16:11Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-29T08:31:54Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,16 @@
1
1
  [
2
+ {
3
+ "v": "0.450.0",
4
+ "at": "2026-10-29T08:31:57.056Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 1096,
9
+ "t": "Grill runs go to the Claude API; --changed narrows further",
10
+ "s": "Grill runs go to the Claude API; --changed narrows further"
11
+ }
12
+ ]
13
+ },
2
14
  {
3
15
  "v": "0.449.0",
4
16
  "at": "2026-10-29T08:16:15.214Z",
@@ -0,0 +1,146 @@
1
+ 'use strict';
2
+ /* grill-api.js — a grill run on the Claude API instead of a background `claude -p` session (Grill and Forecast, part G-A; lib/grill-runs.js
3
+ * starts it, lib/grill.js says what it may spend). The run is a plain tool loop on the Messages API with the same limits as the CLI run:
4
+ *
5
+ * read_file · find_files · search_text read-only, inside the repository root; no write, no web
6
+ * pmos only the verbs the grill skill uses: initiative export · task list · source status|show · grill find|voices|status
7
+ *
8
+ * The run's only write is `pmos grill find` (pinned by the run's PMOS_GRILL_* env, as in the CLI run). The loop stops at its budget:
9
+ * after every response the cost is counted from the usage, and the run ends before it can pass --budget.
10
+ *
11
+ * available(env) → bool an API key is set (ANTHROPIC_API_KEY) and PMOS_GRILL_API is not off
12
+ * costOf(model, usage) → US dollars null for a model with no known price
13
+ * run({ prompt, root, env, budget, model?, client?, signal?, pmosBin? }) → Promise<{ ok, code, costUsd, note?, turns }>
14
+ * (the shape lib/grill-runs.js `ended` reads: { code, result: { ok, costUsd } })
15
+ */
16
+ const fs = require('fs');
17
+ const path = require('path');
18
+ const { execFile } = require('child_process');
19
+
20
+ const DEFAULT_MODEL = 'claude-opus-5-5';
21
+ const PRICE = Object.freeze({ // US dollars per million tokens: input, output, cache read, cache write (5 min)
22
+ 'claude-opus-5-5': [4, 20, 0.4, 5], 'claude-opus-5': [5, 25, 0.5, 6.25], 'claude-sonnet-5-5': [2, 10, 0.2, 2.5], 'claude-sonnet-5': [2, 10, 0.2, 2.5], 'claude-haiku-5-5': [0.1, 0.5, 0.01, 0.125],
23
+ });
24
+ const MAX_TURNS = 30;
25
+ const MAX_TOKENS = 8000;
26
+ const READ_MAX = 60000;
27
+ const OUT_MAX = 12000;
28
+ const SKIP = new Set(['node_modules', '.git', 'dist', 'build']);
29
+ const PMOS_OK = [['initiative', 'export'], ['task', 'list'], ['source', 'status'], ['source', 'show'], ['grill', 'find'], ['grill', 'voices'], ['grill', 'status']];
30
+
31
+ const flagOff = (v) => /^(off|0|false|no)$/i.test(String(v || '').trim());
32
+ const available = (env = process.env) => !!(env.ANTHROPIC_API_KEY && String(env.ANTHROPIC_API_KEY).trim()) && !flagOff(env.PMOS_GRILL_API);
33
+ const modelOf = (env = process.env) => String(env.PMOS_GRILL_MODEL || '').trim() || DEFAULT_MODEL;
34
+ function costOf(model, usage) {
35
+ const p = PRICE[model]; if (!p || !usage) return null;
36
+ const n = (k) => Number(usage[k]) || 0;
37
+ return (n('input_tokens') * p[0] + n('output_tokens') * p[1] + n('cache_read_input_tokens') * p[2] + n('cache_creation_input_tokens') * p[3]) / 1e6;
38
+ }
39
+
40
+ const TOOLS = [
41
+ { name: 'read_file', description: 'Read one text file of the repository. path is relative to the repository root. Returns the first 60000 characters.',
42
+ input_schema: { type: 'object', properties: { path: { type: 'string' } }, required: ['path'], additionalProperties: false } },
43
+ { name: 'find_files', description: 'List repository files whose path contains the text (case-insensitive), at most 200. Example: "planning/prd".',
44
+ input_schema: { type: 'object', properties: { contains: { type: 'string' } }, required: ['contains'], additionalProperties: false } },
45
+ { name: 'search_text', description: 'Search repository text files for a literal string (case-insensitive). Returns path:line: text, at most 100 lines.',
46
+ input_schema: { type: 'object', properties: { text: { type: 'string' }, under: { type: 'string', description: 'optional folder, relative to the root' } }, required: ['text'], additionalProperties: false } },
47
+ { name: 'pmos', description: 'Run one pmos command. Allowed: initiative export <id>; task list <id>; source status; source show <source>; grill find <angle> --json - (the JSON goes in stdin); grill voices --sources <n>; grill status. Anything else is refused.',
48
+ input_schema: { type: 'object', properties: { args: { type: 'array', items: { type: 'string' } }, stdin: { type: 'string', description: 'JSON for grill find' } }, required: ['args'], additionalProperties: false } },
49
+ ];
50
+
51
+ const within = (root, rel) => {
52
+ const abs = path.resolve(root, String(rel || ''));
53
+ return abs === root || abs.startsWith(root + path.sep) ? abs : null;
54
+ };
55
+ function walk(root, dir, visit, state) {
56
+ let ents = []; try { ents = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
57
+ for (const e of ents) {
58
+ if (state.stop) return;
59
+ if (SKIP.has(e.name)) continue;
60
+ const abs = path.join(dir, e.name);
61
+ if (e.isDirectory()) walk(root, abs, visit, state);
62
+ else if (e.isFile()) visit(abs, path.relative(root, abs));
63
+ }
64
+ }
65
+ const isText = (buf) => !buf.subarray(0, 2000).includes(0);
66
+
67
+ function runPmos(input, { root, env, pmosBin }) {
68
+ const args = Array.isArray(input.args) ? input.args.map(String) : [];
69
+ if (!PMOS_OK.some(([a, b]) => args[0] === a && args[1] === b)) return Promise.resolve({ text: 'refused: this run may run only ' + PMOS_OK.map((x) => x.join(' ')).join(', '), error: true });
70
+ return new Promise((resolve) => {
71
+ const child = execFile(process.execPath, [pmosBin, ...args], { cwd: root, env, timeout: 60000, maxBuffer: 4e6 }, (err, stdout, stderr) => {
72
+ resolve({ text: String(stdout || '') + (stderr ? '\n' + stderr : '') || (err ? String(err.message) : '(no output)'), error: !!err });
73
+ });
74
+ child.stdin.on('error', () => {});
75
+ child.stdin.end(typeof input.stdin === 'string' ? input.stdin : '');
76
+ });
77
+ }
78
+
79
+ async function callTool(name, input, ctx) {
80
+ const i = input && typeof input === 'object' ? input : {};
81
+ try {
82
+ if (name === 'read_file') {
83
+ const abs = within(ctx.root, i.path); if (!abs) return { text: 'refused: outside the repository', error: true };
84
+ const buf = fs.readFileSync(abs); if (!isText(buf)) return { text: 'not a text file', error: true };
85
+ return { text: buf.toString('utf8').slice(0, READ_MAX) };
86
+ }
87
+ if (name === 'find_files') {
88
+ const q = String(i.contains || '').toLowerCase(), out = [], st = { stop: false };
89
+ walk(ctx.root, ctx.root, (abs, rel) => { if (rel.toLowerCase().includes(q)) { out.push(rel); if (out.length >= 200) st.stop = true; } }, st);
90
+ return { text: out.join('\n') || '(none)' };
91
+ }
92
+ if (name === 'search_text') {
93
+ const q = String(i.text || '').toLowerCase(), base = within(ctx.root, i.under || ''); if (!base || !q) return { text: 'refused: bad folder or empty text', error: true };
94
+ const out = [], st = { stop: false };
95
+ walk(ctx.root, base, (abs, rel) => {
96
+ let buf; try { if (fs.statSync(abs).size > 2e6) return; buf = fs.readFileSync(abs); } catch { return; }
97
+ if (!isText(buf)) return;
98
+ const lines = buf.toString('utf8').split('\n');
99
+ for (let n = 0; n < lines.length && !st.stop; n++) if (lines[n].toLowerCase().includes(q)) { out.push(`${rel}:${n + 1}: ${lines[n].trim().slice(0, 200)}`); if (out.length >= 100) st.stop = true; }
100
+ }, st);
101
+ return { text: out.join('\n') || '(no match)' };
102
+ }
103
+ if (name === 'pmos') return await runPmos(i, ctx);
104
+ return { text: 'unknown tool ' + name, error: true };
105
+ } catch (e) { return { text: 'failed: ' + String((e && e.message) || e).slice(0, 200), error: true }; }
106
+ }
107
+
108
+ async function run({ prompt, root, env: extra, budget, model, client, signal, pmosBin } = {}) {
109
+ const env = { ...process.env, ...(extra || {}) };
110
+ const useModel = model || modelOf(env), limit = Number(budget);
111
+ if (!available(env) && !client) return { ok: false, code: 1, costUsd: 0, turns: 0, note: 'no ANTHROPIC_API_KEY' };
112
+ if (PRICE[useModel] == null) return { ok: false, code: 1, costUsd: 0, turns: 0, note: `no known price for ${useModel}: the budget cannot be held` };
113
+ const api = client || new (require('@anthropic-ai/sdk'))({ apiKey: env.ANTHROPIC_API_KEY });
114
+ const ctx = { root: path.resolve(root || process.cwd()), env, pmosBin: pmosBin || path.join(__dirname, '..', 'bin', 'pmos.js') };
115
+ const messages = [{ role: 'user', content: String(prompt) }];
116
+ let cost = 0, turns = 0;
117
+ const done = (ok, note) => ({ ok, code: ok ? 0 : 1, costUsd: Math.round(cost * 10000) / 10000, turns, ...(note ? { note } : {}) });
118
+ while (turns < MAX_TURNS) {
119
+ if (signal && signal.aborted) return { ...done(false, 'stopped'), stopped: true };
120
+ turns++;
121
+ let res;
122
+ try {
123
+ res = await api.messages.create({ model: useModel, max_tokens: MAX_TOKENS, thinking: { type: 'adaptive' }, output_config: { effort: 'medium' },
124
+ system: 'You are Claude, running one PMOS grill run. Follow the procedure in the user message. Your tools are read-only except `pmos grill find`; there is no web and no `Bash`: where the procedure names a `pmos` command, call the pmos tool with its args.',
125
+ tools: TOOLS, messages }, signal ? { signal } : undefined);
126
+ } catch (e) {
127
+ if (signal && signal.aborted) return { ...done(false, 'stopped'), stopped: true };
128
+ return done(false, 'the Claude API failed: ' + String((e && e.status ? e.status + ' ' : '') + ((e && e.message) || e)).slice(0, 200));
129
+ }
130
+ cost += costOf(useModel, res.usage) || 0;
131
+ messages.push({ role: 'assistant', content: res.content });
132
+ if (res.stop_reason === 'refusal') return done(false, 'Claude declined this run');
133
+ if (res.stop_reason === 'max_tokens') return done(false, 'the answer was cut at max_tokens');
134
+ if (res.stop_reason !== 'tool_use') return done(true);
135
+ if (Number.isFinite(limit) && limit > 0 && cost >= limit) return done(false, `the run reached its $${limit} budget`);
136
+ const results = [];
137
+ for (const b of res.content) if (b.type === 'tool_use') {
138
+ const r = await callTool(b.name, b.input, ctx);
139
+ results.push({ type: 'tool_result', tool_use_id: b.id, content: String(r.text).slice(0, OUT_MAX), ...(r.error ? { is_error: true } : {}) });
140
+ }
141
+ messages.push({ role: 'user', content: results });
142
+ }
143
+ return done(false, `the run did not finish in ${MAX_TURNS} turns`);
144
+ }
145
+
146
+ module.exports = { available, modelOf, costOf, run, TOOLS, PRICE, DEFAULT_MODEL, MAX_TURNS };
@@ -12,6 +12,7 @@
12
12
  * deps: { workspaces() → [w], isLead(w), stateDirFor(w), runtimeDir(), rowOf(w, id) → { title, intent, stage, stages } | null,
13
13
  * exits(w) → [{ ini, board, stage }] (stages about to end), shapes(w) → [{ ini, board, n, end }] (open tasks, latest due),
14
14
  * goalInis(w, goalId) → [{ id, endAt, status }] (the initiatives anchored to that goal), checks(w, day) → [{ ini, board, tasks }] (late or at-risk work), turned(dir, sinceIso) → [forecast `turned` line] (lib/forecast.js),
15
+ * api { available(env), run({ prompt, root, env, budget, signal }) → Promise<{ ok, code, costUsd, note?, stopped? }> } (lib/grill-api.js; optional),
15
16
  * setting(key) (lib/settings-store.js get), open(now) → bool, headlessOff() → bool, env, promptFor(skillId), spawn(spec), stop(session), warn }
16
17
  */
17
18
  const crypto = require('crypto');
@@ -90,10 +91,21 @@ function create(deps) {
90
91
  const open = mine.filter((p) => !P.drops.has(PR.sigOf(p)) && !kept.has(p.id)).slice(0, 20).map((p) => one(p.title, 120));
91
92
  const prompt = promptOf(skill, { run, why, detail, ini, title: row.title || ini, intent: row.intent || '', stage: row.stage || '', stages: row.stages || [], today: localDay(now), open, dropped, budget: b.budget });
92
93
  active.set(run, { session: null });
94
+ const env = { PMOS_GRILL_FILE: PR.ledgerFile(dir), PMOS_GRILL_LOG: G.logFile(rt), PMOS_GRILL_WS: ws, PMOS_GRILL_BOARD: board || '', PMOS_GRILL_INI: ini, PMOS_GRILL_RUN: run, PMOS_GRILL_BUDGET: String(b.budget) };
95
+ // With an API key the run goes to the Claude API (lib/grill-api.js); without one it stays a background agent session
96
+ if (deps.api && deps.api.available(deps.env)) {
97
+ const ctl = new AbortController();
98
+ G.append(rt, { kind: 'start', run, ws, ini, board: board || '', why, key, budget: b.budget }, now);
99
+ active.get(run).session = { abort: () => ctl.abort() };
100
+ Promise.resolve().then(() => deps.api.run({ prompt, root: w.root, env, budget: b.budget, signal: ctl.signal }))
101
+ .then((r) => ended(run, { code: r.code, stopped: !!r.stopped, note: r.note, result: { ok: r.ok, costUsd: r.costUsd } }),
102
+ (e) => ended(run, { code: 1, note: String((e && e.message) || e), result: { costUsd: 0 } }));
103
+ return { ok: true, run, budget: b.budget, api: true };
104
+ }
93
105
  let session = null;
94
106
  try {
95
107
  session = deps.spawn({ name: 'Grilling · ' + one(row.title || ini, 60), ws, origin: `grill:${ws}:${ini}:${run}`, initialInput: prompt + '\r', initiative: ini,
96
- env: { PMOS_GRILL_FILE: PR.ledgerFile(dir), PMOS_GRILL_LOG: G.logFile(rt), PMOS_GRILL_WS: ws, PMOS_GRILL_BOARD: board || '', PMOS_GRILL_INI: ini, PMOS_GRILL_RUN: run, PMOS_GRILL_BUDGET: String(b.budget) },
108
+ env,
97
109
  onDone: (r) => ended(run, r) });
98
110
  } catch (e) { warn('grill run', e); }
99
111
  if (session && session.held) { active.delete(run); return { ok: false, held: true, error: 'Claude is busy with other runs; it grills in a minute' }; }
@@ -107,7 +119,7 @@ function create(deps) {
107
119
  return { ok: true, run, budget: b.budget };
108
120
  }
109
121
 
110
- function stop(run) { const a = active.get(run); if (a && a.session && deps.stop) deps.stop(a.session); }
122
+ function stop(run) { const a = active.get(run); if (!a || !a.session) return; if (a.session.abort) a.session.abort(); else if (deps.stop) deps.stop(a.session); }
111
123
 
112
124
  /** What is due now, in order: stage exits, forecast turns, big moves, the monthly look. → [{ ws, board, ini, why, key, detail }] */
113
125
  function dueOf(w, F, mode, now) {
@@ -20,6 +20,9 @@
20
20
  * the run's whole budget, which goes to the run as --max-budget-usd, so the month never goes beyond the cap. At the cap Claude pauses and
21
21
  * says so once per month (a `paused` line).
22
22
  *
23
+ * WHERE IT RUNS: with ANTHROPIC_API_KEY set, a run goes to the Claude API (lib/grill-api.js: a tool loop on the Messages API, model
24
+ * PMOS_GRILL_MODEL or claude-opus-5-5, cost counted from usage and held to the budget); PMOS_GRILL_API=off or no key keeps the background agent session.
25
+ *
23
26
  * THE LOG, <runtime>/grill-runs.jsonl (machine-wide, so the cap covers every product), one line per event { at, kind, ... }:
24
27
  * start { run, ws, ini, board, why, key, budget } key: what started it (the stage, the turn, the move), so it runs once per key
25
28
  * voices { run, n } how many stored research and note sources the run found for Voices
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.449.0",
3
+ "version": "0.450.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.449.0",
9
+ "version": "0.450.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
+ "@anthropic-ai/sdk": "^1.3.0",
12
13
  "@xterm/addon-fit": "^0.11.0",
13
14
  "@xterm/addon-web-links": "^0.12.0",
14
15
  "@xterm/xterm": "^5.5.0",
@@ -27,6 +28,52 @@
27
28
  "node": ">=18"
28
29
  }
29
30
  },
31
+ "node_modules/@anthropic-ai/sdk": {
32
+ "version": "1.3.0",
33
+ "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-1.3.0.tgz",
34
+ "integrity": "sha512-k7z9BlLLPxfZH+ov7dS6EnaN/wiZeV8YNT1LZfrpAHIy7oY7pHr4UzirF9f2OlHtFEnRBOX+AZQ91Y5fK+TPTw==",
35
+ "license": "Apache-2.0",
36
+ "dependencies": {
37
+ "@opentelemetry/api": "^1.4.1",
38
+ "json-schema-to-ts": "^3.1.1",
39
+ "standardwebhooks": "^1.0.0"
40
+ },
41
+ "bin": {
42
+ "anthropic-ai-sdk": "bin/cli"
43
+ },
44
+ "peerDependencies": {
45
+ "zod": "^3.25.0 || ^4.0.0"
46
+ },
47
+ "peerDependenciesMeta": {
48
+ "zod": {
49
+ "optional": true
50
+ }
51
+ }
52
+ },
53
+ "node_modules/@babel/runtime": {
54
+ "version": "7.29.10",
55
+ "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.10.tgz",
56
+ "integrity": "sha512-NpugTzbKgGrNe45Ui32cN8vCFFMxVtP/9rtfwv0nP5FRDAjvYBxJcLVpYA9mr1jxP6cnIT7x9LUzuDTbWYYNRA==",
57
+ "license": "MIT",
58
+ "engines": {
59
+ "node": ">=6.9.0"
60
+ }
61
+ },
62
+ "node_modules/@opentelemetry/api": {
63
+ "version": "1.10.0",
64
+ "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.10.0.tgz",
65
+ "integrity": "sha512-lMkyes8iHrG+mk6WH7X70MdCLI2RS0FwNBY1PyQ8UemaijE2m5mv5A0Niy3HtbYTFrgkUEQjFMXmSAk2hQDuPQ==",
66
+ "license": "Apache-2.0",
67
+ "engines": {
68
+ "node": ">=8.0.0"
69
+ }
70
+ },
71
+ "node_modules/@stablelib/base64": {
72
+ "version": "1.0.1",
73
+ "resolved": "https://registry.npmjs.org/@stablelib/base64/-/base64-1.0.1.tgz",
74
+ "integrity": "sha512-1bnPQqSxSuc3Ii6MhBysoWCg58j97aUjuCSZrGSmDxNqtytIi0k8utUenAwTZN4V5mXXYGsVUI9zeBqy+jBOSQ==",
75
+ "license": "MIT"
76
+ },
30
77
  "node_modules/@xterm/addon-fit": {
31
78
  "version": "0.11.0",
32
79
  "resolved": "https://registry.npmjs.org/@xterm/addon-fit/-/addon-fit-0.11.0.tgz",
@@ -45,6 +92,25 @@
45
92
  "integrity": "sha512-hqJHYaQb5OptNunnyAnkHyM8aCjZ1MEIDTQu1iIbbTD/xops91NB5yq1ZK/dC2JDbVWtF23zUtl9JE2NqwT87A==",
46
93
  "license": "MIT"
47
94
  },
95
+ "node_modules/fast-sha256": {
96
+ "version": "1.3.0",
97
+ "resolved": "https://registry.npmjs.org/fast-sha256/-/fast-sha256-1.3.0.tgz",
98
+ "integrity": "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==",
99
+ "license": "Unlicense"
100
+ },
101
+ "node_modules/json-schema-to-ts": {
102
+ "version": "3.1.1",
103
+ "resolved": "https://registry.npmjs.org/json-schema-to-ts/-/json-schema-to-ts-3.1.1.tgz",
104
+ "integrity": "sha512-+DWg8jCJG2TEnpy7kOm/7/AxaYoaRbjVB4LFZLySZlWn8exGs3A4OLJR966cVvU26N7X9TWxl+Jsw7dzAqKT6g==",
105
+ "license": "MIT",
106
+ "dependencies": {
107
+ "@babel/runtime": "^7.18.3",
108
+ "ts-algebra": "^2.0.0"
109
+ },
110
+ "engines": {
111
+ "node": ">=16"
112
+ }
113
+ },
48
114
  "node_modules/node-addon-api": {
49
115
  "version": "7.1.1",
50
116
  "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz",
@@ -96,6 +162,22 @@
96
162
  "node": ">=14.19.0"
97
163
  }
98
164
  },
165
+ "node_modules/standardwebhooks": {
166
+ "version": "1.1.1",
167
+ "resolved": "https://registry.npmjs.org/standardwebhooks/-/standardwebhooks-1.1.1.tgz",
168
+ "integrity": "sha512-bCbX9ZEyFkWPsRz7Bl3NuQUJohmwGSev/yhr7vhaGPlc4AfIrspIRa6cPTBuI1ItmrTDJ4d/S2hCsfe4+vQGnQ==",
169
+ "license": "MIT",
170
+ "dependencies": {
171
+ "@stablelib/base64": "^1.0.0",
172
+ "fast-sha256": "^1.3.0"
173
+ }
174
+ },
175
+ "node_modules/ts-algebra": {
176
+ "version": "2.0.0",
177
+ "resolved": "https://registry.npmjs.org/ts-algebra/-/ts-algebra-2.0.0.tgz",
178
+ "integrity": "sha512-FPAhNPFMrkwz76P7cdjdmiShwMynZYN6SgOujD1urY4oNm80Ou9oMdmbR45LotcKOXoy7wSmHkRFE6Mxbrhefw==",
179
+ "license": "MIT"
180
+ },
99
181
  "node_modules/ws": {
100
182
  "version": "8.21.1",
101
183
  "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.1.tgz",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.449.0",
3
+ "version": "0.450.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -24,6 +24,7 @@
24
24
  "node": ">=18"
25
25
  },
26
26
  "dependencies": {
27
+ "@anthropic-ai/sdk": "^1.3.0",
27
28
  "@xterm/addon-fit": "^0.11.0",
28
29
  "@xterm/addon-web-links": "^0.12.0",
29
30
  "@xterm/xterm": "^5.5.0",
@@ -355,10 +355,22 @@ function traceChanges(changes, ctx) {
355
355
  if (b) { const w = routes(b.keys, `server.js:${n}`); if (w) return w; continue; }
356
356
  const own = fnAt(n);
357
357
  if (own && own.name !== 'handleRequest') { const w = useOf(own.name); if (w) return `${own.name} (server.js:${n}) is used by ${w}`; continue; }
358
+ const mod = wiringOf(n);
359
+ if (mod) { nameHits(mod).forEach((x) => picked.add(x)); if (inList.has('test.js')) picked.add('test.js'); continue; } // start-up wiring of one lib module: the suites that name it, and the server boot suite
358
360
  return `server.js:${n}, outside every route and function`;
359
361
  }
360
362
  return null;
361
363
  };
364
+ // A line inside a top-level statement that builds one lib module (`const x = require('./lib/m.js').create({ ... })`): the module's file.
365
+ const wiringOf = (n) => {
366
+ const { C } = parseServer();
367
+ for (let i = n - 1; i >= 0; i--) {
368
+ if (!C[i].trim() || /^\s/.test(C[i])) continue; // inside the statement: keep going up to its first line
369
+ const m = /^(?:const|let)\s+\w+\s*=\s*require\(\s*'\.\/(lib\/[\w.-]+)'\s*\)\.\w+\(\{\s*$/.exec(C[i]);
370
+ return m ? m[1] : null;
371
+ }
372
+ return null;
373
+ };
362
374
  const useOf = (name) => { // the routes that use the top-level `name` of server.js
363
375
  if (used.has(name)) return null;
364
376
  used.add(name);
@@ -385,7 +397,9 @@ function traceChanges(changes, ctx) {
385
397
  return w;
386
398
  };
387
399
  const users1 = (f) => {
388
- const re = new RegExp(`[/'"\`]${reEsc(stemOf(f))}(?:\\.m?js)?['"\`]`);
400
+ // a path or a file name: './x', '/x.js' or 'x.js'. A bare quoted word ('grill') is a string, not a use of lib/grill.js.
401
+ const re = new RegExp(`[/'"\`]${reEsc(stemOf(f))}\\.m?js['"\`]|/${reEsc(stemOf(f))}['"\`]`);
402
+ const pathRe = new RegExp(`/${reEsc(stemOf(f))}(?:\\.m?js)?['"\`]`);
389
403
  let n = 0;
390
404
  for (const g of code) {
391
405
  if (g === f) continue;
@@ -396,14 +410,21 @@ function traceChanges(changes, ctx) {
396
410
  if (WIDE.has(g)) return `${f} is used by ${g}`;
397
411
  if (g.startsWith('public/')) { viaPublic(g); continue; }
398
412
  if (g === 'server.js') {
399
- const names = []; const inline = [];
413
+ const names = []; const inline = []; const factories = [];
400
414
  t.split('\n').forEach((line, i) => {
401
- if (!re.test(line)) return;
415
+ if (!re.test(line) || !pathRe.test(line)) return; // a bare quoted word ('grill') is not a path
402
416
  if (/'\/lib\//.test(line)) return; // served to the browser: the public graph has it
403
417
  const m = /^(?:const|let|var)\s+(?:\{([^}]*)\}|(\w+))\s*=\s*require\(/.exec(line);
404
- if (m) names.push(...(m[1] ? m[1].split(',').map((x) => x.split(':').pop().trim()).filter(Boolean) : [m[2]]));
418
+ if (m && /require\([^)]*\)\.create\(/.test(line)) factories.push(m[2]); // a service built at start-up: only a route that calls it can reach a page
419
+ else if (m) names.push(...(m[1] ? m[1].split(',').map((x) => x.split(':').pop().trim()).filter(Boolean) : [m[2]]));
405
420
  else inline.push(i + 1); // a require inside a function or a route: that line
406
421
  });
422
+ for (const name of factories.filter(Boolean)) { // only the uses inside a route block; a timer or a start-up call is the boot suite's
423
+ if (used.has(name)) continue; used.add(name);
424
+ const { C, blockAt } = parseServer(); const re = new RegExp(`\\b${reEsc(name)}\\b`);
425
+ for (let i = 0; i < C.length; i++) { const b = re.test(C[i]) ? blockAt(i + 1) : null; if (b) { const w = routes(b.keys, `server.js:${i + 1}`); if (w) return w; } }
426
+ if (inList.has('test.js')) picked.add('test.js');
427
+ }
407
428
  for (const name of names) { const w = useOf(name); if (w) return w; }
408
429
  const w = serverLines(inline); if (w) return w;
409
430
  continue;
@@ -472,9 +493,30 @@ function changedSuites(list, ref, { exact = false } = {}) {
472
493
  });
473
494
  const read = (f) => { try { return fs.readFileSync(path.join(DIR, f), 'utf8'); } catch { return null; } };
474
495
  const browser = new Set([...FILES.panels, ...FILES.ui]);
496
+ const deps = changedDeps(git('diff', '-U0', base, '--', path.join(DIR, 'package.json')), changes.some((c) => c.file === 'package.json'));
497
+ if (deps) { // a dependency was added or bumped: only the files that require it, and the install check, can be reached by it
498
+ for (let i = changes.length - 1; i >= 0; i--) if (changes[i].file === 'package.json' || changes[i].file === 'package-lock.json') changes.splice(i, 1);
499
+ const hit = (f) => /\.m?js$/.test(f) && deps.some((d) => new RegExp(`require\\(\\s*['"]${reEsc(d)}(?:/[^'"]*)?['"]\\s*\\)|from\\s+['"]${reEsc(d)}['"]`).test(read(f) || ''));
500
+ for (const f of all) if (hit(f) && !changes.some((c) => c.file === f)) changes.push({ file: f });
501
+ changes.push({ file: 'offline-tarball.test.js' });
502
+ }
475
503
  return { files, ...traceChanges(changes, { list, read, files: [...new Set([...all, ...files])], browser }) };
476
504
  }
477
505
 
506
+ /* The dependency names a package.json diff adds or bumps, when that is ALL it changes (a script, the engines or any other line returns null:
507
+ * then package.json stays wide). `changed` is false when package.json is not in the diff. package-lock.json then follows it. */
508
+ function changedDeps(diff, changed) {
509
+ if (!changed || diff == null) return null;
510
+ const names = [];
511
+ for (const line of diff.split('\n')) {
512
+ if (!/^[+-]/.test(line) || /^(\+\+\+|---)/.test(line)) continue;
513
+ const m = /^[+-]\s*"(@?[\w./-]+)"\s*:\s*"[^"]*",?\s*$/.exec(line);
514
+ if (!m || /^(name|version|description|license|main|bin|start|test|engines|node)$/.test(m[1]) || /^(test|start|doctor)/.test(m[1])) return null;
515
+ names.push(m[1]);
516
+ }
517
+ return names.length ? [...new Set(names)] : null;
518
+ }
519
+
478
520
  /* The new-side line numbers a `git diff -U0` touches. A pure removal counts the lines on both sides of where it was. */
479
521
  function diffLines(diff) {
480
522
  const out = [];
@@ -637,4 +679,4 @@ async function main() {
637
679
  }
638
680
 
639
681
  if (require.main === module) main().catch((e) => { console.error(e); process.exitCode = 1; });
640
- else module.exports = { traceChanges, diffLines, strip, WIDE };
682
+ else module.exports = { traceChanges, diffLines, strip, changedDeps, WIDE };
@@ -2953,6 +2953,7 @@ const grillRuns = require('./lib/grill-runs.js').create({
2953
2953
  open: deepOpenNow,
2954
2954
  headlessOff: () => headlessLib.switchedOff(process.env),
2955
2955
  env: process.env,
2956
+ api: require('./lib/grill-api.js'),
2956
2957
  promptFor: (skillId) => { const h = homeWorkspace(); const t = taskById(skillId, h ? h.root : SELF_ROOT); return t && t.prompt ? t.prompt : null; },
2957
2958
  spawn: (spec) => orchSpawn.spawn({ name: spec.name, agent: 'claude', ws: spec.ws, origin: spec.origin, initialInput: spec.initialInput, initiative: spec.initiative, extraEnv: spec.env, autoDelete: undefined, onDone: spec.onDone }),
2958
2959
  stop: (s) => { if (s && s.child) stopHeadless(s); },