claude-code-session-manager 0.87.0 → 0.88.1
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 +26 -53
- package/dist/assets/{AgentLibrary-DyLWzZDf.js → AgentLibrary-kQF8_wAw.js} +1 -1
- package/dist/assets/{DataModel--mISIJ6h.js → DataModel-CY_mMnsr.js} +1 -1
- package/dist/assets/{History-C2ahUXTg.js → History-Sji2brb0.js} +1 -1
- package/dist/assets/{Hooks-BiC6oyR2.js → Hooks-CtqpO-p5.js} +1 -1
- package/dist/assets/{HostBilko-BPleEOld.js → HostBilko-DN0ydOCr.js} +1 -1
- package/dist/assets/{Library-Dc8Qst1R.js → Library-CoiLZTKh.js} +1 -1
- package/dist/assets/{ListDetail-DIXh-OLX.js → ListDetail-CmqiQ_io.js} +1 -1
- package/dist/assets/{MarkdownEditor-C90bkLXK.js → MarkdownEditor-HPoNeKhT.js} +1 -1
- package/dist/assets/{McpServers-DqcbLOLZ.js → McpServers-Bj1X3_NT.js} +1 -1
- package/dist/assets/{Memory-CW62MXlh.js → Memory-1PKjsM3b.js} +1 -1
- package/dist/assets/{Panel-Bw1FhRuF.js → Panel-I1s6ghPo.js} +1 -1
- package/dist/assets/{Permissions-BcUC-5y8.js → Permissions-BhiiZjHQ.js} +1 -1
- package/dist/assets/{Plugins-BnKx9flD.js → Plugins-gv3_fkPX.js} +2 -2
- package/dist/assets/{ProvenanceBadge-Bw5vNVPT.js → ProvenanceBadge-BGcgBd8V.js} +1 -1
- package/dist/assets/{SaveBar-CWr0O_w-.js → SaveBar-BGr9eZ4g.js} +1 -1
- package/dist/assets/{Scheduler-DYdLuUqq.js → Scheduler-Bdo_awPq.js} +7 -7
- package/dist/assets/{ScopeSwitcher-CrBLbg8s.js → ScopeSwitcher-ukl0qWaA.js} +1 -1
- package/dist/assets/{Settings-DluB-vN1.js → Settings-DJkFj22G.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-CHLSseay.js → SkillReferenceGraph-0t1Qblp6.js} +1 -1
- package/dist/assets/{Skills-gNdo_HNK.js → Skills-CeVdBGE-.js} +1 -1
- package/dist/assets/{SystemPrompt-Cru05-Ia.js → SystemPrompt-CfKvNHi3.js} +1 -1
- package/dist/assets/{TagLibrary-DNHY0xou.js → TagLibrary-DAzNaUPd.js} +1 -1
- package/dist/assets/{TiptapBody-I4lmbCgP.js → TiptapBody--S_rGXoA.js} +1 -1
- package/dist/assets/{Toggle-bWMHjmRh.js → Toggle-Dszm0xnp.js} +1 -1
- package/dist/assets/{index-DV3PorRY.css → index-BHTX4OTc.css} +1 -1
- package/dist/assets/{index-fc_JjdxL.js → index-Dp4Rc--q.js} +356 -356
- package/dist/assets/{settingsSchema-BfhtZnGD.js → settingsSchema-BLbssMYo.js} +1 -1
- package/dist/assets/{whisperWorker-Dbia1OpC.js → whisperWorker-C7ZGQwKg.js} +7 -7
- package/dist/index.html +2 -2
- package/dist/vad/ort-wasm-simd-threaded.asyncify.mjs +106 -110
- package/dist/vad/ort-wasm-simd-threaded.asyncify.wasm +0 -0
- package/dist/vad/ort-wasm-simd-threaded.jsep.mjs +98 -98
- package/dist/vad/ort-wasm-simd-threaded.jsep.wasm +0 -0
- package/dist/vad/ort-wasm-simd-threaded.jspi.mjs +99 -102
- package/dist/vad/ort-wasm-simd-threaded.jspi.wasm +0 -0
- package/dist/vad/ort-wasm-simd-threaded.mjs +46 -46
- package/dist/vad/ort-wasm-simd-threaded.wasm +0 -0
- package/package.json +10 -13
- package/scripts/README.md +59 -0
- package/scripts/audit-ops-hygiene.cjs +350 -0
- package/scripts/hooks/guard-destructive-git.cjs +10 -34
- package/scripts/hooks/guard-inline-implementation.cjs +14 -8
- package/scripts/hooks/guard-prd-writes.cjs +7 -36
- package/scripts/hooks/guard-self-schedule.cjs +175 -0
- package/scripts/ops-sweep.cjs +355 -0
- package/scripts/scheduler-mcp-server.cjs +28 -71
- package/src/main/__tests__/bilkoHost-integration.test.cjs +3 -3
- package/src/main/__tests__/chat-cancel-terminal.test.cjs +6 -9
- package/src/main/__tests__/chat-exit-close-race.test.cjs +3 -3
- package/src/main/__tests__/chat-mcp-consent-notice.test.cjs +4 -5
- package/src/main/__tests__/chat-queue.test.cjs +2 -2
- package/src/main/__tests__/chat-stop-signal.test.cjs +2 -2
- package/src/main/__tests__/dep-orphan-archive-health.test.cjs +77 -0
- package/src/main/__tests__/dod-batchkey.test.cjs +2 -2
- package/src/main/__tests__/dod-drain-hook.test.cjs +2 -2
- package/src/main/__tests__/dod-report.test.cjs +2 -2
- package/src/main/__tests__/dod-reverify.test.cjs +2 -2
- package/src/main/__tests__/epicMint.test.cjs +2 -2
- package/src/main/__tests__/exchanges.test.cjs +2 -2
- package/src/main/__tests__/extractJson.test.cjs +2 -2
- package/src/main/__tests__/files-reject-credentials.test.cjs +1 -1
- package/src/main/__tests__/fixtures/1218-fo-01-move-scripts-lib-into-src-main-lib.log +556 -0
- package/src/main/__tests__/health-build-freshness.test.cjs +39 -0
- package/src/main/__tests__/health-delegation-chain.test.cjs +15 -1
- package/src/main/__tests__/health-queue-dispatch.test.cjs +58 -7
- package/src/main/__tests__/health-tick-liveness.test.cjs +27 -3
- package/src/main/__tests__/health-usage-poller.test.cjs +70 -23
- package/src/main/__tests__/historyRollup.test.cjs +2 -2
- package/src/main/__tests__/kg-augment.test.cjs +2 -2
- package/src/main/__tests__/mcpStatus.test.cjs +2 -2
- package/src/main/__tests__/memoryAggregate.test.cjs +1 -1
- package/src/main/__tests__/memoryStale.test.cjs +1 -1
- package/src/main/__tests__/opsErrorLogTelemetryTap.test.cjs +25 -1
- package/src/main/__tests__/pollLoop-dispatch-on-failure.test.cjs +33 -3
- package/src/main/__tests__/prd-group-allocator.test.cjs +2 -2
- package/src/main/__tests__/prdAdminRouteParity.test.cjs +2 -0
- package/src/main/__tests__/prdAdminRoutes.test.cjs +14 -2
- package/src/main/__tests__/prdAuthoringSeed.test.cjs +39 -0
- package/src/main/__tests__/prdLocationsArchived.test.cjs +20 -13
- package/src/main/__tests__/proc-role-env.test.cjs +125 -0
- package/src/main/__tests__/procname-claude-spawn-sites.test.cjs +304 -0
- package/src/main/__tests__/procname-sm-processes.test.cjs +127 -0
- package/src/main/__tests__/projectHomeAdminRoutes.test.cjs +81 -401
- package/src/main/__tests__/projectPages.test.cjs +63 -149
- package/src/main/__tests__/queue-health-verdict.test.cjs +9 -9
- package/src/main/__tests__/queue-starvation-dispatch-driver.test.cjs +117 -20
- package/src/main/__tests__/queueHistory.test.cjs +2 -2
- package/src/main/__tests__/rateLimitPollerStreak.test.cjs +38 -3
- package/src/main/__tests__/runVerify-landed-commit-outranks.test.cjs +181 -0
- package/src/main/__tests__/runVerify.test.cjs +5 -5
- package/src/main/__tests__/scheduleJobStatusDrift.test.cjs +3 -3
- package/src/main/__tests__/scheduleJobTransitions.test.cjs +2 -2
- package/src/main/__tests__/scheduler-adopted-run-supervision.test.cjs +143 -0
- package/src/main/__tests__/scheduler-autofix-select.test.cjs +2 -2
- package/src/main/__tests__/scheduler-autopromote.test.cjs +2 -2
- package/src/main/__tests__/scheduler-bash-timeout-env.test.cjs +3 -5
- package/src/main/__tests__/scheduler-boot-orphans.test.cjs +78 -97
- package/src/main/__tests__/scheduler-default-eligible-heal.test.cjs +161 -0
- package/src/main/__tests__/scheduler-dispatch-loop.test.cjs +58 -0
- package/src/main/__tests__/scheduler-epic-digest.test.cjs +3 -5
- package/src/main/__tests__/scheduler-force-tick-outcome.test.cjs +2 -2
- package/src/main/__tests__/scheduler-gate-shadow.test.cjs +119 -0
- package/src/main/__tests__/scheduler-guard-verdict-autoresolve.test.cjs +46 -0
- package/src/main/__tests__/scheduler-heartbeat-payload.test.cjs +80 -0
- package/src/main/__tests__/scheduler-inplace-salvage.test.cjs +25 -18
- package/src/main/__tests__/scheduler-investigation-prompt.test.cjs +4 -4
- package/src/main/__tests__/scheduler-launch-failure.test.cjs +3 -5
- package/src/main/__tests__/scheduler-looks-done.test.cjs +26 -7
- package/src/main/__tests__/scheduler-manual-pause.test.cjs +118 -0
- package/src/main/__tests__/scheduler-meta-code-sha.test.cjs +26 -3
- package/src/main/__tests__/scheduler-prd-missing-skip.test.cjs +17 -2
- package/src/main/__tests__/scheduler-prd-persona-spawn.test.cjs +3 -5
- package/src/main/__tests__/scheduler-quiet-machine-lease.test.cjs +41 -6
- package/src/main/__tests__/scheduler-rate-limit-pause.test.cjs +62 -6
- package/src/main/__tests__/scheduler-rate-limit-spin-guard.test.cjs +3 -5
- package/src/main/__tests__/scheduler-reap-dead-running-jobs.test.cjs +23 -4
- package/src/main/__tests__/scheduler-reconcile-cwd-preserve.test.cjs +100 -0
- package/src/main/__tests__/scheduler-reconcile-invalid-repair.test.cjs +3 -3
- package/src/main/__tests__/scheduler-reconcile-quarantine.test.cjs +4 -4
- package/src/main/__tests__/scheduler-shard-quarantine.test.cjs +110 -0
- package/src/main/__tests__/scheduler-shared-tree-guard.test.cjs +81 -1
- package/src/main/__tests__/scheduler-stall-per-project.test.cjs +14 -0
- package/src/main/__tests__/scheduler-starve-escalation.test.cjs +4 -4
- package/src/main/__tests__/scheduler-stranded-autofix-park.test.cjs +245 -0
- package/src/main/__tests__/scheduler-supervisor-record.test.cjs +81 -0
- package/src/main/__tests__/scheduler-tick-cancel-token.test.cjs +2 -2
- package/src/main/__tests__/scheduler-tick-wedge.test.cjs +172 -0
- package/src/main/__tests__/scheduler-transient-failure.test.cjs +2 -2
- package/src/main/__tests__/scheduler-worktree-cap-defer.test.cjs +37 -11
- package/src/main/__tests__/scheduler-worktree-exec-cwd.test.cjs +3 -5
- package/src/main/__tests__/usageSingleFlight.test.cjs +157 -0
- package/src/main/__tests__/workTypeLibrary.test.cjs +1 -1
- package/src/main/bilkoHost.cjs +16 -7
- package/src/main/build-info.json +8 -0
- package/src/main/chatRunner.cjs +4 -2
- package/src/main/config.cjs +2 -3
- package/src/main/docEdit.cjs +4 -2
- package/src/main/health.cjs +276 -52
- package/src/main/heapSnapshot.cjs +2 -2
- package/src/main/historyAggregator.cjs +1 -1
- package/src/main/index.cjs +61 -10
- package/src/main/ipcSchemas.cjs +6 -17
- package/src/main/lib/__tests__/auditLog.test.cjs +38 -0
- package/src/main/lib/__tests__/buildIdentity.test.cjs +121 -0
- package/src/main/lib/__tests__/cwdClassify.test.cjs +111 -0
- package/src/main/lib/__tests__/definitionOfDoneSequence.test.cjs +95 -0
- package/src/main/lib/__tests__/delegationReadiness.test.cjs +1 -1
- package/src/main/lib/__tests__/dispatchLoop.test.cjs +63 -0
- package/src/main/lib/__tests__/gateFixtures.json +20 -0
- package/src/main/lib/__tests__/gitWorktree.test.cjs +8 -1
- package/src/main/lib/__tests__/instanceLock.test.cjs +93 -7
- package/src/main/lib/__tests__/jobSupervisorRecord.test.cjs +78 -0
- package/src/main/lib/__tests__/jobWorktreeBootLive.test.cjs +11 -0
- package/src/main/lib/__tests__/localAdminHttp.test.cjs +1 -1
- package/src/main/lib/__tests__/mcpToolCatalog.test.cjs +6 -1
- package/src/main/lib/__tests__/procIdentity.test.cjs +119 -0
- package/src/main/lib/__tests__/procName.test.cjs +92 -0
- package/src/main/lib/__tests__/queueStoreMachineStateRecovery.test.cjs +67 -0
- package/src/main/lib/__tests__/schedulerMcpServerHelp.test.cjs +6 -7
- package/src/main/lib/__tests__/schedulerMcpServerProjectHome.test.cjs +37 -204
- package/src/main/lib/__tests__/schedulerPaths.test.cjs +226 -0
- package/src/main/lib/__tests__/schedulerPathsWorktree.test.cjs +94 -0
- package/src/main/lib/__tests__/schedulerRuntimeState.test.cjs +56 -0
- package/src/main/lib/__tests__/sessionSlots.test.cjs +45 -0
- package/src/main/lib/__tests__/telemetryBacklog.test.cjs +1 -1
- package/src/main/lib/__tests__/upgradeDrain.test.cjs +130 -0
- package/src/main/lib/__tests__/usageCircuit.test.cjs +61 -0
- package/src/main/lib/__tests__/watchdog-helpers.test.cjs +63 -0
- package/src/main/lib/__tests__/watchdog-relaunch.test.cjs +73 -0
- package/src/main/lib/activeIndexRebuild.cjs +1 -3
- package/src/main/lib/activeSessions.cjs +20 -88
- package/src/main/lib/adoptedRunSupervisor.cjs +136 -0
- package/src/main/lib/agentModelResolve.cjs +33 -1
- package/src/main/lib/agentPersonaSchema.cjs +2 -2
- package/src/main/lib/auditLog.cjs +30 -5
- package/src/main/lib/buildIdentity.cjs +113 -0
- package/src/main/lib/classifyPromptTicket.cjs +3 -2
- package/src/main/lib/claudeBin.cjs +37 -2
- package/src/main/lib/cleanEnv.cjs +27 -1
- package/src/main/lib/credentials.cjs +4 -2
- package/src/main/lib/cwdClassify.cjs +185 -0
- package/src/main/lib/definitionOfDone.cjs +296 -52
- package/src/main/lib/dispatchLoop.cjs +40 -0
- package/src/main/lib/effectiveModelInfo.cjs +9 -10
- package/src/main/lib/ephemeralCwd.cjs +7 -28
- package/src/main/lib/gitWorktree.cjs +95 -8
- package/src/main/lib/guardShims.cjs +3 -3
- package/src/main/lib/historyRollup.cjs +6 -7
- package/src/main/lib/instanceLock.cjs +32 -5
- package/src/main/lib/jobSupervisorRecord.cjs +147 -0
- package/src/main/lib/jobWorktreeBootLive.cjs +9 -5
- package/src/main/lib/localAdminHttp.cjs +9 -27
- package/src/main/lib/mcpToolCatalog.cjs +29 -77
- package/src/main/lib/opsOwnership.cjs +27 -19
- package/src/main/lib/prdAuthoringSeed.cjs +36 -0
- package/src/main/lib/prdLocations.cjs +48 -1
- package/src/main/lib/procIdentity.cjs +126 -0
- package/src/main/lib/procName.cjs +98 -0
- package/src/main/lib/projectHomeAdminRoutes.cjs +56 -327
- package/src/main/lib/queueHistory.cjs +8 -7
- package/src/main/lib/queueStore.cjs +57 -37
- package/src/main/lib/quietMachineLease.cjs +19 -2
- package/src/main/lib/reservationExpiry.cjs +30 -0
- package/src/main/lib/runClaudeP.cjs +4 -2
- package/src/main/lib/runLogRetention.cjs +3 -2
- package/src/main/lib/scheduleJobSchema.cjs +2 -2
- package/src/main/lib/scheduleJobTransitions.cjs +29 -2
- package/src/main/lib/schedulerBatch.cjs +27 -2
- package/src/main/lib/schedulerPaths.cjs +175 -0
- package/src/main/lib/schedulerRuntimeState.cjs +59 -0
- package/src/main/lib/sessionSlots.cjs +47 -9
- package/src/main/lib/smProcNames.cjs +51 -0
- package/src/main/lib/upgradeDrain.cjs +188 -0
- package/src/main/lib/usageCircuit.cjs +53 -6
- package/src/main/lib/watchdogHelpers.cjs +70 -37
- package/src/main/lib/withTimeout.cjs +33 -0
- package/src/main/mcpStatus.cjs +4 -2
- package/src/main/pluginInstall.cjs +6 -2
- package/src/main/projectPages.cjs +41 -145
- package/src/main/pty.cjs +8 -1
- package/src/main/queueOps.cjs +10 -10
- package/src/main/runVerify.cjs +69 -3
- package/src/main/scheduler.cjs +1607 -383
- package/src/main/seedAgentPersonas.cjs +1 -1
- package/src/main/seedDevPlugin.cjs +1 -1
- package/src/main/seedSchedulerMcp.cjs +7 -6
- package/src/main/seedStatus.cjs +1 -1
- package/src/main/supervisor.cjs +5 -3
- package/src/main/usage.cjs +126 -62
- package/src/preload/api.d.ts +18 -64
- package/src/preload/index.cjs +2 -4
- package/src/seed/agents/project-home-builder.md +31 -48
- package/screenshots/.gitkeep +0 -0
- package/screenshots/README-screenshots.md +0 -13
- package/src/main/lib/projectPageSummarySchema.cjs +0 -181
- package/src/main/teams.cjs +0 -95
- package/src/main/templates/project-pages-catalog.json +0 -741
- package/src/main/templates/project-pages-default-home.html +0 -123
- package/src/main/templates/project-pages-pipeline.md +0 -417
- package/src/seed/prompts/code-review/ac-coverage-check.md +0 -8
- package/src/seed/prompts/code-review/correctness-only.md +0 -8
- package/src/seed/prompts/code-review/full-spectrum-high.md +0 -8
- package/src/seed/prompts/code-review/hallucination-check.md +0 -8
- package/src/seed/prompts/code-review/public-api-compat.md +0 -8
- package/src/seed/prompts/code-review/readability-naming.md +0 -8
- package/src/seed/prompts/debugging/bug-as-failing-test.md +0 -8
- package/src/seed/prompts/debugging/git-bisect-regression.md +0 -8
- package/src/seed/prompts/debugging/instrument-intermittent-bug.md +0 -8
- package/src/seed/prompts/debugging/localize-pipeline-failure.md +0 -8
- package/src/seed/prompts/debugging/reproduce-then-diagnose.md +0 -8
- package/src/seed/prompts/documentation/adr-from-change.md +0 -8
- package/src/seed/prompts/documentation/module-readme.md +0 -8
- package/src/seed/prompts/documentation/onboarding-plan.md +0 -8
- package/src/seed/prompts/documentation/refresh-claude-md.md +0 -8
- package/src/seed/prompts/documentation/tsdoc-public-exports.md +0 -8
- package/src/seed/prompts/git-pr/conventional-commit.md +0 -8
- package/src/seed/prompts/git-pr/draft-pr-title-body.md +0 -8
- package/src/seed/prompts/git-pr/pre-commit-safety-sweep.md +0 -8
- package/src/seed/prompts/git-pr/release-notes-block.md +0 -8
- package/src/seed/prompts/git-pr/split-large-pr.md +0 -8
- package/src/seed/prompts/performance/bundle-startup-audit.md +0 -8
- package/src/seed/prompts/performance/complexity-audit.md +0 -8
- package/src/seed/prompts/performance/cpu-profile-hot-path.md +0 -8
- package/src/seed/prompts/performance/db-query-plan-review.md +0 -8
- package/src/seed/prompts/performance/memory-leak-hunt.md +0 -8
- package/src/seed/prompts/qa/api-contract-tests.md +0 -8
- package/src/seed/prompts/qa/e2e-critical-path.md +0 -8
- package/src/seed/prompts/qa/failing-test-for-bug.md +0 -8
- package/src/seed/prompts/qa/find-missing-test-coverage.md +0 -8
- package/src/seed/prompts/qa/stabilize-flaky-test.md +0 -8
- package/src/seed/prompts/qa/tdd-red-first.md +0 -8
- package/src/seed/prompts/qa/visual-regression-review.md +0 -8
- package/src/seed/prompts/qa/wcag-axe-scan.md +0 -8
- package/src/seed/prompts/refactoring/dead-code-sweep.md +0 -8
- package/src/seed/prompts/refactoring/extract-duplicated-pattern.md +0 -8
- package/src/seed/prompts/refactoring/modernize-legacy-file.md +0 -8
- package/src/seed/prompts/refactoring/reduce-cyclomatic-complexity.md +0 -8
- package/src/seed/prompts/refactoring/tighten-module-boundaries.md +0 -8
- package/src/seed/prompts/security/authz-audit.md +0 -8
- package/src/seed/prompts/security/crypto-correctness.md +0 -8
- package/src/seed/prompts/security/cwe-top-25-hunt.md +0 -8
- package/src/seed/prompts/security/dependency-audit.md +0 -8
- package/src/seed/prompts/security/ipc-boundary-hardening.md +0 -8
- package/src/seed/prompts/security/owasp-top-10-staged-diff.md +0 -8
- package/src/seed/prompts/security/secret-credential-scan.md +0 -8
- package/web/README.md +0 -41
- package/web/project-pages/logic/dist/logic.cjs +0 -4709
- package/web/project-pages/render.cjs +0 -70
- package/web/project-pages/renderer/dist/renderer.cjs +0 -18900
- package/web/project-pages/validate-summary.cjs +0 -62
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* projectHomeAdminRoutes.cjs — the
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* machine with no repo checked out. These four routes make the app itself
|
|
9
|
-
* the authority on paths/schema/catalog/rendering, reusing the shipped
|
|
10
|
-
* assets PRD 1088 put in the npm tarball (web/project-pages/renderer/dist/
|
|
11
|
-
* renderer.cjs, web/project-pages/logic/dist/logic.cjs,
|
|
12
|
-
* src/main/templates/project-pages-catalog.json,
|
|
13
|
-
* src/main/templates/project-pages-pipeline.md) rather than reimplementing
|
|
14
|
-
* any of them.
|
|
2
|
+
* projectHomeAdminRoutes.cjs — the single admin route behind the
|
|
3
|
+
* `project_home_write` MCP tool: POST /admin/project-home/write {cwd, html}
|
|
4
|
+
* writes one self-contained HTML document to
|
|
5
|
+
* `session-manager-operations/project-pages/home.html` (owner: project-home,
|
|
6
|
+
* see opsOwnership.cjs). Registered against the same injected
|
|
7
|
+
* localAdminHttp.cjs transport as prdAdminRoutes.cjs.
|
|
15
8
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* `(req, res, query: URLSearchParams)`).
|
|
20
|
-
*
|
|
21
|
-
* The MCP tool surface that calls these routes is the NEXT PRD in this
|
|
22
|
-
* chain — this file only exposes the HTTP contract.
|
|
9
|
+
* "Self-contained" is enforced here, not trusted: the document must not
|
|
10
|
+
* reference any remote resource (`<script src>`, `<link href=http*>`,
|
|
11
|
+
* remote `@import` / `url(http*)`), so opening it never causes network egress.
|
|
23
12
|
*/
|
|
24
13
|
'use strict';
|
|
25
14
|
|
|
@@ -28,64 +17,31 @@ const path = require('node:path');
|
|
|
28
17
|
const { readBody, sendJson } = require('./localAdminHttp.cjs');
|
|
29
18
|
const { resolveProjectContext } = require('./projectRootResolve.cjs');
|
|
30
19
|
const { opsPath, OPS_ROOT_DIR } = require('./opsOwnership.cjs');
|
|
31
|
-
const { PROJECT_PAGE_SUMMARY_JSON_SCHEMA, PROJECT_PAGE_PICKS_JSON_SCHEMA } = require('./projectPageSummarySchema.cjs');
|
|
32
20
|
const config = require('../config.cjs');
|
|
33
21
|
const { schemas } = require('../ipcSchemas.cjs');
|
|
34
22
|
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// Drop $comment — it names the repo-relative source files the catalog
|
|
52
|
-
// was generated from (build-tooling provenance), which would violate
|
|
53
|
-
// this route's "never point the caller at a repo-relative path"
|
|
54
|
-
// contract if echoed back verbatim.
|
|
55
|
-
cachedCatalog = { lenses: parsed.lenses };
|
|
56
|
-
}
|
|
57
|
-
return cachedCatalog;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
let cachedSpecText = null;
|
|
61
|
-
function loadSpecText() {
|
|
62
|
-
if (cachedSpecText === null) {
|
|
63
|
-
cachedSpecText = fs.readFileSync(SPEC_PATH, 'utf8');
|
|
64
|
-
}
|
|
65
|
-
return cachedSpecText;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
let cachedRenderer = null;
|
|
69
|
-
function loadRenderer() {
|
|
70
|
-
if (!cachedRenderer) {
|
|
71
|
-
({ renderProjectPages: cachedRenderer } = require(RENDERER_BUNDLE_PATH));
|
|
72
|
-
}
|
|
73
|
-
return cachedRenderer;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
let cachedValidator = null;
|
|
77
|
-
function loadValidator() {
|
|
78
|
-
if (!cachedValidator) {
|
|
79
|
-
({ validateProjectPageSummary: cachedValidator } = require(LOGIC_BUNDLE_PATH));
|
|
23
|
+
const MAX_HTML_BYTES = 1024 * 1024;
|
|
24
|
+
|
|
25
|
+
// Each detector is a linear regex scan; the input is capped at 1MB first.
|
|
26
|
+
const REMOTE_REFERENCE_CHECKS = [
|
|
27
|
+
{ re: /<script\b[^>]*\bsrc\s*=/i, message: '<script src> is not allowed — inline all scripts' },
|
|
28
|
+
{ re: /<link\b[^>]*\bhref\s*=\s*["']?\s*(?:https?:)?\/\//i, message: '<link href="http(s)://…"> is not allowed — inline all styles' },
|
|
29
|
+
{ re: /@import\b/i, message: '@import is not allowed — inline all styles' },
|
|
30
|
+
{ re: /url\(\s*["']?\s*(?:https?:)?\/\//i, message: 'url(http(s)://…) is not allowed — embed assets as data: URIs' },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/** -> null when `html` is acceptable, else a human-readable rejection reason. */
|
|
34
|
+
function validateHomeHtml(html) {
|
|
35
|
+
if (typeof html !== 'string' || html.trim().length === 0) return 'html must be a non-empty string';
|
|
36
|
+
if (Buffer.byteLength(html, 'utf8') > MAX_HTML_BYTES) return `html exceeds the ${MAX_HTML_BYTES}-byte limit`;
|
|
37
|
+
for (const { re, message } of REMOTE_REFERENCE_CHECKS) {
|
|
38
|
+
if (re.test(html)) return `html must be self-contained: ${message}`;
|
|
80
39
|
}
|
|
81
|
-
return
|
|
40
|
+
return null;
|
|
82
41
|
}
|
|
83
42
|
|
|
84
43
|
/** Same definition crossProjectFeedback.cjs uses for "is this a Session
|
|
85
|
-
* Manager project": it already has an operations root.
|
|
86
|
-
* NOT require project-pages/ specifically to exist — a project that has
|
|
87
|
-
* never generated a Project Home page yet is still a Session Manager
|
|
88
|
-
* project (see the "no output dir yet" edge case on /status and /render). */
|
|
44
|
+
* Manager project": it already has an operations root. */
|
|
89
45
|
function isSessionManagerProject(cwd) {
|
|
90
46
|
try {
|
|
91
47
|
return fs.statSync(path.join(cwd, OPS_ROOT_DIR)).isDirectory();
|
|
@@ -94,26 +50,8 @@ function isSessionManagerProject(cwd) {
|
|
|
94
50
|
}
|
|
95
51
|
}
|
|
96
52
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
summaryPath: path.join(dir, 'summary.json'),
|
|
101
|
-
picksPath: path.join(dir, 'picks.json'),
|
|
102
|
-
outputDir: path.join(dir, 'output'),
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Resolve+validate a caller-supplied cwd into a real Session Manager
|
|
108
|
-
* project root. Never throws — returns a structured verdict so every route
|
|
109
|
-
* can turn a bad cwd into a JSON error instead of an unhandled throw (this
|
|
110
|
-
* PRD's edge-case requirement).
|
|
111
|
-
*
|
|
112
|
-
* Deliberately does NOT call config.addAllowedRoot here — that widens
|
|
113
|
-
* config.cjs's process-lifetime write boundary and belongs only on an
|
|
114
|
-
* actual write path (the render route calls it itself, right before
|
|
115
|
-
* writing), not on every GET this function also gates.
|
|
116
|
-
*/
|
|
53
|
+
/** Resolve a caller-supplied cwd into a real Session Manager project root.
|
|
54
|
+
* Never throws — returns a structured verdict. */
|
|
117
55
|
function resolveCwd(rawCwd) {
|
|
118
56
|
if (!rawCwd || typeof rawCwd !== 'string') {
|
|
119
57
|
return { ok: false, status: 400, error: 'cwd is required' };
|
|
@@ -121,9 +59,8 @@ function resolveCwd(rawCwd) {
|
|
|
121
59
|
if (!path.isAbsolute(rawCwd)) {
|
|
122
60
|
return { ok: false, status: 400, error: 'cwd must be an absolute path' };
|
|
123
61
|
}
|
|
124
|
-
// Normalizes a worktree/ops-internal cwd to its real project root
|
|
125
|
-
//
|
|
126
|
-
// Epic's worktree still targets the right project.
|
|
62
|
+
// Normalizes a worktree/ops-internal cwd to its real project root so a
|
|
63
|
+
// headless job inside an Epic's worktree still targets the right project.
|
|
127
64
|
const resolved = resolveProjectContext({ cwd: rawCwd });
|
|
128
65
|
const candidate = resolved.cwd || rawCwd;
|
|
129
66
|
let realCwd;
|
|
@@ -142,261 +79,53 @@ function resolveCwd(rawCwd) {
|
|
|
142
79
|
return { ok: true, cwd: realCwd };
|
|
143
80
|
}
|
|
144
81
|
|
|
145
|
-
/** Each validateProjectPageSummary error string is "<field.path> must ...".
|
|
146
|
-
* Split it into { field, message } for the route's documented response
|
|
147
|
-
* shape — the validator itself only returns flat strings. */
|
|
148
|
-
function toFieldErrors(errors) {
|
|
149
|
-
return errors.map((message) => {
|
|
150
|
-
const m = /^([\w.]+)\s/.exec(message);
|
|
151
|
-
return { field: m ? m[1] : 'summary', message };
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Structural check for ProjectPagePicks (lensId -> slotId -> variantId) —
|
|
157
|
-
* the shipped validator only covers `summary`, so this is the one guard
|
|
158
|
-
* against handing the renderer bundle a shape it doesn't expect. Returns
|
|
159
|
-
* "<field> must ..." strings in the same format toFieldErrors expects, so
|
|
160
|
-
* both routes can share one error-shape.
|
|
161
|
-
*/
|
|
162
|
-
function validatePicksShape(picks) {
|
|
163
|
-
if (picks === null || typeof picks !== 'object' || Array.isArray(picks)) {
|
|
164
|
-
return ['picks must be an object'];
|
|
165
|
-
}
|
|
166
|
-
const errors = [];
|
|
167
|
-
for (const [lensId, slotMap] of Object.entries(picks)) {
|
|
168
|
-
if (slotMap === null || typeof slotMap !== 'object' || Array.isArray(slotMap)) {
|
|
169
|
-
errors.push(`picks.${lensId} must be an object`);
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
for (const [slotId, variantId] of Object.entries(slotMap)) {
|
|
173
|
-
if (typeof variantId !== 'string' || variantId.length === 0) {
|
|
174
|
-
errors.push(`picks.${lensId}.${slotId} must be a non-empty string`);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return errors;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/** Shared readBody -> JSON.parse -> zod-schema.parse pipeline for the two
|
|
182
|
-
* POST routes — collapses the 3-step try/catch chain that was previously
|
|
183
|
-
* duplicated in both handlers into one call. Returns either
|
|
184
|
-
* { ok: true, input } or { ok: false, status, error, details }. */
|
|
185
|
-
async function parseJsonBody(req, schema) {
|
|
186
|
-
const raw = await readBody(req);
|
|
187
|
-
let body;
|
|
188
|
-
try {
|
|
189
|
-
body = raw ? JSON.parse(raw) : {};
|
|
190
|
-
} catch {
|
|
191
|
-
return { ok: false, status: 400, error: 'invalid JSON body' };
|
|
192
|
-
}
|
|
193
|
-
try {
|
|
194
|
-
return { ok: true, input: schema.parse(body) };
|
|
195
|
-
} catch (e) {
|
|
196
|
-
return { ok: false, status: 400, error: 'invalid payload', details: e?.issues ?? e?.message };
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function buildProtocol() {
|
|
201
|
-
return [
|
|
202
|
-
'Call GET /admin/project-home/status?cwd=<abs> to see what already exists for this project (summary.json, picks.json, and any prior output).',
|
|
203
|
-
'Compose a ProjectPageSummary object matching the schema in this response\'s "summarySchema" field. Never fabricate content — every field must trace to something concrete about this project (an Epic goal, a source file/dir, a convention, a git log entry). Omit "brief" entirely if this project has no generated brief.json yet; omit "quotes" entries rather than inventing a testimonial.',
|
|
204
|
-
'For each lens in this response\'s "catalog.lenses", and for each of that lens\'s slots, pick exactly one variant id by judging the candidate variants\' "note" text against the summary content you composed. Assemble the picks into a ProjectPagePicks object (lensId -> slotId -> variantId) matching "picksSchema".',
|
|
205
|
-
'POST /admin/project-home/validate-summary with {cwd, summary}. If "valid" is false, fix every listed {field, message} error and re-validate before continuing.',
|
|
206
|
-
'POST /admin/project-home/render with {cwd, summary, picks}. This re-validates the summary server-side (rejecting with no writes on failure), renders all 5 lenses, and writes summary.json, picks.json, and output/{home,marketing,feature,architecture,brief}.html + output/manifest.json at the absolute paths in this response\'s "paths" field.',
|
|
207
|
-
'Optionally call GET /admin/project-home/status again to confirm the new files landed and to read manifest.json\'s generatedAt.',
|
|
208
|
-
];
|
|
209
|
-
}
|
|
210
|
-
|
|
211
82
|
function registerAdminRoute(adminHttp) {
|
|
212
|
-
//
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
let
|
|
83
|
+
// POST /admin/project-home/write {cwd, html}
|
|
84
|
+
adminHttp.registerRoute('POST', '/admin/project-home/write', async (req, res) => {
|
|
85
|
+
// Allow headroom over MAX_HTML_BYTES for JSON escaping; the html byte
|
|
86
|
+
// limit itself is enforced by validateHomeHtml below.
|
|
87
|
+
let raw;
|
|
217
88
|
try {
|
|
218
|
-
|
|
89
|
+
raw = await readBody(req, MAX_HTML_BYTES * 2 + 4096);
|
|
219
90
|
} catch (e) {
|
|
220
|
-
sendJson(res, 400, { ok: false, error:
|
|
91
|
+
sendJson(res, 400, { ok: false, error: `request body rejected: ${e?.message ?? 'unreadable'} (html limit is ${MAX_HTML_BYTES} bytes)` });
|
|
221
92
|
return;
|
|
222
93
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
94
|
+
let body;
|
|
95
|
+
try {
|
|
96
|
+
body = raw ? JSON.parse(raw) : {};
|
|
97
|
+
} catch {
|
|
98
|
+
sendJson(res, 400, { ok: false, error: 'invalid JSON body' });
|
|
226
99
|
return;
|
|
227
100
|
}
|
|
228
|
-
|
|
229
|
-
// but opsPath's own (separate) ephemeral-root check refuses — keep this
|
|
230
|
-
// route's "never an unhandled throw" contract even on that edge.
|
|
101
|
+
let input;
|
|
231
102
|
try {
|
|
232
|
-
|
|
233
|
-
sendJson(res, 200, {
|
|
234
|
-
ok: true,
|
|
235
|
-
protocol: buildProtocol(),
|
|
236
|
-
summarySchema: PROJECT_PAGE_SUMMARY_JSON_SCHEMA,
|
|
237
|
-
picksSchema: PROJECT_PAGE_PICKS_JSON_SCHEMA,
|
|
238
|
-
catalog: loadCatalog(),
|
|
239
|
-
paths: { summaryPath, picksPath, outputDir },
|
|
240
|
-
spec: { text: loadSpecText(), path: SPEC_PATH },
|
|
241
|
-
});
|
|
103
|
+
input = schemas.projectHomeAdminWriteBody.parse(body);
|
|
242
104
|
} catch (e) {
|
|
243
|
-
sendJson(res, 400, { ok: false, error:
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
// POST /admin/project-home/validate-summary {cwd, summary}
|
|
248
|
-
adminHttp.registerRoute('POST', '/admin/project-home/validate-summary', async (req, res) => {
|
|
249
|
-
const parsed = await parseJsonBody(req, schemas.projectHomeAdminValidateSummaryBody);
|
|
250
|
-
if (!parsed.ok) {
|
|
251
|
-
sendJson(res, parsed.status, { ok: false, error: parsed.error, details: parsed.details });
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
const { input } = parsed;
|
|
255
|
-
const resolved = resolveCwd(input.cwd);
|
|
256
|
-
if (!resolved.ok) {
|
|
257
|
-
sendJson(res, resolved.status, { ok: false, error: resolved.error });
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
const validateProjectPageSummary = loadValidator();
|
|
261
|
-
const result = validateProjectPageSummary(input.summary);
|
|
262
|
-
if (!result.ok) {
|
|
263
|
-
sendJson(res, 200, { ok: true, valid: false, errors: toFieldErrors(result.errors) });
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
sendJson(res, 200, { ok: true, valid: true, errors: [] });
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
// POST /admin/project-home/render {cwd, summary, picks}
|
|
270
|
-
adminHttp.registerRoute('POST', '/admin/project-home/render', async (req, res) => {
|
|
271
|
-
const parsed = await parseJsonBody(req, schemas.projectHomeAdminRenderBody);
|
|
272
|
-
if (!parsed.ok) {
|
|
273
|
-
sendJson(res, parsed.status, { ok: false, error: parsed.error, details: parsed.details });
|
|
105
|
+
sendJson(res, 400, { ok: false, error: 'invalid payload', details: e?.issues ?? e?.message });
|
|
274
106
|
return;
|
|
275
107
|
}
|
|
276
|
-
const { input } = parsed;
|
|
277
108
|
const resolved = resolveCwd(input.cwd);
|
|
278
109
|
if (!resolved.ok) {
|
|
279
110
|
sendJson(res, resolved.status, { ok: false, error: resolved.error });
|
|
280
111
|
return;
|
|
281
112
|
}
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
if (!validation.ok || picksErrors.length > 0) {
|
|
286
|
-
sendJson(res, 400, {
|
|
287
|
-
ok: false,
|
|
288
|
-
valid: false,
|
|
289
|
-
errors: [...toFieldErrors(validation.ok ? [] : validation.errors), ...toFieldErrors(picksErrors)],
|
|
290
|
-
});
|
|
113
|
+
const rejection = validateHomeHtml(input.html);
|
|
114
|
+
if (rejection) {
|
|
115
|
+
sendJson(res, 400, { ok: false, error: rejection });
|
|
291
116
|
return;
|
|
292
117
|
}
|
|
293
|
-
|
|
294
|
-
//
|
|
295
|
-
// write-allowed root — see resolveCwd's header for why this must not
|
|
296
|
-
// happen on the GET routes above.
|
|
118
|
+
// Only a route that is actually about to write widens config.cjs's
|
|
119
|
+
// write boundary to this project root.
|
|
297
120
|
config.addAllowedRoot(resolved.cwd);
|
|
298
121
|
try {
|
|
299
|
-
const
|
|
300
|
-
|
|
122
|
+
const homePath = opsPath(resolved.cwd, 'project-pages', 'home.html');
|
|
123
|
+
await config.writeTextAtomic(homePath, input.html, { writer: 'project-home' });
|
|
124
|
+
sendJson(res, 200, { ok: true, path: homePath, bytes: Buffer.byteLength(input.html, 'utf8') });
|
|
301
125
|
} catch (e) {
|
|
302
|
-
sendJson(res, 500, { ok: false, error: e?.message ?? '
|
|
126
|
+
sendJson(res, 500, { ok: false, error: e?.message ?? 'write failed' });
|
|
303
127
|
}
|
|
304
128
|
});
|
|
305
|
-
|
|
306
|
-
// GET /admin/project-home/status?cwd=<abs>
|
|
307
|
-
adminHttp.registerRoute('GET', '/admin/project-home/status', async (req, res, query) => {
|
|
308
|
-
let input;
|
|
309
|
-
try {
|
|
310
|
-
input = schemas.projectHomeAdminCwdQuery.parse(Object.fromEntries(query ?? []));
|
|
311
|
-
} catch (e) {
|
|
312
|
-
sendJson(res, 400, { ok: false, error: 'invalid query', details: e?.issues ?? e?.message });
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
const resolved = resolveCwd(input.cwd);
|
|
316
|
-
if (!resolved.ok) {
|
|
317
|
-
sendJson(res, resolved.status, { ok: false, error: resolved.error });
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
try {
|
|
321
|
-
const status = await getStatus(resolved.cwd);
|
|
322
|
-
sendJson(res, 200, { ok: true, ...status });
|
|
323
|
-
} catch (e) {
|
|
324
|
-
sendJson(res, 400, { ok: false, error: e?.message ?? 'failed to read project-pages status' });
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// Per-cwd in-process promise chain — the render route's only concurrency
|
|
330
|
-
// guard. Sufficient because this admin HTTP server is a single Node
|
|
331
|
-
// process (Electron main) with no worker pool for these routes; a second
|
|
332
|
-
// concurrent render for the SAME cwd simply waits for the first to finish
|
|
333
|
-
// writing before it starts, so output/ is never observed half-written by
|
|
334
|
-
// two overlapping /render calls (it does NOT defend against a
|
|
335
|
-
// project-home-builder Epic's own separate Write-tool calls racing this
|
|
336
|
-
// route from a different OS process — see project-pages/README.md's
|
|
337
|
-
// concurrency section). Entries are evicted once their chain settles so
|
|
338
|
-
// this Map doesn't grow for the life of the process across many cwds.
|
|
339
|
-
const renderChains = new Map();
|
|
340
|
-
function serializedPerCwd(cwd, fn) {
|
|
341
|
-
const prev = renderChains.get(cwd) || Promise.resolve();
|
|
342
|
-
const next = prev.catch(() => {}).then(fn);
|
|
343
|
-
const settled = next.catch(() => {});
|
|
344
|
-
renderChains.set(cwd, settled);
|
|
345
|
-
settled.finally(() => {
|
|
346
|
-
if (renderChains.get(cwd) === settled) renderChains.delete(cwd);
|
|
347
|
-
});
|
|
348
|
-
return next;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
async function doRender(cwd, summary, picks) {
|
|
352
|
-
const renderProjectPages = loadRenderer();
|
|
353
|
-
const pages = renderProjectPages(summary, picks);
|
|
354
|
-
const generatedAt = new Date().toISOString();
|
|
355
|
-
const { summaryPath, picksPath, outputDir } = projectPagesPaths(cwd);
|
|
356
|
-
|
|
357
|
-
// The 5 lens files plus summary.json/picks.json have no ordering
|
|
358
|
-
// dependency on each other — only manifest.json's presence is the
|
|
359
|
-
// "generation complete" signal getStatus() relies on, so it's written
|
|
360
|
-
// last, after everything else has landed.
|
|
361
|
-
const lensWrites = LENSES.map((lens) => {
|
|
362
|
-
const lensPath = path.join(outputDir, `${lens}.html`);
|
|
363
|
-
return config.writeTextAtomic(lensPath, pages[lens], { writer: 'project-home' }).then(() => lensPath);
|
|
364
|
-
});
|
|
365
|
-
const [, , ...lensPaths] = await Promise.all([
|
|
366
|
-
config.writeJson(summaryPath, summary, { writer: 'project-home' }).then(() => summaryPath),
|
|
367
|
-
config.writeJson(picksPath, picks, { writer: 'project-home' }).then(() => picksPath),
|
|
368
|
-
...lensWrites,
|
|
369
|
-
]);
|
|
370
|
-
const manifestPath = path.join(outputDir, 'manifest.json');
|
|
371
|
-
await config.writeJson(manifestPath, { generatedAt }, { writer: 'project-home' });
|
|
372
|
-
|
|
373
|
-
return { filesWritten: [summaryPath, picksPath, ...lensPaths, manifestPath], generatedAt };
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
async function getStatus(cwd) {
|
|
377
|
-
const { summaryPath, picksPath, outputDir } = projectPagesPaths(cwd);
|
|
378
|
-
const [summaryRes, picksRes, manifestRes, ...lensRes] = await Promise.all([
|
|
379
|
-
config.readJson(summaryPath),
|
|
380
|
-
config.readJson(picksPath),
|
|
381
|
-
config.readJson(path.join(outputDir, 'manifest.json')),
|
|
382
|
-
...LENSES.map((lens) => config.readText(path.join(outputDir, `${lens}.html`))),
|
|
383
|
-
]);
|
|
384
|
-
|
|
385
|
-
const output = {};
|
|
386
|
-
LENSES.forEach((lens, i) => {
|
|
387
|
-
const r = lensRes[i];
|
|
388
|
-
output[lens] = { exists: r.exists, mtimeMs: r.exists ? r.mtimeMs : null };
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
return {
|
|
392
|
-
summary: { exists: summaryRes.exists, mtimeMs: summaryRes.exists ? summaryRes.mtimeMs : null },
|
|
393
|
-
picks: { exists: picksRes.exists, mtimeMs: picksRes.exists ? picksRes.mtimeMs : null },
|
|
394
|
-
output,
|
|
395
|
-
manifest: {
|
|
396
|
-
exists: manifestRes.exists,
|
|
397
|
-
generatedAt: manifestRes.exists && manifestRes.data ? (manifestRes.data.generatedAt ?? null) : null,
|
|
398
|
-
},
|
|
399
|
-
};
|
|
400
129
|
}
|
|
401
130
|
|
|
402
|
-
module.exports = { registerAdminRoute };
|
|
131
|
+
module.exports = { registerAdminRoute, validateHomeHtml, MAX_HTML_BYTES };
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
// `nowMs` and `opts` so it's testable without touching the real clock or
|
|
11
11
|
// disk. appendHistory/readHistory own the actual fs I/O.
|
|
12
12
|
|
|
13
|
-
const os = require('os');
|
|
14
13
|
const path = require('path');
|
|
15
14
|
const fsp = require('fs').promises;
|
|
16
15
|
const { HISTORY_RETENTION_MS } = require('./schedulerConfig.cjs');
|
|
17
16
|
const { projectHistoryPath, stateCwds } = require('./queueStore.cjs');
|
|
17
|
+
const { queueHistoryPath } = require('./schedulerPaths.cjs');
|
|
18
18
|
const { resolveIsFixPlan } = require('./fixPlanSlug.cjs');
|
|
19
19
|
|
|
20
20
|
// Legacy global sidecar — READ-ONLY since 2026-07-31 (federated per-project
|
|
@@ -26,8 +26,9 @@ const { resolveIsFixPlan } = require('./fixPlanSlug.cjs');
|
|
|
26
26
|
// Overridable via SM_HISTORY_PATH_OVERRIDE so queueHistory.test.cjs can point
|
|
27
27
|
// this at an isolated tmpdir path instead of racing a live Electron
|
|
28
28
|
// instance's scheduler.cjs, which writes this same machine-global file.
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
function historyPath() {
|
|
30
|
+
return process.env.SM_HISTORY_PATH_OVERRIDE || queueHistoryPath();
|
|
31
|
+
}
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* Every history file currently in play: each project's shard + the legacy
|
|
@@ -37,12 +38,12 @@ const HISTORY_PATH = process.env.SM_HISTORY_PATH_OVERRIDE
|
|
|
37
38
|
* would leak real production history rows into an otherwise-isolated test.
|
|
38
39
|
*/
|
|
39
40
|
function historyPaths() {
|
|
40
|
-
if (process.env.SM_HISTORY_PATH_OVERRIDE) return [
|
|
41
|
+
if (process.env.SM_HISTORY_PATH_OVERRIDE) return [historyPath()];
|
|
41
42
|
const paths = [];
|
|
42
43
|
for (const cwd of stateCwds()) {
|
|
43
44
|
try { paths.push(projectHistoryPath(cwd)); } catch { /* unusable cwd */ }
|
|
44
45
|
}
|
|
45
|
-
paths.push(
|
|
46
|
+
paths.push(historyPath());
|
|
46
47
|
return paths;
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -50,7 +51,7 @@ function historyPathFor(entry) {
|
|
|
50
51
|
if (entry && entry.cwd) {
|
|
51
52
|
try { return projectHistoryPath(entry.cwd); } catch { /* fall through */ }
|
|
52
53
|
}
|
|
53
|
-
return
|
|
54
|
+
return historyPath();
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
// `kind` keeps a needs_review_entry/needs_review_resolution line (see
|
|
@@ -332,7 +333,7 @@ async function completedSlugsForCwd(cwd) {
|
|
|
332
333
|
}
|
|
333
334
|
|
|
334
335
|
module.exports = {
|
|
335
|
-
|
|
336
|
+
historyPath,
|
|
336
337
|
partitionJobs,
|
|
337
338
|
appendHistory,
|
|
338
339
|
readHistory,
|