claude-code-session-manager 0.139.0 → 0.140.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 (150) hide show
  1. package/README.md +20 -4
  2. package/dist/assets/AppSettings-CMFEM68R.js +2 -0
  3. package/dist/assets/History--JwsFnbn.js +2 -0
  4. package/dist/assets/{HomeClaudeConfig-CGD2Onjv.js → HomeClaudeConfig-ijEXs--3.js} +2 -2
  5. package/dist/assets/{Panel-Csyd9HbD.js → Panel-CALyU0pe.js} +1 -1
  6. package/dist/assets/{ProjectClaudeConfig-C-jlYpC_.js → ProjectClaudeConfig-sdlA-fUb.js} +1 -1
  7. package/dist/assets/Scheduler-YT3j8SUa.js +16 -0
  8. package/dist/assets/{SkillReferenceGraph-DcscPXAG.js → SkillReferenceGraph-CxAuwhNN.js} +1 -1
  9. package/dist/assets/{Skills-BpGRKOcY.js → Skills-DtRzghn5.js} +26 -26
  10. package/dist/assets/{TiptapBody-DSU3769X.js → TiptapBody-DApeu7x8.js} +1 -1
  11. package/dist/assets/{ViewTabs-C0PRZx4_.js → ViewTabs-B7qLXRAH.js} +1 -1
  12. package/dist/assets/{VoiceButton-D2rMurNg.js → VoiceButton-DtStfv1H.js} +1 -1
  13. package/dist/assets/{historyTotals-TcIQs2sh.js → historyTotals-ydfnwepc.js} +1 -1
  14. package/dist/assets/index-CtxruO1L.js +3121 -0
  15. package/dist/assets/{index-BCySPdtU.css → index-DKXdXfka.css} +1 -1
  16. package/dist/index.html +2 -2
  17. package/dist-web/app.css +1 -1
  18. package/dist-web/app.js +423 -426
  19. package/package.json +5 -2
  20. package/plugins/AGENTS.md +60 -0
  21. package/plugins/CLAUDE.md +1 -60
  22. package/plugins/session-manager-dev/skills/develop/SKILL.md +26 -19
  23. package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +5 -4
  24. package/plugins/session-manager-dev/skills/maintaining-md-network/audit.md +4 -2
  25. package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +16 -12
  26. package/plugins/session-manager-dev/skills/maintaining-md-network/migrate-to-agents-md.md +15 -0
  27. package/plugins/session-manager-dev/skills/maintaining-md-network/placement.md +50 -2
  28. package/plugins/session-manager-dev/skills/maintaining-md-network/plan.md +10 -10
  29. package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +117 -112
  30. package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdDuplicates.cjs +182 -0
  31. package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdLinks.cjs +340 -0
  32. package/scripts/README.md +1 -0
  33. package/scripts/hooks/guard-tool-risk.cjs +91 -0
  34. package/scripts/hooks/lib/guard-tool-risk-policy.cjs +217 -0
  35. package/scripts/ops-sweep.cjs +53 -23
  36. package/scripts/scheduler-mcp-server.cjs +200 -18
  37. package/src/main/build-info.json +4 -4
  38. package/src/main/config.cjs +112 -8
  39. package/src/main/docEdit.cjs +6 -1
  40. package/src/main/files.cjs +7 -27
  41. package/src/main/health.cjs +48 -15
  42. package/src/main/historyAggregator.cjs +88 -5
  43. package/src/main/historyDashboard.cjs +69 -4
  44. package/src/main/index.cjs +56 -2
  45. package/src/main/ipcSchemas.cjs +112 -16
  46. package/src/main/lib/AGENTS.md +54 -0
  47. package/src/main/lib/CLAUDE.md +1 -54
  48. package/src/main/lib/agent-cli/adapters/codex.cjs +5 -2
  49. package/src/main/lib/agent-cli/agentCliIpc.cjs +18 -2
  50. package/src/main/lib/agent-cli/agentCliSessionStore.cjs +1 -0
  51. package/src/main/lib/agent-cli/agentCliTurn.cjs +20 -2
  52. package/src/main/lib/agent-cli/geminiContextDefaults.cjs +94 -0
  53. package/src/main/lib/claude/effectiveModelInfo.cjs +90 -20
  54. package/src/main/lib/claude/jobSandboxPolicy.cjs +202 -0
  55. package/src/main/lib/claude/personaToolScope.cjs +12 -6
  56. package/src/main/lib/claude/rateLimitDetect.cjs +13 -2
  57. package/src/main/lib/claude/runClaudeP.cjs +6 -1
  58. package/src/main/lib/claude/toolRiskIpc.cjs +177 -0
  59. package/src/main/lib/claude/toolRiskMarks.cjs +373 -0
  60. package/src/main/lib/demo-video-kit/seedKit.cjs +27 -6
  61. package/src/main/lib/ephemeralCwd.cjs +37 -2
  62. package/src/main/lib/epic/delegationReadiness.cjs +42 -9
  63. package/src/main/lib/epic/epicAdminRoutes.cjs +25 -5
  64. package/src/main/lib/epic/epicOutsideRead.cjs +118 -1
  65. package/src/main/lib/epic/epicOutsideState.cjs +2 -2
  66. package/src/main/lib/epic/epicSweepValidator.cjs +7 -2
  67. package/src/main/lib/epic/epicValidationHook.cjs +24 -4
  68. package/src/main/lib/epic/guardSpawnSettings.cjs +57 -1
  69. package/src/main/lib/externalContract.cjs +31 -5
  70. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +55 -1
  71. package/src/main/lib/feedback-remote/crossProjectReply.cjs +106 -11
  72. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +47 -19
  73. package/src/main/lib/feedback-remote/needsYouStore.cjs +6 -2
  74. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +98 -1
  75. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +5 -0
  76. package/src/main/lib/git/branchSweep.cjs +209 -4
  77. package/src/main/lib/git/gitWorktree.cjs +41 -5
  78. package/src/main/lib/guardShims.cjs +1 -1
  79. package/src/main/lib/historyRollup.cjs +26 -0
  80. package/src/main/lib/insideHome.cjs +27 -1
  81. package/src/main/lib/mcpToolCatalog.cjs +122 -12
  82. package/src/main/lib/mdDocCensus.cjs +59 -78
  83. package/src/main/lib/mdDocRefs.cjs +71 -93
  84. package/src/main/lib/mdNetworkScan.cjs +245 -250
  85. package/src/main/lib/mdReviewRecord.cjs +22 -9
  86. package/src/main/lib/memoryMdNetwork.cjs +5 -12
  87. package/src/main/lib/opsOwnership.cjs +18 -2
  88. package/src/main/lib/opsRetentionSettings.cjs +28 -4
  89. package/src/main/lib/persona-macro/macroJobDispatch.cjs +90 -20
  90. package/src/main/lib/persona-macro/macroJobIpc.cjs +144 -46
  91. package/src/main/lib/persona-macro/macroJobStatus.cjs +87 -9
  92. package/src/main/lib/persona-macro/macroLibrary.cjs +95 -5
  93. package/src/main/lib/persona-macro/personaImportHealth.cjs +78 -17
  94. package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +96 -0
  95. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +11 -0
  96. package/src/main/lib/prd/depSlugResolve.cjs +104 -4
  97. package/src/main/lib/prd/prdAdminRoutes.cjs +35 -2
  98. package/src/main/lib/prd/prdCreate.cjs +351 -23
  99. package/src/main/lib/prd/prdDisposition.cjs +11 -2
  100. package/src/main/lib/prd/prdFrontmatter.cjs +96 -3
  101. package/src/main/lib/process/loginItem.cjs +171 -0
  102. package/src/main/lib/process/loginItemPlan.cjs +193 -0
  103. package/src/main/lib/project-pages/playerBridge.cjs +4 -0
  104. package/src/main/lib/project-pages/videoReview.cjs +268 -0
  105. package/src/main/lib/project-pages/videoReviewIpc.cjs +229 -0
  106. package/src/main/lib/scheduler/cpuSample.cjs +131 -4
  107. package/src/main/lib/scheduler/fixPlanSlug.cjs +4 -3
  108. package/src/main/lib/scheduler/loadGate.cjs +24 -6
  109. package/src/main/lib/scheduler/planRecordHarvest.cjs +108 -0
  110. package/src/main/lib/scheduler/planRecordRetention.cjs +144 -0
  111. package/src/main/lib/scheduler/queueStore.cjs +7 -0
  112. package/src/main/lib/scheduler/rcaReport.cjs +21 -1
  113. package/src/main/lib/scheduler/reaperHelpers.cjs +35 -5
  114. package/src/main/lib/scheduler/runLogRetention.cjs +104 -3
  115. package/src/main/lib/scheduler/scheduleJobSchema.cjs +3 -0
  116. package/src/main/lib/scheduler/schedulerBatch.cjs +25 -48
  117. package/src/main/lib/scheduler/schedulerPaths.cjs +3 -0
  118. package/src/main/lib/scheduler/sessionSlots.cjs +176 -21
  119. package/src/main/lib/scheduler/validationQuality.cjs +282 -0
  120. package/src/main/lib/scheduler/validatorVerdictSchema.cjs +254 -0
  121. package/src/main/lib/tasks/taskAdminRoutes.cjs +641 -0
  122. package/src/main/lib/tasks/taskIpc.cjs +80 -0
  123. package/src/main/lib/tasks/taskLedger.cjs +502 -0
  124. package/src/main/lib/tasks/taskRun.cjs +313 -0
  125. package/src/main/lib/tasks/taskSwitch.cjs +120 -0
  126. package/src/main/loginItemIpc.cjs +35 -0
  127. package/src/main/loopEfficiencyHandlers.cjs +10 -1
  128. package/src/main/projectPages.cjs +6 -15
  129. package/src/main/promptSessionEvents.cjs +9 -1
  130. package/src/main/queueOps.cjs +260 -3
  131. package/src/main/runVerify.cjs +53 -25
  132. package/src/main/scheduler/AGENTS.md +26 -0
  133. package/src/main/scheduler/CLAUDE.md +1 -26
  134. package/src/main/scheduler/budget.cjs +239 -9
  135. package/src/main/scheduler/cancelDependents.cjs +154 -0
  136. package/src/main/scheduler/prdParser.cjs +4 -1
  137. package/src/main/scheduler/starvation.cjs +20 -18
  138. package/src/main/scheduler.cjs +745 -64
  139. package/src/main/supervisor.cjs +5 -1
  140. package/src/main/templates/PRD_AUTHORING.md +6 -1
  141. package/src/main/validationQualityHandlers.cjs +199 -0
  142. package/src/main/webRemote.cjs +10 -2
  143. package/src/preload/api.d.ts +364 -21
  144. package/src/preload/apiSurface.json +89 -10
  145. package/src/preload/index.cjs +23 -2
  146. package/src/seed/agents/validator.md +19 -8
  147. package/dist/assets/AppSettings-CUfWY9vN.js +0 -2
  148. package/dist/assets/History-DDnqaLyw.js +0 -2
  149. package/dist/assets/Scheduler-NLs08fx7.js +0 -16
  150. package/dist/assets/index-C-d0DCre.js +0 -3124
@@ -20,10 +20,11 @@
20
20
  'use strict';
21
21
 
22
22
  const { z } = require('zod');
23
+ const { MISS_KINDS } = require('./scheduler/validatorVerdictSchema.cjs');
23
24
 
24
25
  const CatalogEntrySchema = z.object({
25
26
  name: z.string().min(1),
26
- group: z.enum(['scheduler', 'chat', 'feedback', 'help', 'project-home', 'macros', 'customer-feedback', 'epics', 'agents']),
27
+ group: z.enum(['scheduler', 'chat', 'feedback', 'help', 'project-home', 'macros', 'customer-feedback', 'epics', 'agents', 'tasks']),
27
28
  purpose: z.string().min(1),
28
29
  summary: z.string().min(10).max(90).regex(/^[^|`\n]+$/),
29
30
  whenToUse: z.string().min(1),
@@ -111,6 +112,11 @@ const MCP_TOOL_CATALOG = [
111
112
  + 'disk by the verifier, and declaring them is the ONLY way an artifact-only PRD can pass the finish '
112
113
  + 'protocol without a commit. Each requires the other (the write is refused if only one is given), and '
113
114
  + 'no path may contain "..". '
115
+ + '`riskTools` (optional, up to 20) names the tool-risk rules this PRD is cleared to call although they are '
116
+ + 'marked irreversible, money or public in a tool-risk.json, in the same syntax as the marks. '
117
+ + 'A bare slug already used by a PRD in ANOTHER Epic is refused as a cross-Epic duplicate (the error names '
118
+ + 'the exact NN slugs); add them to dependsOn, or call again with allowDuplicateOf: [those NN slugs] for a '
119
+ + 'deliberate duplicate. '
114
120
  + '`gate` and `files` are REQUIRED on every call — the tool refuses a call missing either. `gate` lists '
115
121
  + '1-10 commands that prove this PRD is done (each starting with `timeout <seconds>`, joined with `&&`, '
116
122
  + 'no shell metacharacters), or exactly `["none"]` for a PRD with no runnable check; the scheduler '
@@ -154,7 +160,9 @@ const MCP_TOOL_CATALOG = [
154
160
  + 'written and every per-entry error is returned as { index, slug, error }. Returns each slug and its NN, plus '
155
161
  + 'any advisory warnings. Like scheduler_create_prd it only writes files; the queue rows are derived by the '
156
162
  + 'next reconcile pass. All entries must resolve to the same project and Epic; top-level cwd, sourcePromptId '
157
- + 'and origin fields are forwarded the same way as scheduler_create_prd.',
163
+ + 'and origin fields are forwarded the same way as scheduler_create_prd. An entry whose bare slug already '
164
+ + 'exists in another Epic fails the batch as a cross-Epic duplicate; give that entry dependsOn on the named NN '
165
+ + 'slugs, or allowDuplicateOf: [those NN slugs] for a deliberate duplicate, and call again.',
158
166
  summary: 'Queue a whole plan of PRDs in one all-or-nothing call.',
159
167
  whenToUse: 'Use to queue a whole plan at once, validate PRD included: dependsOn may name other entries of the same call by bare slug (earlier or later), so a chain needs no ordering of calls.',
160
168
  whenNotToUse: 'Do not use for a single PRD — use scheduler_create_prd. Not callable from inside a headless scheduled job (same refusal as scheduler_create_prd). If the app is not running, stop and ask the human to start it; never hand-write PRD files.',
@@ -236,7 +244,9 @@ const MCP_TOOL_CATALOG = [
236
244
  + 'cancelled job lands as "failed" with an error naming the cause. Refuses a slug whose job is already terminal '
237
245
  + '(completed/failed/needs_review) — nothing to cancel. A cancelled running job\'s commits are never landed on '
238
246
  + 'the base branch; they stay on the job branch, reported in the result as landed:false plus '
239
- + 'jobBranch/jobBranchSha.',
247
+ + 'jobBranch/jobBranchSha. If the job has pending dependents the cancel is refused and lists them; call again '
248
+ + 'with dependents: { action: "cascade" } (cancel them too), { action: "repoint", to: "<slug>" } (depend on '
249
+ + 'another PRD instead) or { action: "clear" } (drop the dependency).',
240
250
  summary: 'Cancel a job that has not finished.',
241
251
  whenToUse: 'Use to stop a running or pending job that should not continue (e.g. it was queued in error, or scope changed underneath it).',
242
252
  whenNotToUse: 'Do not use on an already-terminal job (completed/failed/needs_review) — use scheduler_reset_job if it should run again.',
@@ -384,7 +394,7 @@ const MCP_TOOL_CATALOG = [
384
394
  html: '<!DOCTYPE html><html><head><style>body{font:16px sans-serif}</style></head><body><h1>Architecture</h1></body></html>',
385
395
  },
386
396
  notes: "cwd is optional — defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted. "
387
- + 'Give exactly one of `html` / `htmlPath` (absolute .html/.htm file, <= 2MB read limit).',
397
+ + 'Give exactly one of `html` / `htmlPath` (absolute .html/.htm file, <= 2 MiB read limit; the project_video_write cap is 2 MiB per started 30 s of lengthS).',
388
398
  },
389
399
  {
390
400
  name: 'project_matrix_read',
@@ -422,13 +432,15 @@ const MCP_TOOL_CATALOG = [
422
432
  requiredOneOf: [['html', 'htmlPath']],
423
433
  group: 'project-home',
424
434
  purpose: "Write one video for this project's Project Home — ONE self-contained HTML/JS document identified by `videoId` — "
425
- + "via the session-manager app's admin API. Writing an existing videoId replaces that video.",
435
+ + "via the session-manager app's admin API. Writing an existing videoId replaces that video. `kind` is 'project-demo', 'blog-post', "
436
+ + "'feature' or 'episode' (an episode of a series, e.g. from a Project Video tool). The video is 16:9 by default; a vertical 9:16 video "
437
+ + 'declares <meta name="sm-demo-aspect" content="9:16"> in its head.',
426
438
  summary: 'Save one self-contained HTML video for Project Home.',
427
439
  whenToUse: 'Use when asked to make a project video (demo, marketing). Compose the whole document yourself (inline <style>/<script>, '
428
440
  + 'data: URIs for assets, CSS/JS-driven animation) from what is really true about the project, declare `kind` and `lengthS`, '
429
441
  + 'then pass the document as `html` or — preferred when it embeds a base64 audio/image data URI — as an absolute `htmlPath`.',
430
442
  whenNotToUse: 'Never fabricate content. Do not use for static knowledge pages — use project_page_write. The document must be self-contained '
431
- + 'and non-network-capable: the call is rejected for empty input, more than 2MB, remote references, or network-capable APIs.',
443
+ + 'and non-network-capable: the call is rejected for empty input, more than 2 MiB per started 30 s of lengthS, remote references, or network-capable APIs.',
432
444
  exampleArgs: {
433
445
  cwd: '/home/bilko/Projects/session-manager',
434
446
  videoId: 'demo-30s',
@@ -439,7 +451,7 @@ const MCP_TOOL_CATALOG = [
439
451
  meta: {},
440
452
  },
441
453
  notes: "cwd is optional — defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted. "
442
- + 'Give exactly one of `html` / `htmlPath` (absolute .html/.htm file, <= 2MB).',
454
+ + 'Give exactly one of `html` / `htmlPath` (absolute .html/.htm file, <= 2 MiB per started 30 s of lengthS).',
443
455
  },
444
456
  {
445
457
  name: 'project_demo_video_write',
@@ -456,7 +468,7 @@ const MCP_TOOL_CATALOG = [
456
468
  + 'local .html file and pass its absolute path as `htmlPath`.',
457
469
  whenNotToUse: 'Never fabricate content — every claim must trace to something concrete in the project. The '
458
470
  + 'document must be self-contained and non-network-capable: the call is rejected for empty input, more than '
459
- + '2MB, any <script src>, <link href="http…">, @import, or url(http…) (no remote references); any '
471
+ + '2 MiB per started 30 s of lengthS (the sm-demo-duration seconds), any <script src>, <link href="http…">, @import, or url(http…) (no remote references); any '
460
472
  + 'fetch/XMLHttpRequest/WebSocket/EventSource/sendBeacon/dynamic import/importScripts/<iframe>/<object>/'
461
473
  + '<embed>/window.open/http(s)-pointing src or href (no network-capable APIs); or a missing/out-of-range '
462
474
  + 'sm-demo-duration meta tag.',
@@ -465,7 +477,7 @@ const MCP_TOOL_CATALOG = [
465
477
  html: '<!DOCTYPE html><html><head><meta name="sm-demo-duration" content="30"></head><body><h1>Example</h1></body></html>',
466
478
  },
467
479
  notes: "cwd is optional — defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted. "
468
- + 'Give exactly one of `html` / `htmlPath` (absolute .html/.htm file, <= 2MB); prefer `htmlPath` for base64 data URIs. '
480
+ + 'Give exactly one of `html` / `htmlPath` (absolute .html/.htm file, <= 2 MiB per started 30 s of lengthS); prefer `htmlPath` for base64 data URIs. '
469
481
  + 'The document is CSP-stamped after it is written, so the viewer sandbox is the real network fence — these checks are defence in depth.',
470
482
  },
471
483
  {
@@ -488,6 +500,28 @@ const MCP_TOOL_CATALOG = [
488
500
  notes: "cwd is optional — defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted. "
489
501
  + 'Give exactly one of `js` / `jsPath` (absolute .js file, <= 300KB).',
490
502
  },
503
+ {
504
+ name: 'project_video_review_write',
505
+ group: 'project-home',
506
+ purpose: 'Save review material (text up to 32000 characters, such as a whole episode script, and 1-6 images, such as a storyboard contact sheet) '
507
+ + "for a review-stage Project Video tool run, via the session-manager app's admin API. Saving again replaces the previous material. "
508
+ + 'It cannot approve, ask for changes or retry: only a human click in Project Home ▸ Video can.',
509
+ summary: 'Save a script and images for a human to review a video.',
510
+ whenToUse: 'Use at the end of a review-stage Project Video tool run, once the material the human must check is ready: pass the `videoId` '
511
+ + 'the run was dispatched for, the review `text`, and `imagePaths` (absolute .png/.jpg/.jpeg/.webp files, each at most 2 MiB). '
512
+ + 'Then stop and say the material waits for the human in Project Home ▸ Video.',
513
+ whenNotToUse: 'Never use it to record a decision — a call carrying decision, status, approved or approvedAt is refused, and no tool can '
514
+ + 'approve, ask for changes or retry. Do not use for the finished video — use project_video_write. The call is refused when the entry '
515
+ + 'has no recorded dispatch, for text outside 1-32000 characters, and for images that are not PNG, JPEG or WebP.',
516
+ exampleArgs: {
517
+ cwd: '/home/bilko/Projects/session-manager',
518
+ videoId: 'ep-1',
519
+ text: 'Episode 1 script: ...',
520
+ imagePaths: ['/tmp/ep-1/storyboard.png'],
521
+ },
522
+ notes: "cwd is optional — defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted. "
523
+ + 'The images are read from disk and base64-encoded by the MCP server before the save.',
524
+ },
491
525
  {
492
526
  name: 'customer_feedback_list',
493
527
  group: 'customer-feedback',
@@ -550,7 +584,10 @@ const MCP_TOOL_CATALOG = [
550
584
  purpose: "List this project's HOT KEYS macros — the saved (agent, tag, prompt) one-click buttons shown "
551
585
  + "in the Sessions tab's HOT KEYS strip or as tools in Project Home ▸ Tools, via the session-manager app's admin API. "
552
586
  + "Each macro's `surface` tells where it shows: 'sessions' = Sessions HOT KEYS strip, 'project-home' = a tool in "
553
- + 'Project Home ▸ Tools, shown in every project (only what it generates is per project).',
587
+ + 'Project Home ▸ Tools, shown in every project (only what it generates is per project), '
588
+ + "'project-video' = this project's own Video tool in Project Home ▸ Video only, beside Demo Video (never in Sessions HOT KEYS, "
589
+ + 'Project Home ▸ Tools, the phone remote or other projects); it carries `job` { estimateMinutes 5-60 (the run budget is 3x, capped at 180 minutes), '
590
+ + 'repoPaths (optional: a committing run that must land a commit under those paths), review (optional: a review stage a human approves first) }.',
554
591
  summary: "List this project's saved one-click macros.",
555
592
  whenToUse: 'Use to see what macros already exist for this project (including machine-wide `*` macros and '
556
593
  + 'built-ins) before deciding whether to add, update or delete one.',
@@ -564,7 +601,14 @@ const MCP_TOOL_CATALOG = [
564
601
  group: 'macros',
565
602
  purpose: "Create or update one of this project's HOT KEYS macros — a saved (agentName, tag, prompt) "
566
603
  + 'one-click button — via the session-manager app\'s admin API, through the same macroLibrary.cjs store '
567
- + 'the Sessions HOT KEYS strip reads from.',
604
+ + 'the Sessions HOT KEYS strip reads from. `surface` '
605
+ + "'project-video' = this project's own Video tool in Project Home ▸ Video only, beside Demo Video (never in Sessions HOT KEYS, "
606
+ + 'Project Home ▸ Tools, the phone remote or other projects); it carries `job` { estimateMinutes 5-60 (the run budget is 3x, capped at 180 minutes), '
607
+ + 'repoPaths (optional: a committing run that must land a commit under those paths), review (optional: a review stage a human approves first) }. '
608
+ + 'A project-video save always needs `humanRequestQuote`, the human\'s words naming Project Home. '
609
+ + 'A project-video save is refused unless its agentName is a persona file in this project\'s .claude/agents/ or ~/.claude/agents/ '
610
+ + 'and, when that persona lists `tools`, the list includes mcp__session-manager-scheduler__project_video_write '
611
+ + '(plus mcp__session-manager-scheduler__project_video_review_write for a review tool) — the run is a headless job scoped to those tools.',
568
612
  summary: 'Create or change a saved one-click macro (agent, mission, prompt).',
569
613
  whenToUse: 'Pass `id` to update an existing macro already visible to this project; omit `id` to create a new '
570
614
  + 'one scoped to this project. Use for things like a "Publish git + npm" macro a human will press '
@@ -590,7 +634,8 @@ const MCP_TOOL_CATALOG = [
590
634
  },
591
635
  notes: "cwd is optional — defaults to the calling session's own project root (SM_PROJECT_ROOT or "
592
636
  + 'process.cwd()) when omitted. label, agentName, tag and prompt are all required strings. '
593
- + "`surface` is optional: 'sessions' = Sessions HOT KEYS strip, 'project-home' = a tool in Project Home ▸ Tools. "
637
+ + "`surface` is optional: 'sessions' = Sessions HOT KEYS strip, 'project-home' = a tool in Project Home ▸ Tools, "
638
+ + "'project-video' = this project's own tool in Project Home ▸ Video (saved for this project only; `projects` is ignored). "
594
639
  + "A surface 'project-home' macro is always saved for every project (only what it generates is per project); it "
595
640
  + 'needs `humanRequestQuote` naming Project Home (or every project) and is refused in a scheduled job or outside '
596
641
  + 'a Session Manager chat session. '
@@ -666,6 +711,36 @@ const MCP_TOOL_CATALOG = [
666
711
  exampleArgs: { cwd: '/home/bilko/Projects/session-manager' },
667
712
  notes: 'Returns { ok: true, agents }.',
668
713
  },
714
+ {
715
+ name: 'task_list',
716
+ group: 'tasks',
717
+ purpose: "Read-only list of one project's Task ledger via the session-manager app's admin API (GET /admin/tasks) "
718
+ + '— the same rows the Scheduler ▸ Tasks page shows, newest first. A Task is one headless `claude -p` run '
719
+ + 'for the project (run by Session Manager, source "sm", or imported as a direct call, source "direct"). '
720
+ + 'Each row carries taskId, agent, model, effort, caller, status, timings, usage and cost, never prompt or '
721
+ + 'output text.',
722
+ summary: "List a project's Tasks with their status, model and cost.",
723
+ whenToUse: 'Use to audit which Tasks ran in a project, how they ended and what they cost. Filter by '
724
+ + '`since`/`until` (ISO), `pipeline`/`runId`/`step` (the caller), `agent`, `status` or `source`; page with '
725
+ + '`limit` (1-200, default 50) and `offset`.',
726
+ whenNotToUse: 'Do not use this to run or import a Task — it is read-only. Do not use it to read one Task\'s '
727
+ + 'prompt or output; use task_get. A `cwd` that is not an absolute project root is refused.',
728
+ exampleArgs: { cwd: '/home/bilko/Projects/session-manager', status: 'error', limit: 20 },
729
+ notes: 'Returns { ok: true, tasks, total, hasMore }; a partial page adds a `note`.',
730
+ },
731
+ {
732
+ name: 'task_get',
733
+ group: 'tasks',
734
+ purpose: "Read-only fetch of one Task from a project's Task ledger via the session-manager app's admin API "
735
+ + '(GET /admin/task): every task_list field plus prompt, output, stderrTail and envelope (each text capped '
736
+ + 'at 1 MiB, with promptTruncated / outputTruncated flags).',
737
+ summary: 'Read one Task in full, with its prompt and output.',
738
+ whenToUse: 'Use after task_list to see exactly what one Task was asked and what it answered, by its taskId.',
739
+ whenNotToUse: 'Do not use this to run, retry or import a Task — it is read-only. An unknown id answers '
740
+ + '404 unknown_task; a `cwd` that is not an absolute project root is refused.',
741
+ exampleArgs: { cwd: '/home/bilko/Projects/session-manager', id: 'task-abc123' },
742
+ notes: 'Returns { ok: true, task }.',
743
+ },
669
744
  {
670
745
  name: 'session_manager_help',
671
746
  group: 'help',
@@ -728,6 +803,19 @@ const MCP_RECIPES = [
728
803
  'Read the result delivery: "delivered", "event-only" or "fallback". Report only that; never say the other project acted. At most 3 replies per thread.',
729
804
  ],
730
805
  },
806
+ {
807
+ id: 'add-project-video-tool',
808
+ title: 'Add a project video tool',
809
+ steps: [
810
+ 'First the persona — a project-video macro_save is refused unless both hold: (1) agentName is a persona file in this project\'s .claude/agents/<name>.md or ~/.claude/agents/<name>.md (project-local resolves first); (2) when that persona lists `tools`, the list includes mcp__session-manager-scheduler__project_video_write, plus mcp__session-manager-scheduler__project_video_review_write for a review tool, because a headless job may call only the MCP tools its persona lists. Write or fix that persona file before macro_save.',
811
+ 'Only when the human asked in this chat for a video tool in Project Home. It shows in this project\'s Project Home ▸ Video only, beside Demo Video — never in Sessions HOT KEYS, Tools, the phone remote or other projects.',
812
+ 'Call macro_save with surface \'project-video\', agentName (that persona), tag, prompt, job { estimateMinutes 5-60 (budget 3x, capped at 180 minutes), repoPaths (optional: a committing run), review (optional: a review stage) } and humanRequestQuote — the human\'s words naming Project Home.',
813
+ 'Each press runs as a scheduled job. The run saves its video with project_video_write (kind e.g. \'episode\'; 9:16 via <meta name="sm-demo-aspect" content="9:16">) using the videoId from the PRD\'s \'Entry id\' line — never a new id.',
814
+ 'A review tool\'s first run calls project_video_review_write (text up to 32000 characters — a whole script fits — plus 1-6 images) and ends. The next run carries \'Review: approved…\' (build the final video) or \'Review: changes requested…\' (redo the review material with that note).',
815
+ 'If an approved final run fails, the owner presses Retry in Project Home ▸ Video; the next run carries the same \'Review: approved by the owner at <time>\' and \'Replace entry: <id>\' lines, so the final stage must start from the approved material (files its review stage committed, or the saved review material), not from the review run\'s context. No agent, script or MCP call can retry.',
816
+ 'A repoPaths run must land a commit under those paths (the saved video entry itself is never committed); without repoPaths the run is artifact-only. Only the human approves, asks for changes or retries — in Project Home ▸ Video; no tool can.',
817
+ ],
818
+ },
731
819
  ];
732
820
 
733
821
  for (const entry of MCP_TOOL_CATALOG) {
@@ -741,7 +829,29 @@ function composeDescription(entry) {
741
829
  return [entry.purpose, entry.whenToUse, entry.whenNotToUse, entry.notes].filter(Boolean).join(' ');
742
830
  }
743
831
 
832
+ // `fixes` input of scheduler_create_prd / each scheduler_create_prds entry
833
+ // (PRD prd-fixes-api-surface). scheduler-mcp-server.cjs puts this exact
834
+ // fragment into its shared create-PRD item schema; the missKind enum is built
835
+ // from MISS_KINDS so it can never drift from the validator's list.
836
+ const FIXES_DESCRIPTION = 'Optional: the earlier PRDs this PRD repairs, each with its miss kind and a one-line reason. '
837
+ + 'Name every PRD whose bug this PRD fixes; one that already had a VERIFIED verdict counts as a validator miss (escape).';
838
+ const FIXES_INPUT_SCHEMA = Object.freeze({
839
+ type: 'array',
840
+ description: FIXES_DESCRIPTION,
841
+ items: {
842
+ type: 'object',
843
+ properties: {
844
+ prd: { type: 'string', description: 'NN-slug or bare slug of the earlier PRD this one repairs.' },
845
+ missKind: { type: 'string', enum: [...MISS_KINDS], description: 'Kind of miss the earlier PRD had.' },
846
+ reason: { type: 'string', description: 'One line: what was wrong with it.' },
847
+ },
848
+ required: ['prd', 'missKind', 'reason'],
849
+ },
850
+ });
851
+
744
852
  module.exports = {
853
+ FIXES_DESCRIPTION,
854
+ FIXES_INPUT_SCHEMA,
745
855
  MCP_TOOL_CATALOG,
746
856
  MCP_RECIPES,
747
857
  CatalogEntrySchema,
@@ -15,8 +15,16 @@
15
15
  * - parseGitLog(stdout) — `git log --max-count=2000 --no-renames
16
16
  * --format=%x01%ct --name-only -z` stdout -> newest-first { ms, files }.
17
17
  * - importsOf(text, fromPath) — the path.md imports (at-sign prefixed) a doc makes.
18
+ * - recordCollectionDocs(census) — every doc inside a record collection, linked
19
+ * or not, except the root and README/CLAUDE/AGENTS/index docs.
18
20
  *
19
- * Roles, by precedence: map (the root + its transitive imports, depth <= 5)
21
+ * - rootMapDoc(has) — the root map doc: AGENTS.md when `has('AGENTS.md')`, else
22
+ * CLAUDE.md. Beside a root AGENTS.md, a root CLAUDE.md (the stub that imports
23
+ * it) is part of the map too.
24
+ *
25
+ * Roles, by precedence: map (the root map doc — root AGENTS.md, else root
26
+ * CLAUDE.md — plus a root CLAUDE.md beside an AGENTS.md root, and their
27
+ * transitive imports, depth <= 5)
20
28
  * > scoped (any other CLAUDE.md / AGENTS.md / CLAUDE.local.md) > agent
21
29
  * (.claude/, skills/<x>/, plugins/<x>/agents|commands/) > record (in a record
22
30
  * collection, unreachable, not a README/CLAUDE/AGENTS/index) > doc.
@@ -24,9 +32,11 @@
24
32
  * Never throws on malformed input: invalid entries are skipped.
25
33
  */
26
34
 
27
- const path = require('node:path');
35
+ // importsOf is the shared link convention's; re-exported so consumers keep requiring it from here.
36
+ const { importsOf } = require('../../../plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdLinks.cjs');
28
37
 
29
- const ROOT_DOC = 'CLAUDE.md';
38
+ const AGENTS_DOC = 'AGENTS.md';
39
+ const CLAUDE_DOC = 'CLAUDE.md';
30
40
  const MAX_IMPORT_DEPTH = 5;
31
41
  const COLLECTION_MIN_DOCS = 20;
32
42
  const COLLECTION_MAX_LINKED_SHARE = 0.05;
@@ -36,34 +46,45 @@ const MAX_CODE_REF_FILES = 10;
36
46
  const MAX_DEAD_REFS = 10;
37
47
  const MAX_CHANGED_SINCE = 20;
38
48
 
39
- const MD_RE = /\.md$/i;
40
- const FENCE_RE = /^\s*(`{3,}|~{3,})(.*)$/;
41
- const INLINE_CODE_RE = /(`+).{0,1024}?\1/g;
42
- const IMPORT_RE = /(^|\s)@(\S+)/g;
43
- const TRAILING_PUNCT_RE = /[),.;:!?'"\]]+$/;
44
49
  const AGENT_RE = /(^|\/)\.claude\/|(^|\/)skills\/[^/]+\/|(^|\/)plugins\/[^/]+\/(agents|commands)\//;
45
50
  const SCOPED_NAMES = new Set(['CLAUDE.md', 'AGENTS.md', 'CLAUDE.local.md']);
46
51
  const NEVER_RECORD_NAMES = new Set(['README.md', 'CLAUDE.md', 'AGENTS.md', 'index.md']);
47
52
 
53
+ /**
54
+ * The root map doc: root AGENTS.md when it exists, else root CLAUDE.md.
55
+ * @param {(relPath: string) => boolean} has whether a repo-relative doc exists
56
+ * @returns {string}
57
+ */
58
+ function rootMapDoc(has) {
59
+ return has(AGENTS_DOC) ? AGENTS_DOC : CLAUDE_DOC;
60
+ }
61
+
62
+ /**
63
+ * The root docs of the map: `root`, plus a root CLAUDE.md beside an AGENTS.md root.
64
+ * @param {string} root @param {(relPath: string) => boolean} has @returns {string[]}
65
+ */
66
+ function mapRoots(root, has) {
67
+ if (!has(root)) return [];
68
+ return root === AGENTS_DOC && has(CLAUDE_DOC) ? [root, CLAUDE_DOC] : [root];
69
+ }
70
+
48
71
  /**
49
72
  * @typedef {'map' | 'scoped' | 'agent' | 'record' | 'doc'} MdDocRole
50
73
  * @typedef {{ path: string, ms: number }} MdChangedSince
51
- * @typedef {{ path: string, role: MdDocRole, depth: number | null, lines: number | null, bytes: number | null, lastCommitMs: number | null, commits: number, linkedFrom: number, codeRefs: number, codeRefFiles: string[], deadRefs: string[], changedSince: MdChangedSince[], collection: string | null }} MdDoc
52
- * @typedef {{ folder: string, docs: number, linked: number, lastCommitMs: number | null, source: 'heuristic' | 'override' }} MdRecordCollection
74
+ * @typedef {{ path: string, role: MdDocRole, depth: number | null, lines: number | null, bytes: number | null, lastCommitMs: number | null, commits: number, linkedFrom: number, codeRefs: number, codeRefFiles: string[], deadRefs: string[], ambiguousRefs: string[], changedSince: MdChangedSince[], collection: string | null }} MdDoc
75
+ * @typedef {{ folder: string, docs: number, linked: number, lastCommitMs: number | null, source: 'heuristic' }} MdRecordCollection
53
76
  * @typedef {{ tracked: number, network: number, records: number, unlinked: number, byRole: Record<MdDocRole, number> }} MdCensusCounts
54
77
  * @typedef {{ docs: MdDoc[], collections: MdRecordCollection[], counts: MdCensusCounts, gitWindow: { commits: number, oldestMs: number | null }, warnings: string[] }} MdCensus
55
78
  * @typedef {{ path: string, text?: string | null, lines?: number | null, bytes?: number | null }} MdCensusDocInput
56
79
  * @typedef {{ ms: number, files: string[] }} GitLogEntry
57
- * @typedef {{ deadRefs: string[], changedSince: MdChangedSince[] }} MdDocRefs
80
+ * @typedef {{ deadRefs: string[], ambiguousRefs: string[], changedSince: MdChangedSince[] }} MdDocRefs
58
81
  * @typedef {object} CensusInput
59
- * @property {string} [root] the root doc (default CLAUDE.md)
82
+ * @property {string} [root] the root map doc (default: rootMapDoc over `docs`)
60
83
  * @property {MdCensusDocInput[]} docs every tracked .md, repo-relative POSIX
61
84
  * @property {Map<string, { depth: number, linkedFrom: number }>} reachable docs links reach from the root
62
85
  * @property {GitLogEntry[]} [log] newest first
63
86
  * @property {Map<string, MdDocRefs>} [refs]
64
87
  * @property {Map<string, string[]>} [codeMentions] doc path -> code files naming it
65
- * @property {string[]} [recordFolders] folders forced to be record collections
66
- * @property {string[]} [docFolders] folders (and subfolders) never record collections
67
88
  */
68
89
 
69
90
  /** @param {unknown} v @returns {v is number} */
@@ -81,14 +102,6 @@ function baseName(p) {
81
102
  return p.slice(p.lastIndexOf('/') + 1);
82
103
  }
83
104
 
84
- /** Folder form with a trailing slash, or '' for the repo root / invalid. @param {unknown} f @returns {string} */
85
- function toFolder(f) {
86
- if (typeof f !== 'string') return '';
87
- const norm = path.posix.normalize(f.trim()).replace(/^\.\/+/, '').replace(/\/+$/, '');
88
- if (!norm || norm === '.' || norm.startsWith('../') || norm === '..' || norm.startsWith('/')) return '';
89
- return `${norm}/`;
90
- }
91
-
92
105
  /** Every ancestor folder of `p`, shallowest first, each with a trailing slash. @param {string} p @returns {string[]} */
93
106
  function foldersOf(p) {
94
107
  /** @type {string[]} */
@@ -97,42 +110,6 @@ function foldersOf(p) {
97
110
  return out;
98
111
  }
99
112
 
100
- /**
101
- * The `@path.md` imports in `text`, outside fenced and inline code, resolved
102
- * against `fromPath`'s folder. Skips `@~/...`, absolute and escaping targets.
103
- * @param {string} text @param {string} fromPath @returns {string[]}
104
- */
105
- function importsOf(text, fromPath) {
106
- if (typeof text !== 'string' || typeof fromPath !== 'string') return [];
107
- const dir = path.posix.dirname(fromPath);
108
- /** @type {string[]} */
109
- const out = [];
110
- const seen = new Set();
111
- let fence = '';
112
- for (const line of text.split(/\r?\n/)) {
113
- const f = FENCE_RE.exec(line);
114
- if (fence) {
115
- if (f && f[1][0] === fence[0] && f[1].length >= fence.length && f[2].trim() === '') fence = '';
116
- continue;
117
- }
118
- if (f && !(f[1][0] === '`' && f[2].includes('`'))) {
119
- fence = f[1];
120
- continue;
121
- }
122
- const visible = line.replace(INLINE_CODE_RE, ' ');
123
- for (const m of visible.matchAll(IMPORT_RE)) {
124
- const target = m[2].replace(TRAILING_PUNCT_RE, '');
125
- if (!MD_RE.test(target) || target.startsWith('~') || target.startsWith('/')) continue;
126
- const resolved = path.posix.normalize(path.posix.join(dir, target));
127
- if (resolved === '..' || resolved.startsWith('../') || resolved.startsWith('/')) continue;
128
- if (seen.has(resolved)) continue;
129
- seen.add(resolved);
130
- out.push(resolved);
131
- }
132
- }
133
- return out;
134
- }
135
-
136
113
  /**
137
114
  * Parse `git log --max-count=2000 --no-renames --format=%x01%ct --name-only -z`.
138
115
  * @param {string} stdout @returns {GitLogEntry[]} newest first; [] when empty or unparseable
@@ -181,14 +158,12 @@ function changedSinceList(list) {
181
158
  */
182
159
  function censusMdDocs(input) {
183
160
  const {
184
- root = ROOT_DOC,
161
+ root: rootInput,
185
162
  docs = [],
186
163
  reachable = new Map(),
187
164
  log = [],
188
165
  refs,
189
166
  codeMentions,
190
- recordFolders = [],
191
- docFolders = [],
192
167
  } = input || /** @type {CensusInput} */ ({ docs: [], reachable: new Map() });
193
168
  /** @type {string[]} */
194
169
  const warnings = [];
@@ -236,10 +211,14 @@ function censusMdDocs(input) {
236
211
  // Map: root + transitive @-imports.
237
212
  /** @type {Map<string, string | null | undefined>} */
238
213
  const textOf = new Map(list.map((d) => [d.path, d.text]));
214
+ /** @param {string} p */
215
+ const hasDoc = (p) => textOf.has(p);
216
+ const root = rootInput === undefined ? rootMapDoc(hasDoc) : rootInput;
239
217
  const mapSet = new Set();
240
- if (typeof root === 'string' && textOf.has(root)) {
241
- mapSet.add(root);
242
- let frontier = [root];
218
+ const roots = typeof root === 'string' ? mapRoots(root, hasDoc) : [];
219
+ if (roots.length > 0) {
220
+ for (const r of roots) mapSet.add(r);
221
+ let frontier = roots;
243
222
  for (let depth = 1; depth <= MAX_IMPORT_DEPTH && frontier.length > 0; depth += 1) {
244
223
  /** @type {string[]} */
245
224
  const next = [];
@@ -259,9 +238,6 @@ function censusMdDocs(input) {
259
238
  const isReachable = (p) => reach.has(p) || mapSet.has(p);
260
239
 
261
240
  // Record collections.
262
- const blocked = (Array.isArray(docFolders) ? docFolders : []).map(toFolder).filter(Boolean);
263
- /** @param {string} folder */
264
- const isBlocked = (folder) => blocked.some((b) => folder.startsWith(b));
265
241
  /** @type {Map<string, { docs: number, linked: number, withCommits: number, writeOnce: number, last: number | null }>} */
266
242
  const stats = new Map();
267
243
  for (const d of list) {
@@ -285,18 +261,9 @@ function censusMdDocs(input) {
285
261
  const collections = [];
286
262
  /** @param {string} folder */
287
263
  const insideChosen = (folder) => collections.some((c) => folder.startsWith(c.folder));
288
- const overrides = [...new Set((Array.isArray(recordFolders) ? recordFolders : []).map(toFolder).filter(Boolean))].sort(
289
- (a, b) => a.length - b.length,
290
- );
291
- for (const folder of overrides) {
292
- if (insideChosen(folder)) continue;
293
- const s = stats.get(folder);
294
- if (!s) warnings.push(`Record folder override matches no doc: ${folder}`);
295
- collections.push({ folder, docs: s ? s.docs : 0, linked: s ? s.linked : 0, lastCommitMs: s ? s.last : null, source: 'override' });
296
- }
297
264
  const candidates = [...stats.keys()].sort((a, b) => a.split('/').length - b.split('/').length || (a < b ? -1 : a > b ? 1 : 0));
298
265
  for (const folder of candidates) {
299
- if (isBlocked(folder) || insideChosen(folder) || overrides.some((o) => o.startsWith(folder))) continue;
266
+ if (insideChosen(folder)) continue;
300
267
  const s = /** @type {NonNullable<ReturnType<typeof stats.get>>} */ (stats.get(folder));
301
268
  if (s.docs < COLLECTION_MIN_DOCS || s.linked > s.docs * COLLECTION_MAX_LINKED_SHARE) continue;
302
269
  if (s.withCommits > 0 && s.writeOnce < s.withCommits * WRITE_ONCE_MIN_SHARE) continue;
@@ -347,6 +314,7 @@ function censusMdDocs(input) {
347
314
  codeRefs: mentions.length,
348
315
  codeRefFiles: mentions.slice(0, MAX_CODE_REF_FILES),
349
316
  deadRefs: ref ? stringList(ref.deadRefs, MAX_DEAD_REFS) : [],
317
+ ambiguousRefs: ref ? stringList(ref.ambiguousRefs, MAX_DEAD_REFS) : [],
350
318
  changedSince: ref ? changedSinceList(ref.changedSince) : [],
351
319
  collection: role === 'record' ? folder : null,
352
320
  });
@@ -361,4 +329,17 @@ function censusMdDocs(input) {
361
329
  };
362
330
  }
363
331
 
364
- module.exports = { censusMdDocs, parseGitLog, importsOf };
332
+ /**
333
+ * Every doc inside one of `census`'s record collections: the role-`record`
334
+ * docs plus linked docs in a collection folder. README/CLAUDE/AGENTS/index docs
335
+ * and map docs are never records. The network scan never walks these.
336
+ * @param {MdCensus} census @returns {string[]}
337
+ */
338
+ function recordCollectionDocs(census) {
339
+ const folders = census.collections.map((c) => c.folder);
340
+ return census.docs
341
+ .filter((d) => d.role === 'record' || (d.role === 'doc' && !NEVER_RECORD_NAMES.has(baseName(d.path)) && folders.some((f) => d.path.startsWith(f))))
342
+ .map((d) => d.path);
343
+ }
344
+
345
+ module.exports = { censusMdDocs, parseGitLog, importsOf, recordCollectionDocs, rootMapDoc, mapRoots };