claude-code-session-manager 0.144.0 → 0.145.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.
Files changed (57) hide show
  1. package/dist/assets/{AppSettings-Z68gQiVE.js → AppSettings-BR5b6oof.js} +2 -2
  2. package/dist/assets/{History-C3E6y_7t.js → History-B4U0mCdK.js} +1 -1
  3. package/dist/assets/HomeClaudeConfig-DQqG7lFE.js +5 -0
  4. package/dist/assets/{Panel-CnfWs46Z.js → Panel-CwsOJ0nI.js} +1 -1
  5. package/dist/assets/{ProjectClaudeConfig-CP0Wsg-H.js → ProjectClaudeConfig-BzRowu8x.js} +1 -1
  6. package/dist/assets/{Scheduler-D8un7N3B.js → Scheduler-dr7CNOcL.js} +1 -1
  7. package/dist/assets/{SkillReferenceGraph-DRtZV1Al.js → SkillReferenceGraph-CroBPY4C.js} +1 -1
  8. package/dist/assets/{Skills-Bg5O2Hyn.js → Skills-BiW2lCnD.js} +1 -1
  9. package/dist/assets/{TiptapBody-BdzoBmqu.js → TiptapBody-CYTkQiva.js} +1 -1
  10. package/dist/assets/{Toggle-Dt5K1OXt.js → Toggle-WFBYo8JI.js} +1 -1
  11. package/dist/assets/{VoiceButton-CTLyRgdF.js → VoiceButton-DZu8dTpO.js} +1 -1
  12. package/dist/assets/{historyTotals-B2_KWBga.js → historyTotals-B7KeXLSE.js} +1 -1
  13. package/dist/assets/{index-446b69rr.js → index-hXRNm0UJ.js} +128 -128
  14. package/dist/index.html +1 -1
  15. package/dist-web/app.js +394 -394
  16. package/package.json +1 -1
  17. package/plugins/session-manager-dev/skills/develop/SKILL.md +11 -6
  18. package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +1 -1
  19. package/plugins/session-manager-dev/skills/maintaining-md-network/weekly-consolidation.md +8 -4
  20. package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +9 -6
  21. package/src/main/build-info.json +4 -4
  22. package/src/main/chatRunner.cjs +35 -5
  23. package/src/main/config.cjs +12 -0
  24. package/src/main/index.cjs +2 -2
  25. package/src/main/ipcSchemas.cjs +5 -0
  26. package/src/main/lib/claude/headlessMcpServers.cjs +1 -1
  27. package/src/main/lib/claude/personaToolScope.cjs +23 -8
  28. package/src/main/lib/demo-video-kit/resumableRun.cjs +21 -14
  29. package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
  30. package/src/main/lib/epic/epicOutsideRead.cjs +43 -8
  31. package/src/main/lib/epic/planReviewInput.cjs +2 -0
  32. package/src/main/lib/epic/scriptStartedBy.cjs +19 -4
  33. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +84 -12
  34. package/src/main/lib/feedback-remote/localAdminHttp.cjs +5 -1
  35. package/src/main/lib/feedback-remote/serviceMcpSession.cjs +6 -3
  36. package/src/main/lib/feedback-remote/servicePairings.cjs +48 -0
  37. package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +11 -6
  38. package/src/main/lib/mcpToolCatalog.cjs +4 -2
  39. package/src/main/lib/opsOwnership.cjs +2 -0
  40. package/src/main/lib/prd/prdCreate.cjs +2 -1
  41. package/src/main/lib/prd/prdMcpReachWarnings.cjs +3 -1
  42. package/src/main/lib/prd/prdSandboxWarnings.cjs +1 -1
  43. package/src/main/lib/scheduler/planReviewStore.cjs +24 -2
  44. package/src/main/lib/scheduler/reviewNotice.cjs +3 -1
  45. package/src/main/lib/tasks/memoryConsolidation.cjs +21 -12
  46. package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +131 -11
  47. package/src/main/runVerify.cjs +77 -3
  48. package/src/main/scheduler/gitTreeGuard.cjs +6 -0
  49. package/src/main/scheduler/planReviewHold.cjs +11 -5
  50. package/src/main/scheduler/prdPaths.cjs +10 -1
  51. package/src/main/scheduler.cjs +170 -18
  52. package/src/main/templates/PRD_AUTHORING.md +2 -2
  53. package/src/main/webRemote.cjs +22 -0
  54. package/src/preload/api.d.ts +8 -0
  55. package/src/preload/apiSurface.json +11 -0
  56. package/src/preload/index.cjs +2 -0
  57. package/dist/assets/HomeClaudeConfig-Yd1vXzBn.js +0 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-session-manager",
3
- "version": "0.144.0",
3
+ "version": "0.145.0",
4
4
  "description": "Free desktop app for Claude Code: run many sessions, each in its own git worktree; queue work that runs headless within your usage limits; agents drive it through an MCP server and skills.",
5
5
  "type": "module",
6
6
  "main": "src/main/index.cjs",
@@ -85,11 +85,13 @@ three failure modes have different fixes:
85
85
  human to start the app, then retry the same call. Why: a PRD file the API did not write is
86
86
  quarantined and never runs.
87
87
  - **(b) Create errors with "did not answer" or "Connection closed".** It may still have been written; retry the same call with the same slug (it returns the existing PRD with `alreadyExisted: true`, or per entry `applied`) and never re-issue it under a new slug. `scheduler_get_prd` accepts the bare slug.
88
- - **(c) Tool ABSENT from your tool list.** The `session-manager-scheduler` MCP server is not
89
- registered: a **misconfiguration**, not an offline app.
90
- **STOP. Do not write any PRD file.** Tell the human. The app registers the server at user
91
- scope the first time it starts. If it is still missing, the human deletes
92
- `~/.claude/session-manager/.scheduler-mcp-seeded`, restarts the app, and opens a new session.
88
+ - **(c) Tool ABSENT from your tool list.** A **misconfiguration**, not an offline app.
89
+ **STOP. Do not write any PRD file.** Diagnose first: run `claude mcp get session-manager-scheduler`.
90
+ If it shows **Connected**, the server is registered and the chat's gear scope hid it: look for
91
+ a `Gear:` notice in the chat and report it to the human as a Session Manager gear bug. Never
92
+ delete the seeded marker or restart for it. Only if it is NOT registered: the app registers it
93
+ at user scope on first start; the human deletes `~/.claude/session-manager/.scheduler-mcp-seeded`,
94
+ restarts the app, and opens a new session.
93
95
  Never add a project `.mcp.json` entry yourself. Why: it brings back per-repo drift.
94
96
 
95
97
  ### Steps
@@ -186,7 +188,7 @@ Never pass `parallelGroup`; it is ignored. The API writes the frontmatter, `# Fi
186
188
  ### gate and files rules
187
189
 
188
190
  The syntax rules for `gate` and `files` are in PRD_AUTHORING.md §6, and the API enforces them: it
189
- refuses a bad gate or path and returns warnings — read them and fix the input. Two rules only you
191
+ refuses a bad gate or path and returns warnings — read them and fix the input. Three rules only you
190
192
  can apply, because they depend on the repo at authoring time:
191
193
 
192
194
  1. Before queueing, run each gate command once at the current HEAD in the main checkout. If it
@@ -198,6 +200,9 @@ can apply, because they depend on the repo at authoring time:
198
200
  criterion; keep them out of PRDs at authoring time (PRD_AUTHORING.md §14, No human-only gates).
199
201
  Live-run steps that need gitignored state follow PRD_AUTHORING.md §7 (absolute main-checkout
200
202
  paths, artifact-only).
203
+ 3. Never list a path under `.claude/agents`, `commands`, `skills`, `hooks` or `settings*.json` in
204
+ `files`: the job sandbox refuses every write there, so the architect makes that edit inline
205
+ in the Epic chat (PRD_AUTHORING.md#job-sandbox-limits).
201
206
 
202
207
  ### What a headless run cannot do
203
208
 
@@ -81,6 +81,6 @@ Weekly consolidation
81
81
  - [ ] Look for a pending weekly Task record; walk it if found (weekly-consolidation.md)
82
82
  - [ ] Else gather memory, network, transcripts, Lessons blocks, steering file
83
83
  - [ ] Subagents find patterns; keep those seen in 2+ sessions
84
- - [ ] Write the record: verify, organize, enrich changes plus housekeeping
84
+ - [ ] Write the record: verify, organize, enrich, procedure changes plus housekeeping
85
85
  - [ ] Owner accepts or rejects each change; apply only accepted ones, commit the record
86
86
  ```
@@ -40,10 +40,13 @@ Each kept pattern becomes ONE change of one kind:
40
40
  - **verify:** a memory or doc line no longer true is fixed or removed.
41
41
  - **organize:** duplicates are merged; a lasting fact moves from memory into the doc that owns it (placement.md).
42
42
  - **enrich:** a missing lesson is added.
43
+ - **procedure:** a new skill or small tool is proposed for a multi-step procedure that was worked out by hand (the same steps rebuilt from scratch, not run from a doc) in at least 2 sessions in the window. The proposal names the skill's path, when to use it, its steps, and the files or commands it relies on; a tool instead names its path and the README line that lists it. Before you propose one, search the project's existing skills (`.claude/skills/`, `plugins/*/skills/`), tools and docs for the same procedure. If one already covers it, propose an edit to that file as **organize** instead, never a second skill. A pattern that repeats a single step, or that only produced a lesson, stays enrich.
43
44
 
44
45
  ## Keep learnings few
45
46
 
46
- - At most 5 enrich adds per run.
47
+ - At most 5 adds per run: enrich and procedure together.
48
+ - At most 1 procedure per run. If more than one qualifies, propose the one seen in the most sessions; the rest produce no change.
49
+ - A run with no procedure rebuilt by hand in 2+ sessions proposes none.
47
50
  - Merges and removals are unlimited.
48
51
  - Prefer pruning.
49
52
 
@@ -70,18 +73,19 @@ Template:
70
73
  | Id | Kind | Target file | Change | Example sessions | Count |
71
74
  | --- | --- | --- | --- | --- | --- |
72
75
  | c1 | verify / organize / enrich | <path> | <the change> | <id>, <id> | <N, at least 2> |
76
+ | c2 | procedure | <proposed skill or tool path> | <name; when to use it; steps; files or commands it relies on; README line for a tool> | <id>, <id> | <N, at least 2> |
73
77
  ```
74
78
 
75
- Every row names at least 2 session ids.
79
+ Every row names at least 2 session ids. A procedure row counts as an add in Totals.
76
80
 
77
81
  ## Apply
78
82
 
79
83
  1. The owner accepts or rejects each change. Only accepted changes are applied.
80
- 2. The architect applies them in the Epic the owner opened with the macro: memory edits inline; doc changes inline when small and provable, otherwise `/develop`.
84
+ 2. The architect applies them in the Epic the owner opened with the macro: memory edits inline; doc changes inline when small and provable, otherwise `/develop`. An accepted procedure row whose path is under `.claude/` (a skill) is written from the Epic chat, never by a PRD: headless job sandboxes mount `.claude/` read-only. A tool outside `.claude/` may go through `/develop`.
81
85
  3. Commit the record as session-manager-operations/reviews/docs/<YYYY-MM-DD>-md-network-weekly.md, following the record rules in drift-check.md.
82
86
 
83
87
  When pressed with Mode 'Weekly consolidation', first look for the newest pending weekly Task (`task_list` with pipeline memory-consolidation, then `task_get` for its output) and walk its record. If none is pending, run the pass in the Epic.
84
88
 
85
89
  ## Steering file
86
90
 
87
- Optional: session-manager-operations/md-network/steering.md. A human writes it and tracks it in git; it says what the owner thinks matters and does not. Read it as a plain file. No code reads it through `opsPath()`, so it needs no `opsOwnership.cjs` entry and no ops AGENTS.md owners row (it has no owning writer; the folder is human-authored). If code ever reads it through `opsPath()`, add the entry and the row then.
91
+ Optional: session-manager-operations/md-network/steering.md. A human writes it and tracks it in git; it says what the owner thinks matters and does not. The app reads it through `opsPath()`; it is declared `tracked` in `GIT_CLASS` with an ops AGENTS.md row. It has no owning writer (human-authored), so it gets no `OWNERS` entry.
@@ -241,9 +241,12 @@ Two distinct failure modes — don't conflate them:
241
241
  `active-index.json` is exactly the racing second writer the single-writer law
242
242
  exists to prevent. Tell the human to start the app, and report the finding to
243
243
  them in the meantime so it isn't lost.
244
- - **`feedback_open_session` is absent from your tool list entirely** — the
245
- `session-manager-scheduler` MCP server isn't registered for this project.
246
- That's a misconfiguration, not an offline app. Tell the human: the app
247
- registers the server at user scope the first time it starts; if it is still
248
- missing, delete `~/.claude/session-manager/.scheduler-mcp-seeded`, restart the
249
- app, and open a new session. Never add an MCP entry yourself.
244
+ - **`feedback_open_session` is absent from your tool list entirely** —
245
+ a misconfiguration, not an offline app. STOP: never hand-write the session.
246
+ Diagnose first: run `claude mcp get session-manager-scheduler`. If it shows
247
+ **Connected**, the server is registered and the chat's gear scope hid it —
248
+ look for a `Gear:` notice in the chat and report it to the human as a Session
249
+ Manager gear bug; never delete the seeded marker or restart for it. Only if it
250
+ is NOT registered: the app registers it at user scope on first start; delete
251
+ `~/.claude/session-manager/.scheduler-mcp-seeded`, restart the app, and open a
252
+ new session. Never add a project `.mcp.json` / MCP entry yourself.
@@ -1,8 +1,8 @@
1
1
  {
2
- "version": "0.144.0",
3
- "gitSha": "4760ce98481d63f0e842bcdfb9277d6eabb45c60",
4
- "gitShortSha": "4760ce98",
2
+ "version": "0.145.0",
3
+ "gitSha": "2a609e11c1db8f39df7efe6b76e52abafbe191f2",
4
+ "gitShortSha": "2a609e11",
5
5
  "gitBranch": "HEAD",
6
- "builtAt": "2026-11-27T02:32:59.091Z",
6
+ "builtAt": "2026-11-27T22:59:01.972Z",
7
7
  "dirty": false
8
8
  }
@@ -56,7 +56,7 @@ const { developLoopOffSettingsArgs } = require('./lib/epic/developLoopSpawn.cjs'
56
56
  const packSpawnArgs = require('./lib/packs/packSpawnArgs.cjs');
57
57
  const { resolveEpicEffort, effortArgs } = require('./lib/claude/agentEffortResolve.cjs');
58
58
  const { planEpicSpawn, resolveEpicTurnModel } = require('./lib/epic/epicSpawnPlan.cjs');
59
- const { buildPersonaToolScope, personaToolScopeArgs, skillDenyArgs } = require('./lib/claude/personaToolScope.cjs');
59
+ const { buildPersonaToolScope, personaToolScopeArgs, skillDenyArgs, HEADLESS_SCOPE_AGENT_NAME, CHAT_HARNESS_MCP_SERVERS } = require('./lib/claude/personaToolScope.cjs');
60
60
  const epicWorktreeMint = require('./lib/epic/epicWorktreeMint.cjs');
61
61
  const epicDepsSync = require('./lib/epic/epicDepsSync.cjs');
62
62
  const logs = require('./logs.cjs');
@@ -1689,6 +1689,29 @@ function registerChatHandlers() {
1689
1689
 
1690
1690
  const undecidedLogged = new Set();
1691
1691
 
1692
+ /**
1693
+ * Servers in the argv's --mcp-config that no --agents tools entry (mcp__<s> or mcp__<s>__*) grants.
1694
+ * [] when either flag is absent or unparseable. Pure.
1695
+ * @param {string[]} args
1696
+ * @returns {string[]}
1697
+ */
1698
+ function ungrantedMcpServers(args) {
1699
+ if (!Array.isArray(args)) return [];
1700
+ const ai = args.indexOf('--agents');
1701
+ const mi = args.indexOf('--mcp-config');
1702
+ if (ai < 0 || mi < 0) return [];
1703
+ let tools; let servers;
1704
+ try {
1705
+ const agents = JSON.parse(args[ai + 1]);
1706
+ const def = agents && agents[HEADLESS_SCOPE_AGENT_NAME];
1707
+ tools = def && Array.isArray(def.tools) ? def.tools.map(String) : null;
1708
+ servers = Object.keys((JSON.parse(args[mi + 1]) || {}).mcpServers || {});
1709
+ } catch { return []; }
1710
+ if (!tools) return [];
1711
+ const granted = new Set(tools.filter((t) => t.startsWith('mcp__')).map((t) => t.slice(5).split('__')[0]));
1712
+ return servers.filter((s) => !granted.has(s));
1713
+ }
1714
+
1692
1715
  /**
1693
1716
  * Gear for a chat turn (PRD 4768): the argv that gives an Epic whose pinned snapshot carries
1694
1717
  * `gearBindsChat` the same scope a job gets — persona tools, strict MCP with the declared servers,
@@ -1697,7 +1720,7 @@ const undecidedLogged = new Set();
1697
1720
  * An unknown declared server/pack never crashes the turn: it is dropped and reported in `errors`.
1698
1721
  * Pure apart from reading ~/.claude.json and <cwd>/.mcp.json (declared servers), the pack catalog and the seeded MCP entry (injectable for tests).
1699
1722
  * `projectRoot` is the Epic's main project cwd: a worktree `cwd` still sees servers under projects[<main root>].
1700
- * @param {{ snapshot: any, cwd?: string, projectRoot?: string, deps?: { home?: string, knownMcpServers?: Record<string, object>, listPacks?: () => { packs: any[] }, listUnpackedSkills?: () => string[], log?: (msg: string) => void } }} opts
1723
+ * @param {{ snapshot: any, cwd?: string, projectRoot?: string, deps?: { home?: string, knownMcpServers?: Record<string, object>, listPacks?: () => { packs: any[] }, listUnpackedSkills?: () => string[], log?: (msg: string) => void, scopeArgs?: typeof personaToolScopeArgs } }} opts
1701
1724
  * @returns {{ args: string[], errors: string[] }}
1702
1725
  */
1703
1726
  function gearChatArgs({ snapshot, cwd, projectRoot, deps = {} }) {
@@ -1729,9 +1752,13 @@ function gearChatArgs({ snapshot, cwd, projectRoot, deps = {} }) {
1729
1752
  try { unpacked = (deps.listUnpackedSkills || require('./lib/packs/packCatalog.cjs').listUnpackedSkills)(); } catch { unpacked = []; }
1730
1753
  const packs = Array.isArray(snapshot.packs) ? snapshot.packs.map(String) : [];
1731
1754
  const knownPackIds = new Set(catalog.map((p) => String(p.id)));
1732
- const declared = Array.isArray(snapshot.mcpServers) ? snapshot.mcpServers.map(String) : [];
1755
+ const personaDeclared = Array.isArray(snapshot.mcpServers) ? snapshot.mcpServers.map(String) : [];
1756
+ // SM's own harness rides every scoped chat; the scheduler is always kept so its absence is reported below.
1757
+ const harness = CHAT_HARNESS_MCP_SERVERS.filter((n) => n === 'session-manager-scheduler' || Object.prototype.hasOwnProperty.call(known || {}, n));
1758
+ const declared = [...new Set([...personaDeclared, ...harness])];
1733
1759
  const scope = buildPersonaToolScope(snapshot.tools, { loadout, disallowed: [] });
1734
- const attempt = personaToolScopeArgs(scope, { mcpServers: known, declaredServers: declared, packs, knownPacks: [...knownPackIds] });
1760
+ const scopeFn = deps.scopeArgs || personaToolScopeArgs;
1761
+ const attempt = scopeFn(scope, { mcpServers: known, declaredServers: declared, packs, knownPacks: [...knownPackIds] });
1735
1762
  /** @type {string[]} */ const errors = [];
1736
1763
  let scopeArgs = attempt.args;
1737
1764
  let equipped = packs;
@@ -1752,12 +1779,14 @@ function gearChatArgs({ snapshot, cwd, projectRoot, deps = {} }) {
1752
1779
  curDeclared = curDeclared.filter((d) => d !== r.name);
1753
1780
  curPacks = curPacks.filter((p) => p !== r.name);
1754
1781
  curScope = curScope ? { tools: curScope.tools.filter((t) => !(t.startsWith('mcp__') && t.slice(5).split('__')[0] === r.name) && t !== r.name) } : curScope;
1755
- cur = personaToolScopeArgs(curScope, { mcpServers: known, declaredServers: curDeclared, packs: curPacks, knownPacks: [...knownPackIds] });
1782
+ cur = scopeFn(curScope, { mcpServers: known, declaredServers: curDeclared, packs: curPacks, knownPacks: [...knownPackIds] });
1756
1783
  r = cur.refusal;
1757
1784
  }
1758
1785
  scopeArgs = cur.args;
1759
1786
  equipped = curPacks;
1760
1787
  }
1788
+ // A loaded-but-ungranted server is invisible to the CLI (even ToolSearch) — never omit it silently.
1789
+ for (const name of ungrantedMcpServers(scopeArgs)) errors.push(`Gear: "${name}" was loaded but not granted to this chat's tools; its tools are unavailable this turn.`);
1761
1790
  const installedSkills = [...new Set([...catalog.flatMap((p) => p.skills || []), ...unpacked].map(String))];
1762
1791
  const deny = skillDenyArgs({ installedSkills, equippedPacks: equipped, packCatalog: catalog, loadout });
1763
1792
  return { args: [...scopeArgs, ...deny], errors };
@@ -1775,6 +1804,7 @@ module.exports = {
1775
1804
  noteChatRunOrigin,
1776
1805
  turnInstructionFor,
1777
1806
  gearChatArgs,
1807
+ ungrantedMcpServers,
1778
1808
  shouldFollowUp,
1779
1809
  parseStopSignal,
1780
1810
  splitStopSignal,
@@ -79,6 +79,17 @@ function addAllowedRoot(dir) {
79
79
  if (dir) allowedRoots.add(pathFor().resolve(dir));
80
80
  }
81
81
 
82
+ /**
83
+ * Remove a root registered via addAllowedRoot (same normalization). Returns
84
+ * true when one was removed; the built-in home root is never removed.
85
+ */
86
+ function removeAllowedRoot(dir) {
87
+ if (!dir) return false;
88
+ const abs = pathFor().resolve(dir);
89
+ if (abs === pathFor().resolve(os.homedir())) return false;
90
+ return allowedRoots.delete(abs);
91
+ }
92
+
82
93
  /** Snapshot of the registered roots (main-process-registered only). */
83
94
  function getAllowedRoots() {
84
95
  return [...allowedRoots];
@@ -703,6 +714,7 @@ module.exports = {
703
714
  listDir,
704
715
  exists,
705
716
  addAllowedRoot,
717
+ removeAllowedRoot,
706
718
  getAllowedRoots,
707
719
  registerPromptSessionsRoot,
708
720
  transitionEpicArchiveWrite,
@@ -1598,7 +1598,7 @@ app.whenReady().then(async () => {
1598
1598
  label: 'Help',
1599
1599
  submenu: [
1600
1600
  {
1601
- label: 'Book a Free Hour with Bilko',
1601
+ label: 'Book a Free Consultation',
1602
1602
  click: () => {
1603
1603
  if (mainWindow && !mainWindow.isDestroyed()) {
1604
1604
  sendIfAlive(mainWindow, 'app:open-free-hour');
@@ -1791,7 +1791,7 @@ app.whenReady().then(async () => {
1791
1791
  // ~/.claude/projects scan, banned on timer paths); a project with no
1792
1792
  // subscriptions is a no-op.
1793
1793
  const runWebhookDelivery = () => {
1794
- scheduler.readQueue()
1794
+ Promise.resolve().then(() => scheduler.readQueue())
1795
1795
  .then((q) => require('./lib/telemetry/webhookDelivery.cjs').runDeliveryPass({
1796
1796
  cwds: (Array.isArray(q?.jobs) ? q.jobs : []).map((j) => j && j.cwd).filter((c) => typeof c === 'string' && c),
1797
1797
  logs,
@@ -1575,6 +1575,10 @@ const webRemoteServicePairCancel = z.object({
1575
1575
  const webRemoteServiceRevoke = z.object({
1576
1576
  serviceId: z.string().regex(WEB_REMOTE_UUID_RE),
1577
1577
  }).strict();
1578
+ const webRemoteServiceSetStartWork = z.object({
1579
+ serviceId: z.string().regex(WEB_REMOTE_UUID_RE),
1580
+ targets: z.array(z.string().min(1).max(4096)).max(200),
1581
+ }).strict();
1578
1582
  const webRemoteRelayClientRevoke = z.object({
1579
1583
  clientId: z.string().uuid(),
1580
1584
  }).strict();
@@ -1908,6 +1912,7 @@ module.exports = {
1908
1912
  webRemoteServiceConfirmSas,
1909
1913
  webRemoteServicePairCancel,
1910
1914
  webRemoteServiceRevoke,
1915
+ webRemoteServiceSetStartWork,
1911
1916
  webRemoteRelayClientRevoke,
1912
1917
  sessionSubscribe,
1913
1918
  ptySpawn,
@@ -35,7 +35,7 @@ function serversOf(map) {
35
35
  const SECRET_FLAG_RE = /^--(api-key|apikey|token|access-token|secret|password|auth|pat)(=|$)/i;
36
36
  const EXTRA_KEY_RE = /(^|_)(PAT|CREDENTIALS?|PRIVATE_KEY)$/i;
37
37
  const QUERY_KEY_RE = /(token|key|secret|password|sig|signature|auth)/i;
38
- const USERINFO_RE = /[a-z][a-z0-9+.-]*:\/\/[^/\s:@]+:[^/\s@]*@/i;
38
+ const USERINFO_RE = /[a-z][a-z0-9+.-]*:\/\/[^/?#\s@]+@/i;
39
39
  const HINT = 'move the secret to a vault ref (environment profile) or run it outside the job';
40
40
 
41
41
  function secretKey(key) {
@@ -89,14 +89,6 @@ const hasOwn = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
89
89
  function personaToolScopeArgs(scope, { mcpServers, declaredServers = [], packs = [], knownPacks = [] } = {}) {
90
90
  /** @type {string[]} */
91
91
  const args = [];
92
- if (scope) {
93
- const def = {
94
- description: 'Headless run with a scheduler-enforced tool scope.',
95
- prompt: 'Tool scope is enforced by the scheduler.',
96
- tools: scope.tools,
97
- };
98
- args.push('--agents', JSON.stringify({ [HEADLESS_SCOPE_AGENT_NAME]: def }), '--agent', HEADLESS_SCOPE_AGENT_NAME);
99
- }
100
92
  /** @type {null|{ code: 'capability_unknown', name: string }} */
101
93
  let refusal = null;
102
94
  const refuse = (name) => { if (!refusal) refusal = { code: 'capability_unknown', name }; };
@@ -123,6 +115,25 @@ function personaToolScopeArgs(scope, { mcpServers, declaredServers = [], packs =
123
115
  for (const p of Array.isArray(packs) ? packs : []) {
124
116
  if (!knownPackSet.has(String(p))) refuse(String(p));
125
117
  }
118
+ if (scope) {
119
+ // The --agents tools array scopes MCP tools too (probe 2026-11-27, CLI
120
+ // 2.1.330): a loaded server whose tools the array never names is invisible,
121
+ // even to ToolSearch. A server the persona DECLARES (mcpServers:) and names
122
+ // no single tool of is granted whole via the server-level `mcp__<server>`.
123
+ const tools = [...scope.tools];
124
+ for (const d of Array.isArray(declaredServers) ? declaredServers : []) {
125
+ const n = String(d).trim();
126
+ if (!n || !hasOwn(picked, n) || mcpTools.some((t) => mcpServerOf(t) === n)) continue;
127
+ const whole = `mcp__${n}`;
128
+ if (!tools.includes(whole)) tools.push(whole);
129
+ }
130
+ const def = {
131
+ description: 'Headless run with a scheduler-enforced tool scope.',
132
+ prompt: 'Tool scope is enforced by the scheduler.',
133
+ tools,
134
+ };
135
+ args.push('--agents', JSON.stringify({ [HEADLESS_SCOPE_AGENT_NAME]: def }), '--agent', HEADLESS_SCOPE_AGENT_NAME);
136
+ }
126
137
  // --mcp-config is variadic: it is followed immediately by --strict-mcp-config.
127
138
  // With no server, no --mcp-config at all — strict mode alone boots none.
128
139
  if (Object.keys(picked).length) args.push('--mcp-config', JSON.stringify({ mcpServers: picked }));
@@ -227,7 +238,11 @@ async function resolveSkillDeny({ packs = [], loadout, deps } = {}) {
227
238
  }
228
239
  }
229
240
 
241
+ /** Session Manager's own MCP harness, added to every scoped chat's declared servers (scheduler required, bilko-host optional). */
242
+ const CHAT_HARNESS_MCP_SERVERS = Object.freeze(['session-manager-scheduler', 'bilko-host']);
243
+
230
244
  module.exports = {
245
+ CHAT_HARNESS_MCP_SERVERS,
231
246
  resolveSkillDeny,
232
247
  JOB_MCP_TOOLS_ENV,
233
248
  personaToolScopeEnv,
@@ -263,25 +263,32 @@ function supervise(args) {
263
263
  // Not detached: the step and anything it spawns stay in this process group.
264
264
  const step = spawn(process.execPath, argv, { stdio: ['ignore', 'inherit', 'inherit'], cwd: process.cwd() });
265
265
  const every = Math.min(LEASE_CHECK_MAX_MS, Math.max(1, Math.floor(leaseMs / 4)));
266
- const timer = setInterval(() => {
267
- let age = Infinity;
268
- try { age = Date.now() - fs.statSync(leasePath(stateDir)).mtimeMs; } catch { /* missing lease = no caller */ }
269
- if (age <= leaseMs) return;
270
- clearInterval(timer);
271
- try {
272
- writeResult(stateDir, key, { ok: false, error: `abandoned: no caller for ${Math.round(leaseMs / 60000)} min` });
273
- } catch { /* stateDir gone */ }
274
- process.stderr.write(`resumableRun supervisor: lease expired, stopping group ${process.pid}\n`);
275
- killTree(process.pid);
276
- process.exit(1);
277
- }, every);
266
+ let timer = null;
267
+ const startLeaseClock = () => {
268
+ // The lease clock starts when the step process actually exists, not when
269
+ // startOrAttach ran: a loaded machine can delay this supervisor past leaseMs.
270
+ refreshLease(stateDir);
271
+ timer = setInterval(() => {
272
+ let age = Infinity;
273
+ try { age = Date.now() - fs.statSync(leasePath(stateDir)).mtimeMs; } catch { /* missing lease = no caller */ }
274
+ if (age <= leaseMs) return;
275
+ clearInterval(timer);
276
+ try {
277
+ writeResult(stateDir, key, { ok: false, error: `abandoned: no caller for ${Math.round(leaseMs / 60000)} min` });
278
+ } catch { /* stateDir gone */ }
279
+ process.stderr.write(`resumableRun supervisor: lease expired, stopping group ${process.pid}\n`);
280
+ killTree(process.pid);
281
+ process.exit(1);
282
+ }, every);
283
+ };
284
+ step.on('spawn', startLeaseClock);
278
285
  step.on('error', (err) => {
279
286
  process.stderr.write(`resumableRun supervisor: step failed to start: ${err.message}\n`);
280
- clearInterval(timer);
287
+ if (timer) clearInterval(timer);
281
288
  process.exit(1);
282
289
  });
283
290
  step.on('exit', (code, signal) => {
284
- clearInterval(timer);
291
+ if (timer) clearInterval(timer);
285
292
  // The step wrote its result before exiting; stop whatever it left in this
286
293
  // group (e.g. a voice wrapper's grandchildren). The waiter is not in it.
287
294
  const exitCode = code ?? (signal ? 1 : 0);
@@ -19,9 +19,9 @@ const path = require('node:path');
19
19
  const { schedulerHome } = require('../scheduler/schedulerPaths.cjs');
20
20
  const { writeTextAtomic } = require('../util/atomicFs.cjs');
21
21
 
22
- const KIT_VERSION = '45';
22
+ const KIT_VERSION = '46';
23
23
  // sha256 of kitDigest(__dirname). Update together with a KIT_VERSION bump.
24
- const KIT_DIGEST = 'd1735e9ad8044d68d81ba52fd4d95f5b80f763f2811a8674211d25ef5d49f482';
24
+ const KIT_DIGEST = '95029c2c1d26c80570102c6138ab3473536a56ddff5830802ca678e2b0fcd98d';
25
25
  const KIT_FILES = Object.freeze(['checks.cjs', 'sound.cjs', 'capture.cjs', 'frames.cjs', 'character.cjs', 'playwrightLoader.cjs', 'export.cjs', 'kind-tiktok.md', 'kind-marketing.md', 'cast.md', 'project-home-html.md', 'resumableRun.cjs', 'voiceLibrary.cjs', 'voiceLane.cjs', 'kokoroSay.cjs', 'projectSounds.cjs', 'standalone.cjs']);
26
26
  const STAMP_FILE = 'KIT_VERSION';
27
27
 
@@ -218,23 +218,58 @@ function startedByOf(raw) {
218
218
  return r.success ? r.data : null;
219
219
  }
220
220
 
221
- /** fixes[] ({ prd, missKind }) from this Epic's PRD files (prds/ and prds-archived/); [] on any failure. */
221
+ let MAX_FIX_FILES = 2000;
222
+ let MAX_FIX_CACHE = 5000;
223
+ /** Test seam: override the per-call file cap and the total cache bound. */
224
+ function _setFixesCapsForTests(files, cache) {
225
+ MAX_FIX_FILES = files == null ? 2000 : files;
226
+ MAX_FIX_CACHE = cache == null ? 5000 : cache;
227
+ }
228
+ /** Leading PRD number of a file name; -1 when it has none. */
229
+ function prdNN(name) {
230
+ const m = /^(\d+)/.exec(name);
231
+ return m ? Number(m[1]) : -1;
232
+ }
233
+ /** abs path -> { mtimeMs, size, fixes } — a repeat read re-parses only files whose stat changed. */
234
+ const fixesCache = new Map();
235
+
236
+ /** fixes[] ({ prd, missKind }) from this Epic's PRD files (prds/ and prds-archived/); [] on any failure. At most MAX_FIX_FILES files per call (the newest by name are kept). */
222
237
  function readEpicFixes(cwd, epicId) {
223
238
  const out = [];
224
239
  try {
225
240
  if (!isSafeEpicId(epicId)) return out;
226
241
  const base = path.join(opsPath(cwd, 'scheduler', 'epics'), epicId);
242
+ let files = [];
227
243
  for (const sub of ['prds', 'prds-archived']) {
228
244
  let names;
229
245
  try { names = fs.readdirSync(path.join(base, sub)); } catch { continue; }
230
- for (const n of names.filter((x) => x.endsWith('.md')).sort()) {
231
- try {
232
- const { fm } = splitFrontmatter(fs.readFileSync(path.join(base, sub, n), 'utf8'));
246
+ for (const n of names) if (n.endsWith('.md')) files.push({ n, p: path.join(base, sub, n) });
247
+ }
248
+ files.sort((x, y) => prdNN(x.n) - prdNN(y.n) || (x.n < y.n ? -1 : x.n > y.n ? 1 : x.p < y.p ? -1 : x.p > y.p ? 1 : 0));
249
+ files = files.map((f) => f.p);
250
+ if (files.length > MAX_FIX_FILES) files = files.slice(-MAX_FIX_FILES);
251
+ const seen = new Set(files);
252
+ for (const file of files) {
253
+ try {
254
+ const st = fs.statSync(file);
255
+ let hit = fixesCache.get(file);
256
+ if (!hit || hit.mtimeMs !== st.mtimeMs || hit.size !== st.size) {
257
+ const { fm } = splitFrontmatter(fs.readFileSync(file, 'utf8'));
233
258
  const list = typeof fm.fixes === 'string' ? parseFixes(fm.fixes) : null;
234
- for (const f of list || []) out.push({ prd: f.prd, missKind: f.missKind });
235
- } catch { /* skip unreadable PRD */ }
236
- }
259
+ hit = { mtimeMs: st.mtimeMs, size: st.size, fixes: (list || []).map((f) => ({ prd: f.prd, missKind: f.missKind })) };
260
+ fixesCache.set(file, hit);
261
+ } else {
262
+ // LRU: a hit moves the entry to the back so eviction drops the least recently used.
263
+ fixesCache.delete(file);
264
+ fixesCache.set(file, hit);
265
+ }
266
+ while (fixesCache.size > MAX_FIX_CACHE) fixesCache.delete(fixesCache.keys().next().value);
267
+ for (const f of hit.fixes) out.push({ prd: f.prd, missKind: f.missKind });
268
+ } catch { fixesCache.delete(file); /* skip unreadable or deleted PRD */ }
237
269
  }
270
+ // Drop deleted/out-of-scope files of this Epic from the cache.
271
+ const prefix = base + path.sep;
272
+ for (const k of fixesCache.keys()) if (k.startsWith(prefix) && !seen.has(k)) fixesCache.delete(k);
238
273
  } catch { /* none */ }
239
274
  return out;
240
275
  }
@@ -458,4 +493,4 @@ async function listOpenEpicRecords(cwd, opts = {}) {
458
493
  }
459
494
  }
460
495
 
461
- module.exports = { readVerdictFiles, listOpenEpicRecords, getEpicRecord, findEpicProject };
496
+ module.exports = { readEpicFixes, _setFixesCapsForTests, _fixesCacheSizeForTests: () => fixesCache.size, get MAX_FIX_FILES() { return MAX_FIX_FILES; }, get MAX_FIX_CACHE() { return MAX_FIX_CACHE; }, readVerdictFiles, listOpenEpicRecords, getEpicRecord, findEpicProject };
@@ -116,6 +116,8 @@ function buildPlanReviewInput({ epicId, cwd, epicGoal, validateSlug, members, ba
116
116
  agentType: 'plan-reviewer',
117
117
  tag: 'build',
118
118
  sourcePromptId: epicId,
119
+ // The plan's own PRDs are incomplete; without a disposition prdCreate refuses.
120
+ disposition: 'new-head',
119
121
  cwd,
120
122
  };
121
123
  }
@@ -2,7 +2,8 @@
2
2
 
3
3
  /**
4
4
  * scriptStartedBy.cjs — how a script-started Epic records who started it.
5
- * EpicSource.startedBy = { kind: 'script', route, caller?, fromCwd?, fromEpicId? };
5
+ * EpicSource.startedBy = { kind: 'script', route, caller?, fromCwd?, fromEpicId? }
6
+ * | { kind: 'service', serviceId, name } (a paired service under an owner grant);
6
7
  * absent for every human press. 'new-epic-ui' stays the mint authority
7
8
  * (epicMint.cjs); startedBy sits next to it. The stored shape is lenient
8
9
  * (promptSessionSchema.cjs); this is the strict entry-point validator.
@@ -17,7 +18,7 @@ const CallerSchema = z.object({
17
18
  attempt: z.number().int().min(0).optional(),
18
19
  }).strict();
19
20
 
20
- const StartedBySchema = z.object({
21
+ const ScriptStartedBySchema = z.object({
21
22
  kind: z.literal('script'),
22
23
  route: z.string().min(1).max(200),
23
24
  caller: CallerSchema.optional(),
@@ -25,6 +26,20 @@ const StartedBySchema = z.object({
25
26
  fromEpicId: z.string().max(200).optional(),
26
27
  }).strict();
27
28
 
29
+ /** A paired service started it under an owner startWork grant. */
30
+ const ServiceStartedBySchema = z.object({
31
+ kind: z.literal('service'),
32
+ serviceId: z.string().min(1).max(200),
33
+ name: z.string().min(1).max(200),
34
+ }).strict();
35
+
36
+ const StartedBySchema = z.discriminatedUnion('kind', [ScriptStartedBySchema, ServiceStartedBySchema]);
37
+
38
+ /** @param {{ serviceId: string, name: string }} args */
39
+ function buildServiceStartedBy({ serviceId, name }) {
40
+ return ServiceStartedBySchema.parse({ kind: 'service', serviceId, name });
41
+ }
42
+
28
43
  /**
29
44
  * Build a StartedBySchema-valid object, omitting absent/empty keys.
30
45
  * @param {{ route: string, caller?: object, fromCwd?: string, fromEpicId?: string }} args
@@ -40,7 +55,7 @@ function buildStartedBy({ route, caller, fromCwd, fromEpicId } = {}) {
40
55
  }
41
56
  if (typeof fromCwd === 'string' && fromCwd) out.fromCwd = fromCwd;
42
57
  if (typeof fromEpicId === 'string' && fromEpicId) out.fromEpicId = fromEpicId;
43
- return StartedBySchema.parse(out);
58
+ return ScriptStartedBySchema.parse(out);
44
59
  }
45
60
 
46
61
  /**
@@ -68,4 +83,4 @@ async function startedByFromRequest({ route, caller, socket } = {}, deps = {}) {
68
83
  return buildStartedBy({ route, caller, fromCwd, fromEpicId });
69
84
  }
70
85
 
71
- module.exports = { CallerSchema, StartedBySchema, buildStartedBy, startedByFromRequest };
86
+ module.exports = { CallerSchema, StartedBySchema, ScriptStartedBySchema, ServiceStartedBySchema, buildStartedBy, buildServiceStartedBy, startedByFromRequest };