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
package/src/main/files.cjs
CHANGED
|
@@ -22,6 +22,7 @@ const os = require('node:os');
|
|
|
22
22
|
const { z } = require('zod');
|
|
23
23
|
const { assertInsideHome } = require('./lib/insideHome.cjs');
|
|
24
24
|
const { expandHome } = require('./lib/expandHome.cjs');
|
|
25
|
+
const atomicFs = require('./lib/atomicFs.cjs');
|
|
25
26
|
const { schemas } = require('./ipcSchemas.cjs');
|
|
26
27
|
|
|
27
28
|
/**
|
|
@@ -163,11 +164,7 @@ async function writeFile(filePath, content) {
|
|
|
163
164
|
return { ok: false, error: e.message };
|
|
164
165
|
}
|
|
165
166
|
try {
|
|
166
|
-
|
|
167
|
-
await fsp.mkdir(dir, { recursive: true });
|
|
168
|
-
const tmp = `${resolved}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
169
|
-
await fsp.writeFile(tmp, content, 'utf8');
|
|
170
|
-
await fsp.rename(tmp, resolved);
|
|
167
|
+
await atomicFs.writeTextAtomic(resolved, content);
|
|
171
168
|
return { ok: true, error: null };
|
|
172
169
|
} catch (e) {
|
|
173
170
|
return { ok: false, error: e.message };
|
package/src/main/health.cjs
CHANGED
|
@@ -815,7 +815,7 @@ async function check(opts = {}) {
|
|
|
815
815
|
|
|
816
816
|
// 1.7. Check test infrastructure exists.
|
|
817
817
|
const hasPlaywright = fs.existsSync(path.join(PROJECT_ROOT, 'playwright.config.ts'));
|
|
818
|
-
const hasE2E = fs.existsSync(path.join(PROJECT_ROOT, 'e2e'));
|
|
818
|
+
const hasE2E = fs.existsSync(path.join(PROJECT_ROOT, 'tests', 'e2e'));
|
|
819
819
|
status.components.test_infrastructure = {
|
|
820
820
|
ok: hasPlaywright && hasE2E,
|
|
821
821
|
playwright: hasPlaywright,
|
package/src/main/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ const { createAdminHttp } = require('./lib/localAdminHttp.cjs');
|
|
|
33
33
|
const prdCreate = require('./lib/prdCreate.cjs');
|
|
34
34
|
const prdAdminRoutes = require('./lib/prdAdminRoutes.cjs');
|
|
35
35
|
const projectHomeAdminRoutes = require('./lib/projectHomeAdminRoutes.cjs');
|
|
36
|
+
const { smfileResponseHeaders, shouldBlockFrameNavigation } = require('./lib/smfileHeaders.cjs');
|
|
36
37
|
const { appendAuditEvent } = require('./lib/auditLog.cjs');
|
|
37
38
|
const chatRunner = require('./chatRunner.cjs');
|
|
38
39
|
const promptSessionEvents = require('./promptSessionEvents.cjs');
|
|
@@ -42,6 +43,7 @@ const epicWorktreeMint = require('./lib/epicWorktreeMint.cjs');
|
|
|
42
43
|
const epicWorktreeMerge = require('./lib/epicWorktreeMerge.cjs');
|
|
43
44
|
const epicWorktreeProjectConfig = require('./lib/epicWorktreeProjectConfig.cjs');
|
|
44
45
|
const agentLibrary = require('./agentLibrary.cjs');
|
|
46
|
+
const macroLibrary = require('./lib/macroLibrary.cjs');
|
|
45
47
|
const agentModelResolve = require('./lib/agentModelResolve.cjs');
|
|
46
48
|
const agentEffortResolve = require('./lib/agentEffortResolve.cjs');
|
|
47
49
|
const { resolveEffectiveModelInfo } = require('./lib/effectiveModelInfo.cjs');
|
|
@@ -52,7 +54,6 @@ const upgradeDrain = require('./lib/upgradeDrain.cjs');
|
|
|
52
54
|
const { writeGuardShims } = require('./lib/guardShims.cjs');
|
|
53
55
|
const { MCP_TOOL_CATALOG, MCP_RECIPES } = require('./lib/mcpToolCatalog.cjs');
|
|
54
56
|
const { sendIfAlive } = require('./lib/sendToRenderer.cjs');
|
|
55
|
-
const { resolveBuildTarget } = require('./lib/buildTarget.cjs');
|
|
56
57
|
const crossProjectFeedback = require('./lib/crossProjectFeedback.cjs');
|
|
57
58
|
const adminHttp = createAdminHttp();
|
|
58
59
|
scheduler.registerAdminRoutes(adminHttp);
|
|
@@ -88,7 +89,6 @@ const memoryTool = require('./memoryTool.cjs');
|
|
|
88
89
|
const { registerMemoryAggregateIpc } = require('./memoryAggregate.cjs');
|
|
89
90
|
const { registerProjectBriefIpc } = require('./projectBrief.cjs');
|
|
90
91
|
const { registerProjectPagesIpc, attachWindow: attachProjectPagesWindow, closeAllOutputWatchers: closeAllProjectPagesWatchers } = require('./projectPages.cjs');
|
|
91
|
-
const { registerBilkoHostIpc } = require('./bilkoHost.cjs');
|
|
92
92
|
const promptSessionTranscript = require('./promptSessionTranscript.cjs');
|
|
93
93
|
const { computeEpicDelegationStats } = require('./lib/epicDelegationStats.cjs');
|
|
94
94
|
const agentMemory = require('./agentMemory.cjs');
|
|
@@ -456,6 +456,21 @@ function createWindow() {
|
|
|
456
456
|
configMgr.releaseWatchesForSender(mainWindow.webContents.id);
|
|
457
457
|
});
|
|
458
458
|
|
|
459
|
+
// CSP (frame-src/connect-src) does not govern a subframe navigating itself —
|
|
460
|
+
// a demo-video document could still exfiltrate data via meta refresh or
|
|
461
|
+
// `location.href = 'https://…'`. Block any such navigation out of an
|
|
462
|
+
// smfile:// demo-video subframe.
|
|
463
|
+
mainWindow.webContents.on('will-frame-navigate', (details) => {
|
|
464
|
+
if (shouldBlockFrameNavigation({
|
|
465
|
+
isMainFrame: details.isMainFrame,
|
|
466
|
+
currentUrl: details.frame?.url,
|
|
467
|
+
targetUrl: details.url,
|
|
468
|
+
})) {
|
|
469
|
+
details.preventDefault();
|
|
470
|
+
console.warn('[main] blocked will-frame-navigate to', details.url);
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
|
|
459
474
|
mainWindow.webContents.on('context-menu', (_e, params) => {
|
|
460
475
|
const items = [];
|
|
461
476
|
if (params.editFlags.canCopy) items.push({ label: 'Copy', role: 'copy' });
|
|
@@ -551,6 +566,28 @@ ipcMain.handle('agents:remove-override', async (_e, payload) => {
|
|
|
551
566
|
broadcastAgentsChanged();
|
|
552
567
|
return result;
|
|
553
568
|
});
|
|
569
|
+
// Macro library (macroLibrary.cjs): global machine-local one-click sidebar
|
|
570
|
+
// macros (agent + tag + prompt). Store path is fixed in-module; the renderer
|
|
571
|
+
// never supplies it. Mutations broadcast `macros:changed`.
|
|
572
|
+
function broadcastMacrosChanged() {
|
|
573
|
+
sendIfAlive(mainWindow, 'macros:changed', {});
|
|
574
|
+
}
|
|
575
|
+
ipcMain.handle('macros:list', () => macroLibrary.listMacros());
|
|
576
|
+
ipcMain.handle('macros:save', validated(schemas.macrosSave, async (payload) => {
|
|
577
|
+
const macro = await macroLibrary.saveMacro(payload);
|
|
578
|
+
broadcastMacrosChanged();
|
|
579
|
+
return macro;
|
|
580
|
+
}));
|
|
581
|
+
ipcMain.handle('macros:delete', validated(schemas.macrosDelete, async (payload) => {
|
|
582
|
+
const result = await macroLibrary.deleteMacro(payload);
|
|
583
|
+
broadcastMacrosChanged();
|
|
584
|
+
return result;
|
|
585
|
+
}));
|
|
586
|
+
ipcMain.handle('macros:set-project', validated(schemas.macrosSetProject, async (payload) => {
|
|
587
|
+
const result = await macroLibrary.setMacroProject(payload);
|
|
588
|
+
if (result.ok) broadcastMacrosChanged();
|
|
589
|
+
return result;
|
|
590
|
+
}));
|
|
554
591
|
// New Epic AIM composer (epicIntake.ts's `agentBody`/`agentPath`): unlike
|
|
555
592
|
// list-personas above (global dir only), this honors the project-overlay-
|
|
556
593
|
// then-global precedence so an Epic's opening prompt carries the persona
|
|
@@ -877,13 +914,6 @@ ipcMain.handle('app:git-branch', validated(schemas.appGitBranch, async ({ cwd })
|
|
|
877
914
|
});
|
|
878
915
|
}));
|
|
879
916
|
|
|
880
|
-
// Resolves a project's publish target for 'build'-tagged Epics — see
|
|
881
|
-
// lib/buildTarget.cjs. Null means the Build toolbar button should be disabled
|
|
882
|
-
// (no explicit config, no auto-discoverable publishable package.json).
|
|
883
|
-
ipcMain.handle('build:resolve-target', validated(schemas.buildResolveTarget, ({ cwd }) => {
|
|
884
|
-
return resolveBuildTarget(cwd);
|
|
885
|
-
}));
|
|
886
|
-
|
|
887
917
|
// Containment check for the open-in-{editor,finder,terminal} handlers lives
|
|
888
918
|
// in lib/insideHome.cjs — single chokepoint for the /home/bilkoEVIL prefix-trap.
|
|
889
919
|
// Editor / finder / terminal logic lives in lib/openExternalApp.cjs.
|
|
@@ -983,7 +1013,6 @@ epicWorktreeProjectConfig.registerEpicWorktreeProjectConfigHandlers();
|
|
|
983
1013
|
registerMemoryAggregateIpc();
|
|
984
1014
|
registerProjectBriefIpc();
|
|
985
1015
|
registerProjectPagesIpc();
|
|
986
|
-
registerBilkoHostIpc();
|
|
987
1016
|
ipcMain.handle('promptSessionTranscript:append', validated(schemas.promptSessionTranscriptAppend, async ({ cwd, epicId, role, text, at, eventId }) => {
|
|
988
1017
|
const ok = await promptSessionTranscript.appendTurn(cwd, epicId, { role, text, at, eventId });
|
|
989
1018
|
return { ok };
|
|
@@ -1263,7 +1292,7 @@ app.whenReady().then(async () => {
|
|
|
1263
1292
|
const buf = await fs.promises.readFile(realPath);
|
|
1264
1293
|
const ext = path.extname(realPath).toLowerCase();
|
|
1265
1294
|
const type = SMFILE_MIME[ext] || 'application/octet-stream';
|
|
1266
|
-
return new Response(buf, { headers:
|
|
1295
|
+
return new Response(buf, { headers: smfileResponseHeaders(realPath, type) });
|
|
1267
1296
|
} catch (err) {
|
|
1268
1297
|
return new Response(`smfile error: ${err && err.message}`, { status: 404 });
|
|
1269
1298
|
}
|
package/src/main/ipcSchemas.cjs
CHANGED
|
@@ -13,6 +13,7 @@ const { PromptSessionSchema, EpicTagSchema, EpicSourceSchema, EpicIntakeSectionS
|
|
|
13
13
|
const { PrdWorkTypeSchema } = require('./lib/workTypeLibrary.cjs');
|
|
14
14
|
const { PERSONA_NAME_RE } = require('./agentLibrary.cjs');
|
|
15
15
|
const { AgentPersonaSaveSchema } = require('./lib/agentPersonaSchema.cjs');
|
|
16
|
+
const { MacroSaveSchema, MacroDeleteSchema, MacroSetProjectSchema } = require('./lib/macroLibrary.cjs');
|
|
16
17
|
|
|
17
18
|
// ──────────────────────────────────────────── PTY
|
|
18
19
|
const ptySpawn = z.object({
|
|
@@ -282,6 +283,15 @@ const scheduleSlug = z.object({
|
|
|
282
283
|
slug: z.string().regex(SCHEDULE_SLUG_RE),
|
|
283
284
|
});
|
|
284
285
|
|
|
286
|
+
// reset-job: slug + optional cwd — narrows the match to one project's job
|
|
287
|
+
// row so two different projects' slugs that happen to collide (slugs carry
|
|
288
|
+
// no cwd salt) don't cross-reset. Mirrors remote.resetJob's own cwd filter
|
|
289
|
+
// in scheduler.cjs.
|
|
290
|
+
const scheduleResetJob = z.object({
|
|
291
|
+
slug: z.string().regex(SCHEDULE_SLUG_RE),
|
|
292
|
+
cwd: z.string().min(1).max(4096).optional(),
|
|
293
|
+
});
|
|
294
|
+
|
|
285
295
|
const scheduleReadLog = z.object({
|
|
286
296
|
slug: z.string().regex(SCHEDULE_SLUG_RE),
|
|
287
297
|
runId: z.string().regex(SCHEDULE_RUN_ID_RE),
|
|
@@ -409,6 +419,17 @@ const schedulerCreatePrd = z.object({
|
|
|
409
419
|
// invalidate. See prdCreate.cjs's buildPrdBody and schedulerBatch.cjs's
|
|
410
420
|
// pickNextBatch.
|
|
411
421
|
quietMachine: z.boolean().optional(),
|
|
422
|
+
// Commands that prove this PRD is done (gate-and-files-in-PRD-body unit) —
|
|
423
|
+
// rendered verbatim as the `# Gate` body section's ```gate fence and read
|
|
424
|
+
// back by definitionOfDone.cjs's resolveGate/parseChain. ['none'] opts out
|
|
425
|
+
// for docs/config PRDs with no runnable check. Shape-validated (length,
|
|
426
|
+
// chars, no-shell, none-is-alone) by prdGateFiles.cjs's validateGate, not
|
|
427
|
+
// here — this schema only bounds array size and element type.
|
|
428
|
+
gate: z.array(z.string()).min(1).max(10).optional(),
|
|
429
|
+
// Repo-relative files/folders this PRD may change — rendered verbatim as
|
|
430
|
+
// the `# Files` body section. Validated (repo-relative, no .., no globs)
|
|
431
|
+
// by prdGateFiles.cjs's validateFiles, not here.
|
|
432
|
+
files: z.array(z.string()).min(1).max(50).optional(),
|
|
412
433
|
});
|
|
413
434
|
|
|
414
435
|
// Renderer-facing counterpart to adminPrdFrontmatterPatch's dependsOn/
|
|
@@ -588,6 +609,9 @@ const setSessionSlotsSchema = z.object({
|
|
|
588
609
|
// Full field-level rules live in lib/agentPersonaSchema.cjs, mirroring
|
|
589
610
|
// AgentPersonaSaveInput (src/preload/api.d.ts) field-for-field.
|
|
590
611
|
const agentsSavePersona = AgentPersonaSaveSchema;
|
|
612
|
+
const macrosSave = MacroSaveSchema;
|
|
613
|
+
const macrosDelete = MacroDeleteSchema;
|
|
614
|
+
const macrosSetProject = MacroSetProjectSchema;
|
|
591
615
|
|
|
592
616
|
// ──────────────────────────────────────────── Memory tool (Bundle C, cycle 3)
|
|
593
617
|
// Workspace-scoped markdown store at ~/.claude/projects/<ws>/memory/.
|
|
@@ -706,30 +730,13 @@ const projectHomeAdminWriteBody = z.object({
|
|
|
706
730
|
html: z.string(),
|
|
707
731
|
}).strict();
|
|
708
732
|
|
|
709
|
-
//
|
|
710
|
-
//
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
}).strict();
|
|
715
|
-
const bilkoHostPrepareBundle = z.object({
|
|
716
|
-
cwd: z.string().min(1).max(4096),
|
|
717
|
-
slug: z.string().min(1).max(64).regex(/^[a-z0-9-]+$/, 'slug must be lowercase kebab-case'),
|
|
718
|
-
}).strict();
|
|
719
|
-
const BILKO_HOST_DOCUMENT_SOURCE = z.union([
|
|
720
|
-
z.object({ kind: z.literal('project-page-lens'), lens: z.enum(['home', 'marketing', 'feature', 'architecture']) }).strict(),
|
|
721
|
-
z.object({ kind: z.literal('file'), path: z.string().min(1).max(4096) }).strict(),
|
|
722
|
-
]);
|
|
723
|
-
const bilkoHostAddDocument = z.object({
|
|
724
|
-
cwd: z.string().min(1).max(4096),
|
|
725
|
-
subpath: z.string().min(1).max(200),
|
|
726
|
-
title: z.string().min(1).max(200),
|
|
727
|
-
source: BILKO_HOST_DOCUMENT_SOURCE,
|
|
728
|
-
}).strict();
|
|
729
|
-
const bilkoHostRemoveDocument = z.object({
|
|
730
|
-
cwd: z.string().min(1).max(4096),
|
|
731
|
-
id: z.string().min(1).max(200),
|
|
733
|
+
// Mirrors projectHomeAdminWriteBody; content limits (network-check rejections,
|
|
734
|
+
// size cap, duration meta) live in projectHomeAdminRoutes.cjs's validateDemoVideoHtml.
|
|
735
|
+
const projectDemoVideoAdminWriteBody = z.object({
|
|
736
|
+
cwd: z.string().min(1).max(4096).optional(),
|
|
737
|
+
html: z.string(),
|
|
732
738
|
}).strict();
|
|
739
|
+
|
|
733
740
|
const projectBriefSetPin = z.object({
|
|
734
741
|
cwd: z.string().min(1).max(4096),
|
|
735
742
|
block: PROJECT_BRIEF_BLOCK,
|
|
@@ -993,12 +1000,6 @@ const appGitBranch = z.object({
|
|
|
993
1000
|
cwd: z.string().min(1).max(4096),
|
|
994
1001
|
}).passthrough();
|
|
995
1002
|
|
|
996
|
-
// build:resolve-target — see src/main/lib/buildTarget.cjs. cwd is a trusted
|
|
997
|
-
// TAB cwd, not validatePath'd here (same invariant as appGitBranch above).
|
|
998
|
-
const buildResolveTarget = z.object({
|
|
999
|
-
cwd: z.string().min(1).max(4096),
|
|
1000
|
-
}).passthrough();
|
|
1001
|
-
|
|
1002
1003
|
// git:status / git:file-status — see src/main/git.cjs. cwd is validatePath'd
|
|
1003
1004
|
// inside the handler (allowedRoots = home), so the schema only enforces shape.
|
|
1004
1005
|
const gitStatus = z.object({
|
|
@@ -1100,6 +1101,7 @@ module.exports = {
|
|
|
1100
1101
|
sessionsPayload,
|
|
1101
1102
|
layoutEnvelope,
|
|
1102
1103
|
scheduleSlug,
|
|
1104
|
+
scheduleResetJob,
|
|
1103
1105
|
scheduleReadLog,
|
|
1104
1106
|
scheduleWritePrd,
|
|
1105
1107
|
schedulerCreatePrd,
|
|
@@ -1122,7 +1124,6 @@ module.exports = {
|
|
|
1122
1124
|
voiceSetRecording,
|
|
1123
1125
|
appTestFireHook,
|
|
1124
1126
|
appGitBranch,
|
|
1125
|
-
buildResolveTarget,
|
|
1126
1127
|
gitStatus,
|
|
1127
1128
|
gitFileStatus,
|
|
1128
1129
|
repoAnalyze,
|
|
@@ -1138,10 +1139,7 @@ module.exports = {
|
|
|
1138
1139
|
projectBriefCwd,
|
|
1139
1140
|
projectPagesCwd,
|
|
1140
1141
|
projectHomeAdminWriteBody,
|
|
1141
|
-
|
|
1142
|
-
bilkoHostPrepareBundle,
|
|
1143
|
-
bilkoHostAddDocument,
|
|
1144
|
-
bilkoHostRemoveDocument,
|
|
1142
|
+
projectDemoVideoAdminWriteBody,
|
|
1145
1143
|
projectBriefSetPin,
|
|
1146
1144
|
projectBriefUpdate,
|
|
1147
1145
|
promptSessionTranscriptAppend,
|
|
@@ -1172,6 +1170,9 @@ module.exports = {
|
|
|
1172
1170
|
chatExternalSend,
|
|
1173
1171
|
exchangesList,
|
|
1174
1172
|
agentsSavePersona,
|
|
1173
|
+
macrosSave,
|
|
1174
|
+
macrosDelete,
|
|
1175
|
+
macrosSetProject,
|
|
1175
1176
|
agentsGetPersonaBody,
|
|
1176
1177
|
agentsResolveModelInfo,
|
|
1177
1178
|
modelsCatalog,
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
'use strict';
|
|
24
24
|
|
|
25
25
|
const { z } = require('zod');
|
|
26
|
-
const { WorkTypeSchema } = require('./workTypeLibrary.cjs');
|
|
26
|
+
const { WorkTypeSchema, LEGACY_WORK_TYPES } = require('./workTypeLibrary.cjs');
|
|
27
27
|
const { PERSONA_NAME_RE, ALL_PROJECTS } = require('../agentLibrary.cjs');
|
|
28
28
|
|
|
29
29
|
// Bounded free-text fields — generous for legitimate persona authoring while
|
|
@@ -53,13 +53,24 @@ const AgentPersonaSaveSchema = z.object({
|
|
|
53
53
|
model: BoundedString,
|
|
54
54
|
effort: BoundedString.optional(),
|
|
55
55
|
color: BoundedString,
|
|
56
|
-
|
|
56
|
+
// A legacy tag value (e.g. the retired 'bilko-host-publisher') must keep
|
|
57
|
+
// loading on an old on-disk persona — dropped silently, never thrown. Any
|
|
58
|
+
// other unknown value still fails via WorkTypeSchema.
|
|
59
|
+
tags: z.preprocess(
|
|
60
|
+
(v) => (Array.isArray(v) ? v.filter((t) => !(typeof t === 'string' && LEGACY_WORK_TYPES.includes(t))) : v),
|
|
61
|
+
z.array(WorkTypeSchema),
|
|
62
|
+
),
|
|
57
63
|
projects: z.array(ProjectEntrySchema).optional(),
|
|
58
64
|
action: z.string().max(20000).optional(),
|
|
59
65
|
actionLabel: BoundedString.optional(),
|
|
60
66
|
title: BoundedString.optional(),
|
|
61
67
|
// Set = write this project's frontmatter-only override (model/effort only) instead of the global file.
|
|
62
68
|
projectName: BoundedString.optional(),
|
|
69
|
+
// Bundled-persona version stamp (seedAgentPersonas.cjs). Omit to carry over
|
|
70
|
+
// the existing file's stamp unchanged — see agentLibrary.cjs's savePersona.
|
|
71
|
+
// Without this field zod's default "strip unknown keys" behavior would
|
|
72
|
+
// silently drop it from a save payload that did carry one.
|
|
73
|
+
seedVersion: z.number().int().optional(),
|
|
63
74
|
// Unbounded — a persona's body is arbitrary system-prompt prose.
|
|
64
75
|
body: z.string(),
|
|
65
76
|
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* atomicFs.cjs — canonical tmp+rename file-IO primitives, extracted out of
|
|
5
|
+
* config.cjs so non-Electron modules (lib/*.cjs) can reuse the exact same
|
|
6
|
+
* atomic-write recipe without importing config.cjs's electron-adjacent
|
|
7
|
+
* validation layer. NO electron import here, intentionally — this module is
|
|
8
|
+
* pure Node and must stay requirable from any process.
|
|
9
|
+
*
|
|
10
|
+
* Recipe (unchanged from the original config.cjs copies this consolidates):
|
|
11
|
+
* write to `<file>.tmp-<pid>-<ts>-<rand>` in the SAME directory, then rename
|
|
12
|
+
* over the real path. mkdir -p the parent first. On write/rename failure,
|
|
13
|
+
* best-effort unlink the tmp file before rethrowing.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const fs = require('node:fs');
|
|
17
|
+
const fsp = require('node:fs/promises');
|
|
18
|
+
const path = require('node:path');
|
|
19
|
+
|
|
20
|
+
function tmpPathFor(file) {
|
|
21
|
+
return `${file}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* opts.mode: optional POSIX permission bits applied to the tmp file before
|
|
26
|
+
* rename (chmod'd explicitly too — some platforms ignore the mode arg on
|
|
27
|
+
* writeFile when the file pre-exists).
|
|
28
|
+
* opts.fsync: fsync the tmp file's fd before rename (durability for callers
|
|
29
|
+
* that need the write to survive a crash immediately after it returns).
|
|
30
|
+
*/
|
|
31
|
+
async function writeTextAtomic(file, text, opts = {}) {
|
|
32
|
+
const dir = path.dirname(file);
|
|
33
|
+
await fsp.mkdir(dir, { recursive: true });
|
|
34
|
+
const tmp = tmpPathFor(file);
|
|
35
|
+
try {
|
|
36
|
+
const handle = await fsp.open(tmp, 'w', opts.mode);
|
|
37
|
+
try {
|
|
38
|
+
await handle.writeFile(text, 'utf8');
|
|
39
|
+
if (opts.mode) {
|
|
40
|
+
try { await handle.chmod(opts.mode); } catch { /* umask may have already applied it */ }
|
|
41
|
+
}
|
|
42
|
+
if (opts.fsync) await handle.sync();
|
|
43
|
+
} finally {
|
|
44
|
+
await handle.close();
|
|
45
|
+
}
|
|
46
|
+
await fsp.rename(tmp, file);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
try { await fsp.unlink(tmp); } catch { /* tmp never created or already gone */ }
|
|
49
|
+
throw e;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function writeTextAtomicSync(file, text, opts = {}) {
|
|
54
|
+
const dir = path.dirname(file);
|
|
55
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
56
|
+
const tmp = tmpPathFor(file);
|
|
57
|
+
try {
|
|
58
|
+
const fd = fs.openSync(tmp, 'w', opts.mode);
|
|
59
|
+
try {
|
|
60
|
+
fs.writeSync(fd, text, null, 'utf8');
|
|
61
|
+
if (opts.mode) {
|
|
62
|
+
try { fs.chmodSync(tmp, opts.mode); } catch { /* umask may have already applied it */ }
|
|
63
|
+
}
|
|
64
|
+
if (opts.fsync) fs.fsyncSync(fd);
|
|
65
|
+
} finally {
|
|
66
|
+
fs.closeSync(fd);
|
|
67
|
+
}
|
|
68
|
+
fs.renameSync(tmp, file);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
try { fs.unlinkSync(tmp); } catch { /* tmp never created or already gone */ }
|
|
71
|
+
throw e;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function serializeJson(obj, { space = 2, newline = true } = {}) {
|
|
76
|
+
const json = JSON.stringify(obj, null, space);
|
|
77
|
+
return newline ? `${json}\n` : json;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function writeJsonAtomic(file, obj, opts = {}) {
|
|
81
|
+
await writeTextAtomic(file, serializeJson(obj, opts), opts);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function writeJsonAtomicSync(file, obj, opts = {}) {
|
|
85
|
+
writeTextAtomicSync(file, serializeJson(obj, opts), opts);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function readJsonOr(file, fallback) {
|
|
89
|
+
try {
|
|
90
|
+
const raw = await fsp.readFile(file, 'utf8');
|
|
91
|
+
if (raw.trim() === '') return fallback;
|
|
92
|
+
return JSON.parse(raw);
|
|
93
|
+
} catch {
|
|
94
|
+
return fallback;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function readJsonOrSync(file, fallback) {
|
|
99
|
+
try {
|
|
100
|
+
const raw = fs.readFileSync(file, 'utf8');
|
|
101
|
+
if (raw.trim() === '') return fallback;
|
|
102
|
+
return JSON.parse(raw);
|
|
103
|
+
} catch {
|
|
104
|
+
return fallback;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
module.exports = {
|
|
109
|
+
tmpPathFor,
|
|
110
|
+
writeTextAtomic,
|
|
111
|
+
writeTextAtomicSync,
|
|
112
|
+
writeJsonAtomic,
|
|
113
|
+
writeJsonAtomicSync,
|
|
114
|
+
readJsonOr,
|
|
115
|
+
readJsonOrSync,
|
|
116
|
+
};
|
|
@@ -19,20 +19,13 @@
|
|
|
19
19
|
*/
|
|
20
20
|
'use strict';
|
|
21
21
|
|
|
22
|
-
const { execFile } = require('node:child_process');
|
|
23
22
|
const gitWorktree = require('./gitWorktree.cjs');
|
|
23
|
+
const { execGit: sharedExecGit } = require('./gitExec.cjs');
|
|
24
24
|
|
|
25
|
+
// Thin re-shape over the shared gitExec.execGit — kept so call sites below
|
|
26
|
+
// (positional `timeout`, no `-C` prefix needed) don't all need touching.
|
|
25
27
|
function execGit(cwd, args, timeout = 20_000) {
|
|
26
|
-
return
|
|
27
|
-
execFile('git', ['-C', cwd, ...args], { timeout, windowsHide: true, encoding: 'utf8' }, (err, stdout, stderr) => {
|
|
28
|
-
if (err) {
|
|
29
|
-
err.stderrText = stderr;
|
|
30
|
-
reject(err);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
resolve(stdout || '');
|
|
34
|
-
});
|
|
35
|
-
});
|
|
28
|
+
return sharedExecGit(cwd, args, { timeout });
|
|
36
29
|
}
|
|
37
30
|
|
|
38
31
|
/** List every local branch under `refs/heads/sm-job/*`. Never throws. */
|
|
@@ -114,7 +107,15 @@ async function sweepStrandedJobBranches({ cwd, jobs, attemptedBranches }) {
|
|
|
114
107
|
continue;
|
|
115
108
|
}
|
|
116
109
|
attempted.add(attemptKey);
|
|
117
|
-
|
|
110
|
+
// baseBranch: read off the job row when one still exists (the crash-between-
|
|
111
|
+
// commit-and-integrate case this sweep exists for) so integration targets the
|
|
112
|
+
// SAME branch the checkout was actually on when the worktree was created —
|
|
113
|
+
// not whatever cwd happens to sit on during this sweep pass. A fully orphaned
|
|
114
|
+
// branch (no row at all) has nothing to read, so it falls back to
|
|
115
|
+
// resolveDefaultBranch(cwd), same as before.
|
|
116
|
+
const integration = await gitWorktree.integrateJobBranch({
|
|
117
|
+
cwd, branch, slug: slug || branch, baseBranch: (row && row.worktreeBaseBranch) || null,
|
|
118
|
+
});
|
|
118
119
|
results.push({ branch, slug, action: integration.ok ? 'integrated' : 'conflict', integration });
|
|
119
120
|
}
|
|
120
121
|
return { results };
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
* daemon whose "release" is bump VERSION, write the changelog, tag, and flag
|
|
22
22
|
* that the live server needs a restart. That requires reading CLAUDE.md and
|
|
23
23
|
* git history and exercising judgment, so discovery lives in the agent: a
|
|
24
|
-
* `null` here means **not configured yet
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* `null` here means **not configured yet**; the builder skill probes the
|
|
25
|
+
* project and writes the config. No IPC or UI calls this resolver today;
|
|
26
|
+
* builds start from a user-created Macro (e.g. agent `builder`, tag `build`).
|
|
27
27
|
*/
|
|
28
28
|
'use strict';
|
|
29
29
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* builtinMacros.cjs — the machine-local Macro library's seeded built-ins.
|
|
5
|
+
*
|
|
6
|
+
* These drive Project Home's one-click actions through the same (agent, tag,
|
|
7
|
+
* prompt) hot-key framework as user-created macros. `macroLibrary.cjs`'s
|
|
8
|
+
* `ensureBuiltins` seeds any entry here that is missing from macros.json, and
|
|
9
|
+
* upgrades an unedited stored copy whose `builtinVersion` is behind this file.
|
|
10
|
+
*
|
|
11
|
+
* Plain Node, no Electron imports.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const BUILTIN_MACROS = Object.freeze([
|
|
15
|
+
Object.freeze({
|
|
16
|
+
id: 'builtin-project-home',
|
|
17
|
+
label: 'Project Home',
|
|
18
|
+
agentName: 'project-home-builder',
|
|
19
|
+
tag: 'project-home-builder',
|
|
20
|
+
surface: 'project-home',
|
|
21
|
+
projects: ['*'],
|
|
22
|
+
builtinVersion: 1,
|
|
23
|
+
prompt:
|
|
24
|
+
"Generate this project's Project Home page: one self-contained HTML overview (what it is, who it is for, key features, structure, how to run it, key commands), grounded only in what you read in the repository. Save it with a single project_home_write call.",
|
|
25
|
+
}),
|
|
26
|
+
Object.freeze({
|
|
27
|
+
id: 'builtin-demo-video',
|
|
28
|
+
label: 'Demo Video',
|
|
29
|
+
agentName: 'demo-video-builder',
|
|
30
|
+
tag: 'project-home-builder',
|
|
31
|
+
surface: 'project-home',
|
|
32
|
+
projects: ['*'],
|
|
33
|
+
builtinVersion: 1,
|
|
34
|
+
prompt:
|
|
35
|
+
'Generate a 30-second demo video for this project as one self-contained HTML/JavaScript animation that presents its main goals and key features, grounded only in what you read in the repository. Save it with a single project_demo_video_write call.',
|
|
36
|
+
}),
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
module.exports = { BUILTIN_MACROS };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* claudeCliCaps.cjs — probes the installed `claude` CLI for
|
|
5
|
+
* `--permission-prompts` support once per process, caches the result.
|
|
6
|
+
*
|
|
7
|
+
* Headless spawns (scheduler/supervisor/docEdit/runClaudeP) have no human
|
|
8
|
+
* attached, so a tool that waits on AskUserQuestion or a permission prompt
|
|
9
|
+
* would stall the job forever. `--permission-prompts none` (CLI v2.1.285+)
|
|
10
|
+
* auto-denies those prompts and removes human-requiring tools. Older CLIs
|
|
11
|
+
* don't recognize the flag, so it's only appended when `claude --help`
|
|
12
|
+
* confirms support.
|
|
13
|
+
*
|
|
14
|
+
* Only a SUCCESSFUL probe (a real supported/unsupported determination from
|
|
15
|
+
* actual `--help` text) is cached for the rest of the process — an error
|
|
16
|
+
* (ENOENT, timeout, a throw) is never cached: this call returns [] (the safe
|
|
17
|
+
* default: omit the flag) but a LATER call re-probes, subject to a
|
|
18
|
+
* once-per-60s backoff so a persistently broken binary doesn't turn every
|
|
19
|
+
* headless spawn attempt into a fresh probe.
|
|
20
|
+
*
|
|
21
|
+
* The probe spawns the SAME binary/spawn target every real headless spawn
|
|
22
|
+
* site uses — `claudeSpawnTarget('aux', ...)` from claudeBin.cjs — not a raw
|
|
23
|
+
* `resolveClaudeBin()` result, so what gets probed is provably what later
|
|
24
|
+
* gets spawned (aliasing/argv0 labeling included).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const claudeBinLib = require('./claudeBin.cjs');
|
|
28
|
+
|
|
29
|
+
const PROBE_TIMEOUT_MS = 10_000;
|
|
30
|
+
const FLAG_ARGS = ['--permission-prompts', 'none'];
|
|
31
|
+
const DEFAULT_REPROBE_AFTER_ERROR_MS = 60_000;
|
|
32
|
+
|
|
33
|
+
let _execFile = require('node:child_process').execFile;
|
|
34
|
+
|
|
35
|
+
/** Test hook — inject a stub execFile(file, args, opts, cb) instead of spawning the real CLI. */
|
|
36
|
+
function _setExecFileForTest(fn) {
|
|
37
|
+
_execFile = fn || require('node:child_process').execFile;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Test hook — forget the cached probe result and any error backoff so the next call re-probes immediately. */
|
|
41
|
+
function _resetForTest() {
|
|
42
|
+
cachedArgs = null;
|
|
43
|
+
inflight = null;
|
|
44
|
+
lastErrorAt = 0;
|
|
45
|
+
reprobeAfterErrorMs = DEFAULT_REPROBE_AFTER_ERROR_MS;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Test hook — shrink the once-per-60s error backoff so a re-probe-after-error test doesn't need to sleep 60s. */
|
|
49
|
+
function _setReprobeBackoffMsForTest(ms) {
|
|
50
|
+
reprobeAfterErrorMs = typeof ms === 'number' && ms >= 0 ? ms : DEFAULT_REPROBE_AFTER_ERROR_MS;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let cachedArgs = null; // set ONLY by a successful probe — never by an error path
|
|
54
|
+
let inflight = null;
|
|
55
|
+
let lastErrorAt = 0;
|
|
56
|
+
let reprobeAfterErrorMs = DEFAULT_REPROBE_AFTER_ERROR_MS;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Probes `claude --help` once per process (successful result only); every
|
|
60
|
+
* call (including concurrent/later ones) resolves the same cached arg array
|
|
61
|
+
* once a successful probe has landed. A probe error is never cached — this
|
|
62
|
+
* call still resolves [] for the caller, but the NEXT call re-probes for
|
|
63
|
+
* real once `reprobeAfterErrorMs` has elapsed since the last error.
|
|
64
|
+
*/
|
|
65
|
+
function ensureCliCapsProbed() {
|
|
66
|
+
if (cachedArgs) return Promise.resolve(cachedArgs);
|
|
67
|
+
if (inflight) return inflight;
|
|
68
|
+
if (lastErrorAt && Date.now() - lastErrorAt < reprobeAfterErrorMs) {
|
|
69
|
+
return Promise.resolve([]);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let bin;
|
|
73
|
+
try { bin = claudeBinLib.resolveClaudeBin(); } catch { bin = 'claude'; }
|
|
74
|
+
let target;
|
|
75
|
+
try { target = claudeBinLib.claudeSpawnTarget('aux', 'cli-caps-probe', bin); } catch { target = { command: bin }; }
|
|
76
|
+
|
|
77
|
+
// NOTE: `inflight` is cleared via `.finally()` below, never directly
|
|
78
|
+
// inside this executor. A real `execFile` callback is always async, but a
|
|
79
|
+
// TEST stub firing its callback synchronously would otherwise run
|
|
80
|
+
// `succeed`/`fail` (and their `inflight = null`) to completion BEFORE the
|
|
81
|
+
// `inflight = promise` assignment two lines down ever runs — leaving
|
|
82
|
+
// `inflight` wedged at a stale, already-settled promise forever, so this
|
|
83
|
+
// function would never re-probe again regardless of the cache/backoff
|
|
84
|
+
// state. `.finally()` callbacks always run as a microtask, strictly after
|
|
85
|
+
// the synchronous assignment below, so this ordering hazard can't recur.
|
|
86
|
+
const promise = new Promise((resolve) => {
|
|
87
|
+
const succeed = (args) => {
|
|
88
|
+
cachedArgs = args;
|
|
89
|
+
resolve(args);
|
|
90
|
+
};
|
|
91
|
+
const fail = () => {
|
|
92
|
+
lastErrorAt = Date.now();
|
|
93
|
+
resolve([]);
|
|
94
|
+
};
|
|
95
|
+
try {
|
|
96
|
+
const execOpts = { timeout: PROBE_TIMEOUT_MS, windowsHide: true };
|
|
97
|
+
if (target.argv0) execOpts.argv0 = target.argv0;
|
|
98
|
+
_execFile(target.command, ['--help'], execOpts, (err, stdout) => {
|
|
99
|
+
if (err) {
|
|
100
|
+
console.warn('[claudeCliCaps] claude --help probe failed; headless spawns will omit --permission-prompts:', err?.message || err);
|
|
101
|
+
fail();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
succeed(String(stdout || '').includes('--permission-prompts') ? FLAG_ARGS.slice() : []);
|
|
105
|
+
});
|
|
106
|
+
} catch (e) {
|
|
107
|
+
console.warn('[claudeCliCaps] claude --help probe threw; headless spawns will omit --permission-prompts:', e?.message || e);
|
|
108
|
+
fail();
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
inflight = promise;
|
|
112
|
+
promise.finally(() => {
|
|
113
|
+
if (inflight === promise) inflight = null;
|
|
114
|
+
});
|
|
115
|
+
return promise;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Sync accessor for the cached probe result — [] until ensureCliCapsProbed() has resolved successfully at least once. */
|
|
119
|
+
function headlessPermissionArgs() {
|
|
120
|
+
return cachedArgs ? cachedArgs.slice() : [];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
module.exports = {
|
|
124
|
+
headlessPermissionArgs,
|
|
125
|
+
ensureCliCapsProbed,
|
|
126
|
+
_setExecFileForTest,
|
|
127
|
+
_resetForTest,
|
|
128
|
+
_setReprobeBackoffMsForTest,
|
|
129
|
+
};
|