claude-code-session-manager 0.141.0 → 0.143.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/.claude-plugin/marketplace.json +1 -1
- package/README.md +76 -153
- package/bin/cli.cjs +11 -0
- package/dist/assets/AppSettings-BO4jDVGO.js +2 -0
- package/dist/assets/{History-DJMiuXyK.js → History-DTttbvPb.js} +1 -1
- package/dist/assets/HomeClaudeConfig-DADP5bfn.js +3 -0
- package/dist/assets/{Panel-Bf1Cf8UL.js → Panel-B_D4Bg7L.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-BWPpypf9.js → ProjectClaudeConfig-DPnDJKcr.js} +7 -7
- package/dist/assets/Scheduler-CNLjn90m.js +16 -0
- package/dist/assets/{SkillReferenceGraph-Ba4TkX2C.js → SkillReferenceGraph-D1b2aiol.js} +1 -1
- package/dist/assets/{Skills-C1v91GEO.js → Skills-cfV7sgk6.js} +5 -5
- package/dist/assets/{TiptapBody-BrcWVpiW.js → TiptapBody-DVXtEIVy.js} +1 -1
- package/dist/assets/Toggle-CYajnSdx.js +1 -0
- package/dist/assets/{VoiceButton-qivnDV6K.js → VoiceButton-DJ4gGRuE.js} +1 -1
- package/dist/assets/{historyTotals-CMCPTKqC.js → historyTotals-D3MoHY2U.js} +1 -1
- package/dist/assets/index-CdTppjKR.js +3133 -0
- package/dist/assets/{index-DKXdXfka.css → index-DVHIHoJf.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +496 -484
- package/package.json +6 -4
- package/plugins/AGENTS.md +4 -3
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
- package/plugins/session-manager-dev/hooks/hooks.json +15 -0
- package/plugins/session-manager-dev/hooks/residue-check.cjs +241 -0
- package/plugins/session-manager-dev/skills/builder/SKILL.md +5 -0
- package/plugins/session-manager-dev/skills/develop/SKILL.md +58 -18
- package/plugins/session-manager-dev/skills/develop/standards.md +3 -2
- package/scripts/README.md +2 -0
- package/scripts/hooks/guard-tool-risk.cjs +5 -1
- package/scripts/hooks/lib/guard-tool-risk-policy.cjs +158 -1
- package/scripts/scheduler-mcp-server.cjs +1032 -112
- package/src/main/adminRouteRegistry.cjs +69 -0
- package/src/main/agentLibrary.cjs +72 -4
- package/src/main/agentsIpc.cjs +3 -2
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +336 -23
- package/src/main/config.cjs +35 -1
- package/src/main/docEdit.cjs +4 -2
- package/src/main/health.cjs +129 -2
- package/src/main/index.cjs +110 -52
- package/src/main/ipcSchemas.cjs +172 -8
- package/src/main/lib/AGENTS.md +1 -1
- package/src/main/lib/chatBootRecovery.cjs +2 -0
- package/src/main/lib/claude/agentModelResolve.cjs +51 -25
- package/src/main/lib/claude/agentSnapshot.cjs +186 -0
- package/src/main/lib/claude/environmentProfiles.cjs +242 -0
- package/src/main/lib/claude/jobSandboxPolicy.cjs +241 -33
- package/src/main/lib/claude/personaToolScope.cjs +82 -31
- package/src/main/lib/claude/runClaudeP.cjs +4 -2
- package/src/main/lib/claude/toolRiskMarks.cjs +41 -1
- package/src/main/lib/claude/usageCircuit.cjs +49 -21
- package/src/main/lib/claude/vaultRefs.cjs +277 -0
- package/src/main/lib/demo-video-kit/capture.cjs +282 -12
- package/src/main/lib/demo-video-kit/cast.md +52 -0
- package/src/main/lib/demo-video-kit/character.cjs +778 -30
- package/src/main/lib/demo-video-kit/checks.cjs +120 -1
- package/src/main/lib/demo-video-kit/export.cjs +218 -0
- package/src/main/lib/demo-video-kit/frames.cjs +104 -9
- package/src/main/lib/demo-video-kit/kind-marketing.md +121 -0
- package/src/main/lib/demo-video-kit/kind-tiktok.md +103 -0
- package/src/main/lib/demo-video-kit/kokoroSay.cjs +205 -0
- package/src/main/lib/demo-video-kit/project-home-html.md +43 -0
- package/src/main/lib/demo-video-kit/projectSounds.cjs +191 -0
- package/src/main/lib/demo-video-kit/resumableRun.cjs +298 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +3 -3
- package/src/main/lib/demo-video-kit/sound.cjs +166 -9
- package/src/main/lib/demo-video-kit/standalone.cjs +231 -0
- package/src/main/lib/demo-video-kit/voiceLane.cjs +233 -0
- package/src/main/lib/demo-video-kit/voiceLibrary.cjs +312 -0
- package/src/main/lib/epic/activeIndexMerge.cjs +5 -0
- package/src/main/lib/epic/artifactAdminRoutes.cjs +211 -0
- package/src/main/lib/epic/artifactIpc.cjs +153 -0
- package/src/main/lib/epic/artifactNotice.cjs +72 -0
- package/src/main/lib/epic/artifactRetention.cjs +356 -0
- package/src/main/lib/epic/artifactStore.cjs +435 -0
- package/src/main/lib/epic/delegationReadiness.cjs +83 -2
- package/src/main/lib/epic/epicAgentRefresh.cjs +97 -0
- package/src/main/lib/epic/epicEventLog.cjs +258 -0
- package/src/main/lib/epic/epicMint.cjs +43 -1
- package/src/main/lib/epic/epicOutsideRead.cjs +1 -0
- package/src/main/lib/epic/epicOutsideState.cjs +18 -4
- package/src/main/lib/epic/epicPurge.cjs +347 -0
- package/src/main/lib/epic/epicReopen.cjs +5 -2
- package/src/main/lib/epic/epicSettle.cjs +4 -13
- package/src/main/lib/epic/epicSpawnPlan.cjs +57 -4
- package/src/main/lib/epic/epicStateEmitter.cjs +248 -0
- package/src/main/lib/epic/epicStatusMirror.cjs +34 -1
- package/src/main/lib/epic/epicTransitions.cjs +139 -0
- package/src/main/lib/epic/epicValidationHook.cjs +94 -4
- package/src/main/lib/epic/guardSpawnSettings.cjs +3 -2
- package/src/main/lib/externalContract.cjs +48 -4
- package/src/main/lib/feedback-remote/autoStartedSession.cjs +1 -1
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +478 -127
- package/src/main/lib/feedback-remote/customerFeedbackAdminRoutes.cjs +16 -3
- package/src/main/lib/feedback-remote/customerFeedbackClient.cjs +11 -6
- package/src/main/lib/feedback-remote/customerFeedbackInbox.cjs +26 -1
- package/src/main/lib/feedback-remote/customerFeedbackIpc.cjs +5 -2
- package/src/main/lib/feedback-remote/feedbackBoxDrain.cjs +409 -0
- package/src/main/lib/feedback-remote/feedbackBoxKeys.cjs +218 -0
- package/src/main/lib/feedback-remote/feedbackEnvelope.cjs +163 -0
- package/src/main/lib/feedback-remote/feedbackRelayClient.cjs +164 -0
- package/src/main/lib/feedback-remote/feedbackReport.cjs +234 -0
- package/src/main/lib/feedback-remote/feedbackSeal.cjs +217 -0
- package/src/main/lib/feedback-remote/localAdminHttp.cjs +108 -2
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +32 -1
- package/src/main/lib/feedback-remote/needsYouIpc.cjs +17 -0
- package/src/main/lib/feedback-remote/needsYouStore.cjs +177 -6
- package/src/main/lib/feedback-remote/pendingReplies.cjs +207 -0
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +282 -14
- package/src/main/lib/feedback-remote/replyClaims.cjs +159 -0
- package/src/main/lib/feedback-remote/serviceClient.cjs +429 -0
- package/src/main/lib/feedback-remote/serviceMcpSession.cjs +252 -0
- package/src/main/lib/feedback-remote/serviceMcpTools.cjs +284 -0
- package/src/main/lib/feedback-remote/servicePairings.cjs +313 -0
- package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +290 -0
- package/src/main/lib/feedback-remote/siteFeedbackAdminRoutes.cjs +295 -0
- package/src/main/lib/feedback-remote/siteFeedbackInbox.cjs +598 -0
- package/src/main/lib/feedback-remote/siteFeedbackIpc.cjs +86 -0
- package/src/main/lib/feedback-remote/siteFeedbackService.cjs +477 -0
- package/src/main/lib/git/gitWorktree.cjs +8 -0
- package/src/main/lib/git/runtimeStateUntrack.cjs +15 -1
- package/src/main/lib/git/worktreeDeps.cjs +182 -4
- package/src/main/lib/mcpToolCatalog.cjs +399 -29
- package/src/main/lib/opsOwnership.cjs +141 -28
- package/src/main/lib/opsRetentionSettings.cjs +27 -5
- package/src/main/lib/persona-macro/builtinMacros.cjs +7 -2
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +52 -8
- package/src/main/lib/persona-macro/macroJobIpc.cjs +16 -6
- package/src/main/lib/persona-macro/macroLibrary.cjs +49 -7
- package/src/main/lib/persona-macro/personaFrontmatterSchema.cjs +83 -0
- package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +3 -0
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +309 -0
- package/src/main/lib/phaseProjection.cjs +103 -0
- package/src/main/lib/prd/depSlugResolve.cjs +4 -13
- package/src/main/lib/prd/prdBodyPatch.cjs +12 -17
- package/src/main/lib/prd/prdCreate.cjs +387 -228
- package/src/main/lib/prd/prdCriteria.cjs +228 -0
- package/src/main/lib/prd/prdFrontmatter.cjs +43 -3
- package/src/main/lib/prd/prdGateFiles.cjs +125 -49
- package/src/main/lib/prd/prdSizing.cjs +3 -1
- package/src/main/lib/process/cleanEnv.cjs +52 -1
- package/src/main/lib/process/leftoverRenice.cjs +178 -0
- package/src/main/lib/process/memoryScope.cjs +31 -3
- package/src/main/lib/project-pages/pagesLibrary.cjs +72 -6
- package/src/main/lib/project-pages/videoPressLines.cjs +145 -0
- package/src/main/lib/project-pages/videoReviewIpc.cjs +3 -2
- package/src/main/lib/project-pages/videoScriptPress.cjs +260 -0
- package/src/main/lib/project-pages/videoScriptRunRoute.cjs +351 -0
- package/src/main/lib/project-pages/videoScriptSwitchIpc.cjs +49 -0
- package/src/main/lib/project-pages/videoScriptSwitchRoute.cjs +173 -0
- package/src/main/lib/project-pages/voiceAdminRoutes.cjs +175 -0
- package/src/main/lib/project-pages/voicePreview.cjs +196 -0
- package/src/main/lib/project-pages/voicesIpc.cjs +186 -0
- package/src/main/lib/promptSessionSchema.cjs +6 -0
- package/src/main/lib/scheduler/cancelledRow.cjs +57 -0
- package/src/main/lib/scheduler/cpuSample.cjs +133 -42
- package/src/main/lib/scheduler/criteriaChecks.cjs +313 -0
- package/src/main/lib/scheduler/definitionOfDone.cjs +44 -5
- package/src/main/lib/scheduler/heldSchedulerTurns.cjs +238 -0
- package/src/main/lib/scheduler/jobMemoryStats.cjs +324 -0
- package/src/main/lib/scheduler/loadGate.cjs +82 -4
- package/src/main/lib/scheduler/planRecordHarvest.cjs +152 -54
- package/src/main/lib/scheduler/prdOutcomeRecord.cjs +191 -0
- package/src/main/lib/scheduler/queueStore.cjs +16 -0
- package/src/main/lib/scheduler/rcaReport.cjs +79 -15
- package/src/main/lib/scheduler/runLogRetention.cjs +42 -1
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +18 -0
- package/src/main/lib/scheduler/scheduleJobTransitions.cjs +47 -0
- package/src/main/lib/scheduler/schedulerConfig.cjs +47 -0
- package/src/main/lib/scheduler/schedulerPaths.cjs +9 -3
- package/src/main/lib/scheduler/schedulerRuntimeState.cjs +50 -1
- package/src/main/lib/scheduler/sessionSlots.cjs +5 -1
- package/src/main/lib/scheduler/slotsRoute.cjs +251 -0
- package/src/main/lib/scheduler/toolClearance.cjs +258 -0
- package/src/main/lib/scheduler/usageHoldRoute.cjs +97 -0
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +152 -11
- package/src/main/lib/tasks/memoryConsolidation.cjs +312 -0
- package/src/main/lib/tasks/mitigationReview.cjs +314 -0
- package/src/main/lib/tasks/taskAdminRoutes.cjs +390 -25
- package/src/main/lib/tasks/taskIpc.cjs +22 -18
- package/src/main/lib/tasks/taskLedger.cjs +147 -25
- package/src/main/lib/tasks/taskRun.cjs +186 -17
- package/src/main/lib/tasks/taskSwitch.cjs +85 -12
- package/src/main/lib/tasks/taskSwitchRoute.cjs +172 -0
- package/src/main/lib/telemetry/auditEvents.cjs +204 -6
- package/src/main/lib/telemetry/auditLog.cjs +6 -2
- package/src/main/lib/telemetry/eventsAdminRoutes.cjs +198 -6
- package/src/main/lib/telemetry/webhookDelivery.cjs +205 -0
- package/src/main/lib/telemetry/webhookRegistry.cjs +281 -0
- package/src/main/lib/toolUseClassify.cjs +181 -0
- package/src/main/lib/util/atomicFs.cjs +2 -2
- package/src/main/lib/util/smfileRange.cjs +77 -0
- package/src/main/projectPages.cjs +3 -1
- package/src/main/promptSessionEvents.cjs +21 -1
- package/src/main/pty.cjs +77 -0
- package/src/main/queueOps.cjs +33 -14
- package/src/main/runVerify.cjs +74 -9
- package/src/main/scheduler/AGENTS.md +1 -0
- package/src/main/scheduler/budget.cjs +6 -5
- package/src/main/scheduler/prdParser.cjs +46 -13
- package/src/main/scheduler/reviewLadder.cjs +9 -25
- package/src/main/scheduler/utilizationHold.cjs +191 -0
- package/src/main/scheduler.cjs +1932 -213
- package/src/main/templates/PRD_AUTHORING.md +11 -3
- package/src/main/webRemote.cjs +463 -6
- package/src/preload/api.d.ts +576 -39
- package/src/preload/apiSurface.json +223 -7
- package/src/preload/index.cjs +48 -1
- package/src/seed/agents/architect.md +6 -1
- package/src/seed/agents/blender-artist.md +2 -1
- package/src/seed/agents/competitive-analyst.md +3 -1
- package/src/seed/agents/competitive-researcher.md +2 -1
- package/src/seed/agents/demo-video-builder.md +98 -87
- package/src/seed/agents/dev-lead.md +3 -3
- package/src/seed/agents/project-home-builder.md +9 -31
- package/src/seed/agents/validator.md +23 -23
- package/dist/assets/AppSettings-DExeJhqQ.js +0 -2
- package/dist/assets/HomeClaudeConfig-CTp2tkZ4.js +0 -3
- package/dist/assets/Scheduler-cyr61UAC.js +0 -16
- package/dist/assets/ViewTabs-DXhOWFG0.js +0 -1
- package/dist/assets/index-B2TQz3nd.js +0 -3121
- package/src/main/lib/epic/epicStateWatcher.cjs +0 -157
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* phaseProjection.cjs — one outside "phase" for every Epic, scheduler job and Task.
|
|
5
|
+
*
|
|
6
|
+
* Top-level in lib/ (not under epic/, scheduler/ or tasks/) because it spans
|
|
7
|
+
* all three domains: each has its own status vocabulary, and an outside
|
|
8
|
+
* reader needs ONE small answer to "is anything happening, and is it mine to
|
|
9
|
+
* act on?". Pure: no fs, no clock, no mutation.
|
|
10
|
+
*
|
|
11
|
+
* idle — nothing is running and nothing is asked of anyone
|
|
12
|
+
* running — work is in flight (or queued to run)
|
|
13
|
+
* rescheduling — something stopped and the scheduler's own recovery
|
|
14
|
+
* ladder is still working on it
|
|
15
|
+
* waiting_on_human — a real question is open, or the ladder gave up
|
|
16
|
+
* terminated — finished for good (done, skipped, cancelled, closed)
|
|
17
|
+
*
|
|
18
|
+
* Matches src/renderer/lib/needsHuman.ts: a needs_review park is the
|
|
19
|
+
* scheduler's job ("being fixed"), never the human's — UNTIL the ladder gives
|
|
20
|
+
* up. The ladder's give-up signal is the grouped review notice going out
|
|
21
|
+
* (reviewNotice.sentAt — sent only when the ladder fails or the hold window
|
|
22
|
+
* ends; lib/scheduler/reviewNotice.cjs), or a park the ladder never touches
|
|
23
|
+
* by design (verdict 'refire_capped', see scheduler/reviewLadder.cjs
|
|
24
|
+
* isRefireCapped). A run that asked a question (verdict 'needs_human') and an
|
|
25
|
+
* Epic chat with an open question (needs-input) are real questions.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const { isCancelledRow } = require('./scheduler/cancelledRow.cjs');
|
|
29
|
+
|
|
30
|
+
const PHASES = Object.freeze(['idle', 'running', 'rescheduling', 'waiting_on_human', 'terminated']);
|
|
31
|
+
|
|
32
|
+
/** Precedence when several jobs make up one Epic: the first match wins. */
|
|
33
|
+
const EPIC_PRECEDENCE = Object.freeze(['waiting_on_human', 'rescheduling', 'running']);
|
|
34
|
+
|
|
35
|
+
const isObj = (v) => v != null && typeof v === 'object';
|
|
36
|
+
|
|
37
|
+
/** True when a needs_review row is no longer the ladder's to fix. */
|
|
38
|
+
function ladderGaveUp(job) {
|
|
39
|
+
if (job.verifierVerdict === 'refire_capped') return true;
|
|
40
|
+
const n = isObj(job.reviewNotice) ? job.reviewNotice : null;
|
|
41
|
+
return !!(n && typeof n.sentAt === 'string' && n.sentAt);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param {any} job a scheduler queue row (or any { status, ... } shape)
|
|
46
|
+
* @returns {'idle'|'running'|'rescheduling'|'waiting_on_human'|'terminated'}
|
|
47
|
+
*/
|
|
48
|
+
function phaseOfJob(job) {
|
|
49
|
+
if (!isObj(job)) return 'idle';
|
|
50
|
+
const status = typeof job.status === 'string' ? job.status : '';
|
|
51
|
+
if (isCancelledRow(job)) return 'terminated';
|
|
52
|
+
switch (status) {
|
|
53
|
+
case 'pending': return 'idle';
|
|
54
|
+
case 'running': return 'running';
|
|
55
|
+
// An auto-fix investigation and a quarantine are both ladder rungs.
|
|
56
|
+
case 'investigating':
|
|
57
|
+
case 'quarantined': return 'rescheduling';
|
|
58
|
+
case 'failed': return ladderGaveUp(job) ? 'waiting_on_human' : 'rescheduling';
|
|
59
|
+
case 'needs_review':
|
|
60
|
+
if (job.verifierVerdict === 'needs_human') return 'waiting_on_human';
|
|
61
|
+
return ladderGaveUp(job) ? 'waiting_on_human' : 'rescheduling';
|
|
62
|
+
case 'completed':
|
|
63
|
+
case 'skipped': return 'terminated';
|
|
64
|
+
default: return 'idle';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @param {{ status?: string, needsInput?: boolean, chatBusy?: boolean, jobPhases?: string[], refuted?: number }} [args]
|
|
70
|
+
* status — the Epic's lifecycle status (proposed / active / completed)
|
|
71
|
+
* jobPhases — phaseOfJob of each of the Epic's known PRDs
|
|
72
|
+
* refuted — count of PRDs whose newest verdict is refuted (the Epic's
|
|
73
|
+
* automated turn queues their fix, so: rescheduling)
|
|
74
|
+
* @returns {'idle'|'running'|'rescheduling'|'waiting_on_human'|'terminated'}
|
|
75
|
+
*/
|
|
76
|
+
function phaseOfEpic(args) {
|
|
77
|
+
const a = isObj(args) ? args : {};
|
|
78
|
+
if (a.status === 'completed') return 'terminated';
|
|
79
|
+
// A proposed Epic waits for a human to approve it.
|
|
80
|
+
if (a.status === 'proposed') return 'waiting_on_human';
|
|
81
|
+
if (a.needsInput === true && a.chatBusy !== true) return 'waiting_on_human';
|
|
82
|
+
const phases = Array.isArray(a.jobPhases) ? a.jobPhases : [];
|
|
83
|
+
if (phases.includes('waiting_on_human')) return 'waiting_on_human';
|
|
84
|
+
if (phases.includes('rescheduling') || (typeof a.refuted === 'number' && a.refuted > 0)) return 'rescheduling';
|
|
85
|
+
// A queued (idle) PRD inside an active Epic is work about to run.
|
|
86
|
+
if (a.chatBusy === true || phases.includes('running') || phases.includes('idle')) return 'running';
|
|
87
|
+
return 'idle';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @param {any} task a folded Task ledger row ({ status: 'running' | an end status })
|
|
92
|
+
* @returns {'idle'|'running'|'rescheduling'|'waiting_on_human'|'terminated'}
|
|
93
|
+
*/
|
|
94
|
+
function phaseOfTask(task) {
|
|
95
|
+
const status = isObj(task) && typeof task.status === 'string' ? task.status : '';
|
|
96
|
+
if (!status) return 'idle';
|
|
97
|
+
if (status === 'running') return 'running';
|
|
98
|
+
// Every other Task status is a terminal end status (taskLedger.cjs
|
|
99
|
+
// TERMINAL_STATUSES); a Task is never retried by Session Manager.
|
|
100
|
+
return 'terminated';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
module.exports = { PHASES, EPIC_PRECEDENCE, phaseOfJob, phaseOfEpic, phaseOfTask };
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* record and Epic ordering on top of the same bare-name rule.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
const { isCancelledRow } = require('../scheduler/cancelledRow.cjs');
|
|
20
|
+
|
|
19
21
|
/** Strip one leading `NN-` prefix, if present. */
|
|
20
22
|
function bareSlug(slug) {
|
|
21
23
|
return String(slug ?? '').replace(/^\d+-/, '');
|
|
@@ -86,17 +88,6 @@ function findNearMatches(depSlug, candidateSlugs, limit = 3) {
|
|
|
86
88
|
.map((entry) => entry.slug);
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
/**
|
|
90
|
-
* Was this row cancelled by a human (admin API cancel), rather than failing on
|
|
91
|
-
* its own? scheduler.cjs's cancel handler stamps `cancelledAt` and an error
|
|
92
|
-
* starting 'cancelled via admin API'; either marker counts.
|
|
93
|
-
*/
|
|
94
|
-
function isCancelledRow(row) {
|
|
95
|
-
if (!row) return false;
|
|
96
|
-
if (typeof row.cancelledAt === 'string' ? row.cancelledAt.length > 0 : row.cancelledAt != null) return true;
|
|
97
|
-
return typeof row.error === 'string' && row.error.startsWith('cancelled via admin API');
|
|
98
|
-
}
|
|
99
|
-
|
|
100
91
|
/** The Epic a queue row belongs to: `epicId`, else its `sourcePromptId`. */
|
|
101
92
|
function epicOf(job) {
|
|
102
93
|
return job?.epicId ?? job?.sourcePromptId ?? null;
|
|
@@ -125,7 +116,7 @@ function isPrefixedSlug(slug) {
|
|
|
125
116
|
* dependent's Epic → 'row'
|
|
126
117
|
* 5. bare dep: a satisfied record with that bare name → 'satisfied'
|
|
127
118
|
* 6. → 'unresolved'
|
|
128
|
-
* In steps 3-4 a cancelled row (isCancelledRow) is dropped when a satisfied
|
|
119
|
+
* In steps 3-4 a cancelled row (isCancelledRow, lib/scheduler/cancelledRow.cjs) is dropped when a satisfied
|
|
129
120
|
* record shares its bare name — a human-cancelled duplicate must never freeze
|
|
130
121
|
* the dependents of the PRD that genuinely finished (Self, 2026-11-22: the
|
|
131
122
|
* cancelled 1056-sm-contract-client froze 16 dependents of the completed
|
|
@@ -183,5 +174,5 @@ function makeDepResolver(projectJobs, satisfiedSlugs = new Set(), opts = {}) {
|
|
|
183
174
|
}
|
|
184
175
|
|
|
185
176
|
module.exports = {
|
|
186
|
-
bareSlug, resolveDepSlug, findNearMatches, isSatisfiedDepRow,
|
|
177
|
+
bareSlug, resolveDepSlug, findNearMatches, isSatisfiedDepRow, epicOf, makeDepResolver,
|
|
187
178
|
};
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
const { validateGate, validateFiles, renderFilesSection, renderGateSection } = require('./prdGateFiles.cjs');
|
|
10
10
|
const { resolveGate, parseChain, isNoneGate } = require('../scheduler/definitionOfDone.cjs');
|
|
11
|
+
const { validateCriteria, renderCriteriaLines } = require('./prdCriteria.cjs');
|
|
11
12
|
|
|
12
13
|
const H_AC = '# Acceptance criteria';
|
|
13
14
|
const H_FILES = '# Files';
|
|
@@ -58,8 +59,11 @@ function gateSignature(body) {
|
|
|
58
59
|
|
|
59
60
|
/**
|
|
60
61
|
* @param {string} body
|
|
61
|
-
* @param {{gate?: string[], files?: string[], acceptanceCriteria?:
|
|
62
|
-
*
|
|
62
|
+
* @param {{gate?: string[], files?: string[], acceptanceCriteria?: unknown[], previousCriteria?: unknown}} patch
|
|
63
|
+
* acceptanceCriteria entries are strings or structured criteria (prdCriteria.cjs);
|
|
64
|
+
* previousCriteria (the PRD's frontmatter `criteria`) keeps ids stable.
|
|
65
|
+
* @returns {{ok:true, body:string, warnings:string[], criteria?: object[]}|{ok:false, error:string}}
|
|
66
|
+
* `criteria` (when acceptanceCriteria was patched) is what the caller writes to frontmatter.
|
|
63
67
|
*/
|
|
64
68
|
function applyStructuredPrdPatch(body, patch) {
|
|
65
69
|
if (typeof body !== 'string') return { ok: false, error: 'body must be a string.' };
|
|
@@ -87,21 +91,12 @@ function applyStructuredPrdPatch(body, patch) {
|
|
|
87
91
|
if (!f.ok) return { ok: false, error: f.error };
|
|
88
92
|
filesList = f.files;
|
|
89
93
|
}
|
|
94
|
+
let criteria = null;
|
|
90
95
|
if (hasAc) {
|
|
91
|
-
const
|
|
92
|
-
if (!
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
acLines = [];
|
|
96
|
-
for (let i = 0; i < ac.length; i++) {
|
|
97
|
-
if (typeof ac[i] !== 'string' || ac[i].trim() === '') {
|
|
98
|
-
return { ok: false, error: `acceptanceCriteria entry ${i + 1}: must be a non-empty string.` };
|
|
99
|
-
}
|
|
100
|
-
if (/[\r\n]/.test(ac[i])) {
|
|
101
|
-
return { ok: false, error: `acceptanceCriteria entry ${i + 1}: must not contain a newline.` };
|
|
102
|
-
}
|
|
103
|
-
acLines.push(`- [ ] ${ac[i].trim()}`);
|
|
104
|
-
}
|
|
96
|
+
const cv = validateCriteria(patch.acceptanceCriteria, { previous: patch.previousCriteria });
|
|
97
|
+
if (!cv.ok) return { ok: false, error: `acceptanceCriteria: ${cv.error}` };
|
|
98
|
+
criteria = cv.criteria;
|
|
99
|
+
acLines = renderCriteriaLines(criteria);
|
|
105
100
|
}
|
|
106
101
|
|
|
107
102
|
const lines = body.split('\n');
|
|
@@ -132,7 +127,7 @@ function applyStructuredPrdPatch(body, patch) {
|
|
|
132
127
|
return { ok: false, error: 'The patch would change how the scheduler reads the PRD gate (stray gate fence in the new text).' };
|
|
133
128
|
}
|
|
134
129
|
|
|
135
|
-
return { ok: true, body: next, warnings };
|
|
130
|
+
return criteria ? { ok: true, body: next, warnings, criteria } : { ok: true, body: next, warnings };
|
|
136
131
|
}
|
|
137
132
|
|
|
138
133
|
module.exports = { applyStructuredPrdPatch };
|