claude-code-session-manager 0.141.0 → 0.142.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 +80 -70
- package/bin/cli.cjs +11 -0
- package/dist/assets/AppSettings-BcZgIvvY.js +2 -0
- package/dist/assets/{History-DJMiuXyK.js → History-DpZuJXi1.js} +1 -1
- package/dist/assets/HomeClaudeConfig-D32ZJtU-.js +3 -0
- package/dist/assets/{Panel-Bf1Cf8UL.js → Panel-BjdJjhqt.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-BWPpypf9.js → ProjectClaudeConfig-BTClYV6i.js} +7 -7
- package/dist/assets/Scheduler-DPobKx1Z.js +16 -0
- package/dist/assets/{SkillReferenceGraph-Ba4TkX2C.js → SkillReferenceGraph-Cqyu4mef.js} +1 -1
- package/dist/assets/{Skills-C1v91GEO.js → Skills-vv0noNVI.js} +5 -5
- package/dist/assets/{TiptapBody-BrcWVpiW.js → TiptapBody-CXi8Pvut.js} +1 -1
- package/dist/assets/Toggle-CiYCWLjh.js +1 -0
- package/dist/assets/{VoiceButton-qivnDV6K.js → VoiceButton-4NKKd1sC.js} +1 -1
- package/dist/assets/{historyTotals-CMCPTKqC.js → historyTotals-DDunb8Ch.js} +1 -1
- package/dist/assets/index-Cn5E9958.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 +4 -2
- package/plugins/AGENTS.md +4 -3
- 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/develop/SKILL.md +52 -18
- package/plugins/session-manager-dev/skills/develop/standards.md +3 -2
- package/scripts/README.md +1 -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 +732 -110
- package/src/main/adminRouteRegistry.cjs +59 -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 +231 -16
- package/src/main/config.cjs +30 -0
- package/src/main/docEdit.cjs +4 -2
- package/src/main/health.cjs +91 -0
- package/src/main/index.cjs +98 -48
- package/src/main/ipcSchemas.cjs +161 -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 +43 -0
- package/src/main/lib/demo-video-kit/character.cjs +722 -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 +99 -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/resumableRun.cjs +298 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +3 -3
- 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/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 +310 -0
- package/src/main/lib/epic/artifactStore.cjs +392 -0
- package/src/main/lib/epic/delegationReadiness.cjs +76 -2
- package/src/main/lib/epic/epicAgentRefresh.cjs +97 -0
- package/src/main/lib/epic/epicEventLog.cjs +214 -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/epicStatusMirror.cjs +34 -1
- package/src/main/lib/epic/epicTransitions.cjs +139 -0
- package/src/main/lib/epic/epicValidationHook.cjs +81 -2
- package/src/main/lib/epic/guardSpawnSettings.cjs +3 -2
- package/src/main/lib/externalContract.cjs +37 -4
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +389 -126
- 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 +2 -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 +189 -0
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +188 -10
- 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/worktreeDeps.cjs +77 -2
- package/src/main/lib/mcpToolCatalog.cjs +304 -28
- package/src/main/lib/opsOwnership.cjs +29 -1
- 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 +263 -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 +41 -5
- package/src/main/lib/prd/prdCriteria.cjs +225 -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/videoReviewIpc.cjs +3 -2
- 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 +169 -0
- package/src/main/lib/scheduler/definitionOfDone.cjs +44 -5
- package/src/main/lib/scheduler/jobMemoryStats.cjs +313 -0
- package/src/main/lib/scheduler/loadGate.cjs +82 -4
- package/src/main/lib/scheduler/planRecordHarvest.cjs +32 -2
- package/src/main/lib/scheduler/prdOutcomeRecord.cjs +133 -0
- package/src/main/lib/scheduler/runLogRetention.cjs +42 -1
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +5 -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 +0 -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 +237 -0
- package/src/main/lib/scheduler/toolClearance.cjs +258 -0
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +140 -10
- package/src/main/lib/tasks/memoryConsolidation.cjs +300 -0
- package/src/main/lib/tasks/mitigationReview.cjs +294 -0
- package/src/main/lib/tasks/taskAdminRoutes.cjs +312 -22
- 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 +207 -6
- 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/smfileRange.cjs +77 -0
- package/src/main/projectPages.cjs +3 -1
- package/src/main/promptSessionEvents.cjs +5 -0
- package/src/main/pty.cjs +68 -0
- package/src/main/queueOps.cjs +32 -13
- 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 +101 -0
- package/src/main/scheduler.cjs +1414 -189
- package/src/main/templates/PRD_AUTHORING.md +5 -2
- package/src/main/webRemote.cjs +463 -6
- package/src/preload/api.d.ts +529 -38
- package/src/preload/apiSurface.json +209 -7
- package/src/preload/index.cjs +46 -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 +87 -83
- 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 +9 -10
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-session-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.142.0",
|
|
4
4
|
"description": "Free desktop app for Claude Code: run many sessions, each in its own git worktree; queue work that runs headless within your usage limits; agents drive it through an MCP server and skills.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main/index.cjs",
|
|
@@ -73,6 +73,8 @@
|
|
|
73
73
|
"lint:readme": "node scripts/check-readme.cjs",
|
|
74
74
|
"readme:build": "node scripts/check-readme.cjs --write",
|
|
75
75
|
"lint:paths": "node scripts/check-ops-path-literals.cjs",
|
|
76
|
+
"lint:status-writes": "node scripts/check-status-writes.cjs",
|
|
77
|
+
"lint:event-log": "node scripts/check-event-log-writers.cjs",
|
|
76
78
|
"lint:any": "node scripts/check-explicit-any.cjs",
|
|
77
79
|
"lint:main-ts-check": "node scripts/check-main-ts-check.cjs",
|
|
78
80
|
"lint:filenames": "node scripts/check-tracked-filenames.cjs",
|
|
@@ -82,7 +84,7 @@
|
|
|
82
84
|
"lint:e2e-budget": "node scripts/check-e2e-budget.cjs",
|
|
83
85
|
"lint:scroll": "node scripts/check-scroll-into-view.cjs",
|
|
84
86
|
"check:frame": "node scripts/frame-integrity.mjs",
|
|
85
|
-
"lint": "npm run lint:selectors && npm run lint:hooks && npm run lint:docs && npm run lint:paths && npm run lint:any && npm run lint:main-ts-check && npm run lint:filenames && npm run lint:renderer-storage && npm run lint:test-smells && npm run lint:page-stewards && npm run lint:e2e-budget && npm run lint:scroll && npm run lint:readme",
|
|
87
|
+
"lint": "npm run lint:selectors && npm run lint:hooks && npm run lint:docs && npm run lint:paths && npm run lint:status-writes && npm run lint:event-log && npm run lint:any && npm run lint:main-ts-check && npm run lint:filenames && npm run lint:renderer-storage && npm run lint:test-smells && npm run lint:page-stewards && npm run lint:e2e-budget && npm run lint:scroll && npm run lint:readme",
|
|
86
88
|
"sync:settings-schema": "node scripts/sync-settings-schema.cjs"
|
|
87
89
|
},
|
|
88
90
|
"keywords": [
|
package/plugins/AGENTS.md
CHANGED
|
@@ -8,6 +8,8 @@ Part of the **AGENT LAYER** partition — see
|
|
|
8
8
|
`session-manager-dev/skills/` — 4 skills (`builder`, `develop`, `maintaining-md-network`, `send-feedback`); keep in sync with `project-partition.md` and
|
|
9
9
|
`seedDevPlugin.cjs`'s header count.
|
|
10
10
|
|
|
11
|
+
`session-manager-dev/hooks/` — the residue Stop hook (develop rule 6).
|
|
12
|
+
|
|
11
13
|
`packs/<id>/` — context packs (plugin + `sm-pack.json` + optional `laws.md`), loaded per session by `--plugin-dir`, not the marketplace; read by `src/main/lib/packs/packCatalog.cjs`.
|
|
12
14
|
|
|
13
15
|
Two manifests: root [`.claude-plugin/marketplace.json`](../.claude-plugin/marketplace.json)
|
|
@@ -35,8 +37,7 @@ purpose and runs only when `session-manager-operations/manual/manual.json` exist
|
|
|
35
37
|
## Who consumes this
|
|
36
38
|
|
|
37
39
|
**Other repos**, not (only) this one. A project installs `claude-code-session-manager` from npm,
|
|
38
|
-
or references its skills/hooks directly.
|
|
39
|
-
Editing a skill here changes every consuming repo. See
|
|
40
|
+
or references its skills/hooks directly. See
|
|
40
41
|
[`../session-manager-operations/reviews/2026-09-12-agent-layer-consumers.md`](../session-manager-operations/reviews/2026-09-12-agent-layer-consumers.md)
|
|
41
42
|
for live consumers.
|
|
42
43
|
|
|
@@ -48,7 +49,7 @@ for live consumers.
|
|
|
48
49
|
never this repo's own absolute path or a copy.
|
|
49
50
|
- Do not confuse this with `.claude/` at the repo root — this repo's own unshipped local dev
|
|
50
51
|
config. `.claude/agents/*.md` are per-project OVERLAYS that win over
|
|
51
|
-
`~/.claude/agents/*.md` (
|
|
52
|
+
`~/.claude/agents/*.md` (per `src/main/agentLibrary.cjs`);
|
|
52
53
|
`src/seed/agents/` is the shipped source for the personas
|
|
53
54
|
`src/main/seedAgentPersonas.cjs` copies into `~/.claude/agents/` (its `PERSONAS` list);
|
|
54
55
|
`builder` has no seed source — the generic `~/.claude/agents/builder.md` is machine-local
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* residue-check.cjs — Stop-hook checker for the develop skill's rule 6
|
|
4
|
+
* (No residue): a report hands back nothing an agent could do.
|
|
5
|
+
*
|
|
6
|
+
* findResidue(text) is a pure function returning at most MAX_LINES report
|
|
7
|
+
* lines that hand work back without an outcome. Run as a script, it reads the
|
|
8
|
+
* Stop hook JSON from stdin and, when residue is found in an Epic chat turn,
|
|
9
|
+
* prints {"decision":"block","reason":...} once so the agent gives each line
|
|
10
|
+
* an outcome. Every error fails open (exit 0, no output).
|
|
11
|
+
*
|
|
12
|
+
* Ships inside the plugin to other repos: CommonJS, Node built-ins only, no
|
|
13
|
+
* dependency on src/main.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const fs = require('node:fs');
|
|
19
|
+
|
|
20
|
+
const MAX_LINES = 5;
|
|
21
|
+
const DEADLINE_MS = 4500;
|
|
22
|
+
const TRANSCRIPT_TAIL_BYTES = 8 * 1024 * 1024;
|
|
23
|
+
// Mirrors chatRunner.cjs's STOP_SENTINEL (kept literal: no src/main dependency).
|
|
24
|
+
const NEEDS_INPUT_SENTINEL = '<<<SM_NEEDS_INPUT>>>';
|
|
25
|
+
|
|
26
|
+
// A label counts only when it is the WHOLE heading / bold label (optional trailing colon):
|
|
27
|
+
// '## Remaining budget' or '**Deferred to PRD 4100 (queued)**' are not residue labels.
|
|
28
|
+
const RESIDUE_LABEL_RE = /^(still open|open items|remaining|not covered|deferred|follow[- ]?ups?|left for later|gaps?|what happens next)\s*:?$/i;
|
|
29
|
+
const NEEDS_YOU_LABEL_RE = /^needs you\b/i;
|
|
30
|
+
// Quoted spans skipped by the phrase match: a report quoting a phrase is analysing it, not handing work back.
|
|
31
|
+
// A straight single quote opens only after a non-word char, so apostrophes (it's, haven't) never open one.
|
|
32
|
+
const QUOTED_SPAN_RES = [/"[^"\n]*"/g, /“[^”\n]*”/g, /‘[^’\n]*’/g, /`[^`\n]*`/g, /(^|[^\w'])'[^'\n]*'(?![\w])/g];
|
|
33
|
+
const RESIDUE_PHRASES = ['needs a new epic', 'say the word', "haven't queued", "didn't look into", 'follow-up for later',
|
|
34
|
+
'one gap', 'left those to', 'i will add that', "i'll add that"];
|
|
35
|
+
// Each phrase as a whole-word, case-insensitive regex: 'one gap' must not fire on 'phone gap' / 'none gap'.
|
|
36
|
+
// An apostrophe counts as a word char at the bounds so "haven't" never matches inside a longer contraction.
|
|
37
|
+
const RESIDUE_PHRASE_RES = RESIDUE_PHRASES.map(
|
|
38
|
+
(p) => new RegExp(`(?<![\\w'])${p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![\\w'])`, 'i'));
|
|
39
|
+
// A line that names its own outcome (a PRD reference + an un-negated outcome verb) is not residue (rule 6).
|
|
40
|
+
// A PRD reference is 'PRD <n>' or an NNNN-kebab-slug (4300-fix-thing); a bare number, a year or a date
|
|
41
|
+
// (2026-11-23: a digit after the dash) is not one.
|
|
42
|
+
const PRD_REF_RES = [/\bPRD\s*#?\d+\b/i, /(?<![\w.-])\d{4}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?![\w-])/i];
|
|
43
|
+
const OUTCOME_VERB_RE = /\b(queued|closed|fixed|decided|scheduled)\b/gi;
|
|
44
|
+
// A negation anywhere before an outcome verb on the line ('not queued yet', "hasn't been fixed") voids the skip.
|
|
45
|
+
const NEGATION_RE = /(?<![\w'])(not|no|never|without|yet to|has not|hasn't|isn't)(?![\w'])/i;
|
|
46
|
+
const EMPTY_ENTRY_RE = /^(?:[-*+]\s*)?(?:none|nothing|n\/a)\.?$/i;
|
|
47
|
+
|
|
48
|
+
/** Lower-case and straighten curly apostrophes for phrase matching. */
|
|
49
|
+
function normalize(s) {
|
|
50
|
+
return s.replace(/[‘’ʼ]/g, "'").toLowerCase();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** True when a line carries its own outcome: a PRD reference and an outcome verb with no negation before it. */
|
|
54
|
+
function namesOwnOutcome(s) {
|
|
55
|
+
const line = normalize(s);
|
|
56
|
+
if (!PRD_REF_RES.some((re) => re.test(line))) return false;
|
|
57
|
+
const verbs = [...line.matchAll(OUTCOME_VERB_RE)];
|
|
58
|
+
if (!verbs.length) return false;
|
|
59
|
+
// Strict: a negation before ANY outcome verb (so before the last one) leaves the line counted.
|
|
60
|
+
const last = verbs[verbs.length - 1];
|
|
61
|
+
return !NEGATION_RE.test(line.slice(0, last.index));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Remove quoted spans (double, curly, single, backtick) from a line before the phrase match. */
|
|
65
|
+
function stripQuoted(s) {
|
|
66
|
+
let out = s;
|
|
67
|
+
for (const re of QUOTED_SPAN_RES) out = out.replace(re, (m, lead) => (typeof lead === 'string' ? `${lead} ` : ' '));
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Strip markdown emphasis + trailing punctuation from a label. */
|
|
72
|
+
function cleanLabel(s) {
|
|
73
|
+
return s.replace(/[*_`]/g, '').trim();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** `**Label:** rest` / `__Label__ rest` at line start → { label, rest }; else null. */
|
|
77
|
+
function parseBoldLabel(trimmed) {
|
|
78
|
+
const m = /^(?:[-*+]\s+)?(\*\*|__)(.+?)\1\s*:?\s*(.*)$/.exec(trimmed);
|
|
79
|
+
if (!m) return null;
|
|
80
|
+
return { label: cleanLabel(m[2]).replace(/:$/, '').trim(), rest: m[3].trim() };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Find report lines that hand work back without an outcome.
|
|
85
|
+
* @param {string} text
|
|
86
|
+
* @returns {string[]} at most MAX_LINES trimmed lines
|
|
87
|
+
*/
|
|
88
|
+
function findResidue(text) {
|
|
89
|
+
if (typeof text !== 'string' || !text) return [];
|
|
90
|
+
const out = [];
|
|
91
|
+
const lines = text.split(/\r?\n/);
|
|
92
|
+
let fence = null; // the fence marker while inside a code fence
|
|
93
|
+
let section = null; // 'residue' | 'needs-you' | null
|
|
94
|
+
let sectionKind = null; // 'heading' | 'bold'
|
|
95
|
+
let prevBlank = false;
|
|
96
|
+
|
|
97
|
+
for (const raw of lines) {
|
|
98
|
+
if (out.length >= MAX_LINES) break;
|
|
99
|
+
const trimmed = raw.trim();
|
|
100
|
+
|
|
101
|
+
const fenceMatch = /^(```+|~~~+)/.exec(trimmed);
|
|
102
|
+
if (fence) {
|
|
103
|
+
if (fenceMatch && fenceMatch[1][0] === fence[0] && fenceMatch[1].length >= fence.length) fence = null;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (fenceMatch) { fence = fenceMatch[1]; continue; }
|
|
107
|
+
if (trimmed.startsWith('>')) { prevBlank = false; continue; }
|
|
108
|
+
if (!trimmed) { prevBlank = true; continue; }
|
|
109
|
+
|
|
110
|
+
const heading = /^#{1,6}\s+(.*)$/.exec(trimmed);
|
|
111
|
+
if (heading) {
|
|
112
|
+
const label = cleanLabel(heading[1]);
|
|
113
|
+
section = NEEDS_YOU_LABEL_RE.test(label) ? 'needs-you' : RESIDUE_LABEL_RE.test(label) ? 'residue' : null;
|
|
114
|
+
sectionKind = 'heading';
|
|
115
|
+
prevBlank = false;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const bold = parseBoldLabel(trimmed);
|
|
120
|
+
let lineCounts = false;
|
|
121
|
+
let isLabelLine = false;
|
|
122
|
+
if (bold && (NEEDS_YOU_LABEL_RE.test(bold.label) || RESIDUE_LABEL_RE.test(bold.label) || !bold.rest)) {
|
|
123
|
+
section = NEEDS_YOU_LABEL_RE.test(bold.label) ? 'needs-you' : RESIDUE_LABEL_RE.test(bold.label) ? 'residue' : null;
|
|
124
|
+
sectionKind = 'bold';
|
|
125
|
+
isLabelLine = true;
|
|
126
|
+
if (section === 'residue' && bold.rest && !EMPTY_ENTRY_RE.test(bold.rest)) lineCounts = true;
|
|
127
|
+
} else if (sectionKind === 'bold' && prevBlank && !/^([-*+]|\d+[.)])\s/.test(trimmed) && !/^\s/.test(raw)) {
|
|
128
|
+
// A bold-label section ends at a new, non-list paragraph.
|
|
129
|
+
section = null;
|
|
130
|
+
sectionKind = null;
|
|
131
|
+
}
|
|
132
|
+
prevBlank = false;
|
|
133
|
+
|
|
134
|
+
if (section === 'needs-you') continue;
|
|
135
|
+
if (!isLabelLine && section === 'residue' && !EMPTY_ENTRY_RE.test(trimmed)) lineCounts = true;
|
|
136
|
+
if (!lineCounts && !trimmed.startsWith('|')) {
|
|
137
|
+
// Markdown table rows and quoted spans are analysis, not hand-backs: skip them for the phrase match.
|
|
138
|
+
const norm = normalize(stripQuoted(trimmed));
|
|
139
|
+
if (RESIDUE_PHRASE_RES.some((re) => re.test(norm))) lineCounts = true;
|
|
140
|
+
}
|
|
141
|
+
if (lineCounts && namesOwnOutcome(trimmed)) lineCounts = false;
|
|
142
|
+
if (lineCounts) out.push(trimmed);
|
|
143
|
+
}
|
|
144
|
+
return out;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** True when the message ends with the needs-input sentinel followed by its JSON line. */
|
|
148
|
+
function endsWithNeedsInput(text) {
|
|
149
|
+
if (typeof text !== 'string') return false;
|
|
150
|
+
const idx = text.lastIndexOf(NEEDS_INPUT_SENTINEL);
|
|
151
|
+
if (idx < 0) return false;
|
|
152
|
+
const after = text.slice(idx + NEEDS_INPUT_SENTINEL.length).trim()
|
|
153
|
+
.replace(/^```[a-z]*\s*/i, '').replace(/\s*```$/, '').trim();
|
|
154
|
+
if (!after) return true;
|
|
155
|
+
try {
|
|
156
|
+
const v = JSON.parse(after);
|
|
157
|
+
return v !== null && typeof v === 'object';
|
|
158
|
+
} catch {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Text of the last assistant entry with text content in a JSONL transcript. */
|
|
164
|
+
function lastAssistantTextFromTranscript(file) {
|
|
165
|
+
if (typeof file !== 'string' || !file) return '';
|
|
166
|
+
const fd = fs.openSync(file, 'r');
|
|
167
|
+
let buf;
|
|
168
|
+
try {
|
|
169
|
+
const size = fs.fstatSync(fd).size;
|
|
170
|
+
const len = Math.min(size, TRANSCRIPT_TAIL_BYTES);
|
|
171
|
+
buf = Buffer.alloc(len);
|
|
172
|
+
fs.readSync(fd, buf, 0, len, size - len);
|
|
173
|
+
} finally {
|
|
174
|
+
fs.closeSync(fd);
|
|
175
|
+
}
|
|
176
|
+
const lines = buf.toString('utf8').split('\n');
|
|
177
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
178
|
+
const line = lines[i].trim();
|
|
179
|
+
if (!line) continue;
|
|
180
|
+
let entry;
|
|
181
|
+
try { entry = JSON.parse(line); } catch { continue; }
|
|
182
|
+
if (!entry || entry.type !== 'assistant' || !entry.message) continue;
|
|
183
|
+
const content = entry.message.content;
|
|
184
|
+
if (typeof content === 'string') { if (content.trim()) return content; continue; }
|
|
185
|
+
if (!Array.isArray(content)) continue;
|
|
186
|
+
const text = content.filter((b) => b && b.type === 'text' && typeof b.text === 'string').map((b) => b.text).join('\n');
|
|
187
|
+
if (text.trim()) return text;
|
|
188
|
+
}
|
|
189
|
+
return '';
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function buildReason(found) {
|
|
193
|
+
return [
|
|
194
|
+
'No residue: this report hands back work without an outcome:',
|
|
195
|
+
...found.map((l) => ` > ${l}`),
|
|
196
|
+
'Give each one an outcome: queue a PRD (name its slug), decide it with a one-line revert, '
|
|
197
|
+
+ 'schedule it with its trigger (a dependsOn, a preflight hold or a date), or close it with a reason. '
|
|
198
|
+
+ "Put a step only the human can do under 'Needs you' as one exact action. Then end the turn again.",
|
|
199
|
+
].join('\n');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Decide from the parsed Stop input + env. Returns the JSON to print, or null. */
|
|
203
|
+
function evaluate(input, env) {
|
|
204
|
+
if (!env.SM_CHAT_SESSION_ID) return null;
|
|
205
|
+
// Scheduled claude -p jobs (scheduler.cjs childEnv) set SM_SCHEDULER_JOB_SLUG; they never set SM_CHAT_SESSION_ID
|
|
206
|
+
// themselves but may inherit it, so the job marker wins.
|
|
207
|
+
if (env.SM_SCHEDULER_JOB_SLUG || env.SM_SCHEDULER_JOB_EPIC_ID) return null;
|
|
208
|
+
if (env.SM_RESIDUE_CHECK === '0') return null;
|
|
209
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)) return null;
|
|
210
|
+
if (input.stop_hook_active === true) return null;
|
|
211
|
+
let text = typeof input.last_assistant_message === 'string' ? input.last_assistant_message : '';
|
|
212
|
+
if (!text.trim()) text = lastAssistantTextFromTranscript(input.transcript_path);
|
|
213
|
+
if (!text.trim() || endsWithNeedsInput(text)) return null;
|
|
214
|
+
const found = findResidue(text);
|
|
215
|
+
if (!found.length) return null;
|
|
216
|
+
return { decision: 'block', reason: buildReason(found) };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function main() {
|
|
220
|
+
const timer = setTimeout(() => process.exit(0), DEADLINE_MS);
|
|
221
|
+
timer.unref();
|
|
222
|
+
const chunks = [];
|
|
223
|
+
process.stdin.on('data', (c) => chunks.push(c));
|
|
224
|
+
process.stdin.on('error', () => process.exit(0));
|
|
225
|
+
process.stdin.on('end', () => {
|
|
226
|
+
try {
|
|
227
|
+
const raw = Buffer.concat(chunks).toString('utf8');
|
|
228
|
+
const result = evaluate(JSON.parse(raw), process.env);
|
|
229
|
+
if (result) process.stdout.write(JSON.stringify(result) + '\n');
|
|
230
|
+
} catch {
|
|
231
|
+
// fail open
|
|
232
|
+
}
|
|
233
|
+
process.exitCode = 0;
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
module.exports = { findResidue, endsWithNeedsInput, lastAssistantTextFromTranscript, evaluate, MAX_LINES };
|
|
238
|
+
|
|
239
|
+
if (require.main === module) {
|
|
240
|
+
try { main(); } catch { process.exit(0); }
|
|
241
|
+
}
|
|
@@ -41,6 +41,18 @@ new work. **report** = your final message to the human.
|
|
|
41
41
|
the reasons behind the run rules. Interactive work uses the built-in `/code-review` for
|
|
42
42
|
review (and `test-driven-development` / `systematic-debugging` skills when installed). Why:
|
|
43
43
|
one copy never goes stale.
|
|
44
|
+
6. **No residue.** A report hands back nothing an agent could do. Give every follow-up, gap,
|
|
45
|
+
finding (any severity) and open choice one outcome in the same turn: **queued** (its PRD
|
|
46
|
+
slug), **decided** (what you chose and a one-line revert), **scheduled** (what fires it
|
|
47
|
+
later: a `dependsOn`, a `preflight` hold or a date) or **closed** (a one-line reason). Only
|
|
48
|
+
a step that needs the human's own hands or authority goes under Needs you, as one exact
|
|
49
|
+
action: sudo, a vendor agreement, a 2FA code, a public publish nobody approved, or a switch
|
|
50
|
+
the project laws reserve for a human, or a PRD refuted twice on the same criterion (one
|
|
51
|
+
decision: re-plan it or drop that criterion). Never write "deferred", "follow-up for later", "needs
|
|
52
|
+
a new Epic from you" or "say the word". Why: a list nobody owns becomes debt the human has
|
|
53
|
+
to chase. Enforced by the plugin's Stop hook (`hooks/residue-check.cjs`): it checks each
|
|
54
|
+
Epic chat turn once and asks for an outcome for any line that hands work back;
|
|
55
|
+
`SM_RESIDUE_CHECK=0` turns it off.
|
|
44
56
|
|
|
45
57
|
## Phase 1 — plan and queue
|
|
46
58
|
|
|
@@ -52,6 +64,10 @@ One goal = one validate PRD = one plan card on the Scheduler. Why: the Scheduler
|
|
|
52
64
|
card as the validate PRD plus everything it transitively depends on.
|
|
53
65
|
The validate PRD's title is the card title, so write it as `Validate: <plain-language goal>`.
|
|
54
66
|
Keep one goal per validate PRD; a second goal is a second plan, with its own validate PRD.
|
|
67
|
+
A defect you find in this project outside the Epic's goal is such a second plan, queued in this
|
|
68
|
+
Epic (a side plan with its own `Validate: <goal>` PRD); the Epic's title and objective stay
|
|
69
|
+
unchanged. Never hand it back as needing a new Epic. A defect in another project goes to
|
|
70
|
+
`/send-feedback`.
|
|
55
71
|
Prefer wide over deep: PRDs that share no files run in parallel; only chain two PRDs on a real
|
|
56
72
|
file or output dependency, never to express reading order alone.
|
|
57
73
|
A follow-up or fix PRD for the same goal depends on that plan's open PRDs instead of starting
|
|
@@ -80,6 +96,12 @@ three failure modes have different fixes:
|
|
|
80
96
|
|
|
81
97
|
1. **Clarify only what a wrong guess would cost rework on.** Ask 2–4 plain-text questions in
|
|
82
98
|
one message, once, and wait. Never use AskUserQuestion. Why: Chat view turns run headless.
|
|
99
|
+
Decide instead of asking when the human's own words, the project laws or memory, or the code
|
|
100
|
+
already settle the choice, or when git can revert a wrong guess; report it under Decided
|
|
101
|
+
(rule 6). Ask only about what is irreversible outside git (data loss, a public publish,
|
|
102
|
+
money, contacting people) or what the project laws reserve for the human. Never repeat an
|
|
103
|
+
unanswered question in a later turn: take the option you recommended, unless the choice is
|
|
104
|
+
reserved.
|
|
83
105
|
2. **Explore broadly.** Find the absolute path, helpers and patterns to reuse, the test
|
|
84
106
|
command, constraints, and exact paths and signatures. Read look-alike siblings to confirm
|
|
85
107
|
the shape. Check existing tests, and `scheduler_list_prds` for an open PRD on the same
|
|
@@ -97,12 +119,20 @@ three failure modes have different fixes:
|
|
|
97
119
|
touches input, auth or data), never as follow-ups. Why: TDD needs the test with the code;
|
|
98
120
|
security is decided while writing it. Also check quality (performance, error handling).
|
|
99
121
|
Deeper edge cases, hardening and docs may be sibling PRDs.
|
|
122
|
+
When the project has a Field Manual (`session-manager-operations/manual/manual.json`
|
|
123
|
+
exists), a plan that ships or changes a user-visible surface includes one sibling `doc`
|
|
124
|
+
PRD that writes or revises its chapter under `session-manager-operations/manual/chapters/`,
|
|
125
|
+
in the same plan and covered by the plan's `validate` PRD. Skip it when the project has no
|
|
126
|
+
`manual.json`. Why: a release never finds a gap it can only report.
|
|
100
127
|
6. **Pick a shape.** Most asks are an independent set. Chain 3–5 PRDs only for truly
|
|
101
128
|
sequential work: each link `dependsOn` the previous one; its notes name what that link
|
|
102
129
|
delivers and say to read the landed code first. Never chain past 5; redo the completeness
|
|
103
130
|
pass. Each goal's first sentence names its type, in chain order: `primitive` (new helper
|
|
104
131
|
and its test), `wire` (adopt it at named call sites), `behavior` (one function's logic and
|
|
105
|
-
its test), `migration` (mechanical change), `doc`, `validate`.
|
|
132
|
+
its test), `migration` (mechanical change), `doc`, `validate`. A gap you leave out of the
|
|
133
|
+
first plan is queued in the same turn as a later wave that `dependsOn` the PRDs it builds
|
|
134
|
+
on, or held by `preflight` or a date when it must wait for something. Never list it as "not
|
|
135
|
+
covered" or "stage 2".
|
|
106
136
|
7. **Keep each PRD small**: at most 3 edited files, 1 new file, 6 criteria. Test files edited or added in lockstep with
|
|
107
137
|
the PRD's own code do not count toward the 3-edited / 1-new file limit. The validate PRD is
|
|
108
138
|
exempt: it has one criterion per PRD, plus the record. A new helper and its first caller are
|
|
@@ -128,9 +158,9 @@ three failure modes have different fixes:
|
|
|
128
158
|
gate or files warning shows a real mistake, fix it with `scheduler_update_prd`: its `gate`,
|
|
129
159
|
`files` and `acceptanceCriteria` fields are validated and re-rendered. Why: a full body
|
|
130
160
|
replacement is for prose only and is not re-checked. Never
|
|
131
|
-
change a PRD only to silence a warning.
|
|
132
|
-
|
|
133
|
-
|
|
161
|
+
change a PRD only to silence a warning. Then post one short message: each PRD's number and
|
|
162
|
+
slug, the validate slug, and that no per-PRD check will come from this session. Name a
|
|
163
|
+
warning only if you changed a PRD because of it.
|
|
134
164
|
13. **Never stop for review after queueing.** Why: the validator is the review.
|
|
135
165
|
|
|
136
166
|
### PRD fields
|
|
@@ -254,34 +284,38 @@ Rules:
|
|
|
254
284
|
Never relay a question to the human: resolve every PRD through cases 1-4, making the
|
|
255
285
|
safest reasonable choice, and report it. Why: queued work runs with no questions asked.
|
|
256
286
|
2. **A PLAN SETTLED digest.** Read the validator records it names. A `REFUTED` PRD, or a
|
|
257
|
-
Critical or
|
|
258
|
-
plus a new validate PRD.
|
|
287
|
+
finding at any severity (Critical, Important or Minor), means a fix wave: one `behavior`
|
|
288
|
+
or `wire` PRD per finding plus a new validate PRD. A finding with nothing to fix gets a
|
|
289
|
+
one-line close reason in the report instead. Never fix inline. Every fix PRD sets `fixes: [{ prd, missKind, reason }]`,
|
|
259
290
|
one entry per PRD it repairs, including a PRD a validator `VERIFIED` whose bug was found later
|
|
260
291
|
(an escape). Why: escapes are counted from `fixes`. The new validate PRD has one criterion per fix
|
|
261
292
|
PRD and one per PRD the earlier validator marked `REFUTED`, each cited by slug. Why: a
|
|
262
293
|
refuted PRD keeps its Epic blocked until a validator verifies that same PRD. A PRD marked
|
|
263
|
-
`REFUTED` again after its fix wave, on the same criterion, gets no third fix wave:
|
|
264
|
-
|
|
265
|
-
to decide. Why: a second miss on the same criterion means the plan is wrong, and another
|
|
294
|
+
`REFUTED` again after its fix wave, on the same criterion, gets no third fix wave: put it
|
|
295
|
+
under Needs you (rule 6) with the validator's reason and what was tried. Why: a second miss on the same criterion means the plan is wrong, and another
|
|
266
296
|
wave would repeat it. A Not validated list means validate exactly those PRDs here. All
|
|
267
297
|
`VERIFIED` with nothing open means Done: write the final report.
|
|
268
298
|
3. **A `PRECONDITION HOLD` notice** is not a park and not a fix-wave trigger. Do nothing — no
|
|
269
299
|
reset, no edit, no fix PRD; the scheduler re-checks the preflight on its own. State the
|
|
270
300
|
missing precondition in the report. Why: only a person can supply it.
|
|
271
301
|
4. **Done** = the latest validator marked every PRD `VERIFIED`, including each PRD an earlier
|
|
272
|
-
validator refuted,
|
|
302
|
+
validator refuted, every finding at every severity is fixed or closed with a reason, and its record exists in the main checkout's
|
|
273
303
|
`session-manager-operations/plan-records/<epic-id>/`.
|
|
274
|
-
Never "done with caveats": a REFUTED PRD gets a fix wave, or after its second refutation
|
|
275
|
-
|
|
304
|
+
Never "done with caveats": a REFUTED PRD gets a fix wave, or after its second refutation a
|
|
305
|
+
Needs you entry for the human to decide.
|
|
276
306
|
|
|
277
307
|
### Final report
|
|
278
308
|
|
|
279
|
-
1.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
3.
|
|
283
|
-
4.
|
|
284
|
-
|
|
309
|
+
1. **Landed:** each PRD slug and its commit; the validation record path (it exists in the main
|
|
310
|
+
checkout's `session-manager-operations/plan-records/<epic-id>/`).
|
|
311
|
+
2. **Decided:** each choice you made instead of asking, with a one-line revert.
|
|
312
|
+
3. **Queued:** side plans and later waves still to run, by slug. They finish without the human.
|
|
313
|
+
4. **Scheduled:** what fires on its own later, and its trigger. A reply owed to another project after a release is sent at once,
|
|
314
|
+
as `feedback_reply` with `deliverWhen.appVersionAbove` set to the version running now
|
|
315
|
+
(`admin-api.json` `appVersion`), so it sends itself after the release even if this Epic is closed.
|
|
316
|
+
5. **Needs you:** only steps rule 6 allows, including a PRD refuted twice, one exact action each. Omit it when empty.
|
|
317
|
+
|
|
318
|
+
Expected API warnings and skipped optional steps are not reported.
|
|
285
319
|
|
|
286
320
|
## Never
|
|
287
321
|
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
- One concept = one implementation. Before writing code that computes, fetches, formats or displays a value, search for the existing implementation and reuse it; a datum shown in N places flows from one shared accessor, store, hook or endpoint.
|
|
24
24
|
- Extend, don't fork: generalize a close-but-insufficient function (add a param, widen the contract) instead of cloning a variant. Why: copies drift, and divergence is how silent inconsistencies ship (one site reads a 0–100 percentage as a 0–1 fraction).
|
|
25
|
-
- Duplication you touch is a bug in scope: route both copies through the shared unit when both are in the PRD's `# Files`; otherwise name the duplicate in
|
|
25
|
+
- Duplication you touch is a bug in scope: route both copies through the shared unit when both are in the PRD's `# Files`; otherwise name the duplicate in a `Follow-up:` commit trailer.
|
|
26
26
|
|
|
27
27
|
## Test-driven development
|
|
28
28
|
|
|
@@ -68,8 +68,9 @@ Long hangs, not bad code, cause most failed runs. The PRD body carries a one-lin
|
|
|
68
68
|
- **Bound every command.** Wrap every test, build, dev-server, deploy, or poll command in a hard timeout, e.g. `timeout 300 <typecheck|unit>` or `curl --max-time 15`. Why: a bare `playwright test`, `vite`, `pnpm dev`, full e2e suite, or endpoint-polling publish hangs until the 4-hour watchdog kills it with SIGTERM.
|
|
69
69
|
- **Verify before done.** Run the acceptance test once before declaring success. Why: a run that ends on a failing test is not done — fix it or `exit 1` with the failure instead.
|
|
70
70
|
- **Fail loud, fail fast.** On any step failure, print one diagnostic line and `exit 1`. Do not swallow it with `|| true` or retry silently. Exception: a `rateLimited` exit-1 is the scheduler's own benign auto-pause — it resumes next window on its own, so do not engineer around it.
|
|
71
|
+
- **Files a human should review go to the Artifacts store.** Write them to `$SM_ARTIFACTS_DIR` (ingested when the turn or run ends) or publish them with `artifact_publish`; never write them by absolute path into the main checkout. Why: a gitignored folder there is invisible from the Epic and lost with the worktree ([layout](../../../../session-manager-operations/artifacts/README.md)).
|
|
71
72
|
- **Stay in the AC.** Do not add work past the acceptance checklist — "while we're here" extras are how runs overrun. Keep the body clean UTF-8, with no NUL or control bytes.
|
|
72
|
-
- **You ARE the executor — never re-queue or self-schedule.** Do the acceptance criteria yourself. Why: `/develop` or any queue-authoring skill just writes a *new* PRD and returns — the run exits 0 having done nothing, with no commit and no verdict line (`needs_review` with `no_verdict_sentinel`). The same applies to calling `ScheduleWakeup`, or backgrounding a review agent (`/code-review`, `/security-review`) and ending your turn with something like "I'll wait for the review agents to complete": a headless run has no next turn, so nothing ever resumes it — no verdict line prints, and the job parks in `needs_review` even though the work already landed. Run a required second review pass synchronously, inline, before the finish protocol — call the reviewer and read its result in the same turn. If the work is too big for one run, do not queue more work; see the timeout rule below.
|
|
73
|
+
- **You ARE the executor — never re-queue or self-schedule.** Do the acceptance criteria yourself. Why: `/develop` or any queue-authoring skill just writes a *new* PRD and returns — the run exits 0 having done nothing, with no commit and no verdict line (`needs_review` with `no_verdict_sentinel`). The same applies to calling `ScheduleWakeup`, or backgrounding a review agent (`/code-review`, `/security-review`) and ending your turn with something like "I'll wait for the review agents to complete": a headless run has no next turn, so nothing ever resumes it — no verdict line prints, and the job parks in `needs_review` even though the work already landed. Run a required second review pass synchronously, inline, before the finish protocol — call the reviewer and read its result in the same turn. If the work is too big for one run, do not queue more work; see the timeout rule below. (Model mitigation MM-1 in [model-mitigations.md](../../../../session-manager-operations/architecture/model-mitigations.md).)
|
|
73
74
|
- **Never `git stash`, `git reset`, `git checkout -- <path>`, or `git clean` against working-tree state you did not create.** You are normally isolated in your own `git worktree` on branch `sm-job/<slug>`, and the scheduler salvages any uncommitted diff of yours on teardown — so you never need to touch shared state to protect your own work. Confirm isolation with `git rev-parse --git-common-dir` (a worktree's common-dir differs from its own `.git`) or by checking your cwd; `git diff`/`git status` are always safe. If you land in a SHARED tree with pre-existing dirty tracked files anyway, work around them — scope `git add`/commits to only the paths you touched — or end with `SCHEDULER_VERDICT: FAIL <reason>` (`SCHEDULER_VERDICT: BLOCKED_BY_FOREIGN_WIP` only when your gate failed on those files, as the finish protocol says); never discard, stash, or revert someone else's uncommitted changes to get a clean checkout. A shared tree may be feeding a running service that reads its config straight from the working tree, so reverting it is a production change, not a local inconvenience. The scheduler runs a shared-tree stash guard as a backstop (`checkSharedTreeGuard`/`evaluateSharedTreeGuard`), but that guard exists to catch a mistake, not to license one. Executors have stashed a sibling job's WIP and an operator's live config edit and never restored either.
|
|
74
75
|
- **`gh pr edit --body` can fail on repos with legacy GitHub Projects (classic) boards.** It queries the deprecated `repository.pullRequest.projectCards` field and errors with a `GraphQL: Projects (classic) is being deprecated` message even though the edit itself would otherwise succeed — a known `gh` CLI quirk, not a defect in your work. Prefer `gh api -X PATCH repos/<owner>/<repo>/pulls/<n> -f body="$(cat body.md)"` instead; it skips that field. If `gh pr edit` fails this way anyway retry immediately with the `gh api` form and note the fallback in your report.
|
|
75
76
|
- **Never `sleep N && <cmd>` to poll remote CI/job status.** The harness hard-blocks a `sleep` chained to another command. Use the tool's own blocking watcher under a hard cap instead: `timeout 600 gh run watch <run-id> --repo <owner>/<repo> --exit-status`. `gh pr checks` exits 8 while checks are pending and 1 on failure — that is not a defect in your work.
|
package/scripts/README.md
CHANGED
|
@@ -31,6 +31,7 @@ scripts/lib was moved into src/main/lib (2026-09); nothing under src/ may requir
|
|
|
31
31
|
| mint-epic.cjs | manual; joins an existing Epic and prints its prds dir | yes |
|
|
32
32
|
| ops-sweep.cjs | manual; `node scripts/ops-sweep.cjs <cwd>` | yes |
|
|
33
33
|
| postinstall.cjs | npm `postinstall` | yes |
|
|
34
|
+
| purge-dry-run.cjs | manual / validators, read-only; `node scripts/purge-dry-run.cjs <cwd> <epicId>` prints `purgeEpic({ dryRun: true })` JSON (artifacts by kind + counts), deletes nothing; a real purge stays the epic:purge IPC | no |
|
|
34
35
|
| refresh-vad-assets.mjs | `npm run refresh:vad-assets` | no |
|
|
35
36
|
| replay-verdicts.cjs | manual, dev-only, read-only | no |
|
|
36
37
|
| scheduler-mcp-server.cjs | registered as an MCP server (`seedSchedulerMcp.cjs`, `send-feedback` SKILL.md) | yes |
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
* then a blocking mark is denied in a Chat turn (SM_CHAT_SESSION_ID set —
|
|
31
31
|
* a -p turn has no approval surface, and the CLI turns 'ask' into a generic
|
|
32
32
|
* auto-deny) and answered with 'ask' in a Terminal session.
|
|
33
|
+
* - Headless WebFetch/WebSearch: denied when the job's environment
|
|
34
|
+
* (SM_JOB_ENVIRONMENT) disallows it — tool not allowed or host off the
|
|
35
|
+
* allow-list — naming the environment; SM_JOB_ENVIRONMENT_MODE=report only
|
|
36
|
+
* records it ('environment_would_block' audit row).
|
|
33
37
|
* - Any other internal error fails open with a stderr line, like
|
|
34
38
|
* guard-self-schedule.cjs.
|
|
35
39
|
*
|
|
@@ -42,7 +46,7 @@
|
|
|
42
46
|
* "hooks": {
|
|
43
47
|
* "PreToolUse": [
|
|
44
48
|
* {
|
|
45
|
-
* "matcher": "Bash|mcp__.*|Write|Edit|MultiEdit|NotebookEdit",
|
|
49
|
+
* "matcher": "Bash|mcp__.*|Write|Edit|MultiEdit|NotebookEdit|WebFetch|WebSearch",
|
|
46
50
|
* "hooks": [
|
|
47
51
|
* { "type": "command", "command": "node ~/.claude/session-manager/hooks/guard-tool-risk.cjs" }
|
|
48
52
|
* ]
|