claude-code-session-manager 0.130.2 → 0.131.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 (88) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/bin/cli.cjs +19 -2
  3. package/dist/assets/AgentLibrary-CYXre0J-.js +2 -0
  4. package/dist/assets/{AppSettings-Bpwynea4.js → AppSettings-xNSfCj8e.js} +2 -2
  5. package/dist/assets/{Button-DSoqrxCB.js → Button-BWljh5IK.js} +1 -1
  6. package/dist/assets/DocumentEditorPane-FUC2hZlp.js +1 -0
  7. package/dist/assets/Extensions-CsyUoklz.js +2 -0
  8. package/dist/assets/{History-DzMo9Otn.js → History-BvNmY9OQ.js} +2 -2
  9. package/dist/assets/{Library-C5wKMTSn.js → Library-DVXk77zA.js} +12 -12
  10. package/dist/assets/{ListDetail-DDQ1S0yu.js → ListDetail-DAAx__24.js} +1 -1
  11. package/dist/assets/{Panel-B-3NWUlv.js → Panel-g2D-e-RM.js} +1 -1
  12. package/dist/assets/ProjectClaudeConfig-BDuHJwaO.js +25 -0
  13. package/dist/assets/{ProvenanceBadge-CUChwz4Z.js → ProvenanceBadge-wew4_nf3.js} +1 -1
  14. package/dist/assets/Scheduler-CbeUIqD-.js +16 -0
  15. package/dist/assets/Settings-B23RsRfm.js +2 -0
  16. package/dist/assets/{SkillReferenceGraph-C6JEdypC.js → SkillReferenceGraph-BxQPCfsg.js} +1 -1
  17. package/dist/assets/Skills-4AR2FQrI.js +29 -0
  18. package/dist/assets/{SourceChip-DcBNYYhe.js → SourceChip-jrC0vjfw.js} +1 -1
  19. package/dist/assets/SystemPrompt-hHoBEnYb.js +1 -0
  20. package/dist/assets/{TiptapBody-DiVYC-_O.js → TiptapBody-FkUqxO9u.js} +1 -1
  21. package/dist/assets/{Toggle-Cs3k6I96.js → Toggle-DQMNWZKT.js} +1 -1
  22. package/dist/assets/ViewTabs-DGU0ZuxB.js +1 -0
  23. package/dist/assets/{VoiceButton-C3NLotUZ.js → VoiceButton-BPPvDllh.js} +1 -1
  24. package/dist/assets/{historyTotals-f-E0L9Xw.js → historyTotals-D8Oc3wUK.js} +1 -1
  25. package/dist/assets/index-9ajPMXBg.js +3097 -0
  26. package/dist/assets/{index-Bp8XE9A6.css → index-oXqzajWV.css} +1 -1
  27. package/dist/index.html +2 -2
  28. package/dist-web/app.css +1 -1
  29. package/dist-web/app.js +455 -427
  30. package/package.json +1 -1
  31. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  32. package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +15 -5
  33. package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +8 -4
  34. package/scripts/scheduler-mcp-server.cjs +71 -0
  35. package/src/main/agentLibrary.cjs +81 -29
  36. package/src/main/agentsIpc.cjs +21 -16
  37. package/src/main/build-info.json +4 -4
  38. package/src/main/index.cjs +9 -0
  39. package/src/main/ipcSchemas.cjs +35 -2
  40. package/src/main/lib/epic/epicMint.cjs +61 -6
  41. package/src/main/lib/epic/epicWorktreeMerge.cjs +11 -9
  42. package/src/main/lib/epic/epicWorktreeMint.cjs +45 -4
  43. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +32 -5
  44. package/src/main/lib/epic/restorableSessions.cjs +749 -0
  45. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +61 -0
  46. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +4 -0
  47. package/src/main/lib/git/branchSweep.cjs +9 -3
  48. package/src/main/lib/git/gitExec.cjs +8 -1
  49. package/src/main/lib/git/gitWorktree.cjs +771 -96
  50. package/src/main/lib/git/jobWorktree.cjs +3 -0
  51. package/src/main/lib/git/jobWorktreeBootLive.cjs +14 -2
  52. package/src/main/lib/mcpToolCatalog.cjs +28 -0
  53. package/src/main/lib/mcpToolsProbe.cjs +831 -0
  54. package/src/main/lib/mdNetworkScan.cjs +555 -0
  55. package/src/main/lib/persona-macro/agentPersonaSchema.cjs +18 -5
  56. package/src/main/lib/persona-macro/builtinMacros.cjs +22 -4
  57. package/src/main/lib/persona-macro/macroJobDispatch.cjs +17 -2
  58. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +38 -0
  59. package/src/main/lib/project-pages/competitiveMatrix.cjs +258 -0
  60. package/src/main/lib/project-pages/matrixHtml.cjs +239 -0
  61. package/src/main/lib/project-pages/matrixStore.cjs +112 -0
  62. package/src/main/lib/promptSessionSchema.cjs +5 -0
  63. package/src/main/lib/scheduler/fixPlanSlug.cjs +15 -1
  64. package/src/main/lib/scheduler/reaperHelpers.cjs +35 -0
  65. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  66. package/src/main/lib/scheduler/scheduleJobTransitions.cjs +8 -7
  67. package/src/main/lib/scheduler/terminalRunOutcome.cjs +61 -15
  68. package/src/main/projectPages.cjs +51 -7
  69. package/src/main/runVerify.cjs +8 -3
  70. package/src/main/scheduler/budget.cjs +146 -7
  71. package/src/main/scheduler/gitTreeGuard.cjs +92 -20
  72. package/src/main/scheduler/reviewLadder.cjs +60 -0
  73. package/src/main/scheduler.cjs +477 -53
  74. package/src/main/seedAgentPersonas.cjs +1 -1
  75. package/src/preload/api.d.ts +250 -7
  76. package/src/preload/apiSurface.json +28 -0
  77. package/src/preload/index.cjs +6 -0
  78. package/src/seed/agents/competitive-analyst.md +69 -0
  79. package/src/seed/agents/competitive-researcher.md +75 -0
  80. package/src/seed/agents/validator.md +2 -2
  81. package/dist/assets/AgentLibrary-Bfj862qf.js +0 -2
  82. package/dist/assets/Extensions-BziIutWV.js +0 -13
  83. package/dist/assets/Memory-Bq5T33d2.js +0 -25
  84. package/dist/assets/Scheduler-CkGHMXvo.js +0 -16
  85. package/dist/assets/Settings-DGxvyajs.js +0 -2
  86. package/dist/assets/SystemPrompt-CfozyVQx.js +0 -1
  87. package/dist/assets/ViewTabs-DFXH03tb.js +0 -1
  88. package/dist/assets/index-CuAfFXNd.js +0 -3086
@@ -513,30 +513,36 @@ function gitRangeCommits(cwd, before, after) {
513
513
  }
514
514
 
515
515
  /**
516
- * Read-only check: is a job's `sm-job/<slug>` worktree branch already fully
517
- * integrated into `cwd`'s current HEAD — i.e. every commit on the branch is
518
- * an ancestor of (or equal to) HEAD? Mirrors gitWorktree.cjs's own
519
- * integrateBranch() no-op detection (`mergeBase === branchHead`) exactly, but
520
- * deliberately never calls integrateBranch itself: this is used by
521
- * reapDeadRunningJobs to PROVE a dead job's work already landed, never to
522
- * perform the landing — attempting a real merge from an audit check is a
523
- * mutating action with its own conflict/timing risk, and "land the still-
524
- * stranded branch" is explicitly a separate, later decision (mechanical
525
- * recovery, or a human), not something a reap pass should do on its own
526
- * initiative. See reapDeadRunningJobs's own header comment for why the
527
- * conservative failure direction here is needs_review, never a silent merge.
516
+ * Read-only check: is a job's `sm-job/<slug>` worktree branch already
517
+ * integrated into `cwd`'s current HEAD? Two proofs, cheapest first:
518
+ * 1. Ancestry: the branch tip is an ancestor of (or equal to) HEAD, the
519
+ * same `mergeBase === branchHead` test as integrateBranch()'s no-op
520
+ * detection.
521
+ * 2. Content: `gitWorktree.isBranchContentLanded({ cwd, base: 'HEAD', branch, sinceSha: forkSha })`.
522
+ * Linear landing (PRDs 2743, 2825) replays the branch onto the base, so a
523
+ * landed branch's own commits never become ancestors of HEAD. Proof 1
524
+ * alone made the reaper park a landed job as "still holds unintegrated
525
+ * work — never merged" (validator finding I-2). The helper also accepts
526
+ * patch-equivalent commits on HEAD, or a merge that would change nothing.
527
+ * `forkSha` (the branch's fork point) is passed as `sinceSha`, bounding
528
+ * the proof to the job's own commits — a base rebased after the fork
529
+ * never makes the base's rewritten commits read as unlanded job work.
530
+ * This check itself never calls integrateBranch: it is read-only proof.
531
+ * The landing decision belongs to reapDeadRunningJobs, which integrates a
532
+ * `false` branch only when the run printed its own SCHEDULER_VERDICT: PASS
533
+ * line; any other outcome parks needs_review, never a silent merge.
528
534
  *
529
535
  * Returns:
530
- * - true — branch exists and is fully contained in HEAD (already
531
- * integrated by a prior pass, or a genuine no-op branch that never
532
- * diverged from its base — both cases legitimately "landed").
533
- * - false — branch exists and still holds commits not in HEAD (a real
534
- * stranded deliverable, e.g. the PRD 1118 shape).
536
+ * - true — branch exists and its content is already in HEAD (integrated by
537
+ * a prior pass, landed as a linear replay, or a genuine no-op branch that
538
+ * never diverged from its base — all legitimately "landed").
539
+ * - false — branch exists and still holds work HEAD lacks (a real stranded
540
+ * deliverable, e.g. the PRD 1118 shape), or neither proof could be read.
535
541
  * - null — branch does not exist at all (never a worktree run — an
536
- * in-place run, or SM_JOB_WORKTREE_DISABLE), or the git calls errored.
542
+ * in-place run, or SM_JOB_WORKTREE_DISABLE), or `rev-parse` errored.
537
543
  * Never throws.
538
544
  */
539
- function isBranchAlreadyIntegrated(cwd, branch) {
545
+ function isBranchAlreadyIntegrated(cwd, branch, forkSha = null) {
540
546
  return new Promise((resolve) => {
541
547
  if (!cwd || !branch) { resolve(null); return; }
542
548
  execFile(
@@ -550,7 +556,9 @@ function isBranchAlreadyIntegrated(cwd, branch) {
550
556
  { timeout: 10_000, windowsHide: true },
551
557
  (mbErr, mbOut) => {
552
558
  const mergeBase = mbErr ? '' : String(mbOut || '').trim();
553
- resolve(mergeBase !== '' && mergeBase === branchHead);
559
+ if (mergeBase !== '' && mergeBase === branchHead) { resolve(true); return; }
560
+ gitWorktree.isBranchContentLanded({ cwd, base: 'HEAD', branch, sinceSha: forkSha || undefined })
561
+ .then((landed) => resolve(landed === true), () => resolve(false));
554
562
  },
555
563
  );
556
564
  },
@@ -558,6 +566,69 @@ function isBranchAlreadyIntegrated(cwd, branch) {
558
566
  });
559
567
  }
560
568
 
569
+ // replayBranchOnto (gitWorktree.cjs) copies exactly these four fields onto
570
+ // each commit it replays. With `-z` every record ends in a NUL, and no field
571
+ // can hold one, so a record is always exactly four fields.
572
+ const COMMIT_IDENTITY_FORMAT = '%an%x00%ae%x00%aI%x00%B';
573
+ const REPLAY_MATCH_MAX_COMMITS = 200;
574
+ const REPLAY_MATCH_MAX_BUFFER = 16 * 1024 * 1024;
575
+
576
+ /** `git log -z --format=COMMIT_IDENTITY_FORMAT` output → one comparable key per commit. */
577
+ function parseCommitIdentityLog(out) {
578
+ const fields = String(out || '').split('\0');
579
+ const keys = [];
580
+ for (let i = 0; i + 3 < fields.length; i += 4) {
581
+ // The message loses its trailing newlines, as replayBranchOnto trims the one it copies.
582
+ keys.push(JSON.stringify([fields[i], fields[i + 1], fields[i + 2], fields[i + 3].replace(/\n+$/, '')]));
583
+ }
584
+ return keys;
585
+ }
586
+
587
+ /**
588
+ * The subset of `shas` that linear landing copied off `branch`.
589
+ * replayBranchOnto (gitWorktree.cjs) re-creates each commit it replays with
590
+ * `commit-tree`, keeping its author name, author email, author date and
591
+ * message (trailing newlines trimmed). The copy on the base is therefore never
592
+ * an ancestor of the branch. A sha counts when those four fields equal those
593
+ * of a commit in `git log <sha>..<branch>` (the branch commits the sha does
594
+ * not already contain), reading at most REPLAY_MATCH_MAX_COMMITS of them.
595
+ * The branch is resolved once. A sha that is not a hex object name, or a
596
+ * branch name starting with '-', never reaches git. Never throws: a missing
597
+ * branch, an unresolvable sha or any git failure means no match.
598
+ *
599
+ * @param {string} cwd
600
+ * @param {string[]} shas
601
+ * @param {string} branch
602
+ * @returns {Promise<Set<string>>}
603
+ */
604
+ async function commitsReplayedFromBranch(cwd, shas, branch) {
605
+ const replayed = new Set();
606
+ if (!cwd || typeof branch !== 'string' || !branch || branch.startsWith('-') || !Array.isArray(shas)) return replayed;
607
+ const candidates = shas.filter((sha) => typeof sha === 'string' && /^[0-9a-f]{4,64}$/i.test(sha));
608
+ if (!candidates.length) return replayed;
609
+ try {
610
+ await sharedGitExec.execGit(cwd, ['rev-parse', '--verify', '--quiet', `${branch}^{commit}`], { timeout: 10_000 });
611
+ } catch {
612
+ return replayed; // no such branch, so nothing on it was replayed
613
+ }
614
+ const opts = { timeout: 10_000, maxBuffer: REPLAY_MATCH_MAX_BUFFER };
615
+ for (const sha of candidates) {
616
+ try {
617
+ const branchKeys = new Set(parseCommitIdentityLog(await sharedGitExec.execGit(
618
+ cwd,
619
+ ['log', '-z', `--max-count=${REPLAY_MATCH_MAX_COMMITS}`, `--format=${COMMIT_IDENTITY_FORMAT}`, `${sha}..${branch}`, '--'],
620
+ opts,
621
+ )));
622
+ if (!branchKeys.size) continue;
623
+ const [own] = parseCommitIdentityLog(await sharedGitExec.execGit(
624
+ cwd, ['log', '-z', '-1', `--format=${COMMIT_IDENTITY_FORMAT}`, sha, '--'], opts,
625
+ ));
626
+ if (own !== undefined && branchKeys.has(own)) replayed.add(sha);
627
+ } catch { /* unresolvable sha, or git failed: no match */ }
628
+ }
629
+ return replayed;
630
+ }
631
+
561
632
  /**
562
633
  * Override for a SIGTERM'd (143) run when a commit landed in its window.
563
634
  * Exit 143 alone doesn't prove the deliverable is missing — the 776/779
@@ -713,6 +784,7 @@ module.exports = {
713
784
  strandedCommitVerdict,
714
785
  gitRangeCommits,
715
786
  isBranchAlreadyIntegrated,
787
+ commitsReplayedFromBranch,
716
788
  classifySigtermWithCommit,
717
789
  evaluateFinalizeDrop,
718
790
  evaluateDispatchSidecarReconcile,
@@ -122,6 +122,7 @@ function selectMechanicalRecoveryTarget(job, currentHeadSha = null) {
122
122
  branch: jobWorktree.branchNameFor(job.slug),
123
123
  carriedPaths: job.carriedPaths || [],
124
124
  baseBranch: job.worktreeBaseBranch || null,
125
+ forkSha: job.worktreeForkSha || null,
125
126
  };
126
127
  }
127
128
 
@@ -187,9 +188,59 @@ const RESCAN_EXCLUDED_VERDICTS = new Set([
187
188
  // Its damage IS a commit stranded on an unmerged sm-job branch — a landedCommit restates it; selectMechanicalRecoveryTarget owns the real re-merge.
188
189
  'worktree_integration_failed',
189
190
  // The run overran its own time/cost estimate; no transcript or git evidence can un-overrun it (selectAutoFixTargets excludes it too).
191
+ // Carve-out (isFinishReviewKillHealEligible): a kill inside the finish-protocol review AFTER the commit
192
+ // integrated left only the review + verdict undone, so a green re-run of the PRD's own gate is the proof.
190
193
  'budget_exceeded',
191
194
  ]);
192
195
 
196
+ /**
197
+ * Finish-review budget-kill heal (one attempt). The ONLY budget_exceeded rows
198
+ * any self-heal rung may touch: the kill hit inside the finish-protocol review
199
+ * (budgetKillPhase 'finish-review', stamped at finalize) after the run landed
200
+ * a commit. Everything else budget_exceeded stays excluded (above).
201
+ *
202
+ * Pure. Integration into the main checkout is only partly provable here: a
203
+ * row carrying an integrationFailureKind (stampIntegrationFailure — commit
204
+ * stranded on an unmerged sm-job branch) is refused outright; the rung in
205
+ * scheduler.cjs additionally requires landedCommit to be an ancestor of the
206
+ * main checkout's HEAD before it runs the gate.
207
+ *
208
+ * Bounded to one attempt by finishReviewHealAttemptedAt, stamped by the rung
209
+ * whatever the outcome (red, unrunnable, not integrated) — so a red gate never
210
+ * loops. Kill-switch: SM_FINISH_REVIEW_HEAL_DISABLE=1.
211
+ */
212
+ function isFinishReviewKillHealEligible(job) {
213
+ if (process.env.SM_FINISH_REVIEW_HEAL_DISABLE === '1') return false;
214
+ if (!job || job.status !== 'needs_review') return false;
215
+ if (job.verifierVerdict !== 'budget_exceeded') return false;
216
+ if (job.budgetKillPhase !== 'finish-review') return false;
217
+ if (typeof job.landedCommit !== 'string' || job.landedCommit.length === 0) return false;
218
+ if (job.finishReviewHealAttemptedAt) return false;
219
+ if (job.integrationFailureKind) return false;
220
+ if (isCancelledJob(job) || isRefireCapped(job)) return false;
221
+ return true;
222
+ }
223
+
224
+ /**
225
+ * Pure decision for the finish-review heal, from ground truth the rung
226
+ * computed: evidenceOk (landedCommit is git-verified evidence from THIS
227
+ * dispatch), integratedOk (landedCommit is an ancestor of the main
228
+ * checkout's HEAD), setupOk (scratch worktree's declared setup settled), the
229
+ * resolved gate, and runGateSequence's outcome. First failed check names the
230
+ * reason. Mirrors decideGateAuthority's trusted-gate rule ('ac-line-guess'
231
+ * never counts).
232
+ */
233
+ function decideFinishReviewKillHeal({ evidenceOk, integratedOk, gate, setupOk, outcome } = {}) {
234
+ if (evidenceOk !== true) return { complete: false, reason: 'commit-not-from-this-run' };
235
+ if (integratedOk !== true) return { complete: false, reason: 'commit-not-integrated' };
236
+ const hasGate = (gate?.source === 'explicit' || gate?.source === 'ac-line')
237
+ && Array.isArray(gate?.sequence) && gate.sequence.length > 0;
238
+ if (!hasGate) return { complete: false, reason: 'no-gate' };
239
+ if (setupOk !== true) return { complete: false, reason: 'setup-not-settled' };
240
+ if (outcome?.status !== 'green') return { complete: false, reason: outcome?.status === 'red' ? 'gate-red' : 'gate-not-runnable' };
241
+ return { complete: true, reason: 'gate-green' };
242
+ }
243
+
193
244
  // Per-pass / per-row bounds on the evidence-only rung (the widened candidate
194
245
  // set). Each scan costs one computeLooksDone: a per-cwd-deduped `git fetch`
195
246
  // (<=~20s) + a git log. Unbounded, a backlog of N parked rows would pay N of
@@ -879,6 +930,8 @@ function selectAutoFixTargets(jobs, { fixSlugExists, resolveJobRunId = resolveRu
879
930
  // auto-fix investigation or auto-retry — the run didn't fail, it simply
880
931
  // overran its own estimate; there's no code defect to diagnose (Out of
881
932
  // scope: "retrying or auto-resuming a budget-killed job" for this PRD).
933
+ // The finish-review carve-out (isFinishReviewKillHealEligible) heals via a gate
934
+ // re-run, never via auto-fix — so this exclusion holds for every budget_exceeded row.
882
935
  if (job.verifierVerdict === 'budget_exceeded') return false;
883
936
  // A stale re-run whose work already shipped (rcaReport's 'already-shipped'
884
937
  // class) must never buy a fix-plan PRD — there is nothing to fix, and the
@@ -970,6 +1023,11 @@ function selectGateShadowTarget(jobs, headByCwd, { authorityDisabled = false, ba
970
1023
  return typeof head === 'string' && head.length > 0;
971
1024
  });
972
1025
 
1026
+ // Tier 0: a finish-review budget kill's one-shot heal (bounded by its own
1027
+ // attempt stamp, so it can win the pick at most once per row).
1028
+ const finishReviewHeal = eligible.find((j) => isFinishReviewKillHealEligible(j));
1029
+ if (finishReviewHeal) return finishReviewHeal;
1030
+
973
1031
  const isStale = (j) => {
974
1032
  const head = headByCwd.get(j.cwd);
975
1033
  return !j.gateShadow || j.gateShadow.head !== head || j.gateShadow.definitive !== true;
@@ -1074,4 +1132,6 @@ module.exports = {
1074
1132
  selectAutoFixTargets,
1075
1133
  isEligibleForImmediateAutoFix,
1076
1134
  selectGateShadowTarget,
1135
+ isFinishReviewKillHealEligible,
1136
+ decideFinishReviewKillHeal,
1077
1137
  };