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.
- package/README.md +3 -3
- package/bin/cli.cjs +16 -4
- package/bin/node-floor.cjs +41 -0
- package/dist/assets/DataModel-CXaH2GED.js +1 -0
- package/dist/assets/{History-Bfdoywlh.js → History-Cerii-HA.js} +2 -2
- package/dist/assets/{Hooks-CKDJjTJV.js → Hooks-aXMb5LDy.js} +3 -3
- package/dist/assets/{Library-7akfgy67.js → Library-WrJFKEOJ.js} +1 -1
- package/dist/assets/{MarkdownEditor-DDesiqet.js → MarkdownEditor-D1BMCXS7.js} +1 -1
- package/dist/assets/{McpServers-D4lZtXof.js → McpServers-Cf0davLd.js} +2 -2
- package/dist/assets/{Memory-CeI8G1w5.js → Memory-Dn6NHWPe.js} +6 -6
- package/dist/assets/Permissions-CTVuFPjg.js +3 -0
- package/dist/assets/{Plugins-P4eCXy_S.js → Plugins-C2TyF8Mn.js} +2 -2
- package/dist/assets/ProvenanceBadge-F_jwHSwE.js +1 -0
- package/dist/assets/{SaveBar-l9jnEMES.js → SaveBar-DA1KVJST.js} +1 -1
- package/dist/assets/Scheduler-Bm6Q_hlu.js +16 -0
- package/dist/assets/{ScopeSwitcher-CjJi8ST5.js → ScopeSwitcher-BygZlJca.js} +1 -1
- package/dist/assets/Settings-BYCiv5KV.js +3 -0
- package/dist/assets/{SkillReferenceGraph-CjbO01Sg.js → SkillReferenceGraph-CcLnl9np.js} +1 -1
- package/dist/assets/{Skills-BxZ9_fCR.js → Skills-ChffsdTD.js} +2 -2
- package/dist/assets/{SystemPrompt-D8vfFb8b.js → SystemPrompt-dNkfHE_M.js} +1 -1
- package/dist/assets/{TagLibrary-2vzUo7YL.js → TagLibrary-jVlEuB0m.js} +1 -1
- package/dist/assets/{TiptapBody-B8ZfbK90.js → TiptapBody-6_cdwcP0.js} +1 -1
- package/dist/assets/{Toggle-BbW4nGGf.js → Toggle-CVXqGpAP.js} +1 -1
- package/dist/assets/ViewTabs-DO1YVbpc.js +1 -0
- package/dist/assets/{index-CKH5Uxik.css → index-D89EUizB.css} +1 -1
- package/dist/assets/{index-Cd98Q1lD.js → index-DbCQPWWY.js} +747 -752
- package/dist/assets/{settingsSchema-IhUfucCF.js → settingsSchema-Wrvn-Yz1.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +25 -29
- package/plugins/CLAUDE.md +6 -6
- package/plugins/session-manager-dev/skills/builder/4-manual/SKILL.md +21 -19
- package/plugins/session-manager-dev/skills/builder/SKILL.md +3 -3
- package/plugins/session-manager-dev/skills/develop/SKILL.md +254 -510
- package/plugins/session-manager-dev/skills/develop/standards.md +17 -22
- package/scripts/README.md +3 -11
- package/scripts/audit-ops-hygiene.cjs +3 -3
- package/scripts/hooks/lib/guard-prd-writes-policy.cjs +1 -1
- package/scripts/hooks/lib/guard-self-schedule-policy.cjs +1 -1
- package/scripts/mint-epic.cjs +2 -3
- package/scripts/scheduler-mcp-server.cjs +64 -7
- package/src/main/agentLibrary.cjs +22 -2
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +4 -3
- package/src/main/config.cjs +41 -38
- package/src/main/docEdit.cjs +4 -1
- package/src/main/files.cjs +2 -5
- package/src/main/health.cjs +1 -1
- package/src/main/index.cjs +40 -11
- package/src/main/ipcSchemas.cjs +35 -34
- package/src/main/lib/agentPersonaSchema.cjs +13 -2
- package/src/main/lib/atomicFs.cjs +116 -0
- package/src/main/lib/branchSweep.cjs +13 -12
- package/src/main/lib/buildTarget.cjs +3 -3
- package/src/main/lib/builtinMacros.cjs +39 -0
- package/src/main/lib/claudeCliCaps.cjs +129 -0
- package/src/main/lib/credentials.cjs +2 -4
- package/src/main/lib/crossProjectFeedback.cjs +3 -3
- package/src/main/lib/cwdClassify.cjs +15 -3
- package/src/main/lib/definitionOfDone.cjs +207 -125
- package/src/main/lib/dodDrainHook.cjs +11 -5
- package/src/main/lib/epicMint.cjs +2 -4
- package/src/main/lib/epicStatusMirror.cjs +8 -10
- package/src/main/lib/epicWorktreeProjectConfig.cjs +2 -4
- package/src/main/lib/gateAuthority.cjs +96 -0
- package/src/main/lib/gitExec.cjs +69 -0
- package/src/main/lib/gitWorktree.cjs +656 -92
- package/src/main/lib/instanceLock.cjs +5 -8
- package/src/main/lib/launchFailure.cjs +2 -3
- package/src/main/lib/macroLibrary.cjs +480 -0
- package/src/main/lib/mcpToolCatalog.cjs +49 -17
- package/src/main/lib/needsReviewLedger.cjs +1 -1
- package/src/main/lib/opsErrorLog.cjs +11 -1
- package/src/main/lib/opsOwnership.cjs +5 -9
- package/src/main/lib/pidAlive.cjs +32 -0
- package/src/main/lib/prdCreate.cjs +121 -12
- package/src/main/lib/prdDisposition.cjs +2 -2
- package/src/main/lib/prdGateFiles.cjs +284 -0
- package/src/main/lib/prdLocations.cjs +61 -0
- package/src/main/lib/prdMigration.cjs +2 -3
- package/src/main/lib/prdSizing.cjs +2 -1
- package/src/main/lib/projectHomeAdminRoutes.cjs +136 -21
- package/src/main/lib/promptSessionSchema.cjs +10 -2
- package/src/main/lib/rcaReport.cjs +4 -6
- package/src/main/lib/reaperHelpers.cjs +8 -1
- package/src/main/lib/reservationExpiry.cjs +6 -1
- package/src/main/lib/reviewNotice.cjs +263 -0
- package/src/main/lib/runClaudeP.cjs +4 -1
- package/src/main/lib/schedulerPaths.cjs +22 -2
- package/src/main/lib/sessionSlots.cjs +2 -4
- package/src/main/lib/shippedPersonaSeeds.cjs +226 -0
- package/src/main/lib/smfileHeaders.cjs +66 -0
- package/src/main/lib/timeoutShim.cjs +123 -0
- package/src/main/lib/timeoutShimScript.cjs +275 -0
- package/src/main/lib/upgradeDrain.cjs +4 -10
- package/src/main/lib/watchdogHelpers.cjs +12 -25
- package/src/main/lib/workTypeLibrary.cjs +7 -1
- package/src/main/projectPages.cjs +43 -13
- package/src/main/promptSessionEvents.cjs +37 -13
- package/src/main/scheduler.cjs +910 -198
- package/src/main/seedAgentPersonas.cjs +279 -24
- package/src/main/supervisor.cjs +4 -1
- package/src/main/templates/PRD_AUTHORING.md +126 -406
- package/src/preload/__tests__/preload-surface.test.cjs +68 -0
- package/src/preload/api.d.ts +53 -94
- package/src/preload/index.cjs +14 -9
- package/src/seed/agents/architect.md +2 -0
- package/src/seed/agents/demo-video-builder.md +84 -0
- package/src/seed/agents/dev-lead.md +18 -18
- package/src/seed/agents/project-home-builder.md +66 -35
- package/src/seed/agents/validator.md +10 -4
- package/dist/assets/DataModel-DCEgMTjH.js +0 -1
- package/dist/assets/HostBilko-CDVHE0hT.js +0 -1
- package/dist/assets/Permissions-BGleLja4.js +0 -3
- package/dist/assets/ProvenanceBadge-BFczzI1B.js +0 -1
- package/dist/assets/Scheduler-C_phpeUS.js +0 -16
- package/dist/assets/Settings-BIwZ3FGQ.js +0 -3
- package/src/main/__tests__/activeIndexMerge.test.cjs +0 -235
- package/src/main/__tests__/agentEffortResolve.test.cjs +0 -117
- package/src/main/__tests__/agentLibrary.test.cjs +0 -276
- package/src/main/__tests__/agentModelResolve.test.cjs +0 -311
- package/src/main/__tests__/agentOverlayWrite.test.cjs +0 -95
- package/src/main/__tests__/bilkoHost-deriveSlug.test.cjs +0 -26
- package/src/main/__tests__/bilkoHost-integration.test.cjs +0 -118
- package/src/main/__tests__/bilkoHostCore.test.cjs +0 -72
- package/src/main/__tests__/broadcastCoalescer.test.cjs +0 -122
- package/src/main/__tests__/chat-cancel-terminal.test.cjs +0 -120
- package/src/main/__tests__/chat-dead-channels.test.cjs +0 -63
- package/src/main/__tests__/chat-exit-close-race.test.cjs +0 -146
- package/src/main/__tests__/chat-mcp-consent-notice.test.cjs +0 -139
- package/src/main/__tests__/chat-preamble-anchors.test.cjs +0 -100
- package/src/main/__tests__/chat-queue.test.cjs +0 -97
- package/src/main/__tests__/chat-stop-signal.test.cjs +0 -89
- package/src/main/__tests__/chatRunner-epic-worktree-execcwd.test.cjs +0 -125
- package/src/main/__tests__/chatRunner-session-flag-retry.test.cjs +0 -252
- package/src/main/__tests__/classifyPromptTicket.test.cjs +0 -101
- package/src/main/__tests__/classifyTranscriptLine.test.cjs +0 -201
- package/src/main/__tests__/computeDepHistorySatisfaction.test.cjs +0 -66
- package/src/main/__tests__/config-readText-bounded.test.cjs +0 -84
- package/src/main/__tests__/configWriteBoundaryOwners.test.cjs +0 -59
- package/src/main/__tests__/crossProjectFeedback.test.cjs +0 -334
- package/src/main/__tests__/crossProjectFeedbackRoutes.test.cjs +0 -161
- package/src/main/__tests__/dep-orphan-archive-health.test.cjs +0 -77
- package/src/main/__tests__/develop-skill-failure-modes.test.cjs +0 -70
- package/src/main/__tests__/docEdit.test.cjs +0 -244
- package/src/main/__tests__/dod-batchkey.test.cjs +0 -183
- package/src/main/__tests__/dod-drain-hook.test.cjs +0 -302
- package/src/main/__tests__/dod-report.test.cjs +0 -304
- package/src/main/__tests__/dod-reverify.test.cjs +0 -285
- package/src/main/__tests__/epicContextDigest.test.cjs +0 -174
- package/src/main/__tests__/epicMint.test.cjs +0 -332
- package/src/main/__tests__/epicMintTelemetryTap.test.cjs +0 -64
- package/src/main/__tests__/epicStatusMirror.test.cjs +0 -110
- package/src/main/__tests__/epicValidationHook.test.cjs +0 -291
- package/src/main/__tests__/exchanges.test.cjs +0 -122
- package/src/main/__tests__/exchangesPromptId.test.cjs +0 -61
- package/src/main/__tests__/extractJson.test.cjs +0 -51
- package/src/main/__tests__/files-reject-credentials.test.cjs +0 -40
- package/src/main/__tests__/fixtures/1218-fo-01-move-scripts-lib-into-src-main-lib.log +0 -556
- package/src/main/__tests__/flatPrdTickSweep.test.cjs +0 -110
- package/src/main/__tests__/health-build-freshness.test.cjs +0 -39
- package/src/main/__tests__/health-claude-md-budget.test.cjs +0 -57
- package/src/main/__tests__/health-credentials.test.cjs +0 -81
- package/src/main/__tests__/health-delegation-chain.test.cjs +0 -124
- package/src/main/__tests__/health-per-project-stall.test.cjs +0 -84
- package/src/main/__tests__/health-prd-migration.test.cjs +0 -37
- package/src/main/__tests__/health-queue-dispatch.test.cjs +0 -135
- package/src/main/__tests__/health-starve-escalation.test.cjs +0 -94
- package/src/main/__tests__/health-tick-liveness.test.cjs +0 -179
- package/src/main/__tests__/health-usage-poller.test.cjs +0 -144
- package/src/main/__tests__/health-worktree-cap-blocked.test.cjs +0 -65
- package/src/main/__tests__/heapSnapshot.test.cjs +0 -121
- package/src/main/__tests__/historyAggregatorIntraday.test.cjs +0 -313
- package/src/main/__tests__/historyDashboard.test.cjs +0 -163
- package/src/main/__tests__/historyRollup.test.cjs +0 -333
- package/src/main/__tests__/intradayRefresh.test.cjs +0 -39
- package/src/main/__tests__/ipcSchemas-dependsOn.test.cjs +0 -39
- package/src/main/__tests__/kg-augment.test.cjs +0 -195
- package/src/main/__tests__/loadGateDetailTick.test.cjs +0 -31
- package/src/main/__tests__/machineProfile.test.cjs +0 -152
- package/src/main/__tests__/mcpStatus.test.cjs +0 -61
- package/src/main/__tests__/memoryAggregate.test.cjs +0 -109
- package/src/main/__tests__/memoryStale.test.cjs +0 -88
- package/src/main/__tests__/needsReviewLedger.test.cjs +0 -162
- package/src/main/__tests__/openExternalApp-spawn-error.test.cjs +0 -25
- package/src/main/__tests__/opsErrorLog.test.cjs +0 -109
- package/src/main/__tests__/opsErrorLogTelemetryTap.test.cjs +0 -173
- package/src/main/__tests__/personaMerge.test.cjs +0 -169
- package/src/main/__tests__/planValidator.test.cjs +0 -125
- package/src/main/__tests__/pollLoop-dispatch-on-failure.test.cjs +0 -176
- package/src/main/__tests__/prd-group-allocator.test.cjs +0 -119
- package/src/main/__tests__/prdAdminRouteParity.test.cjs +0 -70
- package/src/main/__tests__/prdAdminRoutes.test.cjs +0 -718
- package/src/main/__tests__/prdAgentType.test.cjs +0 -103
- package/src/main/__tests__/prdAuthoringSeed.test.cjs +0 -39
- package/src/main/__tests__/prdCreate.test.cjs +0 -979
- package/src/main/__tests__/prdCreateAdoption.test.cjs +0 -205
- package/src/main/__tests__/prdCreateDisposition.test.cjs +0 -201
- package/src/main/__tests__/prdCreatePlanId.test.cjs +0 -132
- package/src/main/__tests__/prdFrontmatterAgentType.test.cjs +0 -117
- package/src/main/__tests__/prdFrontmatterDependsOn.test.cjs +0 -136
- package/src/main/__tests__/prdFrontmatterDisposition.test.cjs +0 -125
- package/src/main/__tests__/prdFrontmatterQuietMachine.test.cjs +0 -108
- package/src/main/__tests__/prdLocations.test.cjs +0 -195
- package/src/main/__tests__/prdLocationsArchived.test.cjs +0 -201
- package/src/main/__tests__/prdMigration.test.cjs +0 -349
- package/src/main/__tests__/prdMigrationLegacyAdopt.test.cjs +0 -91
- package/src/main/__tests__/prdParserHighWater.test.cjs +0 -74
- package/src/main/__tests__/prdParserSourcePromptId.test.cjs +0 -65
- package/src/main/__tests__/prdSetDisposition.test.cjs +0 -222
- package/src/main/__tests__/prdSizing.test.cjs +0 -106
- package/src/main/__tests__/prdSourcePromptIdBackfill.test.cjs +0 -118
- package/src/main/__tests__/prdUpdateDependsOn.test.cjs +0 -160
- package/src/main/__tests__/proc-role-env.test.cjs +0 -125
- package/src/main/__tests__/procname-claude-spawn-sites.test.cjs +0 -304
- package/src/main/__tests__/procname-sm-processes.test.cjs +0 -127
- package/src/main/__tests__/projectHomeAdminRoutes.test.cjs +0 -177
- package/src/main/__tests__/projectPages.test.cjs +0 -137
- package/src/main/__tests__/promptSessionEvents.test.cjs +0 -234
- package/src/main/__tests__/promptSessionSchema.test.cjs +0 -101
- package/src/main/__tests__/promptSessionTranscript.test.cjs +0 -0
- package/src/main/__tests__/promptSessionsCreateEpicHandler.test.cjs +0 -159
- package/src/main/__tests__/pty-epic-worktree-spawn-cwd.test.cjs +0 -282
- package/src/main/__tests__/pty-session-open-telemetry.test.cjs +0 -96
- package/src/main/__tests__/pty-write-result.test.cjs +0 -46
- package/src/main/__tests__/queue-health-verdict.test.cjs +0 -170
- package/src/main/__tests__/queue-starvation-dispatch-driver.test.cjs +0 -286
- package/src/main/__tests__/queue-starvation-per-project.test.cjs +0 -147
- package/src/main/__tests__/queueHistory.test.cjs +0 -355
- package/src/main/__tests__/queueOps-interactive-ac-lint.test.cjs +0 -65
- package/src/main/__tests__/queueOpsArchiveDestination.test.cjs +0 -65
- package/src/main/__tests__/queueOpsAutoArchive.test.cjs +0 -211
- package/src/main/__tests__/rateLimitPollerStreak.test.cjs +0 -128
- package/src/main/__tests__/rcaReport.test.cjs +0 -266
- package/src/main/__tests__/reconcileFlatPrdSweep.test.cjs +0 -119
- package/src/main/__tests__/reconcileTiming.test.cjs +0 -135
- package/src/main/__tests__/runLogRetention.test.cjs +0 -489
- package/src/main/__tests__/runVerify-atomic-verdicts.test.cjs +0 -26
- package/src/main/__tests__/runVerify-blocked-by-foreign-wip.test.cjs +0 -58
- package/src/main/__tests__/runVerify-landed-commit-outranks.test.cjs +0 -191
- package/src/main/__tests__/runVerify-policy-denial.test.cjs +0 -89
- package/src/main/__tests__/runVerify-transcript-commit-evidence.test.cjs +0 -225
- package/src/main/__tests__/runVerify.test.cjs +0 -1784
- package/src/main/__tests__/scheduleJobSchema.test.cjs +0 -127
- package/src/main/__tests__/scheduleJobStatusDrift.test.cjs +0 -65
- package/src/main/__tests__/scheduleJobTransitions.test.cjs +0 -277
- package/src/main/__tests__/scheduleJobTransitionsGrep.test.cjs +0 -59
- package/src/main/__tests__/scheduleJobTransitionsTelemetryTap.test.cjs +0 -72
- package/src/main/__tests__/scheduler-admin-routes.test.cjs +0 -199
- package/src/main/__tests__/scheduler-adopted-run-supervision.test.cjs +0 -143
- package/src/main/__tests__/scheduler-already-satisfied-on-main.test.cjs +0 -105
- package/src/main/__tests__/scheduler-archive-completed-prd.test.cjs +0 -102
- package/src/main/__tests__/scheduler-archived-twin-guard.test.cjs +0 -155
- package/src/main/__tests__/scheduler-autofix-outcome.test.cjs +0 -188
- package/src/main/__tests__/scheduler-autofix-select.test.cjs +0 -439
- package/src/main/__tests__/scheduler-autopromote.test.cjs +0 -51
- package/src/main/__tests__/scheduler-bash-timeout-env.test.cjs +0 -101
- package/src/main/__tests__/scheduler-blocked-by-foreign-wip.test.cjs +0 -107
- package/src/main/__tests__/scheduler-boot-orphans.test.cjs +0 -153
- package/src/main/__tests__/scheduler-broadcast-reconcile.test.cjs +0 -121
- package/src/main/__tests__/scheduler-clear-queue-history.test.cjs +0 -134
- package/src/main/__tests__/scheduler-commit-guard-noop.test.cjs +0 -244
- package/src/main/__tests__/scheduler-committed-in-window.test.cjs +0 -182
- package/src/main/__tests__/scheduler-cross-project-batch.test.cjs +0 -43
- package/src/main/__tests__/scheduler-default-eligible-heal.test.cjs +0 -168
- package/src/main/__tests__/scheduler-dispatch-loop.test.cjs +0 -58
- package/src/main/__tests__/scheduler-effective-concurrency.test.cjs +0 -81
- package/src/main/__tests__/scheduler-epic-digest.test.cjs +0 -227
- package/src/main/__tests__/scheduler-failed-autoreset.test.cjs +0 -121
- package/src/main/__tests__/scheduler-finalize-dispatch-guards.test.cjs +0 -229
- package/src/main/__tests__/scheduler-find-prd-dir.test.cjs +0 -75
- package/src/main/__tests__/scheduler-fix-plan-path.test.cjs +0 -119
- package/src/main/__tests__/scheduler-force-tick-outcome.test.cjs +0 -46
- package/src/main/__tests__/scheduler-foreign-wip-manifest.test.cjs +0 -78
- package/src/main/__tests__/scheduler-gate-shadow.test.cjs +0 -119
- package/src/main/__tests__/scheduler-guard-verdict-autoresolve.test.cjs +0 -390
- package/src/main/__tests__/scheduler-heal-refusal.test.cjs +0 -61
- package/src/main/__tests__/scheduler-heartbeat-payload.test.cjs +0 -80
- package/src/main/__tests__/scheduler-inplace-salvage.test.cjs +0 -323
- package/src/main/__tests__/scheduler-integration-failure-stamp.test.cjs +0 -41
- package/src/main/__tests__/scheduler-investigation-clean-skip.test.cjs +0 -63
- package/src/main/__tests__/scheduler-investigation-prompt.test.cjs +0 -123
- package/src/main/__tests__/scheduler-job-budget.test.cjs +0 -172
- package/src/main/__tests__/scheduler-job-overrun.test.cjs +0 -175
- package/src/main/__tests__/scheduler-launch-failure.test.cjs +0 -199
- package/src/main/__tests__/scheduler-leftover-fields.test.cjs +0 -52
- package/src/main/__tests__/scheduler-leftover-quarantine.test.cjs +0 -199
- package/src/main/__tests__/scheduler-looks-done.test.cjs +0 -537
- package/src/main/__tests__/scheduler-manual-pause.test.cjs +0 -118
- package/src/main/__tests__/scheduler-mechanical-recovery.test.cjs +0 -245
- package/src/main/__tests__/scheduler-meta-code-sha.test.cjs +0 -46
- package/src/main/__tests__/scheduler-mutate-reentrancy.test.cjs +0 -117
- package/src/main/__tests__/scheduler-needs-review-autoresolve.test.cjs +0 -197
- package/src/main/__tests__/scheduler-never-stop.test.cjs +0 -157
- package/src/main/__tests__/scheduler-no-dead-end-status.test.cjs +0 -152
- package/src/main/__tests__/scheduler-no-orphan-run-dir.test.cjs +0 -81
- package/src/main/__tests__/scheduler-notify-originating-tab-transcript.test.cjs +0 -87
- package/src/main/__tests__/scheduler-notify-originating-tab.test.cjs +0 -343
- package/src/main/__tests__/scheduler-periodic-reverify-guard.test.cjs +0 -217
- package/src/main/__tests__/scheduler-porcelain-rename.test.cjs +0 -164
- package/src/main/__tests__/scheduler-prd-missing-skip.test.cjs +0 -161
- package/src/main/__tests__/scheduler-prd-persona-spawn.test.cjs +0 -178
- package/src/main/__tests__/scheduler-quarantine-autoresolve.test.cjs +0 -165
- package/src/main/__tests__/scheduler-quiet-machine-lease.test.cjs +0 -257
- package/src/main/__tests__/scheduler-rate-limit-cooldown-freshness.test.cjs +0 -123
- package/src/main/__tests__/scheduler-rate-limit-pause.test.cjs +0 -152
- package/src/main/__tests__/scheduler-rate-limit-spin-guard.test.cjs +0 -156
- package/src/main/__tests__/scheduler-reap-dead-running-jobs.test.cjs +0 -754
- package/src/main/__tests__/scheduler-reaper-helpers-basics.test.cjs +0 -87
- package/src/main/__tests__/scheduler-reconcile-cwd-preserve.test.cjs +0 -100
- package/src/main/__tests__/scheduler-reconcile-history-backfill.test.cjs +0 -105
- package/src/main/__tests__/scheduler-reconcile-invalid-repair.test.cjs +0 -203
- package/src/main/__tests__/scheduler-reconcile-quarantine.test.cjs +0 -247
- package/src/main/__tests__/scheduler-reset-job-fields-guard.test.cjs +0 -77
- package/src/main/__tests__/scheduler-resume-recovery.test.cjs +0 -254
- package/src/main/__tests__/scheduler-shard-quarantine.test.cjs +0 -115
- package/src/main/__tests__/scheduler-shared-tree-guard.test.cjs +0 -380
- package/src/main/__tests__/scheduler-sigterm-commit.test.cjs +0 -43
- package/src/main/__tests__/scheduler-stall-per-project.test.cjs +0 -126
- package/src/main/__tests__/scheduler-starve-escalation.test.cjs +0 -154
- package/src/main/__tests__/scheduler-stranded-autofix-park.test.cjs +0 -252
- package/src/main/__tests__/scheduler-stranded-investigation.test.cjs +0 -185
- package/src/main/__tests__/scheduler-stuck-failed-escalation.test.cjs +0 -136
- package/src/main/__tests__/scheduler-supervisor-record.test.cjs +0 -81
- package/src/main/__tests__/scheduler-tick-cancel-token.test.cjs +0 -54
- package/src/main/__tests__/scheduler-tick-wedge.test.cjs +0 -172
- package/src/main/__tests__/scheduler-transient-failure.test.cjs +0 -141
- package/src/main/__tests__/scheduler-unreadable-queue-guard.test.cjs +0 -62
- package/src/main/__tests__/scheduler-utilization-hold.test.cjs +0 -89
- package/src/main/__tests__/scheduler-verify-prd-path.test.cjs +0 -109
- package/src/main/__tests__/scheduler-worktree-cap-defer.test.cjs +0 -234
- package/src/main/__tests__/scheduler-worktree-exec-cwd.test.cjs +0 -120
- package/src/main/__tests__/scheduler-writeprd-epic-rollback.test.cjs +0 -105
- package/src/main/__tests__/schedulerBatchRootBlocker.test.cjs +0 -117
- package/src/main/__tests__/schedulerStateSidecarRestore.test.cjs +0 -110
- package/src/main/__tests__/seedAgentPersonas.test.cjs +0 -184
- package/src/main/__tests__/seedSchedulerMcp.test.cjs +0 -211
- package/src/main/__tests__/seedStatus.test.cjs +0 -100
- package/src/main/__tests__/seedValidatorPersona.test.cjs +0 -116
- package/src/main/__tests__/stop-signal-anchor.test.cjs +0 -75
- package/src/main/__tests__/telemetryClient.test.cjs +0 -1055
- package/src/main/__tests__/telemetryContract.test.cjs +0 -930
- package/src/main/__tests__/telemetrySettings.test.cjs +0 -210
- package/src/main/__tests__/transcripts-batch-flush.test.cjs +0 -249
- package/src/main/__tests__/transcripts-doFlush-array.test.cjs +0 -124
- package/src/main/__tests__/transcripts-paged-reads.test.cjs +0 -241
- package/src/main/__tests__/transcripts-worktree-epic-path.test.cjs +0 -154
- package/src/main/__tests__/transcriptsUsageFor.test.cjs +0 -206
- package/src/main/__tests__/uniquePrdNumbers.test.cjs +0 -153
- package/src/main/__tests__/usageSingleFlight.test.cjs +0 -169
- package/src/main/__tests__/validationSentinels.test.cjs +0 -84
- package/src/main/__tests__/workTypeLibrary.test.cjs +0 -89
- package/src/main/bilkoHost.cjs +0 -314
- package/src/main/bilkoHostCore.cjs +0 -89
- package/src/main/lib/__tests__/active-sessions.test.cjs +0 -251
- package/src/main/lib/__tests__/activeIndexRebuild.test.cjs +0 -179
- package/src/main/lib/__tests__/agentPersonaSchema.test.cjs +0 -67
- package/src/main/lib/__tests__/auditLog.test.cjs +0 -38
- package/src/main/lib/__tests__/bootSelfHeal.test.cjs +0 -107
- package/src/main/lib/__tests__/branchSweep.test.cjs +0 -164
- package/src/main/lib/__tests__/buildIdentity.test.cjs +0 -121
- package/src/main/lib/__tests__/buildTarget.test.cjs +0 -52
- package/src/main/lib/__tests__/childWithLog.test.cjs +0 -321
- package/src/main/lib/__tests__/coldBootPromptSessionsWrite.test.cjs +0 -87
- package/src/main/lib/__tests__/crashTelemetry.test.cjs +0 -103
- package/src/main/lib/__tests__/credentials-futile-refresh.test.cjs +0 -115
- package/src/main/lib/__tests__/cwdClassify.test.cjs +0 -111
- package/src/main/lib/__tests__/definitionOfDoneSequence.test.cjs +0 -95
- package/src/main/lib/__tests__/delegationReadiness.test.cjs +0 -1175
- package/src/main/lib/__tests__/dispatchLoop.test.cjs +0 -63
- package/src/main/lib/__tests__/effectiveModelInfo.test.cjs +0 -244
- package/src/main/lib/__tests__/ephemeralCwd.test.cjs +0 -91
- package/src/main/lib/__tests__/epicDelegationStats.test.cjs +0 -137
- package/src/main/lib/__tests__/epicSpawnCwd.test.cjs +0 -283
- package/src/main/lib/__tests__/epicSpawnPlan.test.cjs +0 -196
- package/src/main/lib/__tests__/epicTranscriptPath.test.cjs +0 -163
- package/src/main/lib/__tests__/epicWorktreeBoot.test.cjs +0 -136
- package/src/main/lib/__tests__/epicWorktreeMerge.test.cjs +0 -130
- package/src/main/lib/__tests__/epicWorktreeMint.test.cjs +0 -117
- package/src/main/lib/__tests__/epicWorktreeProjectConfig.test.cjs +0 -137
- package/src/main/lib/__tests__/fixChainDepth.test.cjs +0 -40
- package/src/main/lib/__tests__/fixtures/204-mercury-steam-horse.log.txt +0 -13
- package/src/main/lib/__tests__/fixtures/scheduler-machine.json.corrupt-1789147548 +0 -34
- package/src/main/lib/__tests__/gateFixtures.json +0 -20
- package/src/main/lib/__tests__/gitCacheBound.test.cjs +0 -69
- package/src/main/lib/__tests__/gitWorktree.test.cjs +0 -1478
- package/src/main/lib/__tests__/gitWorktreeSalvage.test.cjs +0 -107
- package/src/main/lib/__tests__/gitWorktreeSalvageDelta.test.cjs +0 -153
- package/src/main/lib/__tests__/guardShims.test.cjs +0 -158
- package/src/main/lib/__tests__/importReferences.spec.cjs +0 -56
- package/src/main/lib/__tests__/instanceLock.test.cjs +0 -173
- package/src/main/lib/__tests__/jobSupervisorRecord.test.cjs +0 -78
- package/src/main/lib/__tests__/jobWorktree.test.cjs +0 -199
- package/src/main/lib/__tests__/jobWorktreeBootLive.test.cjs +0 -82
- package/src/main/lib/__tests__/landedSinceRun.test.cjs +0 -133
- package/src/main/lib/__tests__/launchFailure.test.cjs +0 -220
- package/src/main/lib/__tests__/loadGate.test.cjs +0 -303
- package/src/main/lib/__tests__/localAdminHttp.test.cjs +0 -214
- package/src/main/lib/__tests__/loopDelay.test.cjs +0 -68
- package/src/main/lib/__tests__/mcpToolCatalog.test.cjs +0 -107
- package/src/main/lib/__tests__/modelCatalog.test.cjs +0 -202
- package/src/main/lib/__tests__/opsOwnership.test.cjs +0 -113
- package/src/main/lib/__tests__/opsRootAbsoluteCwd.test.cjs +0 -328
- package/src/main/lib/__tests__/opsRootNestedWrite.test.cjs +0 -51
- package/src/main/lib/__tests__/opsRootResolve.test.cjs +0 -149
- package/src/main/lib/__tests__/prdDeclaredPaths.test.cjs +0 -82
- package/src/main/lib/__tests__/prdDisposition.test.cjs +0 -224
- package/src/main/lib/__tests__/procIdentity.test.cjs +0 -119
- package/src/main/lib/__tests__/procName.test.cjs +0 -92
- package/src/main/lib/__tests__/projectBriefCore.test.cjs +0 -216
- package/src/main/lib/__tests__/projectRootResolve.test.cjs +0 -148
- package/src/main/lib/__tests__/queueHealth.test.cjs +0 -58
- package/src/main/lib/__tests__/queueStoreAtomicWrite.test.cjs +0 -88
- package/src/main/lib/__tests__/queueStoreMachineStateRecovery.test.cjs +0 -190
- package/src/main/lib/__tests__/quietMachineLease.test.cjs +0 -39
- package/src/main/lib/__tests__/rateLimitWindow.test.cjs +0 -88
- package/src/main/lib/__tests__/reaperHelpers.test.cjs +0 -577
- package/src/main/lib/__tests__/schedulerBatchDepends.test.cjs +0 -312
- package/src/main/lib/__tests__/schedulerBatchFairness.test.cjs +0 -213
- package/src/main/lib/__tests__/schedulerBatchLaunchHold.test.cjs +0 -125
- package/src/main/lib/__tests__/schedulerBatchProjectCap.test.cjs +0 -127
- package/src/main/lib/__tests__/schedulerBatchQuietMachine.test.cjs +0 -109
- package/src/main/lib/__tests__/schedulerMcpServerHeadlessRefusal.test.cjs +0 -71
- package/src/main/lib/__tests__/schedulerMcpServerHelp.test.cjs +0 -216
- package/src/main/lib/__tests__/schedulerMcpServerProjectHome.test.cjs +0 -183
- package/src/main/lib/__tests__/schedulerPaths.test.cjs +0 -226
- package/src/main/lib/__tests__/schedulerPathsWorktree.test.cjs +0 -133
- package/src/main/lib/__tests__/schedulerRuntimeState.test.cjs +0 -56
- package/src/main/lib/__tests__/sessionSlots.test.cjs +0 -144
- package/src/main/lib/__tests__/telemetryBacklog.test.cjs +0 -626
- package/src/main/lib/__tests__/telemetryBoot.test.cjs +0 -134
- package/src/main/lib/__tests__/telemetryConsent.test.cjs +0 -136
- package/src/main/lib/__tests__/telemetryCounters.test.cjs +0 -57
- package/src/main/lib/__tests__/telemetryCountersMetadataColumn.test.cjs +0 -98
- package/src/main/lib/__tests__/terminalRunOutcome.test.cjs +0 -200
- package/src/main/lib/__tests__/toolUseClassify.test.cjs +0 -53
- package/src/main/lib/__tests__/updateCheck.test.cjs +0 -63
- package/src/main/lib/__tests__/upgradeDrain.test.cjs +0 -130
- package/src/main/lib/__tests__/usageCircuit.test.cjs +0 -354
- package/src/main/lib/__tests__/watchdog-helpers.test.cjs +0 -441
- package/src/main/lib/__tests__/watchdog-relaunch.test.cjs +0 -266
- package/src/main/lib/kgExchangePairing.cjs +0 -75
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* jobs finishing in <=10 min, yet nothing at the authoring gate flags an oversized PRD before
|
|
6
6
|
* it lands. `sizingWarnings` is the single rule set; prdCreate.cjs's createPrd() surfaces its
|
|
7
7
|
* output in the create-prd response, and scheduler-mcp-server.cjs's scheduler_create_prd
|
|
8
|
-
* handler prints it as a "
|
|
8
|
+
* handler prints it as part of a "Warnings:" block (merged with the gate/files warnings
|
|
9
|
+
* from prdGateFiles.cjs). Warnings never block a write.
|
|
9
10
|
*/
|
|
10
11
|
'use strict';
|
|
11
12
|
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* projectHomeAdminRoutes.cjs — the
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* see opsOwnership.cjs). Registered
|
|
7
|
-
* localAdminHttp.cjs transport as
|
|
2
|
+
* projectHomeAdminRoutes.cjs — the two admin routes behind the
|
|
3
|
+
* project_home_write MCP tool and its demo-video sibling:
|
|
4
|
+
* POST /admin/project-home/write {cwd, html} -> project-pages/home.html
|
|
5
|
+
* POST /admin/project-home/demo-video/write {cwd, html} -> project-pages/demo-video/index.html
|
|
6
|
+
* both owned by writer 'project-home' (see opsOwnership.cjs). Registered
|
|
7
|
+
* against the same injected localAdminHttp.cjs transport as
|
|
8
|
+
* prdAdminRoutes.cjs.
|
|
8
9
|
*
|
|
9
10
|
* "Self-contained" is enforced here, not trusted: the document must not
|
|
10
11
|
* reference any remote resource (`<script src>`, `<link href=http*>`,
|
|
11
12
|
* remote `@import` / `url(http*)`), so opening it never causes network egress.
|
|
13
|
+
*
|
|
14
|
+
* The demo-video document runs inline JavaScript (the home page does not), so
|
|
15
|
+
* it additionally rejects network-capable APIs (fetch, WebSocket, dynamic
|
|
16
|
+
* import, …) and has a Content-Security-Policy meta stamped into <head>
|
|
17
|
+
* before it is written — the real network fence, since the viewer renders it
|
|
18
|
+
* via smfile:// in a sandboxed iframe that sends no CSP header itself. The
|
|
19
|
+
* regex checks below are defence in depth, not the control.
|
|
12
20
|
*/
|
|
13
21
|
'use strict';
|
|
14
22
|
|
|
@@ -21,8 +29,9 @@ const config = require('../config.cjs');
|
|
|
21
29
|
const { schemas } = require('../ipcSchemas.cjs');
|
|
22
30
|
|
|
23
31
|
const MAX_HTML_BYTES = 1024 * 1024;
|
|
32
|
+
const MAX_DEMO_VIDEO_BYTES = 2 * 1024 * 1024;
|
|
24
33
|
|
|
25
|
-
// Each detector is a linear regex scan; the input is capped
|
|
34
|
+
// Each detector is a linear regex scan; the input is capped first.
|
|
26
35
|
const REMOTE_REFERENCE_CHECKS = [
|
|
27
36
|
{ re: /<script\b[^>]*\bsrc\s*=/i, message: '<script src> is not allowed — inline all scripts' },
|
|
28
37
|
{ re: /<link\b[^>]*\bhref\s*=\s*["']?\s*(?:https?:)?\/\//i, message: '<link href="http(s)://…"> is not allowed — inline all styles' },
|
|
@@ -30,6 +39,43 @@ const REMOTE_REFERENCE_CHECKS = [
|
|
|
30
39
|
{ re: /url\(\s*["']?\s*(?:https?:)?\/\//i, message: 'url(http(s)://…) is not allowed — embed assets as data: URIs' },
|
|
31
40
|
];
|
|
32
41
|
|
|
42
|
+
// Demo-video documents run inline JS; these reject the network-capable
|
|
43
|
+
// surface a self-contained, CSP-fenced document must never reach for.
|
|
44
|
+
const NETWORK_CHECKS = [
|
|
45
|
+
{ re: /\bfetch\s*\(/i, message: 'fetch(...) is not allowed' },
|
|
46
|
+
{ re: /\bXMLHttpRequest\b/i, message: 'XMLHttpRequest is not allowed' },
|
|
47
|
+
{ re: /\bWebSocket\b/i, message: 'WebSocket is not allowed' },
|
|
48
|
+
{ re: /\bEventSource\b/i, message: 'EventSource is not allowed' },
|
|
49
|
+
{ re: /\bsendBeacon\b/i, message: 'sendBeacon is not allowed' },
|
|
50
|
+
{ re: /\bimport\s*\(/i, message: 'import(...) is not allowed' },
|
|
51
|
+
{ re: /\bimportScripts\b/i, message: 'importScripts is not allowed' },
|
|
52
|
+
{ re: /<iframe\b/i, message: '<iframe> is not allowed' },
|
|
53
|
+
{ re: /<object\b/i, message: '<object> is not allowed' },
|
|
54
|
+
{ re: /<embed\b/i, message: '<embed> is not allowed' },
|
|
55
|
+
{ re: /\bwindow\.open\b/i, message: 'window.open is not allowed' },
|
|
56
|
+
{ re: /\b(?:src|href)\s*=\s*["']?\s*(?:https?:)?\/\//i, message: 'src=/href= pointing at http(s): or // is not allowed' },
|
|
57
|
+
{ re: /["'`](?:fetch|XMLHttpRequest|WebSocket|EventSource|sendBeacon|open|importScripts)["'`]/i, message: 'computed/bracket access to a network API (e.g. window["fetch"]) is not allowed' },
|
|
58
|
+
{ re: /\bWorker\s*\(/i, message: 'Worker(...) is not allowed' },
|
|
59
|
+
{ re: /\bSharedWorker\b/i, message: 'SharedWorker is not allowed' },
|
|
60
|
+
{ re: /\bserviceWorker\b/i, message: 'serviceWorker is not allowed' },
|
|
61
|
+
{ re: /rel\s*=\s*["']?\s*(?:prefetch|preconnect|dns-prefetch|preload)/i, message: 'rel="prefetch|preconnect|dns-prefetch|preload" is not allowed' },
|
|
62
|
+
{ re: /\beval\s*\(/i, message: 'eval(...) is not allowed' },
|
|
63
|
+
{ re: /\bFunction\s*\(/i, message: 'Function(...) is not allowed' },
|
|
64
|
+
{ re: /<base\b/i, message: '<base> is not allowed' },
|
|
65
|
+
{ re: /<form\b/i, message: '<form> is not allowed' },
|
|
66
|
+
{ re: /http-equiv\s*=\s*["']?refresh/i, message: 'meta refresh is not allowed' },
|
|
67
|
+
{ re: /\blocation\s*(?:\.\s*(?:href|assign|replace)\b|=[^=])/i, message: 'location.href/assign/replace/= navigation is not allowed' },
|
|
68
|
+
{ re: /\bdocument\.location\b/i, message: 'document.location is not allowed' },
|
|
69
|
+
{ re: /\b(?:top|parent)\./i, message: 'top./parent. property access is not allowed' },
|
|
70
|
+
{ re: /<a\b[^>]*\bhref\s*=\s*["']?\s*(?:https?:|\/\/|javascript:)/i, message: '<a href="http(s):|//|javascript:…"> is not allowed' },
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
const DURATION_META_RE = /<meta\b[^>]*\bname\s*=\s*["']sm-demo-duration["'][^>]*\bcontent\s*=\s*["'](\d+)["'][^>]*>/i;
|
|
74
|
+
const MIN_DEMO_DURATION_S = 5;
|
|
75
|
+
const MAX_DEMO_DURATION_S = 30;
|
|
76
|
+
|
|
77
|
+
const DEMO_VIDEO_CSP = '<meta http-equiv="Content-Security-Policy" content="default-src \'none\'; script-src \'unsafe-inline\'; style-src \'unsafe-inline\'; img-src data: blob:; media-src data: blob:; font-src data:; connect-src \'none\'">';
|
|
78
|
+
|
|
33
79
|
/** -> null when `html` is acceptable, else a human-readable rejection reason. */
|
|
34
80
|
function validateHomeHtml(html) {
|
|
35
81
|
if (typeof html !== 'string' || html.trim().length === 0) return 'html must be a non-empty string';
|
|
@@ -40,6 +86,42 @@ function validateHomeHtml(html) {
|
|
|
40
86
|
return null;
|
|
41
87
|
}
|
|
42
88
|
|
|
89
|
+
/** -> null when `html` is acceptable, else a human-readable rejection reason. */
|
|
90
|
+
function validateDemoVideoHtml(html) {
|
|
91
|
+
if (typeof html !== 'string' || html.trim().length === 0) return 'html must be a non-empty string';
|
|
92
|
+
if (Buffer.byteLength(html, 'utf8') > MAX_DEMO_VIDEO_BYTES) return `html exceeds the ${MAX_DEMO_VIDEO_BYTES}-byte limit`;
|
|
93
|
+
for (const { re, message } of REMOTE_REFERENCE_CHECKS) {
|
|
94
|
+
if (re.test(html)) return `html must be self-contained: ${message}`;
|
|
95
|
+
}
|
|
96
|
+
for (const { re, message } of NETWORK_CHECKS) {
|
|
97
|
+
if (re.test(html)) return `html must not be network-capable: ${message}`;
|
|
98
|
+
}
|
|
99
|
+
const match = html.match(DURATION_META_RE);
|
|
100
|
+
if (!match) {
|
|
101
|
+
return 'html must declare <meta name="sm-demo-duration" content="N"> with '
|
|
102
|
+
+ `${MIN_DEMO_DURATION_S} <= N <= ${MAX_DEMO_DURATION_S}`;
|
|
103
|
+
}
|
|
104
|
+
const duration = Number(match[1]);
|
|
105
|
+
if (!Number.isFinite(duration) || duration < MIN_DEMO_DURATION_S || duration > MAX_DEMO_DURATION_S) {
|
|
106
|
+
return `sm-demo-duration must be between ${MIN_DEMO_DURATION_S} and ${MAX_DEMO_DURATION_S}, got ${match[1]}`;
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Strips any existing CSP meta and a leading doctype, then returns the CSP
|
|
113
|
+
* as the very first element after a fresh `<!DOCTYPE html>` — a position no
|
|
114
|
+
* decoy `<head` text, HTML comment, or string literal in the document can
|
|
115
|
+
* influence. The HTML parser folds a <meta> emitted right after the doctype
|
|
116
|
+
* into the implicitly-created <head>, and a later <html>/<head> start tag is
|
|
117
|
+
* merged/ignored, so the CSP still applies to the whole document.
|
|
118
|
+
*/
|
|
119
|
+
function injectCsp(html) {
|
|
120
|
+
const withoutCsp = html.replace(/<meta\b[^>]*\bhttp-equiv\s*=\s*["']Content-Security-Policy["'][^>]*>\s*/gi, '');
|
|
121
|
+
const withoutDoctype = withoutCsp.replace(/^\s*<!DOCTYPE\b[^>]*>\s*/i, '');
|
|
122
|
+
return `<!DOCTYPE html>${DEMO_VIDEO_CSP}${withoutDoctype}`;
|
|
123
|
+
}
|
|
124
|
+
|
|
43
125
|
/** Same definition crossProjectFeedback.cjs uses for "is this a Session
|
|
44
126
|
* Manager project": it already has an operations root. */
|
|
45
127
|
function isSessionManagerProject(cwd) {
|
|
@@ -79,16 +161,20 @@ function resolveCwd(rawCwd) {
|
|
|
79
161
|
return { ok: true, cwd: realCwd };
|
|
80
162
|
}
|
|
81
163
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
164
|
+
/**
|
|
165
|
+
* Builds a POST handler shared by both routes: read+parse the body, validate
|
|
166
|
+
* against `schema`, resolve cwd, run `validate(html)`, optionally `transform`
|
|
167
|
+
* the html (CSP injection), then write it atomically as writer 'project-home'.
|
|
168
|
+
*/
|
|
169
|
+
function makeWriteHandler({ schema, maxBytes, validate, transform, targetPath }) {
|
|
170
|
+
return async (req, res) => {
|
|
171
|
+
// Allow headroom over maxBytes for JSON escaping; the html byte limit
|
|
172
|
+
// itself is enforced by `validate` below.
|
|
87
173
|
let raw;
|
|
88
174
|
try {
|
|
89
|
-
raw = await readBody(req,
|
|
175
|
+
raw = await readBody(req, maxBytes * 2 + 4096);
|
|
90
176
|
} catch (e) {
|
|
91
|
-
sendJson(res, 400, { ok: false, error: `request body rejected: ${e?.message ?? 'unreadable'} (html limit is ${
|
|
177
|
+
sendJson(res, 400, { ok: false, error: `request body rejected: ${e?.message ?? 'unreadable'} (html limit is ${maxBytes} bytes)` });
|
|
92
178
|
return;
|
|
93
179
|
}
|
|
94
180
|
let body;
|
|
@@ -100,7 +186,7 @@ function registerAdminRoute(adminHttp) {
|
|
|
100
186
|
}
|
|
101
187
|
let input;
|
|
102
188
|
try {
|
|
103
|
-
input =
|
|
189
|
+
input = schema.parse(body);
|
|
104
190
|
} catch (e) {
|
|
105
191
|
sendJson(res, 400, { ok: false, error: 'invalid payload', details: e?.issues ?? e?.message });
|
|
106
192
|
return;
|
|
@@ -110,7 +196,7 @@ function registerAdminRoute(adminHttp) {
|
|
|
110
196
|
sendJson(res, resolved.status, { ok: false, error: resolved.error });
|
|
111
197
|
return;
|
|
112
198
|
}
|
|
113
|
-
const rejection =
|
|
199
|
+
const rejection = validate(input.html);
|
|
114
200
|
if (rejection) {
|
|
115
201
|
sendJson(res, 400, { ok: false, error: rejection });
|
|
116
202
|
return;
|
|
@@ -118,14 +204,43 @@ function registerAdminRoute(adminHttp) {
|
|
|
118
204
|
// Only a route that is actually about to write widens config.cjs's
|
|
119
205
|
// write boundary to this project root.
|
|
120
206
|
config.addAllowedRoot(resolved.cwd);
|
|
207
|
+
const finalHtml = transform ? transform(input.html) : input.html;
|
|
121
208
|
try {
|
|
122
|
-
const
|
|
123
|
-
await
|
|
124
|
-
|
|
209
|
+
const abs = targetPath(resolved.cwd);
|
|
210
|
+
await fs.promises.mkdir(path.dirname(abs), { recursive: true });
|
|
211
|
+
await config.writeTextAtomic(abs, finalHtml, { writer: 'project-home' });
|
|
212
|
+
sendJson(res, 200, { ok: true, path: abs, bytes: Buffer.byteLength(finalHtml, 'utf8') });
|
|
125
213
|
} catch (e) {
|
|
126
214
|
sendJson(res, 500, { ok: false, error: e?.message ?? 'write failed' });
|
|
127
215
|
}
|
|
128
|
-
}
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function registerAdminRoute(adminHttp) {
|
|
220
|
+
// POST /admin/project-home/write {cwd, html}
|
|
221
|
+
adminHttp.registerRoute('POST', '/admin/project-home/write', makeWriteHandler({
|
|
222
|
+
schema: schemas.projectHomeAdminWriteBody,
|
|
223
|
+
maxBytes: MAX_HTML_BYTES,
|
|
224
|
+
validate: validateHomeHtml,
|
|
225
|
+
targetPath: (cwd) => opsPath(cwd, 'project-pages', 'home.html'),
|
|
226
|
+
}));
|
|
227
|
+
|
|
228
|
+
// POST /admin/project-home/demo-video/write {cwd, html}
|
|
229
|
+
adminHttp.registerRoute('POST', '/admin/project-home/demo-video/write', makeWriteHandler({
|
|
230
|
+
schema: schemas.projectDemoVideoAdminWriteBody,
|
|
231
|
+
maxBytes: MAX_DEMO_VIDEO_BYTES,
|
|
232
|
+
validate: validateDemoVideoHtml,
|
|
233
|
+
transform: injectCsp,
|
|
234
|
+
targetPath: (cwd) => opsPath(cwd, 'project-pages', 'demo-video', 'index.html'),
|
|
235
|
+
}));
|
|
129
236
|
}
|
|
130
237
|
|
|
131
|
-
module.exports = {
|
|
238
|
+
module.exports = {
|
|
239
|
+
registerAdminRoute,
|
|
240
|
+
validateHomeHtml,
|
|
241
|
+
validateDemoVideoHtml,
|
|
242
|
+
injectCsp,
|
|
243
|
+
DEMO_VIDEO_CSP,
|
|
244
|
+
MAX_HTML_BYTES,
|
|
245
|
+
MAX_DEMO_VIDEO_BYTES,
|
|
246
|
+
};
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
16
|
const { z } = require('zod');
|
|
17
|
-
const { WorkTypeSchema } = require('./workTypeLibrary.cjs');
|
|
17
|
+
const { WorkTypeSchema, LEGACY_WORK_TYPES } = require('./workTypeLibrary.cjs');
|
|
18
18
|
|
|
19
19
|
// Mirrors EpicTag (src/renderer/lib/tagLibrary.ts:10) — the Epic-level
|
|
20
20
|
// mission tag. Epic tag and PRD tag (ipcSchemas.cjs's scheduleRetagPrd `tag`
|
|
@@ -23,6 +23,14 @@ const { WorkTypeSchema } = require('./workTypeLibrary.cjs');
|
|
|
23
23
|
// own enum literal.
|
|
24
24
|
const EpicTagSchema = WorkTypeSchema;
|
|
25
25
|
|
|
26
|
+
// A legacy tag value (e.g. the retired 'bilko-host-publisher') must keep
|
|
27
|
+
// loading on an old on-disk Epic — dropped silently (treated as absent),
|
|
28
|
+
// never thrown. Any other unknown value still fails via EpicTagSchema.
|
|
29
|
+
const LegacyAwareEpicTagSchema = z.preprocess(
|
|
30
|
+
(v) => (typeof v === 'string' && LEGACY_WORK_TYPES.includes(v) ? undefined : v),
|
|
31
|
+
EpicTagSchema.optional(),
|
|
32
|
+
);
|
|
33
|
+
|
|
26
34
|
// Mirrors EpicSource (src/renderer/state/promptSessions.ts:22-27).
|
|
27
35
|
const EpicSourceSchema = z.object({
|
|
28
36
|
producer: z.enum(['new-epic-ui', 'scheduler-dispatch', 'cross-project-feedback']),
|
|
@@ -69,7 +77,7 @@ const PromptSessionSchema = z.object({
|
|
|
69
77
|
createdAt: z.string(),
|
|
70
78
|
completedAt: z.string().nullable(),
|
|
71
79
|
resumedFromId: z.string().nullable().optional(),
|
|
72
|
-
tag:
|
|
80
|
+
tag: LegacyAwareEpicTagSchema,
|
|
73
81
|
openingPrompt: z.string().nullable().optional(),
|
|
74
82
|
source: EpicSourceSchema.optional(),
|
|
75
83
|
agentType: z.string().optional(),
|
|
@@ -35,6 +35,7 @@ const path = require('node:path');
|
|
|
35
35
|
const { splitFrontmatter } = require('./prdFrontmatter.cjs');
|
|
36
36
|
const { readTail } = require('./fileTail.cjs');
|
|
37
37
|
const { resolvePrdWriteDir } = require('./prdLocations.cjs');
|
|
38
|
+
const atomicFs = require('./atomicFs.cjs');
|
|
38
39
|
|
|
39
40
|
// ─── VERDICT_LABELS — deliberate duplicate ──────────────────────────────────
|
|
40
41
|
// Mirrors src/renderer/components/tabs/scheduler/sched-primitives.tsx:123-131.
|
|
@@ -396,15 +397,12 @@ async function writeRcaReport({ job, runDir, verdict, annotations, investigation
|
|
|
396
397
|
job, verdict, meta, logTail, acText, failureClass, investigationText, annotations,
|
|
397
398
|
});
|
|
398
399
|
|
|
399
|
-
//
|
|
400
|
-
// of this lib uses it: the run directory lives under
|
|
400
|
+
// atomicFs.cjs (not config.cjs's writeTextAtomic) for the same reason the
|
|
401
|
+
// rest of this lib uses it: the run directory lives under
|
|
401
402
|
// ~/.claude/session-manager/scheduled-plans/runs/, which is Session-Manager
|
|
402
403
|
// runtime state, not an OWNERS namespace under a project's operations root.
|
|
403
404
|
const reportPath = path.join(runDir, `root-cause-${job.slug}.md`);
|
|
404
|
-
|
|
405
|
-
const tmp = `${reportPath}.tmp-${process.pid}`;
|
|
406
|
-
fs.writeFileSync(tmp, markdown);
|
|
407
|
-
fs.renameSync(tmp, reportPath);
|
|
405
|
+
atomicFs.writeTextAtomicSync(reportPath, markdown);
|
|
408
406
|
|
|
409
407
|
const summary = rcaSummaryLine(job, verdict);
|
|
410
408
|
const recoveryAction = recoveryActionFor(failureClass);
|
|
@@ -11,6 +11,7 @@ const fs = require('node:fs');
|
|
|
11
11
|
const path = require('node:path');
|
|
12
12
|
const { readTail } = require('./fileTail.cjs');
|
|
13
13
|
const { detectRateLimitInLog } = require('./rateLimitDetect.cjs');
|
|
14
|
+
const { pidAlive } = require('./pidAlive.cjs');
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Return true if pid is alive AND its cmdline looks like a claude process.
|
|
@@ -20,12 +21,18 @@ const { detectRateLimitInLog } = require('./rateLimitDetect.cjs');
|
|
|
20
21
|
* cmdline, so we conservatively return true — never false-reap a live PID
|
|
21
22
|
* just because we can't verify its identity.
|
|
22
23
|
*
|
|
24
|
+
* Existence check now delegates to the shared pidAlive() (pidAlive.cjs) so
|
|
25
|
+
* EPERM (pid exists, owned by another user) counts as alive here too — the
|
|
26
|
+
* previous bare `process.kill(pid, 0)` + catch-all-false treated EPERM the
|
|
27
|
+
* same as ESRCH (no such process), silently false-reaping a live-but-
|
|
28
|
+
* unsignalable pid.
|
|
29
|
+
*
|
|
23
30
|
* Conservative by design: a false negative (live process treated as dead) is
|
|
24
31
|
* far worse than a late reap.
|
|
25
32
|
*/
|
|
26
33
|
function claudePidAlive(pid) {
|
|
27
34
|
if (!pid || typeof pid !== 'number' || pid <= 1) return false;
|
|
28
|
-
|
|
35
|
+
if (!pidAlive(pid)) return false;
|
|
29
36
|
try {
|
|
30
37
|
const cmd = fs.readFileSync(`/proc/${pid}/cmdline`, 'utf8').replace(/\0/g, ' ');
|
|
31
38
|
return /\bclaude\b/.test(cmd);
|
|
@@ -9,10 +9,15 @@
|
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
+
const { pidAlive } = require('./pidAlive.cjs');
|
|
13
|
+
|
|
12
14
|
const DEFAULT_GRACE_MS = 10 * 60 * 1000;
|
|
13
15
|
|
|
16
|
+
// Thin alias over pidAlive.cjs's shared pidAlive() — kept as its own named
|
|
17
|
+
// export (rather than inlining the require at every call site) so existing
|
|
18
|
+
// imports of `defaultPidAlive` from this module keep working unchanged.
|
|
14
19
|
function defaultPidAlive(pid) {
|
|
15
|
-
|
|
20
|
+
return pidAlive(pid);
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
/**
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* reviewNotice.cjs — pure helpers behind the quiet, grouped needs_review
|
|
5
|
+
* notice (this PRD).
|
|
6
|
+
*
|
|
7
|
+
* Before this module, a park into `needs_review` told the authoring Epic
|
|
8
|
+
* immediately (scheduler.cjs's notifyNeedsReview), BEFORE the scheduler's own
|
|
9
|
+
* recovery ladder (mechanical re-integration, resume, quarantine, auto-fix,
|
|
10
|
+
* gate re-run, bounded auto-resolve) ever got a chance to run. Most parks
|
|
11
|
+
* heal on their own, so that immediate message was usually a false alarm.
|
|
12
|
+
*
|
|
13
|
+
* The new rule: record a notice at park time (buildReviewNotice) and send
|
|
14
|
+
* nothing yet. Send ONE message, grouped by (cwd, Epic, cause), only once the
|
|
15
|
+
* ladder gives up on a row (an auto-resolve skip) or the row has sat
|
|
16
|
+
* `needs_review` past a hold window (selectDueReviewNotices + holdMsFromEnv).
|
|
17
|
+
* scheduler.cjs's flushDueReviewNotices is the only caller that actually
|
|
18
|
+
* sends — this module stays fs/network-free so it is unit-testable without
|
|
19
|
+
* touching queue.json or the Epic event store.
|
|
20
|
+
*
|
|
21
|
+
* Each park is one episode with one hold clock. scheduler.cjs's
|
|
22
|
+
* resetJobFields deletes `job.reviewNotice` outright, so a human reset always
|
|
23
|
+
* starts the next park's clock fresh — it never inherits a stale
|
|
24
|
+
* `firstParkedAt` from days earlier. A rung-6 ladder requeue goes through
|
|
25
|
+
* `transitionJob` directly, not `resetJobFields`, so that requeue keeps the
|
|
26
|
+
* same clock on purpose (it is still the same unresolved episode).
|
|
27
|
+
*
|
|
28
|
+
* The sent message also says plainly whether the group still blocks other
|
|
29
|
+
* work: formatReviewNotice names any `pending` row whose `dependsOn` names a
|
|
30
|
+
* still-`needs_review` row in the group, instead of always claiming nothing
|
|
31
|
+
* is waiting. And a row that is not yet due on its own only joins a due
|
|
32
|
+
* group — "sweeps in" — once it has sat for SWEEP_MIN_AGE_MINUTES, so a row
|
|
33
|
+
* that parked seconds ago is never announced before the ladder's early rungs
|
|
34
|
+
* get a chance to run.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
// Default hold before an un-resolved needs_review park gets its own grouped
|
|
38
|
+
// notice, in minutes. Overridable via SM_REVIEW_NOTICE_HOLD_MINUTES.
|
|
39
|
+
const DEFAULT_HOLD_MINUTES = 240;
|
|
40
|
+
|
|
41
|
+
// Same dependsOn slug-matching rule schedulerBatch.cjs's findBlockingDep uses
|
|
42
|
+
// at run time (exact slug first, else bare-name after stripping one leading
|
|
43
|
+
// `NN-`) — reused here, not reimplemented, so formatReviewNotice's "blocks"
|
|
44
|
+
// wording can never disagree with what actually holds a dependent `pending`
|
|
45
|
+
// row in the real queue.
|
|
46
|
+
const { bareSlug } = require('./depSlugResolve.cjs');
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* buildReviewNotice({ job, report, epicId, now, prior }) → ReviewNotice
|
|
50
|
+
*
|
|
51
|
+
* Stamped onto a job row (`job.reviewNotice`) the moment it parks
|
|
52
|
+
* `needs_review`, in the SAME mutate that classifies the RCA report
|
|
53
|
+
* (scheduler.cjs's park path). `report` is rcaReport.cjs's writeRcaReport()
|
|
54
|
+
* result — `null`, or `{ filed: false, ... }` when the report was skipped
|
|
55
|
+
* (SM_RCA_DISABLE, no verdict, etc.) — in which case a deterministic fallback
|
|
56
|
+
* summary stands in for the one the RCA report would have carried.
|
|
57
|
+
*
|
|
58
|
+
* `firstParkedAt` is the anchor selectDueReviewNotices measures the hold
|
|
59
|
+
* window from. It is carried forward from `prior` (the job's existing
|
|
60
|
+
* reviewNotice, if any) as long as that prior notice is still unsent — a
|
|
61
|
+
* re-park of the SAME unresolved episode (e.g. one more ladder attempt that
|
|
62
|
+
* also fails) must not restart the hold clock. Once a notice has been sent,
|
|
63
|
+
* a later park starts a fresh clock — and so does a later park after a human
|
|
64
|
+
* reset, because resetJobFields deletes the notice outright, so `prior` is
|
|
65
|
+
* `undefined` and this falls to the same `now` default.
|
|
66
|
+
*/
|
|
67
|
+
function buildReviewNotice({ job, report, epicId, now, prior } = {}) {
|
|
68
|
+
const cause = `${job?.verifierVerdict || 'unknown'}${job?.integrationFailureKind ? `:${job.integrationFailureKind}` : ''}`;
|
|
69
|
+
const filed = Boolean(report && report.filed);
|
|
70
|
+
const summary = filed ? report.summary : `${job?.slug ?? 'unknown job'} stopped (${cause})`;
|
|
71
|
+
const reportPath = filed ? (report.path ?? null) : null;
|
|
72
|
+
const firstParkedAt = prior && !prior.sentAt && prior.firstParkedAt ? prior.firstParkedAt : now;
|
|
73
|
+
return {
|
|
74
|
+
summary,
|
|
75
|
+
reportPath,
|
|
76
|
+
cause,
|
|
77
|
+
epicId: epicId ?? null,
|
|
78
|
+
firstParkedAt,
|
|
79
|
+
sentAt: null,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// A not-yet-due row only joins a due group ("sweeps in") once it has sat
|
|
84
|
+
// `needs_review` for at least this long. Why: the self-heal ladder
|
|
85
|
+
// (scheduler-operations.md §4) needs about 30 minutes to work through its
|
|
86
|
+
// early rungs, so sweeping in a row seconds after it parked would announce
|
|
87
|
+
// it before the ladder ever got a chance to self-heal it. A row that is due
|
|
88
|
+
// ON ITS OWN (its own hold expired, or a skipped auto-resolve) is never held
|
|
89
|
+
// back by this rule — see isDue below.
|
|
90
|
+
const SWEEP_MIN_AGE_MINUTES = 30;
|
|
91
|
+
|
|
92
|
+
// Milliseconds since reviewNotice.firstParkedAt, or 0 for a missing/
|
|
93
|
+
// unparsable timestamp (fail young — never treat a bad timestamp as old
|
|
94
|
+
// enough to sweep in early).
|
|
95
|
+
function parkedAgeMs(j, now) {
|
|
96
|
+
const firstParkedAt = j.reviewNotice && j.reviewNotice.firstParkedAt;
|
|
97
|
+
if (!firstParkedAt) return 0;
|
|
98
|
+
const parkedMs = Date.parse(firstParkedAt);
|
|
99
|
+
return Number.isFinite(parkedMs) ? now - parkedMs : 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* selectDueReviewNotices(jobs, { now, holdMs }) → [{ cwd, epicId, cause, jobs }]
|
|
104
|
+
*
|
|
105
|
+
* A row is a candidate when it carries an unsent `reviewNotice` and is
|
|
106
|
+
* either `skipped` with `needsReviewAutoResolvedSkip` (the ladder gave up),
|
|
107
|
+
* or still `needs_review` with its notice's `firstParkedAt` at least
|
|
108
|
+
* `holdMs` in the past. completed/pending/running rows, and rows whose
|
|
109
|
+
* notice is already sent, are never candidates.
|
|
110
|
+
*
|
|
111
|
+
* Grouping key is (cwd, reviewNotice.epicId, reviewNotice.cause) — one
|
|
112
|
+
* message per distinct cause per Epic, not one per PRD. Once any row in a
|
|
113
|
+
* key is due, every other unsent candidate sharing that same key is swept
|
|
114
|
+
* into the SAME group even if it individually hasn't reached its own due
|
|
115
|
+
* condition yet, so a cause that affects several PRDs is reported once —
|
|
116
|
+
* except a swept-in `needs_review` row must itself be at least
|
|
117
|
+
* SWEEP_MIN_AGE_MINUTES old (parkedAgeMs); a row due on its own skips that
|
|
118
|
+
* check entirely.
|
|
119
|
+
*/
|
|
120
|
+
function selectDueReviewNotices(jobs = [], { now = Date.now(), holdMs = DEFAULT_HOLD_MINUTES * 60000 } = {}) {
|
|
121
|
+
const isCandidate = (j) => Boolean(
|
|
122
|
+
j
|
|
123
|
+
&& j.reviewNotice
|
|
124
|
+
&& !j.reviewNotice.sentAt
|
|
125
|
+
&& (j.status === 'needs_review' || (j.status === 'skipped' && j.needsReviewAutoResolvedSkip)),
|
|
126
|
+
);
|
|
127
|
+
const isDue = (j) => {
|
|
128
|
+
if (j.status === 'skipped' && j.needsReviewAutoResolvedSkip) return true;
|
|
129
|
+
if (j.status !== 'needs_review') return false;
|
|
130
|
+
const firstParkedAt = j.reviewNotice.firstParkedAt;
|
|
131
|
+
if (!firstParkedAt) return false;
|
|
132
|
+
const parkedMs = Date.parse(firstParkedAt);
|
|
133
|
+
if (!Number.isFinite(parkedMs)) return false;
|
|
134
|
+
return now - parkedMs >= holdMs;
|
|
135
|
+
};
|
|
136
|
+
const keyOf = (j) => `${j.cwd ?? ''}\u0000${j.reviewNotice.epicId ?? ''}\u0000${j.reviewNotice.cause ?? ''}`;
|
|
137
|
+
|
|
138
|
+
const list = Array.isArray(jobs) ? jobs : [];
|
|
139
|
+
const dueKeys = new Set();
|
|
140
|
+
for (const j of list) {
|
|
141
|
+
if (isCandidate(j) && isDue(j)) dueKeys.add(keyOf(j));
|
|
142
|
+
}
|
|
143
|
+
if (dueKeys.size === 0) return [];
|
|
144
|
+
|
|
145
|
+
const sweepMinAgeMs = SWEEP_MIN_AGE_MINUTES * 60000;
|
|
146
|
+
const groupsByKey = new Map();
|
|
147
|
+
for (const j of list) {
|
|
148
|
+
if (!isCandidate(j)) continue;
|
|
149
|
+
const key = keyOf(j);
|
|
150
|
+
if (!dueKeys.has(key)) continue;
|
|
151
|
+
// Not due on its own, and too young to sweep in — leave it for a later
|
|
152
|
+
// pass, once either its own hold expires or it ages past the sweep gate.
|
|
153
|
+
if (!isDue(j) && parkedAgeMs(j, now) < sweepMinAgeMs) continue;
|
|
154
|
+
if (!groupsByKey.has(key)) {
|
|
155
|
+
groupsByKey.set(key, { cwd: j.cwd ?? null, epicId: j.reviewNotice.epicId ?? null, cause: j.reviewNotice.cause ?? null, jobs: [] });
|
|
156
|
+
}
|
|
157
|
+
groupsByKey.get(key).jobs.push(j);
|
|
158
|
+
}
|
|
159
|
+
return Array.from(groupsByKey.values());
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Plain-language stand-in for the raw verifier/integration cause string.
|
|
163
|
+
// Only causes worth explaining in human terms get an entry — formatReviewNotice
|
|
164
|
+
// falls back to the raw cause for anything not listed here.
|
|
165
|
+
const HUMAN_CAUSE = {
|
|
166
|
+
'worktree_integration_failed:stray_checkout': 'the main checkout was on a different branch, so the work could not be merged',
|
|
167
|
+
transcript_errors: "the run's transcript showed error lines, so its pass could not be trusted",
|
|
168
|
+
no_verdict_sentinel: 'the run finished without leaving a clear pass or fail signal',
|
|
169
|
+
abandoned_background_task: 'the run started a background task and then stopped watching it',
|
|
170
|
+
silent_no_op: 'the run finished clean but made no changes, so there is no evidence it did the work',
|
|
171
|
+
pass_no_commit: 'the run reported success but did not commit anything',
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
function humanCauseFor(cause) {
|
|
175
|
+
return HUMAN_CAUSE[cause] ?? cause;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// One phrase per ladder rung, in the fixed order the ladder itself runs
|
|
179
|
+
// (scheduler-operations.md §4). Checked across every row in the group — the
|
|
180
|
+
// summary is the union of what was tried for ANY of the grouped PRDs, not
|
|
181
|
+
// just one.
|
|
182
|
+
function ladderSummaryFor(jobs) {
|
|
183
|
+
const some = (pred) => jobs.some(pred);
|
|
184
|
+
const phrases = [];
|
|
185
|
+
if (some((j) => j.mechanicalRecoveryAttempted)) phrases.push('re-merged the branch');
|
|
186
|
+
if (some((j) => j.resumeRecoveryAttempted)) phrases.push('resumed the session');
|
|
187
|
+
if (some((j) => (j.quarantineResolveAttempts ?? 0) > 0)) phrases.push('set aside stray files');
|
|
188
|
+
if (some((j) => j.autoFixAttempted)) phrases.push('ran an auto-fix job');
|
|
189
|
+
if (some((j) => j.gateShadow)) phrases.push('re-ran the gate');
|
|
190
|
+
if (some((j) => (j.exhaustedResolveAttempts ?? 0) > 0)) phrases.push('re-queued the job');
|
|
191
|
+
if (some((j) => j.needsReviewAutoResolvedSkip)) phrases.push('gave up and skipped the job');
|
|
192
|
+
return phrases.length ? phrases.join(', ') : 'nothing yet';
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// The pending rows (from the FULL job list, not just this group) that a
|
|
196
|
+
// still-`needs_review` row in the group blocks. A dep slug "names" a group
|
|
197
|
+
// row when it matches that row's slug exactly, or by bare name (same rule as
|
|
198
|
+
// findBlockingDep). Only rows in the group's own cwd are considered — a
|
|
199
|
+
// dependsOn chain never crosses projects. Returns a sorted, de-duplicated
|
|
200
|
+
// list of the blocked rows' slugs.
|
|
201
|
+
function blockedDependents(group, jobs) {
|
|
202
|
+
const blockingSlugs = (group.jobs ?? [])
|
|
203
|
+
.filter((j) => j.status === 'needs_review')
|
|
204
|
+
.map((j) => j.slug)
|
|
205
|
+
.filter(Boolean);
|
|
206
|
+
if (!blockingSlugs.length) return [];
|
|
207
|
+
const namesABlockingSlug = (depSlug) => blockingSlugs.some(
|
|
208
|
+
(slug) => depSlug === slug || bareSlug(depSlug) === bareSlug(slug),
|
|
209
|
+
);
|
|
210
|
+
const blocked = new Set();
|
|
211
|
+
for (const p of jobs ?? []) {
|
|
212
|
+
if (p.status !== 'pending' || p.cwd !== group.cwd) continue;
|
|
213
|
+
if ((p.dependsOn ?? []).some(namesABlockingSlug)) blocked.add(p.slug);
|
|
214
|
+
}
|
|
215
|
+
return [...blocked].sort();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* formatReviewNotice(group, { jobs }) → plain-text message body for the
|
|
220
|
+
* authoring Epic's event chain. `group` is one entry from
|
|
221
|
+
* selectDueReviewNotices(). `jobs` is the FULL live job list (every status,
|
|
222
|
+
* every project) — needed to find any `pending` row this group still blocks;
|
|
223
|
+
* omit it (or pass `[]`) to always get the "nothing is waiting" wording,
|
|
224
|
+
* e.g. from a caller that only has the group itself.
|
|
225
|
+
*/
|
|
226
|
+
function formatReviewNotice(group, { jobs = [] } = {}) {
|
|
227
|
+
const groupJobs = group.jobs ?? [];
|
|
228
|
+
const slugs = groupJobs.map((j) => j.slug).filter(Boolean);
|
|
229
|
+
const reportPaths = groupJobs.map((j) => j.reviewNotice?.reportPath).filter(Boolean);
|
|
230
|
+
const blocked = blockedDependents(group, jobs);
|
|
231
|
+
const waitingLine = blocked.length
|
|
232
|
+
? `These PRDs block ${blocked.length} other PRD(s) until they are fixed, reset or archived: ${blocked.join(', ')}.`
|
|
233
|
+
: 'The rest of the plan keeps running. Nothing is waiting on you unless you want to act.';
|
|
234
|
+
const lines = [
|
|
235
|
+
`${groupJobs.length} PRD(s) stopped for the same reason: ${humanCauseFor(group.cause)}.`,
|
|
236
|
+
`The scheduler already tried to fix this on its own: ${ladderSummaryFor(groupJobs)}.`,
|
|
237
|
+
waitingLine,
|
|
238
|
+
`PRDs: ${slugs.join(', ')}`,
|
|
239
|
+
];
|
|
240
|
+
if (reportPaths.length) lines.push(`Reports: ${reportPaths.join(', ')}`);
|
|
241
|
+
return lines.join('\n');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* holdMsFromEnv(env) → milliseconds a needs_review park waits, with no
|
|
246
|
+
* ladder resolution, before it gets a grouped notice on its own (case b in
|
|
247
|
+
* selectDueReviewNotices). SM_REVIEW_NOTICE_HOLD_MINUTES must be a positive
|
|
248
|
+
* number; anything else (unset, zero, negative, NaN) falls back to the
|
|
249
|
+
* DEFAULT_HOLD_MINUTES default.
|
|
250
|
+
*/
|
|
251
|
+
function holdMsFromEnv(env = process.env) {
|
|
252
|
+
const raw = Number(env.SM_REVIEW_NOTICE_HOLD_MINUTES);
|
|
253
|
+
const minutes = Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_HOLD_MINUTES;
|
|
254
|
+
return minutes * 60000;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
module.exports = {
|
|
258
|
+
DEFAULT_HOLD_MINUTES,
|
|
259
|
+
buildReviewNotice,
|
|
260
|
+
selectDueReviewNotices,
|
|
261
|
+
formatReviewNotice,
|
|
262
|
+
holdMsFromEnv,
|
|
263
|
+
};
|
|
@@ -16,12 +16,14 @@
|
|
|
16
16
|
|
|
17
17
|
const { spawn } = require('node:child_process');
|
|
18
18
|
const { resolveClaudeBin, claudeSpawnTarget } = require('./claudeBin.cjs');
|
|
19
|
+
const { headlessPermissionArgs, ensureCliCapsProbed } = require('./claudeCliCaps.cjs');
|
|
19
20
|
const { withProcRole } = require('./cleanEnv.cjs');
|
|
20
21
|
|
|
21
22
|
const MAX_OUT_BYTES = 8 * 1024 * 1024;
|
|
22
23
|
|
|
23
24
|
/** Spawn `claude -p`, capture stdout. Resolves {ok, out, error} — never throws. */
|
|
24
|
-
function runClaudeP(prompt, { model = 'sonnet', timeoutMs = 180_000, systemPrompt = null } = {}) {
|
|
25
|
+
async function runClaudeP(prompt, { model = 'sonnet', timeoutMs = 180_000, systemPrompt = null } = {}) {
|
|
26
|
+
await ensureCliCapsProbed();
|
|
25
27
|
return new Promise((resolve) => {
|
|
26
28
|
let bin;
|
|
27
29
|
try { bin = resolveClaudeBin(); } catch (e) { resolve({ ok: false, error: `claude not found: ${e?.message}` }); return; }
|
|
@@ -29,6 +31,7 @@ function runClaudeP(prompt, { model = 'sonnet', timeoutMs = 180_000, systemPromp
|
|
|
29
31
|
'-p', prompt,
|
|
30
32
|
'--model', model,
|
|
31
33
|
'--dangerously-skip-permissions',
|
|
34
|
+
...headlessPermissionArgs(),
|
|
32
35
|
'--output-format', 'text',
|
|
33
36
|
];
|
|
34
37
|
if (systemPrompt) args.push('--append-system-prompt', systemPrompt);
|
|
@@ -23,8 +23,28 @@ const os = require('node:os');
|
|
|
23
23
|
const path = require('node:path');
|
|
24
24
|
|
|
25
25
|
function isUnder(child, parent) {
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const within = (c, p) => {
|
|
27
|
+
const rel = path.relative(p, c);
|
|
28
|
+
return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
|
|
29
|
+
};
|
|
30
|
+
const c = path.resolve(child);
|
|
31
|
+
const p = path.resolve(parent);
|
|
32
|
+
if (within(c, p)) return true;
|
|
33
|
+
// Symlinked roots (macOS os.tmpdir() /var -> /private/var): also compare canonical spellings.
|
|
34
|
+
return within(realpathDeepest(c), realpathDeepest(p));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** realpath of the deepest existing ancestor + the not-yet-existing tail. Never throws. */
|
|
38
|
+
function realpathDeepest(abs) {
|
|
39
|
+
let head = abs;
|
|
40
|
+
const tail = [];
|
|
41
|
+
for (;;) {
|
|
42
|
+
try { return path.join(fs.realpathSync(head), ...tail.reverse()); } catch { /* walk up */ }
|
|
43
|
+
const up = path.dirname(head);
|
|
44
|
+
if (up === head) return abs;
|
|
45
|
+
tail.push(path.basename(head));
|
|
46
|
+
head = up;
|
|
47
|
+
}
|
|
28
48
|
}
|
|
29
49
|
|
|
30
50
|
/**
|