cadre-ai 3.4.0 → 3.5.1
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 +2 -2
- package/.codex-plugin/plugin.json +2 -2
- package/CHANGELOG.md +90 -0
- package/README.md +52 -20
- package/dist/cadre-cli.mjs +398 -92
- package/dist/cadre-mcp.mjs +455 -195
- package/package.json +3 -2
- 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.3.0"];
|
|
31000
|
+
var CADRE_RUNTIME_VERSION = "3.5.1";
|
|
31001
|
+
var LEGACY_RUNTIME_VERSIONS = ["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);
|
|
@@ -31838,15 +31842,6 @@ function executionStatus(projectRoot, trackId, executionId) {
|
|
|
31838
31842
|
const journal = readExecution(projectRoot, trackId, executionId);
|
|
31839
31843
|
return { journal, ...deriveExecutionStatus(journal) };
|
|
31840
31844
|
}
|
|
31841
|
-
var EXECUTION_CHECKPOINT_EVENTS = [
|
|
31842
|
-
"start",
|
|
31843
|
-
"record_commit",
|
|
31844
|
-
"record_integration",
|
|
31845
|
-
"record_verification",
|
|
31846
|
-
"complete",
|
|
31847
|
-
"block",
|
|
31848
|
-
"resume"
|
|
31849
|
-
];
|
|
31850
31845
|
function checkpointUpdates(journal, input) {
|
|
31851
31846
|
const node = journal.nodes[input.nodeId];
|
|
31852
31847
|
if (!node) throw new Error(`unknown execution node ${input.nodeId}`);
|
|
@@ -32011,6 +32006,21 @@ function applyExecutionCheckpoint(input, proposalDigest, preparedProposal) {
|
|
|
32011
32006
|
};
|
|
32012
32007
|
}
|
|
32013
32008
|
function deriveExecutionFinishInput(input) {
|
|
32009
|
+
const journal = readExecution(input.projectRoot, input.trackId, input.executionId);
|
|
32010
|
+
if (journal.status === "completed" && journal.headCommit && journal.completedAt) {
|
|
32011
|
+
return { ...input, headCommit: journal.headCommit, completedAt: journal.completedAt };
|
|
32012
|
+
}
|
|
32013
|
+
const { statePath } = executionPaths(input.projectRoot, input.trackId, input.executionId);
|
|
32014
|
+
const state = JSON.parse(readFileSync3(statePath, "utf8"));
|
|
32015
|
+
const priorHead = state.lastExecution?.headCommit;
|
|
32016
|
+
const priorCompletedAt = state.lastExecution?.completedAt;
|
|
32017
|
+
if (state.lastExecution?.executionId === input.executionId && typeof priorHead === "string" && typeof priorCompletedAt === "string") {
|
|
32018
|
+
return {
|
|
32019
|
+
...input,
|
|
32020
|
+
headCommit: priorHead,
|
|
32021
|
+
completedAt: priorCompletedAt
|
|
32022
|
+
};
|
|
32023
|
+
}
|
|
32014
32024
|
return {
|
|
32015
32025
|
...input,
|
|
32016
32026
|
headCommit: resolveGitCommit(input.projectRoot),
|
|
@@ -32049,7 +32059,8 @@ function previewExecutionFinish(input) {
|
|
|
32049
32059
|
const state = JSON.parse(stateBody);
|
|
32050
32060
|
const journal = JSON.parse(journalBody);
|
|
32051
32061
|
const operation = state.operation;
|
|
32052
|
-
|
|
32062
|
+
const stateAlreadyCompleted = state.status === "ready_for_review" && state.lastExecution?.executionId === input.executionId && state.lastExecution.headCommit === input.headCommit && state.lastExecution.completedAt === input.completedAt;
|
|
32063
|
+
if (!stateAlreadyCompleted && (operation?.action !== "implement" || operation.executionId !== input.executionId)) {
|
|
32053
32064
|
throw new Error("track does not point to this implementation execution");
|
|
32054
32065
|
}
|
|
32055
32066
|
if (!["in_progress", "completed"].includes(journal.status)) throw new Error("execution cannot be completed");
|
|
@@ -32093,7 +32104,7 @@ function previewExecutionFinish(input) {
|
|
|
32093
32104
|
completedAt: input.completedAt,
|
|
32094
32105
|
headCommit: input.headCommit
|
|
32095
32106
|
};
|
|
32096
|
-
const completedState = {
|
|
32107
|
+
const completedState = stateAlreadyCompleted ? state : {
|
|
32097
32108
|
...state,
|
|
32098
32109
|
status: "ready_for_review",
|
|
32099
32110
|
checkpoint: "ready_for_review",
|
|
@@ -32140,27 +32151,12 @@ function applyExecutionFinish(input, proposalDigest, preparedProposal) {
|
|
|
32140
32151
|
if (lstatSync(proposal.journalPath).isSymbolicLink() || lstatSync(proposal.statePath).isSymbolicLink() || lstatSync(proposal.planPath).isSymbolicLink() || lstatSync(proposal.tracksPath).isSymbolicLink()) {
|
|
32141
32152
|
throw new Error("refusing to complete execution through a symbolic link");
|
|
32142
32153
|
}
|
|
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
|
-
}
|
|
32154
|
+
writeTextAtomically(proposal.journalPath, `${JSON.stringify(proposal.journal, null, 2)}
|
|
32155
|
+
`);
|
|
32156
|
+
writeTextAtomically(proposal.statePath, `${JSON.stringify(proposal.state, null, 2)}
|
|
32157
|
+
`);
|
|
32158
|
+
writeTextAtomically(proposal.planPath, proposal.planContent);
|
|
32159
|
+
writeTextAtomically(proposal.tracksPath, proposal.tracksContent);
|
|
32164
32160
|
return proposal;
|
|
32165
32161
|
}
|
|
32166
32162
|
function validateExecutionJournal(trackRoot, state, graph, errors) {
|
|
@@ -32836,6 +32832,7 @@ import {
|
|
|
32836
32832
|
readFileSync as readFileSync5,
|
|
32837
32833
|
readdirSync as readdirSync4,
|
|
32838
32834
|
renameSync as renameSync2,
|
|
32835
|
+
rmdirSync,
|
|
32839
32836
|
unlinkSync as unlinkSync2,
|
|
32840
32837
|
writeFileSync as writeFileSync3
|
|
32841
32838
|
} from "node:fs";
|
|
@@ -32880,9 +32877,13 @@ function candidateStageRoot(projectRootInput, candidateIdInput) {
|
|
|
32880
32877
|
}
|
|
32881
32878
|
return join4(stageParent, candidateId);
|
|
32882
32879
|
}
|
|
32883
|
-
function prepareCandidateStage(projectRootInput, candidateIdInput) {
|
|
32880
|
+
function prepareCandidateStage(projectRootInput, candidateIdInput, expectedFiles) {
|
|
32884
32881
|
const projectRoot = safeProjectRoot(projectRootInput);
|
|
32885
32882
|
const candidateId = normalizeCandidateId(candidateIdInput);
|
|
32883
|
+
const normalizedExpected = expectedFiles?.map(normalizeCandidatePath);
|
|
32884
|
+
if (normalizedExpected && new Set(normalizedExpected).size !== normalizedExpected.length) {
|
|
32885
|
+
throw new Error("Candidate expectedFiles contains duplicate paths");
|
|
32886
|
+
}
|
|
32886
32887
|
const cadreRoot2 = join4(projectRoot, ".cadre");
|
|
32887
32888
|
if (existsSync6(cadreRoot2)) {
|
|
32888
32889
|
const stat = lstatSync3(cadreRoot2);
|
|
@@ -32912,7 +32913,24 @@ function prepareCandidateStage(projectRootInput, candidateIdInput) {
|
|
|
32912
32913
|
const stagePath = join4(cadreRoot2, "stage", candidateId);
|
|
32913
32914
|
mkdirSync2(stagePath, { recursive: true });
|
|
32914
32915
|
candidateStageRoot(projectRoot, candidateId);
|
|
32915
|
-
|
|
32916
|
+
const retainedFiles = listCandidatePaths(projectRoot, candidateId);
|
|
32917
|
+
if (normalizedExpected === void 0) return { stagePath, gitignorePath, retainedFiles, removedFiles: [] };
|
|
32918
|
+
const expected = new Set(normalizedExpected);
|
|
32919
|
+
const removedFiles = retainedFiles.filter((path) => !expected.has(path));
|
|
32920
|
+
for (const path of removedFiles) unlinkSync2(join4(stagePath, path));
|
|
32921
|
+
const pruneEmptyDirectories = (directory) => {
|
|
32922
|
+
for (const entry of readdirSync4(directory, { withFileTypes: true })) {
|
|
32923
|
+
if (entry.isDirectory()) pruneEmptyDirectories(join4(directory, entry.name));
|
|
32924
|
+
}
|
|
32925
|
+
if (directory !== stagePath && readdirSync4(directory).length === 0) rmdirSync(directory);
|
|
32926
|
+
};
|
|
32927
|
+
pruneEmptyDirectories(stagePath);
|
|
32928
|
+
return {
|
|
32929
|
+
stagePath,
|
|
32930
|
+
gitignorePath,
|
|
32931
|
+
retainedFiles: retainedFiles.filter((path) => expected.has(path)),
|
|
32932
|
+
removedFiles
|
|
32933
|
+
};
|
|
32916
32934
|
}
|
|
32917
32935
|
function assertRegularPath(root, target) {
|
|
32918
32936
|
const relation = relative2(root, target);
|
|
@@ -33282,18 +33300,39 @@ function loadProjectInitCandidate(input) {
|
|
|
33282
33300
|
return { ...input, files };
|
|
33283
33301
|
}
|
|
33284
33302
|
function previewProjectInitCandidate(input) {
|
|
33285
|
-
|
|
33286
|
-
|
|
33303
|
+
const proposal = buildProjectInitProposal(loadProjectInitCandidate(input));
|
|
33304
|
+
assertInitializationBootstrap(input.projectRoot, proposal);
|
|
33305
|
+
return proposal;
|
|
33287
33306
|
}
|
|
33288
|
-
function assertInitializationBootstrap(projectRootInput) {
|
|
33307
|
+
function assertInitializationBootstrap(projectRootInput, proposal) {
|
|
33289
33308
|
const root = safeProjectRoot(projectRootInput);
|
|
33290
33309
|
const cadreRoot2 = join6(root, ".cadre");
|
|
33291
33310
|
if (!existsSync8(cadreRoot2) || !lstatSync4(cadreRoot2).isDirectory() || lstatSync4(cadreRoot2).isSymbolicLink()) {
|
|
33292
33311
|
throw new Error(`${cadreRoot2} must be a prepared candidate-stage directory`);
|
|
33293
33312
|
}
|
|
33294
|
-
const
|
|
33295
|
-
|
|
33296
|
-
|
|
33313
|
+
const expected = new Map(proposal.files.map((file2) => [file2.path, file2.content]));
|
|
33314
|
+
const visit = (directory) => {
|
|
33315
|
+
for (const entry of readdirSync6(directory, { withFileTypes: true })) {
|
|
33316
|
+
const target = join6(directory, entry.name);
|
|
33317
|
+
const path = relative4(cadreRoot2, target).replaceAll("\\", "/");
|
|
33318
|
+
if (path === "stage" || path.startsWith("stage/")) continue;
|
|
33319
|
+
if (entry.isSymbolicLink()) throw new Error(`Refusing symbolic link inside initialization state: ${target}`);
|
|
33320
|
+
if (entry.isDirectory()) {
|
|
33321
|
+
visit(target);
|
|
33322
|
+
continue;
|
|
33323
|
+
}
|
|
33324
|
+
if (!entry.isFile()) throw new Error(`Unsupported initialization state entry: ${target}`);
|
|
33325
|
+
const content = expected.get(path);
|
|
33326
|
+
if (content === void 0) throw new Error(`${cadreRoot2} contains unexpected canonical state: ${path}`);
|
|
33327
|
+
if (readFileSync7(target, "utf8") !== content) {
|
|
33328
|
+
throw new Error(`Interrupted initialization disagrees at ${path}`);
|
|
33329
|
+
}
|
|
33330
|
+
}
|
|
33331
|
+
};
|
|
33332
|
+
visit(cadreRoot2);
|
|
33333
|
+
const canonicalEntries = readdirSync6(cadreRoot2).filter((entry) => ![".gitignore", "stage"].includes(entry));
|
|
33334
|
+
if (canonicalEntries.length && !canonicalEntries.some((entry) => proposal.files.some((file2) => file2.path === entry || file2.path.startsWith(`${entry}/`)))) {
|
|
33335
|
+
throw new Error(`${cadreRoot2} contains unrelated canonical project state`);
|
|
33297
33336
|
}
|
|
33298
33337
|
}
|
|
33299
33338
|
function targetWithin(root, relativePath) {
|
|
@@ -33394,7 +33433,7 @@ function recordGitInitialized(projectRootInput) {
|
|
|
33394
33433
|
|
|
33395
33434
|
// src/domain/worktrees.ts
|
|
33396
33435
|
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";
|
|
33436
|
+
import { existsSync as existsSync9, lstatSync as lstatSync5, readdirSync as readdirSync7, realpathSync as realpathSync2, rmdirSync as rmdirSync2 } from "node:fs";
|
|
33398
33437
|
import { dirname as dirname4, join as join7, relative as relative5, resolve as resolve9 } from "node:path";
|
|
33399
33438
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
33400
33439
|
var SHA2 = /^[0-9a-f]{7,40}$/;
|
|
@@ -33644,7 +33683,7 @@ function applyWorktreeCleanup(input, proposalDigest, preparedProposal) {
|
|
|
33644
33683
|
let directory = dirname4(proposal.path);
|
|
33645
33684
|
while (directory.startsWith(`${managedRoot}/`)) {
|
|
33646
33685
|
if (!existsSync9(directory) || readdirSync7(directory).length) break;
|
|
33647
|
-
|
|
33686
|
+
rmdirSync2(directory);
|
|
33648
33687
|
directory = dirname4(directory);
|
|
33649
33688
|
}
|
|
33650
33689
|
return { removedPath: proposal.path, removedBranch: proposal.branch };
|
|
@@ -33677,7 +33716,7 @@ function managedWorktreeStatus(projectRoot) {
|
|
|
33677
33716
|
}
|
|
33678
33717
|
|
|
33679
33718
|
// src/domain/governance.ts
|
|
33680
|
-
import { createHash as createHash7 } from "node:crypto";
|
|
33719
|
+
import { createHash as createHash7, randomUUID as randomUUID3 } from "node:crypto";
|
|
33681
33720
|
import {
|
|
33682
33721
|
existsSync as existsSync10,
|
|
33683
33722
|
lstatSync as lstatSync6,
|
|
@@ -33685,6 +33724,7 @@ import {
|
|
|
33685
33724
|
readFileSync as readFileSync8,
|
|
33686
33725
|
readdirSync as readdirSync8,
|
|
33687
33726
|
renameSync as renameSync4,
|
|
33727
|
+
unlinkSync as unlinkSync4,
|
|
33688
33728
|
writeFileSync as writeFileSync5
|
|
33689
33729
|
} from "node:fs";
|
|
33690
33730
|
import { dirname as dirname5, join as join8, relative as relative6 } from "node:path";
|
|
@@ -33709,7 +33749,14 @@ function assertWritableFile(path) {
|
|
|
33709
33749
|
function writeApprovedFile(path, content) {
|
|
33710
33750
|
assertWritableFile(path);
|
|
33711
33751
|
mkdirSync4(dirname5(path), { recursive: true });
|
|
33712
|
-
|
|
33752
|
+
if (existsSync10(path) && readFileSync8(path, "utf8") === content) return;
|
|
33753
|
+
const temporaryPath = join8(dirname5(path), `.${randomUUID3()}.cadre.tmp`);
|
|
33754
|
+
try {
|
|
33755
|
+
writeFileSync5(temporaryPath, content, { flag: "wx" });
|
|
33756
|
+
renameSync4(temporaryPath, path);
|
|
33757
|
+
} finally {
|
|
33758
|
+
if (existsSync10(temporaryPath)) unlinkSync4(temporaryPath);
|
|
33759
|
+
}
|
|
33713
33760
|
}
|
|
33714
33761
|
function requireCurrentProject(projectRoot) {
|
|
33715
33762
|
const validation = validateProject(projectRoot);
|
|
@@ -33721,19 +33768,27 @@ function deriveReviewCompleteInput(input) {
|
|
|
33721
33768
|
const validation = requireCurrentProject(input.projectRoot);
|
|
33722
33769
|
const state = validation.states.get(input.trackId);
|
|
33723
33770
|
const reviewedHead = state?.lastExecution?.headCommit;
|
|
33771
|
+
const executionId = state?.lastExecution?.executionId;
|
|
33724
33772
|
if (!reviewedHead || !SHA3.test(reviewedHead)) throw new Error(`${input.trackId} has no completed execution head`);
|
|
33773
|
+
if (!executionId) throw new Error(`${input.trackId} has no completed execution journal`);
|
|
33774
|
+
const execution = executionStatus(input.projectRoot, input.trackId, executionId).journal;
|
|
33775
|
+
if (execution.status !== "completed" || execution.headCommit !== reviewedHead || !SHA3.test(execution.baseCommit)) {
|
|
33776
|
+
throw new Error(`${input.trackId} completed execution evidence is inconsistent`);
|
|
33777
|
+
}
|
|
33725
33778
|
if (!isGitAncestor(input.projectRoot, reviewedHead)) {
|
|
33726
33779
|
throw new Error(`completed execution head ${reviewedHead} is not an ancestor of current HEAD`);
|
|
33727
33780
|
}
|
|
33728
|
-
const
|
|
33781
|
+
const acceptedRisks = (input.acceptedRisks ?? []).map((risk) => risk.trim()).filter(Boolean);
|
|
33782
|
+
const existingCycle = state.status === "completed" ? state.reviewCycles?.at(-1) : void 0;
|
|
33783
|
+
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
33784
|
return {
|
|
33730
33785
|
projectRoot: input.projectRoot,
|
|
33731
33786
|
trackId: input.trackId,
|
|
33732
|
-
reviewedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
33787
|
+
reviewedAt: typeof matchingCycle?.reviewedAt === "string" ? matchingCycle.reviewedAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
33733
33788
|
reviewedHead,
|
|
33734
|
-
commitRange: `${
|
|
33789
|
+
commitRange: `${execution.baseCommit}..${reviewedHead}`,
|
|
33735
33790
|
approval: input.approval,
|
|
33736
|
-
...
|
|
33791
|
+
...acceptedRisks.length ? { acceptedRisks } : {}
|
|
33737
33792
|
};
|
|
33738
33793
|
}
|
|
33739
33794
|
function previewReviewComplete(input) {
|
|
@@ -33750,9 +33805,7 @@ function previewReviewComplete(input) {
|
|
|
33750
33805
|
const track = validation.tracks.find((candidate) => candidate.id === input.trackId);
|
|
33751
33806
|
const current = validation.states.get(input.trackId);
|
|
33752
33807
|
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
|
-
}
|
|
33808
|
+
if (track.location !== `tracks/${input.trackId}`) throw new Error(`${input.trackId} is not an active track`);
|
|
33756
33809
|
if (current.operation != null) throw new Error(`${input.trackId} already has an active operation`);
|
|
33757
33810
|
const execution = current.lastExecution;
|
|
33758
33811
|
if (!execution?.executionId || !execution.planRevision || !execution.graphDigest || execution.headCommit !== input.reviewedHead) {
|
|
@@ -33764,7 +33817,7 @@ function previewReviewComplete(input) {
|
|
|
33764
33817
|
const tracksBody = readFileSync8(tracksPath, "utf8");
|
|
33765
33818
|
const acceptedRisks = (input.acceptedRisks ?? []).map((risk) => risk.trim()).filter(Boolean);
|
|
33766
33819
|
const cycle = {
|
|
33767
|
-
cycle: (current.reviewCycles?.length ?? 0) + 1,
|
|
33820
|
+
cycle: current.status === "completed" ? current.reviewCycles?.length ?? 0 : (current.reviewCycles?.length ?? 0) + 1,
|
|
33768
33821
|
reviewedAt: input.reviewedAt,
|
|
33769
33822
|
outcome: "clean",
|
|
33770
33823
|
executionId: execution.executionId,
|
|
@@ -33775,7 +33828,10 @@ function previewReviewComplete(input) {
|
|
|
33775
33828
|
approval: input.approval,
|
|
33776
33829
|
...acceptedRisks.length ? { acceptedRisks } : {}
|
|
33777
33830
|
};
|
|
33778
|
-
const
|
|
33831
|
+
const existingCycle = current.reviewCycles?.at(-1);
|
|
33832
|
+
const resuming = current.status === "completed" && JSON.stringify(existingCycle) === JSON.stringify(cycle);
|
|
33833
|
+
if (current.status !== "ready_for_review" && !resuming) throw new Error(`${input.trackId} is not ready for review`);
|
|
33834
|
+
const state = resuming ? current : {
|
|
33779
33835
|
...current,
|
|
33780
33836
|
status: "completed",
|
|
33781
33837
|
checkpoint: "completed",
|
|
@@ -33788,12 +33844,15 @@ function previewReviewComplete(input) {
|
|
|
33788
33844
|
state,
|
|
33789
33845
|
tracksPath,
|
|
33790
33846
|
tracksContent,
|
|
33791
|
-
digest: hash5({ stateBody, tracksBody, input, state, tracksContent })
|
|
33847
|
+
digest: hash5({ stateBody, tracksBody, input, state, tracksContent }),
|
|
33848
|
+
resuming
|
|
33792
33849
|
};
|
|
33793
33850
|
}
|
|
33794
33851
|
function applyReviewComplete(input, proposalDigest) {
|
|
33795
33852
|
const proposal = previewReviewComplete(input);
|
|
33796
|
-
if (proposal.digest !== proposalDigest
|
|
33853
|
+
if (proposal.digest !== proposalDigest && !proposal.resuming) {
|
|
33854
|
+
throw new Error("review completion proposal is stale; preview it again");
|
|
33855
|
+
}
|
|
33797
33856
|
writeApprovedFile(proposal.statePath, json2(proposal.state));
|
|
33798
33857
|
writeApprovedFile(proposal.tracksPath, proposal.tracksContent);
|
|
33799
33858
|
const validation = validateProject(input.projectRoot);
|
|
@@ -33945,7 +34004,11 @@ function previewMaterializedArchiveBatch(input) {
|
|
|
33945
34004
|
if (existingOperation && (existingOperation.action !== "archive" || existingOperation.status !== "in_progress" || existingOperation.baseCommit !== input.baseCommit || JSON.stringify(existingOperation.selectedTracks) !== JSON.stringify(input.selectedTracks))) {
|
|
33946
34005
|
throw new Error(`archive batch ${input.batchId} does not match the approved input`);
|
|
33947
34006
|
}
|
|
33948
|
-
const validation =
|
|
34007
|
+
const validation = validateProject(root);
|
|
34008
|
+
const recoverableErrors = existingOperation ? new Set(existingOperation.selectedTracks.map((trackId) => `${trackId}: status completed requires location tracks/${trackId}`)) : /* @__PURE__ */ new Set();
|
|
34009
|
+
const blockingErrors = validation.errors.filter((error51) => !recoverableErrors.has(error51));
|
|
34010
|
+
if (blockingErrors.length) throw new Error(blockingErrors.join("\n"));
|
|
34011
|
+
if (!validation.project) throw new Error("Cadre project state is unavailable");
|
|
33949
34012
|
const selected = new Set(input.selectedTracks);
|
|
33950
34013
|
const updates = input.updates.map((update) => ({ ...update, path: update.path.replaceAll("\\", "/") }));
|
|
33951
34014
|
if (new Set(updates.map((update) => update.path)).size !== updates.length) {
|
|
@@ -33975,8 +34038,8 @@ function previewMaterializedArchiveBatch(input) {
|
|
|
33975
34038
|
const state = validation.states.get(trackId);
|
|
33976
34039
|
if (!track || !state) throw new Error(`unknown selected track ${trackId}`);
|
|
33977
34040
|
const pending = track.status === "completed" && track.location === `tracks/${trackId}`;
|
|
33978
|
-
const
|
|
33979
|
-
if (!pending && !
|
|
34041
|
+
const partiallyPromoted = existingOperation != null && ["completed", "archived"].includes(track.status) && track.location === `archive/${trackId}`;
|
|
34042
|
+
if (!pending && !partiallyPromoted || state.operation != null) {
|
|
33980
34043
|
throw new Error(`${trackId} is not an eligible completed track`);
|
|
33981
34044
|
}
|
|
33982
34045
|
const sourcePath = join8(cadreRoot(root), pending ? "tracks" : "archive", trackId);
|
|
@@ -34036,7 +34099,12 @@ function previewMaterializedArchiveBatch(input) {
|
|
|
34036
34099
|
}
|
|
34037
34100
|
function applyMaterializedArchiveBatch(input, proposalDigest) {
|
|
34038
34101
|
const proposal = previewMaterializedArchiveBatch(input);
|
|
34039
|
-
if (proposal.digest !== proposalDigest)
|
|
34102
|
+
if (proposal.digest !== proposalDigest) {
|
|
34103
|
+
const existing = existsSync10(proposal.operationPath) ? JSON.parse(readFileSync8(proposal.operationPath, "utf8")) : null;
|
|
34104
|
+
if (!proposal.resuming || existing?.approvalDigest !== proposal.initialOperation.approvalDigest) {
|
|
34105
|
+
throw new Error("archive batch proposal is stale; preview it again");
|
|
34106
|
+
}
|
|
34107
|
+
}
|
|
34040
34108
|
const currentOperation = existsSync10(proposal.operationPath) ? JSON.parse(readFileSync8(proposal.operationPath, "utf8")) : proposal.initialOperation;
|
|
34041
34109
|
if (!existsSync10(proposal.operationPath)) writeApprovedFile(proposal.operationPath, json2(currentOperation));
|
|
34042
34110
|
mkdirSync4(join8(cadreRoot(input.projectRoot), "archive"), { recursive: true });
|
|
@@ -34080,8 +34148,8 @@ function previewArchiveBatchRecord(input) {
|
|
|
34080
34148
|
const operationPath = join8(cadreRoot(root), "operations", `${input.batchId}.json`);
|
|
34081
34149
|
const operationBody = readFileSync8(operationPath, "utf8");
|
|
34082
34150
|
const currentOperation = JSON.parse(operationBody);
|
|
34083
|
-
if (currentOperation.action !== "archive" || currentOperation.status
|
|
34084
|
-
throw new Error(`${input.batchId} is not
|
|
34151
|
+
if (currentOperation.action !== "archive" || !["in_progress", "completed"].includes(currentOperation.status) || currentOperation.status === "completed" && currentOperation.archiveCommit !== input.archiveCommit) {
|
|
34152
|
+
throw new Error(`${input.batchId} is not a matching archive batch`);
|
|
34085
34153
|
}
|
|
34086
34154
|
const projectPath = join8(cadreRoot(root), "project.json");
|
|
34087
34155
|
const projectBody = readFileSync8(projectPath, "utf8");
|
|
@@ -34091,13 +34159,21 @@ function previewArchiveBatchRecord(input) {
|
|
|
34091
34159
|
const body = readFileSync8(path, "utf8");
|
|
34092
34160
|
const current = JSON.parse(body);
|
|
34093
34161
|
if (current.status !== "archived") throw new Error(`${trackId} is not archived`);
|
|
34162
|
+
const existingCommit = current.commits?.archive;
|
|
34163
|
+
if (existingCommit && existingCommit !== input.archiveCommit) {
|
|
34164
|
+
throw new Error(`${trackId} archive commit differs from the current batch`);
|
|
34165
|
+
}
|
|
34166
|
+
const existingHistory = (Array.isArray(current.history) ? current.history : []).find((entry) => typeof entry === "object" && entry !== null && entry.action === "archive" && entry.batchId === input.batchId);
|
|
34167
|
+
if (existingHistory && existingHistory.commit !== input.archiveCommit) {
|
|
34168
|
+
throw new Error(`${trackId} archive history differs from the current batch`);
|
|
34169
|
+
}
|
|
34094
34170
|
return {
|
|
34095
34171
|
path,
|
|
34096
34172
|
body,
|
|
34097
34173
|
state: {
|
|
34098
34174
|
...current,
|
|
34099
34175
|
commits: { ...current.commits ?? {}, archive: input.archiveCommit },
|
|
34100
|
-
history: [...Array.isArray(current.history) ? current.history : [], {
|
|
34176
|
+
history: existingHistory ? current.history : [...Array.isArray(current.history) ? current.history : [], {
|
|
34101
34177
|
action: "archive",
|
|
34102
34178
|
batchId: input.batchId,
|
|
34103
34179
|
commit: input.archiveCommit
|
|
@@ -34105,9 +34181,13 @@ function previewArchiveBatchRecord(input) {
|
|
|
34105
34181
|
}
|
|
34106
34182
|
};
|
|
34107
34183
|
});
|
|
34184
|
+
const existingProjectHistory = (currentProject.history ?? []).find((entry) => typeof entry === "object" && entry !== null && entry.action === "archive" && entry.batchId === input.batchId);
|
|
34185
|
+
if (existingProjectHistory && existingProjectHistory.commit !== input.archiveCommit) {
|
|
34186
|
+
throw new Error(`project archive history differs for ${input.batchId}`);
|
|
34187
|
+
}
|
|
34108
34188
|
const project = {
|
|
34109
34189
|
...currentProject,
|
|
34110
|
-
history: [...currentProject.history ?? [], {
|
|
34190
|
+
history: existingProjectHistory ? currentProject.history ?? [] : [...currentProject.history ?? [], {
|
|
34111
34191
|
action: "archive",
|
|
34112
34192
|
batchId: input.batchId,
|
|
34113
34193
|
tracks: [...currentOperation.selectedTracks],
|
|
@@ -34317,7 +34397,7 @@ import {
|
|
|
34317
34397
|
openSync,
|
|
34318
34398
|
readFileSync as readFileSync9,
|
|
34319
34399
|
readdirSync as readdirSync9,
|
|
34320
|
-
unlinkSync as
|
|
34400
|
+
unlinkSync as unlinkSync5,
|
|
34321
34401
|
writeFileSync as writeFileSync6
|
|
34322
34402
|
} from "node:fs";
|
|
34323
34403
|
import { homedir as homedir2 } from "node:os";
|
|
@@ -34490,13 +34570,40 @@ var ProposalTokenStore = class {
|
|
|
34490
34570
|
}
|
|
34491
34571
|
unlinkRecord(path) {
|
|
34492
34572
|
try {
|
|
34493
|
-
|
|
34573
|
+
unlinkSync5(path);
|
|
34494
34574
|
} catch (error51) {
|
|
34495
34575
|
if (error51.code !== "ENOENT") throw error51;
|
|
34496
34576
|
}
|
|
34497
34577
|
}
|
|
34498
34578
|
};
|
|
34499
34579
|
|
|
34580
|
+
// src/mcp/tool-names.ts
|
|
34581
|
+
var CADRE_MCP_TOOLS = {
|
|
34582
|
+
workflowElicit: "workflow_elicit",
|
|
34583
|
+
templateGetMany: "template_get_many",
|
|
34584
|
+
styleguideResolve: "styleguide_resolve",
|
|
34585
|
+
projectStatus: "project_status",
|
|
34586
|
+
stateValidate: "state_validate",
|
|
34587
|
+
candidateStagePrepare: "candidate_stage_prepare",
|
|
34588
|
+
candidateInspect: "candidate_inspect",
|
|
34589
|
+
executionGraphValidate: "execution_graph_validate",
|
|
34590
|
+
reviewComplete: "review_complete",
|
|
34591
|
+
archiveBatchCandidate: "archive_batch_candidate",
|
|
34592
|
+
archiveBatchRecord: "archive_batch_record",
|
|
34593
|
+
executionStart: "execution_start",
|
|
34594
|
+
executionCheckpoint: "execution_checkpoint",
|
|
34595
|
+
executionStatus: "execution_status",
|
|
34596
|
+
executionFinish: "execution_finish",
|
|
34597
|
+
worktreeCreate: "worktree_create",
|
|
34598
|
+
integration: "integration",
|
|
34599
|
+
worktreeCleanup: "worktree_cleanup",
|
|
34600
|
+
projectInitCandidate: "project_init_candidate",
|
|
34601
|
+
setupRecordCommit: "setup_record_commit",
|
|
34602
|
+
setupRecordGitInitialized: "setup_record_git_initialized",
|
|
34603
|
+
tracksRender: "tracks_render"
|
|
34604
|
+
};
|
|
34605
|
+
var CADRE_MCP_TOOL_NAMES = Object.freeze(Object.values(CADRE_MCP_TOOLS));
|
|
34606
|
+
|
|
34500
34607
|
// src/mcp/server.ts
|
|
34501
34608
|
function result(value, summary = "Cadre operation completed.") {
|
|
34502
34609
|
return {
|
|
@@ -34504,9 +34611,16 @@ function result(value, summary = "Cadre operation completed.") {
|
|
|
34504
34611
|
structuredContent: value
|
|
34505
34612
|
};
|
|
34506
34613
|
}
|
|
34507
|
-
function templateResult(templates) {
|
|
34614
|
+
function templateResult(templates, contentMode) {
|
|
34508
34615
|
return {
|
|
34509
|
-
content: templates.map((template) => ({
|
|
34616
|
+
content: contentMode === "text" ? templates.map((template) => ({
|
|
34617
|
+
type: "text",
|
|
34618
|
+
text: [
|
|
34619
|
+
`<cadre-template id=${JSON.stringify(template.id)} uri=${JSON.stringify(template.uri)} mimeType=${JSON.stringify(template.mimeType)}>`,
|
|
34620
|
+
template.content,
|
|
34621
|
+
"</cadre-template>"
|
|
34622
|
+
].join("\n")
|
|
34623
|
+
})) : templates.map((template) => ({
|
|
34510
34624
|
type: "resource",
|
|
34511
34625
|
resource: {
|
|
34512
34626
|
uri: template.uri,
|
|
@@ -34526,6 +34640,9 @@ function sha256(content) {
|
|
|
34526
34640
|
function artifact(path, content) {
|
|
34527
34641
|
return { path, sha256: sha256(content) };
|
|
34528
34642
|
}
|
|
34643
|
+
function candidateManifest(files) {
|
|
34644
|
+
return files.map((file2) => artifact(file2.path, file2.content)).sort((left, right) => left.path.localeCompare(right.path));
|
|
34645
|
+
}
|
|
34529
34646
|
function jsonArtifact(path, value) {
|
|
34530
34647
|
return artifact(path, `${JSON.stringify(value, null, 2)}
|
|
34531
34648
|
`);
|
|
@@ -34548,17 +34665,13 @@ function requireCurrentProject2(projectRoot) {
|
|
|
34548
34665
|
}
|
|
34549
34666
|
return root;
|
|
34550
34667
|
}
|
|
34551
|
-
var adaptiveModeSchema = external_exports.enum(["prepare", "apply"]);
|
|
34552
34668
|
function adaptiveInputSchema(prepare) {
|
|
34553
|
-
|
|
34554
|
-
|
|
34555
|
-
|
|
34556
|
-
|
|
34557
|
-
|
|
34558
|
-
|
|
34559
|
-
proposalToken: proposalTokenSchema.optional(),
|
|
34560
|
-
...optionalPrepare
|
|
34561
|
-
}).strict();
|
|
34669
|
+
return {
|
|
34670
|
+
request: external_exports.discriminatedUnion("mode", [
|
|
34671
|
+
external_exports.strictObject({ mode: external_exports.literal("prepare"), ...prepare }),
|
|
34672
|
+
external_exports.strictObject({ mode: external_exports.literal("apply"), proposalToken: proposalTokenSchema })
|
|
34673
|
+
])
|
|
34674
|
+
};
|
|
34562
34675
|
}
|
|
34563
34676
|
function normalizeAdaptiveInput(input, requiredPrepareFields, command) {
|
|
34564
34677
|
const prepareFields = Object.keys(input).filter((key) => key !== "mode" && key !== "proposalToken");
|
|
@@ -34646,6 +34759,48 @@ function projectStatusView(validation) {
|
|
|
34646
34759
|
warnings: validation.warnings
|
|
34647
34760
|
};
|
|
34648
34761
|
}
|
|
34762
|
+
function focusedValidationErrors(validation, root, trackIds) {
|
|
34763
|
+
const markers = trackIds.flatMap((id) => [
|
|
34764
|
+
`${id}:`,
|
|
34765
|
+
join10(root, ".cadre", "tracks", id),
|
|
34766
|
+
join10(root, ".cadre", "archive", id),
|
|
34767
|
+
`/${id}/`
|
|
34768
|
+
]);
|
|
34769
|
+
return validation.errors.filter((error51) => markers.some((marker) => error51.includes(marker)));
|
|
34770
|
+
}
|
|
34771
|
+
function stagedTrackCandidates(root, validation) {
|
|
34772
|
+
const stageRoot = join10(root, ".cadre", "stage");
|
|
34773
|
+
if (!existsSync12(stageRoot)) return [];
|
|
34774
|
+
return readdirSync10(stageRoot, { withFileTypes: true }).filter((entry) => entry.name.startsWith("track-") && entry.name.length > "track-".length).map((entry) => {
|
|
34775
|
+
const candidateId = entry.name;
|
|
34776
|
+
const trackId = candidateId.slice("track-".length);
|
|
34777
|
+
const canonical = validation.tracks.find((track) => track.id === trackId);
|
|
34778
|
+
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";
|
|
34779
|
+
try {
|
|
34780
|
+
const paths = listCandidatePaths(root, candidateId);
|
|
34781
|
+
const files = candidateManifest(readCandidateFiles(root, candidateId, paths));
|
|
34782
|
+
return {
|
|
34783
|
+
trackId,
|
|
34784
|
+
candidateId,
|
|
34785
|
+
canonicalState,
|
|
34786
|
+
valid: true,
|
|
34787
|
+
files,
|
|
34788
|
+
errors: [],
|
|
34789
|
+
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."
|
|
34790
|
+
};
|
|
34791
|
+
} catch (error51) {
|
|
34792
|
+
return {
|
|
34793
|
+
trackId,
|
|
34794
|
+
candidateId,
|
|
34795
|
+
canonicalState,
|
|
34796
|
+
valid: false,
|
|
34797
|
+
files: [],
|
|
34798
|
+
errors: [serializeCadreError(error51).message],
|
|
34799
|
+
nextAction: "Repair or remove the unsafe staged candidate before resuming it."
|
|
34800
|
+
};
|
|
34801
|
+
}
|
|
34802
|
+
}).sort((left, right) => left.trackId.localeCompare(right.trackId));
|
|
34803
|
+
}
|
|
34649
34804
|
var PLAN_VALIDATION_STATUSES = [
|
|
34650
34805
|
"drafting-spec",
|
|
34651
34806
|
"drafting-plan",
|
|
@@ -34702,9 +34857,9 @@ function createCadreServer() {
|
|
|
34702
34857
|
].join(" ")
|
|
34703
34858
|
}
|
|
34704
34859
|
);
|
|
34705
|
-
server.registerTool(
|
|
34860
|
+
server.registerTool(CADRE_MCP_TOOLS.workflowElicit, {
|
|
34706
34861
|
title: "Collect Cadre workflow input",
|
|
34707
|
-
description: "
|
|
34862
|
+
description: "Request a decision.",
|
|
34708
34863
|
inputSchema: workflowElicitationInputSchema,
|
|
34709
34864
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34710
34865
|
}, async (input) => {
|
|
@@ -34735,21 +34890,24 @@ function createCadreServer() {
|
|
|
34735
34890
|
async () => ({ contents: [{ uri: template.uri, mimeType: template.mimeType, text: template.content }] })
|
|
34736
34891
|
);
|
|
34737
34892
|
}
|
|
34738
|
-
server.registerTool(
|
|
34893
|
+
server.registerTool(CADRE_MCP_TOOLS.templateGetMany, {
|
|
34739
34894
|
title: "Get multiple Cadre templates",
|
|
34740
|
-
description: "Read
|
|
34741
|
-
inputSchema: {
|
|
34895
|
+
description: "Read templates.",
|
|
34896
|
+
inputSchema: {
|
|
34897
|
+
ids: external_exports.array(external_exports.enum(TEMPLATE_IDS)).min(1),
|
|
34898
|
+
contentMode: external_exports.enum(["embedded_resource", "text"]).optional().default("embedded_resource")
|
|
34899
|
+
},
|
|
34742
34900
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34743
|
-
}, async ({ ids }) => {
|
|
34901
|
+
}, async ({ ids, contentMode }) => {
|
|
34744
34902
|
try {
|
|
34745
|
-
return templateResult(getTemplates(ids).map(describeTemplate));
|
|
34903
|
+
return templateResult(getTemplates(ids).map(describeTemplate), contentMode);
|
|
34746
34904
|
} catch (error51) {
|
|
34747
34905
|
return failure(error51);
|
|
34748
34906
|
}
|
|
34749
34907
|
});
|
|
34750
|
-
server.registerTool(
|
|
34908
|
+
server.registerTool(CADRE_MCP_TOOLS.styleguideResolve, {
|
|
34751
34909
|
title: "Resolve default styleguides",
|
|
34752
|
-
description: "Resolve
|
|
34910
|
+
description: "Resolve styleguides.",
|
|
34753
34911
|
inputSchema: { technologies: external_exports.array(external_exports.string()).min(1) },
|
|
34754
34912
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34755
34913
|
}, async ({ technologies }) => {
|
|
@@ -34765,9 +34923,9 @@ function createCadreServer() {
|
|
|
34765
34923
|
return failure(error51);
|
|
34766
34924
|
}
|
|
34767
34925
|
});
|
|
34768
|
-
server.registerTool(
|
|
34926
|
+
server.registerTool(CADRE_MCP_TOOLS.projectStatus, {
|
|
34769
34927
|
title: "Read Cadre project status",
|
|
34770
|
-
description: "Read
|
|
34928
|
+
description: "Read project status.",
|
|
34771
34929
|
inputSchema: {
|
|
34772
34930
|
projectRoot: external_exports.string().min(1),
|
|
34773
34931
|
view: external_exports.enum(["project", "track", "implementation"]).optional().default("project"),
|
|
@@ -34787,15 +34945,55 @@ function createCadreServer() {
|
|
|
34787
34945
|
worktreeRuntime = null;
|
|
34788
34946
|
}
|
|
34789
34947
|
return result(
|
|
34790
|
-
{ ...projectStatusView(validation), worktreeRuntime },
|
|
34948
|
+
{ ...projectStatusView(validation), stagedTrackCandidates: stagedTrackCandidates(root, validation), worktreeRuntime },
|
|
34791
34949
|
`Cadre project ${validation.errors.length ? "has validation errors" : "is valid"}; ${validation.tracks.length} track${validation.tracks.length === 1 ? "" : "s"}.`
|
|
34792
34950
|
);
|
|
34793
34951
|
}
|
|
34794
34952
|
if (!trackId) throw new Error(`${view} project_status requires trackId`);
|
|
34795
34953
|
const track = validation.tracks.find((candidate) => candidate.id === trackId);
|
|
34796
|
-
|
|
34954
|
+
const stagedCandidate = stagedTrackCandidates(root, validation).find((candidate) => candidate.trackId === trackId);
|
|
34955
|
+
if (!track) {
|
|
34956
|
+
const canonicalPaths = [
|
|
34957
|
+
join10(root, ".cadre", "tracks", trackId),
|
|
34958
|
+
join10(root, ".cadre", "archive", trackId)
|
|
34959
|
+
];
|
|
34960
|
+
if (canonicalPaths.some((path) => existsSync12(path))) {
|
|
34961
|
+
throw new CadreError(
|
|
34962
|
+
"TRACK_STATE_INVALID",
|
|
34963
|
+
`Cadre track ${trackId} has a canonical directory but its state is invalid or unreadable.`,
|
|
34964
|
+
{
|
|
34965
|
+
trackId,
|
|
34966
|
+
errors: validation.errors.filter((error51) => error51.includes(trackId))
|
|
34967
|
+
}
|
|
34968
|
+
);
|
|
34969
|
+
}
|
|
34970
|
+
const candidateId = `track-${trackId}`;
|
|
34971
|
+
if (!stagedCandidate) throw new Error(`unknown Cadre track ${trackId}`);
|
|
34972
|
+
if (view === "implementation") {
|
|
34973
|
+
throw new CadreError(
|
|
34974
|
+
"TRACK_CANDIDATE_ONLY",
|
|
34975
|
+
`Cadre track ${trackId} has a staged candidate but no canonical state; resume it with track status and candidate_inspect before implementation.`,
|
|
34976
|
+
{ trackId, candidateId }
|
|
34977
|
+
);
|
|
34978
|
+
}
|
|
34979
|
+
return result({
|
|
34980
|
+
kind: "staged_track_candidate",
|
|
34981
|
+
valid: validation.errors.length === 0 && stagedCandidate.valid,
|
|
34982
|
+
derivedStateCurrent: validation.warnings.length === 0,
|
|
34983
|
+
upgradeRequired: validation.project?.runtimeVersion !== CADRE_RUNTIME_VERSION || validation.project?.templateSetVersion !== TEMPLATE_SET_VERSION,
|
|
34984
|
+
targetRuntimeVersion: CADRE_RUNTIME_VERSION,
|
|
34985
|
+
targetTemplateSetVersion: TEMPLATE_SET_VERSION,
|
|
34986
|
+
trackId,
|
|
34987
|
+
candidate: stagedCandidate,
|
|
34988
|
+
errors: [...validation.errors, ...stagedCandidate.errors],
|
|
34989
|
+
focusedErrors: [...focusedValidationErrors(validation, root, [trackId]), ...stagedCandidate.errors],
|
|
34990
|
+
warnings: validation.warnings,
|
|
34991
|
+
nextAction: "Resume the track proposal with candidate_inspect; do not create canonical state before approval."
|
|
34992
|
+
}, `${trackId}: staged track candidate awaiting inspection or approval.`);
|
|
34993
|
+
}
|
|
34797
34994
|
const dependencies = (track.dependencies ?? []).map((id) => validation.tracks.find((candidate) => candidate.id === id)).filter((candidate) => Boolean(candidate)).map(trackSummary);
|
|
34798
34995
|
const focused = {
|
|
34996
|
+
kind: "canonical_track",
|
|
34799
34997
|
valid: validation.errors.length === 0,
|
|
34800
34998
|
derivedStateCurrent: validation.warnings.length === 0,
|
|
34801
34999
|
upgradeRequired: validation.project?.runtimeVersion !== CADRE_RUNTIME_VERSION || validation.project?.templateSetVersion !== TEMPLATE_SET_VERSION,
|
|
@@ -34804,7 +35002,9 @@ function createCadreServer() {
|
|
|
34804
35002
|
track: trackSummary(track),
|
|
34805
35003
|
state: validation.states.get(trackId) ?? null,
|
|
34806
35004
|
dependencies,
|
|
34807
|
-
errors: validation.errors
|
|
35005
|
+
errors: validation.errors,
|
|
35006
|
+
focusedErrors: focusedValidationErrors(validation, root, [trackId, ...dependencies.map((dependency) => dependency.id)]),
|
|
35007
|
+
...stagedCandidate ? { stagedCandidate } : {},
|
|
34808
35008
|
warnings: validation.warnings
|
|
34809
35009
|
};
|
|
34810
35010
|
if (view === "track") {
|
|
@@ -34829,9 +35029,9 @@ function createCadreServer() {
|
|
|
34829
35029
|
return failure(error51);
|
|
34830
35030
|
}
|
|
34831
35031
|
});
|
|
34832
|
-
server.registerTool(
|
|
35032
|
+
server.registerTool(CADRE_MCP_TOOLS.stateValidate, {
|
|
34833
35033
|
title: "Validate Cadre project state",
|
|
34834
|
-
description: "Validate
|
|
35034
|
+
description: "Validate state.",
|
|
34835
35035
|
inputSchema: { projectRoot: external_exports.string().min(1) },
|
|
34836
35036
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34837
35037
|
}, async ({ projectRoot }) => {
|
|
@@ -34841,36 +35041,43 @@ function createCadreServer() {
|
|
|
34841
35041
|
return failure(error51);
|
|
34842
35042
|
}
|
|
34843
35043
|
});
|
|
34844
|
-
server.registerTool(
|
|
35044
|
+
server.registerTool(CADRE_MCP_TOOLS.candidateStagePrepare, {
|
|
34845
35045
|
title: "Prepare a Cadre candidate stage",
|
|
34846
|
-
description: "
|
|
35046
|
+
description: "Prepare staging.",
|
|
34847
35047
|
inputSchema: {
|
|
34848
35048
|
projectRoot: external_exports.string().min(1),
|
|
34849
|
-
candidateId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)
|
|
35049
|
+
candidateId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
35050
|
+
expectedFiles: external_exports.array(external_exports.string().min(1)).min(1).optional()
|
|
34850
35051
|
},
|
|
34851
|
-
annotations: {
|
|
34852
|
-
}, async ({ projectRoot, candidateId }) => {
|
|
35052
|
+
annotations: { destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
35053
|
+
}, async ({ projectRoot, candidateId, expectedFiles }) => {
|
|
34853
35054
|
try {
|
|
34854
|
-
return result(
|
|
35055
|
+
return result(
|
|
35056
|
+
prepareCandidateStage(projectRoot, candidateId, expectedFiles),
|
|
35057
|
+
`Prepared Cadre candidate stage ${candidateId}.`
|
|
35058
|
+
);
|
|
34855
35059
|
} catch (error51) {
|
|
34856
35060
|
return failure(error51);
|
|
34857
35061
|
}
|
|
34858
35062
|
});
|
|
34859
|
-
server.registerTool(
|
|
35063
|
+
server.registerTool(CADRE_MCP_TOOLS.candidateInspect, {
|
|
34860
35064
|
title: "Inspect staged artifact candidates",
|
|
34861
|
-
description: "
|
|
34862
|
-
inputSchema: {
|
|
35065
|
+
description: "Inspect staging.",
|
|
35066
|
+
inputSchema: external_exports.strictObject({
|
|
34863
35067
|
projectRoot: external_exports.string().min(1),
|
|
34864
35068
|
candidateId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
34865
35069
|
files: external_exports.array(external_exports.string().min(1)).min(1),
|
|
34866
|
-
|
|
34867
|
-
|
|
35070
|
+
planValidations: external_exports.array(external_exports.object({
|
|
35071
|
+
path: external_exports.string().min(1),
|
|
35072
|
+
targetStatus: external_exports.enum(PLAN_VALIDATION_STATUSES)
|
|
35073
|
+
})).optional().default([])
|
|
35074
|
+
}),
|
|
34868
35075
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34869
|
-
}, async ({ projectRoot, candidateId, files,
|
|
35076
|
+
}, async ({ projectRoot, candidateId, files, planValidations }) => {
|
|
34870
35077
|
try {
|
|
34871
35078
|
const root = safeProjectRoot(projectRoot);
|
|
34872
35079
|
const candidates = readCandidateFiles(root, candidateId, files);
|
|
34873
|
-
const manifest = candidates
|
|
35080
|
+
const manifest = candidateManifest(candidates);
|
|
34874
35081
|
const actualPaths = listCandidatePaths(root, candidateId);
|
|
34875
35082
|
const expectedPaths = manifest.map((file2) => file2.path);
|
|
34876
35083
|
if (JSON.stringify(actualPaths) !== JSON.stringify(expectedPaths)) {
|
|
@@ -34878,31 +35085,56 @@ function createCadreServer() {
|
|
|
34878
35085
|
`Candidate stage must contain exactly the declared files; expected ${expectedPaths.join(", ")}, found ${actualPaths.join(", ")}`
|
|
34879
35086
|
);
|
|
34880
35087
|
}
|
|
34881
|
-
|
|
34882
|
-
|
|
34883
|
-
|
|
34884
|
-
|
|
35088
|
+
const normalizedPlanValidations = planValidations.map((validation) => ({
|
|
35089
|
+
path: normalizeCandidatePath(validation.path),
|
|
35090
|
+
targetStatus: validation.targetStatus
|
|
35091
|
+
})).sort((left, right) => left.path.localeCompare(right.path));
|
|
35092
|
+
const validationPaths = normalizedPlanValidations.map((validation) => validation.path);
|
|
35093
|
+
if (new Set(validationPaths).size !== validationPaths.length) {
|
|
35094
|
+
throw new Error("Candidate planValidations contains duplicate paths");
|
|
35095
|
+
}
|
|
35096
|
+
for (const path of validationPaths) {
|
|
35097
|
+
if (path.split("/").at(-1) !== "plan.md") {
|
|
35098
|
+
throw new Error(`Candidate plan validation path must name plan.md: ${path}`);
|
|
35099
|
+
}
|
|
35100
|
+
if (!expectedPaths.includes(path)) {
|
|
35101
|
+
throw new Error(`Candidate plan validation path is not a declared staged file: ${path}`);
|
|
35102
|
+
}
|
|
35103
|
+
}
|
|
35104
|
+
const candidatePlanPaths = candidates.map((candidate) => candidate.path).filter((path) => path.split("/").at(-1) === "plan.md").sort();
|
|
35105
|
+
if (JSON.stringify(candidatePlanPaths) !== JSON.stringify(validationPaths)) {
|
|
35106
|
+
throw new Error(
|
|
35107
|
+
`Candidate planValidations must exactly match staged plan files; expected ${candidatePlanPaths.join(", ") || "none"}, found ${validationPaths.join(", ") || "none"}`
|
|
35108
|
+
);
|
|
35109
|
+
}
|
|
35110
|
+
const plans = normalizedPlanValidations.map((validation) => {
|
|
35111
|
+
const candidate = candidates.find((file2) => file2.path === validation.path);
|
|
34885
35112
|
if (Buffer.byteLength(candidate.content, "utf8") > MAX_DRAFT_PLAN_CHARACTERS) {
|
|
34886
|
-
throw new Error(`Candidate plan exceeds ${MAX_DRAFT_PLAN_CHARACTERS} bytes`);
|
|
35113
|
+
throw new Error(`Candidate plan exceeds ${MAX_DRAFT_PLAN_CHARACTERS} bytes: ${candidate.path}`);
|
|
34887
35114
|
}
|
|
34888
35115
|
const errors = [];
|
|
34889
35116
|
const graph = parsePlanContent(candidate.content, candidate.path, errors);
|
|
34890
|
-
validatePlanGraph(candidate.path, graph, targetStatus, errors);
|
|
34891
|
-
|
|
34892
|
-
}
|
|
35117
|
+
validatePlanGraph(candidate.path, graph, validation.targetStatus, errors);
|
|
35118
|
+
return { ...validation, valid: errors.length === 0, graph, errors };
|
|
35119
|
+
});
|
|
34893
35120
|
return result({
|
|
34894
35121
|
candidateId,
|
|
34895
35122
|
files: manifest,
|
|
34896
|
-
|
|
34897
|
-
|
|
35123
|
+
plans,
|
|
35124
|
+
digest: sha256(JSON.stringify({
|
|
35125
|
+
projectRoot: root,
|
|
35126
|
+
candidateId,
|
|
35127
|
+
files: manifest,
|
|
35128
|
+
planValidations: normalizedPlanValidations
|
|
35129
|
+
}))
|
|
34898
35130
|
}, `Inspected ${manifest.length} staged Cadre artifact${manifest.length === 1 ? "" : "s"}.`);
|
|
34899
35131
|
} catch (error51) {
|
|
34900
35132
|
return failure(error51);
|
|
34901
35133
|
}
|
|
34902
35134
|
});
|
|
34903
|
-
server.registerTool(
|
|
35135
|
+
server.registerTool(CADRE_MCP_TOOLS.executionGraphValidate, {
|
|
34904
35136
|
title: "Validate a track execution graph",
|
|
34905
|
-
description: "
|
|
35137
|
+
description: "Validate plan DAG.",
|
|
34906
35138
|
inputSchema: { projectRoot: external_exports.string().min(1), trackId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/) },
|
|
34907
35139
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34908
35140
|
}, async ({ projectRoot, trackId }) => {
|
|
@@ -34922,20 +35154,19 @@ function createCadreServer() {
|
|
|
34922
35154
|
const reviewCompleteSchema = {
|
|
34923
35155
|
projectRoot: external_exports.string().min(1),
|
|
34924
35156
|
trackId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
34925
|
-
commitRangeStart: external_exports.string().min(1),
|
|
34926
35157
|
approval: external_exports.string().min(1),
|
|
34927
35158
|
acceptedRisks: external_exports.array(external_exports.string().min(1)).optional()
|
|
34928
35159
|
};
|
|
34929
|
-
server.registerTool(
|
|
35160
|
+
server.registerTool(CADRE_MCP_TOOLS.reviewComplete, {
|
|
34930
35161
|
title: "Complete a clean review",
|
|
34931
|
-
description: "
|
|
35162
|
+
description: "Complete review.",
|
|
34932
35163
|
inputSchema: adaptiveInputSchema(reviewCompleteSchema),
|
|
34933
|
-
annotations: {
|
|
34934
|
-
}, async (
|
|
35164
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35165
|
+
}, async ({ request }) => {
|
|
34935
35166
|
try {
|
|
34936
35167
|
const adaptive = normalizeAdaptiveInput(
|
|
34937
|
-
|
|
34938
|
-
["projectRoot", "trackId", "
|
|
35168
|
+
request,
|
|
35169
|
+
["projectRoot", "trackId", "approval"],
|
|
34939
35170
|
"review_complete"
|
|
34940
35171
|
);
|
|
34941
35172
|
if (adaptive.mode === "apply") {
|
|
@@ -34986,15 +35217,15 @@ function createCadreServer() {
|
|
|
34986
35217
|
selectedTracks: external_exports.array(external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)).min(1).optional(),
|
|
34987
35218
|
updates: external_exports.array(archiveCandidateUpdateSchema)
|
|
34988
35219
|
};
|
|
34989
|
-
server.registerTool(
|
|
35220
|
+
server.registerTool(CADRE_MCP_TOOLS.archiveBatchCandidate, {
|
|
34990
35221
|
title: "Govern a staged archive batch",
|
|
34991
|
-
description: "
|
|
35222
|
+
description: "Apply archive batch.",
|
|
34992
35223
|
inputSchema: adaptiveInputSchema(archiveBatchCandidateSchema),
|
|
34993
|
-
annotations: {
|
|
34994
|
-
}, async (
|
|
35224
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35225
|
+
}, async ({ request }) => {
|
|
34995
35226
|
try {
|
|
34996
35227
|
const adaptive = normalizeAdaptiveInput(
|
|
34997
|
-
|
|
35228
|
+
request,
|
|
34998
35229
|
["projectRoot", "candidateId", "updates"],
|
|
34999
35230
|
"archive_batch_candidate"
|
|
35000
35231
|
);
|
|
@@ -35046,11 +35277,11 @@ function createCadreServer() {
|
|
|
35046
35277
|
projectRoot: external_exports.string().min(1),
|
|
35047
35278
|
batchId: external_exports.string().regex(/^archive-[0-9A-Za-z]+(?:-[0-9A-Za-z]+)*$/)
|
|
35048
35279
|
};
|
|
35049
|
-
server.registerTool(
|
|
35280
|
+
server.registerTool(CADRE_MCP_TOOLS.archiveBatchRecord, {
|
|
35050
35281
|
title: "Record archive provenance",
|
|
35051
|
-
description: "
|
|
35282
|
+
description: "Record archive.",
|
|
35052
35283
|
inputSchema: archiveRecordSchema,
|
|
35053
|
-
annotations: {
|
|
35284
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35054
35285
|
}, async (input) => {
|
|
35055
35286
|
try {
|
|
35056
35287
|
requireCurrentProject2(input.projectRoot);
|
|
@@ -35079,11 +35310,11 @@ function createCadreServer() {
|
|
|
35079
35310
|
approvalMode: external_exports.enum(EXECUTION_APPROVAL_MODES).optional(),
|
|
35080
35311
|
maxWorkers: external_exports.number().int().min(1).max(32).optional().default(3)
|
|
35081
35312
|
};
|
|
35082
|
-
server.registerTool(
|
|
35313
|
+
server.registerTool(CADRE_MCP_TOOLS.executionStart, {
|
|
35083
35314
|
title: "Start implementation execution",
|
|
35084
|
-
description: "
|
|
35315
|
+
description: "Start execution.",
|
|
35085
35316
|
inputSchema: executionStartSchema,
|
|
35086
|
-
annotations: {
|
|
35317
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35087
35318
|
}, async (input) => {
|
|
35088
35319
|
try {
|
|
35089
35320
|
requireCurrentProject2(input.projectRoot);
|
|
@@ -35115,42 +35346,74 @@ function createCadreServer() {
|
|
|
35115
35346
|
trackId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
35116
35347
|
executionId: external_exports.string().regex(/^[0-9A-Za-z]+(?:-[0-9A-Za-z]+)*$/)
|
|
35117
35348
|
};
|
|
35118
|
-
const
|
|
35349
|
+
const checkpointScopeSchema = {
|
|
35119
35350
|
...executionScopeSchema,
|
|
35120
|
-
nodeId: external_exports.string().regex(/^(?:P\d+|T\d+\.\d+)$/)
|
|
35121
|
-
|
|
35122
|
-
|
|
35123
|
-
|
|
35124
|
-
|
|
35125
|
-
|
|
35126
|
-
|
|
35127
|
-
|
|
35128
|
-
|
|
35129
|
-
|
|
35130
|
-
|
|
35351
|
+
nodeId: external_exports.string().regex(/^(?:P\d+|T\d+\.\d+)$/)
|
|
35352
|
+
};
|
|
35353
|
+
const commitSchema = external_exports.string().regex(/^[0-9a-f]{7,40}$/);
|
|
35354
|
+
const evidenceSchema = external_exports.string().min(1);
|
|
35355
|
+
const executionCheckpointActionSchema = external_exports.discriminatedUnion("event", [
|
|
35356
|
+
external_exports.strictObject({
|
|
35357
|
+
event: external_exports.literal("start"),
|
|
35358
|
+
workerId: external_exports.string().min(1).nullable().optional(),
|
|
35359
|
+
worktreePath: external_exports.string().min(1).nullable().optional(),
|
|
35360
|
+
branch: external_exports.string().min(1).nullable().optional(),
|
|
35361
|
+
verification: evidenceSchema.optional()
|
|
35362
|
+
}),
|
|
35363
|
+
external_exports.strictObject({
|
|
35364
|
+
event: external_exports.literal("record_commit"),
|
|
35365
|
+
commit: commitSchema,
|
|
35366
|
+
verification: evidenceSchema,
|
|
35367
|
+
authorization: evidenceSchema
|
|
35368
|
+
}),
|
|
35369
|
+
external_exports.strictObject({
|
|
35370
|
+
event: external_exports.literal("record_integration"),
|
|
35371
|
+
commit: commitSchema,
|
|
35372
|
+
verification: evidenceSchema
|
|
35373
|
+
}),
|
|
35374
|
+
external_exports.strictObject({
|
|
35375
|
+
event: external_exports.literal("record_verification"),
|
|
35376
|
+
commit: commitSchema,
|
|
35377
|
+
verification: evidenceSchema,
|
|
35378
|
+
authorization: evidenceSchema
|
|
35379
|
+
}),
|
|
35380
|
+
external_exports.strictObject({
|
|
35381
|
+
event: external_exports.literal("complete"),
|
|
35382
|
+
commit: commitSchema.optional(),
|
|
35383
|
+
verification: evidenceSchema.optional(),
|
|
35384
|
+
authorization: evidenceSchema.optional()
|
|
35385
|
+
}),
|
|
35386
|
+
external_exports.strictObject({ event: external_exports.literal("block"), blocker: evidenceSchema }),
|
|
35387
|
+
external_exports.strictObject({ event: external_exports.literal("resume") })
|
|
35388
|
+
]);
|
|
35389
|
+
server.registerTool(CADRE_MCP_TOOLS.executionCheckpoint, {
|
|
35131
35390
|
title: "Apply an execution checkpoint",
|
|
35132
|
-
description: "
|
|
35133
|
-
inputSchema:
|
|
35134
|
-
|
|
35135
|
-
|
|
35391
|
+
description: "Checkpoint execution.",
|
|
35392
|
+
inputSchema: {
|
|
35393
|
+
scope: external_exports.strictObject(checkpointScopeSchema),
|
|
35394
|
+
action: executionCheckpointActionSchema
|
|
35395
|
+
},
|
|
35396
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35397
|
+
}, async ({ scope, action }) => {
|
|
35136
35398
|
try {
|
|
35137
|
-
requireCurrentProject2(
|
|
35138
|
-
const
|
|
35139
|
-
const
|
|
35399
|
+
requireCurrentProject2(scope.projectRoot);
|
|
35400
|
+
const checkpointInput = { ...scope, ...action };
|
|
35401
|
+
const preview = previewExecutionCheckpoint(checkpointInput);
|
|
35402
|
+
const applied = applyExecutionCheckpoint(checkpointInput, preview.digest, preview);
|
|
35140
35403
|
return result({
|
|
35141
35404
|
commandStatus: "applied",
|
|
35142
35405
|
path: applied.path,
|
|
35143
35406
|
transition: applied.transition,
|
|
35144
35407
|
checkpoint: applied.journal.checkpoint,
|
|
35145
|
-
derivedStatus: executionSchedulerView(applied.journal, [
|
|
35408
|
+
derivedStatus: executionSchedulerView(applied.journal, [checkpointInput.nodeId])
|
|
35146
35409
|
});
|
|
35147
35410
|
} catch (error51) {
|
|
35148
35411
|
return failure(error51);
|
|
35149
35412
|
}
|
|
35150
35413
|
});
|
|
35151
|
-
server.registerTool(
|
|
35414
|
+
server.registerTool(CADRE_MCP_TOOLS.executionStatus, {
|
|
35152
35415
|
title: "Read implementation execution status",
|
|
35153
|
-
description: "Read
|
|
35416
|
+
description: "Read execution.",
|
|
35154
35417
|
inputSchema: {
|
|
35155
35418
|
projectRoot: external_exports.string().min(1),
|
|
35156
35419
|
trackId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
@@ -35171,11 +35434,11 @@ function createCadreServer() {
|
|
|
35171
35434
|
trackId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
35172
35435
|
executionId: external_exports.string().regex(/^[0-9A-Za-z]+(?:-[0-9A-Za-z]+)*$/)
|
|
35173
35436
|
};
|
|
35174
|
-
server.registerTool(
|
|
35437
|
+
server.registerTool(CADRE_MCP_TOOLS.executionFinish, {
|
|
35175
35438
|
title: "Complete implementation execution",
|
|
35176
|
-
description: "
|
|
35439
|
+
description: "Finish execution.",
|
|
35177
35440
|
inputSchema: executionFinishSchema,
|
|
35178
|
-
annotations: {
|
|
35441
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35179
35442
|
}, async (input) => {
|
|
35180
35443
|
try {
|
|
35181
35444
|
requireCurrentProject2(input.projectRoot);
|
|
@@ -35202,11 +35465,11 @@ function createCadreServer() {
|
|
|
35202
35465
|
executionId: external_exports.string().regex(/^[0-9A-Za-z]+(?:-[0-9A-Za-z]+)*$/),
|
|
35203
35466
|
nodeId: external_exports.string().regex(/^(?:P\d+|T\d+\.\d+)$/)
|
|
35204
35467
|
};
|
|
35205
|
-
server.registerTool(
|
|
35468
|
+
server.registerTool(CADRE_MCP_TOOLS.worktreeCreate, {
|
|
35206
35469
|
title: "Create a Cadre worker worktree",
|
|
35207
|
-
description: "
|
|
35470
|
+
description: "Create worktree.",
|
|
35208
35471
|
inputSchema: worktreeSchema,
|
|
35209
|
-
annotations: {
|
|
35472
|
+
annotations: { destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
35210
35473
|
}, async (input) => {
|
|
35211
35474
|
try {
|
|
35212
35475
|
requireCurrentProject2(input.projectRoot);
|
|
@@ -35229,15 +35492,15 @@ function createCadreServer() {
|
|
|
35229
35492
|
return failure(error51);
|
|
35230
35493
|
}
|
|
35231
35494
|
});
|
|
35232
|
-
server.registerTool(
|
|
35495
|
+
server.registerTool(CADRE_MCP_TOOLS.integration, {
|
|
35233
35496
|
title: "Integrate a worker branch",
|
|
35234
|
-
description: "
|
|
35497
|
+
description: "Integrate branch.",
|
|
35235
35498
|
inputSchema: adaptiveInputSchema(worktreeSchema),
|
|
35236
|
-
annotations: {
|
|
35237
|
-
}, async (
|
|
35499
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35500
|
+
}, async ({ request }) => {
|
|
35238
35501
|
try {
|
|
35239
35502
|
const adaptive = normalizeAdaptiveInput(
|
|
35240
|
-
|
|
35503
|
+
request,
|
|
35241
35504
|
["projectRoot", "trackId", "executionId", "nodeId"],
|
|
35242
35505
|
"integration"
|
|
35243
35506
|
);
|
|
@@ -35265,11 +35528,11 @@ function createCadreServer() {
|
|
|
35265
35528
|
return failure(error51);
|
|
35266
35529
|
}
|
|
35267
35530
|
});
|
|
35268
|
-
server.registerTool(
|
|
35531
|
+
server.registerTool(CADRE_MCP_TOOLS.worktreeCleanup, {
|
|
35269
35532
|
title: "Clean up an integrated worker",
|
|
35270
|
-
description: "
|
|
35533
|
+
description: "Clean worktree.",
|
|
35271
35534
|
inputSchema: worktreeSchema,
|
|
35272
|
-
annotations: {
|
|
35535
|
+
annotations: { destructiveHint: true, openWorldHint: false }
|
|
35273
35536
|
}, async (input) => {
|
|
35274
35537
|
try {
|
|
35275
35538
|
const cleanupInput = input;
|
|
@@ -35294,19 +35557,19 @@ function createCadreServer() {
|
|
|
35294
35557
|
context: external_exports.enum(["greenfield", "brownfield"]),
|
|
35295
35558
|
gitDisposition: external_exports.enum(["existing", "initialize"]),
|
|
35296
35559
|
baseCommit: external_exports.string().regex(/^[0-9a-f]{7,40}$/).nullable(),
|
|
35297
|
-
approvedAt: external_exports.
|
|
35560
|
+
approvedAt: external_exports.string().min(1),
|
|
35298
35561
|
stagedFiles: external_exports.array(external_exports.string().min(1)).min(3),
|
|
35299
35562
|
styleguideIds: external_exports.array(external_exports.string().min(1)).min(1)
|
|
35300
35563
|
};
|
|
35301
|
-
server.registerTool(
|
|
35564
|
+
server.registerTool(CADRE_MCP_TOOLS.projectInitCandidate, {
|
|
35302
35565
|
title: "Initialize from a staged Cadre candidate",
|
|
35303
|
-
description: "
|
|
35566
|
+
description: "Initialize project.",
|
|
35304
35567
|
inputSchema: adaptiveInputSchema(initCandidateSchema),
|
|
35305
|
-
annotations: {
|
|
35306
|
-
}, async (
|
|
35568
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35569
|
+
}, async ({ request }) => {
|
|
35307
35570
|
try {
|
|
35308
35571
|
const adaptive = normalizeAdaptiveInput(
|
|
35309
|
-
|
|
35572
|
+
request,
|
|
35310
35573
|
[
|
|
35311
35574
|
"projectRoot",
|
|
35312
35575
|
"projectName",
|
|
@@ -35334,9 +35597,9 @@ function createCadreServer() {
|
|
|
35334
35597
|
digest: applied.digest
|
|
35335
35598
|
});
|
|
35336
35599
|
}
|
|
35337
|
-
const
|
|
35338
|
-
const preview = previewProjectInitCandidate(
|
|
35339
|
-
return proposalResult("project_init_candidate",
|
|
35600
|
+
const initRequest = adaptive.request;
|
|
35601
|
+
const preview = previewProjectInitCandidate(initRequest);
|
|
35602
|
+
return proposalResult("project_init_candidate", initRequest, {
|
|
35340
35603
|
runtimeVersion: preview.runtimeVersion,
|
|
35341
35604
|
templateSetVersion: preview.templateSetVersion,
|
|
35342
35605
|
files: preview.files.map(({ path, sha256: digest }) => ({ path, sha256: digest })),
|
|
@@ -35346,11 +35609,10 @@ function createCadreServer() {
|
|
|
35346
35609
|
return failure(error51);
|
|
35347
35610
|
}
|
|
35348
35611
|
});
|
|
35349
|
-
server.registerTool(
|
|
35612
|
+
server.registerTool(CADRE_MCP_TOOLS.setupRecordCommit, {
|
|
35350
35613
|
title: "Record the project setup commit",
|
|
35351
|
-
description: "Complete a pending create operation by recording its already-created Git commit SHA.",
|
|
35352
35614
|
inputSchema: { projectRoot: external_exports.string().min(1) },
|
|
35353
|
-
annotations: {
|
|
35615
|
+
annotations: { destructiveHint: false, openWorldHint: false }
|
|
35354
35616
|
}, async ({ projectRoot }) => {
|
|
35355
35617
|
try {
|
|
35356
35618
|
requireCurrentProject2(projectRoot);
|
|
@@ -35360,11 +35622,10 @@ function createCadreServer() {
|
|
|
35360
35622
|
return failure(error51);
|
|
35361
35623
|
}
|
|
35362
35624
|
});
|
|
35363
|
-
server.registerTool(
|
|
35625
|
+
server.registerTool(CADRE_MCP_TOOLS.setupRecordGitInitialized, {
|
|
35364
35626
|
title: "Record Git initialization checkpoint",
|
|
35365
|
-
description: "Advance an approved create operation after the caller verifies Git was initialized at the exact project root.",
|
|
35366
35627
|
inputSchema: { projectRoot: external_exports.string().min(1) },
|
|
35367
|
-
annotations: {
|
|
35628
|
+
annotations: { destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
35368
35629
|
}, async ({ projectRoot }) => {
|
|
35369
35630
|
try {
|
|
35370
35631
|
requireCurrentProject2(projectRoot);
|
|
@@ -35373,11 +35634,10 @@ function createCadreServer() {
|
|
|
35373
35634
|
return failure(error51);
|
|
35374
35635
|
}
|
|
35375
35636
|
});
|
|
35376
|
-
server.registerTool(
|
|
35637
|
+
server.registerTool(CADRE_MCP_TOOLS.tracksRender, {
|
|
35377
35638
|
title: "Render the derived tracks index",
|
|
35378
|
-
description: "Atomically validate and rewrite deterministic tracks.md from current track-local state.",
|
|
35379
35639
|
inputSchema: { projectRoot: external_exports.string().min(1) },
|
|
35380
|
-
annotations: {
|
|
35640
|
+
annotations: { destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
35381
35641
|
}, async ({ projectRoot }) => {
|
|
35382
35642
|
try {
|
|
35383
35643
|
const input = { projectRoot: requireCurrentProject2(projectRoot) };
|