claude-code-session-manager 0.142.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 +20 -107
- package/dist/assets/{AppSettings-BcZgIvvY.js → AppSettings-BO4jDVGO.js} +1 -1
- package/dist/assets/{History-DpZuJXi1.js → History-DTttbvPb.js} +1 -1
- package/dist/assets/{HomeClaudeConfig-D32ZJtU-.js → HomeClaudeConfig-DADP5bfn.js} +2 -2
- package/dist/assets/{Panel-BjdJjhqt.js → Panel-B_D4Bg7L.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-BTClYV6i.js → ProjectClaudeConfig-DPnDJKcr.js} +1 -1
- package/dist/assets/{Scheduler-DPobKx1Z.js → Scheduler-CNLjn90m.js} +8 -8
- package/dist/assets/{SkillReferenceGraph-Cqyu4mef.js → SkillReferenceGraph-D1b2aiol.js} +1 -1
- package/dist/assets/{Skills-vv0noNVI.js → Skills-cfV7sgk6.js} +1 -1
- package/dist/assets/{TiptapBody-CXi8Pvut.js → TiptapBody-DVXtEIVy.js} +1 -1
- package/dist/assets/{Toggle-CiYCWLjh.js → Toggle-CYajnSdx.js} +1 -1
- package/dist/assets/{VoiceButton-4NKKd1sC.js → VoiceButton-DJ4gGRuE.js} +1 -1
- package/dist/assets/{historyTotals-DDunb8Ch.js → historyTotals-D3MoHY2U.js} +1 -1
- package/dist/assets/{index-Cn5E9958.js → index-CdTppjKR.js} +436 -436
- package/dist/index.html +1 -1
- package/dist-web/app.js +356 -356
- package/package.json +3 -3
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
- package/plugins/session-manager-dev/skills/builder/SKILL.md +5 -0
- package/plugins/session-manager-dev/skills/develop/SKILL.md +9 -3
- package/scripts/README.md +1 -0
- package/scripts/scheduler-mcp-server.cjs +304 -6
- package/src/main/adminRouteRegistry.cjs +10 -0
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +105 -7
- package/src/main/config.cjs +5 -1
- package/src/main/health.cjs +38 -2
- package/src/main/index.cjs +12 -4
- package/src/main/ipcSchemas.cjs +11 -0
- package/src/main/lib/demo-video-kit/cast.md +10 -1
- package/src/main/lib/demo-video-kit/character.cjs +77 -21
- package/src/main/lib/demo-video-kit/kind-tiktok.md +5 -1
- package/src/main/lib/demo-video-kit/projectSounds.cjs +191 -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/epic/activeIndexMerge.cjs +5 -0
- package/src/main/lib/epic/artifactRetention.cjs +55 -9
- package/src/main/lib/epic/artifactStore.cjs +78 -35
- package/src/main/lib/epic/delegationReadiness.cjs +10 -3
- package/src/main/lib/epic/epicEventLog.cjs +45 -1
- package/src/main/lib/epic/epicStateEmitter.cjs +248 -0
- package/src/main/lib/epic/epicValidationHook.cjs +13 -2
- package/src/main/lib/externalContract.cjs +12 -1
- package/src/main/lib/feedback-remote/autoStartedSession.cjs +1 -1
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +96 -8
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +30 -0
- package/src/main/lib/feedback-remote/pendingReplies.cjs +18 -0
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +94 -4
- package/src/main/lib/feedback-remote/replyClaims.cjs +159 -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 +113 -10
- package/src/main/lib/mcpToolCatalog.cjs +102 -8
- package/src/main/lib/opsOwnership.cjs +113 -28
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +46 -0
- package/src/main/lib/prd/prdCreate.cjs +350 -227
- package/src/main/lib/prd/prdCriteria.cjs +7 -4
- package/src/main/lib/project-pages/videoPressLines.cjs +145 -0
- 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/scheduler/criteriaChecks.cjs +164 -20
- package/src/main/lib/scheduler/heldSchedulerTurns.cjs +238 -0
- package/src/main/lib/scheduler/jobMemoryStats.cjs +13 -2
- package/src/main/lib/scheduler/planRecordHarvest.cjs +120 -52
- package/src/main/lib/scheduler/prdOutcomeRecord.cjs +60 -2
- package/src/main/lib/scheduler/queueStore.cjs +16 -0
- package/src/main/lib/scheduler/rcaReport.cjs +79 -15
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +13 -0
- package/src/main/lib/scheduler/schedulerPaths.cjs +9 -0
- package/src/main/lib/scheduler/slotsRoute.cjs +101 -87
- package/src/main/lib/scheduler/usageHoldRoute.cjs +97 -0
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +16 -5
- package/src/main/lib/tasks/memoryConsolidation.cjs +14 -2
- package/src/main/lib/tasks/mitigationReview.cjs +21 -1
- package/src/main/lib/tasks/taskAdminRoutes.cjs +78 -3
- package/src/main/lib/tasks/taskLedger.cjs +2 -2
- package/src/main/lib/telemetry/auditEvents.cjs +21 -24
- package/src/main/lib/telemetry/auditLog.cjs +6 -2
- package/src/main/lib/util/atomicFs.cjs +2 -2
- package/src/main/promptSessionEvents.cjs +16 -1
- package/src/main/pty.cjs +11 -2
- package/src/main/queueOps.cjs +1 -1
- package/src/main/runVerify.cjs +1 -1
- package/src/main/scheduler/utilizationHold.cjs +96 -6
- package/src/main/scheduler.cjs +533 -39
- package/src/main/templates/PRD_AUTHORING.md +7 -2
- package/src/preload/api.d.ts +47 -1
- package/src/preload/apiSurface.json +14 -0
- package/src/preload/index.cjs +2 -0
- package/src/seed/agents/demo-video-builder.md +15 -8
- package/src/seed/agents/validator.md +20 -19
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* admin-api.json; honors SM_SCHEDULER_HOME) = { version: 1, entries }.
|
|
12
12
|
* An entry is due once appVersionAbove < running appVersion (strictly, via
|
|
13
13
|
* seedDevPlugin.cjs compareSemver — an equal version is not due).
|
|
14
|
+
* An entry with `commits` (release.commits) is further gated by the
|
|
15
|
+
* deliverer on tag v<running version> containing every commit.
|
|
14
16
|
* A missing or unreadable file reads as empty. Writes go through
|
|
15
17
|
* util/atomicFs.cjs.
|
|
16
18
|
*
|
|
@@ -26,6 +28,7 @@ const { schedulerHome } = require('../scheduler/schedulerPaths.cjs');
|
|
|
26
28
|
const STORE_VERSION = 1;
|
|
27
29
|
const FILE_NAME = 'pending-replies.json';
|
|
28
30
|
const SEMVER_RE = /^\d+\.\d+\.\d+$/;
|
|
31
|
+
const COMMIT_RE = /^[0-9a-f]{7,40}$/;
|
|
29
32
|
/** Failed delivery attempts (one per hourly pass) before an entry gives up for good. */
|
|
30
33
|
const MAX_DELIVERY_ATTEMPTS = 24;
|
|
31
34
|
|
|
@@ -79,12 +82,26 @@ function normalizeYSource(v) {
|
|
|
79
82
|
try { return JSON.parse(JSON.stringify(v)); } catch { return null; }
|
|
80
83
|
}
|
|
81
84
|
|
|
85
|
+
/** Lowercased, de-duplicated commit hashes (7-40 hex); [] when none are valid. */
|
|
86
|
+
function normalizeCommits(v) {
|
|
87
|
+
if (!Array.isArray(v)) return [];
|
|
88
|
+
const out = [];
|
|
89
|
+
for (const c of v) {
|
|
90
|
+
if (typeof c !== 'string') continue;
|
|
91
|
+
const lc = c.toLowerCase();
|
|
92
|
+
if (COMMIT_RE.test(lc) && !out.includes(lc)) out.push(lc);
|
|
93
|
+
}
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
|
|
82
97
|
/** Pure: build a full ledger entry from caller input. Throws on a bad appVersionAbove. */
|
|
83
98
|
function buildEntry(input, now = new Date()) {
|
|
84
99
|
const e = input && typeof input === 'object' ? input : {};
|
|
85
100
|
if (!isSemver(e.appVersionAbove)) {
|
|
86
101
|
throw new Error(`pendingReplies: appVersionAbove must be x.y.z, got ${JSON.stringify(e.appVersionAbove)}`);
|
|
87
102
|
}
|
|
103
|
+
// release.commits the reply claims: delivery waits until tag v<running> holds every one.
|
|
104
|
+
const commits = normalizeCommits(e.commits);
|
|
88
105
|
return {
|
|
89
106
|
id: crypto.randomUUID(),
|
|
90
107
|
createdAt: now.toISOString(),
|
|
@@ -97,6 +114,7 @@ function buildEntry(input, now = new Date()) {
|
|
|
97
114
|
message: str(e.message),
|
|
98
115
|
referencePaths: Array.isArray(e.referencePaths) ? e.referencePaths.filter((p) => typeof p === 'string') : [],
|
|
99
116
|
appVersionAbove: e.appVersionAbove,
|
|
117
|
+
...(commits.length ? { commits } : {}),
|
|
100
118
|
// What delivery needs once the scheduling Epic has closed: its source
|
|
101
119
|
// (externalRef / proposal / replyTo) and the cap count this reply took.
|
|
102
120
|
ySource: normalizeYSource(e.ySource),
|
|
@@ -34,11 +34,12 @@ const path = require('node:path');
|
|
|
34
34
|
const crypto = require('node:crypto');
|
|
35
35
|
const { readBody, sendJson } = require('./localAdminHttp.cjs');
|
|
36
36
|
const { resolveProjectContext } = require('../projectRootResolve.cjs');
|
|
37
|
-
const { opsPath, OPS_ROOT_DIR } = require('../opsOwnership.cjs');
|
|
37
|
+
const { opsPath, OPS_ROOT_DIR, assertOpsWrite } = require('../opsOwnership.cjs');
|
|
38
38
|
const config = require('../../config.cjs');
|
|
39
39
|
const { schemas, ENTRY_ID_RE } = require('../../ipcSchemas.cjs');
|
|
40
40
|
const { validateCharacterJson, validateCharacterJs, voiceIdRefsOf, inspectCharacter, characterDir, MAX_JSON_BYTES: MAX_CHARACTER_JSON_BYTES, MAX_JS_BYTES: MAX_CHARACTER_JS_BYTES } = require('../demo-video-kit/character.cjs');
|
|
41
41
|
const voiceLibrary = require('../demo-video-kit/voiceLibrary.cjs');
|
|
42
|
+
const projectSounds = require('../demo-video-kit/projectSounds.cjs');
|
|
42
43
|
const { checkHtmlLimits, checkPostCaption, TIKTOK_CHECK_IDS } = require('../demo-video-kit/checks.cjs');
|
|
43
44
|
const { injectPlayerBridge } = require('../project-pages/playerBridge.cjs');
|
|
44
45
|
const { readMatrix, matrixJsonSchema, MAX_MATRIX_BYTES } = require('../project-pages/competitiveMatrix.cjs');
|
|
@@ -63,6 +64,8 @@ const VIDEO_OUTCOMES = ['season-complete'];
|
|
|
63
64
|
const OUTCOME_TEXT_MAX = 300;
|
|
64
65
|
const OUTCOME_BODY_KEYS = ['cwd', 'videoId', 'outcome', 'text'];
|
|
65
66
|
const OUTCOME_WRITE_BODY_MAX = 64 * 1024;
|
|
67
|
+
/** Character write body cap: js + json, every project sound WAV as base64, and 128 KiB of overhead. */
|
|
68
|
+
const CHARACTER_WRITE_BODY_MAX = MAX_CHARACTER_JS_BYTES * 2 + base64LengthFor(projectSounds.MAX_SOUNDS_TOTAL_BYTES) + 128 * 1024;
|
|
66
69
|
|
|
67
70
|
// Each detector is a linear regex scan; the input is capped first.
|
|
68
71
|
const REMOTE_REFERENCE_CHECKS = [
|
|
@@ -457,7 +460,9 @@ function registerAdminRoute(adminHttp) {
|
|
|
457
460
|
// POST /admin/project-home/videos/outcome/write {cwd, videoId, outcome, text} -> videos/<videoId>/outcome.json
|
|
458
461
|
adminHttp.registerRoute('POST', '/admin/project-home/videos/outcome/write', outcomeWriteHandler);
|
|
459
462
|
|
|
460
|
-
// POST /admin/project-home/character/write {cwd, json, js, replace?} -> videos/_character/
|
|
463
|
+
// POST /admin/project-home/character/write {cwd, json, js, replace?, sounds?} -> videos/_character/
|
|
464
|
+
// (sounds = { <name>: <base64 WAV> } for every file-backed sound, written to sounds/<name>.wav;
|
|
465
|
+
// answers {ok, path, bytes, sounds: <names written>})
|
|
461
466
|
adminHttp.registerRoute('POST', '/admin/project-home/character/write', characterWriteHandler);
|
|
462
467
|
|
|
463
468
|
// POST /admin/project-home/matrix/read {cwd?} -> {ok, matrix|null, error, path, schema}
|
|
@@ -641,10 +646,78 @@ async function outcomeWriteHandler(req, res) {
|
|
|
641
646
|
}
|
|
642
647
|
}
|
|
643
648
|
|
|
649
|
+
/**
|
|
650
|
+
* Checks a character write's `sounds` payload ({ <name>: <base64 WAV> }) against the
|
|
651
|
+
* file-backed sounds `jsonObj` declares: exactly one entry per name, valid base64, each
|
|
652
|
+
* WAV within its kind's cap and readable, and the total within MAX_SOUNDS_TOTAL_BYTES.
|
|
653
|
+
* -> {files: [{name, buffer}]} | {error}. Errors never echo the payload.
|
|
654
|
+
*/
|
|
655
|
+
function checkSoundPayload(jsonObj, sounds) {
|
|
656
|
+
const payload = sounds === undefined || sounds === null ? {} : sounds;
|
|
657
|
+
if (typeof payload !== 'object' || Array.isArray(payload)) {
|
|
658
|
+
return { error: 'sounds payload must be an object of { name: base64 WAV }' };
|
|
659
|
+
}
|
|
660
|
+
const names = projectSounds.fileBackedSoundNames(jsonObj);
|
|
661
|
+
for (const name of names) {
|
|
662
|
+
if (!Object.prototype.hasOwnProperty.call(payload, name)) {
|
|
663
|
+
return { error: `sound '${name}' has no WAV: send it as sounds.${name} (project_character_write soundPaths.${name})` };
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
for (const key of Object.keys(payload)) {
|
|
667
|
+
if (!names.includes(key)) return { error: `sound '${key}' was sent but character.json declares no file-backed sound by that name` };
|
|
668
|
+
}
|
|
669
|
+
const files = [];
|
|
670
|
+
let total = 0;
|
|
671
|
+
for (const name of names) {
|
|
672
|
+
const b64 = payload[name];
|
|
673
|
+
if (typeof b64 !== 'string' || b64.length % 4 !== 0 || !BASE64_RE.test(b64)) {
|
|
674
|
+
return { error: `sound '${name}' is not valid base64` };
|
|
675
|
+
}
|
|
676
|
+
const kind = projectSounds.findProjectSound(jsonObj, name).kind;
|
|
677
|
+
const cap = kind === 'sfx' ? projectSounds.MAX_SFX_WAV_BYTES : projectSounds.MAX_BED_WAV_BYTES;
|
|
678
|
+
const label = `sound '${name}'`;
|
|
679
|
+
if (b64.length > base64LengthFor(cap)) {
|
|
680
|
+
return { error: `${label} is over the ${cap}-byte limit for a ${kind === 'sfx' ? 'sound effect' : 'music bed'}` };
|
|
681
|
+
}
|
|
682
|
+
const buffer = Buffer.from(b64, 'base64');
|
|
683
|
+
const wavErr = projectSounds.checkSoundWav(buffer, label, kind);
|
|
684
|
+
if (wavErr) return { error: wavErr };
|
|
685
|
+
total += buffer.length;
|
|
686
|
+
files.push({ name, buffer });
|
|
687
|
+
}
|
|
688
|
+
if (total > projectSounds.MAX_SOUNDS_TOTAL_BYTES) {
|
|
689
|
+
return { error: `sounds total ${total} bytes exceed the ${projectSounds.MAX_SOUNDS_TOTAL_BYTES}-byte limit` };
|
|
690
|
+
}
|
|
691
|
+
return { files };
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/** Removes every entry of soundsDir(cwd) that is not a declared <name>.wav; removes the folder when nothing is declared. */
|
|
695
|
+
async function pruneSounds(cwd, names) {
|
|
696
|
+
const dir = projectSounds.soundsDir(cwd);
|
|
697
|
+
let entries;
|
|
698
|
+
try {
|
|
699
|
+
entries = await fs.promises.readdir(dir);
|
|
700
|
+
} catch (e) {
|
|
701
|
+
if (e && e.code === 'ENOENT') return;
|
|
702
|
+
throw e;
|
|
703
|
+
}
|
|
704
|
+
const keep = new Set(names.map((n) => `${n}.wav`));
|
|
705
|
+
for (const entry of entries) {
|
|
706
|
+
if (keep.has(entry)) continue;
|
|
707
|
+
const abs = path.join(dir, entry);
|
|
708
|
+
assertOpsWrite(abs, 'project-home');
|
|
709
|
+
await fs.promises.rm(abs, { recursive: true, force: true });
|
|
710
|
+
}
|
|
711
|
+
if (names.length === 0) {
|
|
712
|
+
assertOpsWrite(dir, 'project-home');
|
|
713
|
+
await fs.promises.rmdir(dir);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
644
717
|
async function characterWriteHandler(req, res) {
|
|
645
718
|
let raw;
|
|
646
719
|
try {
|
|
647
|
-
raw = await readBody(req,
|
|
720
|
+
raw = await readBody(req, CHARACTER_WRITE_BODY_MAX);
|
|
648
721
|
} catch (e) {
|
|
649
722
|
sendJson(res, 400, { ok: false, error: `request body rejected: ${e?.message ?? 'unreadable'}` });
|
|
650
723
|
return;
|
|
@@ -687,6 +760,11 @@ async function characterWriteHandler(req, res) {
|
|
|
687
760
|
sendJson(res, 400, { ok: false, error: `character.json exceeds the ${MAX_CHARACTER_JSON_BYTES}-byte limit (${jsonBytes} bytes as saved)` });
|
|
688
761
|
return;
|
|
689
762
|
}
|
|
763
|
+
const soundPayload = checkSoundPayload(jsonObj, body.sounds);
|
|
764
|
+
if (soundPayload.error) {
|
|
765
|
+
sendJson(res, 400, { ok: false, error: `character.json invalid: ${soundPayload.error}` });
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
690
768
|
const jsErr = validateCharacterJs(body.js, [...REMOTE_REFERENCE_CHECKS, ...NETWORK_CHECKS]);
|
|
691
769
|
if (jsErr) {
|
|
692
770
|
sendJson(res, 400, { ok: false, error: jsErr });
|
|
@@ -707,10 +785,22 @@ async function characterWriteHandler(req, res) {
|
|
|
707
785
|
try {
|
|
708
786
|
const dir = characterDir(resolved.cwd);
|
|
709
787
|
await fs.promises.mkdir(dir, { recursive: true });
|
|
788
|
+
for (const f of soundPayload.files) {
|
|
789
|
+
await config.writeBinaryAtomic(projectSounds.soundFile(resolved.cwd, f.name), f.buffer, { writer: 'project-home' });
|
|
790
|
+
}
|
|
710
791
|
const jsPath = path.join(dir, 'character.js');
|
|
711
792
|
await config.writeTextAtomic(jsPath, body.js, { writer: 'project-home' });
|
|
712
793
|
await config.writeTextAtomic(path.join(dir, 'character.json'), jsonText, { writer: 'project-home' });
|
|
713
|
-
|
|
794
|
+
// character.json is saved: the persona is usable, so a stale-WAV prune failure is reported, never a 500.
|
|
795
|
+
let pruneError;
|
|
796
|
+
try {
|
|
797
|
+
await pruneSounds(resolved.cwd, soundPayload.files.map((f) => f.name));
|
|
798
|
+
} catch (e) {
|
|
799
|
+
pruneError = e?.message ?? String(e);
|
|
800
|
+
}
|
|
801
|
+
const answer = { ok: true, path: dir, bytes: Buffer.byteLength(body.js, 'utf8'), sounds: soundPayload.files.map((f) => f.name) };
|
|
802
|
+
if (pruneError !== undefined) answer.pruneError = pruneError;
|
|
803
|
+
sendJson(res, 200, answer);
|
|
714
804
|
} catch (e) {
|
|
715
805
|
sendJson(res, 500, { ok: false, error: e?.message ?? 'write failed' });
|
|
716
806
|
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* replyClaims.cjs — the single decider for whether a cross-project reply's
|
|
3
|
+
* release claim is true.
|
|
4
|
+
*
|
|
5
|
+
* Used by crossProjectReply.cjs (the app route) and
|
|
6
|
+
* scripts/scheduler-mcp-server.cjs (the MCP server), so it must load outside
|
|
7
|
+
* Electron: requires only node built-ins and ../git/gitExec.cjs.
|
|
8
|
+
*
|
|
9
|
+
* - findUnfilledPlaceholders: version-ish template tokens left in a message
|
|
10
|
+
* ('{version}', '{{appVersion}}', '${release}', '<semver>', ...).
|
|
11
|
+
* - findSessionManagerVersions: the x.y.z a message names as a Session
|
|
12
|
+
* Manager release ('Session Manager 0.143.0', 'SM v0.143.0').
|
|
13
|
+
* - normalizeReleaseClaim: validates a caller's `{ commits }` claim.
|
|
14
|
+
* - isSessionManagerRepo / checkReleaseContains: verify with git that tag
|
|
15
|
+
* v<version> contains every claimed commit. Never throws.
|
|
16
|
+
*/
|
|
17
|
+
'use strict';
|
|
18
|
+
|
|
19
|
+
const fs = require('node:fs');
|
|
20
|
+
const path = require('node:path');
|
|
21
|
+
|
|
22
|
+
const SM_PACKAGE_NAME = 'claude-code-session-manager';
|
|
23
|
+
const VERSION_RE = /^\d+\.\d+\.\d+$/;
|
|
24
|
+
const COMMIT_RE = /^[0-9a-f]{7,40}$/i;
|
|
25
|
+
const MAX_COMMITS = 20;
|
|
26
|
+
|
|
27
|
+
const PLACEHOLDER_NAMES = [
|
|
28
|
+
'version', 'appversion', 'app_version', 'app-version', 'release',
|
|
29
|
+
'releaseversion', 'release_version', 'smversion', 'sm_version', 'semver',
|
|
30
|
+
];
|
|
31
|
+
// Longest first so alternation never stops at a prefix ('release' vs 'release_version').
|
|
32
|
+
const NAME_ALT = PLACEHOLDER_NAMES.slice()
|
|
33
|
+
.sort((a, b) => b.length - a.length)
|
|
34
|
+
.map((n) => n.replace(/[-_]/g, (c) => `\\${c}`))
|
|
35
|
+
.join('|');
|
|
36
|
+
const INNER = `[ \\t]*(?:${NAME_ALT})[ \\t]*`;
|
|
37
|
+
// Two-char openers before one-char ones so '{{x}}' / '${x}' match whole.
|
|
38
|
+
const PLACEHOLDER_SRC = [
|
|
39
|
+
`\\{\\{${INNER}\\}\\}`,
|
|
40
|
+
`\\$\\{${INNER}\\}`,
|
|
41
|
+
`\\{${INNER}\\}`,
|
|
42
|
+
`<${INNER}>`,
|
|
43
|
+
`\\[${INNER}\\]`,
|
|
44
|
+
`%${INNER}%`,
|
|
45
|
+
].join('|');
|
|
46
|
+
|
|
47
|
+
function findUnfilledPlaceholders(message, opts = {}) {
|
|
48
|
+
if (typeof message !== 'string') return [];
|
|
49
|
+
const allowVersionToken = !!(opts && opts.allowVersionToken);
|
|
50
|
+
const re = new RegExp(PLACEHOLDER_SRC, 'gi');
|
|
51
|
+
const out = [];
|
|
52
|
+
for (const m of message.matchAll(re)) {
|
|
53
|
+
const tok = m[0];
|
|
54
|
+
if (allowVersionToken && tok === '{version}') continue;
|
|
55
|
+
if (!out.includes(tok)) out.push(tok);
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const SM_VERSION_SRC = '\\b(?:[Ss][Ee][Ss][Ss][Ii][Oo][Nn] [Mm][Aa][Nn][Aa][Gg][Ee][Rr]|SM)'
|
|
61
|
+
+ '(?:\\s+(?:release|version|app))?\\s+v?(\\d+\\.\\d+\\.\\d+)\\b';
|
|
62
|
+
|
|
63
|
+
function findSessionManagerVersions(message) {
|
|
64
|
+
if (typeof message !== 'string') return [];
|
|
65
|
+
const out = [];
|
|
66
|
+
for (const m of message.matchAll(new RegExp(SM_VERSION_SRC, 'g'))) {
|
|
67
|
+
if (!out.includes(m[1])) out.push(m[1]);
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function isPlainObject(v) {
|
|
73
|
+
if (!v || typeof v !== 'object' || Array.isArray(v)) return false;
|
|
74
|
+
const proto = Object.getPrototypeOf(v);
|
|
75
|
+
return proto === Object.prototype || proto === null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function normalizeReleaseClaim(raw) {
|
|
79
|
+
const fail = (error) => ({ ok: false, error });
|
|
80
|
+
if (!isPlainObject(raw)) return fail('release must be an object { commits: [...] }');
|
|
81
|
+
const keys = Object.keys(raw);
|
|
82
|
+
if (keys.length !== 1 || keys[0] !== 'commits') {
|
|
83
|
+
return fail('release must have exactly one key, commits');
|
|
84
|
+
}
|
|
85
|
+
const { commits } = raw;
|
|
86
|
+
if (!Array.isArray(commits) || commits.length < 1 || commits.length > MAX_COMMITS) {
|
|
87
|
+
return fail(`release.commits must be an array of 1-${MAX_COMMITS} commit hashes`);
|
|
88
|
+
}
|
|
89
|
+
const out = [];
|
|
90
|
+
for (const c of commits) {
|
|
91
|
+
if (typeof c !== 'string' || !COMMIT_RE.test(c)) {
|
|
92
|
+
return fail(`release.commits has an invalid commit hash: ${JSON.stringify(c)}`);
|
|
93
|
+
}
|
|
94
|
+
const lc = c.toLowerCase();
|
|
95
|
+
if (!out.includes(lc)) out.push(lc);
|
|
96
|
+
}
|
|
97
|
+
return { ok: true, value: { commits: out } };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function isSessionManagerRepo(cwd) {
|
|
101
|
+
try {
|
|
102
|
+
if (typeof cwd !== 'string' || !cwd) return false;
|
|
103
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'));
|
|
104
|
+
return !!pkg && typeof pkg === 'object' && pkg.name === SM_PACKAGE_NAME;
|
|
105
|
+
} catch {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function defaultRunGit(cwd, args) {
|
|
111
|
+
const { execGit } = require('../git/gitExec.cjs');
|
|
112
|
+
return execGit(cwd, args, { timeout: 15000 });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function checkReleaseContains(input, opts = {}) {
|
|
116
|
+
try {
|
|
117
|
+
const { repoCwd, version, commits } = input || {};
|
|
118
|
+
if (typeof version !== 'string' || !VERSION_RE.test(version)) {
|
|
119
|
+
return { ok: false, error: `release version ${JSON.stringify(version)} is not x.y.z` };
|
|
120
|
+
}
|
|
121
|
+
if (typeof repoCwd !== 'string' || !repoCwd) {
|
|
122
|
+
return { ok: false, error: 'no repository to check the release against' };
|
|
123
|
+
}
|
|
124
|
+
const claim = normalizeReleaseClaim({ commits });
|
|
125
|
+
if (!claim.ok) return { ok: false, error: claim.error };
|
|
126
|
+
const runGit = (opts && typeof opts.runGit === 'function') ? opts.runGit : defaultRunGit;
|
|
127
|
+
const tag = `v${version}`;
|
|
128
|
+
const git = async (args) => { await runGit(repoCwd, args); };
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
await git(['rev-parse', '-q', '--verify', `refs/tags/${tag}^{commit}`]);
|
|
132
|
+
} catch {
|
|
133
|
+
return { ok: false, error: `release tag ${tag} does not exist` };
|
|
134
|
+
}
|
|
135
|
+
for (const c of claim.value.commits) {
|
|
136
|
+
try {
|
|
137
|
+
await git(['rev-parse', '-q', '--verify', `${c}^{commit}`]);
|
|
138
|
+
} catch {
|
|
139
|
+
return { ok: false, error: `commit ${c} is not known to this repository` };
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
await git(['merge-base', '--is-ancestor', c, tag]);
|
|
143
|
+
} catch {
|
|
144
|
+
return { ok: false, error: `release tag ${tag} does not contain commit ${c}` };
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return { ok: true, tag };
|
|
148
|
+
} catch (err) {
|
|
149
|
+
return { ok: false, error: `release check failed: ${err && err.message ? err.message : String(err)}` };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
module.exports = {
|
|
154
|
+
findUnfilledPlaceholders,
|
|
155
|
+
findSessionManagerVersions,
|
|
156
|
+
normalizeReleaseClaim,
|
|
157
|
+
isSessionManagerRepo,
|
|
158
|
+
checkReleaseContains,
|
|
159
|
+
};
|
|
@@ -980,6 +980,14 @@ async function createWorktree({ kind, cwd, key, fromRef }) {
|
|
|
980
980
|
const epicDir = worktreeDirFor(kind, cwd, key);
|
|
981
981
|
const epicBranch = branchNameFor(kind, key);
|
|
982
982
|
if (fs.existsSync(epicDir) && await isRegisteredWorktreeOnBranch(cwd, epicDir, epicBranch)) {
|
|
983
|
+
// node_modules links are a snapshot from mint time: pick up packages main gained
|
|
984
|
+
// since (and drop links main lost). Best-effort — never fails the reuse.
|
|
985
|
+
try {
|
|
986
|
+
const sync = await require('./worktreeDeps.cjs').syncNodeModulesLinks({ mainCwd: cwd, worktreeCwd: epicDir });
|
|
987
|
+
if (sync && (sync.added || sync.removed)) console.log(`[gitWorktree] synced dep links: +${sync.added} -${sync.removed} -> ${epicDir}`);
|
|
988
|
+
} catch (err) {
|
|
989
|
+
console.warn(`[gitWorktree] dep link sync failed for ${epicDir}: ${(err && err.message) || err}`);
|
|
990
|
+
}
|
|
983
991
|
return { ok: true, dir: epicDir, branch: epicBranch, baseCwd: cwd, reused: true };
|
|
984
992
|
}
|
|
985
993
|
}
|
|
@@ -34,6 +34,20 @@ async function findTrackedRuntimeState(projectRoot) {
|
|
|
34
34
|
return out.split('\0').filter((p) => p && path.posix.basename(p) !== 'README.md');
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Untracked runtime paths (repo-relative, posix) that git can see — i.e. not
|
|
39
|
+
* ignored by any .gitignore. Each one is a namespace missing its self-ignore.
|
|
40
|
+
*/
|
|
41
|
+
async function findVisibleRuntimeState(projectRoot) {
|
|
42
|
+
let out;
|
|
43
|
+
try {
|
|
44
|
+
out = await execGit(projectRoot, ['ls-files', '-z', '--others', '--exclude-standard', '--', ...nsPathspecs()], { maxBuffer: 64 * 1024 * 1024 });
|
|
45
|
+
} catch {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
return out.split('\0').filter(Boolean);
|
|
49
|
+
}
|
|
50
|
+
|
|
37
51
|
/** Sorted list of every file on disk under the runtime namespaces. */
|
|
38
52
|
function listRuntimeFilesOnDisk(projectRoot) {
|
|
39
53
|
const found = [];
|
|
@@ -121,4 +135,4 @@ async function untrackRuntimeState(projectRoot, opts = {}) {
|
|
|
121
135
|
}
|
|
122
136
|
}
|
|
123
137
|
|
|
124
|
-
module.exports = { findTrackedRuntimeState, untrackRuntimeState, listRuntimeFilesOnDisk };
|
|
138
|
+
module.exports = { findTrackedRuntimeState, findVisibleRuntimeState, untrackRuntimeState, listRuntimeFilesOnDisk };
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* worktreeDeps.cjs —
|
|
2
|
+
* worktreeDeps.cjs — link the main checkout's gitignored top-level
|
|
3
3
|
* dependency dirs (node_modules, .venv, venv) into a fresh worktree.
|
|
4
4
|
*
|
|
5
|
+
* node_modules is never linked whole: the worktree gets a REAL node_modules
|
|
6
|
+
* folder holding one symlink per entry of the main checkout's node_modules
|
|
7
|
+
* (packages, scope folders such as @types linked whole, and .bin; other dot
|
|
8
|
+
* entries — .vite, .cache, .package-lock.json — are not linked, so caches and
|
|
9
|
+
* npm's hidden lockfile stay worktree-local). Why: npm ci reads node_modules'
|
|
10
|
+
* entries and removes each one; through a whole-folder link that deletes the
|
|
11
|
+
* main checkout's packages (2026-11-24: a widget gate's
|
|
12
|
+
* `npm --prefix web/feedback-widget ci` emptied the main checkout's
|
|
13
|
+
* web/feedback-widget/node_modules). With per-entry links an install removes
|
|
14
|
+
* only links. .venv/venv keep the whole-folder link.
|
|
15
|
+
*
|
|
5
16
|
* `git worktree add` checks out tracked files only, so a job worktree has no
|
|
6
17
|
* dependencies and executors park needs_review. A gitignore pattern like
|
|
7
18
|
* `node_modules/` (trailing slash) matches directories only and a symlink is
|
|
@@ -41,11 +52,15 @@
|
|
|
41
52
|
* NESTED_MAX_DEPTH segments deep (never under node_modules), at most
|
|
42
53
|
* NESTED_MAX_PACKAGES of the eligible ones (main has `<dir>/node_modules`, it is
|
|
43
54
|
* gitignored there, the worktree has none — filtered before the cap), the dir is
|
|
44
|
-
*
|
|
55
|
+
* built from per-entry links to the main checkout's (as above) and `/<dir>/node_modules` goes to info/exclude
|
|
45
56
|
* after the link succeeds. Ineligible packages are not reported as skipped. pnpm projects skip this — their
|
|
46
57
|
* offline install already builds every workspace node_modules per worktree.
|
|
47
58
|
*
|
|
48
|
-
*
|
|
59
|
+
* syncNodeModulesLinks refreshes those per-entry links on a reused Epic worktree (the
|
|
60
|
+
* links are a snapshot; the old whole-folder link saw packages added to main later).
|
|
61
|
+
*
|
|
62
|
+
* Never throws; failures land in `skipped` (nested entries as `<rel> (<reason>)`);
|
|
63
|
+
* a failed node_modules build is removed again (links only, never their targets).
|
|
49
64
|
*/
|
|
50
65
|
'use strict';
|
|
51
66
|
|
|
@@ -67,6 +82,49 @@ function exists(p) {
|
|
|
67
82
|
try { fs.lstatSync(p); return true; } catch { return false; }
|
|
68
83
|
}
|
|
69
84
|
|
|
85
|
+
/** True for a node_modules entry that gets a link: anything not dot-prefixed, plus `.bin`. */
|
|
86
|
+
function isLinkedModulesEntry(name) {
|
|
87
|
+
return !name.startsWith('.') || name === '.bin';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Link every linked entry of `src` (a main-checkout node_modules) that `dest` (a real
|
|
92
|
+
* worktree node_modules folder) lacks. Existing dest entries — links or real — are never
|
|
93
|
+
* touched. `strict` rethrows a symlink failure (initial build); otherwise failures are
|
|
94
|
+
* skipped per entry. Returns the count of links made.
|
|
95
|
+
*/
|
|
96
|
+
function linkMissingModulesEntries(src, dest, strict) {
|
|
97
|
+
let added = 0;
|
|
98
|
+
for (const e of fs.readdirSync(src, { withFileTypes: true })) {
|
|
99
|
+
if (!isLinkedModulesEntry(e.name)) continue;
|
|
100
|
+
const link = path.join(dest, e.name);
|
|
101
|
+
if (exists(link)) continue;
|
|
102
|
+
const target = path.join(src, e.name);
|
|
103
|
+
try {
|
|
104
|
+
fs.symlinkSync(target, link, isDir(target) ? 'dir' : 'file');
|
|
105
|
+
added++;
|
|
106
|
+
} catch (err) {
|
|
107
|
+
if (strict) throw err;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return added;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Create `dest` as a real directory holding one symlink per linked entry of `src` (a
|
|
115
|
+
* node_modules folder). Throws on failure after removing whatever it created at `dest`;
|
|
116
|
+
* removal unlinks links only — it never follows them into `src`.
|
|
117
|
+
*/
|
|
118
|
+
function linkModulesEntries(src, dest) {
|
|
119
|
+
fs.mkdirSync(dest);
|
|
120
|
+
try {
|
|
121
|
+
linkMissingModulesEntries(src, dest, true);
|
|
122
|
+
} catch (err) {
|
|
123
|
+
try { fs.rmSync(dest, { recursive: true, force: true }); } catch { /* best-effort */ }
|
|
124
|
+
throw err;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
70
128
|
async function isIgnored(cwd, name) {
|
|
71
129
|
try {
|
|
72
130
|
await execGit(cwd, ['check-ignore', '-q', name], { timeout: 10_000 });
|
|
@@ -222,12 +280,12 @@ async function nestedPackageDirs(worktreeCwd) {
|
|
|
222
280
|
}
|
|
223
281
|
|
|
224
282
|
/**
|
|
225
|
-
*
|
|
283
|
+
* Build `<dir>/node_modules` (per-entry links) for nested npm packages; pushes into linked/skipped. Never throws.
|
|
226
284
|
* Filter first (main has it, it is gitignored, the worktree has none), then cap at
|
|
227
285
|
* NESTED_MAX_PACKAGES, so ineligible packages never take a slot and never appear in
|
|
228
286
|
* `skipped`. `skipped` gets only eligible packages left unlinked, as `<rel> (<reason>)`.
|
|
229
|
-
* The info/exclude line is written only after the
|
|
230
|
-
* the
|
|
287
|
+
* The info/exclude line is written only after the links succeed; if that write fails
|
|
288
|
+
* the folder of links is removed again so status stays clean.
|
|
231
289
|
*/
|
|
232
290
|
async function linkNestedNodeModules(mainCwd, worktreeCwd, linked, skipped) {
|
|
233
291
|
try {
|
|
@@ -248,7 +306,7 @@ async function linkNestedNodeModules(mainCwd, worktreeCwd, linked, skipped) {
|
|
|
248
306
|
const src = path.join(mainCwd, rel);
|
|
249
307
|
const dest = path.join(worktreeCwd, rel);
|
|
250
308
|
try {
|
|
251
|
-
|
|
309
|
+
linkModulesEntries(src, dest);
|
|
252
310
|
} catch (err) {
|
|
253
311
|
skipped.push(`${rel} (symlink failed: ${(err && err.code) || (err && err.message) || err})`);
|
|
254
312
|
continue;
|
|
@@ -257,7 +315,7 @@ async function linkNestedNodeModules(mainCwd, worktreeCwd, linked, skipped) {
|
|
|
257
315
|
await addExcludes(mainCwd, [rel]);
|
|
258
316
|
linked.push(rel);
|
|
259
317
|
} catch (err) {
|
|
260
|
-
try { fs.
|
|
318
|
+
try { fs.rmSync(dest, { recursive: true, force: true }); } catch { /* best-effort */ }
|
|
261
319
|
skipped.push(`${rel} (exclude write failed: ${(err && err.code) || (err && err.message) || err})`);
|
|
262
320
|
}
|
|
263
321
|
}
|
|
@@ -293,7 +351,8 @@ async function linkDependencyDirs({ mainCwd, worktreeCwd, names = DEFAULT_DEP_DI
|
|
|
293
351
|
}
|
|
294
352
|
// Exclude first: a link without its exclude line would dirty status.
|
|
295
353
|
await addExcludes(mainCwd, [name]);
|
|
296
|
-
|
|
354
|
+
if (name === 'node_modules') linkModulesEntries(src, dest);
|
|
355
|
+
else fs.symlinkSync(src, dest, 'dir');
|
|
297
356
|
linked.push(name);
|
|
298
357
|
} catch {
|
|
299
358
|
skipped.push(name);
|
|
@@ -313,4 +372,48 @@ async function linkDependencyDirs({ mainCwd, worktreeCwd, names = DEFAULT_DEP_DI
|
|
|
313
372
|
return { linked, skipped, installed, setup };
|
|
314
373
|
}
|
|
315
374
|
|
|
316
|
-
|
|
375
|
+
/**
|
|
376
|
+
* Refresh one worktree node_modules (`rel`) against the main checkout's: link entries main
|
|
377
|
+
* gained since the snapshot, unlink worktree links whose target is gone. Skips unless the
|
|
378
|
+
* worktree folder is a real directory (a whole-folder symlink is left alone). Reads main
|
|
379
|
+
* only. Never throws.
|
|
380
|
+
*/
|
|
381
|
+
function syncModulesDir(mainCwd, worktreeCwd, rel, counts) {
|
|
382
|
+
try {
|
|
383
|
+
const dest = path.join(worktreeCwd, rel);
|
|
384
|
+
const st = fs.lstatSync(dest);
|
|
385
|
+
if (st.isSymbolicLink() || !st.isDirectory()) return;
|
|
386
|
+
const src = path.join(mainCwd, rel);
|
|
387
|
+
if (isDir(src)) counts.added += linkMissingModulesEntries(src, dest, false);
|
|
388
|
+
for (const name of fs.readdirSync(dest)) {
|
|
389
|
+
const link = path.join(dest, name);
|
|
390
|
+
try {
|
|
391
|
+
if (!fs.lstatSync(link).isSymbolicLink() || fs.existsSync(link)) continue;
|
|
392
|
+
fs.unlinkSync(link); // removes the dangling link itself, never a target
|
|
393
|
+
counts.removed++;
|
|
394
|
+
} catch { /* best-effort per entry */ }
|
|
395
|
+
}
|
|
396
|
+
} catch { /* absent or unreadable */ }
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Bring a reused (long-lived Epic) worktree's per-entry node_modules links up to date with
|
|
401
|
+
* the main checkout — root plus each nested npm package (same set linkNestedNodeModules
|
|
402
|
+
* considers). pnpm projects are skipped (their worktree node_modules is a real install).
|
|
403
|
+
* No-op under SM_WORKTREE_DEP_LINK_DISABLE=1. Never throws.
|
|
404
|
+
* @param {{ mainCwd: string, worktreeCwd: string }} opts
|
|
405
|
+
* @returns {Promise<{ added: number, removed: number }>}
|
|
406
|
+
*/
|
|
407
|
+
async function syncNodeModulesLinks({ mainCwd, worktreeCwd }) {
|
|
408
|
+
const counts = { added: 0, removed: 0 };
|
|
409
|
+
try {
|
|
410
|
+
if (process.env.SM_WORKTREE_DEP_LINK_DISABLE === '1') return counts;
|
|
411
|
+
if (!mainCwd || !worktreeCwd || isPnpmProject(mainCwd)) return counts;
|
|
412
|
+
const rels = ['node_modules'];
|
|
413
|
+
for (const dir of await nestedPackageDirs(worktreeCwd)) rels.push(`${dir}/node_modules`);
|
|
414
|
+
for (const rel of rels) syncModulesDir(mainCwd, worktreeCwd, rel, counts);
|
|
415
|
+
} catch { /* best-effort */ }
|
|
416
|
+
return counts;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
module.exports = { linkDependencyDirs, syncNodeModulesLinks, isPnpmProject, isUvProject, DEFAULT_DEP_DIRS, NESTED_MAX_PACKAGES };
|