claude-code-session-manager 0.111.0 → 0.113.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 (290) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/dist/assets/{AgentLibrary-rBO1daqM.js → AgentLibrary-wvrcLGGS.js} +2 -2
  3. package/dist/assets/{Button-DsEYRZg0.js → Button-B6h0F0XT.js} +1 -1
  4. package/dist/assets/{DataModel-D8sbvvBC.js → DataModel-C5pW9E3u.js} +1 -1
  5. package/dist/assets/{History-BEHLtxia.js → History-BV4e8YOM.js} +2 -2
  6. package/dist/assets/{Hooks-CKpvlXrg.js → Hooks-CrFSv4x1.js} +3 -3
  7. package/dist/assets/{Library-CeF4qh9d.js → Library-D-GIt3EY.js} +5 -5
  8. package/dist/assets/{ListDetail-DcfmxPFk.js → ListDetail-Bco_wfs6.js} +1 -1
  9. package/dist/assets/{MarkdownEditor-CvK1pyto.js → MarkdownEditor-C-yHSXNV.js} +1 -1
  10. package/dist/assets/{McpServers-D-h2ihzJ.js → McpServers-CfDekadG.js} +2 -2
  11. package/dist/assets/{Memory-BnF89x8v.js → Memory-CGGLexkR.js} +4 -4
  12. package/dist/assets/{Panel-CQY5zano.js → Panel-DGMEuYYG.js} +1 -1
  13. package/dist/assets/{Permissions-DLukmmsz.js → Permissions-Cx2zjtYZ.js} +3 -3
  14. package/dist/assets/{Plugins-0Pf0OZ4l.js → Plugins-Bc_W3IyR.js} +2 -2
  15. package/dist/assets/ProvenanceBadge-DiKAUR1u.js +1 -0
  16. package/dist/assets/RemoteMachines-8_77-WPD.js +3 -0
  17. package/dist/assets/{SaveBar-DjijiUb0.js → SaveBar-Blpzdq1R.js} +1 -1
  18. package/dist/assets/{Scheduler-Cm3EXZvE.js → Scheduler-Bd70AM4X.js} +9 -9
  19. package/dist/assets/{ScopeSwitcher-B-P-kSfq.js → ScopeSwitcher-wxN0h4YW.js} +1 -1
  20. package/dist/assets/Settings-CQ7DA3zW.js +4 -0
  21. package/dist/assets/{SkillReferenceGraph-Epv2GJmj.js → SkillReferenceGraph-DH1NLOiS.js} +1 -1
  22. package/dist/assets/Skills-CmyRyu4_.js +2 -0
  23. package/dist/assets/SystemPrompt-KAc3UMCd.js +1 -0
  24. package/dist/assets/TagLibrary-C8EvHnpg.js +1 -0
  25. package/dist/assets/{TiptapBody-DAMO3DhO.js → TiptapBody-d423mH6D.js} +1 -1
  26. package/dist/assets/{Toggle-Ba_f7q_m.js → Toggle-D1wsGE9S.js} +1 -1
  27. package/dist/assets/{ViewTabs-CGX6MAhc.js → ViewTabs-CjHw3kGY.js} +1 -1
  28. package/dist/assets/{historyTotals-vgfk8EOL.js → historyTotals-DFHzqLt7.js} +1 -1
  29. package/dist/assets/{index-CPieAFsl.js → index-Ci1u018F.js} +266 -266
  30. package/dist/assets/{settingsSchema-D0FxNrTy.js → settingsSchema-Ctf3pZVI.js} +1 -1
  31. package/dist/assets/{useAgentsDirWatch-DCu6BNYN.js → useAgentsDirWatch-B1NBmOAe.js} +1 -1
  32. package/dist/assets/{useRemotePeers-D4cdJDyh.js → useRemotePeers-BHjSJs9D.js} +1 -1
  33. package/dist/index.html +1 -1
  34. package/package.json +3 -2
  35. package/plugins/CLAUDE.md +5 -8
  36. package/plugins/session-manager-dev/.claude-plugin/plugin.json +3 -6
  37. package/plugins/session-manager-dev/skills/builder/1-classify-and-bump/SKILL.md +2 -2
  38. package/plugins/session-manager-dev/skills/builder/SKILL.md +2 -3
  39. package/plugins/session-manager-dev/skills/develop/SKILL.md +1 -1
  40. package/plugins/session-manager-dev/skills/develop/standards.md +3 -3
  41. package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +13 -0
  42. package/scripts/README.md +3 -3
  43. package/scripts/audit-ops-hygiene.cjs +4 -4
  44. package/scripts/hooks/guard-destructive-git.cjs +4 -4
  45. package/scripts/hooks/guard-inline-implementation.cjs +1 -1
  46. package/scripts/hooks/guard-prd-writes.cjs +2 -2
  47. package/scripts/hooks/lib/guard-destructive-git-policy.cjs +1 -1
  48. package/scripts/mint-epic.cjs +2 -2
  49. package/scripts/scheduler-mcp-server.cjs +27 -9
  50. package/src/main/agentLibrary.cjs +5 -5
  51. package/src/main/agentsIpc.cjs +76 -0
  52. package/src/main/build-info.json +4 -4
  53. package/src/main/chatRunner.cjs +30 -13
  54. package/src/main/config.cjs +20 -3
  55. package/src/main/crashDiagnostics.cjs +2 -2
  56. package/src/main/docEdit.cjs +5 -5
  57. package/src/main/files.cjs +2 -2
  58. package/src/main/git.cjs +1 -1
  59. package/src/main/health.cjs +20 -18
  60. package/src/main/heapSnapshot.cjs +1 -1
  61. package/src/main/historyAggregator.cjs +2 -2
  62. package/src/main/index.cjs +50 -132
  63. package/src/main/ipcSchemas.cjs +13 -10
  64. package/src/main/lib/CLAUDE.md +48 -0
  65. package/src/main/lib/activeSessions.cjs +14 -1
  66. package/src/main/lib/classifyPromptTicket.cjs +2 -2
  67. package/src/main/lib/{agentModelResolve.cjs → claude/agentModelResolve.cjs} +7 -7
  68. package/src/main/lib/{claudeBin.cjs → claude/claudeBin.cjs} +4 -4
  69. package/src/main/lib/{effectiveModelInfo.cjs → claude/effectiveModelInfo.cjs} +9 -9
  70. package/src/main/lib/{modelCatalog.cjs → claude/modelCatalog.cjs} +3 -3
  71. package/src/main/lib/claude/rateLimitDetect.cjs +54 -0
  72. package/src/main/lib/{rateLimitWindow.cjs → claude/rateLimitWindow.cjs} +24 -12
  73. package/src/main/lib/{runClaudeP.cjs → claude/runClaudeP.cjs} +1 -1
  74. package/src/main/lib/credentials.cjs +18 -92
  75. package/src/main/lib/cwdClassify.cjs +1 -1
  76. package/src/main/lib/{activeIndexMerge.cjs → epic/activeIndexMerge.cjs} +3 -3
  77. package/src/main/lib/{activeIndexRebuild.cjs → epic/activeIndexRebuild.cjs} +1 -1
  78. package/src/main/lib/{delegationReadiness.cjs → epic/delegationReadiness.cjs} +21 -29
  79. package/src/main/lib/{epicContextDigest.cjs → epic/epicContextDigest.cjs} +1 -1
  80. package/src/main/lib/{epicDelegationStats.cjs → epic/epicDelegationStats.cjs} +2 -2
  81. package/src/main/lib/{epicMint.cjs → epic/epicMint.cjs} +11 -11
  82. package/src/main/lib/{epicSpawnPlan.cjs → epic/epicSpawnPlan.cjs} +3 -3
  83. package/src/main/lib/{epicStatusMirror.cjs → epic/epicStatusMirror.cjs} +2 -2
  84. package/src/main/lib/{epicTranscriptDiagnostic.cjs → epic/epicTranscriptDiagnostic.cjs} +2 -2
  85. package/src/main/lib/{epicTranscriptPath.cjs → epic/epicTranscriptPath.cjs} +2 -2
  86. package/src/main/lib/{epicValidationHook.cjs → epic/epicValidationHook.cjs} +3 -3
  87. package/src/main/lib/{epicWorktreeBoot.cjs → epic/epicWorktreeBoot.cjs} +1 -1
  88. package/src/main/lib/{epicWorktreeMerge.cjs → epic/epicWorktreeMerge.cjs} +3 -3
  89. package/src/main/lib/{epicWorktreeMint.cjs → epic/epicWorktreeMint.cjs} +3 -3
  90. package/src/main/lib/{epicWorktreeProjectConfig.cjs → epic/epicWorktreeProjectConfig.cjs} +4 -4
  91. package/src/main/lib/{promptSessionsCreateEpic.cjs → epic/promptSessionsCreateEpic.cjs} +4 -4
  92. package/src/main/lib/{crossProjectFeedback.cjs → feedback-remote/crossProjectFeedback.cjs} +114 -16
  93. package/src/main/lib/{customerFeedbackClient.cjs → feedback-remote/customerFeedbackClient.cjs} +3 -3
  94. package/src/main/lib/{customerFeedbackInbox.cjs → feedback-remote/customerFeedbackInbox.cjs} +2 -2
  95. package/src/main/lib/{customerFeedbackIpc.cjs → feedback-remote/customerFeedbackIpc.cjs} +1 -1
  96. package/src/main/lib/feedback-remote/humanPromptLedger.cjs +93 -0
  97. package/src/main/lib/{localAdminHttp.cjs → feedback-remote/localAdminHttp.cjs} +2 -2
  98. package/src/main/lib/{macroAdminRoutes.cjs → feedback-remote/macroAdminRoutes.cjs} +1 -1
  99. package/src/main/lib/{projectHomeAdminRoutes.cjs → feedback-remote/projectHomeAdminRoutes.cjs} +4 -4
  100. package/src/main/lib/{relayClientAuth.cjs → feedback-remote/relayClientAuth.cjs} +2 -2
  101. package/src/main/lib/{remoteClientSessions.cjs → feedback-remote/remoteClientSessions.cjs} +1 -1
  102. package/src/main/lib/{gitWorktree.cjs → git/gitWorktree.cjs} +7 -7
  103. package/src/main/lib/historyRollup.cjs +1 -1
  104. package/src/main/lib/importReferences.cjs +1 -1
  105. package/src/main/lib/machineProfile.cjs +1 -1
  106. package/src/main/lib/mcpToolCatalog.cjs +9 -3
  107. package/src/main/lib/openExternalApp.cjs +1 -1
  108. package/src/main/lib/opsOwnership.cjs +3 -3
  109. package/src/main/lib/{agentPersonaSchema.cjs → persona-macro/agentPersonaSchema.cjs} +2 -2
  110. package/src/main/lib/{macroLibrary.cjs → persona-macro/macroLibrary.cjs} +5 -5
  111. package/src/main/lib/{personaMerge.cjs → persona-macro/personaMerge.cjs} +4 -4
  112. package/src/main/lib/{depSlugResolve.cjs → prd/depSlugResolve.cjs} +16 -1
  113. package/src/main/lib/{prdAdminRoutes.cjs → prd/prdAdminRoutes.cjs} +7 -7
  114. package/src/main/lib/{prdAgentType.cjs → prd/prdAgentType.cjs} +3 -3
  115. package/src/main/lib/{prdCreate.cjs → prd/prdCreate.cjs} +12 -12
  116. package/src/main/lib/{prdDeclaredPaths.cjs → prd/prdDeclaredPaths.cjs} +1 -1
  117. package/src/main/lib/{prdGateFiles.cjs → prd/prdGateFiles.cjs} +1 -1
  118. package/src/main/lib/{prdLocations.cjs → prd/prdLocations.cjs} +2 -2
  119. package/src/main/lib/{prdMigration.cjs → prd/prdMigration.cjs} +3 -3
  120. package/src/main/lib/prereqs.cjs +2 -2
  121. package/src/main/lib/{instanceLock.cjs → process/instanceLock.cjs} +4 -11
  122. package/src/main/lib/{pidAlive.cjs → process/pidAlive.cjs} +1 -1
  123. package/src/main/lib/{procName.cjs → process/procName.cjs} +2 -2
  124. package/src/main/lib/{timeoutShim.cjs → process/timeoutShim.cjs} +1 -1
  125. package/src/main/lib/projectRootResolve.cjs +1 -1
  126. package/src/main/lib/promptSessionSchema.cjs +1 -1
  127. package/src/main/lib/{definitionOfDone.cjs → scheduler/definitionOfDone.cjs} +6 -12
  128. package/src/main/lib/scheduler/finalizeReason.cjs +30 -0
  129. package/src/main/lib/{fixChainDepth.cjs → scheduler/fixChainDepth.cjs} +1 -1
  130. package/src/main/lib/scheduler/flatSweepThrottle.cjs +17 -0
  131. package/src/main/lib/{jobDirtFilter.cjs → scheduler/jobDirtFilter.cjs} +1 -1
  132. package/src/main/lib/{jobSupervisorRecord.cjs → scheduler/jobSupervisorRecord.cjs} +1 -1
  133. package/src/main/lib/{launchFailure.cjs → scheduler/launchFailure.cjs} +2 -2
  134. package/src/main/lib/{queueStore.cjs → scheduler/queueStore.cjs} +6 -6
  135. package/src/main/lib/{quietMachineLease.cjs → scheduler/quietMachineLease.cjs} +1 -1
  136. package/src/main/lib/{rcaReport.cjs → scheduler/rcaReport.cjs} +4 -4
  137. package/src/main/lib/{reaperHelpers.cjs → scheduler/reaperHelpers.cjs} +3 -3
  138. package/src/main/lib/{reservationExpiry.cjs → scheduler/reservationExpiry.cjs} +4 -11
  139. package/src/main/lib/{reviewNotice.cjs → scheduler/reviewNotice.cjs} +1 -1
  140. package/src/main/lib/{runLogRetention.cjs → scheduler/runLogRetention.cjs} +34 -13
  141. package/src/main/lib/{scheduleJobTransitions.cjs → scheduler/scheduleJobTransitions.cjs} +3 -3
  142. package/src/main/lib/{schedulerBatch.cjs → scheduler/schedulerBatch.cjs} +9 -13
  143. package/src/main/lib/{schedulerConfig.cjs → scheduler/schedulerConfig.cjs} +1 -1
  144. package/src/main/lib/{schedulerRuntimeState.cjs → scheduler/schedulerRuntimeState.cjs} +1 -1
  145. package/src/main/lib/{sessionSlots.cjs → scheduler/sessionSlots.cjs} +2 -2
  146. package/src/main/lib/{upgradeDrain.cjs → scheduler/upgradeDrain.cjs} +8 -11
  147. package/src/main/lib/{watchdogHelpers.cjs → scheduler/watchdogHelpers.cjs} +5 -19
  148. package/src/main/lib/{auditLog.cjs → telemetry/auditLog.cjs} +1 -1
  149. package/src/main/lib/{opsErrorLog.cjs → telemetry/opsErrorLog.cjs} +4 -4
  150. package/src/main/lib/{telemetryBacklog.cjs → telemetry/telemetryBacklog.cjs} +4 -4
  151. package/src/main/lib/{telemetryBoot.cjs → telemetry/telemetryBoot.cjs} +1 -1
  152. package/src/main/lib/{telemetryClient.cjs → telemetry/telemetryClient.cjs} +12 -8
  153. package/src/main/lib/{telemetrySettings.cjs → telemetry/telemetrySettings.cjs} +1 -1
  154. package/src/main/lib/{atomicFs.cjs → util/atomicFs.cjs} +42 -0
  155. package/src/main/lib/{loopDelay.cjs → util/loopDelay.cjs} +1 -1
  156. package/src/main/logs.cjs +1 -1
  157. package/src/main/mcpStatus.cjs +2 -2
  158. package/src/main/memoryAggregate.cjs +3 -3
  159. package/src/main/memoryTool.cjs +1 -1
  160. package/src/main/otel.cjs +2 -2
  161. package/src/main/pluginInstall.cjs +29 -3
  162. package/src/main/projectBrief.cjs +6 -6
  163. package/src/main/projectPages.cjs +1 -1
  164. package/src/main/promptSessionEvents.cjs +2 -2
  165. package/src/main/pty.cjs +7 -7
  166. package/src/main/queueOps.cjs +6 -6
  167. package/src/main/remoteClient.cjs +4 -4
  168. package/src/main/remoteClientIpc.cjs +1 -1
  169. package/src/main/runVerify.cjs +6 -3
  170. package/src/main/scheduler/CLAUDE.md +26 -0
  171. package/src/main/scheduler/budget.cjs +576 -0
  172. package/src/main/scheduler/gitTreeGuard.cjs +672 -0
  173. package/src/main/scheduler/prdParser.cjs +4 -4
  174. package/src/main/scheduler/prdPaths.cjs +487 -0
  175. package/src/main/scheduler/reviewLadder.cjs +1011 -0
  176. package/src/main/scheduler/starvation.cjs +390 -0
  177. package/src/main/scheduler.cjs +331 -3320
  178. package/src/main/seedAgentPersonas.cjs +5 -5
  179. package/src/main/seedDevPlugin.cjs +70 -3
  180. package/src/main/seedSchedulerMcp.cjs +2 -2
  181. package/src/main/supervisor.cjs +50 -27
  182. package/src/main/telemetryIpc.cjs +51 -0
  183. package/src/main/transcripts.cjs +3 -3
  184. package/src/main/updaterIpc.cjs +1 -1
  185. package/src/main/usage.cjs +1 -1
  186. package/src/main/watchers.cjs +1 -1
  187. package/src/main/webRemote.cjs +22 -7
  188. package/src/preload/api.d.ts +14 -8
  189. package/src/preload/index.cjs +9 -3
  190. package/dist/assets/ProvenanceBadge-vC7Tj-JP.js +0 -1
  191. package/dist/assets/RemoteMachines-CWnKbFHc.js +0 -3
  192. package/dist/assets/Settings-DYDlp2m_.js +0 -4
  193. package/dist/assets/Skills-DHO0N0C2.js +0 -2
  194. package/dist/assets/SystemPrompt-DxeNofL9.js +0 -1
  195. package/dist/assets/TagLibrary-QOAs7ISO.js +0 -1
  196. package/plugins/session-manager-dev/skills/blog-for-project-feature/0-select/SKILL.md +0 -39
  197. package/plugins/session-manager-dev/skills/blog-for-project-feature/1-research/SKILL.md +0 -37
  198. package/plugins/session-manager-dev/skills/blog-for-project-feature/2-storyboard/SKILL.md +0 -64
  199. package/plugins/session-manager-dev/skills/blog-for-project-feature/3-capture/SKILL.md +0 -52
  200. package/plugins/session-manager-dev/skills/blog-for-project-feature/4-draft-copy/SKILL.md +0 -37
  201. package/plugins/session-manager-dev/skills/blog-for-project-feature/5-illustrate/SKILL.md +0 -50
  202. package/plugins/session-manager-dev/skills/blog-for-project-feature/6-compose/SKILL.md +0 -51
  203. package/plugins/session-manager-dev/skills/blog-for-project-feature/7-review/SKILL.md +0 -54
  204. package/plugins/session-manager-dev/skills/blog-for-project-feature/SKILL.md +0 -144
  205. package/plugins/session-manager-dev/skills/blog-for-project-feature/feature.config.yaml +0 -90
  206. package/plugins/session-manager-dev/skills/discover-features/SKILL.md +0 -95
  207. package/plugins/session-manager-dev/skills/explain-to-me/SKILL.md +0 -205
  208. package/plugins/session-manager-dev/skills/explain-to-me/assets/style-reference.html +0 -163
  209. package/plugins/session-manager-dev/skills/find-opportunity/SKILL.md +0 -83
  210. package/plugins/session-manager-dev/skills/issue-address/0-select/0-fetch-pool/SKILL.md +0 -38
  211. package/plugins/session-manager-dev/skills/issue-address/0-select/1-reject-fixed/SKILL.md +0 -64
  212. package/plugins/session-manager-dev/skills/issue-address/0-select/2-reject-claimed/SKILL.md +0 -71
  213. package/plugins/session-manager-dev/skills/issue-address/0-select/3-rank-impact/SKILL.md +0 -39
  214. package/plugins/session-manager-dev/skills/issue-address/0-select/SKILL.md +0 -75
  215. package/plugins/session-manager-dev/skills/issue-address/1-confirm-open/SKILL.md +0 -39
  216. package/plugins/session-manager-dev/skills/issue-address/2-claim/SKILL.md +0 -57
  217. package/plugins/session-manager-dev/skills/issue-address/3-reproduce/SKILL.md +0 -40
  218. package/plugins/session-manager-dev/skills/issue-address/4-fix/SKILL.md +0 -33
  219. package/plugins/session-manager-dev/skills/issue-address/5-verify/SKILL.md +0 -40
  220. package/plugins/session-manager-dev/skills/issue-address/SKILL.md +0 -120
  221. package/plugins/session-manager-dev/skills/local-project-health/SKILL.md +0 -58
  222. package/plugins/session-manager-dev/skills/memory-sanitation/SKILL.md +0 -147
  223. package/plugins/session-manager-dev/skills/ops-sweep/SKILL.md +0 -137
  224. package/plugins/session-manager-dev/skills/pr-review-sweep/0-fetch/SKILL.md +0 -41
  225. package/plugins/session-manager-dev/skills/pr-review-sweep/1-classify/SKILL.md +0 -56
  226. package/plugins/session-manager-dev/skills/pr-review-sweep/2-check-fixed/SKILL.md +0 -49
  227. package/plugins/session-manager-dev/skills/pr-review-sweep/3-queue/SKILL.md +0 -57
  228. package/plugins/session-manager-dev/skills/pr-review-sweep/4-land-and-resolve/SKILL.md +0 -60
  229. package/plugins/session-manager-dev/skills/pr-review-sweep/SKILL.md +0 -124
  230. package/plugins/session-manager-dev/skills/pr-signal/SKILL.md +0 -67
  231. package/plugins/session-manager-dev/skills/project-status/SKILL.md +0 -243
  232. package/plugins/session-manager-dev/skills/requesting-code-review/SKILL.md +0 -98
  233. package/plugins/session-manager-dev/skills/requesting-code-review/code-reviewer.md +0 -146
  234. package/src/main/lib/rateLimitDetect.cjs +0 -35
  235. /package/src/main/lib/{agentEffortResolve.cjs → claude/agentEffortResolve.cjs} +0 -0
  236. /package/src/main/lib/{claudeCliCaps.cjs → claude/claudeCliCaps.cjs} +0 -0
  237. /package/src/main/lib/{usageCircuit.cjs → claude/usageCircuit.cjs} +0 -0
  238. /package/src/main/lib/{epicSpawnCwd.cjs → epic/epicSpawnCwd.cjs} +0 -0
  239. /package/src/main/lib/{customerFeedbackAdminRoutes.cjs → feedback-remote/customerFeedbackAdminRoutes.cjs} +0 -0
  240. /package/src/main/lib/{remoteE2eCrypto.cjs → feedback-remote/remoteE2eCrypto.cjs} +0 -0
  241. /package/src/main/lib/{branchSweep.cjs → git/branchSweep.cjs} +0 -0
  242. /package/src/main/lib/{gitExec.cjs → git/gitExec.cjs} +0 -0
  243. /package/src/main/lib/{jobWorktree.cjs → git/jobWorktree.cjs} +0 -0
  244. /package/src/main/lib/{jobWorktreeBootLive.cjs → git/jobWorktreeBootLive.cjs} +0 -0
  245. /package/src/main/lib/{jobWorktreeTerminalOrphanLive.cjs → git/jobWorktreeTerminalOrphanLive.cjs} +0 -0
  246. /package/src/main/lib/{builtinMacros.cjs → persona-macro/builtinMacros.cjs} +0 -0
  247. /package/src/main/lib/{personaImportHealth.cjs → persona-macro/personaImportHealth.cjs} +0 -0
  248. /package/src/main/lib/{shippedPersonaSeeds.cjs → persona-macro/shippedPersonaSeeds.cjs} +0 -0
  249. /package/src/main/lib/{planValidator.cjs → prd/planValidator.cjs} +0 -0
  250. /package/src/main/lib/{prdAuthoringSeed.cjs → prd/prdAuthoringSeed.cjs} +0 -0
  251. /package/src/main/lib/{prdDisposition.cjs → prd/prdDisposition.cjs} +0 -0
  252. /package/src/main/lib/{prdFrontmatter.cjs → prd/prdFrontmatter.cjs} +0 -0
  253. /package/src/main/lib/{prdSizing.cjs → prd/prdSizing.cjs} +0 -0
  254. /package/src/main/lib/{workTypeLibrary.cjs → prd/workTypeLibrary.cjs} +0 -0
  255. /package/src/main/lib/{childWithLog.cjs → process/childWithLog.cjs} +0 -0
  256. /package/src/main/lib/{cleanEnv.cjs → process/cleanEnv.cjs} +0 -0
  257. /package/src/main/lib/{defaultShell.cjs → process/defaultShell.cjs} +0 -0
  258. /package/src/main/lib/{killTree.cjs → process/killTree.cjs} +0 -0
  259. /package/src/main/lib/{loginShellPath.cjs → process/loginShellPath.cjs} +0 -0
  260. /package/src/main/lib/{procIdentity.cjs → process/procIdentity.cjs} +0 -0
  261. /package/src/main/lib/{singleInstanceGuard.cjs → process/singleInstanceGuard.cjs} +0 -0
  262. /package/src/main/lib/{smProcNames.cjs → process/smProcNames.cjs} +0 -0
  263. /package/src/main/lib/{timeoutShimScript.cjs → process/timeoutShimScript.cjs} +0 -0
  264. /package/src/main/lib/{winSpawn.cjs → process/winSpawn.cjs} +0 -0
  265. /package/src/main/lib/{adoptedRunSupervisor.cjs → scheduler/adoptedRunSupervisor.cjs} +0 -0
  266. /package/src/main/lib/{dispatchLoop.cjs → scheduler/dispatchLoop.cjs} +0 -0
  267. /package/src/main/lib/{dodDrainHook.cjs → scheduler/dodDrainHook.cjs} +0 -0
  268. /package/src/main/lib/{fixPlanSlug.cjs → scheduler/fixPlanSlug.cjs} +0 -0
  269. /package/src/main/lib/{gateAuthority.cjs → scheduler/gateAuthority.cjs} +0 -0
  270. /package/src/main/lib/{landedSinceRun.cjs → scheduler/landedSinceRun.cjs} +0 -0
  271. /package/src/main/lib/{loadGate.cjs → scheduler/loadGate.cjs} +0 -0
  272. /package/src/main/lib/{needsReviewLedger.cjs → scheduler/needsReviewLedger.cjs} +0 -0
  273. /package/src/main/lib/{queueHealth.cjs → scheduler/queueHealth.cjs} +0 -0
  274. /package/src/main/lib/{queueHistory.cjs → scheduler/queueHistory.cjs} +0 -0
  275. /package/src/main/lib/{scheduleJobSchema.cjs → scheduler/scheduleJobSchema.cjs} +0 -0
  276. /package/src/main/lib/{schedulerPaths.cjs → scheduler/schedulerPaths.cjs} +0 -0
  277. /package/src/main/lib/{terminalRunOutcome.cjs → scheduler/terminalRunOutcome.cjs} +0 -0
  278. /package/src/main/lib/{validationSentinels.cjs → scheduler/validationSentinels.cjs} +0 -0
  279. /package/src/main/lib/{crashTelemetry.cjs → telemetry/crashTelemetry.cjs} +0 -0
  280. /package/src/main/lib/{otlpTraceExporter.cjs → telemetry/otlpTraceExporter.cjs} +0 -0
  281. /package/src/main/lib/{telemetryConsent.cjs → telemetry/telemetryConsent.cjs} +0 -0
  282. /package/src/main/lib/{telemetryCounters.cjs → telemetry/telemetryCounters.cjs} +0 -0
  283. /package/src/main/lib/{encodeCwd.cjs → util/encodeCwd.cjs} +0 -0
  284. /package/src/main/lib/{expandHome.cjs → util/expandHome.cjs} +0 -0
  285. /package/src/main/lib/{extractJson.cjs → util/extractJson.cjs} +0 -0
  286. /package/src/main/lib/{fileTail.cjs → util/fileTail.cjs} +0 -0
  287. /package/src/main/lib/{headTailBuffer.cjs → util/headTailBuffer.cjs} +0 -0
  288. /package/src/main/lib/{kebabCase.cjs → util/kebabCase.cjs} +0 -0
  289. /package/src/main/lib/{lruCache.cjs → util/lruCache.cjs} +0 -0
  290. /package/src/main/lib/{withTimeout.cjs → util/withTimeout.cjs} +0 -0
@@ -10,7 +10,7 @@ if (process.env.SM_BOOT_DIAG === '1') {
10
10
  process.stderr.write(`[boot-diag] failed: ${err && err.message}\n`);
11
11
  }
12
12
  }
13
- const { PROC_NAMES, setProcessTitle, inhibitHolderShell } = require('./lib/smProcNames.cjs');
13
+ const { PROC_NAMES, setProcessTitle, inhibitHolderShell } = require('./lib/process/smProcNames.cjs');
14
14
  // Self-describing `comm` in System Monitor (pn-03). process.argv is a JS copy
15
15
  // made at startup, so the argv-memory overwrite below never affects the
16
16
  // `process.argv.includes('--simple')` read further down.
@@ -23,10 +23,10 @@ const fsp = require('node:fs/promises');
23
23
  const os = require('node:os');
24
24
  const { schemas, validated } = require('./ipcSchemas.cjs');
25
25
  const { createProjectFolder } = require('./lib/projectFolder.cjs');
26
- const { cleanChildEnv } = require('./lib/cleanEnv.cjs');
27
- const { applyLoginShellPath } = require('./lib/loginShellPath.cjs');
28
- const { terminateLosingInstance } = require('./lib/singleInstanceGuard.cjs');
29
- const { acquireSchedulerOwnership, releaseSchedulerOwnership } = require('./lib/instanceLock.cjs');
26
+ const { cleanChildEnv } = require('./lib/process/cleanEnv.cjs');
27
+ const { applyLoginShellPath } = require('./lib/process/loginShellPath.cjs');
28
+ const { terminateLosingInstance } = require('./lib/process/singleInstanceGuard.cjs');
29
+ const { acquireSchedulerOwnership, releaseSchedulerOwnership } = require('./lib/process/instanceLock.cjs');
30
30
  const { manager: ptyManager, registerPtyHandlers } = require('./pty.cjs');
31
31
  const configMgr = require('./config.cjs');
32
32
  const transcripts = require('./transcripts.cjs');
@@ -57,34 +57,30 @@ crashDiagnostics.startCrashReporter();
57
57
  const voiceHotkey = require('./voiceHotkey.cjs');
58
58
  const voiceWizard = require('./voiceWizard.cjs');
59
59
  const scheduler = require('./scheduler.cjs');
60
- const { createAdminHttp } = require('./lib/localAdminHttp.cjs');
61
- const prdCreate = require('./lib/prdCreate.cjs');
62
- const prdAdminRoutes = require('./lib/prdAdminRoutes.cjs');
63
- const projectHomeAdminRoutes = require('./lib/projectHomeAdminRoutes.cjs');
64
- const macroAdminRoutes = require('./lib/macroAdminRoutes.cjs');
60
+ const { createAdminHttp } = require('./lib/feedback-remote/localAdminHttp.cjs');
61
+ const prdCreate = require('./lib/prd/prdCreate.cjs');
62
+ const prdAdminRoutes = require('./lib/prd/prdAdminRoutes.cjs');
63
+ const projectHomeAdminRoutes = require('./lib/feedback-remote/projectHomeAdminRoutes.cjs');
64
+ const macroAdminRoutes = require('./lib/feedback-remote/macroAdminRoutes.cjs');
65
65
  const { smfileResponseHeaders, shouldBlockFrameNavigation } = require('./lib/smfileHeaders.cjs');
66
- const { appendAuditEvent } = require('./lib/auditLog.cjs');
66
+ const { appendAuditEvent } = require('./lib/telemetry/auditLog.cjs');
67
67
  const chatRunner = require('./chatRunner.cjs');
68
68
  const promptSessionEvents = require('./promptSessionEvents.cjs');
69
- const activeIndexMerge = require('./lib/activeIndexMerge.cjs');
70
- const promptSessionsCreateEpic = require('./lib/promptSessionsCreateEpic.cjs');
71
- const customerFeedbackIpc = require('./lib/customerFeedbackIpc.cjs');
72
- const epicWorktreeMint = require('./lib/epicWorktreeMint.cjs');
73
- const epicWorktreeMerge = require('./lib/epicWorktreeMerge.cjs');
74
- const epicWorktreeProjectConfig = require('./lib/epicWorktreeProjectConfig.cjs');
75
- const agentLibrary = require('./agentLibrary.cjs');
76
- const macroLibrary = require('./lib/macroLibrary.cjs');
77
- const agentModelResolve = require('./lib/agentModelResolve.cjs');
78
- const agentEffortResolve = require('./lib/agentEffortResolve.cjs');
79
- const { resolveEffectiveModelInfo } = require('./lib/effectiveModelInfo.cjs');
80
- const { resolveModelCatalog } = require('./lib/modelCatalog.cjs');
81
- const { checkDelegationReadiness, ensureGuardsInstalled, installPrdWriteGuard, installDestructiveGitGuard, installInlineImplementationGuard, installSelfScheduleGuard } = require('./lib/delegationReadiness.cjs');
69
+ const activeIndexMerge = require('./lib/epic/activeIndexMerge.cjs');
70
+ const promptSessionsCreateEpic = require('./lib/epic/promptSessionsCreateEpic.cjs');
71
+ const customerFeedbackIpc = require('./lib/feedback-remote/customerFeedbackIpc.cjs');
72
+ const epicWorktreeMint = require('./lib/epic/epicWorktreeMint.cjs');
73
+ const epicWorktreeMerge = require('./lib/epic/epicWorktreeMerge.cjs');
74
+ const epicWorktreeProjectConfig = require('./lib/epic/epicWorktreeProjectConfig.cjs');
75
+ const macroLibrary = require('./lib/persona-macro/macroLibrary.cjs');
76
+ const { resolveModelCatalog } = require('./lib/claude/modelCatalog.cjs');
77
+ const { checkDelegationReadiness, ensureGuardsInstalled, installPrdWriteGuard, installDestructiveGitGuard, installInlineImplementationGuard, installSelfScheduleGuard } = require('./lib/epic/delegationReadiness.cjs');
82
78
  const { resolveProjectContext } = require('./lib/projectRootResolve.cjs');
83
- const upgradeDrain = require('./lib/upgradeDrain.cjs');
79
+ const upgradeDrain = require('./lib/scheduler/upgradeDrain.cjs');
84
80
  const { writeGuardShims } = require('./lib/guardShims.cjs');
85
81
  const { MCP_TOOL_CATALOG, MCP_RECIPES } = require('./lib/mcpToolCatalog.cjs');
86
82
  const { sendIfAlive } = require('./lib/sendToRenderer.cjs');
87
- const crossProjectFeedback = require('./lib/crossProjectFeedback.cjs');
83
+ const crossProjectFeedback = require('./lib/feedback-remote/crossProjectFeedback.cjs');
88
84
  const adminHttp = createAdminHttp();
89
85
  scheduler.registerAdminRoutes(adminHttp);
90
86
  prdCreate.registerAdminRoute(adminHttp, scheduler.remote);
@@ -94,9 +90,9 @@ macroAdminRoutes.registerAdminRoute(adminHttp, { onChanged: () => broadcastMacro
94
90
  chatRunner.registerAdminRoute(adminHttp);
95
91
  // Project-to-project feedback conduit — the app is the only process holding
96
92
  // several projects' operations roots open, so it performs the cross-folder
97
- // write (lib/crossProjectFeedback.cjs).
93
+ // write (lib/feedback-remote/crossProjectFeedback.cjs).
98
94
  crossProjectFeedback.registerAdminRoute(adminHttp);
99
- require('./lib/customerFeedbackAdminRoutes.cjs').registerAdminRoute(adminHttp);
95
+ require('./lib/feedback-remote/customerFeedbackAdminRoutes.cjs').registerAdminRoute(adminHttp);
100
96
  const supervisor = require('./supervisor.cjs');
101
97
  const watchers = require('./watchers.cjs');
102
98
  const queueOps = require('./queueOps.cjs');
@@ -107,22 +103,18 @@ const { seedSchedulerMcp } = require('./seedSchedulerMcp.cjs');
107
103
  const { getSeedStatus } = require('./seedStatus.cjs');
108
104
  const otel = require('./otel.cjs');
109
105
  const otelSettings = require('./otelSettings.cjs');
110
- const telemetrySettings = require('./lib/telemetrySettings.cjs');
111
- const telemetryClient = require('./lib/telemetryClient.cjs');
112
- const telemetryBacklog = require('./lib/telemetryBacklog.cjs');
113
- const telemetryConsent = require('./lib/telemetryConsent.cjs');
114
106
  const { registerHistoryAggregatorHandlers, finalizeClosedDays, refreshIntradayToday } = require('./historyAggregator.cjs');
115
- const runLogRetention = require('./lib/runLogRetention.cjs');
107
+ const runLogRetention = require('./lib/scheduler/runLogRetention.cjs');
116
108
  const { registerHistoryDashboardHandlers } = require('./historyDashboard.cjs');
117
- const { tryAcquireLock, releaseLock, DEFAULT_LOCK_PATH } = require('./lib/watchdogHelpers.cjs');
109
+ const { tryAcquireLock, releaseLock, DEFAULT_LOCK_PATH } = require('./lib/scheduler/watchdogHelpers.cjs');
118
110
  const { createIntradayRefresh } = require('./lib/intradayRefresh.cjs');
119
- const schedulerConfig = require('./lib/schedulerConfig.cjs');
111
+ const schedulerConfig = require('./lib/scheduler/schedulerConfig.cjs');
120
112
  const memoryTool = require('./memoryTool.cjs');
121
113
  const { registerMemoryAggregateIpc } = require('./memoryAggregate.cjs');
122
114
  const { registerProjectBriefIpc } = require('./projectBrief.cjs');
123
115
  const { registerProjectPagesIpc, attachWindow: attachProjectPagesWindow, closeAllOutputWatchers: closeAllProjectPagesWatchers } = require('./projectPages.cjs');
124
116
  const promptSessionTranscript = require('./promptSessionTranscript.cjs');
125
- const { computeEpicDelegationStats } = require('./lib/epicDelegationStats.cjs');
117
+ const { computeEpicDelegationStats } = require('./lib/epic/epicDelegationStats.cjs');
126
118
  const agentMemory = require('./agentMemory.cjs');
127
119
  const git = require('./git.cjs');
128
120
  const heapSnapshot = require('./heapSnapshot.cjs');
@@ -130,14 +122,16 @@ const filesIpc = require('./files.cjs');
130
122
  const { registerDocEditHandlers, attachWindow: attachDocEditWindow } = require('./docEdit.cjs');
131
123
  const webRemote = require('./webRemote.cjs');
132
124
  const { registerRemoteClientHandlers } = require('./remoteClientIpc.cjs');
125
+ const { registerAgentsHandlers } = require('./agentsIpc.cjs');
126
+ const { registerTelemetryHandlers } = require('./telemetryIpc.cjs');
133
127
  const { registerUpdaterIpc } = require('./updaterIpc.cjs');
134
128
  const { listExchanges } = require('./exchanges.cjs');
135
- const { resolveClaudeBin } = require('./lib/claudeBin.cjs');
129
+ const { resolveClaudeBin } = require('./lib/claude/claudeBin.cjs');
136
130
  const { checkInsideHome, assertInsideHome } = require('./lib/insideHome.cjs');
137
131
  const { openInEditor, openFileInEditor, openInFinder, openInTerminal, runInTerminal } = require('./lib/openExternalApp.cjs');
138
132
  const { checkPrereqs } = require('./lib/prereqs.cjs');
139
- const { rebuildActiveIndex } = require('./lib/activeIndexRebuild.cjs');
140
- const { activeIndexPath: promptSessionsActiveIndexPath } = require('./lib/epicMint.cjs');
133
+ const { rebuildActiveIndex } = require('./lib/epic/activeIndexRebuild.cjs');
134
+ const { activeIndexPath: promptSessionsActiveIndexPath } = require('./lib/epic/epicMint.cjs');
141
135
  const { allProjectCwds } = require('./lib/activeSessions.cjs');
142
136
  const { scheduleBootSelfHeal } = require('./lib/bootSelfHeal.cjs');
143
137
 
@@ -354,7 +348,7 @@ function relaunchViaNpx() {
354
348
 
355
349
  /**
356
350
  * rebootApp({force}) — restart is a REQUEST that drains first and never kills
357
- * (lib/upgradeDrain.cjs): dispatch pauses, running jobs finish, then the
351
+ * (lib/scheduler/upgradeDrain.cjs): dispatch pauses, running jobs finish, then the
358
352
  * scheduler's heartbeat-driven drain calls performReboot(). `force: true`
359
353
  * keeps the old immediate behaviour (kills running executors) for humans who
360
354
  * accept the cost.
@@ -480,7 +474,7 @@ function createWindow() {
480
474
  // known project has already accumulated, marking exactly what's
481
475
  // CONFIRMED delivered. Fired after the window is shown (never blocks
482
476
  // startup) and yields between files internally. See telemetryBacklog.cjs.
483
- require('./lib/telemetryBacklog.cjs')
477
+ require('./lib/telemetry/telemetryBacklog.cjs')
484
478
  .bootDrain({ appVersion: app.getVersion() })
485
479
  .catch((e) => {
486
480
  logs.writeLine({ scope: 'telemetry', level: 'warn', message: 'telemetryBacklog.bootDrain failed', meta: { error: e?.message } });
@@ -583,36 +577,6 @@ ipcMain.handle('mcp:status', () => probeMcpStatus());
583
577
  // the renderer never makes a direct HTTP call. Static data, no cwd needed.
584
578
  ipcMain.handle('mcp:catalog', () => ({ ok: true, tools: MCP_TOOL_CATALOG, recipes: MCP_RECIPES }));
585
579
 
586
- // Agent Library nav page (Home face only): global `~/.claude/agents/*.md`
587
- // personas plus, per currently-open project tab, whether that project
588
- // overlays the same agent name at `<cwd>/.claude/agents/<name>.md`. Read-only.
589
- ipcMain.handle('agents:list-personas', () => agentLibrary.listPersonas());
590
- // Agent Library CRUD — global personas only (`~/.claude/agents/*.md`); a
591
- // project's local overlay can only be removed here (removeOverride), never
592
- // created, since Agent Library is a Home-face, machine-wide surface with no
593
- // per-tab cwd context of its own. Each mutation broadcasts `agents:changed`
594
- // so Agent Library and Tag Library — two independently-mounted dockview
595
- // panels, each with its own component-local `listPersonas()` snapshot —
596
- // both refresh off the one file on disk instead of one panel going stale
597
- // after the other edits the agent<->tag relationship.
598
- function broadcastAgentsChanged() {
599
- sendIfAlive(mainWindow, 'agents:changed', {});
600
- }
601
- ipcMain.handle('agents:save-persona', validated(schemas.agentsSavePersona, async (payload) => {
602
- const result = await agentLibrary.savePersona(payload);
603
- broadcastAgentsChanged();
604
- return result;
605
- }));
606
- ipcMain.handle('agents:delete-persona', async (_e, payload) => {
607
- const result = await agentLibrary.deletePersona(payload);
608
- broadcastAgentsChanged();
609
- return result;
610
- });
611
- ipcMain.handle('agents:remove-override', async (_e, payload) => {
612
- const result = await agentLibrary.removeOverride(payload);
613
- broadcastAgentsChanged();
614
- return result;
615
- });
616
580
  // Macro library (macroLibrary.cjs): global machine-local one-click sidebar
617
581
  // macros (agent + tag + prompt). Store path is fixed in-module; the renderer
618
582
  // never supplies it. Mutations broadcast `macros:changed`.
@@ -635,31 +599,6 @@ ipcMain.handle('macros:set-project', validated(schemas.macrosSetProject, async (
635
599
  if (result.ok) broadcastMacrosChanged();
636
600
  return result;
637
601
  }));
638
- // New Epic AIM composer (epicIntake.ts's `agentBody`/`agentPath`): unlike
639
- // list-personas above (global dir only), this honors the project-overlay-
640
- // then-global precedence so an Epic's opening prompt carries the persona
641
- // body that actually applies to its cwd. Read-only.
642
- ipcMain.handle('agents:get-persona-body', validated(schemas.agentsGetPersonaBody, (payload) =>
643
- agentLibrary.getPersonaBody(payload)));
644
-
645
- // "What will this Epic's launch actually use for --model?" — the SAME
646
- // resolver chatRunner.cjs's Chat-view launch calls in-process
647
- // (agentModelResolve.cjs's resolveEpicModel), reached here so Terminal's
648
- // launch (EpicTerminalPane.tsx, a renderer module with no fs access) agrees
649
- // with Chat by calling the identical function rather than a second one that
650
- // is merely supposed to. Never throws (resolveEpicModel's own contract).
651
- ipcMain.handle('agents:resolve-epic-model', validated(schemas.agentsResolveEpicModel, (payload) =>
652
- agentModelResolve.resolveEpicModel(payload)));
653
- // Effort twin of the above (agentEffortResolve.cjs): Terminal appends
654
- // `--effort <level>` only when `effort` is non-null. Never throws.
655
- ipcMain.handle('agents:resolve-epic-effort', validated(schemas.agentsResolveEpicEffort, (payload) =>
656
- agentEffortResolve.resolveEpicEffort(payload)));
657
-
658
- // "What will this Epic actually run as?" (PRD: effective-model-resolver) —
659
- // persona alias + evidence-based concrete model id + provenance, for a given
660
- // (cwd, agentType). Read-only observer; never affects what a launch resolves.
661
- ipcMain.handle('agents:resolve-model-info', validated(schemas.agentsResolveModelInfo, (payload) =>
662
- resolveEffectiveModelInfo(payload)));
663
602
 
664
603
  // Live model/effort catalog (modelCatalog.cjs) — never throws; `force` bypasses its cache.
665
604
  ipcMain.handle('models:catalog', validated(schemas.modelsCatalog, (payload) =>
@@ -700,7 +639,7 @@ ipcMain.handle('app:delegation-readiness', validated(schemas.delegationReadiness
700
639
  // session-manager-operations/logs/errors-<date>.jsonl, same shape as every
701
640
  // other structured error line.
702
641
  function logGuardInstallAttempt(guard, cwd, outcome) {
703
- const opsErrorLog = require('./lib/opsErrorLog.cjs');
642
+ const opsErrorLog = require('./lib/telemetry/opsErrorLog.cjs');
704
643
  opsErrorLog.appendError({
705
644
  cwd,
706
645
  scope: 'delegationReadinessGuardInstall',
@@ -1101,6 +1040,7 @@ filesIpc.registerFilesHandlers();
1101
1040
  registerDocEditHandlers();
1102
1041
  webRemote.registerRemoteHandlers();
1103
1042
  registerRemoteClientHandlers(() => mainWindow);
1043
+ registerAgentsHandlers({ ipcMain, getWindow: () => mainWindow });
1104
1044
  try {
1105
1045
  registerUpdaterIpc({ ipcMain, getWindow: () => mainWindow, ptyManager });
1106
1046
  } catch (e) {
@@ -1126,35 +1066,7 @@ ipcMain.handle('exchanges:list', validated(schemas.exchangesList, async (payload
1126
1066
  }
1127
1067
  }));
1128
1068
 
1129
- // OTEL telemetry export (opt-in via ~/.claude/session-manager/otel.json).
1130
- ipcMain.handle('otel:get-config', async () => otelSettings.load());
1131
- ipcMain.handle('otel:set-config', async (_e, cfg) => {
1132
- if (!otelSettings.isValid(cfg)) {
1133
- return { ok: false, error: 'invalid config' };
1134
- }
1135
- const saved = await otelSettings.save(cfg);
1136
- const result = await otel.applyConfig(saved);
1137
- return { ok: !!result?.ok, error: result?.error ?? null, config: saved, status: otel.status() };
1138
- });
1139
- ipcMain.handle('otel:status', () => otel.status());
1140
- ipcMain.handle('otel:config-path', () => otelSettings.storePath());
1141
-
1142
- // Product telemetry (bilko.run) — anonymous, on-by-default, opt-out consent
1143
- // UX + inspector over the client PRDs above wired. Settings > Telemetry's
1144
- // "Product telemetry" section is the sole UI surface for this; see
1145
- // session-manager-operations/architecture/telemetry.md for the data model.
1146
- ipcMain.handle('telemetry:get-config', async () => telemetrySettings.load());
1147
- ipcMain.handle('telemetry:set-config', validated(schemas.telemetrySetConfig, async (cfg) => {
1148
- const saved = await telemetryConsent.applyConsentUpdate(cfg, { telemetrySettings, telemetryClient });
1149
- return { ok: true, config: saved, status: telemetryClient.status() };
1150
- }));
1151
- ipcMain.handle('telemetry:status', () => ({
1152
- ...telemetryClient.status(),
1153
- backlog: telemetryBacklog.lastRunSummary(),
1154
- }));
1155
- ipcMain.handle('telemetry:config-path', () => telemetrySettings.storePath());
1156
- ipcMain.handle('telemetry:recent-records', () => telemetryClient.recentRecords());
1157
- ipcMain.handle('telemetry:flush-now', () => telemetryClient.flush('manual'));
1069
+ registerTelemetryHandlers({ ipcMain });
1158
1070
 
1159
1071
  // Diagnostic-only renderer heap snapshot. No-op unless SM_HEAP_SNAPSHOT=1 —
1160
1072
  // see heapSnapshot.cjs for why this stays off by default.
@@ -1292,14 +1204,14 @@ app.whenReady().then(async () => {
1292
1204
 
1293
1205
  process.on('uncaughtException', (err) => {
1294
1206
  try {
1295
- require('./lib/telemetryClient.cjs').reportError({ name: 'uncaughtException', msg: err?.message, stack: err?.stack });
1207
+ require('./lib/telemetry/telemetryClient.cjs').reportError({ name: 'uncaughtException', msg: err?.message, stack: err?.stack });
1296
1208
  } catch { /* telemetry must never break the existing handling below */ }
1297
1209
  logs.writeLine({ scope: 'main', level: 'error', message: 'uncaughtException', meta: { error: err?.message, stack: err?.stack } });
1298
1210
  });
1299
1211
  process.on('unhandledRejection', (reason) => {
1300
1212
  const r = reason instanceof Error ? { error: reason.message, stack: reason.stack } : { reason: String(reason) };
1301
1213
  try {
1302
- require('./lib/telemetryClient.cjs').reportError({ name: 'unhandledRejection', msg: r.error || r.reason, stack: r.stack });
1214
+ require('./lib/telemetry/telemetryClient.cjs').reportError({ name: 'unhandledRejection', msg: r.error || r.reason, stack: r.stack });
1303
1215
  } catch { /* telemetry must never break the existing handling below */ }
1304
1216
  logs.writeLine({ scope: 'main', level: 'error', message: 'unhandledRejection', meta: r });
1305
1217
  });
@@ -1307,7 +1219,7 @@ app.whenReady().then(async () => {
1307
1219
  // Telemetry boot sequence: flush('boot') always, flush('version-change')
1308
1220
  // when detected, and the once-per-machine install upsert (app_installs) when
1309
1221
  // due (version bump or 30-day liveness heartbeat). See telemetryBoot.cjs.
1310
- require('./lib/telemetryBoot.cjs')
1222
+ require('./lib/telemetry/telemetryBoot.cjs')
1311
1223
  .bootSequence({
1312
1224
  appVersion: app.getVersion(),
1313
1225
  installChannel: require('./lib/machineProfile.cjs').resolveInstallChannel({ appPath: app.getAppPath() }),
@@ -1490,7 +1402,13 @@ app.whenReady().then(async () => {
1490
1402
  console.log(`[main] scheduler ownership held by pid ${ownership.holderPid} — running scheduler-passive (no reconciliation, no admin server)`);
1491
1403
  logs.writeLine({ scope: 'scheduler', level: 'info', message: 'scheduler-passive: ownership held by another instance', meta: { holderPid: ownership.holderPid } });
1492
1404
  }
1493
- // First-boot default: install the bundled session-manager-dev plugin (its 10
1405
+ // Sweep orphaned `<file>.tmp-<pid>-…` files from crashed atomic writers in the
1406
+ // machine-global state dir (per-project dirs belong to reconcile).
1407
+ try {
1408
+ const { removed } = require('./lib/util/atomicFs.cjs').sweepStaleTmpFiles(path.join(os.homedir(), '.claude', 'session-manager'));
1409
+ logs.writeLine({ scope: 'main', level: 'info', message: 'stale tmp sweep', meta: { removed: removed.length } });
1410
+ } catch { /* sweep is best-effort */ }
1411
+ // First-boot default: install the bundled session-manager-dev plugin (its 3
1494
1412
  // dev skills) from the app's own marketplace. One-shot + idempotent; never
1495
1413
  // throws. SM_SEED_DEV_PLUGIN_DISABLE=1 to opt out.
1496
1414
  seedDevPlugin({ logger: console, writeLog: logs.writeLine }).catch((e) => {
@@ -1560,7 +1478,7 @@ app.whenReady().then(async () => {
1560
1478
  }, 30_000);
1561
1479
  // Keep TODAY's rollup line current so the History dashboard never needs to
1562
1480
  // fall back to a live transcript scan. Shares the same O_EXCL lock file as
1563
- // the external watchdog's finalize pass (src/main/lib/watchdogHelpers.cjs)
1481
+ // the external watchdog's finalize pass (src/main/lib/scheduler/watchdogHelpers.cjs)
1564
1482
  // so the two never interleave writes to the rollup; a contended lock just
1565
1483
  // means this tick's refresh is skipped (harmless — the next tick retries).
1566
1484
  const intradayTimer = setInterval(runIntradayRefresh, schedulerConfig.HISTORY_INTRADAY_REFRESH_MS);
@@ -1663,5 +1581,5 @@ app.on('before-quit', () => {
1663
1581
  // Best-effort delivery attempt for whatever telemetry accumulated this run.
1664
1582
  // flush() only removes records it actually delivered — an interrupted or
1665
1583
  // failed attempt leaves the queue file intact for the next boot's flush.
1666
- require('./lib/telemetryClient.cjs').flush('quit').catch(() => {});
1584
+ require('./lib/telemetry/telemetryClient.cjs').flush('quit').catch(() => {});
1667
1585
  });
@@ -10,10 +10,10 @@ const { z } = require('zod');
10
10
  const os = require('node:os');
11
11
  const path = require('node:path');
12
12
  const { PromptSessionSchema, EpicTagSchema, EpicSourceSchema, EpicIntakeSectionSchema } = require('./lib/promptSessionSchema.cjs');
13
- const { PrdWorkTypeSchema } = require('./lib/workTypeLibrary.cjs');
13
+ const { PrdWorkTypeSchema } = require('./lib/prd/workTypeLibrary.cjs');
14
14
  const { PERSONA_NAME_RE } = require('./agentLibrary.cjs');
15
- const { AgentPersonaSaveSchema } = require('./lib/agentPersonaSchema.cjs');
16
- const { MacroSaveSchema, MacroDeleteSchema, MacroSetProjectSchema } = require('./lib/macroLibrary.cjs');
15
+ const { AgentPersonaSaveSchema } = require('./lib/persona-macro/agentPersonaSchema.cjs');
16
+ const { MacroSaveSchema, MacroDeleteSchema, MacroSetProjectSchema } = require('./lib/persona-macro/macroLibrary.cjs');
17
17
 
18
18
  // ──────────────────────────────────────────── PTY
19
19
  const ptySpawn = z.object({
@@ -144,7 +144,7 @@ const configWatchOpts = z.object({ depth: z.number().int().min(0).max(2) }).stri
144
144
  const configParseImports = z.object({ path: z.string().min(1).max(4096) });
145
145
 
146
146
  // ──────────────────────────────────────────── PromptSessions (Epics) active-index merge
147
- // lib/activeIndexMerge.cjs's read-merge-write, invoked over IPC by the
147
+ // lib/epic/activeIndexMerge.cjs's read-merge-write, invoked over IPC by the
148
148
  // renderer's persistActiveIndex (state/promptSessions.ts) instead of that
149
149
  // module doing its own config:read-json/config:write-json round trip. Payload
150
150
  // carries only the CALLING renderer's in-memory contribution for this cwd —
@@ -204,7 +204,7 @@ const promptSessionsMergeActiveIndex = z.object({
204
204
  source: z.literal('epics'),
205
205
  });
206
206
 
207
- // Renderer entry point for main's ensureEpic() (lib/promptSessionsCreateEpic.cjs)
207
+ // Renderer entry point for main's ensureEpic() (lib/epic/promptSessionsCreateEpic.cjs)
208
208
  // — additive step 1 of a two-PRD chain; unused by the app until the next PRD
209
209
  // routes state/promptSessions.ts's createPromptSession through it. `tag`/
210
210
  // `source` reuse promptSessionSchema.cjs's own enums rather than retyping
@@ -226,14 +226,14 @@ const promptSessionsCreateEpic = z.object({
226
226
  });
227
227
 
228
228
  // Renderer entry point for creating an Epic's isolated git worktree
229
- // (lib/epicWorktreeMint.cjs) at the proposed->active transition — PRD 1033.
229
+ // (lib/epic/epicWorktreeMint.cjs) at the proposed->active transition — PRD 1033.
230
230
  const promptSessionsCreateWorktree = z.object({
231
231
  cwd: z.string().min(1).max(4096),
232
232
  epicId: z.string().regex(PROMPT_SESSION_ID_RE),
233
233
  });
234
234
 
235
235
  // Renderer entry point for folding an Epic's isolated git worktree branch
236
- // back into its owning project's main tree (lib/epicWorktreeMerge.cjs) — PRD
236
+ // back into its owning project's main tree (lib/epic/epicWorktreeMerge.cjs) — PRD
237
237
  // 1034, the ONLY point where the per-Epic isolation PRD 1033 wires resolves.
238
238
  // `branch`/`dir` are supplied by the caller (the renderer's own in-memory
239
239
  // `session.worktree`) rather than re-derived from active-index.json, since
@@ -253,7 +253,7 @@ const promptSessionsMergeToMain = z.object({
253
253
  });
254
254
 
255
255
  // Renderer entry points for the per-project "disable Epic worktree
256
- // isolation" UI toggle (lib/epicWorktreeProjectConfig.cjs) — PRD 1035.
256
+ // isolation" UI toggle (lib/epic/epicWorktreeProjectConfig.cjs) — PRD 1035.
257
257
  const promptSessionsGetWorktreeDisabled = z.object({
258
258
  cwd: z.string().min(1).max(4096),
259
259
  });
@@ -415,7 +415,7 @@ const schedulerCreatePrd = z.object({
415
415
  // User-selected work-type tag (PRD 774; independence from the parent
416
416
  // Epic's own tag confirmed PRD 1041) — deterministic, never LLM-classified.
417
417
  // Epic tag and PRD tag draw on the same WorkType vocabulary
418
- // (lib/workTypeLibrary.cjs) but are independent values; 'discussion' is
418
+ // (lib/prd/workTypeLibrary.cjs) but are independent values; 'discussion' is
419
419
  // excluded here for the same reason adminPrdFrontmatterPatch excludes it
420
420
  // below — a discussion-tagged Epic never reaches PRD authoring.
421
421
  tag: PrdWorkTypeSchema.optional(),
@@ -618,7 +618,7 @@ const setSessionSlotsSchema = z.object({
618
618
  // agents:save-persona — the Agent entity (Agent/WorkType/Epic/PRD/Job ERD)
619
619
  // had no boundary validation until this schema; Epic and Job each got theirs
620
620
  // only after a production incident (see scheduleJobSchema.cjs's header).
621
- // Full field-level rules live in lib/agentPersonaSchema.cjs, mirroring
621
+ // Full field-level rules live in lib/persona-macro/agentPersonaSchema.cjs, mirroring
622
622
  // AgentPersonaSaveInput (src/preload/api.d.ts) field-for-field.
623
623
  const agentsSavePersona = AgentPersonaSaveSchema;
624
624
  const macrosSave = MacroSaveSchema;
@@ -919,6 +919,9 @@ const chatRun = z.object({
919
919
  // Originating PromptTicket.id (PRD 748) when this run was dequeued from a
920
920
  // tab's prompt queue — absent for a fresh manual send with no ticket.
921
921
  promptId: z.string().min(1).max(128).optional(),
922
+ // Who authored this send. Only 'human' is auto-approve evidence for
923
+ // crossProjectFeedback; absent or any other value is treated as not-human.
924
+ origin: z.enum(['human', 'external', 'inbound-proposal']).optional(),
922
925
  });
923
926
 
924
927
  const chatCancel = z.object({
@@ -0,0 +1,48 @@
1
+ # src/main/lib/ — scoped context
2
+
3
+ Shared main-process helpers (CommonJS `.cjs`). Layout source of truth: `scripts/lib-layout.json`.
4
+
5
+ ## What's here
6
+
7
+ - `claude/` — claude CLI binary, caps, model/effort resolution.
8
+ - `epic/` — Epic mint, worktrees, active index, spawn plan/cwd, transcripts.
9
+ - `feedback-remote/` — cross-project and customer feedback conduits.
10
+ - `git/` — git exec, worktrees, branch sweeps, job worktrees.
11
+ - `persona-macro/` — agent persona schema/merge, macro library, builtin macros.
12
+ - `prd/` — PRD parsing helpers, admin routes, dep-slug resolution, plan validation.
13
+ - `process/` — child processes, kill tree, env cleaning, pid liveness, instance lock.
14
+ - `scheduler/` — dispatch loop, session slots, gates, supervisors, queue helpers.
15
+ - `telemetry/` — audit/ops error logs, crash and OTLP telemetry.
16
+ - `util/` — generic pure helpers (atomic fs, kebab, home/cwd encoding, JSON extract, tail).
17
+ - top-level files — cross-cutting modules that fit no domain (`opsOwnership`, `activeSessions`, `projectRootResolve`, `cwdClassify`).
18
+ - `__tests__/` — tests for top-level modules; subfolders carry their own.
19
+
20
+ ## Where a new module goes
21
+
22
+ Put it in the subfolder whose domain it serves; pure and domain-free goes in `util/`.
23
+ A new top-level `lib/` module needs a stated reason (no domain fits) in its header comment,
24
+ and a `scripts/lib-layout.json` entry. Never add a subfolder for one file.
25
+
26
+ ## Reuse before writing
27
+
28
+ Each of these was found duplicated once. Grep first; extend the canonical one.
29
+
30
+ | Need | Canonical | Function |
31
+ | --- | --- | --- |
32
+ | Atomic write (tmp+rename) | `util/atomicFs.cjs` | `writeTextAtomic[Sync]`, `writeJsonAtomic[Sync]` |
33
+ | JSON read with fallback | `util/atomicFs.cjs` | `readJsonOr`, `readJsonOrSync` |
34
+ | PID liveness | `process/pidAlive.cjs` | `pidAlive` |
35
+ | Kebab / slug | `util/kebabCase.cjs` | `kebabCase` |
36
+ | Project root, read-only/total (never throws) | `activeSessions.cjs` | `projectRootOf` |
37
+ | Project root, validated; `opsInternal:'refuse'` for writers | `opsOwnership.cjs` | `resolveProjectRoot` |
38
+ | Project root + Epic from session/epic hints | `projectRootResolve.cjs` | `resolveProjectContext` |
39
+ | Ops-root path (single-writer law) | `opsOwnership.cjs` | `opsPath` |
40
+ | Run git | `git/gitExec.cjs` | `execGit` |
41
+ | Spawn `claude -p` (only machine-wide cap) | `scheduler/sessionSlots.cjs` | `acquire`, `release` |
42
+
43
+ Pin `--model` on every `claude -p` spawn.
44
+
45
+ ## What must NOT be assumed
46
+
47
+ - Never `path.join` an agent cwd to build an ops path — use `opsPath`.
48
+ - No private process caps, no hand-rolled tmp+rename, no new `JSON.parse(readFileSync)` fallbacks.
@@ -12,7 +12,7 @@ const fs = require('node:fs');
12
12
  const fsp = require('node:fs/promises');
13
13
  const os = require('node:os');
14
14
  const path = require('node:path');
15
- const { KIND_CONFIG: WORKTREE_KIND_CONFIG } = require('./gitWorktree.cjs');
15
+ const { KIND_CONFIG: WORKTREE_KIND_CONFIG } = require('./git/gitWorktree.cjs');
16
16
  const { OPS_ROOT_DIR } = require('./opsOwnership.cjs');
17
17
  const { classifyCwd, worktreeMainRootOf } = require('./cwdClassify.cjs');
18
18
 
@@ -37,6 +37,17 @@ const TMP_DROP_ROOTS = {
37
37
  get prefixDropRoots() { return [WORKTREE_KIND_CONFIG.job.root, WORKTREE_KIND_CONFIG.epic.root]; },
38
38
  };
39
39
 
40
+ // Test-harness project cwds live at <tmpdir>/sst-*/…. They are never real
41
+ // projects, and leaking them into the active list made the renderer's batched
42
+ // config:watch hit 618 "Path outside allowed boundaries" rejects. Only the
43
+ // `sst-` first segment is matched, so test-stubbed HOMEs that are not sst-*
44
+ // dirs (see the exactDropCwds note above) are still kept.
45
+ function isSstHarnessCwd(cwd) {
46
+ const rel = path.relative(TMPDIR, cwd);
47
+ if (rel === '' || rel.startsWith('..') || path.isAbsolute(rel)) return false;
48
+ return rel.split(path.sep)[0].startsWith('sst-');
49
+ }
50
+
40
51
  // Transcript reads only need the last line with a `cwd` field — a few dozen
41
52
  // lines is always enough. 64 KB keeps peak RSS proportionate.
42
53
  const TAIL_BYTES = 64 * 1024;
@@ -389,6 +400,7 @@ function deriveCwds(records, maxAgeMin, maxCwds, tmpDropRoots) {
389
400
  return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
390
401
  });
391
402
  if (isUnderPrefixDropRoot) return;
403
+ if (isSstHarnessCwd(cwd)) return;
392
404
  if (seen.has(cwd) || result.length >= maxCwds) return;
393
405
  // Must exist AND be a directory — a transcript naming a since-deleted
394
406
  // path, or a file, is not a project.
@@ -456,6 +468,7 @@ module.exports = {
456
468
  allProjectCwds,
457
469
  projectRootOf,
458
470
  worktreeMainRootOf,
471
+ isSstHarnessCwd,
459
472
  bustProjectCwdCache,
460
473
  __waitForPendingRefresh,
461
474
  };
@@ -16,8 +16,8 @@
16
16
  */
17
17
 
18
18
  const { spawn } = require('node:child_process');
19
- const { resolveClaudeBin, claudeSpawnTarget } = require('./claudeBin.cjs');
20
- const { cleanChildEnv, pathWithUserBins } = require('./cleanEnv.cjs');
19
+ const { resolveClaudeBin, claudeSpawnTarget } = require('./claude/claudeBin.cjs');
20
+ const { cleanChildEnv, pathWithUserBins } = require('./process/cleanEnv.cjs');
21
21
 
22
22
  const CLASSIFY_TIMEOUT_MS = 30_000;
23
23
  const CLASSIFY_MODEL = 'sonnet';
@@ -29,10 +29,10 @@
29
29
 
30
30
  const path = require('node:path');
31
31
  const os = require('node:os');
32
- const { splitFrontmatter } = require('./prdFrontmatter.cjs');
33
- const { readActiveIndex, resolvePersonaPaths } = require('./epicMint.cjs');
34
- const { resolveMergedPersona, PERSONA_NAME_RE } = require('./personaMerge.cjs');
35
- const configMgr = require('../config.cjs');
32
+ const { splitFrontmatter } = require('../prd/prdFrontmatter.cjs');
33
+ const { readActiveIndex, resolvePersonaPaths } = require('../epic/epicMint.cjs');
34
+ const { resolveMergedPersona, PERSONA_NAME_RE } = require('../persona-macro/personaMerge.cjs');
35
+ const configMgr = require('../../config.cjs');
36
36
 
37
37
  /** The hardcoded floor every branch of resolveEpicModel falls back to — --model must never be omitted (CLAUDE.md "Automation model pinning"). */
38
38
  const FALLBACK_MODEL = 'sonnet';
@@ -55,7 +55,7 @@ function logDanglingPersonaOnce(cwd, agentType) {
55
55
  // Required lazily: opsErrorLog.cjs is a leaf module with no Electron
56
56
  // dependency, but keeping this require inside the miss path avoids
57
57
  // paying for it on the (overwhelmingly common) hit path.
58
- const { appendError } = require('./opsErrorLog.cjs');
58
+ const { appendError } = require('../telemetry/opsErrorLog.cjs');
59
59
  appendError({
60
60
  cwd,
61
61
  scope: 'agentModelResolve',
@@ -218,10 +218,10 @@ async function resolvePrdPersonaForSpawn({ cwd, agentType, fallbackModel = FALLB
218
218
  const miss = { model: fallbackModel, systemPrompt: null, personaPath: null };
219
219
  if (!agentType) return miss;
220
220
  try {
221
- const getBody = deps.getPersonaBody || require('../agentLibrary.cjs').getPersonaBody;
221
+ const getBody = deps.getPersonaBody || require('../../agentLibrary.cjs').getPersonaBody;
222
222
  const persona = await getBody({ cwd, name: agentType });
223
223
  if (!persona) {
224
- const reportOnce = deps.reportDanglingAgentTypeOnce || require('./prdAgentType.cjs').reportDanglingAgentTypeOnce;
224
+ const reportOnce = deps.reportDanglingAgentTypeOnce || require('../prd/prdAgentType.cjs').reportDanglingAgentTypeOnce;
225
225
  reportOnce(cwd, agentType, deps);
226
226
  return miss;
227
227
  }
@@ -68,7 +68,7 @@ function __resetForTests() { cached = null; }
68
68
  //
69
69
  // Every `claude` spawn goes through claudeSpawnTarget so GNOME System Monitor
70
70
  // shows a distinct comm per role (sm-claude-job / -chat / -aux) and a labelled
71
- // argv0. See lib/procName.cjs for the mechanics. Invariants:
71
+ // argv0. See lib/process/procName.cjs for the mechanics. Invariants:
72
72
  // - SM_CLAUDE_BIN set → aliasing SKIPPED, raw value used verbatim (tests point
73
73
  // it at self-locating stubs; it must stay ONE binary, no path splitting).
74
74
  // - aliasBinFor fails open (returns realBin) → no argv0 is set either, so the
@@ -92,7 +92,7 @@ function claudeSpawnTarget(role, detail, realBin = resolveClaudeBin(), args = []
92
92
  const platform = winOpts.platform || process.platform;
93
93
  if (platform !== 'win32' || !/\.(cmd|bat)$/i.test(base.command)) return base;
94
94
  // Node refuses to spawn a .cmd/.bat without a shell (EINVAL) — wrap in cmd.exe argv.
95
- const { resolveSpawn } = require('./winSpawn.cjs');
95
+ const { resolveSpawn } = require('../process/winSpawn.cjs');
96
96
  const wrapped = resolveSpawn(base.command, args, { platform, ...(winOpts.env ? { env: winOpts.env } : {}), ...(winOpts.exists ? { exists: winOpts.exists } : {}) });
97
97
  return { ...base, ...wrapped };
98
98
  }
@@ -102,7 +102,7 @@ function baseSpawnTarget(role, detail, realBin) {
102
102
  const alias = ROLE_ALIASES[role];
103
103
  if (!alias) return { command: realBin };
104
104
  try {
105
- const { aliasBinFor, smArgv0 } = require('./procName.cjs');
105
+ const { aliasBinFor, smArgv0 } = require('../process/procName.cjs');
106
106
  const command = aliasBinFor(realBin, alias);
107
107
  if (command === realBin) return { command: realBin };
108
108
  return { command, argv0: smArgv0(role, detail) };
@@ -114,7 +114,7 @@ function baseSpawnTarget(role, detail, realBin) {
114
114
  // ---------- version probe ----------
115
115
  //
116
116
  // `claude --version`, cached. The scheduler's launch circuit breaker
117
- // (lib/launchFailure.cjs) records the CLI version a launch block was armed
117
+ // (lib/scheduler/launchFailure.cjs) records the CLI version a launch block was armed
118
118
  // under and drops the block the moment the version changes — the incident
119
119
  // behind it (issue #11: an outdated CLI sending a thinking parameter the
120
120
  // model rejects) is fixed by `claude update`, and the queue must notice