claude-code-session-manager 0.98.0 → 0.101.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 (441) hide show
  1. package/README.md +3 -3
  2. package/bin/cli.cjs +16 -4
  3. package/bin/node-floor.cjs +41 -0
  4. package/dist/assets/DataModel-CXaH2GED.js +1 -0
  5. package/dist/assets/{History-Bfdoywlh.js → History-Cerii-HA.js} +2 -2
  6. package/dist/assets/{Hooks-CKDJjTJV.js → Hooks-aXMb5LDy.js} +3 -3
  7. package/dist/assets/{Library-7akfgy67.js → Library-WrJFKEOJ.js} +1 -1
  8. package/dist/assets/{MarkdownEditor-DDesiqet.js → MarkdownEditor-D1BMCXS7.js} +1 -1
  9. package/dist/assets/{McpServers-D4lZtXof.js → McpServers-Cf0davLd.js} +2 -2
  10. package/dist/assets/{Memory-CeI8G1w5.js → Memory-Dn6NHWPe.js} +6 -6
  11. package/dist/assets/Permissions-CTVuFPjg.js +3 -0
  12. package/dist/assets/{Plugins-P4eCXy_S.js → Plugins-C2TyF8Mn.js} +2 -2
  13. package/dist/assets/ProvenanceBadge-F_jwHSwE.js +1 -0
  14. package/dist/assets/{SaveBar-l9jnEMES.js → SaveBar-DA1KVJST.js} +1 -1
  15. package/dist/assets/Scheduler-Bm6Q_hlu.js +16 -0
  16. package/dist/assets/{ScopeSwitcher-CjJi8ST5.js → ScopeSwitcher-BygZlJca.js} +1 -1
  17. package/dist/assets/Settings-BYCiv5KV.js +3 -0
  18. package/dist/assets/{SkillReferenceGraph-CjbO01Sg.js → SkillReferenceGraph-CcLnl9np.js} +1 -1
  19. package/dist/assets/{Skills-BxZ9_fCR.js → Skills-ChffsdTD.js} +2 -2
  20. package/dist/assets/{SystemPrompt-D8vfFb8b.js → SystemPrompt-dNkfHE_M.js} +1 -1
  21. package/dist/assets/{TagLibrary-2vzUo7YL.js → TagLibrary-jVlEuB0m.js} +1 -1
  22. package/dist/assets/{TiptapBody-B8ZfbK90.js → TiptapBody-6_cdwcP0.js} +1 -1
  23. package/dist/assets/{Toggle-BbW4nGGf.js → Toggle-CVXqGpAP.js} +1 -1
  24. package/dist/assets/ViewTabs-DO1YVbpc.js +1 -0
  25. package/dist/assets/{index-CKH5Uxik.css → index-D89EUizB.css} +1 -1
  26. package/dist/assets/{index-Cd98Q1lD.js → index-DbCQPWWY.js} +747 -752
  27. package/dist/assets/{settingsSchema-IhUfucCF.js → settingsSchema-Wrvn-Yz1.js} +1 -1
  28. package/dist/index.html +2 -2
  29. package/package.json +25 -29
  30. package/plugins/CLAUDE.md +6 -6
  31. package/plugins/session-manager-dev/skills/builder/4-manual/SKILL.md +21 -19
  32. package/plugins/session-manager-dev/skills/builder/SKILL.md +3 -3
  33. package/plugins/session-manager-dev/skills/develop/SKILL.md +254 -510
  34. package/plugins/session-manager-dev/skills/develop/standards.md +17 -22
  35. package/scripts/README.md +3 -11
  36. package/scripts/audit-ops-hygiene.cjs +3 -3
  37. package/scripts/hooks/lib/guard-prd-writes-policy.cjs +1 -1
  38. package/scripts/hooks/lib/guard-self-schedule-policy.cjs +1 -1
  39. package/scripts/mint-epic.cjs +2 -3
  40. package/scripts/scheduler-mcp-server.cjs +64 -7
  41. package/src/main/agentLibrary.cjs +22 -2
  42. package/src/main/build-info.json +4 -4
  43. package/src/main/chatRunner.cjs +4 -3
  44. package/src/main/config.cjs +41 -38
  45. package/src/main/docEdit.cjs +4 -1
  46. package/src/main/files.cjs +2 -5
  47. package/src/main/health.cjs +1 -1
  48. package/src/main/index.cjs +40 -11
  49. package/src/main/ipcSchemas.cjs +35 -34
  50. package/src/main/lib/agentPersonaSchema.cjs +13 -2
  51. package/src/main/lib/atomicFs.cjs +116 -0
  52. package/src/main/lib/branchSweep.cjs +13 -12
  53. package/src/main/lib/buildTarget.cjs +3 -3
  54. package/src/main/lib/builtinMacros.cjs +39 -0
  55. package/src/main/lib/claudeCliCaps.cjs +129 -0
  56. package/src/main/lib/credentials.cjs +2 -4
  57. package/src/main/lib/crossProjectFeedback.cjs +3 -3
  58. package/src/main/lib/cwdClassify.cjs +15 -3
  59. package/src/main/lib/definitionOfDone.cjs +207 -125
  60. package/src/main/lib/dodDrainHook.cjs +11 -5
  61. package/src/main/lib/epicMint.cjs +2 -4
  62. package/src/main/lib/epicStatusMirror.cjs +8 -10
  63. package/src/main/lib/epicWorktreeProjectConfig.cjs +2 -4
  64. package/src/main/lib/gateAuthority.cjs +96 -0
  65. package/src/main/lib/gitExec.cjs +69 -0
  66. package/src/main/lib/gitWorktree.cjs +656 -92
  67. package/src/main/lib/instanceLock.cjs +5 -8
  68. package/src/main/lib/launchFailure.cjs +2 -3
  69. package/src/main/lib/macroLibrary.cjs +480 -0
  70. package/src/main/lib/mcpToolCatalog.cjs +49 -17
  71. package/src/main/lib/needsReviewLedger.cjs +1 -1
  72. package/src/main/lib/opsErrorLog.cjs +11 -1
  73. package/src/main/lib/opsOwnership.cjs +5 -9
  74. package/src/main/lib/pidAlive.cjs +32 -0
  75. package/src/main/lib/prdCreate.cjs +121 -12
  76. package/src/main/lib/prdDisposition.cjs +2 -2
  77. package/src/main/lib/prdGateFiles.cjs +284 -0
  78. package/src/main/lib/prdLocations.cjs +61 -0
  79. package/src/main/lib/prdMigration.cjs +2 -3
  80. package/src/main/lib/prdSizing.cjs +2 -1
  81. package/src/main/lib/projectHomeAdminRoutes.cjs +136 -21
  82. package/src/main/lib/promptSessionSchema.cjs +10 -2
  83. package/src/main/lib/rcaReport.cjs +4 -6
  84. package/src/main/lib/reaperHelpers.cjs +8 -1
  85. package/src/main/lib/reservationExpiry.cjs +6 -1
  86. package/src/main/lib/reviewNotice.cjs +263 -0
  87. package/src/main/lib/runClaudeP.cjs +4 -1
  88. package/src/main/lib/schedulerPaths.cjs +22 -2
  89. package/src/main/lib/sessionSlots.cjs +2 -4
  90. package/src/main/lib/shippedPersonaSeeds.cjs +226 -0
  91. package/src/main/lib/smfileHeaders.cjs +66 -0
  92. package/src/main/lib/timeoutShim.cjs +123 -0
  93. package/src/main/lib/timeoutShimScript.cjs +275 -0
  94. package/src/main/lib/upgradeDrain.cjs +4 -10
  95. package/src/main/lib/watchdogHelpers.cjs +12 -25
  96. package/src/main/lib/workTypeLibrary.cjs +7 -1
  97. package/src/main/projectPages.cjs +43 -13
  98. package/src/main/promptSessionEvents.cjs +37 -13
  99. package/src/main/scheduler.cjs +910 -198
  100. package/src/main/seedAgentPersonas.cjs +279 -24
  101. package/src/main/supervisor.cjs +4 -1
  102. package/src/main/templates/PRD_AUTHORING.md +126 -406
  103. package/src/preload/__tests__/preload-surface.test.cjs +68 -0
  104. package/src/preload/api.d.ts +53 -94
  105. package/src/preload/index.cjs +14 -9
  106. package/src/seed/agents/architect.md +2 -0
  107. package/src/seed/agents/demo-video-builder.md +84 -0
  108. package/src/seed/agents/dev-lead.md +18 -18
  109. package/src/seed/agents/project-home-builder.md +66 -35
  110. package/src/seed/agents/validator.md +10 -4
  111. package/dist/assets/DataModel-DCEgMTjH.js +0 -1
  112. package/dist/assets/HostBilko-CDVHE0hT.js +0 -1
  113. package/dist/assets/Permissions-BGleLja4.js +0 -3
  114. package/dist/assets/ProvenanceBadge-BFczzI1B.js +0 -1
  115. package/dist/assets/Scheduler-C_phpeUS.js +0 -16
  116. package/dist/assets/Settings-BIwZ3FGQ.js +0 -3
  117. package/src/main/__tests__/activeIndexMerge.test.cjs +0 -235
  118. package/src/main/__tests__/agentEffortResolve.test.cjs +0 -117
  119. package/src/main/__tests__/agentLibrary.test.cjs +0 -276
  120. package/src/main/__tests__/agentModelResolve.test.cjs +0 -311
  121. package/src/main/__tests__/agentOverlayWrite.test.cjs +0 -95
  122. package/src/main/__tests__/bilkoHost-deriveSlug.test.cjs +0 -26
  123. package/src/main/__tests__/bilkoHost-integration.test.cjs +0 -118
  124. package/src/main/__tests__/bilkoHostCore.test.cjs +0 -72
  125. package/src/main/__tests__/broadcastCoalescer.test.cjs +0 -122
  126. package/src/main/__tests__/chat-cancel-terminal.test.cjs +0 -120
  127. package/src/main/__tests__/chat-dead-channels.test.cjs +0 -63
  128. package/src/main/__tests__/chat-exit-close-race.test.cjs +0 -146
  129. package/src/main/__tests__/chat-mcp-consent-notice.test.cjs +0 -139
  130. package/src/main/__tests__/chat-preamble-anchors.test.cjs +0 -100
  131. package/src/main/__tests__/chat-queue.test.cjs +0 -97
  132. package/src/main/__tests__/chat-stop-signal.test.cjs +0 -89
  133. package/src/main/__tests__/chatRunner-epic-worktree-execcwd.test.cjs +0 -125
  134. package/src/main/__tests__/chatRunner-session-flag-retry.test.cjs +0 -252
  135. package/src/main/__tests__/classifyPromptTicket.test.cjs +0 -101
  136. package/src/main/__tests__/classifyTranscriptLine.test.cjs +0 -201
  137. package/src/main/__tests__/computeDepHistorySatisfaction.test.cjs +0 -66
  138. package/src/main/__tests__/config-readText-bounded.test.cjs +0 -84
  139. package/src/main/__tests__/configWriteBoundaryOwners.test.cjs +0 -59
  140. package/src/main/__tests__/crossProjectFeedback.test.cjs +0 -334
  141. package/src/main/__tests__/crossProjectFeedbackRoutes.test.cjs +0 -161
  142. package/src/main/__tests__/dep-orphan-archive-health.test.cjs +0 -77
  143. package/src/main/__tests__/develop-skill-failure-modes.test.cjs +0 -70
  144. package/src/main/__tests__/docEdit.test.cjs +0 -244
  145. package/src/main/__tests__/dod-batchkey.test.cjs +0 -183
  146. package/src/main/__tests__/dod-drain-hook.test.cjs +0 -302
  147. package/src/main/__tests__/dod-report.test.cjs +0 -304
  148. package/src/main/__tests__/dod-reverify.test.cjs +0 -285
  149. package/src/main/__tests__/epicContextDigest.test.cjs +0 -174
  150. package/src/main/__tests__/epicMint.test.cjs +0 -332
  151. package/src/main/__tests__/epicMintTelemetryTap.test.cjs +0 -64
  152. package/src/main/__tests__/epicStatusMirror.test.cjs +0 -110
  153. package/src/main/__tests__/epicValidationHook.test.cjs +0 -291
  154. package/src/main/__tests__/exchanges.test.cjs +0 -122
  155. package/src/main/__tests__/exchangesPromptId.test.cjs +0 -61
  156. package/src/main/__tests__/extractJson.test.cjs +0 -51
  157. package/src/main/__tests__/files-reject-credentials.test.cjs +0 -40
  158. package/src/main/__tests__/fixtures/1218-fo-01-move-scripts-lib-into-src-main-lib.log +0 -556
  159. package/src/main/__tests__/flatPrdTickSweep.test.cjs +0 -110
  160. package/src/main/__tests__/health-build-freshness.test.cjs +0 -39
  161. package/src/main/__tests__/health-claude-md-budget.test.cjs +0 -57
  162. package/src/main/__tests__/health-credentials.test.cjs +0 -81
  163. package/src/main/__tests__/health-delegation-chain.test.cjs +0 -124
  164. package/src/main/__tests__/health-per-project-stall.test.cjs +0 -84
  165. package/src/main/__tests__/health-prd-migration.test.cjs +0 -37
  166. package/src/main/__tests__/health-queue-dispatch.test.cjs +0 -135
  167. package/src/main/__tests__/health-starve-escalation.test.cjs +0 -94
  168. package/src/main/__tests__/health-tick-liveness.test.cjs +0 -179
  169. package/src/main/__tests__/health-usage-poller.test.cjs +0 -144
  170. package/src/main/__tests__/health-worktree-cap-blocked.test.cjs +0 -65
  171. package/src/main/__tests__/heapSnapshot.test.cjs +0 -121
  172. package/src/main/__tests__/historyAggregatorIntraday.test.cjs +0 -313
  173. package/src/main/__tests__/historyDashboard.test.cjs +0 -163
  174. package/src/main/__tests__/historyRollup.test.cjs +0 -333
  175. package/src/main/__tests__/intradayRefresh.test.cjs +0 -39
  176. package/src/main/__tests__/ipcSchemas-dependsOn.test.cjs +0 -39
  177. package/src/main/__tests__/kg-augment.test.cjs +0 -195
  178. package/src/main/__tests__/loadGateDetailTick.test.cjs +0 -31
  179. package/src/main/__tests__/machineProfile.test.cjs +0 -152
  180. package/src/main/__tests__/mcpStatus.test.cjs +0 -61
  181. package/src/main/__tests__/memoryAggregate.test.cjs +0 -109
  182. package/src/main/__tests__/memoryStale.test.cjs +0 -88
  183. package/src/main/__tests__/needsReviewLedger.test.cjs +0 -162
  184. package/src/main/__tests__/openExternalApp-spawn-error.test.cjs +0 -25
  185. package/src/main/__tests__/opsErrorLog.test.cjs +0 -109
  186. package/src/main/__tests__/opsErrorLogTelemetryTap.test.cjs +0 -173
  187. package/src/main/__tests__/personaMerge.test.cjs +0 -169
  188. package/src/main/__tests__/planValidator.test.cjs +0 -125
  189. package/src/main/__tests__/pollLoop-dispatch-on-failure.test.cjs +0 -176
  190. package/src/main/__tests__/prd-group-allocator.test.cjs +0 -119
  191. package/src/main/__tests__/prdAdminRouteParity.test.cjs +0 -70
  192. package/src/main/__tests__/prdAdminRoutes.test.cjs +0 -718
  193. package/src/main/__tests__/prdAgentType.test.cjs +0 -103
  194. package/src/main/__tests__/prdAuthoringSeed.test.cjs +0 -39
  195. package/src/main/__tests__/prdCreate.test.cjs +0 -979
  196. package/src/main/__tests__/prdCreateAdoption.test.cjs +0 -205
  197. package/src/main/__tests__/prdCreateDisposition.test.cjs +0 -201
  198. package/src/main/__tests__/prdCreatePlanId.test.cjs +0 -132
  199. package/src/main/__tests__/prdFrontmatterAgentType.test.cjs +0 -117
  200. package/src/main/__tests__/prdFrontmatterDependsOn.test.cjs +0 -136
  201. package/src/main/__tests__/prdFrontmatterDisposition.test.cjs +0 -125
  202. package/src/main/__tests__/prdFrontmatterQuietMachine.test.cjs +0 -108
  203. package/src/main/__tests__/prdLocations.test.cjs +0 -195
  204. package/src/main/__tests__/prdLocationsArchived.test.cjs +0 -201
  205. package/src/main/__tests__/prdMigration.test.cjs +0 -349
  206. package/src/main/__tests__/prdMigrationLegacyAdopt.test.cjs +0 -91
  207. package/src/main/__tests__/prdParserHighWater.test.cjs +0 -74
  208. package/src/main/__tests__/prdParserSourcePromptId.test.cjs +0 -65
  209. package/src/main/__tests__/prdSetDisposition.test.cjs +0 -222
  210. package/src/main/__tests__/prdSizing.test.cjs +0 -106
  211. package/src/main/__tests__/prdSourcePromptIdBackfill.test.cjs +0 -118
  212. package/src/main/__tests__/prdUpdateDependsOn.test.cjs +0 -160
  213. package/src/main/__tests__/proc-role-env.test.cjs +0 -125
  214. package/src/main/__tests__/procname-claude-spawn-sites.test.cjs +0 -304
  215. package/src/main/__tests__/procname-sm-processes.test.cjs +0 -127
  216. package/src/main/__tests__/projectHomeAdminRoutes.test.cjs +0 -177
  217. package/src/main/__tests__/projectPages.test.cjs +0 -137
  218. package/src/main/__tests__/promptSessionEvents.test.cjs +0 -234
  219. package/src/main/__tests__/promptSessionSchema.test.cjs +0 -101
  220. package/src/main/__tests__/promptSessionTranscript.test.cjs +0 -0
  221. package/src/main/__tests__/promptSessionsCreateEpicHandler.test.cjs +0 -159
  222. package/src/main/__tests__/pty-epic-worktree-spawn-cwd.test.cjs +0 -282
  223. package/src/main/__tests__/pty-session-open-telemetry.test.cjs +0 -96
  224. package/src/main/__tests__/pty-write-result.test.cjs +0 -46
  225. package/src/main/__tests__/queue-health-verdict.test.cjs +0 -170
  226. package/src/main/__tests__/queue-starvation-dispatch-driver.test.cjs +0 -286
  227. package/src/main/__tests__/queue-starvation-per-project.test.cjs +0 -147
  228. package/src/main/__tests__/queueHistory.test.cjs +0 -355
  229. package/src/main/__tests__/queueOps-interactive-ac-lint.test.cjs +0 -65
  230. package/src/main/__tests__/queueOpsArchiveDestination.test.cjs +0 -65
  231. package/src/main/__tests__/queueOpsAutoArchive.test.cjs +0 -211
  232. package/src/main/__tests__/rateLimitPollerStreak.test.cjs +0 -128
  233. package/src/main/__tests__/rcaReport.test.cjs +0 -266
  234. package/src/main/__tests__/reconcileFlatPrdSweep.test.cjs +0 -119
  235. package/src/main/__tests__/reconcileTiming.test.cjs +0 -135
  236. package/src/main/__tests__/runLogRetention.test.cjs +0 -489
  237. package/src/main/__tests__/runVerify-atomic-verdicts.test.cjs +0 -26
  238. package/src/main/__tests__/runVerify-blocked-by-foreign-wip.test.cjs +0 -58
  239. package/src/main/__tests__/runVerify-landed-commit-outranks.test.cjs +0 -191
  240. package/src/main/__tests__/runVerify-policy-denial.test.cjs +0 -89
  241. package/src/main/__tests__/runVerify-transcript-commit-evidence.test.cjs +0 -225
  242. package/src/main/__tests__/runVerify.test.cjs +0 -1784
  243. package/src/main/__tests__/scheduleJobSchema.test.cjs +0 -127
  244. package/src/main/__tests__/scheduleJobStatusDrift.test.cjs +0 -65
  245. package/src/main/__tests__/scheduleJobTransitions.test.cjs +0 -277
  246. package/src/main/__tests__/scheduleJobTransitionsGrep.test.cjs +0 -59
  247. package/src/main/__tests__/scheduleJobTransitionsTelemetryTap.test.cjs +0 -72
  248. package/src/main/__tests__/scheduler-admin-routes.test.cjs +0 -199
  249. package/src/main/__tests__/scheduler-adopted-run-supervision.test.cjs +0 -143
  250. package/src/main/__tests__/scheduler-already-satisfied-on-main.test.cjs +0 -105
  251. package/src/main/__tests__/scheduler-archive-completed-prd.test.cjs +0 -102
  252. package/src/main/__tests__/scheduler-archived-twin-guard.test.cjs +0 -155
  253. package/src/main/__tests__/scheduler-autofix-outcome.test.cjs +0 -188
  254. package/src/main/__tests__/scheduler-autofix-select.test.cjs +0 -439
  255. package/src/main/__tests__/scheduler-autopromote.test.cjs +0 -51
  256. package/src/main/__tests__/scheduler-bash-timeout-env.test.cjs +0 -101
  257. package/src/main/__tests__/scheduler-blocked-by-foreign-wip.test.cjs +0 -107
  258. package/src/main/__tests__/scheduler-boot-orphans.test.cjs +0 -153
  259. package/src/main/__tests__/scheduler-broadcast-reconcile.test.cjs +0 -121
  260. package/src/main/__tests__/scheduler-clear-queue-history.test.cjs +0 -134
  261. package/src/main/__tests__/scheduler-commit-guard-noop.test.cjs +0 -244
  262. package/src/main/__tests__/scheduler-committed-in-window.test.cjs +0 -182
  263. package/src/main/__tests__/scheduler-cross-project-batch.test.cjs +0 -43
  264. package/src/main/__tests__/scheduler-default-eligible-heal.test.cjs +0 -168
  265. package/src/main/__tests__/scheduler-dispatch-loop.test.cjs +0 -58
  266. package/src/main/__tests__/scheduler-effective-concurrency.test.cjs +0 -81
  267. package/src/main/__tests__/scheduler-epic-digest.test.cjs +0 -227
  268. package/src/main/__tests__/scheduler-failed-autoreset.test.cjs +0 -121
  269. package/src/main/__tests__/scheduler-finalize-dispatch-guards.test.cjs +0 -229
  270. package/src/main/__tests__/scheduler-find-prd-dir.test.cjs +0 -75
  271. package/src/main/__tests__/scheduler-fix-plan-path.test.cjs +0 -119
  272. package/src/main/__tests__/scheduler-force-tick-outcome.test.cjs +0 -46
  273. package/src/main/__tests__/scheduler-foreign-wip-manifest.test.cjs +0 -78
  274. package/src/main/__tests__/scheduler-gate-shadow.test.cjs +0 -119
  275. package/src/main/__tests__/scheduler-guard-verdict-autoresolve.test.cjs +0 -390
  276. package/src/main/__tests__/scheduler-heal-refusal.test.cjs +0 -61
  277. package/src/main/__tests__/scheduler-heartbeat-payload.test.cjs +0 -80
  278. package/src/main/__tests__/scheduler-inplace-salvage.test.cjs +0 -323
  279. package/src/main/__tests__/scheduler-integration-failure-stamp.test.cjs +0 -41
  280. package/src/main/__tests__/scheduler-investigation-clean-skip.test.cjs +0 -63
  281. package/src/main/__tests__/scheduler-investigation-prompt.test.cjs +0 -123
  282. package/src/main/__tests__/scheduler-job-budget.test.cjs +0 -172
  283. package/src/main/__tests__/scheduler-job-overrun.test.cjs +0 -175
  284. package/src/main/__tests__/scheduler-launch-failure.test.cjs +0 -199
  285. package/src/main/__tests__/scheduler-leftover-fields.test.cjs +0 -52
  286. package/src/main/__tests__/scheduler-leftover-quarantine.test.cjs +0 -199
  287. package/src/main/__tests__/scheduler-looks-done.test.cjs +0 -537
  288. package/src/main/__tests__/scheduler-manual-pause.test.cjs +0 -118
  289. package/src/main/__tests__/scheduler-mechanical-recovery.test.cjs +0 -245
  290. package/src/main/__tests__/scheduler-meta-code-sha.test.cjs +0 -46
  291. package/src/main/__tests__/scheduler-mutate-reentrancy.test.cjs +0 -117
  292. package/src/main/__tests__/scheduler-needs-review-autoresolve.test.cjs +0 -197
  293. package/src/main/__tests__/scheduler-never-stop.test.cjs +0 -157
  294. package/src/main/__tests__/scheduler-no-dead-end-status.test.cjs +0 -152
  295. package/src/main/__tests__/scheduler-no-orphan-run-dir.test.cjs +0 -81
  296. package/src/main/__tests__/scheduler-notify-originating-tab-transcript.test.cjs +0 -87
  297. package/src/main/__tests__/scheduler-notify-originating-tab.test.cjs +0 -343
  298. package/src/main/__tests__/scheduler-periodic-reverify-guard.test.cjs +0 -217
  299. package/src/main/__tests__/scheduler-porcelain-rename.test.cjs +0 -164
  300. package/src/main/__tests__/scheduler-prd-missing-skip.test.cjs +0 -161
  301. package/src/main/__tests__/scheduler-prd-persona-spawn.test.cjs +0 -178
  302. package/src/main/__tests__/scheduler-quarantine-autoresolve.test.cjs +0 -165
  303. package/src/main/__tests__/scheduler-quiet-machine-lease.test.cjs +0 -257
  304. package/src/main/__tests__/scheduler-rate-limit-cooldown-freshness.test.cjs +0 -123
  305. package/src/main/__tests__/scheduler-rate-limit-pause.test.cjs +0 -152
  306. package/src/main/__tests__/scheduler-rate-limit-spin-guard.test.cjs +0 -156
  307. package/src/main/__tests__/scheduler-reap-dead-running-jobs.test.cjs +0 -754
  308. package/src/main/__tests__/scheduler-reaper-helpers-basics.test.cjs +0 -87
  309. package/src/main/__tests__/scheduler-reconcile-cwd-preserve.test.cjs +0 -100
  310. package/src/main/__tests__/scheduler-reconcile-history-backfill.test.cjs +0 -105
  311. package/src/main/__tests__/scheduler-reconcile-invalid-repair.test.cjs +0 -203
  312. package/src/main/__tests__/scheduler-reconcile-quarantine.test.cjs +0 -247
  313. package/src/main/__tests__/scheduler-reset-job-fields-guard.test.cjs +0 -77
  314. package/src/main/__tests__/scheduler-resume-recovery.test.cjs +0 -254
  315. package/src/main/__tests__/scheduler-shard-quarantine.test.cjs +0 -115
  316. package/src/main/__tests__/scheduler-shared-tree-guard.test.cjs +0 -380
  317. package/src/main/__tests__/scheduler-sigterm-commit.test.cjs +0 -43
  318. package/src/main/__tests__/scheduler-stall-per-project.test.cjs +0 -126
  319. package/src/main/__tests__/scheduler-starve-escalation.test.cjs +0 -154
  320. package/src/main/__tests__/scheduler-stranded-autofix-park.test.cjs +0 -252
  321. package/src/main/__tests__/scheduler-stranded-investigation.test.cjs +0 -185
  322. package/src/main/__tests__/scheduler-stuck-failed-escalation.test.cjs +0 -136
  323. package/src/main/__tests__/scheduler-supervisor-record.test.cjs +0 -81
  324. package/src/main/__tests__/scheduler-tick-cancel-token.test.cjs +0 -54
  325. package/src/main/__tests__/scheduler-tick-wedge.test.cjs +0 -172
  326. package/src/main/__tests__/scheduler-transient-failure.test.cjs +0 -141
  327. package/src/main/__tests__/scheduler-unreadable-queue-guard.test.cjs +0 -62
  328. package/src/main/__tests__/scheduler-utilization-hold.test.cjs +0 -89
  329. package/src/main/__tests__/scheduler-verify-prd-path.test.cjs +0 -109
  330. package/src/main/__tests__/scheduler-worktree-cap-defer.test.cjs +0 -234
  331. package/src/main/__tests__/scheduler-worktree-exec-cwd.test.cjs +0 -120
  332. package/src/main/__tests__/scheduler-writeprd-epic-rollback.test.cjs +0 -105
  333. package/src/main/__tests__/schedulerBatchRootBlocker.test.cjs +0 -117
  334. package/src/main/__tests__/schedulerStateSidecarRestore.test.cjs +0 -110
  335. package/src/main/__tests__/seedAgentPersonas.test.cjs +0 -184
  336. package/src/main/__tests__/seedSchedulerMcp.test.cjs +0 -211
  337. package/src/main/__tests__/seedStatus.test.cjs +0 -100
  338. package/src/main/__tests__/seedValidatorPersona.test.cjs +0 -116
  339. package/src/main/__tests__/stop-signal-anchor.test.cjs +0 -75
  340. package/src/main/__tests__/telemetryClient.test.cjs +0 -1055
  341. package/src/main/__tests__/telemetryContract.test.cjs +0 -930
  342. package/src/main/__tests__/telemetrySettings.test.cjs +0 -210
  343. package/src/main/__tests__/transcripts-batch-flush.test.cjs +0 -249
  344. package/src/main/__tests__/transcripts-doFlush-array.test.cjs +0 -124
  345. package/src/main/__tests__/transcripts-paged-reads.test.cjs +0 -241
  346. package/src/main/__tests__/transcripts-worktree-epic-path.test.cjs +0 -154
  347. package/src/main/__tests__/transcriptsUsageFor.test.cjs +0 -206
  348. package/src/main/__tests__/uniquePrdNumbers.test.cjs +0 -153
  349. package/src/main/__tests__/usageSingleFlight.test.cjs +0 -169
  350. package/src/main/__tests__/validationSentinels.test.cjs +0 -84
  351. package/src/main/__tests__/workTypeLibrary.test.cjs +0 -89
  352. package/src/main/bilkoHost.cjs +0 -314
  353. package/src/main/bilkoHostCore.cjs +0 -89
  354. package/src/main/lib/__tests__/active-sessions.test.cjs +0 -251
  355. package/src/main/lib/__tests__/activeIndexRebuild.test.cjs +0 -179
  356. package/src/main/lib/__tests__/agentPersonaSchema.test.cjs +0 -67
  357. package/src/main/lib/__tests__/auditLog.test.cjs +0 -38
  358. package/src/main/lib/__tests__/bootSelfHeal.test.cjs +0 -107
  359. package/src/main/lib/__tests__/branchSweep.test.cjs +0 -164
  360. package/src/main/lib/__tests__/buildIdentity.test.cjs +0 -121
  361. package/src/main/lib/__tests__/buildTarget.test.cjs +0 -52
  362. package/src/main/lib/__tests__/childWithLog.test.cjs +0 -321
  363. package/src/main/lib/__tests__/coldBootPromptSessionsWrite.test.cjs +0 -87
  364. package/src/main/lib/__tests__/crashTelemetry.test.cjs +0 -103
  365. package/src/main/lib/__tests__/credentials-futile-refresh.test.cjs +0 -115
  366. package/src/main/lib/__tests__/cwdClassify.test.cjs +0 -111
  367. package/src/main/lib/__tests__/definitionOfDoneSequence.test.cjs +0 -95
  368. package/src/main/lib/__tests__/delegationReadiness.test.cjs +0 -1175
  369. package/src/main/lib/__tests__/dispatchLoop.test.cjs +0 -63
  370. package/src/main/lib/__tests__/effectiveModelInfo.test.cjs +0 -244
  371. package/src/main/lib/__tests__/ephemeralCwd.test.cjs +0 -91
  372. package/src/main/lib/__tests__/epicDelegationStats.test.cjs +0 -137
  373. package/src/main/lib/__tests__/epicSpawnCwd.test.cjs +0 -283
  374. package/src/main/lib/__tests__/epicSpawnPlan.test.cjs +0 -196
  375. package/src/main/lib/__tests__/epicTranscriptPath.test.cjs +0 -163
  376. package/src/main/lib/__tests__/epicWorktreeBoot.test.cjs +0 -136
  377. package/src/main/lib/__tests__/epicWorktreeMerge.test.cjs +0 -130
  378. package/src/main/lib/__tests__/epicWorktreeMint.test.cjs +0 -117
  379. package/src/main/lib/__tests__/epicWorktreeProjectConfig.test.cjs +0 -137
  380. package/src/main/lib/__tests__/fixChainDepth.test.cjs +0 -40
  381. package/src/main/lib/__tests__/fixtures/204-mercury-steam-horse.log.txt +0 -13
  382. package/src/main/lib/__tests__/fixtures/scheduler-machine.json.corrupt-1789147548 +0 -34
  383. package/src/main/lib/__tests__/gateFixtures.json +0 -20
  384. package/src/main/lib/__tests__/gitCacheBound.test.cjs +0 -69
  385. package/src/main/lib/__tests__/gitWorktree.test.cjs +0 -1478
  386. package/src/main/lib/__tests__/gitWorktreeSalvage.test.cjs +0 -107
  387. package/src/main/lib/__tests__/gitWorktreeSalvageDelta.test.cjs +0 -153
  388. package/src/main/lib/__tests__/guardShims.test.cjs +0 -158
  389. package/src/main/lib/__tests__/importReferences.spec.cjs +0 -56
  390. package/src/main/lib/__tests__/instanceLock.test.cjs +0 -173
  391. package/src/main/lib/__tests__/jobSupervisorRecord.test.cjs +0 -78
  392. package/src/main/lib/__tests__/jobWorktree.test.cjs +0 -199
  393. package/src/main/lib/__tests__/jobWorktreeBootLive.test.cjs +0 -82
  394. package/src/main/lib/__tests__/landedSinceRun.test.cjs +0 -133
  395. package/src/main/lib/__tests__/launchFailure.test.cjs +0 -220
  396. package/src/main/lib/__tests__/loadGate.test.cjs +0 -303
  397. package/src/main/lib/__tests__/localAdminHttp.test.cjs +0 -214
  398. package/src/main/lib/__tests__/loopDelay.test.cjs +0 -68
  399. package/src/main/lib/__tests__/mcpToolCatalog.test.cjs +0 -107
  400. package/src/main/lib/__tests__/modelCatalog.test.cjs +0 -202
  401. package/src/main/lib/__tests__/opsOwnership.test.cjs +0 -113
  402. package/src/main/lib/__tests__/opsRootAbsoluteCwd.test.cjs +0 -328
  403. package/src/main/lib/__tests__/opsRootNestedWrite.test.cjs +0 -51
  404. package/src/main/lib/__tests__/opsRootResolve.test.cjs +0 -149
  405. package/src/main/lib/__tests__/prdDeclaredPaths.test.cjs +0 -82
  406. package/src/main/lib/__tests__/prdDisposition.test.cjs +0 -224
  407. package/src/main/lib/__tests__/procIdentity.test.cjs +0 -119
  408. package/src/main/lib/__tests__/procName.test.cjs +0 -92
  409. package/src/main/lib/__tests__/projectBriefCore.test.cjs +0 -216
  410. package/src/main/lib/__tests__/projectRootResolve.test.cjs +0 -148
  411. package/src/main/lib/__tests__/queueHealth.test.cjs +0 -58
  412. package/src/main/lib/__tests__/queueStoreAtomicWrite.test.cjs +0 -88
  413. package/src/main/lib/__tests__/queueStoreMachineStateRecovery.test.cjs +0 -190
  414. package/src/main/lib/__tests__/quietMachineLease.test.cjs +0 -39
  415. package/src/main/lib/__tests__/rateLimitWindow.test.cjs +0 -88
  416. package/src/main/lib/__tests__/reaperHelpers.test.cjs +0 -577
  417. package/src/main/lib/__tests__/schedulerBatchDepends.test.cjs +0 -312
  418. package/src/main/lib/__tests__/schedulerBatchFairness.test.cjs +0 -213
  419. package/src/main/lib/__tests__/schedulerBatchLaunchHold.test.cjs +0 -125
  420. package/src/main/lib/__tests__/schedulerBatchProjectCap.test.cjs +0 -127
  421. package/src/main/lib/__tests__/schedulerBatchQuietMachine.test.cjs +0 -109
  422. package/src/main/lib/__tests__/schedulerMcpServerHeadlessRefusal.test.cjs +0 -71
  423. package/src/main/lib/__tests__/schedulerMcpServerHelp.test.cjs +0 -216
  424. package/src/main/lib/__tests__/schedulerMcpServerProjectHome.test.cjs +0 -183
  425. package/src/main/lib/__tests__/schedulerPaths.test.cjs +0 -226
  426. package/src/main/lib/__tests__/schedulerPathsWorktree.test.cjs +0 -133
  427. package/src/main/lib/__tests__/schedulerRuntimeState.test.cjs +0 -56
  428. package/src/main/lib/__tests__/sessionSlots.test.cjs +0 -144
  429. package/src/main/lib/__tests__/telemetryBacklog.test.cjs +0 -626
  430. package/src/main/lib/__tests__/telemetryBoot.test.cjs +0 -134
  431. package/src/main/lib/__tests__/telemetryConsent.test.cjs +0 -136
  432. package/src/main/lib/__tests__/telemetryCounters.test.cjs +0 -57
  433. package/src/main/lib/__tests__/telemetryCountersMetadataColumn.test.cjs +0 -98
  434. package/src/main/lib/__tests__/terminalRunOutcome.test.cjs +0 -200
  435. package/src/main/lib/__tests__/toolUseClassify.test.cjs +0 -53
  436. package/src/main/lib/__tests__/updateCheck.test.cjs +0 -63
  437. package/src/main/lib/__tests__/upgradeDrain.test.cjs +0 -130
  438. package/src/main/lib/__tests__/usageCircuit.test.cjs +0 -354
  439. package/src/main/lib/__tests__/watchdog-helpers.test.cjs +0 -441
  440. package/src/main/lib/__tests__/watchdog-relaunch.test.cjs +0 -266
  441. package/src/main/lib/kgExchangePairing.cjs +0 -75
@@ -1,3 +0,0 @@
1
- import{az as d,ak as e,S as T,A as Q,m as P,b1 as ee,a_ as te,aT as se,d as $,aw as ae,aN as ne,aX as re,b5 as G,aZ as le,aR as D,am as ie,aq as oe,v as ce,J as de,X as ue,H,aG as xe}from"./index-Cd98Q1lD.js";import{S as pe}from"./ScopeSwitcher-CjJi8ST5.js";import{S as q}from"./SaveBar-l9jnEMES.js";import{u as me,s as B,E as fe}from"./settingsSchema-IhUfucCF.js";import{T as L}from"./Toggle-BbW4nGGf.js";import"./monaco-editor-BW5C4Iv1.js";const he=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle","permissions"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Model allow/override lists, reasoning depth, and fast-mode toggles — machine-wide, with no per-Epic override yet. An Epic's Agent persona model (Agent Library) still wins over Essentials' plain model default.",advanced:!0,keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled","fallbackModel","enforceAvailableModels","teammateDefaultModel","advisorModel"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],ge={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function W(s){return s.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((l,n)=>{const r=ge[l];return r||(n===0?l.charAt(0).toUpperCase()+l.slice(1):l)}).join(" ")}function z(s){const a=new Set,t=[];for(const n of he){const r=n.keys.filter(i=>s.has(i));r.forEach(i=>a.add(i)),r.length!==0&&t.push({id:n.id,title:n.title,summary:n.summary,advanced:!!n.advanced,keys:r})}const l=Array.from(s).filter(n=>!a.has(n)&&n!=="$schema").sort();return l.length>0&&t.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:l}),t}function be(s,a){return z(s).map(t=>({id:t.id,title:t.title,advanced:t.advanced,total:t.keys.length,setCount:t.keys.filter(l=>a.has(l)).length}))}const ye={};function V(s,a){if(a)return{text:a,authored:!1};const t=ye[s];return t?{text:t,authored:!0}:null}const je={essentials:"star",git:"link",memory:"memory",model:"sparkle",interface:"eye",updates:"reload",env:"keys",hooks:"hooks",mcp:"mcp",plugins:"plugins",filesystem:"folder",login:"lock",feedback:"send",advanced:"shield",other:"dot"},ve=["user","project","local","default"],Ne={user:"user",project:"project",local:"local",default:"default"};function we({node:s,targetScope:a,onOverride:t,schema:l}){const[n,r]=d.useState(""),[i,p]=d.useState(!1),[m,v]=d.useState(!0),x=s.kind==="object"?s:null,w=x?Object.keys(x.children):[],g=l.rootKeys(),y=new Set([...w,...g]),u=d.useMemo(()=>z(y),[Array.from(y).sort().join(",")]),b=d.useMemo(()=>be(y,new Set(w)),[Array.from(y).sort().join(","),w.join(",")]),[C,E]=d.useState(null),f=d.useRef(null),k=o=>{const j=u.find(N=>N.id===o);j!=null&&j.advanced&&!i&&p(!0),E(o)};d.useEffect(()=>{if(!C)return;E(null);const o=f.current,j=document.getElementById(`settings-group-${C}`);if(!o||!j)return;const N=j.getBoundingClientRect().top-o.getBoundingClientRect().top;o.scrollBy({top:N,behavior:"smooth"})},[C]);const S=d.useMemo(()=>u.filter(o=>i||!o.advanced).map(o=>({...o,keys:o.keys.filter(j=>{const N=(x==null?void 0:x.children[j])!==void 0;if(!m&&!N)return!1;if(!n.trim())return!0;const h=l.at([j]);return[j,W(j),(h==null?void 0:h.description)??""].join(" ").toLowerCase().includes(n.toLowerCase())})})).filter(o=>o.keys.length>0),[u,n,i,m,x,l]);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-3 text-xs",children:[e.jsxs("span",{className:"text-fg-faint",children:["writing overrides to"," ",e.jsx("span",{className:"text-fg-dim font-medium",children:T[a].label})]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:o=>v(o.target.checked),className:"accent-accent"}),"show not-yet-configured"]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:o=>p(o.target.checked),className:"accent-accent"}),"show advanced"]}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{value:n,onChange:o=>r(o.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx(ke,{groups:b,onJump:k}),e.jsxs("div",{ref:f,className:"flex-1 overflow-auto py-3",children:[S.map(o=>e.jsx(Se,{id:o.id,title:o.title,summary:o.summary,advanced:o.advanced,children:o.keys.map(j=>{const N=x==null?void 0:x.children[j],h=l.at([j]);return e.jsx(Ce,{keyName:j,node:N,info:h,targetScope:a,onOverride:(c,O)=>t([j],c,O)},j)})},o.id)),S.length===0&&e.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',n,'"']})]})]})]})}function ke({groups:s,onJump:a}){return e.jsx("nav",{className:"shrink-0 w-48 border-r border-line bg-bg-elev/30 overflow-y-auto py-3",children:s.map(t=>e.jsxs("button",{onClick:()=>a(t.id),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bg-hi transition-colors",title:`jump to ${t.title}`,children:[e.jsx(Q,{name:je[t.id]??"dot",size:15,className:"text-fg-faint shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-xs text-fg-dim",children:t.title}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono shrink-0",children:[t.setCount,"/",t.total]})]},t.id))})}function Se({id:s,title:a,summary:t,advanced:l,children:n}){const[r,i]=d.useState(!0);return e.jsxs("section",{id:`settings-group-${s}`,className:"mx-4 mb-4 rounded-lg border border-line shadow-sm bg-bg-elev/50 overflow-hidden",children:[e.jsxs("header",{className:"px-4 py-3 bg-bg-elev cursor-pointer hover:bg-bg-hi flex items-center gap-3 border-b border-line",onClick:()=>i(!r),children:[e.jsx("span",{className:"text-fg-faint w-3",children:r?"▾":"▸"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-fg text-base font-semibold",children:a}),l&&e.jsx("span",{className:"text-[9px] px-1.5 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"advanced"})]}),e.jsx("p",{className:"text-fg-dim text-sm mt-0.5",children:t})]})]}),r&&e.jsx("div",{className:"divide-y divide-line/60",children:n})]})}function Ce({keyName:s,node:a,info:t,targetScope:l,onOverride:n}){const[r,i]=d.useState(!1),[p,m]=d.useState(!1),v=W(s),x=a!==void 0,g=(a==null?void 0:a.kind)==="leaf"?a:null,y=(a==null?void 0:a.kind)==="object"||(a==null?void 0:a.kind)==="array",u=t==null?void 0:t.default,b=g&&u!==void 0&&Z(g.value,u),C=Me({isSet:x,leafNode:g,defaultVal:u,isDefault:!!b,node:a}),E=Ee(g,u),f=E.length>=2,k=!!g&&!b,S=V(s,t==null?void 0:t.description);return e.jsx("div",{className:"px-4 py-3 hover:bg-bg-elev/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("button",{onClick:()=>i(!r),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:r?"collapse":"expand",children:r?"▾":"▸"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[e.jsx("h3",{className:"text-fg text-sm",children:v}),e.jsx(Ie,{kind:C.kind,label:C.label}),f&&e.jsxs("button",{onClick:o=>{o.stopPropagation(),r||i(!0),m(j=>!j)},className:"text-[9px] px-1.5 py-0 rounded border border-blue-900/40 bg-blue-950/30 text-blue-300/90 uppercase tracking-wide hover:bg-blue-900/40",title:"this key is defined in multiple scopes — click to expand",children:["drift · ",E.map(o=>Ne[o]).join(" · ")]}),k&&g&&e.jsx("button",{onClick:o=>{o.stopPropagation(),n(void 0,g.winner)},className:"text-[9px] px-1.5 py-0 rounded border border-line bg-bg-elev text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`reset · delete from ${T[g.winner].label}`,children:"↺ reset"}),(t==null?void 0:t.deprecated)&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"deprecated"}),(t==null?void 0:t.required)&&!x&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-red-900/40 bg-red-950/30 text-red-400/80 uppercase tracking-wide",children:"required"})]}),S&&e.jsx("p",{className:`text-fg-dim text-xs mt-0.5 leading-relaxed ${S.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:S.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:Le(S.text)}),r&&p&&g&&e.jsx(Te,{leaf:g,defaultVal:u,onReset:o=>n(void 0,o)}),r&&e.jsx(Oe,{keyName:s,node:a,info:t,targetScope:l,onOverride:o=>n(o)})]}),e.jsx("div",{className:"shrink-0",children:!r&&e.jsx(De,{node:a,info:t,onSet:o=>{n(o)},disabled:y&&x})})]})})}function Ee(s,a){if(!s)return[];const t=new Set;t.add(s.winner);for(const l of s.shadowed)t.add(l.scope);return a!==void 0&&t.add("default"),ve.filter(l=>t.has(l))}function Te({leaf:s,defaultVal:a,onReset:t}){const l={};l[s.winner]={value:s.value,winner:!0};for(const n of s.shadowed)l[n.scope]={value:n.value,winner:!1};return e.jsxs("div",{className:"mt-2 border border-line rounded bg-bg-elev/40 text-xs",children:[e.jsx("div",{className:"px-2 py-1 text-fg-faint border-b border-line/60",children:"Values across all scopes (winner highlighted · reset removes that scope's value):"}),e.jsxs("div",{className:"divide-y divide-line/60",children:[["user","project","local"].map(n=>{const r=l[n],i=r!==void 0;return e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:T[n].label}),e.jsx("span",{className:`font-mono truncate ${r!=null&&r.winner?"text-accent":"text-fg-dim"}`,children:i?R(r.value):e.jsx("span",{className:"text-fg-faint",children:"—"})}),i?e.jsx("button",{onClick:()=>t(n),className:"text-[9px] px-1.5 py-0 rounded border border-line text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`delete this key from ${T[n].label}`,children:"↺"}):e.jsx("span",{})]},n)}),e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:"Default"}),e.jsx("span",{className:"font-mono text-fg-dim truncate",children:a!==void 0?R(a):e.jsx("span",{className:"text-fg-faint",children:"—"})}),e.jsx("span",{})]})]})]})}function Oe({keyName:s,node:a,info:t,targetScope:l,onOverride:n}){const i=(a==null?void 0:a.kind)==="leaf"?a:null,p=V(s,t==null?void 0:t.description);return e.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[p&&e.jsx("p",{className:`text-fg-dim leading-relaxed whitespace-pre-wrap ${p.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:p.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:p.text}),e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(t==null?void 0:t.type)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(t.type)?t.type.join(" | "):t.type})]}),(t==null?void 0:t.default)!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Default"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:R(t.default)})]}),(t==null?void 0:t.enum)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Options"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:t.enum.map(m=>String(m)).join(" | ")})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Current"}),e.jsxs("dd",{className:"font-mono",children:[e.jsx("span",{className:"text-fg-dim",children:R(i.value)}),e.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",T[i.winner].label]})]})]}),i&&i.shadowed.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Shadowed"}),e.jsx("dd",{className:"space-y-0.5",children:i.shadowed.map((m,v)=>e.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[R(m.value)," —"," ",e.jsx("span",{className:"no-underline",children:T[m.scope].label})]},v))})]}),(a==null?void 0:a.kind)==="array"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Accumulated"}),e.jsxs("dd",{className:"text-fg-dim",children:[a.items.length," items across all scopes"]})]})]}),e.jsx("div",{className:"pt-2 flex items-center gap-2 flex-wrap border-t border-line/60",children:e.jsx(Ae,{keyName:s,node:a,info:t,onChange:n,targetScope:l})})]})}function Ae({node:s,info:a,onChange:t,targetScope:l}){const r=(s==null?void 0:s.kind)==="leaf"?s.value:a==null?void 0:a.default,i=Y(a==null?void 0:a.type);if(i==="boolean"){const p=r===!0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:[{v:!0,label:"on"},{v:!1,label:"off"}].map(({v:m,label:v})=>e.jsx("button",{onClick:()=>t(m),className:`px-3 py-0.5 text-xs transition-colors ${p===m?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:v},v))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",T[l].label]})]})}return a!=null&&a.enum?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-fg-faint",children:"Choose:"}),a.enum.map(p=>{const m=Z(r,p);return e.jsx("button",{onClick:()=>t(p),className:`px-2 py-0.5 text-xs rounded border ${m?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(p)},String(p))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",T[l].label]})]}):i==="integer"||i==="number"?e.jsx(Re,{value:typeof r=="number"?r:void 0,integer:i==="integer",onCommit:t,target:T[l].label}):i==="string"?e.jsx(Pe,{value:typeof r=="string"?r:"",onCommit:t,target:T[l].label}):e.jsxs("div",{className:"text-fg-faint",children:["Complex value (",i??"object/array",") — use the"," ",e.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function Re({value:s,integer:a,onCommit:t,target:l}){const[n,r]=d.useState(s!==void 0?String(s):""),i=()=>{const p=a?parseInt(n,10):parseFloat(n);Number.isNaN(p)||t(p)};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("input",{type:"number",value:n,onChange:p=>r(p.target.value),onBlur:i,onKeyDown:p=>{p.key==="Enter"&&p.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:i,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",l]})]})}function Pe({value:s,onCommit:a,target:t}){const[l,n]=d.useState(s);return e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("span",{className:"text-fg-faint shrink-0",children:"Set to:"}),e.jsx("input",{type:"text",value:l,onChange:r=>n(r.target.value),onKeyDown:r=>{r.key==="Enter"&&a(l)},className:"flex-1 min-w-0 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:()=>a(l),className:"shrink-0 px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",t]})]})}function De({node:s,info:a,onSet:t,disabled:l}){const n=(s==null?void 0:s.kind)==="leaf",r=Y(a==null?void 0:a.type);if(l)return null;if(r==="boolean"){const i=n&&s.value===!0;return e.jsx("button",{onClick:()=>t(!i),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${i?"bg-accent/15 text-accent border-accent/40 hover:bg-accent hover:text-bg":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,title:"toggle",children:i?"on":"off"})}return null}function Me({isSet:s,leafNode:a,defaultVal:t,isDefault:l,node:n}){return s?(n==null?void 0:n.kind)==="array"?{kind:"accumulated",label:`${n.items.length} items`}:(n==null?void 0:n.kind)==="object"?{kind:"set",label:"configured"}:a?l?{kind:"default",label:`= default · ${T[a.winner].label}`}:a.shadowed.length>0?{kind:"override",label:`overriding ${a.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${T[a.winner].label}`}:{kind:"set",label:"configured"}:t!==void 0?{kind:"default",label:`using default: ${R(t)}`}:{kind:"unset",label:"not configured"}}function Ie({kind:s,label:a}){const t={set:"bg-accent/15 text-accent border-accent/30",default:"bg-bg-hi text-fg-dim border-line",unset:"bg-bg-elev text-fg-faint border-line",override:"bg-purple-950/30 text-purple-400/80 border-purple-900/40",accumulated:"bg-blue-950/30 text-blue-400/80 border-blue-900/40"}[s];return e.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${t}`,children:a})}function Y(s){if(s)return Array.isArray(s)?s.find(t=>t!=="null")??s[0]:s}function Z(s,a){return s===a?!0:typeof s!=typeof a?!1:s&&a&&typeof s=="object"?JSON.stringify(s)===JSON.stringify(a):!1}function Le(s){const a=s.trim().split(`
2
- `)[0],t=a.match(/^([^.!?]+[.!?])/);return t?t[1]:a.length>120?a.slice(0,120)+"…":a}function R(s){if(typeof s=="string")return s===""?'""':JSON.stringify(s);if(s===null)return"null";if(s===void 0)return"—";if(typeof s=="object"){const a=JSON.stringify(s);return a.length>60?a.slice(0,60)+"…":a}return String(s)}const _e=1440*60*1e3;function J(s){if(!s)return"never";const a=new Date(s).getTime();return Number.isNaN(a)?"never":new Date(a).toLocaleString()}function U(s){return s?new Date(s).toLocaleString():"never"}function Fe(){return e.jsxs("div",{className:"p-4 max-w-3xl space-y-8 text-sm",children:[e.jsx($e,{}),e.jsx("hr",{className:"border-line"}),e.jsx(Ge,{})]})}function $e(){const[s,a]=d.useState(null),[t,l]=d.useState(null),[n,r]=d.useState(null),[i,p]=d.useState(null),[m,v]=d.useState(!1),[x,w]=d.useState(null),[g,y]=d.useState(null);if(d.useEffect(()=>{let f=!1;return Promise.all([window.api.otel.getConfig(),window.api.otel.status(),window.api.otel.configPath()]).then(([k,S,o])=>{f||(a(k),r(k),l(S),p(o))}).catch(k=>{console.warn("[telemetry] load failed:",k==null?void 0:k.message)}),()=>{f=!0}},[]),!n||!s)return e.jsx(P,{title:"loading…"});const u=JSON.stringify(n)!==JSON.stringify(s),b=(f,k)=>{w(null),r({...n,[f]:k})},C=async()=>{v(!0),w(null);try{const f=await window.api.otel.setConfig(n);!f.ok&&f.error&&w(f.error),a(f.config),r(f.config),l(f.status),y(Date.now())}catch(f){w(f instanceof Error?f.message:String(f))}finally{v(!1)}},E=()=>{w(null),r(s)};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"OpenTelemetry export"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"When enabled, every classified transcript event (tool_use, todo_write, plan, usage, agent_spawn) is mirrored as a 0-duration OTLP/HTTP span. Point this at a local collector (Jaeger, Grafana Tempo, SigNoz, Honeycomb) for cross-session analysis."}),i&&e.jsxs("p",{className:"text-fg-faint text-[11px]",children:["stored at ",e.jsx("span",{className:"font-mono",children:i})]})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Export transcripts to OTEL"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Toggle off to disable all span emission immediately."})]}),e.jsx(L,{checked:n.enabled,onChange:f=>b("enabled",f),label:n.enabled?"on":"off"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"OTLP/HTTP traces endpoint"}),e.jsx("input",{type:"text",value:n.endpoint,onChange:f=>b("endpoint",f.target.value),placeholder:"http://localhost:4318/v1/traces",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsxs("span",{className:"text-fg-dim text-xs",children:["Headers (newline-separated ",e.jsx("span",{className:"font-mono",children:"Key: Value"}),")"]}),e.jsx("textarea",{value:n.headers,onChange:f=>b("headers",f.target.value),placeholder:"x-honeycomb-team: YOUR_API_KEY",rows:3,className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Service name"}),e.jsx("input",{type:"text",value:n.serviceName,onChange:f=>b("serviceName",f.target.value),placeholder:"session-manager",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Include content (PII)"}),e.jsxs("div",{className:"text-fg-faint text-xs leading-relaxed",children:["Adds tool inputs, plan text, and agent prompts to span attributes. Off by default — matches upstream Claude Code's ",e.jsx("span",{className:"font-mono",children:"OTEL_LOG_USER_PROMPTS"})," opt-in."]})]}),e.jsx(L,{checked:n.includeContent,onChange:f=>b("includeContent",f),label:n.includeContent?"on":"off"})]})]}),t&&e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"enabled:"})," ",e.jsx("span",{className:t.enabled?"text-accent":"text-fg-dim",children:String(t.enabled)})]}),t.error&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"error:"})," ",t.error]}),!t.error&&t.enabled&&e.jsx("div",{className:"text-fg-faint",children:"spans batched and exported in the background. Verify by enabling and pointing at a local Jaeger."})]}),e.jsxs("footer",{className:"flex items-center gap-3 pt-2 border-t border-line",children:[e.jsx("button",{onClick:C,disabled:!u||m,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:m?"saving…":"Save"}),e.jsx("button",{onClick:E,disabled:!u||m,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg disabled:opacity-50 disabled:cursor-not-allowed",children:"Revert"}),x&&e.jsx("span",{className:"text-red-400 text-xs",children:x}),!x&&g&&!u&&e.jsx("span",{className:"text-fg-faint text-xs",children:"saved"})]})]})}function Ge(){const[s,a]=d.useState(null),[t,l]=d.useState(null),[n,r]=d.useState("Copy"),[i,p]=d.useState(!1),[m,v]=d.useState(null),[x,w]=d.useState(null),[g,y]=d.useState(null),[u,b]=d.useState(!1),C=()=>{window.api.telemetry.status().then(l).catch(h=>{console.warn("[product-telemetry] status reload failed:",h==null?void 0:h.message)})};if(d.useEffect(()=>{let h=!1;return Promise.all([window.api.telemetry.getConfig(),window.api.telemetry.status()]).then(([c,O])=>{h||(a(c),l(O))}).catch(c=>{console.warn("[product-telemetry] load failed:",c==null?void 0:c.message)}),()=>{h=!0}},[]),!s||!t)return e.jsx(P,{title:"loading…"});const E=async h=>{w(null);try{const c=await window.api.telemetry.setConfig(h);a(c.config),l(c.status)}catch(c){w(c instanceof Error?c.message:String(c))}},f=h=>{E({...s,enabled:h})},k=h=>{E({...s,enabled:h.turnOff?!1:s.enabled,noticeAckedAt:new Date().toISOString()})},S=async()=>{try{await navigator.clipboard.writeText(s.installId),r("Copied"),setTimeout(()=>r("Copy"),1500)}catch{}},o=async()=>{p(!0),v(null);try{const h=await window.api.telemetry.flushNow();v(`sent ${h.sent.length}, failed ${h.failed.length}`),C()}catch(h){v(h instanceof Error?h.message:String(h))}finally{p(!1)}},j=async()=>{if(u){b(!1);return}try{const h=await window.api.telemetry.recentRecords();y(h),b(!0)}catch(h){console.warn("[product-telemetry] recentRecords failed:",h instanceof Error?h.message:h)}},N=s.lastDailyFlushAt?new Date(s.lastDailyFlushAt).getTime()+_e:null;return e.jsxs("div",{className:"space-y-5","data-testid":"product-telemetry-section",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Product telemetry (bilko.run)"}),e.jsxs("p",{className:"text-fg-dim text-xs leading-relaxed",children:["Anonymous, strictly non-identifying usage/error reporting that helps improve this app. On by default; switchable off in one click. See"," ",e.jsx("span",{className:"font-mono",children:"session-manager-operations/architecture/telemetry.md"})," for the full data model."]})]}),!s.noticeAckedAt&&e.jsxs("section",{"data-testid":"telemetry-first-run-notice",className:"border border-accent rounded p-3 space-y-2 text-xs",children:[e.jsx("div",{className:"text-fg font-medium",children:"This app sends anonymous product telemetry"}),e.jsx("p",{className:"text-fg-dim leading-relaxed",children:"Collected: a coarse machine profile (OS/arch/app version, no hardware id), error and warning counts, and session counts — sent on start-up, after an update, and once a day."}),e.jsx("p",{className:"text-fg-dim leading-relaxed",children:"Never collected: prompts, transcripts, file paths, project names, email, or username."}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("button",{onClick:()=>k({turnOff:!1}),className:"px-3 py-1 rounded bg-accent text-bg",children:"OK"}),e.jsx("button",{onClick:()=>k({turnOff:!0}),className:"px-3 py-1 rounded border border-line text-fg-dim hover:text-fg",children:"Turn off"})]})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Send anonymous product telemetry"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Sent on start-up, after an update, and once a day. Strictly anonymous — an install id only, never an email, name, or other identifier."})]}),e.jsx(L,{checked:s.enabled,onChange:f,label:s.enabled?"on":"off"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-fg-dim text-xs",children:"Anonymous install id"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",readOnly:!0,value:s.installId,"aria-label":"Anonymous install identifier",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"}),e.jsx("button",{onClick:S,className:"px-2 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:n})]})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Endpoint"}),e.jsx("div",{className:"font-mono text-fg-dim break-all",children:s.endpoint})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Send cadence"}),e.jsx("div",{className:"text-fg-dim",children:"on start-up, after an update, and once a day"})]}),x&&e.jsx("div",{className:"text-red-400 text-xs",children:x})]}),t.pendingCount>0&&t.sentCount===0&&e.jsxs("section",{"data-testid":"telemetry-never-delivered-warning",className:"border border-red-400 rounded p-3 text-xs space-y-1 text-red-400",children:[e.jsx("div",{className:"font-medium",children:"Never delivered"}),e.jsxs("div",{className:"leading-relaxed",children:[t.pendingCount," record",t.pendingCount===1?"":"s",' queued but none have ever been sent to bilko.run on this install. Check the endpoint/network, or click "Send now" below.']})]}),e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1.5",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"last send:"})," ",U(t.lastFlushAt)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"next daily send due:"})," ",J(N?new Date(N).toISOString():null)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"queued records:"})," ",t.pendingCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"delivered so far:"})," ",t.sentCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"de-duplicated:"})," ",t.dedupedAppends]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"evicted:"})," ",t.evictedCount]}),t.backlog&&e.jsxs("div",{className:"text-fg-faint",children:["last backlog drain (",t.backlog.reason,", ",J(t.backlog.ranAt),"):"," ",t.backlog.linesEnqueued," enqueued, ",t.backlog.linesConfirmed," confirmed,"," ",t.backlog.watermarksRewound," watermarks rewound"]}),t.lastError&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"last error:"})," ",t.lastError.message," ","(",U(t.lastError.at),")"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:o,disabled:i,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:i?"sending…":"Send now"}),m&&e.jsx("span",{className:"text-fg-faint text-xs",children:m})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("button",{onClick:j,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:u?"Hide last records":"Inspect last records sent"}),u&&e.jsx("pre",{"data-testid":"telemetry-inspector-json",className:"bg-bg border border-line rounded p-2 text-[11px] font-mono overflow-auto max-h-96 whitespace-pre-wrap",children:JSON.stringify(g??[],null,2)})]})]})}const He={compact:"Compact",roomy:"Roomy"};function Be(){const{model:s,setModel:a}=ee(),{catalog:t}=te(null),{density:l,setDensity:n}=se();return e.jsxs("div",{className:"p-4 max-w-3xl space-y-5 text-sm",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Session Manager preferences"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"Native app preferences, stored locally — not part of Claude Code's own settings."})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Default model for raw sessions"}),e.jsx($,{options:ae(t),value:s,onChange:a,mono:!0}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Used when opening a raw interactive session without an explicit per-launch override."})]}),e.jsxs("div",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Density"}),e.jsx($,{options:["compact","roomy"],value:l,onChange:r=>n(r),labels:He}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Compact tightens spacing across the app's chrome; Roomy is the default."})]})]})]})}function Je({cwd:s}){const[a,t]=d.useState(!1),[l,n]=d.useState(!1),[r,i]=d.useState(!1),[p,m]=d.useState(!1);d.useEffect(()=>{var y,u;let g=!1;return t(!1),Promise.resolve((u=(y=window.api.promptSessions)==null?void 0:y.getWorktreeDisabled)==null?void 0:u.call(y,{cwd:s})).then(b=>{g||(n((b==null?void 0:b.disabled)??!1),i((b==null?void 0:b.disabled)??!1),t(!0))},()=>{g||t(!0)}),()=>{g=!0}},[s]);const v=a&&r!==l,x=()=>{var g,y;m(!0),Promise.resolve((y=(g=window.api.promptSessions)==null?void 0:g.setWorktreeDisabled)==null?void 0:y.call(g,{cwd:s,disabled:r})).then(u=>{n((u==null?void 0:u.disabled)??r),i((u==null?void 0:u.disabled)??r)}).catch(u=>ne.error(u instanceof Error?u.message:String(u))).finally(()=>m(!1))},w=()=>i(l);return e.jsxs("div",{"data-testid":"settings-epic-isolation",className:"border-b border-line bg-bg-elev px-3 py-2.5 text-[11.5px] leading-snug",children:[e.jsxs("label",{className:"flex items-start gap-2",children:[e.jsx("input",{type:"checkbox",checked:r,disabled:!a||p,onChange:g=>i(g.target.checked),"data-testid":"settings-epic-isolation-checkbox",className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-fg",children:"Disable Epic worktree isolation for this project"}),e.jsxs("span",{className:"block text-fg-dim",children:["Off by default — each active Epic runs in its own isolated ",e.jsx("code",{children:"git worktree"})," (branch"," ",e.jsx("code",{children:"sm-epic/<id>"}),"), merged back to main at an explicit checkpoint. Turning this on makes every new Epic in this project run directly in the shared working tree instead, same as before this feature existed."]})]})]}),v&&e.jsx(q,{dirty:v,busy:p,onSave:x,onRevert:w})]})}const K={user:{title:"Global settings",body:"This is the real ~/.claude/settings.json on disk — the same file the claude CLI reads on every session it starts. Edits apply machine-wide, to every project and every session."},project:{title:"Project settings",body:"This is the real <project>/.claude/settings.json on disk, checked into git. Edits apply to every current and future session in this project, for anyone who clones it."},local:{title:"Local settings",body:"This is the real <project>/.claude/settings.local.json on disk, gitignored. Edits apply to every current and future session in this project, on this machine only."}};function Ue(){const s=re(),a=G(c=>c.tabs),t=G(c=>c.activeTabId),l=a.find(c=>c.id===t)??null,n=(l==null?void 0:l.cwd)??null,r=le(c=>c.navFace),i=d.useRef(!1),p=d.useRef(r),[m,v]=d.useState(()=>r==="project"&&n?"project":"user"),[x,w]=d.useState("effective");d.useEffect(()=>{if(p.current!==r){if(p.current=r,i.current){i.current=!1;return}v(r==="project"&&n?"project":"user")}},[r,n]),d.useEffect(()=>{r==="project"&&(x==="telemetry"||x==="app")&&w("effective")},[r,x]);const g=c=>{i.current=!0,v(c)},y=me(H,s,n),u=y[m]??null,b=D(c=>c.files),C=D(c=>c.setDraft),E=D(c=>c.saveJson),f=D(c=>c.revert),[k,S]=d.useState(null),o=d.useMemo(()=>ie(oe(b,y)),[b,y]),j=(c,O,A)=>{var F;const M=y[A??m];if(!M)return;S(null);const _=((F=b[M])==null?void 0:F.draftRaw)??"";let I={};if(_.trim())try{I=JSON.parse(_)}catch{I={}}const X=xe(I,c,O);C(M,JSON.stringify(X,null,2)+`
3
- `)};if(!s)return e.jsx(P,{title:"loading…"});const N=u?b[u]:null,h=c=>c!=="user"&&!n;return e.jsx(ce,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(ue,{options:[{key:"effective",label:"Guided"},{key:"tree",label:"Tree"},{key:"raw",label:"Raw"},...r==="home"?[{key:"telemetry",label:"Telemetry"},{key:"app",label:"Session Manager"}]:[]],active:x,onChange:w}),x!=="telemetry"&&x!=="app"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(pe,{scopes:H.scopes,active:m,onChange:g,annotate:c=>{if(h(c))return{exists:!1};const O=y[c];if(!O)return null;const A=b[O];return{exists:(A==null?void 0:A.exists)??!1,dirty:(A==null?void 0:A.dirty)??!1}}}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:x==="effective"?`overrides → ${u??"—"}`:u??"—"})]}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/settings",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"schema reference ↗"})]}),footer:x!=="telemetry"&&x!=="app"&&u&&N?e.jsx(q,{dirty:N.dirty,busy:N.busy,parseError:k||N.parseError,lastSavedAt:N.lastSavedAt,leading:N.exists?null:e.jsx("span",{children:"file will be created on save"}),onSave:async()=>{S(null);const c=await E(u);c.ok||S(c.error??"save failed")},onRevert:()=>{S(null),f(u)}}):null,children:x==="telemetry"?e.jsx(Fe,{}):x==="app"?e.jsx(Be,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"settings-scope-note",className:"sticky top-0 z-10 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:K[m].title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:K[m].body}),u&&e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:u})]}),m==="project"&&n&&e.jsx(Je,{cwd:n}),h(m)?e.jsx(P,{title:"no active project",hint:"open a tab in a project directory to edit project or local settings"}):x==="effective"?e.jsx(we,{node:o,targetScope:m,onOverride:j,schema:B()}):x==="tree"?e.jsx(fe,{node:o,targetScope:m,onOverride:j,schema:B()}):u&&N?e.jsx(de,{path:u,value:N.draftRaw,onChange:c=>{S(null),C(u,c)}}):e.jsx(P,{title:"resolving…"})]})})}const Xe=d.memo(Ue);export{K as SETTINGS_SCOPE_NOTES,Xe as Settings};
@@ -1,235 +0,0 @@
1
- /**
2
- * activeIndexMerge.test.cjs — unit tests for the main-process read-merge-write
3
- * of a cwd's prompt-sessions/active-index.json (lib/activeIndexMerge.cjs),
4
- * moved here from the renderer (state/promptSessions.ts's old
5
- * persistActiveIndex, commit 3d12e19) so the merge runs inside the same
6
- * withPathLock instance epicMint.cjs's ensureEpic already serializes through.
7
- *
8
- * Covers the two holes a purely-renderer merge left open:
9
- * - resurrection: a tombstoned id must never be written back by a later
10
- * merge call whose memory contribution still thinks it's open.
11
- * - TOCTOU: a mint (ensureEpic) interleaved with a merge call must survive,
12
- * since both now go through the same lock.
13
- *
14
- * Run: timeout 300 npx vitest run src/main/__tests__/activeIndexMerge.test.cjs
15
- */
16
-
17
- 'use strict';
18
-
19
- import { test, expect, afterEach } from 'vitest';
20
- const fsp = require('node:fs/promises');
21
- const os = require('node:os');
22
- const path = require('node:path');
23
- const { mergeActiveIndex } = require('../lib/activeIndexMerge.cjs');
24
- const { ensureEpic, readActiveIndex, MINT_AUTHORITY_NEW_EPIC_UI } = require('../lib/epicMint.cjs');
25
- const { appendResponseEventIfKnown } = require('../promptSessionEvents.cjs');
26
- const config = require('../config.cjs');
27
-
28
- const tmpDirs = [];
29
- afterEach(async () => {
30
- while (tmpDirs.length) {
31
- const d = tmpDirs.pop();
32
- await fsp.rm(d, { recursive: true, force: true });
33
- }
34
- });
35
-
36
- async function mkCwd() {
37
- const cwd = await fsp.mkdtemp(path.join(os.tmpdir(), 'sm-activeindexmerge-cwd-'));
38
- // config.cjs's readJson/writeJson restrict to registered roots (home dir by
39
- // default) — register this tmp dir so the merge's config.readJson/writeJson
40
- // calls don't reject it as outside the allowed boundary.
41
- config.addAllowedRoot(cwd);
42
- tmpDirs.push(cwd);
43
- return cwd;
44
- }
45
-
46
- function session(id, overrides = {}) {
47
- return {
48
- id,
49
- cwd: overrides.cwd || '/proj',
50
- goalText: overrides.goalText || `goal for ${id}`,
51
- claudeSessionId: overrides.claudeSessionId || `claude-${id}`,
52
- status: overrides.status || 'active',
53
- createdAt: overrides.createdAt || '2026-08-02T13:48:00.000Z',
54
- completedAt: overrides.completedAt ?? null,
55
- };
56
- }
57
-
58
- function promptEvent(id, promptSessionId, at) {
59
- return { id, promptSessionId, kind: 'prompt', causedByEventId: null, at, text: 'x' };
60
- }
61
-
62
- // Incident 2026-08-02: two Epics created by another (already-running) window
63
- // sat on disk. A second window booted empty and, on its first mutation,
64
- // persisted its own (empty-of-those-two) contribution straight over the file.
65
- // The main-side merge must still preserve every pre-existing on-disk Epic.
66
- test('a fresh caller contributing one Epic preserves pre-existing on-disk Epics untouched', async () => {
67
- const cwd = await mkCwd();
68
- const other = session('psess-other');
69
- await mergeActiveIndex(cwd, {
70
- sessions: { [other.id]: other },
71
- events: { [other.id]: [promptEvent('evt-1', other.id, other.createdAt)] },
72
- });
73
-
74
- const fresh = session('psess-fresh', { createdAt: '2026-08-02T13:50:00.000Z' });
75
- await mergeActiveIndex(cwd, {
76
- sessions: { [fresh.id]: fresh },
77
- events: { [fresh.id]: [promptEvent('evt-2', fresh.id, fresh.createdAt)] },
78
- });
79
-
80
- const index = readActiveIndex(cwd);
81
- expect(index.sessions[other.id]).toEqual(other);
82
- expect(index.sessions[fresh.id]).toEqual(fresh);
83
- expect(index.events[other.id]).toHaveLength(1);
84
- });
85
-
86
- test('memory wins over disk on id collision', async () => {
87
- const cwd = await mkCwd();
88
- const original = session('psess-1', { goalText: 'Fresh title' });
89
- await mergeActiveIndex(cwd, { sessions: { [original.id]: original }, events: {} });
90
-
91
- const updated = { ...original, goalText: 'Updated title' };
92
- await mergeActiveIndex(cwd, { sessions: { [updated.id]: updated }, events: {} });
93
-
94
- const index = readActiveIndex(cwd);
95
- expect(index.sessions[original.id].goalText).toBe('Updated title');
96
- });
97
-
98
- test('removedIds drops the row from the merged write and records a removal tombstone', async () => {
99
- const cwd = await mkCwd();
100
- const s = session('psess-1');
101
- await mergeActiveIndex(cwd, { sessions: { [s.id]: s }, events: {} });
102
-
103
- await mergeActiveIndex(cwd, { sessions: {}, events: {}, removedIds: [s.id] });
104
-
105
- const index = readActiveIndex(cwd);
106
- expect(index.sessions[s.id]).toBeUndefined();
107
- expect(index.tombstones[s.id]).toBeTruthy();
108
- });
109
-
110
- // The resurrection hole this PRD closes: two simulated windows. Window A
111
- // completes (markCompleted) and persists the removal. Window B never
112
- // hydrated that removal — its in-memory snapshot still holds the Epic as
113
- // 'active' — and persists afterward. The tombstone must win: the Epic stays
114
- // gone, not resurrected.
115
- test('regression: a later merge whose memory still holds a removed Epic as active does not resurrect it', async () => {
116
- const cwd = await mkCwd();
117
- const s = session('psess-1', { status: 'active' });
118
- await mergeActiveIndex(cwd, { sessions: { [s.id]: s }, events: { [s.id]: [promptEvent('e1', s.id, s.createdAt)] } });
119
-
120
- // Window A: markCompleted removes it.
121
- await mergeActiveIndex(cwd, { sessions: {}, events: {}, removedIds: [s.id] });
122
- expect(readActiveIndex(cwd).sessions[s.id]).toBeUndefined();
123
-
124
- // Window B: stale in-memory snapshot still has it as 'active', persists
125
- // its own (unrelated) mutation — a resurrection-prone merge.
126
- const windowBOther = session('psess-2', { status: 'proposed' });
127
- await mergeActiveIndex(cwd, {
128
- sessions: { [s.id]: s, [windowBOther.id]: windowBOther },
129
- events: { [s.id]: [promptEvent('e1', s.id, s.createdAt)] },
130
- });
131
-
132
- const index = readActiveIndex(cwd);
133
- expect(index.sessions[s.id]).toBeUndefined();
134
- expect(index.events[s.id]).toBeUndefined();
135
- expect(index.sessions[windowBOther.id]).toEqual(windowBOther);
136
- });
137
-
138
- test('event union: disk-only events are appended and re-sorted chain-aware; memory-only events kept', async () => {
139
- const cwd = await mkCwd();
140
- const s = session('psess-1');
141
- const e1 = promptEvent('e1', s.id, '2026-08-02T13:00:00.000Z');
142
- await mergeActiveIndex(cwd, { sessions: { [s.id]: s }, events: { [s.id]: [e1] } });
143
-
144
- // A scheduler job appended a response event directly to disk between our
145
- // two merge calls (simulated by mutating the file out of band).
146
- const midIndex = readActiveIndex(cwd);
147
- const schedulerEvent = { id: 'e2', promptSessionId: s.id, kind: 'response', causedByEventId: 'e1', at: '2026-08-02T13:05:00.000Z', text: 'done' };
148
- midIndex.events[s.id] = [e1, schedulerEvent];
149
- await config.writeJson(path.join(cwd, 'session-manager-operations', 'prompt-sessions', 'active-index.json'), midIndex, { writer: 'epics' });
150
-
151
- // This caller's memory still only knows about e1 plus its own optimistic
152
- // append e3 (not yet on disk).
153
- const e3 = { id: 'e3', promptSessionId: s.id, kind: 'prd_created', causedByEventId: 'e2', at: '2026-08-02T13:10:00.000Z', prdSlug: 'x' };
154
- await mergeActiveIndex(cwd, { sessions: { [s.id]: s }, events: { [s.id]: [e1, e3] } });
155
-
156
- const finalEvents = readActiveIndex(cwd).events[s.id];
157
- expect(finalEvents.map((e) => e.id)).toEqual(['e1', 'e2', 'e3']);
158
- });
159
-
160
- // Electron's structured-clone IPC transport (unlike JSON.parse) can produce
161
- // an own-enumerable "__proto__" key on a cloned object. A plain-object merge
162
- // target's bracket assignment with that key would re-link its own prototype
163
- // instead of storing a normal entry, silently dropping/corrupting the Epic
164
- // and potentially breaking every later Object.keys/JSON.stringify over it.
165
- test('a "__proto__"-keyed session id merges as an ordinary entry, not a prototype pollution', async () => {
166
- const cwd = await mkCwd();
167
- const polluted = session('__proto__', { goalText: 'polluted' });
168
- // Computed key, not `{ __proto__: polluted }` — the latter is special-cased
169
- // by object-literal syntax to set the prototype rather than create an own
170
- // enumerable "__proto__" property, which wouldn't exercise this hazard.
171
- await mergeActiveIndex(cwd, { sessions: { ['__proto__']: polluted }, events: {} });
172
-
173
- const index = readActiveIndex(cwd);
174
- expect(Object.prototype.hasOwnProperty.call(index.sessions, '__proto__')).toBe(true);
175
- expect(index.sessions.__proto__).toEqual(polluted);
176
- expect(Object.getPrototypeOf({})).toBe(Object.prototype);
177
- });
178
-
179
- test('falls back to writing memory state alone when the disk index is corrupt JSON', async () => {
180
- const cwd = await mkCwd();
181
- const filePath = path.join(cwd, 'session-manager-operations', 'prompt-sessions', 'active-index.json');
182
- await fsp.mkdir(path.dirname(filePath), { recursive: true });
183
- await fsp.writeFile(filePath, '{ not valid json', 'utf8');
184
-
185
- const s = session('psess-1');
186
- await mergeActiveIndex(cwd, { sessions: { [s.id]: s }, events: {} });
187
-
188
- const index = readActiveIndex(cwd);
189
- expect(index.sessions[s.id]).toEqual(s);
190
- });
191
-
192
- // TOCTOU: a mint interleaved with a merge call must survive, since both now
193
- // serialize through the same withPathLock (epicMint.cjs exports it; this
194
- // module requires it via the same module — Node's require cache means one
195
- // lock instance, not two independent maps that could still interleave).
196
- test('mint-during-persist: an ensureEpic mint interleaved with a merge call survives', async () => {
197
- const cwd = await mkCwd();
198
- const existing = session('psess-existing');
199
- await mergeActiveIndex(cwd, { sessions: { [existing.id]: existing }, events: {} });
200
-
201
- const [mintResult] = await Promise.all([
202
- ensureEpic(cwd, { goalText: 'minted during a concurrent merge', mintAuthority: MINT_AUTHORITY_NEW_EPIC_UI }),
203
- mergeActiveIndex(cwd, { sessions: { [existing.id]: existing }, events: {} }),
204
- ]);
205
-
206
- const index = readActiveIndex(cwd);
207
- expect(index.sessions[mintResult.epicId]).toBeDefined();
208
- expect(index.sessions[existing.id]).toBeDefined();
209
- });
210
-
211
- // The third writer: promptSessionEvents.cjs's appendResponseEventIfKnown
212
- // (the scheduler's narrow 'scheduler'-delegation append) used to hold its
213
- // OWN independent lock map — a merge call and a response-event append could
214
- // still race past each other's stale read. It now imports activeIndexPath/
215
- // withPathLock from epicMint.cjs (same module, same require-cache instance),
216
- // so a response-event append interleaved with a merge call must survive too.
217
- test('a scheduler response-event append interleaved with a merge call survives (third writer shares the same lock)', async () => {
218
- const cwd = await mkCwd();
219
- const s = session('psess-1', { status: 'active' });
220
- await mergeActiveIndex(cwd, {
221
- sessions: { [s.id]: s },
222
- events: { [s.id]: [promptEvent('e1', s.id, s.createdAt)] },
223
- });
224
-
225
- const [, appended] = await Promise.all([
226
- mergeActiveIndex(cwd, { sessions: { [s.id]: s }, events: { [s.id]: [promptEvent('e1', s.id, s.createdAt)] } }),
227
- appendResponseEventIfKnown(cwd, s.id, 'PRD finished'),
228
- ]);
229
-
230
- expect(appended).toBe(true);
231
- const index = readActiveIndex(cwd);
232
- expect(index.sessions[s.id]).toBeDefined();
233
- expect(index.events[s.id]).toHaveLength(2);
234
- expect(index.events[s.id][1].kind).toBe('response');
235
- });
@@ -1,117 +0,0 @@
1
- /**
2
- * agentEffortResolve.test.cjs — the effort twin of agentModelResolve.test.cjs:
3
- * persona `effort:` wins (overlay beats global), inherit/absent/dangling → no flag.
4
- *
5
- * Run: timeout 120 npx vitest run src/main/__tests__/agentEffortResolve.test.cjs
6
- */
7
-
8
- 'use strict';
9
-
10
- import { test, expect, afterEach } from 'vitest';
11
- const fs = require('node:fs');
12
- const fsp = require('node:fs/promises');
13
- const os = require('node:os');
14
- const path = require('node:path');
15
- const { resolveEpicEffort, effortArgs } = require('../lib/agentEffortResolve.cjs');
16
-
17
- const tmpDirs = [];
18
- afterEach(async () => {
19
- while (tmpDirs.length) await fsp.rm(tmpDirs.pop(), { recursive: true, force: true });
20
- });
21
-
22
- async function mkTmpDir(prefix) {
23
- const dir = await fsp.mkdtemp(path.join(os.tmpdir(), prefix));
24
- tmpDirs.push(dir);
25
- return dir;
26
- }
27
-
28
- function writeIndex(cwd, sessions) {
29
- const dir = path.join(cwd, 'session-manager-operations', 'prompt-sessions');
30
- fs.mkdirSync(dir, { recursive: true });
31
- fs.writeFileSync(path.join(dir, 'active-index.json'), JSON.stringify({ sessions, events: {} }));
32
- }
33
-
34
- function writePersona(dir, name, frontmatter) {
35
- fs.mkdirSync(dir, { recursive: true });
36
- fs.writeFileSync(path.join(dir, `${name}.md`), ['---', `name: ${name}`, ...frontmatter, '---', 'body'].join('\n'));
37
- }
38
-
39
- const noopValidatePath = (p) => p;
40
-
41
- test('persona effort wins (global) for a matching Epic', async () => {
42
- const cwd = await mkTmpDir('sm-effort-cwd-');
43
- const globalDir = await mkTmpDir('sm-effort-agents-');
44
- writeIndex(cwd, { e1: { id: 'e1', claudeSessionId: 's1', agentType: 'p' } });
45
- writePersona(globalDir, 'p', ['effort: high']);
46
- expect(resolveEpicEffort({ cwd, claudeSessionId: 's1', deps: { globalDir, validatePath: noopValidatePath } }))
47
- .toEqual({ effort: 'high', source: 'persona' });
48
- });
49
-
50
- test('project overlay beats global', async () => {
51
- const cwd = await mkTmpDir('sm-effort-cwd-');
52
- const globalDir = await mkTmpDir('sm-effort-agents-');
53
- const projectDir = await mkTmpDir('sm-effort-proj-');
54
- writePersona(globalDir, 'p', ['effort: low']);
55
- writePersona(projectDir, 'p', ['effort: max']);
56
- expect(resolveEpicEffort({ cwd, agentType: 'p', deps: { globalDir, projectDir, validatePath: noopValidatePath } }))
57
- .toEqual({ effort: 'max', source: 'persona-overlay' });
58
- });
59
-
60
- test('inherit and absent resolve to null effort', async () => {
61
- const cwd = await mkTmpDir('sm-effort-cwd-');
62
- const globalDir = await mkTmpDir('sm-effort-agents-');
63
- writePersona(globalDir, 'inh', ['effort: inherit']);
64
- writePersona(globalDir, 'none', []);
65
- const deps = { globalDir, validatePath: noopValidatePath };
66
- expect(resolveEpicEffort({ cwd, agentType: 'inh', deps })).toEqual({ effort: null, source: 'inherit' });
67
- expect(resolveEpicEffort({ cwd, agentType: 'none', deps })).toEqual({ effort: null, source: 'inherit' });
68
- });
69
-
70
- test('a persona effort of `auto` (a /effort reset verb) resolves to no flag', async () => {
71
- const cwd = await mkTmpDir('sm-effort-cwd-');
72
- const globalDir = await mkTmpDir('sm-effort-agents-');
73
- writePersona(globalDir, 'au', ['effort: auto']);
74
- const deps = { globalDir, validatePath: noopValidatePath };
75
- const r = resolveEpicEffort({ cwd, agentType: 'au', deps });
76
- expect(r.effort).toBeNull();
77
- expect(effortArgs(r.effort)).toEqual([]);
78
- });
79
-
80
- test('dangling agentType / unknown Epic / empty opts resolve to null without throwing', async () => {
81
- const cwd = await mkTmpDir('sm-effort-cwd-');
82
- const globalDir = await mkTmpDir('sm-effort-agents-');
83
- writeIndex(cwd, {});
84
- const deps = { globalDir, validatePath: noopValidatePath };
85
- expect(resolveEpicEffort({ cwd, agentType: 'gone', deps })).toEqual({ effort: null, source: null });
86
- expect(resolveEpicEffort({ cwd, claudeSessionId: 'nope', deps })).toEqual({ effort: null, source: null });
87
- expect(resolveEpicEffort({})).toEqual({ effort: null, source: null });
88
- expect(resolveEpicEffort({ cwd, agentType: '../../etc/passwd', deps })).toEqual({ effort: null, source: null });
89
- });
90
-
91
- test('an unknown level is passed through unchanged (CLI warns and degrades)', async () => {
92
- const cwd = await mkTmpDir('sm-effort-cwd-');
93
- const globalDir = await mkTmpDir('sm-effort-agents-');
94
- writePersona(globalDir, 'odd', ['effort: turbo']);
95
- expect(resolveEpicEffort({ cwd, agentType: 'odd', deps: { globalDir, validatePath: noopValidatePath } }).effort).toBe('turbo');
96
- });
97
-
98
- test('effortArgs emits the pair only for a real level', () => {
99
- expect(effortArgs('high')).toEqual(['--effort', 'high']);
100
- for (const v of [null, undefined, '', 'inherit']) expect(effortArgs(v)).toEqual([]);
101
- });
102
-
103
- // Epic-level override (New Session card) > persona frontmatter > no flag.
104
- test('an Epic-level effort override beats the persona effort; an Epic without the field resolves unchanged', async () => {
105
- const cwd = await mkTmpDir('sm-effort-ovr-cwd-');
106
- const globalDir = await mkTmpDir('sm-effort-ovr-agents-');
107
- writeIndex(cwd, {
108
- withOverride: { id: 'withOverride', claudeSessionId: 's-ovr', agentType: 'p', effort: 'max' },
109
- legacy: { id: 'legacy', claudeSessionId: 's-old', agentType: 'p' },
110
- noPersona: { id: 'noPersona', claudeSessionId: 's-np', effort: 'low' },
111
- });
112
- writePersona(globalDir, 'p', ['effort: low']);
113
- const deps = { globalDir, validatePath: noopValidatePath };
114
- expect(resolveEpicEffort({ cwd, claudeSessionId: 's-ovr', deps })).toEqual({ effort: 'max', source: 'epic' });
115
- expect(resolveEpicEffort({ cwd, claudeSessionId: 's-old', deps })).toEqual({ effort: 'low', source: 'persona' });
116
- expect(resolveEpicEffort({ cwd, claudeSessionId: 's-np', deps })).toEqual({ effort: 'low', source: 'epic' });
117
- });