cadre-ai 3.5.0 → 3.6.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/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +81 -0
- package/README.md +24 -10
- package/dist/cadre-cli.mjs +9 -6
- package/dist/cadre-mcp.mjs +916 -193
- package/package.json +1 -1
- package/skills/archive/SKILL.md +6 -6
- package/skills/create/SKILL.md +4 -4
- package/skills/implement/SKILL.md +4 -4
- package/skills/implement/references/governed-mode.md +1 -1
- package/skills/refresh/SKILL.md +3 -3
- package/skills/revert/SKILL.md +3 -3
- package/skills/review/SKILL.md +5 -5
- package/skills/revise/SKILL.md +4 -4
- package/skills/status/SKILL.md +2 -1
- package/skills/track/SKILL.md +5 -5
- package/skills/wisp/SKILL.md +3 -3
package/dist/cadre-mcp.mjs
CHANGED
|
@@ -30972,7 +30972,7 @@ var StdioServerTransport = class {
|
|
|
30972
30972
|
|
|
30973
30973
|
// src/mcp/server.ts
|
|
30974
30974
|
import { createHash as createHash8 } from "node:crypto";
|
|
30975
|
-
import { readFileSync as readFileSync10 } from "node:fs";
|
|
30975
|
+
import { existsSync as existsSync12, readFileSync as readFileSync10, readdirSync as readdirSync10 } from "node:fs";
|
|
30976
30976
|
import { join as join10, resolve as resolve12 } from "node:path";
|
|
30977
30977
|
import { pathToFileURL } from "node:url";
|
|
30978
30978
|
|
|
@@ -30997,8 +30997,8 @@ import { existsSync as existsSync5, lstatSync as lstatSync2, readFileSync as rea
|
|
|
30997
30997
|
import { isAbsolute, join as join3, relative, resolve as resolve5 } from "node:path";
|
|
30998
30998
|
|
|
30999
30999
|
// src/domain/version.ts
|
|
31000
|
-
var CADRE_RUNTIME_VERSION = "3.
|
|
31001
|
-
var LEGACY_RUNTIME_VERSIONS = ["3.4.0", "3.3.0"];
|
|
31000
|
+
var CADRE_RUNTIME_VERSION = "3.6.0";
|
|
31001
|
+
var LEGACY_RUNTIME_VERSIONS = ["3.5.1", "3.5.0", "3.4.0", "3.3.0"];
|
|
31002
31002
|
var TEMPLATE_SET_VERSION = "v2";
|
|
31003
31003
|
var LEGACY_TEMPLATE_SET_VERSIONS = ["v1"];
|
|
31004
31004
|
|
|
@@ -31415,10 +31415,14 @@ function hash2(value) {
|
|
|
31415
31415
|
return createHash2("sha256").update(JSON.stringify(value)).digest("hex");
|
|
31416
31416
|
}
|
|
31417
31417
|
function writeJournalAtomically(path, journal) {
|
|
31418
|
+
writeTextAtomically(path, `${JSON.stringify(journal, null, 2)}
|
|
31419
|
+
`);
|
|
31420
|
+
}
|
|
31421
|
+
function writeTextAtomically(path, content) {
|
|
31422
|
+
if (existsSync4(path) && readFileSync3(path, "utf8") === content) return;
|
|
31418
31423
|
const temporaryPath = join2(dirname(path), `.${basename(path)}.${process.pid}.${randomUUID()}.tmp`);
|
|
31419
31424
|
try {
|
|
31420
|
-
writeFileSync(temporaryPath,
|
|
31421
|
-
`, { flag: "wx" });
|
|
31425
|
+
writeFileSync(temporaryPath, content, { flag: "wx" });
|
|
31422
31426
|
renameSync(temporaryPath, path);
|
|
31423
31427
|
} finally {
|
|
31424
31428
|
if (existsSync4(temporaryPath)) unlinkSync(temporaryPath);
|
|
@@ -32011,6 +32015,21 @@ function applyExecutionCheckpoint(input, proposalDigest, preparedProposal) {
|
|
|
32011
32015
|
};
|
|
32012
32016
|
}
|
|
32013
32017
|
function deriveExecutionFinishInput(input) {
|
|
32018
|
+
const journal = readExecution(input.projectRoot, input.trackId, input.executionId);
|
|
32019
|
+
if (journal.status === "completed" && journal.headCommit && journal.completedAt) {
|
|
32020
|
+
return { ...input, headCommit: journal.headCommit, completedAt: journal.completedAt };
|
|
32021
|
+
}
|
|
32022
|
+
const { statePath } = executionPaths(input.projectRoot, input.trackId, input.executionId);
|
|
32023
|
+
const state = JSON.parse(readFileSync3(statePath, "utf8"));
|
|
32024
|
+
const priorHead = state.lastExecution?.headCommit;
|
|
32025
|
+
const priorCompletedAt = state.lastExecution?.completedAt;
|
|
32026
|
+
if (state.lastExecution?.executionId === input.executionId && typeof priorHead === "string" && typeof priorCompletedAt === "string") {
|
|
32027
|
+
return {
|
|
32028
|
+
...input,
|
|
32029
|
+
headCommit: priorHead,
|
|
32030
|
+
completedAt: priorCompletedAt
|
|
32031
|
+
};
|
|
32032
|
+
}
|
|
32014
32033
|
return {
|
|
32015
32034
|
...input,
|
|
32016
32035
|
headCommit: resolveGitCommit(input.projectRoot),
|
|
@@ -32049,7 +32068,8 @@ function previewExecutionFinish(input) {
|
|
|
32049
32068
|
const state = JSON.parse(stateBody);
|
|
32050
32069
|
const journal = JSON.parse(journalBody);
|
|
32051
32070
|
const operation = state.operation;
|
|
32052
|
-
|
|
32071
|
+
const stateAlreadyCompleted = state.status === "ready_for_review" && state.lastExecution?.executionId === input.executionId && state.lastExecution.headCommit === input.headCommit && state.lastExecution.completedAt === input.completedAt;
|
|
32072
|
+
if (!stateAlreadyCompleted && (operation?.action !== "implement" || operation.executionId !== input.executionId)) {
|
|
32053
32073
|
throw new Error("track does not point to this implementation execution");
|
|
32054
32074
|
}
|
|
32055
32075
|
if (!["in_progress", "completed"].includes(journal.status)) throw new Error("execution cannot be completed");
|
|
@@ -32093,7 +32113,7 @@ function previewExecutionFinish(input) {
|
|
|
32093
32113
|
completedAt: input.completedAt,
|
|
32094
32114
|
headCommit: input.headCommit
|
|
32095
32115
|
};
|
|
32096
|
-
const completedState = {
|
|
32116
|
+
const completedState = stateAlreadyCompleted ? state : {
|
|
32097
32117
|
...state,
|
|
32098
32118
|
status: "ready_for_review",
|
|
32099
32119
|
checkpoint: "ready_for_review",
|
|
@@ -32140,27 +32160,12 @@ function applyExecutionFinish(input, proposalDigest, preparedProposal) {
|
|
|
32140
32160
|
if (lstatSync(proposal.journalPath).isSymbolicLink() || lstatSync(proposal.statePath).isSymbolicLink() || lstatSync(proposal.planPath).isSymbolicLink() || lstatSync(proposal.tracksPath).isSymbolicLink()) {
|
|
32141
32161
|
throw new Error("refusing to complete execution through a symbolic link");
|
|
32142
32162
|
}
|
|
32143
|
-
|
|
32144
|
-
|
|
32145
|
-
|
|
32146
|
-
|
|
32147
|
-
|
|
32148
|
-
|
|
32149
|
-
`, { flag: "wx" });
|
|
32150
|
-
writeFileSync(stateTemporaryPath, `${JSON.stringify(proposal.state, null, 2)}
|
|
32151
|
-
`, { flag: "wx" });
|
|
32152
|
-
writeFileSync(planTemporaryPath, proposal.planContent, { flag: "wx" });
|
|
32153
|
-
writeFileSync(tracksTemporaryPath, proposal.tracksContent, { flag: "wx" });
|
|
32154
|
-
renameSync(journalTemporaryPath, proposal.journalPath);
|
|
32155
|
-
renameSync(stateTemporaryPath, proposal.statePath);
|
|
32156
|
-
renameSync(planTemporaryPath, proposal.planPath);
|
|
32157
|
-
renameSync(tracksTemporaryPath, proposal.tracksPath);
|
|
32158
|
-
} finally {
|
|
32159
|
-
if (existsSync4(journalTemporaryPath)) unlinkSync(journalTemporaryPath);
|
|
32160
|
-
if (existsSync4(stateTemporaryPath)) unlinkSync(stateTemporaryPath);
|
|
32161
|
-
if (existsSync4(planTemporaryPath)) unlinkSync(planTemporaryPath);
|
|
32162
|
-
if (existsSync4(tracksTemporaryPath)) unlinkSync(tracksTemporaryPath);
|
|
32163
|
-
}
|
|
32163
|
+
writeTextAtomically(proposal.journalPath, `${JSON.stringify(proposal.journal, null, 2)}
|
|
32164
|
+
`);
|
|
32165
|
+
writeTextAtomically(proposal.statePath, `${JSON.stringify(proposal.state, null, 2)}
|
|
32166
|
+
`);
|
|
32167
|
+
writeTextAtomically(proposal.planPath, proposal.planContent);
|
|
32168
|
+
writeTextAtomically(proposal.tracksPath, proposal.tracksContent);
|
|
32164
32169
|
return proposal;
|
|
32165
32170
|
}
|
|
32166
32171
|
function validateExecutionJournal(trackRoot, state, graph, errors) {
|
|
@@ -32836,6 +32841,7 @@ import {
|
|
|
32836
32841
|
readFileSync as readFileSync5,
|
|
32837
32842
|
readdirSync as readdirSync4,
|
|
32838
32843
|
renameSync as renameSync2,
|
|
32844
|
+
rmdirSync,
|
|
32839
32845
|
unlinkSync as unlinkSync2,
|
|
32840
32846
|
writeFileSync as writeFileSync3
|
|
32841
32847
|
} from "node:fs";
|
|
@@ -32880,9 +32886,13 @@ function candidateStageRoot(projectRootInput, candidateIdInput) {
|
|
|
32880
32886
|
}
|
|
32881
32887
|
return join4(stageParent, candidateId);
|
|
32882
32888
|
}
|
|
32883
|
-
function prepareCandidateStage(projectRootInput, candidateIdInput) {
|
|
32889
|
+
function prepareCandidateStage(projectRootInput, candidateIdInput, expectedFiles) {
|
|
32884
32890
|
const projectRoot = safeProjectRoot(projectRootInput);
|
|
32885
32891
|
const candidateId = normalizeCandidateId(candidateIdInput);
|
|
32892
|
+
const normalizedExpected = expectedFiles?.map(normalizeCandidatePath);
|
|
32893
|
+
if (normalizedExpected && new Set(normalizedExpected).size !== normalizedExpected.length) {
|
|
32894
|
+
throw new Error("Candidate expectedFiles contains duplicate paths");
|
|
32895
|
+
}
|
|
32886
32896
|
const cadreRoot2 = join4(projectRoot, ".cadre");
|
|
32887
32897
|
if (existsSync6(cadreRoot2)) {
|
|
32888
32898
|
const stat = lstatSync3(cadreRoot2);
|
|
@@ -32912,7 +32922,24 @@ function prepareCandidateStage(projectRootInput, candidateIdInput) {
|
|
|
32912
32922
|
const stagePath = join4(cadreRoot2, "stage", candidateId);
|
|
32913
32923
|
mkdirSync2(stagePath, { recursive: true });
|
|
32914
32924
|
candidateStageRoot(projectRoot, candidateId);
|
|
32915
|
-
|
|
32925
|
+
const retainedFiles = listCandidatePaths(projectRoot, candidateId);
|
|
32926
|
+
if (normalizedExpected === void 0) return { stagePath, gitignorePath, retainedFiles, removedFiles: [] };
|
|
32927
|
+
const expected = new Set(normalizedExpected);
|
|
32928
|
+
const removedFiles = retainedFiles.filter((path) => !expected.has(path));
|
|
32929
|
+
for (const path of removedFiles) unlinkSync2(join4(stagePath, path));
|
|
32930
|
+
const pruneEmptyDirectories = (directory) => {
|
|
32931
|
+
for (const entry of readdirSync4(directory, { withFileTypes: true })) {
|
|
32932
|
+
if (entry.isDirectory()) pruneEmptyDirectories(join4(directory, entry.name));
|
|
32933
|
+
}
|
|
32934
|
+
if (directory !== stagePath && readdirSync4(directory).length === 0) rmdirSync(directory);
|
|
32935
|
+
};
|
|
32936
|
+
pruneEmptyDirectories(stagePath);
|
|
32937
|
+
return {
|
|
32938
|
+
stagePath,
|
|
32939
|
+
gitignorePath,
|
|
32940
|
+
retainedFiles: retainedFiles.filter((path) => expected.has(path)),
|
|
32941
|
+
removedFiles
|
|
32942
|
+
};
|
|
32916
32943
|
}
|
|
32917
32944
|
function assertRegularPath(root, target) {
|
|
32918
32945
|
const relation = relative2(root, target);
|
|
@@ -33282,18 +33309,39 @@ function loadProjectInitCandidate(input) {
|
|
|
33282
33309
|
return { ...input, files };
|
|
33283
33310
|
}
|
|
33284
33311
|
function previewProjectInitCandidate(input) {
|
|
33285
|
-
|
|
33286
|
-
|
|
33312
|
+
const proposal = buildProjectInitProposal(loadProjectInitCandidate(input));
|
|
33313
|
+
assertInitializationBootstrap(input.projectRoot, proposal);
|
|
33314
|
+
return proposal;
|
|
33287
33315
|
}
|
|
33288
|
-
function assertInitializationBootstrap(projectRootInput) {
|
|
33316
|
+
function assertInitializationBootstrap(projectRootInput, proposal) {
|
|
33289
33317
|
const root = safeProjectRoot(projectRootInput);
|
|
33290
33318
|
const cadreRoot2 = join6(root, ".cadre");
|
|
33291
33319
|
if (!existsSync8(cadreRoot2) || !lstatSync4(cadreRoot2).isDirectory() || lstatSync4(cadreRoot2).isSymbolicLink()) {
|
|
33292
33320
|
throw new Error(`${cadreRoot2} must be a prepared candidate-stage directory`);
|
|
33293
33321
|
}
|
|
33294
|
-
const
|
|
33295
|
-
|
|
33296
|
-
|
|
33322
|
+
const expected = new Map(proposal.files.map((file2) => [file2.path, file2.content]));
|
|
33323
|
+
const visit = (directory) => {
|
|
33324
|
+
for (const entry of readdirSync6(directory, { withFileTypes: true })) {
|
|
33325
|
+
const target = join6(directory, entry.name);
|
|
33326
|
+
const path = relative4(cadreRoot2, target).replaceAll("\\", "/");
|
|
33327
|
+
if (path === "stage" || path.startsWith("stage/")) continue;
|
|
33328
|
+
if (entry.isSymbolicLink()) throw new Error(`Refusing symbolic link inside initialization state: ${target}`);
|
|
33329
|
+
if (entry.isDirectory()) {
|
|
33330
|
+
visit(target);
|
|
33331
|
+
continue;
|
|
33332
|
+
}
|
|
33333
|
+
if (!entry.isFile()) throw new Error(`Unsupported initialization state entry: ${target}`);
|
|
33334
|
+
const content = expected.get(path);
|
|
33335
|
+
if (content === void 0) throw new Error(`${cadreRoot2} contains unexpected canonical state: ${path}`);
|
|
33336
|
+
if (readFileSync7(target, "utf8") !== content) {
|
|
33337
|
+
throw new Error(`Interrupted initialization disagrees at ${path}`);
|
|
33338
|
+
}
|
|
33339
|
+
}
|
|
33340
|
+
};
|
|
33341
|
+
visit(cadreRoot2);
|
|
33342
|
+
const canonicalEntries = readdirSync6(cadreRoot2).filter((entry) => ![".gitignore", "stage"].includes(entry));
|
|
33343
|
+
if (canonicalEntries.length && !canonicalEntries.some((entry) => proposal.files.some((file2) => file2.path === entry || file2.path.startsWith(`${entry}/`)))) {
|
|
33344
|
+
throw new Error(`${cadreRoot2} contains unrelated canonical project state`);
|
|
33297
33345
|
}
|
|
33298
33346
|
}
|
|
33299
33347
|
function targetWithin(root, relativePath) {
|
|
@@ -33394,7 +33442,7 @@ function recordGitInitialized(projectRootInput) {
|
|
|
33394
33442
|
|
|
33395
33443
|
// src/domain/worktrees.ts
|
|
33396
33444
|
import { createHash as createHash6 } from "node:crypto";
|
|
33397
|
-
import { existsSync as existsSync9, lstatSync as lstatSync5, readdirSync as readdirSync7, realpathSync as realpathSync2, rmdirSync } from "node:fs";
|
|
33445
|
+
import { existsSync as existsSync9, lstatSync as lstatSync5, readdirSync as readdirSync7, realpathSync as realpathSync2, rmdirSync as rmdirSync2 } from "node:fs";
|
|
33398
33446
|
import { dirname as dirname4, join as join7, relative as relative5, resolve as resolve9 } from "node:path";
|
|
33399
33447
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
33400
33448
|
var SHA2 = /^[0-9a-f]{7,40}$/;
|
|
@@ -33644,7 +33692,7 @@ function applyWorktreeCleanup(input, proposalDigest, preparedProposal) {
|
|
|
33644
33692
|
let directory = dirname4(proposal.path);
|
|
33645
33693
|
while (directory.startsWith(`${managedRoot}/`)) {
|
|
33646
33694
|
if (!existsSync9(directory) || readdirSync7(directory).length) break;
|
|
33647
|
-
|
|
33695
|
+
rmdirSync2(directory);
|
|
33648
33696
|
directory = dirname4(directory);
|
|
33649
33697
|
}
|
|
33650
33698
|
return { removedPath: proposal.path, removedBranch: proposal.branch };
|
|
@@ -33677,7 +33725,7 @@ function managedWorktreeStatus(projectRoot) {
|
|
|
33677
33725
|
}
|
|
33678
33726
|
|
|
33679
33727
|
// src/domain/governance.ts
|
|
33680
|
-
import { createHash as createHash7 } from "node:crypto";
|
|
33728
|
+
import { createHash as createHash7, randomUUID as randomUUID3 } from "node:crypto";
|
|
33681
33729
|
import {
|
|
33682
33730
|
existsSync as existsSync10,
|
|
33683
33731
|
lstatSync as lstatSync6,
|
|
@@ -33685,6 +33733,7 @@ import {
|
|
|
33685
33733
|
readFileSync as readFileSync8,
|
|
33686
33734
|
readdirSync as readdirSync8,
|
|
33687
33735
|
renameSync as renameSync4,
|
|
33736
|
+
unlinkSync as unlinkSync4,
|
|
33688
33737
|
writeFileSync as writeFileSync5
|
|
33689
33738
|
} from "node:fs";
|
|
33690
33739
|
import { dirname as dirname5, join as join8, relative as relative6 } from "node:path";
|
|
@@ -33709,7 +33758,14 @@ function assertWritableFile(path) {
|
|
|
33709
33758
|
function writeApprovedFile(path, content) {
|
|
33710
33759
|
assertWritableFile(path);
|
|
33711
33760
|
mkdirSync4(dirname5(path), { recursive: true });
|
|
33712
|
-
|
|
33761
|
+
if (existsSync10(path) && readFileSync8(path, "utf8") === content) return;
|
|
33762
|
+
const temporaryPath = join8(dirname5(path), `.${randomUUID3()}.cadre.tmp`);
|
|
33763
|
+
try {
|
|
33764
|
+
writeFileSync5(temporaryPath, content, { flag: "wx" });
|
|
33765
|
+
renameSync4(temporaryPath, path);
|
|
33766
|
+
} finally {
|
|
33767
|
+
if (existsSync10(temporaryPath)) unlinkSync4(temporaryPath);
|
|
33768
|
+
}
|
|
33713
33769
|
}
|
|
33714
33770
|
function requireCurrentProject(projectRoot) {
|
|
33715
33771
|
const validation = validateProject(projectRoot);
|
|
@@ -33721,19 +33777,27 @@ function deriveReviewCompleteInput(input) {
|
|
|
33721
33777
|
const validation = requireCurrentProject(input.projectRoot);
|
|
33722
33778
|
const state = validation.states.get(input.trackId);
|
|
33723
33779
|
const reviewedHead = state?.lastExecution?.headCommit;
|
|
33780
|
+
const executionId = state?.lastExecution?.executionId;
|
|
33724
33781
|
if (!reviewedHead || !SHA3.test(reviewedHead)) throw new Error(`${input.trackId} has no completed execution head`);
|
|
33782
|
+
if (!executionId) throw new Error(`${input.trackId} has no completed execution journal`);
|
|
33783
|
+
const execution = executionStatus(input.projectRoot, input.trackId, executionId).journal;
|
|
33784
|
+
if (execution.status !== "completed" || execution.headCommit !== reviewedHead || !SHA3.test(execution.baseCommit)) {
|
|
33785
|
+
throw new Error(`${input.trackId} completed execution evidence is inconsistent`);
|
|
33786
|
+
}
|
|
33725
33787
|
if (!isGitAncestor(input.projectRoot, reviewedHead)) {
|
|
33726
33788
|
throw new Error(`completed execution head ${reviewedHead} is not an ancestor of current HEAD`);
|
|
33727
33789
|
}
|
|
33728
|
-
const
|
|
33790
|
+
const acceptedRisks = (input.acceptedRisks ?? []).map((risk) => risk.trim()).filter(Boolean);
|
|
33791
|
+
const existingCycle = state.status === "completed" ? state.reviewCycles?.at(-1) : void 0;
|
|
33792
|
+
const matchingCycle = existingCycle && existingCycle.outcome === "clean" && existingCycle.executionId === executionId && existingCycle.reviewedHead === reviewedHead && existingCycle.approval === input.approval && JSON.stringify(existingCycle.acceptedRisks ?? []) === JSON.stringify(acceptedRisks) ? existingCycle : void 0;
|
|
33729
33793
|
return {
|
|
33730
33794
|
projectRoot: input.projectRoot,
|
|
33731
33795
|
trackId: input.trackId,
|
|
33732
|
-
reviewedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
33796
|
+
reviewedAt: typeof matchingCycle?.reviewedAt === "string" ? matchingCycle.reviewedAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
33733
33797
|
reviewedHead,
|
|
33734
|
-
commitRange: `${
|
|
33798
|
+
commitRange: `${execution.baseCommit}..${reviewedHead}`,
|
|
33735
33799
|
approval: input.approval,
|
|
33736
|
-
...
|
|
33800
|
+
...acceptedRisks.length ? { acceptedRisks } : {}
|
|
33737
33801
|
};
|
|
33738
33802
|
}
|
|
33739
33803
|
function previewReviewComplete(input) {
|
|
@@ -33750,9 +33814,7 @@ function previewReviewComplete(input) {
|
|
|
33750
33814
|
const track = validation.tracks.find((candidate) => candidate.id === input.trackId);
|
|
33751
33815
|
const current = validation.states.get(input.trackId);
|
|
33752
33816
|
if (!track || !current) throw new Error(`unknown track ${input.trackId}`);
|
|
33753
|
-
if (track.location !== `tracks/${input.trackId}`
|
|
33754
|
-
throw new Error(`${input.trackId} is not ready for review`);
|
|
33755
|
-
}
|
|
33817
|
+
if (track.location !== `tracks/${input.trackId}`) throw new Error(`${input.trackId} is not an active track`);
|
|
33756
33818
|
if (current.operation != null) throw new Error(`${input.trackId} already has an active operation`);
|
|
33757
33819
|
const execution = current.lastExecution;
|
|
33758
33820
|
if (!execution?.executionId || !execution.planRevision || !execution.graphDigest || execution.headCommit !== input.reviewedHead) {
|
|
@@ -33764,7 +33826,7 @@ function previewReviewComplete(input) {
|
|
|
33764
33826
|
const tracksBody = readFileSync8(tracksPath, "utf8");
|
|
33765
33827
|
const acceptedRisks = (input.acceptedRisks ?? []).map((risk) => risk.trim()).filter(Boolean);
|
|
33766
33828
|
const cycle = {
|
|
33767
|
-
cycle: (current.reviewCycles?.length ?? 0) + 1,
|
|
33829
|
+
cycle: current.status === "completed" ? current.reviewCycles?.length ?? 0 : (current.reviewCycles?.length ?? 0) + 1,
|
|
33768
33830
|
reviewedAt: input.reviewedAt,
|
|
33769
33831
|
outcome: "clean",
|
|
33770
33832
|
executionId: execution.executionId,
|
|
@@ -33775,7 +33837,10 @@ function previewReviewComplete(input) {
|
|
|
33775
33837
|
approval: input.approval,
|
|
33776
33838
|
...acceptedRisks.length ? { acceptedRisks } : {}
|
|
33777
33839
|
};
|
|
33778
|
-
const
|
|
33840
|
+
const existingCycle = current.reviewCycles?.at(-1);
|
|
33841
|
+
const resuming = current.status === "completed" && JSON.stringify(existingCycle) === JSON.stringify(cycle);
|
|
33842
|
+
if (current.status !== "ready_for_review" && !resuming) throw new Error(`${input.trackId} is not ready for review`);
|
|
33843
|
+
const state = resuming ? current : {
|
|
33779
33844
|
...current,
|
|
33780
33845
|
status: "completed",
|
|
33781
33846
|
checkpoint: "completed",
|
|
@@ -33788,12 +33853,15 @@ function previewReviewComplete(input) {
|
|
|
33788
33853
|
state,
|
|
33789
33854
|
tracksPath,
|
|
33790
33855
|
tracksContent,
|
|
33791
|
-
digest: hash5({ stateBody, tracksBody, input, state, tracksContent })
|
|
33856
|
+
digest: hash5({ stateBody, tracksBody, input, state, tracksContent }),
|
|
33857
|
+
resuming
|
|
33792
33858
|
};
|
|
33793
33859
|
}
|
|
33794
33860
|
function applyReviewComplete(input, proposalDigest) {
|
|
33795
33861
|
const proposal = previewReviewComplete(input);
|
|
33796
|
-
if (proposal.digest !== proposalDigest
|
|
33862
|
+
if (proposal.digest !== proposalDigest && !proposal.resuming) {
|
|
33863
|
+
throw new Error("review completion proposal is stale; preview it again");
|
|
33864
|
+
}
|
|
33797
33865
|
writeApprovedFile(proposal.statePath, json2(proposal.state));
|
|
33798
33866
|
writeApprovedFile(proposal.tracksPath, proposal.tracksContent);
|
|
33799
33867
|
const validation = validateProject(input.projectRoot);
|
|
@@ -33945,7 +34013,11 @@ function previewMaterializedArchiveBatch(input) {
|
|
|
33945
34013
|
if (existingOperation && (existingOperation.action !== "archive" || existingOperation.status !== "in_progress" || existingOperation.baseCommit !== input.baseCommit || JSON.stringify(existingOperation.selectedTracks) !== JSON.stringify(input.selectedTracks))) {
|
|
33946
34014
|
throw new Error(`archive batch ${input.batchId} does not match the approved input`);
|
|
33947
34015
|
}
|
|
33948
|
-
const validation =
|
|
34016
|
+
const validation = validateProject(root);
|
|
34017
|
+
const recoverableErrors = existingOperation ? new Set(existingOperation.selectedTracks.map((trackId) => `${trackId}: status completed requires location tracks/${trackId}`)) : /* @__PURE__ */ new Set();
|
|
34018
|
+
const blockingErrors = validation.errors.filter((error51) => !recoverableErrors.has(error51));
|
|
34019
|
+
if (blockingErrors.length) throw new Error(blockingErrors.join("\n"));
|
|
34020
|
+
if (!validation.project) throw new Error("Cadre project state is unavailable");
|
|
33949
34021
|
const selected = new Set(input.selectedTracks);
|
|
33950
34022
|
const updates = input.updates.map((update) => ({ ...update, path: update.path.replaceAll("\\", "/") }));
|
|
33951
34023
|
if (new Set(updates.map((update) => update.path)).size !== updates.length) {
|
|
@@ -33975,8 +34047,8 @@ function previewMaterializedArchiveBatch(input) {
|
|
|
33975
34047
|
const state = validation.states.get(trackId);
|
|
33976
34048
|
if (!track || !state) throw new Error(`unknown selected track ${trackId}`);
|
|
33977
34049
|
const pending = track.status === "completed" && track.location === `tracks/${trackId}`;
|
|
33978
|
-
const
|
|
33979
|
-
if (!pending && !
|
|
34050
|
+
const partiallyPromoted = existingOperation != null && ["completed", "archived"].includes(track.status) && track.location === `archive/${trackId}`;
|
|
34051
|
+
if (!pending && !partiallyPromoted || state.operation != null) {
|
|
33980
34052
|
throw new Error(`${trackId} is not an eligible completed track`);
|
|
33981
34053
|
}
|
|
33982
34054
|
const sourcePath = join8(cadreRoot(root), pending ? "tracks" : "archive", trackId);
|
|
@@ -34036,7 +34108,12 @@ function previewMaterializedArchiveBatch(input) {
|
|
|
34036
34108
|
}
|
|
34037
34109
|
function applyMaterializedArchiveBatch(input, proposalDigest) {
|
|
34038
34110
|
const proposal = previewMaterializedArchiveBatch(input);
|
|
34039
|
-
if (proposal.digest !== proposalDigest)
|
|
34111
|
+
if (proposal.digest !== proposalDigest) {
|
|
34112
|
+
const existing = existsSync10(proposal.operationPath) ? JSON.parse(readFileSync8(proposal.operationPath, "utf8")) : null;
|
|
34113
|
+
if (!proposal.resuming || existing?.approvalDigest !== proposal.initialOperation.approvalDigest) {
|
|
34114
|
+
throw new Error("archive batch proposal is stale; preview it again");
|
|
34115
|
+
}
|
|
34116
|
+
}
|
|
34040
34117
|
const currentOperation = existsSync10(proposal.operationPath) ? JSON.parse(readFileSync8(proposal.operationPath, "utf8")) : proposal.initialOperation;
|
|
34041
34118
|
if (!existsSync10(proposal.operationPath)) writeApprovedFile(proposal.operationPath, json2(currentOperation));
|
|
34042
34119
|
mkdirSync4(join8(cadreRoot(input.projectRoot), "archive"), { recursive: true });
|
|
@@ -34080,8 +34157,8 @@ function previewArchiveBatchRecord(input) {
|
|
|
34080
34157
|
const operationPath = join8(cadreRoot(root), "operations", `${input.batchId}.json`);
|
|
34081
34158
|
const operationBody = readFileSync8(operationPath, "utf8");
|
|
34082
34159
|
const currentOperation = JSON.parse(operationBody);
|
|
34083
|
-
if (currentOperation.action !== "archive" || currentOperation.status
|
|
34084
|
-
throw new Error(`${input.batchId} is not
|
|
34160
|
+
if (currentOperation.action !== "archive" || !["in_progress", "completed"].includes(currentOperation.status) || currentOperation.status === "completed" && currentOperation.archiveCommit !== input.archiveCommit) {
|
|
34161
|
+
throw new Error(`${input.batchId} is not a matching archive batch`);
|
|
34085
34162
|
}
|
|
34086
34163
|
const projectPath = join8(cadreRoot(root), "project.json");
|
|
34087
34164
|
const projectBody = readFileSync8(projectPath, "utf8");
|
|
@@ -34091,13 +34168,21 @@ function previewArchiveBatchRecord(input) {
|
|
|
34091
34168
|
const body = readFileSync8(path, "utf8");
|
|
34092
34169
|
const current = JSON.parse(body);
|
|
34093
34170
|
if (current.status !== "archived") throw new Error(`${trackId} is not archived`);
|
|
34171
|
+
const existingCommit = current.commits?.archive;
|
|
34172
|
+
if (existingCommit && existingCommit !== input.archiveCommit) {
|
|
34173
|
+
throw new Error(`${trackId} archive commit differs from the current batch`);
|
|
34174
|
+
}
|
|
34175
|
+
const existingHistory = (Array.isArray(current.history) ? current.history : []).find((entry) => typeof entry === "object" && entry !== null && entry.action === "archive" && entry.batchId === input.batchId);
|
|
34176
|
+
if (existingHistory && existingHistory.commit !== input.archiveCommit) {
|
|
34177
|
+
throw new Error(`${trackId} archive history differs from the current batch`);
|
|
34178
|
+
}
|
|
34094
34179
|
return {
|
|
34095
34180
|
path,
|
|
34096
34181
|
body,
|
|
34097
34182
|
state: {
|
|
34098
34183
|
...current,
|
|
34099
34184
|
commits: { ...current.commits ?? {}, archive: input.archiveCommit },
|
|
34100
|
-
history: [...Array.isArray(current.history) ? current.history : [], {
|
|
34185
|
+
history: existingHistory ? current.history : [...Array.isArray(current.history) ? current.history : [], {
|
|
34101
34186
|
action: "archive",
|
|
34102
34187
|
batchId: input.batchId,
|
|
34103
34188
|
commit: input.archiveCommit
|
|
@@ -34105,9 +34190,13 @@ function previewArchiveBatchRecord(input) {
|
|
|
34105
34190
|
}
|
|
34106
34191
|
};
|
|
34107
34192
|
});
|
|
34193
|
+
const existingProjectHistory = (currentProject.history ?? []).find((entry) => typeof entry === "object" && entry !== null && entry.action === "archive" && entry.batchId === input.batchId);
|
|
34194
|
+
if (existingProjectHistory && existingProjectHistory.commit !== input.archiveCommit) {
|
|
34195
|
+
throw new Error(`project archive history differs for ${input.batchId}`);
|
|
34196
|
+
}
|
|
34108
34197
|
const project = {
|
|
34109
34198
|
...currentProject,
|
|
34110
|
-
history: [...currentProject.history ?? [], {
|
|
34199
|
+
history: existingProjectHistory ? currentProject.history ?? [] : [...currentProject.history ?? [], {
|
|
34111
34200
|
action: "archive",
|
|
34112
34201
|
batchId: input.batchId,
|
|
34113
34202
|
tracks: [...currentOperation.selectedTracks],
|
|
@@ -34317,7 +34406,7 @@ import {
|
|
|
34317
34406
|
openSync,
|
|
34318
34407
|
readFileSync as readFileSync9,
|
|
34319
34408
|
readdirSync as readdirSync9,
|
|
34320
|
-
unlinkSync as
|
|
34409
|
+
unlinkSync as unlinkSync5,
|
|
34321
34410
|
writeFileSync as writeFileSync6
|
|
34322
34411
|
} from "node:fs";
|
|
34323
34412
|
import { homedir as homedir2 } from "node:os";
|
|
@@ -34490,7 +34579,7 @@ var ProposalTokenStore = class {
|
|
|
34490
34579
|
}
|
|
34491
34580
|
unlinkRecord(path) {
|
|
34492
34581
|
try {
|
|
34493
|
-
|
|
34582
|
+
unlinkSync5(path);
|
|
34494
34583
|
} catch (error51) {
|
|
34495
34584
|
if (error51.code !== "ENOENT") throw error51;
|
|
34496
34585
|
}
|
|
@@ -34524,42 +34613,524 @@ var CADRE_MCP_TOOLS = {
|
|
|
34524
34613
|
};
|
|
34525
34614
|
var CADRE_MCP_TOOL_NAMES = Object.freeze(Object.values(CADRE_MCP_TOOLS));
|
|
34526
34615
|
|
|
34527
|
-
// src/mcp/
|
|
34528
|
-
|
|
34616
|
+
// src/mcp/output-schemas.ts
|
|
34617
|
+
var stringArray = external_exports.array(external_exports.string());
|
|
34618
|
+
var pathSchema = external_exports.string().min(1);
|
|
34619
|
+
var digestSchema = external_exports.string().regex(/^[0-9a-f]{64}$/);
|
|
34620
|
+
var commitSchema = external_exports.string().regex(/^[0-9a-f]{7,40}$/);
|
|
34621
|
+
var proposalTokenSchema2 = external_exports.string().regex(/^cadre_pt1_[A-Za-z0-9_-]{32}$/);
|
|
34622
|
+
var commandStatusSchema = external_exports.enum(["approval_required", "applied"]);
|
|
34623
|
+
var jsonObjectSchema = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
34624
|
+
var errorSchema = external_exports.strictObject({
|
|
34625
|
+
code: external_exports.string().min(1),
|
|
34626
|
+
message: external_exports.string(),
|
|
34627
|
+
details: jsonObjectSchema.optional()
|
|
34628
|
+
});
|
|
34629
|
+
var errorOutputSchema = external_exports.strictObject({ error: errorSchema });
|
|
34630
|
+
function compatibleOutputSchema(...successSchemas) {
|
|
34631
|
+
const fields = /* @__PURE__ */ new Map();
|
|
34632
|
+
for (const schema of successSchemas) {
|
|
34633
|
+
for (const [key, field] of Object.entries(schema.shape)) {
|
|
34634
|
+
const candidates = fields.get(key) ?? [];
|
|
34635
|
+
const candidate = field;
|
|
34636
|
+
const signature = JSON.stringify(external_exports.toJSONSchema(candidate));
|
|
34637
|
+
if (!candidates.some((existing) => JSON.stringify(external_exports.toJSONSchema(existing)) === signature)) {
|
|
34638
|
+
candidates.push(candidate);
|
|
34639
|
+
}
|
|
34640
|
+
fields.set(key, candidates);
|
|
34641
|
+
}
|
|
34642
|
+
}
|
|
34643
|
+
const advertised = Object.fromEntries([...fields].map(([key, candidates]) => {
|
|
34644
|
+
const field = candidates.length === 1 ? candidates[0] : external_exports.union(candidates);
|
|
34645
|
+
return [key, field.optional()];
|
|
34646
|
+
}));
|
|
34647
|
+
return external_exports.strictObject({ ...advertised, error: errorSchema.optional() }).superRefine((value, context) => {
|
|
34648
|
+
if (errorOutputSchema.safeParse(value).success) return;
|
|
34649
|
+
if (successSchemas.some((schema) => schema.safeParse(value).success)) return;
|
|
34650
|
+
context.addIssue({ code: "custom", message: "result does not match a declared Cadre output variant" });
|
|
34651
|
+
});
|
|
34652
|
+
}
|
|
34653
|
+
var artifactSchema = external_exports.strictObject({ path: pathSchema, sha256: digestSchema });
|
|
34654
|
+
var templateDescriptorSchema = external_exports.strictObject({
|
|
34655
|
+
id: external_exports.enum(TEMPLATE_IDS),
|
|
34656
|
+
uri: external_exports.string().min(1),
|
|
34657
|
+
mimeType: external_exports.string().min(1),
|
|
34658
|
+
sha256: digestSchema,
|
|
34659
|
+
artifactPath: pathSchema.optional()
|
|
34660
|
+
});
|
|
34661
|
+
var templateSetSchema = external_exports.strictObject({
|
|
34662
|
+
templateSetVersion: external_exports.string().min(1),
|
|
34663
|
+
templates: external_exports.array(templateDescriptorSchema)
|
|
34664
|
+
});
|
|
34665
|
+
var planTaskSchema = external_exports.strictObject({
|
|
34666
|
+
checked: external_exports.boolean(),
|
|
34667
|
+
id: external_exports.string(),
|
|
34668
|
+
phaseId: external_exports.string(),
|
|
34669
|
+
ordinal: external_exports.number().int(),
|
|
34670
|
+
title: external_exports.string(),
|
|
34671
|
+
commit: commitSchema.nullable(),
|
|
34672
|
+
dependencies: stringArray,
|
|
34673
|
+
dependencyDeclared: external_exports.boolean(),
|
|
34674
|
+
manualVerification: external_exports.boolean(),
|
|
34675
|
+
line: external_exports.number().int()
|
|
34676
|
+
});
|
|
34677
|
+
var planPhaseSchema = external_exports.strictObject({
|
|
34678
|
+
number: external_exports.number().int(),
|
|
34679
|
+
id: external_exports.string(),
|
|
34680
|
+
title: external_exports.string(),
|
|
34681
|
+
dependencies: stringArray,
|
|
34682
|
+
dependencyDeclared: external_exports.boolean(),
|
|
34683
|
+
tasks: external_exports.array(planTaskSchema),
|
|
34684
|
+
completionCommit: commitSchema.nullable().optional(),
|
|
34685
|
+
line: external_exports.number().int(),
|
|
34686
|
+
trackVerification: external_exports.boolean()
|
|
34687
|
+
});
|
|
34688
|
+
var planGraphSchema = external_exports.strictObject({
|
|
34689
|
+
specRevision: external_exports.number().int().nullable(),
|
|
34690
|
+
planRevision: external_exports.number().int().nullable(),
|
|
34691
|
+
phases: external_exports.array(planPhaseSchema),
|
|
34692
|
+
digest: digestSchema
|
|
34693
|
+
});
|
|
34694
|
+
var graphValidationSchema = external_exports.strictObject({
|
|
34695
|
+
valid: external_exports.boolean(),
|
|
34696
|
+
graph: planGraphSchema,
|
|
34697
|
+
errors: stringArray
|
|
34698
|
+
});
|
|
34699
|
+
var executionNodeStatusSchema = external_exports.enum(EXECUTION_NODE_STATUSES);
|
|
34700
|
+
var checkpointEventSchema = external_exports.enum(EXECUTION_CHECKPOINT_EVENTS);
|
|
34701
|
+
var executionNodeSchema = external_exports.strictObject({
|
|
34702
|
+
id: external_exports.string(),
|
|
34703
|
+
kind: external_exports.enum(["phase", "task", "manual-verification"]),
|
|
34704
|
+
phaseId: external_exports.string(),
|
|
34705
|
+
dependencies: stringArray,
|
|
34706
|
+
status: executionNodeStatusSchema,
|
|
34707
|
+
workerId: external_exports.string().nullable(),
|
|
34708
|
+
workerHistory: stringArray.optional(),
|
|
34709
|
+
worktreePath: external_exports.string().nullable(),
|
|
34710
|
+
branch: external_exports.string().nullable(),
|
|
34711
|
+
workerCommit: commitSchema.nullable(),
|
|
34712
|
+
mergeCommit: commitSchema.nullable(),
|
|
34713
|
+
verification: external_exports.string().nullable(),
|
|
34714
|
+
approval: external_exports.string().nullable(),
|
|
34715
|
+
blocker: external_exports.string().nullable()
|
|
34716
|
+
});
|
|
34717
|
+
var eventGuidanceSchema = external_exports.record(external_exports.string(), external_exports.strictObject({
|
|
34718
|
+
currentStatus: executionNodeStatusSchema,
|
|
34719
|
+
allowed: external_exports.array(external_exports.strictObject({ event: checkpointEventSchema, requiredFields: stringArray }))
|
|
34720
|
+
}));
|
|
34721
|
+
var schedulerSchema = external_exports.strictObject({
|
|
34722
|
+
readyPhases: stringArray,
|
|
34723
|
+
readyTasks: stringArray,
|
|
34724
|
+
active: stringArray,
|
|
34725
|
+
blocked: stringArray,
|
|
34726
|
+
eventGuidance: eventGuidanceSchema
|
|
34727
|
+
});
|
|
34728
|
+
var transitionSchema = external_exports.strictObject({
|
|
34729
|
+
nodeId: external_exports.string(),
|
|
34730
|
+
event: checkpointEventSchema,
|
|
34731
|
+
from: executionNodeStatusSchema,
|
|
34732
|
+
through: external_exports.array(executionNodeStatusSchema),
|
|
34733
|
+
to: executionNodeStatusSchema,
|
|
34734
|
+
checkpoint: external_exports.string()
|
|
34735
|
+
});
|
|
34736
|
+
var actionableNodeSchema = external_exports.strictObject({
|
|
34737
|
+
id: external_exports.string(),
|
|
34738
|
+
kind: external_exports.enum(["phase", "task", "manual-verification"]),
|
|
34739
|
+
phaseId: external_exports.string(),
|
|
34740
|
+
status: executionNodeStatusSchema,
|
|
34741
|
+
dependencies: stringArray,
|
|
34742
|
+
workerId: external_exports.string().optional(),
|
|
34743
|
+
worktreePath: external_exports.string().optional(),
|
|
34744
|
+
branch: external_exports.string().optional(),
|
|
34745
|
+
blocker: external_exports.string().optional()
|
|
34746
|
+
});
|
|
34747
|
+
var executionStatusSchema = external_exports.strictObject({
|
|
34748
|
+
execution: external_exports.strictObject({
|
|
34749
|
+
executionId: external_exports.string(),
|
|
34750
|
+
trackId: external_exports.string(),
|
|
34751
|
+
status: external_exports.enum(["in_progress", "completed"]),
|
|
34752
|
+
checkpoint: external_exports.string(),
|
|
34753
|
+
requestedMode: external_exports.enum(["parallel", "sequential"]),
|
|
34754
|
+
effectiveMode: external_exports.enum(["parallel", "sequential"]),
|
|
34755
|
+
approvalMode: external_exports.enum(EXECUTION_APPROVAL_MODES),
|
|
34756
|
+
maxWorkers: external_exports.number().int(),
|
|
34757
|
+
planRevision: external_exports.number().int(),
|
|
34758
|
+
startedAt: external_exports.string(),
|
|
34759
|
+
completedAt: external_exports.string().nullable()
|
|
34760
|
+
}),
|
|
34761
|
+
counts: external_exports.partialRecord(executionNodeStatusSchema, external_exports.number().int()),
|
|
34762
|
+
actionableNodes: external_exports.array(actionableNodeSchema),
|
|
34763
|
+
node: executionNodeSchema.optional(),
|
|
34764
|
+
derivedStatus: schedulerSchema
|
|
34765
|
+
});
|
|
34766
|
+
var stagedCandidateSchema = external_exports.strictObject({
|
|
34767
|
+
trackId: external_exports.string(),
|
|
34768
|
+
candidateId: external_exports.string(),
|
|
34769
|
+
canonicalState: external_exports.enum(["absent", "active", "archived", "invalid"]),
|
|
34770
|
+
valid: external_exports.boolean(),
|
|
34771
|
+
files: external_exports.array(artifactSchema),
|
|
34772
|
+
errors: stringArray,
|
|
34773
|
+
nextAction: external_exports.string()
|
|
34774
|
+
});
|
|
34775
|
+
var projectTrackSummarySchema = external_exports.strictObject({
|
|
34776
|
+
id: external_exports.string(),
|
|
34777
|
+
title: external_exports.string(),
|
|
34778
|
+
status: external_exports.string(),
|
|
34779
|
+
checkpoint: external_exports.string().optional(),
|
|
34780
|
+
operation: external_exports.string().optional(),
|
|
34781
|
+
dependencies: stringArray.optional()
|
|
34782
|
+
});
|
|
34783
|
+
var trackSummarySchema = external_exports.strictObject({
|
|
34784
|
+
id: external_exports.string(),
|
|
34785
|
+
title: external_exports.string(),
|
|
34786
|
+
type: external_exports.string(),
|
|
34787
|
+
status: external_exports.string(),
|
|
34788
|
+
checkpoint: external_exports.string().nullable(),
|
|
34789
|
+
operation: external_exports.string().nullable(),
|
|
34790
|
+
dependencies: stringArray,
|
|
34791
|
+
revision: external_exports.number().int(),
|
|
34792
|
+
location: external_exports.string()
|
|
34793
|
+
});
|
|
34794
|
+
var worktreeRuntimeSchema = external_exports.strictObject({
|
|
34795
|
+
worktrees: external_exports.array(external_exports.strictObject({
|
|
34796
|
+
path: external_exports.string(),
|
|
34797
|
+
branch: external_exports.string().nullable(),
|
|
34798
|
+
head: commitSchema,
|
|
34799
|
+
managed: external_exports.boolean()
|
|
34800
|
+
})),
|
|
34801
|
+
orphanedDirectories: stringArray
|
|
34802
|
+
});
|
|
34803
|
+
var projectStatusProjectSchema = external_exports.strictObject({
|
|
34804
|
+
valid: external_exports.boolean(),
|
|
34805
|
+
derivedStateCurrent: external_exports.boolean(),
|
|
34806
|
+
project: external_exports.strictObject({
|
|
34807
|
+
name: external_exports.string().nullable(),
|
|
34808
|
+
context: external_exports.string().nullable(),
|
|
34809
|
+
runtimeVersion: external_exports.string().nullable(),
|
|
34810
|
+
templateSetVersion: external_exports.string().nullable(),
|
|
34811
|
+
setup: external_exports.strictObject({ status: external_exports.string().nullable(), checkpoint: external_exports.string().nullable() }).nullable(),
|
|
34812
|
+
lastRefresh: external_exports.unknown()
|
|
34813
|
+
}).nullable(),
|
|
34814
|
+
upgradeRequired: external_exports.boolean(),
|
|
34815
|
+
targetRuntimeVersion: external_exports.string(),
|
|
34816
|
+
targetTemplateSetVersion: external_exports.string(),
|
|
34817
|
+
counts: external_exports.record(external_exports.string(), external_exports.number().int()),
|
|
34818
|
+
tracks: external_exports.array(projectTrackSummarySchema),
|
|
34819
|
+
errors: stringArray,
|
|
34820
|
+
warnings: stringArray,
|
|
34821
|
+
stagedTrackCandidates: external_exports.array(stagedCandidateSchema),
|
|
34822
|
+
worktreeRuntime: worktreeRuntimeSchema.nullable()
|
|
34823
|
+
});
|
|
34824
|
+
var stagedTrackStatusSchema = external_exports.strictObject({
|
|
34825
|
+
kind: external_exports.literal("staged_track_candidate"),
|
|
34826
|
+
valid: external_exports.boolean(),
|
|
34827
|
+
derivedStateCurrent: external_exports.boolean(),
|
|
34828
|
+
upgradeRequired: external_exports.boolean(),
|
|
34829
|
+
targetRuntimeVersion: external_exports.string(),
|
|
34830
|
+
targetTemplateSetVersion: external_exports.string(),
|
|
34831
|
+
trackId: external_exports.string(),
|
|
34832
|
+
candidate: stagedCandidateSchema,
|
|
34833
|
+
errors: stringArray,
|
|
34834
|
+
focusedErrors: stringArray,
|
|
34835
|
+
warnings: stringArray,
|
|
34836
|
+
nextAction: external_exports.string()
|
|
34837
|
+
});
|
|
34838
|
+
var canonicalTrackStatusShape = {
|
|
34839
|
+
kind: external_exports.literal("canonical_track"),
|
|
34840
|
+
valid: external_exports.boolean(),
|
|
34841
|
+
derivedStateCurrent: external_exports.boolean(),
|
|
34842
|
+
upgradeRequired: external_exports.boolean(),
|
|
34843
|
+
targetRuntimeVersion: external_exports.string(),
|
|
34844
|
+
targetTemplateSetVersion: external_exports.string(),
|
|
34845
|
+
track: trackSummarySchema,
|
|
34846
|
+
state: jsonObjectSchema.nullable(),
|
|
34847
|
+
dependencies: external_exports.array(trackSummarySchema),
|
|
34848
|
+
errors: stringArray,
|
|
34849
|
+
focusedErrors: stringArray,
|
|
34850
|
+
stagedCandidate: stagedCandidateSchema.optional(),
|
|
34851
|
+
warnings: stringArray
|
|
34852
|
+
};
|
|
34853
|
+
var canonicalTrackStatusSchema = external_exports.strictObject(canonicalTrackStatusShape);
|
|
34854
|
+
var implementationStatusSchema = external_exports.strictObject({
|
|
34855
|
+
...canonicalTrackStatusShape,
|
|
34856
|
+
graph: external_exports.strictObject({ valid: external_exports.boolean(), graph: jsonObjectSchema, errors: stringArray }),
|
|
34857
|
+
execution: executionStatusSchema.nullable(),
|
|
34858
|
+
worktrees: worktreeRuntimeSchema.shape.worktrees,
|
|
34859
|
+
orphanedDirectories: stringArray
|
|
34860
|
+
});
|
|
34861
|
+
var validationSchema = external_exports.strictObject({
|
|
34862
|
+
valid: external_exports.boolean(),
|
|
34863
|
+
derivedStateCurrent: external_exports.boolean(),
|
|
34864
|
+
project: jsonObjectSchema.nullable(),
|
|
34865
|
+
tracks: external_exports.array(jsonObjectSchema),
|
|
34866
|
+
errors: stringArray,
|
|
34867
|
+
warnings: stringArray
|
|
34868
|
+
});
|
|
34869
|
+
var stagePrepareSchema = external_exports.strictObject({
|
|
34870
|
+
stagePath: pathSchema,
|
|
34871
|
+
gitignorePath: pathSchema,
|
|
34872
|
+
retainedFiles: stringArray,
|
|
34873
|
+
removedFiles: stringArray
|
|
34874
|
+
});
|
|
34875
|
+
var candidateInspectSchema = external_exports.strictObject({
|
|
34876
|
+
candidateId: external_exports.string(),
|
|
34877
|
+
files: external_exports.array(artifactSchema),
|
|
34878
|
+
plans: external_exports.array(external_exports.strictObject({
|
|
34879
|
+
path: pathSchema,
|
|
34880
|
+
targetStatus: external_exports.string(),
|
|
34881
|
+
valid: external_exports.boolean(),
|
|
34882
|
+
graph: planGraphSchema,
|
|
34883
|
+
errors: stringArray
|
|
34884
|
+
})),
|
|
34885
|
+
digest: digestSchema
|
|
34886
|
+
});
|
|
34887
|
+
var approvalBase = { commandStatus: external_exports.literal("approval_required"), proposalToken: proposalTokenSchema2 };
|
|
34888
|
+
var appliedReceiptBase = {
|
|
34889
|
+
commandStatus: external_exports.literal("applied"),
|
|
34890
|
+
digest: digestSchema,
|
|
34891
|
+
changedPaths: stringArray,
|
|
34892
|
+
changedCount: external_exports.number().int().nonnegative()
|
|
34893
|
+
};
|
|
34894
|
+
var reviewPrepareSchema = external_exports.strictObject({
|
|
34895
|
+
...approvalBase,
|
|
34896
|
+
digest: digestSchema,
|
|
34897
|
+
trackId: external_exports.string(),
|
|
34898
|
+
reviewedHead: commitSchema,
|
|
34899
|
+
commitRange: external_exports.string(),
|
|
34900
|
+
targetStatus: external_exports.string(),
|
|
34901
|
+
files: external_exports.array(artifactSchema)
|
|
34902
|
+
});
|
|
34903
|
+
var reviewAppliedSchema = external_exports.strictObject({
|
|
34904
|
+
...appliedReceiptBase,
|
|
34905
|
+
trackId: external_exports.string(),
|
|
34906
|
+
status: external_exports.string(),
|
|
34907
|
+
checkpoint: external_exports.string(),
|
|
34908
|
+
valid: external_exports.boolean(),
|
|
34909
|
+
derivedStateCurrent: external_exports.boolean()
|
|
34910
|
+
});
|
|
34911
|
+
var archiveMovePrepareSchema = external_exports.strictObject({
|
|
34912
|
+
trackId: external_exports.string(),
|
|
34913
|
+
sourcePath: pathSchema,
|
|
34914
|
+
targetPath: pathSchema,
|
|
34915
|
+
needsMove: external_exports.boolean()
|
|
34916
|
+
});
|
|
34917
|
+
var archivePrepareSchema = external_exports.strictObject({
|
|
34918
|
+
...approvalBase,
|
|
34919
|
+
digest: digestSchema,
|
|
34920
|
+
batchId: external_exports.string(),
|
|
34921
|
+
selectedTracks: stringArray,
|
|
34922
|
+
operationPath: pathSchema,
|
|
34923
|
+
checkpoint: external_exports.string(),
|
|
34924
|
+
resuming: external_exports.boolean(),
|
|
34925
|
+
moves: external_exports.array(archiveMovePrepareSchema),
|
|
34926
|
+
writes: external_exports.array(artifactSchema),
|
|
34927
|
+
tracks: artifactSchema
|
|
34928
|
+
});
|
|
34929
|
+
var archiveAppliedSchema = external_exports.strictObject({
|
|
34930
|
+
...appliedReceiptBase,
|
|
34931
|
+
batchId: external_exports.string(),
|
|
34932
|
+
selectedTracks: stringArray,
|
|
34933
|
+
operationPath: pathSchema,
|
|
34934
|
+
checkpoint: external_exports.string(),
|
|
34935
|
+
moves: external_exports.array(external_exports.strictObject({ trackId: external_exports.string(), targetPath: pathSchema })),
|
|
34936
|
+
valid: external_exports.boolean(),
|
|
34937
|
+
derivedStateCurrent: external_exports.boolean()
|
|
34938
|
+
});
|
|
34939
|
+
var archiveRecordSchema = external_exports.strictObject({
|
|
34940
|
+
...appliedReceiptBase,
|
|
34941
|
+
batchId: external_exports.string(),
|
|
34942
|
+
archiveCommit: commitSchema,
|
|
34943
|
+
checkpoint: external_exports.string(),
|
|
34944
|
+
valid: external_exports.boolean(),
|
|
34945
|
+
derivedStateCurrent: external_exports.boolean()
|
|
34946
|
+
});
|
|
34947
|
+
var executionStartOutputSchema = external_exports.strictObject({
|
|
34948
|
+
commandStatus: external_exports.literal("applied"),
|
|
34949
|
+
journalPath: pathSchema,
|
|
34950
|
+
statePath: pathSchema,
|
|
34951
|
+
execution: external_exports.strictObject({
|
|
34952
|
+
executionId: external_exports.string(),
|
|
34953
|
+
trackId: external_exports.string(),
|
|
34954
|
+
checkpoint: external_exports.string(),
|
|
34955
|
+
requestedMode: external_exports.enum(["parallel", "sequential"]),
|
|
34956
|
+
effectiveMode: external_exports.enum(["parallel", "sequential"]),
|
|
34957
|
+
approvalMode: external_exports.enum(EXECUTION_APPROVAL_MODES),
|
|
34958
|
+
maxWorkers: external_exports.number().int(),
|
|
34959
|
+
nodeCount: external_exports.number().int()
|
|
34960
|
+
}),
|
|
34961
|
+
derivedStatus: schedulerSchema
|
|
34962
|
+
});
|
|
34963
|
+
var checkpointOutputSchema = external_exports.strictObject({
|
|
34964
|
+
commandStatus: external_exports.literal("applied"),
|
|
34965
|
+
path: pathSchema,
|
|
34966
|
+
transition: transitionSchema,
|
|
34967
|
+
checkpoint: external_exports.string(),
|
|
34968
|
+
derivedStatus: schedulerSchema
|
|
34969
|
+
});
|
|
34970
|
+
var executionFinishOutputSchema = external_exports.strictObject({
|
|
34971
|
+
...appliedReceiptBase,
|
|
34972
|
+
executionId: external_exports.string(),
|
|
34973
|
+
status: external_exports.literal("completed"),
|
|
34974
|
+
checkpoint: external_exports.string(),
|
|
34975
|
+
headCommit: commitSchema
|
|
34976
|
+
});
|
|
34977
|
+
var worktreeCreateOutputSchema = external_exports.strictObject({
|
|
34978
|
+
commandStatus: external_exports.literal("applied"),
|
|
34979
|
+
projectRoot: pathSchema,
|
|
34980
|
+
path: pathSchema,
|
|
34981
|
+
relativePath: pathSchema,
|
|
34982
|
+
branch: external_exports.string(),
|
|
34983
|
+
baseCommit: commitSchema,
|
|
34984
|
+
existing: external_exports.boolean(),
|
|
34985
|
+
digest: digestSchema,
|
|
34986
|
+
transition: transitionSchema.nullable(),
|
|
34987
|
+
derivedStatus: schedulerSchema
|
|
34988
|
+
});
|
|
34989
|
+
var integrationPrepareSchema = external_exports.strictObject({
|
|
34990
|
+
...approvalBase,
|
|
34991
|
+
sourcePath: pathSchema,
|
|
34992
|
+
sourceBranch: external_exports.string(),
|
|
34993
|
+
sourceHead: commitSchema,
|
|
34994
|
+
targetPath: pathSchema,
|
|
34995
|
+
targetBranch: external_exports.string(),
|
|
34996
|
+
targetHead: commitSchema,
|
|
34997
|
+
changedFiles: stringArray,
|
|
34998
|
+
alreadyIntegrated: external_exports.boolean(),
|
|
34999
|
+
digest: digestSchema
|
|
35000
|
+
});
|
|
35001
|
+
var integrationAppliedSchema = external_exports.strictObject({
|
|
35002
|
+
commandStatus: external_exports.literal("applied"),
|
|
35003
|
+
status: external_exports.enum(["integrated", "conflicted"]),
|
|
35004
|
+
mergeCommit: commitSchema.nullable(),
|
|
35005
|
+
conflicts: stringArray,
|
|
35006
|
+
targetPath: pathSchema,
|
|
35007
|
+
transition: transitionSchema.optional(),
|
|
35008
|
+
derivedStatus: schedulerSchema.optional()
|
|
35009
|
+
});
|
|
35010
|
+
var cleanupOutputSchema = external_exports.strictObject({
|
|
35011
|
+
commandStatus: external_exports.literal("applied"),
|
|
35012
|
+
removedPath: pathSchema,
|
|
35013
|
+
removedBranch: external_exports.string(),
|
|
35014
|
+
transition: transitionSchema.nullable(),
|
|
35015
|
+
derivedStatus: schedulerSchema
|
|
35016
|
+
});
|
|
35017
|
+
var initPrepareSchema = external_exports.strictObject({
|
|
35018
|
+
...approvalBase,
|
|
35019
|
+
runtimeVersion: external_exports.string(),
|
|
35020
|
+
templateSetVersion: external_exports.string(),
|
|
35021
|
+
files: external_exports.array(artifactSchema),
|
|
35022
|
+
digest: digestSchema
|
|
35023
|
+
});
|
|
35024
|
+
var initAppliedSchema = external_exports.strictObject({
|
|
35025
|
+
...appliedReceiptBase,
|
|
35026
|
+
runtimeVersion: external_exports.string(),
|
|
35027
|
+
templateSetVersion: external_exports.string()
|
|
35028
|
+
});
|
|
35029
|
+
var setupCommitSchema = external_exports.strictObject({ path: pathSchema, commit: commitSchema });
|
|
35030
|
+
var setupGitSchema = external_exports.strictObject({ path: pathSchema, checkpoint: external_exports.literal("commit-pending") });
|
|
35031
|
+
var tracksRenderSchema = external_exports.strictObject({
|
|
35032
|
+
commandStatus: external_exports.literal("applied"),
|
|
35033
|
+
path: pathSchema,
|
|
35034
|
+
sha256: digestSchema,
|
|
35035
|
+
changed: external_exports.boolean(),
|
|
35036
|
+
writtenPath: pathSchema
|
|
35037
|
+
});
|
|
35038
|
+
var workflowOutcomeSchema = external_exports.strictObject({
|
|
35039
|
+
kind: external_exports.enum(["approval", "clarification"]),
|
|
35040
|
+
status: external_exports.enum(["approved", "changes_requested", "answered", "declined", "cancelled", "fallback_required"]),
|
|
35041
|
+
binding: external_exports.string().optional(),
|
|
35042
|
+
answers: external_exports.record(external_exports.string(), external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean(), stringArray])).optional(),
|
|
35043
|
+
fallback: external_exports.string().optional()
|
|
35044
|
+
});
|
|
35045
|
+
var CADRE_MCP_OUTPUT_SCHEMAS = {
|
|
35046
|
+
[CADRE_MCP_TOOLS.workflowElicit]: compatibleOutputSchema(workflowOutcomeSchema),
|
|
35047
|
+
[CADRE_MCP_TOOLS.templateGetMany]: compatibleOutputSchema(templateSetSchema),
|
|
35048
|
+
[CADRE_MCP_TOOLS.styleguideResolve]: compatibleOutputSchema(templateSetSchema),
|
|
35049
|
+
[CADRE_MCP_TOOLS.projectStatus]: compatibleOutputSchema(
|
|
35050
|
+
projectStatusProjectSchema,
|
|
35051
|
+
stagedTrackStatusSchema,
|
|
35052
|
+
canonicalTrackStatusSchema,
|
|
35053
|
+
implementationStatusSchema
|
|
35054
|
+
),
|
|
35055
|
+
[CADRE_MCP_TOOLS.stateValidate]: compatibleOutputSchema(validationSchema),
|
|
35056
|
+
[CADRE_MCP_TOOLS.candidateStagePrepare]: compatibleOutputSchema(stagePrepareSchema),
|
|
35057
|
+
[CADRE_MCP_TOOLS.candidateInspect]: compatibleOutputSchema(candidateInspectSchema),
|
|
35058
|
+
[CADRE_MCP_TOOLS.executionGraphValidate]: compatibleOutputSchema(graphValidationSchema),
|
|
35059
|
+
[CADRE_MCP_TOOLS.reviewComplete]: compatibleOutputSchema(reviewPrepareSchema, reviewAppliedSchema),
|
|
35060
|
+
[CADRE_MCP_TOOLS.archiveBatchCandidate]: compatibleOutputSchema(archivePrepareSchema, archiveAppliedSchema),
|
|
35061
|
+
[CADRE_MCP_TOOLS.archiveBatchRecord]: compatibleOutputSchema(archiveRecordSchema),
|
|
35062
|
+
[CADRE_MCP_TOOLS.executionStart]: compatibleOutputSchema(executionStartOutputSchema),
|
|
35063
|
+
[CADRE_MCP_TOOLS.executionCheckpoint]: compatibleOutputSchema(checkpointOutputSchema),
|
|
35064
|
+
[CADRE_MCP_TOOLS.executionStatus]: compatibleOutputSchema(executionStatusSchema),
|
|
35065
|
+
[CADRE_MCP_TOOLS.executionFinish]: compatibleOutputSchema(executionFinishOutputSchema),
|
|
35066
|
+
[CADRE_MCP_TOOLS.worktreeCreate]: compatibleOutputSchema(worktreeCreateOutputSchema),
|
|
35067
|
+
[CADRE_MCP_TOOLS.integration]: compatibleOutputSchema(integrationPrepareSchema, integrationAppliedSchema),
|
|
35068
|
+
[CADRE_MCP_TOOLS.worktreeCleanup]: compatibleOutputSchema(cleanupOutputSchema),
|
|
35069
|
+
[CADRE_MCP_TOOLS.projectInitCandidate]: compatibleOutputSchema(initPrepareSchema, initAppliedSchema),
|
|
35070
|
+
[CADRE_MCP_TOOLS.setupRecordCommit]: compatibleOutputSchema(setupCommitSchema),
|
|
35071
|
+
[CADRE_MCP_TOOLS.setupRecordGitInitialized]: compatibleOutputSchema(setupGitSchema),
|
|
35072
|
+
[CADRE_MCP_TOOLS.tracksRender]: compatibleOutputSchema(tracksRenderSchema)
|
|
35073
|
+
};
|
|
35074
|
+
|
|
35075
|
+
// src/mcp/results.ts
|
|
35076
|
+
function jsonContent(value) {
|
|
35077
|
+
return { type: "text", text: JSON.stringify(value) };
|
|
35078
|
+
}
|
|
35079
|
+
function result(value, summary = "Cadre operation completed.", leadingContent = []) {
|
|
34529
35080
|
return {
|
|
34530
|
-
content: [
|
|
35081
|
+
content: [
|
|
35082
|
+
...summary ? [{ type: "text", text: summary }] : [],
|
|
35083
|
+
...leadingContent,
|
|
35084
|
+
jsonContent(value)
|
|
35085
|
+
],
|
|
34531
35086
|
structuredContent: value
|
|
34532
35087
|
};
|
|
34533
35088
|
}
|
|
34534
|
-
function
|
|
35089
|
+
function failure(error51) {
|
|
35090
|
+
const serialized = serializeCadreError(error51);
|
|
35091
|
+
const value = { error: serialized };
|
|
34535
35092
|
return {
|
|
34536
|
-
|
|
34537
|
-
|
|
34538
|
-
text:
|
|
34539
|
-
|
|
34540
|
-
|
|
34541
|
-
|
|
34542
|
-
|
|
34543
|
-
|
|
34544
|
-
|
|
34545
|
-
|
|
34546
|
-
|
|
34547
|
-
|
|
34548
|
-
|
|
34549
|
-
|
|
34550
|
-
|
|
34551
|
-
|
|
34552
|
-
|
|
34553
|
-
|
|
35093
|
+
isError: true,
|
|
35094
|
+
content: [
|
|
35095
|
+
{ type: "text", text: serialized.message },
|
|
35096
|
+
jsonContent(value)
|
|
35097
|
+
],
|
|
35098
|
+
structuredContent: value
|
|
35099
|
+
};
|
|
35100
|
+
}
|
|
35101
|
+
function templateResult(templates, contentMode) {
|
|
35102
|
+
const leadingContent = contentMode === "text" ? templates.map((template) => ({
|
|
35103
|
+
type: "text",
|
|
35104
|
+
text: [
|
|
35105
|
+
`<cadre-template id=${JSON.stringify(template.id)} uri=${JSON.stringify(template.uri)} mimeType=${JSON.stringify(template.mimeType)}>`,
|
|
35106
|
+
template.content,
|
|
35107
|
+
"</cadre-template>"
|
|
35108
|
+
].join("\n")
|
|
35109
|
+
})) : templates.map((template) => ({
|
|
35110
|
+
type: "resource",
|
|
35111
|
+
resource: {
|
|
35112
|
+
uri: template.uri,
|
|
35113
|
+
mimeType: template.mimeType,
|
|
35114
|
+
text: template.content
|
|
34554
35115
|
}
|
|
35116
|
+
}));
|
|
35117
|
+
const value = {
|
|
35118
|
+
templateSetVersion: TEMPLATE_SET_VERSION,
|
|
35119
|
+
templates: templates.map(({ content: _content, ...descriptor }) => descriptor)
|
|
34555
35120
|
};
|
|
35121
|
+
return result(value, "", leadingContent);
|
|
34556
35122
|
}
|
|
35123
|
+
|
|
35124
|
+
// src/mcp/server.ts
|
|
34557
35125
|
function sha256(content) {
|
|
34558
35126
|
return createHash8("sha256").update(content).digest("hex");
|
|
34559
35127
|
}
|
|
34560
35128
|
function artifact(path, content) {
|
|
34561
35129
|
return { path, sha256: sha256(content) };
|
|
34562
35130
|
}
|
|
35131
|
+
function candidateManifest(files) {
|
|
35132
|
+
return files.map((file2) => artifact(file2.path, file2.content)).sort((left, right) => left.path.localeCompare(right.path));
|
|
35133
|
+
}
|
|
34563
35134
|
function jsonArtifact(path, value) {
|
|
34564
35135
|
return artifact(path, `${JSON.stringify(value, null, 2)}
|
|
34565
35136
|
`);
|
|
@@ -34582,17 +35153,13 @@ function requireCurrentProject2(projectRoot) {
|
|
|
34582
35153
|
}
|
|
34583
35154
|
return root;
|
|
34584
35155
|
}
|
|
34585
|
-
var adaptiveModeSchema = external_exports.enum(["prepare", "apply"]);
|
|
34586
35156
|
function adaptiveInputSchema(prepare) {
|
|
34587
|
-
|
|
34588
|
-
|
|
34589
|
-
|
|
34590
|
-
|
|
34591
|
-
|
|
34592
|
-
|
|
34593
|
-
proposalToken: proposalTokenSchema.optional(),
|
|
34594
|
-
...optionalPrepare
|
|
34595
|
-
}).strict();
|
|
35157
|
+
return {
|
|
35158
|
+
request: external_exports.discriminatedUnion("mode", [
|
|
35159
|
+
external_exports.strictObject({ mode: external_exports.literal("prepare"), ...prepare }),
|
|
35160
|
+
external_exports.strictObject({ mode: external_exports.literal("apply"), proposalToken: proposalTokenSchema })
|
|
35161
|
+
])
|
|
35162
|
+
};
|
|
34596
35163
|
}
|
|
34597
35164
|
function normalizeAdaptiveInput(input, requiredPrepareFields, command) {
|
|
34598
35165
|
const prepareFields = Object.keys(input).filter((key) => key !== "mode" && key !== "proposalToken");
|
|
@@ -34608,17 +35175,6 @@ function normalizeAdaptiveInput(input, requiredPrepareFields, command) {
|
|
|
34608
35175
|
const { mode: _mode, proposalToken: _proposalToken, ...request } = input;
|
|
34609
35176
|
return { mode: "prepare", request };
|
|
34610
35177
|
}
|
|
34611
|
-
function failure(error51) {
|
|
34612
|
-
const serialized = serializeCadreError(error51);
|
|
34613
|
-
return {
|
|
34614
|
-
isError: true,
|
|
34615
|
-
content: [{
|
|
34616
|
-
type: "text",
|
|
34617
|
-
text: serialized.message
|
|
34618
|
-
}],
|
|
34619
|
-
structuredContent: { error: serialized }
|
|
34620
|
-
};
|
|
34621
|
-
}
|
|
34622
35178
|
function serializableValidation(validation) {
|
|
34623
35179
|
return {
|
|
34624
35180
|
valid: validation.errors.length === 0,
|
|
@@ -34680,6 +35236,48 @@ function projectStatusView(validation) {
|
|
|
34680
35236
|
warnings: validation.warnings
|
|
34681
35237
|
};
|
|
34682
35238
|
}
|
|
35239
|
+
function focusedValidationErrors(validation, root, trackIds) {
|
|
35240
|
+
const markers = trackIds.flatMap((id) => [
|
|
35241
|
+
`${id}:`,
|
|
35242
|
+
join10(root, ".cadre", "tracks", id),
|
|
35243
|
+
join10(root, ".cadre", "archive", id),
|
|
35244
|
+
`/${id}/`
|
|
35245
|
+
]);
|
|
35246
|
+
return validation.errors.filter((error51) => markers.some((marker) => error51.includes(marker)));
|
|
35247
|
+
}
|
|
35248
|
+
function stagedTrackCandidates(root, validation) {
|
|
35249
|
+
const stageRoot = join10(root, ".cadre", "stage");
|
|
35250
|
+
if (!existsSync12(stageRoot)) return [];
|
|
35251
|
+
return readdirSync10(stageRoot, { withFileTypes: true }).filter((entry) => entry.name.startsWith("track-") && entry.name.length > "track-".length).map((entry) => {
|
|
35252
|
+
const candidateId = entry.name;
|
|
35253
|
+
const trackId = candidateId.slice("track-".length);
|
|
35254
|
+
const canonical = validation.tracks.find((track) => track.id === trackId);
|
|
35255
|
+
const canonicalState = canonical?.location.startsWith("archive/") ? "archived" : canonical ? "active" : [join10(root, ".cadre", "tracks", trackId), join10(root, ".cadre", "archive", trackId)].some((path) => existsSync12(path)) ? "invalid" : "absent";
|
|
35256
|
+
try {
|
|
35257
|
+
const paths = listCandidatePaths(root, candidateId);
|
|
35258
|
+
const files = candidateManifest(readCandidateFiles(root, candidateId, paths));
|
|
35259
|
+
return {
|
|
35260
|
+
trackId,
|
|
35261
|
+
candidateId,
|
|
35262
|
+
canonicalState,
|
|
35263
|
+
valid: true,
|
|
35264
|
+
files,
|
|
35265
|
+
errors: [],
|
|
35266
|
+
nextAction: canonicalState === "absent" ? "Resume the unapproved proposal with the track workflow and candidate_inspect." : "Reconcile the matching canonical operation, then remove the stage only after approved hashes and provenance are recorded."
|
|
35267
|
+
};
|
|
35268
|
+
} catch (error51) {
|
|
35269
|
+
return {
|
|
35270
|
+
trackId,
|
|
35271
|
+
candidateId,
|
|
35272
|
+
canonicalState,
|
|
35273
|
+
valid: false,
|
|
35274
|
+
files: [],
|
|
35275
|
+
errors: [serializeCadreError(error51).message],
|
|
35276
|
+
nextAction: "Repair or remove the unsafe staged candidate before resuming it."
|
|
35277
|
+
};
|
|
35278
|
+
}
|
|
35279
|
+
}).sort((left, right) => left.trackId.localeCompare(right.trackId));
|
|
35280
|
+
}
|
|
34683
35281
|
var PLAN_VALIDATION_STATUSES = [
|
|
34684
35282
|
"drafting-spec",
|
|
34685
35283
|
"drafting-plan",
|
|
@@ -34732,14 +35330,16 @@ function createCadreServer() {
|
|
|
34732
35330
|
"Use workflow_elicit for concise approval or clarification forms when supported. When active task context reports a non-interactive approval policy such as Codex Full Access, skip the form and ask one short chat question.",
|
|
34733
35331
|
"Use one adaptive command call when authorization already exists. A command returns approval_required with a proposal token only when a human decision is required; call that same command with the token only after approval.",
|
|
34734
35332
|
"Cadre state is resumable: inspect project_status once at command entry and reserve state_validate for final mutation gates.",
|
|
35333
|
+
"Every tool result ends with a compact JSON text block exactly mirroring structuredContent; use that block for all next-step fields when structured results are unavailable.",
|
|
34735
35334
|
"The plan is the implementation source of truth. Cadre MCP exposes only constrained, digest-gated Git worktree operations and never approves its own changes."
|
|
34736
35335
|
].join(" ")
|
|
34737
35336
|
}
|
|
34738
35337
|
);
|
|
34739
35338
|
server.registerTool(CADRE_MCP_TOOLS.workflowElicit, {
|
|
34740
35339
|
title: "Collect Cadre workflow input",
|
|
34741
|
-
description: "
|
|
35340
|
+
description: "Request a decision.",
|
|
34742
35341
|
inputSchema: workflowElicitationInputSchema,
|
|
35342
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.workflowElicit],
|
|
34743
35343
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34744
35344
|
}, async (input) => {
|
|
34745
35345
|
let request;
|
|
@@ -34771,11 +35371,12 @@ function createCadreServer() {
|
|
|
34771
35371
|
}
|
|
34772
35372
|
server.registerTool(CADRE_MCP_TOOLS.templateGetMany, {
|
|
34773
35373
|
title: "Get multiple Cadre templates",
|
|
34774
|
-
description: "Read
|
|
35374
|
+
description: "Read templates.",
|
|
34775
35375
|
inputSchema: {
|
|
34776
35376
|
ids: external_exports.array(external_exports.enum(TEMPLATE_IDS)).min(1),
|
|
34777
35377
|
contentMode: external_exports.enum(["embedded_resource", "text"]).optional().default("embedded_resource")
|
|
34778
35378
|
},
|
|
35379
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.templateGetMany],
|
|
34779
35380
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34780
35381
|
}, async ({ ids, contentMode }) => {
|
|
34781
35382
|
try {
|
|
@@ -34786,8 +35387,9 @@ function createCadreServer() {
|
|
|
34786
35387
|
});
|
|
34787
35388
|
server.registerTool(CADRE_MCP_TOOLS.styleguideResolve, {
|
|
34788
35389
|
title: "Resolve default styleguides",
|
|
34789
|
-
description: "Resolve
|
|
35390
|
+
description: "Resolve styleguides.",
|
|
34790
35391
|
inputSchema: { technologies: external_exports.array(external_exports.string()).min(1) },
|
|
35392
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.styleguideResolve],
|
|
34791
35393
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34792
35394
|
}, async ({ technologies }) => {
|
|
34793
35395
|
try {
|
|
@@ -34804,13 +35406,14 @@ function createCadreServer() {
|
|
|
34804
35406
|
});
|
|
34805
35407
|
server.registerTool(CADRE_MCP_TOOLS.projectStatus, {
|
|
34806
35408
|
title: "Read Cadre project status",
|
|
34807
|
-
description: "Read
|
|
35409
|
+
description: "Read project status.",
|
|
34808
35410
|
inputSchema: {
|
|
34809
35411
|
projectRoot: external_exports.string().min(1),
|
|
34810
35412
|
view: external_exports.enum(["project", "track", "implementation"]).optional().default("project"),
|
|
34811
35413
|
trackId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).optional(),
|
|
34812
35414
|
executionId: external_exports.string().regex(/^[0-9A-Za-z]+(?:-[0-9A-Za-z]+)*$/).optional()
|
|
34813
35415
|
},
|
|
35416
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.projectStatus],
|
|
34814
35417
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34815
35418
|
}, async ({ projectRoot, view, trackId, executionId }) => {
|
|
34816
35419
|
try {
|
|
@@ -34824,15 +35427,55 @@ function createCadreServer() {
|
|
|
34824
35427
|
worktreeRuntime = null;
|
|
34825
35428
|
}
|
|
34826
35429
|
return result(
|
|
34827
|
-
{ ...projectStatusView(validation), worktreeRuntime },
|
|
35430
|
+
{ ...projectStatusView(validation), stagedTrackCandidates: stagedTrackCandidates(root, validation), worktreeRuntime },
|
|
34828
35431
|
`Cadre project ${validation.errors.length ? "has validation errors" : "is valid"}; ${validation.tracks.length} track${validation.tracks.length === 1 ? "" : "s"}.`
|
|
34829
35432
|
);
|
|
34830
35433
|
}
|
|
34831
35434
|
if (!trackId) throw new Error(`${view} project_status requires trackId`);
|
|
34832
35435
|
const track = validation.tracks.find((candidate) => candidate.id === trackId);
|
|
34833
|
-
|
|
35436
|
+
const stagedCandidate = stagedTrackCandidates(root, validation).find((candidate) => candidate.trackId === trackId);
|
|
35437
|
+
if (!track) {
|
|
35438
|
+
const canonicalPaths = [
|
|
35439
|
+
join10(root, ".cadre", "tracks", trackId),
|
|
35440
|
+
join10(root, ".cadre", "archive", trackId)
|
|
35441
|
+
];
|
|
35442
|
+
if (canonicalPaths.some((path) => existsSync12(path))) {
|
|
35443
|
+
throw new CadreError(
|
|
35444
|
+
"TRACK_STATE_INVALID",
|
|
35445
|
+
`Cadre track ${trackId} has a canonical directory but its state is invalid or unreadable.`,
|
|
35446
|
+
{
|
|
35447
|
+
trackId,
|
|
35448
|
+
errors: validation.errors.filter((error51) => error51.includes(trackId))
|
|
35449
|
+
}
|
|
35450
|
+
);
|
|
35451
|
+
}
|
|
35452
|
+
const candidateId = `track-${trackId}`;
|
|
35453
|
+
if (!stagedCandidate) throw new Error(`unknown Cadre track ${trackId}`);
|
|
35454
|
+
if (view === "implementation") {
|
|
35455
|
+
throw new CadreError(
|
|
35456
|
+
"TRACK_CANDIDATE_ONLY",
|
|
35457
|
+
`Cadre track ${trackId} has a staged candidate but no canonical state; resume it with track status and candidate_inspect before implementation.`,
|
|
35458
|
+
{ trackId, candidateId }
|
|
35459
|
+
);
|
|
35460
|
+
}
|
|
35461
|
+
return result({
|
|
35462
|
+
kind: "staged_track_candidate",
|
|
35463
|
+
valid: validation.errors.length === 0 && stagedCandidate.valid,
|
|
35464
|
+
derivedStateCurrent: validation.warnings.length === 0,
|
|
35465
|
+
upgradeRequired: validation.project?.runtimeVersion !== CADRE_RUNTIME_VERSION || validation.project?.templateSetVersion !== TEMPLATE_SET_VERSION,
|
|
35466
|
+
targetRuntimeVersion: CADRE_RUNTIME_VERSION,
|
|
35467
|
+
targetTemplateSetVersion: TEMPLATE_SET_VERSION,
|
|
35468
|
+
trackId,
|
|
35469
|
+
candidate: stagedCandidate,
|
|
35470
|
+
errors: [...validation.errors, ...stagedCandidate.errors],
|
|
35471
|
+
focusedErrors: [...focusedValidationErrors(validation, root, [trackId]), ...stagedCandidate.errors],
|
|
35472
|
+
warnings: validation.warnings,
|
|
35473
|
+
nextAction: "Resume the track proposal with candidate_inspect; do not create canonical state before approval."
|
|
35474
|
+
}, `${trackId}: staged track candidate awaiting inspection or approval.`);
|
|
35475
|
+
}
|
|
34834
35476
|
const dependencies = (track.dependencies ?? []).map((id) => validation.tracks.find((candidate) => candidate.id === id)).filter((candidate) => Boolean(candidate)).map(trackSummary);
|
|
34835
35477
|
const focused = {
|
|
35478
|
+
kind: "canonical_track",
|
|
34836
35479
|
valid: validation.errors.length === 0,
|
|
34837
35480
|
derivedStateCurrent: validation.warnings.length === 0,
|
|
34838
35481
|
upgradeRequired: validation.project?.runtimeVersion !== CADRE_RUNTIME_VERSION || validation.project?.templateSetVersion !== TEMPLATE_SET_VERSION,
|
|
@@ -34841,7 +35484,9 @@ function createCadreServer() {
|
|
|
34841
35484
|
track: trackSummary(track),
|
|
34842
35485
|
state: validation.states.get(trackId) ?? null,
|
|
34843
35486
|
dependencies,
|
|
34844
|
-
errors: validation.errors
|
|
35487
|
+
errors: validation.errors,
|
|
35488
|
+
focusedErrors: focusedValidationErrors(validation, root, [trackId, ...dependencies.map((dependency) => dependency.id)]),
|
|
35489
|
+
...stagedCandidate ? { stagedCandidate } : {},
|
|
34845
35490
|
warnings: validation.warnings
|
|
34846
35491
|
};
|
|
34847
35492
|
if (view === "track") {
|
|
@@ -34868,8 +35513,9 @@ function createCadreServer() {
|
|
|
34868
35513
|
});
|
|
34869
35514
|
server.registerTool(CADRE_MCP_TOOLS.stateValidate, {
|
|
34870
35515
|
title: "Validate Cadre project state",
|
|
34871
|
-
description: "Validate
|
|
35516
|
+
description: "Validate state.",
|
|
34872
35517
|
inputSchema: { projectRoot: external_exports.string().min(1) },
|
|
35518
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.stateValidate],
|
|
34873
35519
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34874
35520
|
}, async ({ projectRoot }) => {
|
|
34875
35521
|
try {
|
|
@@ -34880,34 +35526,43 @@ function createCadreServer() {
|
|
|
34880
35526
|
});
|
|
34881
35527
|
server.registerTool(CADRE_MCP_TOOLS.candidateStagePrepare, {
|
|
34882
35528
|
title: "Prepare a Cadre candidate stage",
|
|
34883
|
-
description: "
|
|
35529
|
+
description: "Prepare staging.",
|
|
34884
35530
|
inputSchema: {
|
|
34885
35531
|
projectRoot: external_exports.string().min(1),
|
|
34886
|
-
candidateId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)
|
|
35532
|
+
candidateId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
35533
|
+
expectedFiles: external_exports.array(external_exports.string().min(1)).min(1).optional()
|
|
34887
35534
|
},
|
|
34888
|
-
|
|
34889
|
-
|
|
35535
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.candidateStagePrepare],
|
|
35536
|
+
annotations: { destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
35537
|
+
}, async ({ projectRoot, candidateId, expectedFiles }) => {
|
|
34890
35538
|
try {
|
|
34891
|
-
return result(
|
|
35539
|
+
return result(
|
|
35540
|
+
prepareCandidateStage(projectRoot, candidateId, expectedFiles),
|
|
35541
|
+
`Prepared Cadre candidate stage ${candidateId}.`
|
|
35542
|
+
);
|
|
34892
35543
|
} catch (error51) {
|
|
34893
35544
|
return failure(error51);
|
|
34894
35545
|
}
|
|
34895
35546
|
});
|
|
34896
35547
|
server.registerTool(CADRE_MCP_TOOLS.candidateInspect, {
|
|
34897
35548
|
title: "Inspect staged artifact candidates",
|
|
34898
|
-
description: "
|
|
34899
|
-
inputSchema: {
|
|
35549
|
+
description: "Inspect staging.",
|
|
35550
|
+
inputSchema: external_exports.strictObject({
|
|
34900
35551
|
projectRoot: external_exports.string().min(1),
|
|
34901
35552
|
candidateId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
34902
35553
|
files: external_exports.array(external_exports.string().min(1)).min(1),
|
|
34903
|
-
|
|
34904
|
-
|
|
35554
|
+
planValidations: external_exports.array(external_exports.object({
|
|
35555
|
+
path: external_exports.string().min(1),
|
|
35556
|
+
targetStatus: external_exports.enum(PLAN_VALIDATION_STATUSES)
|
|
35557
|
+
})).optional().default([])
|
|
35558
|
+
}),
|
|
35559
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.candidateInspect],
|
|
34905
35560
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34906
|
-
}, async ({ projectRoot, candidateId, files,
|
|
35561
|
+
}, async ({ projectRoot, candidateId, files, planValidations }) => {
|
|
34907
35562
|
try {
|
|
34908
35563
|
const root = safeProjectRoot(projectRoot);
|
|
34909
35564
|
const candidates = readCandidateFiles(root, candidateId, files);
|
|
34910
|
-
const manifest = candidates
|
|
35565
|
+
const manifest = candidateManifest(candidates);
|
|
34911
35566
|
const actualPaths = listCandidatePaths(root, candidateId);
|
|
34912
35567
|
const expectedPaths = manifest.map((file2) => file2.path);
|
|
34913
35568
|
if (JSON.stringify(actualPaths) !== JSON.stringify(expectedPaths)) {
|
|
@@ -34915,23 +35570,48 @@ function createCadreServer() {
|
|
|
34915
35570
|
`Candidate stage must contain exactly the declared files; expected ${expectedPaths.join(", ")}, found ${actualPaths.join(", ")}`
|
|
34916
35571
|
);
|
|
34917
35572
|
}
|
|
34918
|
-
|
|
34919
|
-
|
|
34920
|
-
|
|
34921
|
-
|
|
35573
|
+
const normalizedPlanValidations = planValidations.map((validation) => ({
|
|
35574
|
+
path: normalizeCandidatePath(validation.path),
|
|
35575
|
+
targetStatus: validation.targetStatus
|
|
35576
|
+
})).sort((left, right) => left.path.localeCompare(right.path));
|
|
35577
|
+
const validationPaths = normalizedPlanValidations.map((validation) => validation.path);
|
|
35578
|
+
if (new Set(validationPaths).size !== validationPaths.length) {
|
|
35579
|
+
throw new Error("Candidate planValidations contains duplicate paths");
|
|
35580
|
+
}
|
|
35581
|
+
for (const path of validationPaths) {
|
|
35582
|
+
if (path.split("/").at(-1) !== "plan.md") {
|
|
35583
|
+
throw new Error(`Candidate plan validation path must name plan.md: ${path}`);
|
|
35584
|
+
}
|
|
35585
|
+
if (!expectedPaths.includes(path)) {
|
|
35586
|
+
throw new Error(`Candidate plan validation path is not a declared staged file: ${path}`);
|
|
35587
|
+
}
|
|
35588
|
+
}
|
|
35589
|
+
const candidatePlanPaths = candidates.map((candidate) => candidate.path).filter((path) => path.split("/").at(-1) === "plan.md").sort();
|
|
35590
|
+
if (JSON.stringify(candidatePlanPaths) !== JSON.stringify(validationPaths)) {
|
|
35591
|
+
throw new Error(
|
|
35592
|
+
`Candidate planValidations must exactly match staged plan files; expected ${candidatePlanPaths.join(", ") || "none"}, found ${validationPaths.join(", ") || "none"}`
|
|
35593
|
+
);
|
|
35594
|
+
}
|
|
35595
|
+
const plans = normalizedPlanValidations.map((validation) => {
|
|
35596
|
+
const candidate = candidates.find((file2) => file2.path === validation.path);
|
|
34922
35597
|
if (Buffer.byteLength(candidate.content, "utf8") > MAX_DRAFT_PLAN_CHARACTERS) {
|
|
34923
|
-
throw new Error(`Candidate plan exceeds ${MAX_DRAFT_PLAN_CHARACTERS} bytes`);
|
|
35598
|
+
throw new Error(`Candidate plan exceeds ${MAX_DRAFT_PLAN_CHARACTERS} bytes: ${candidate.path}`);
|
|
34924
35599
|
}
|
|
34925
35600
|
const errors = [];
|
|
34926
35601
|
const graph = parsePlanContent(candidate.content, candidate.path, errors);
|
|
34927
|
-
validatePlanGraph(candidate.path, graph, targetStatus, errors);
|
|
34928
|
-
|
|
34929
|
-
}
|
|
35602
|
+
validatePlanGraph(candidate.path, graph, validation.targetStatus, errors);
|
|
35603
|
+
return { ...validation, valid: errors.length === 0, graph, errors };
|
|
35604
|
+
});
|
|
34930
35605
|
return result({
|
|
34931
35606
|
candidateId,
|
|
34932
35607
|
files: manifest,
|
|
34933
|
-
|
|
34934
|
-
|
|
35608
|
+
plans,
|
|
35609
|
+
digest: sha256(JSON.stringify({
|
|
35610
|
+
projectRoot: root,
|
|
35611
|
+
candidateId,
|
|
35612
|
+
files: manifest,
|
|
35613
|
+
planValidations: normalizedPlanValidations
|
|
35614
|
+
}))
|
|
34935
35615
|
}, `Inspected ${manifest.length} staged Cadre artifact${manifest.length === 1 ? "" : "s"}.`);
|
|
34936
35616
|
} catch (error51) {
|
|
34937
35617
|
return failure(error51);
|
|
@@ -34939,8 +35619,9 @@ function createCadreServer() {
|
|
|
34939
35619
|
});
|
|
34940
35620
|
server.registerTool(CADRE_MCP_TOOLS.executionGraphValidate, {
|
|
34941
35621
|
title: "Validate a track execution graph",
|
|
34942
|
-
description: "
|
|
35622
|
+
description: "Validate plan DAG.",
|
|
34943
35623
|
inputSchema: { projectRoot: external_exports.string().min(1), trackId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/) },
|
|
35624
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.executionGraphValidate],
|
|
34944
35625
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34945
35626
|
}, async ({ projectRoot, trackId }) => {
|
|
34946
35627
|
try {
|
|
@@ -34959,20 +35640,20 @@ function createCadreServer() {
|
|
|
34959
35640
|
const reviewCompleteSchema = {
|
|
34960
35641
|
projectRoot: external_exports.string().min(1),
|
|
34961
35642
|
trackId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
34962
|
-
commitRangeStart: external_exports.string().min(1),
|
|
34963
35643
|
approval: external_exports.string().min(1),
|
|
34964
35644
|
acceptedRisks: external_exports.array(external_exports.string().min(1)).optional()
|
|
34965
35645
|
};
|
|
34966
35646
|
server.registerTool(CADRE_MCP_TOOLS.reviewComplete, {
|
|
34967
35647
|
title: "Complete a clean review",
|
|
34968
|
-
description: "
|
|
35648
|
+
description: "Complete review.",
|
|
34969
35649
|
inputSchema: adaptiveInputSchema(reviewCompleteSchema),
|
|
34970
|
-
|
|
34971
|
-
|
|
35650
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.reviewComplete],
|
|
35651
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35652
|
+
}, async ({ request }) => {
|
|
34972
35653
|
try {
|
|
34973
35654
|
const adaptive = normalizeAdaptiveInput(
|
|
34974
|
-
|
|
34975
|
-
["projectRoot", "trackId", "
|
|
35655
|
+
request,
|
|
35656
|
+
["projectRoot", "trackId", "approval"],
|
|
34976
35657
|
"review_complete"
|
|
34977
35658
|
);
|
|
34978
35659
|
if (adaptive.mode === "apply") {
|
|
@@ -35025,13 +35706,14 @@ function createCadreServer() {
|
|
|
35025
35706
|
};
|
|
35026
35707
|
server.registerTool(CADRE_MCP_TOOLS.archiveBatchCandidate, {
|
|
35027
35708
|
title: "Govern a staged archive batch",
|
|
35028
|
-
description: "
|
|
35709
|
+
description: "Apply archive batch.",
|
|
35029
35710
|
inputSchema: adaptiveInputSchema(archiveBatchCandidateSchema),
|
|
35030
|
-
|
|
35031
|
-
|
|
35711
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.archiveBatchCandidate],
|
|
35712
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35713
|
+
}, async ({ request }) => {
|
|
35032
35714
|
try {
|
|
35033
35715
|
const adaptive = normalizeAdaptiveInput(
|
|
35034
|
-
|
|
35716
|
+
request,
|
|
35035
35717
|
["projectRoot", "candidateId", "updates"],
|
|
35036
35718
|
"archive_batch_candidate"
|
|
35037
35719
|
);
|
|
@@ -35079,15 +35761,16 @@ function createCadreServer() {
|
|
|
35079
35761
|
return failure(error51);
|
|
35080
35762
|
}
|
|
35081
35763
|
});
|
|
35082
|
-
const
|
|
35764
|
+
const archiveRecordSchema2 = {
|
|
35083
35765
|
projectRoot: external_exports.string().min(1),
|
|
35084
35766
|
batchId: external_exports.string().regex(/^archive-[0-9A-Za-z]+(?:-[0-9A-Za-z]+)*$/)
|
|
35085
35767
|
};
|
|
35086
35768
|
server.registerTool(CADRE_MCP_TOOLS.archiveBatchRecord, {
|
|
35087
35769
|
title: "Record archive provenance",
|
|
35088
|
-
description: "
|
|
35089
|
-
inputSchema:
|
|
35090
|
-
|
|
35770
|
+
description: "Record archive.",
|
|
35771
|
+
inputSchema: archiveRecordSchema2,
|
|
35772
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.archiveBatchRecord],
|
|
35773
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35091
35774
|
}, async (input) => {
|
|
35092
35775
|
try {
|
|
35093
35776
|
requireCurrentProject2(input.projectRoot);
|
|
@@ -35118,9 +35801,10 @@ function createCadreServer() {
|
|
|
35118
35801
|
};
|
|
35119
35802
|
server.registerTool(CADRE_MCP_TOOLS.executionStart, {
|
|
35120
35803
|
title: "Start implementation execution",
|
|
35121
|
-
description: "
|
|
35804
|
+
description: "Start execution.",
|
|
35122
35805
|
inputSchema: executionStartSchema,
|
|
35123
|
-
|
|
35806
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.executionStart],
|
|
35807
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35124
35808
|
}, async (input) => {
|
|
35125
35809
|
try {
|
|
35126
35810
|
requireCurrentProject2(input.projectRoot);
|
|
@@ -35152,34 +35836,67 @@ function createCadreServer() {
|
|
|
35152
35836
|
trackId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
35153
35837
|
executionId: external_exports.string().regex(/^[0-9A-Za-z]+(?:-[0-9A-Za-z]+)*$/)
|
|
35154
35838
|
};
|
|
35155
|
-
const
|
|
35839
|
+
const checkpointScopeSchema = {
|
|
35156
35840
|
...executionScopeSchema,
|
|
35157
|
-
nodeId: external_exports.string().regex(/^(?:P\d+|T\d+\.\d+)$/)
|
|
35158
|
-
event: external_exports.enum(EXECUTION_CHECKPOINT_EVENTS),
|
|
35159
|
-
workerId: external_exports.string().min(1).nullable().optional(),
|
|
35160
|
-
worktreePath: external_exports.string().min(1).nullable().optional(),
|
|
35161
|
-
branch: external_exports.string().min(1).nullable().optional(),
|
|
35162
|
-
commit: external_exports.string().regex(/^[0-9a-f]{7,40}$/).optional(),
|
|
35163
|
-
verification: external_exports.string().min(1).optional(),
|
|
35164
|
-
authorization: external_exports.string().min(1).optional(),
|
|
35165
|
-
blocker: external_exports.string().min(1).optional()
|
|
35841
|
+
nodeId: external_exports.string().regex(/^(?:P\d+|T\d+\.\d+)$/)
|
|
35166
35842
|
};
|
|
35843
|
+
const commitSchema2 = external_exports.string().regex(/^[0-9a-f]{7,40}$/);
|
|
35844
|
+
const evidenceSchema = external_exports.string().min(1);
|
|
35845
|
+
const executionCheckpointActionSchema = external_exports.discriminatedUnion("event", [
|
|
35846
|
+
external_exports.strictObject({
|
|
35847
|
+
event: external_exports.literal("start"),
|
|
35848
|
+
workerId: external_exports.string().min(1).nullable().optional(),
|
|
35849
|
+
worktreePath: external_exports.string().min(1).nullable().optional(),
|
|
35850
|
+
branch: external_exports.string().min(1).nullable().optional(),
|
|
35851
|
+
verification: evidenceSchema.optional()
|
|
35852
|
+
}),
|
|
35853
|
+
external_exports.strictObject({
|
|
35854
|
+
event: external_exports.literal("record_commit"),
|
|
35855
|
+
commit: commitSchema2,
|
|
35856
|
+
verification: evidenceSchema,
|
|
35857
|
+
authorization: evidenceSchema
|
|
35858
|
+
}),
|
|
35859
|
+
external_exports.strictObject({
|
|
35860
|
+
event: external_exports.literal("record_integration"),
|
|
35861
|
+
commit: commitSchema2,
|
|
35862
|
+
verification: evidenceSchema
|
|
35863
|
+
}),
|
|
35864
|
+
external_exports.strictObject({
|
|
35865
|
+
event: external_exports.literal("record_verification"),
|
|
35866
|
+
commit: commitSchema2,
|
|
35867
|
+
verification: evidenceSchema,
|
|
35868
|
+
authorization: evidenceSchema
|
|
35869
|
+
}),
|
|
35870
|
+
external_exports.strictObject({
|
|
35871
|
+
event: external_exports.literal("complete"),
|
|
35872
|
+
commit: commitSchema2.optional(),
|
|
35873
|
+
verification: evidenceSchema.optional(),
|
|
35874
|
+
authorization: evidenceSchema.optional()
|
|
35875
|
+
}),
|
|
35876
|
+
external_exports.strictObject({ event: external_exports.literal("block"), blocker: evidenceSchema }),
|
|
35877
|
+
external_exports.strictObject({ event: external_exports.literal("resume") })
|
|
35878
|
+
]);
|
|
35167
35879
|
server.registerTool(CADRE_MCP_TOOLS.executionCheckpoint, {
|
|
35168
35880
|
title: "Apply an execution checkpoint",
|
|
35169
|
-
description: "
|
|
35170
|
-
inputSchema:
|
|
35171
|
-
|
|
35172
|
-
|
|
35881
|
+
description: "Checkpoint execution.",
|
|
35882
|
+
inputSchema: {
|
|
35883
|
+
scope: external_exports.strictObject(checkpointScopeSchema),
|
|
35884
|
+
action: executionCheckpointActionSchema
|
|
35885
|
+
},
|
|
35886
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.executionCheckpoint],
|
|
35887
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35888
|
+
}, async ({ scope, action }) => {
|
|
35173
35889
|
try {
|
|
35174
|
-
requireCurrentProject2(
|
|
35175
|
-
const
|
|
35176
|
-
const
|
|
35890
|
+
requireCurrentProject2(scope.projectRoot);
|
|
35891
|
+
const checkpointInput = { ...scope, ...action };
|
|
35892
|
+
const preview = previewExecutionCheckpoint(checkpointInput);
|
|
35893
|
+
const applied = applyExecutionCheckpoint(checkpointInput, preview.digest, preview);
|
|
35177
35894
|
return result({
|
|
35178
35895
|
commandStatus: "applied",
|
|
35179
35896
|
path: applied.path,
|
|
35180
35897
|
transition: applied.transition,
|
|
35181
35898
|
checkpoint: applied.journal.checkpoint,
|
|
35182
|
-
derivedStatus: executionSchedulerView(applied.journal, [
|
|
35899
|
+
derivedStatus: executionSchedulerView(applied.journal, [checkpointInput.nodeId])
|
|
35183
35900
|
});
|
|
35184
35901
|
} catch (error51) {
|
|
35185
35902
|
return failure(error51);
|
|
@@ -35187,13 +35904,14 @@ function createCadreServer() {
|
|
|
35187
35904
|
});
|
|
35188
35905
|
server.registerTool(CADRE_MCP_TOOLS.executionStatus, {
|
|
35189
35906
|
title: "Read implementation execution status",
|
|
35190
|
-
description: "Read
|
|
35907
|
+
description: "Read execution.",
|
|
35191
35908
|
inputSchema: {
|
|
35192
35909
|
projectRoot: external_exports.string().min(1),
|
|
35193
35910
|
trackId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
35194
35911
|
executionId: external_exports.string().regex(/^[0-9A-Za-z]+(?:-[0-9A-Za-z]+)*$/),
|
|
35195
35912
|
nodeId: external_exports.string().regex(/^(?:P\d+|T\d+\.\d+)$/).optional()
|
|
35196
35913
|
},
|
|
35914
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.executionStatus],
|
|
35197
35915
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
35198
35916
|
}, async (input) => {
|
|
35199
35917
|
try {
|
|
@@ -35210,9 +35928,10 @@ function createCadreServer() {
|
|
|
35210
35928
|
};
|
|
35211
35929
|
server.registerTool(CADRE_MCP_TOOLS.executionFinish, {
|
|
35212
35930
|
title: "Complete implementation execution",
|
|
35213
|
-
description: "
|
|
35931
|
+
description: "Finish execution.",
|
|
35214
35932
|
inputSchema: executionFinishSchema,
|
|
35215
|
-
|
|
35933
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.executionFinish],
|
|
35934
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35216
35935
|
}, async (input) => {
|
|
35217
35936
|
try {
|
|
35218
35937
|
requireCurrentProject2(input.projectRoot);
|
|
@@ -35241,9 +35960,10 @@ function createCadreServer() {
|
|
|
35241
35960
|
};
|
|
35242
35961
|
server.registerTool(CADRE_MCP_TOOLS.worktreeCreate, {
|
|
35243
35962
|
title: "Create a Cadre worker worktree",
|
|
35244
|
-
description: "
|
|
35963
|
+
description: "Create worktree.",
|
|
35245
35964
|
inputSchema: worktreeSchema,
|
|
35246
|
-
|
|
35965
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.worktreeCreate],
|
|
35966
|
+
annotations: { destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
35247
35967
|
}, async (input) => {
|
|
35248
35968
|
try {
|
|
35249
35969
|
requireCurrentProject2(input.projectRoot);
|
|
@@ -35268,13 +35988,14 @@ function createCadreServer() {
|
|
|
35268
35988
|
});
|
|
35269
35989
|
server.registerTool(CADRE_MCP_TOOLS.integration, {
|
|
35270
35990
|
title: "Integrate a worker branch",
|
|
35271
|
-
description: "
|
|
35991
|
+
description: "Integrate branch.",
|
|
35272
35992
|
inputSchema: adaptiveInputSchema(worktreeSchema),
|
|
35273
|
-
|
|
35274
|
-
|
|
35993
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.integration],
|
|
35994
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35995
|
+
}, async ({ request }) => {
|
|
35275
35996
|
try {
|
|
35276
35997
|
const adaptive = normalizeAdaptiveInput(
|
|
35277
|
-
|
|
35998
|
+
request,
|
|
35278
35999
|
["projectRoot", "trackId", "executionId", "nodeId"],
|
|
35279
36000
|
"integration"
|
|
35280
36001
|
);
|
|
@@ -35304,9 +36025,10 @@ function createCadreServer() {
|
|
|
35304
36025
|
});
|
|
35305
36026
|
server.registerTool(CADRE_MCP_TOOLS.worktreeCleanup, {
|
|
35306
36027
|
title: "Clean up an integrated worker",
|
|
35307
|
-
description: "
|
|
36028
|
+
description: "Clean worktree.",
|
|
35308
36029
|
inputSchema: worktreeSchema,
|
|
35309
|
-
|
|
36030
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.worktreeCleanup],
|
|
36031
|
+
annotations: { destructiveHint: true, openWorldHint: false }
|
|
35310
36032
|
}, async (input) => {
|
|
35311
36033
|
try {
|
|
35312
36034
|
const cleanupInput = input;
|
|
@@ -35331,19 +36053,20 @@ function createCadreServer() {
|
|
|
35331
36053
|
context: external_exports.enum(["greenfield", "brownfield"]),
|
|
35332
36054
|
gitDisposition: external_exports.enum(["existing", "initialize"]),
|
|
35333
36055
|
baseCommit: external_exports.string().regex(/^[0-9a-f]{7,40}$/).nullable(),
|
|
35334
|
-
approvedAt: external_exports.
|
|
36056
|
+
approvedAt: external_exports.string().min(1),
|
|
35335
36057
|
stagedFiles: external_exports.array(external_exports.string().min(1)).min(3),
|
|
35336
36058
|
styleguideIds: external_exports.array(external_exports.string().min(1)).min(1)
|
|
35337
36059
|
};
|
|
35338
36060
|
server.registerTool(CADRE_MCP_TOOLS.projectInitCandidate, {
|
|
35339
36061
|
title: "Initialize from a staged Cadre candidate",
|
|
35340
|
-
description: "
|
|
36062
|
+
description: "Initialize project.",
|
|
35341
36063
|
inputSchema: adaptiveInputSchema(initCandidateSchema),
|
|
35342
|
-
|
|
35343
|
-
|
|
36064
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.projectInitCandidate],
|
|
36065
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
36066
|
+
}, async ({ request }) => {
|
|
35344
36067
|
try {
|
|
35345
36068
|
const adaptive = normalizeAdaptiveInput(
|
|
35346
|
-
|
|
36069
|
+
request,
|
|
35347
36070
|
[
|
|
35348
36071
|
"projectRoot",
|
|
35349
36072
|
"projectName",
|
|
@@ -35371,9 +36094,9 @@ function createCadreServer() {
|
|
|
35371
36094
|
digest: applied.digest
|
|
35372
36095
|
});
|
|
35373
36096
|
}
|
|
35374
|
-
const
|
|
35375
|
-
const preview = previewProjectInitCandidate(
|
|
35376
|
-
return proposalResult("project_init_candidate",
|
|
36097
|
+
const initRequest = adaptive.request;
|
|
36098
|
+
const preview = previewProjectInitCandidate(initRequest);
|
|
36099
|
+
return proposalResult("project_init_candidate", initRequest, {
|
|
35377
36100
|
runtimeVersion: preview.runtimeVersion,
|
|
35378
36101
|
templateSetVersion: preview.templateSetVersion,
|
|
35379
36102
|
files: preview.files.map(({ path, sha256: digest }) => ({ path, sha256: digest })),
|
|
@@ -35385,9 +36108,9 @@ function createCadreServer() {
|
|
|
35385
36108
|
});
|
|
35386
36109
|
server.registerTool(CADRE_MCP_TOOLS.setupRecordCommit, {
|
|
35387
36110
|
title: "Record the project setup commit",
|
|
35388
|
-
description: "Complete a pending create operation by recording its already-created Git commit SHA.",
|
|
35389
36111
|
inputSchema: { projectRoot: external_exports.string().min(1) },
|
|
35390
|
-
|
|
36112
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.setupRecordCommit],
|
|
36113
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35391
36114
|
}, async ({ projectRoot }) => {
|
|
35392
36115
|
try {
|
|
35393
36116
|
requireCurrentProject2(projectRoot);
|
|
@@ -35399,9 +36122,9 @@ function createCadreServer() {
|
|
|
35399
36122
|
});
|
|
35400
36123
|
server.registerTool(CADRE_MCP_TOOLS.setupRecordGitInitialized, {
|
|
35401
36124
|
title: "Record Git initialization checkpoint",
|
|
35402
|
-
description: "Advance an approved create operation after the caller verifies Git was initialized at the exact project root.",
|
|
35403
36125
|
inputSchema: { projectRoot: external_exports.string().min(1) },
|
|
35404
|
-
|
|
36126
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.setupRecordGitInitialized],
|
|
36127
|
+
annotations: { destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
35405
36128
|
}, async ({ projectRoot }) => {
|
|
35406
36129
|
try {
|
|
35407
36130
|
requireCurrentProject2(projectRoot);
|
|
@@ -35412,9 +36135,9 @@ function createCadreServer() {
|
|
|
35412
36135
|
});
|
|
35413
36136
|
server.registerTool(CADRE_MCP_TOOLS.tracksRender, {
|
|
35414
36137
|
title: "Render the derived tracks index",
|
|
35415
|
-
description: "Atomically validate and rewrite deterministic tracks.md from current track-local state.",
|
|
35416
36138
|
inputSchema: { projectRoot: external_exports.string().min(1) },
|
|
35417
|
-
|
|
36139
|
+
outputSchema: CADRE_MCP_OUTPUT_SCHEMAS[CADRE_MCP_TOOLS.tracksRender],
|
|
36140
|
+
annotations: { destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
35418
36141
|
}, async ({ projectRoot }) => {
|
|
35419
36142
|
try {
|
|
35420
36143
|
const input = { projectRoot: requireCurrentProject2(projectRoot) };
|