cadre-ai 3.2.0 → 3.3.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 +84 -0
- package/README.md +3 -3
- package/dist/cadre-cli.mjs +1 -1
- package/dist/cadre-mcp.mjs +524 -103
- package/package.json +1 -1
- package/skills/implement/SKILL.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,89 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.3.0] - 2026-08-09
|
|
4
|
+
|
|
5
|
+
Cadre 3.3.0 makes long-running MCP delivery sessions durable across server
|
|
6
|
+
restarts and substantially reduces repeated protocol payloads. It keeps
|
|
7
|
+
project-local state and execution journals compatible while changing several
|
|
8
|
+
MCP response shapes from complete canonical artifacts to compact receipts and
|
|
9
|
+
path/SHA-256 manifests.
|
|
10
|
+
|
|
11
|
+
### Breaking Changes
|
|
12
|
+
|
|
13
|
+
- Changed `execution_checkpoint_preview` and `execution_checkpoint_apply` to
|
|
14
|
+
return a changed-node transition receipt instead of the complete execution
|
|
15
|
+
journal. Apply retains compact `derivedStatus` scheduling arrays and focused
|
|
16
|
+
guidance for changed, active, or blocked nodes.
|
|
17
|
+
- Changed `execution_status` to return execution metadata, node-status counts,
|
|
18
|
+
ready/active/blocked scheduling state, and minimal actionable-node records.
|
|
19
|
+
It no longer echoes the complete journal or guidance for every completed and
|
|
20
|
+
pending node; pass optional `nodeId` for focused full-node detail.
|
|
21
|
+
- Changed initialization, review, archive, execution start/finish, and derived
|
|
22
|
+
track-index responses to return outcome metadata and path/SHA-256 manifests
|
|
23
|
+
instead of full proposed or written artifact contents.
|
|
24
|
+
- Changed proposal tokens from self-contained gzip/base64 payloads to 42-byte
|
|
25
|
+
opaque capabilities backed by the local Cadre runtime cache. Outstanding
|
|
26
|
+
3.2.0 tokens must be previewed again after upgrading.
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- Added durable proposal records under
|
|
31
|
+
`${CADRE_HOME:-~/.cadre}/runtime/proposals`, allowing a preview produced by
|
|
32
|
+
one MCP process to be applied safely after Codex or Claude restarts it.
|
|
33
|
+
- Added seven-day proposal expiry, a 256-record and 32 MiB retained-cache
|
|
34
|
+
bound, an 8 MiB per-proposal bound, and oldest-first cleanup.
|
|
35
|
+
- Added optional focused `nodeId` lookup to `execution_status` without adding a
|
|
36
|
+
separate arbitrary journal-reading tool.
|
|
37
|
+
- Added explicit checkpoint receipts recording the semantic event, source
|
|
38
|
+
status, intermediate transition sequence, target status, and checkpoint.
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- Kept full execution journals as the canonical atomic validation and
|
|
43
|
+
persistence model while projecting only scheduler-relevant state at the MCP
|
|
44
|
+
transport boundary.
|
|
45
|
+
- Kept `proposalToken`, preview/apply tool names, semantic digests, stale-state
|
|
46
|
+
recomputation, and compact `derivedStatus` scheduling arrays stable for
|
|
47
|
+
workflow skills.
|
|
48
|
+
- Updated implementation guidance to reuse checkpoint apply results, request
|
|
49
|
+
focused node detail only when needed, and avoid re-reading the journal after
|
|
50
|
+
each event.
|
|
51
|
+
|
|
52
|
+
### Security And Reliability
|
|
53
|
+
|
|
54
|
+
- Proposal filenames are derived only from validated 192-bit random tokens;
|
|
55
|
+
callers never supply runtime paths.
|
|
56
|
+
- Runtime proposal directories and records are permission-restricted, written
|
|
57
|
+
with exclusive creation and fsync, and checked for ownership, file type,
|
|
58
|
+
symlinks, size, kind, expiry, and schema before use.
|
|
59
|
+
- Proposal resolution remains digest-gated: every apply recomputes current
|
|
60
|
+
state and rejects a stale proposal even when its runtime record is valid.
|
|
61
|
+
- Concurrent cleanup tolerates records already removed by another Codex or
|
|
62
|
+
Claude MCP process, and lost-response retries can reuse retained tokens until
|
|
63
|
+
normal domain idempotency or stale-state checks resolve them.
|
|
64
|
+
|
|
65
|
+
### Performance
|
|
66
|
+
|
|
67
|
+
- Reduced the live 46-node `execution_status` result from roughly 19.5 KiB of
|
|
68
|
+
minified domain data to a 3.1 KiB complete MCP response with no embedded
|
|
69
|
+
journal.
|
|
70
|
+
- Added response-budget regression checks requiring checkpoint preview/apply
|
|
71
|
+
results below 4 KiB and a 50-node default status view below 8 KiB.
|
|
72
|
+
- Removed repeated full workflow, plan, journal, state, pattern, and generated
|
|
73
|
+
index content from mutation responses when an exact digest-bound manifest is
|
|
74
|
+
sufficient.
|
|
75
|
+
|
|
76
|
+
### Compatibility And Upgrade
|
|
77
|
+
|
|
78
|
+
- Existing 3.2.0 `.cadre` projects, track states, operation journals, and
|
|
79
|
+
execution journals require no migration.
|
|
80
|
+
- Direct MCP consumers that read complete artifacts from preview/apply results
|
|
81
|
+
must adopt the compact receipt and manifest shapes. Canonical artifacts
|
|
82
|
+
remain available at their reported project paths.
|
|
83
|
+
- Reinstall the package and native plugins, start a new Codex conversation,
|
|
84
|
+
and run `/reload-plugins` in Claude Code so both clients load the 3.3.0 tool
|
|
85
|
+
schemas. Re-run preview for any proposal token created by 3.2.0.
|
|
86
|
+
|
|
3
87
|
## [3.2.0] - 2026-08-07
|
|
4
88
|
|
|
5
89
|
Cadre 3.2.0 simplifies the execution and governance contracts after analysis
|
package/README.md
CHANGED
|
@@ -303,14 +303,14 @@ The `cadre` stdio server exposes immutable resources at `cadre://templates/v1/..
|
|
|
303
303
|
| `archive_batch_preview` / `archive_batch_apply` | Preview/apply | Preview and apply selected moves, lifecycle states, patterns, seeds, journal, and post-archive index as one approved batch. |
|
|
304
304
|
| `archive_batch_record_preview` / `archive_batch_record_apply` | Preview/apply | Record the resulting archive commit in track, project, and batch provenance without a second batch decision. |
|
|
305
305
|
| `execution_start_preview` / `execution_start_apply` | Preview/apply | Create an approved, digest-gated execution journal and enter `in_progress`. |
|
|
306
|
-
| `execution_checkpoint_preview` / `execution_checkpoint_apply` | Preview/apply | Expand one semantic execution event into its complete legal, evidence-gated transition sequence
|
|
307
|
-
| `execution_status` | No |
|
|
306
|
+
| `execution_checkpoint_preview` / `execution_checkpoint_apply` | Preview/apply | Expand one semantic execution event into its complete legal, evidence-gated transition sequence, apply it atomically, and return a compact transition receipt. |
|
|
307
|
+
| `execution_status` | No | Return a compact ready/active/blocked scheduler view, with optional focused node detail. |
|
|
308
308
|
| `execution_finish_preview` / `execution_finish_apply` | Preview/apply | Require completed nodes, current plan evidence, and removed worktrees before `ready_for_review`. |
|
|
309
309
|
| `worktree_create_preview` / `worktree_create_apply` | Preview/apply | Create or reconcile one derived phase/task worktree and branch. |
|
|
310
310
|
| `integration_preview` / `integration_apply` | Preview/apply | Inspect and merge a clean worker branch into its derived parent, reporting conflicts without resolving them. |
|
|
311
311
|
| `worktree_cleanup_preview` / `worktree_cleanup_apply` | Preview/apply | Remove only a clean worker whose branch is proven integrated into its parent. |
|
|
312
312
|
| `worktree_status` | No | Report Cadre-managed worktrees and orphaned runtime directories. |
|
|
313
|
-
| `project_init_preview` | No | Return the complete proposed initialization
|
|
313
|
+
| `project_init_preview` | No | Return the complete proposed initialization path/hash manifest and digest without echoing file contents. |
|
|
314
314
|
| `project_init_apply` | Yes | Atomically create `.cadre` only when inputs match the approved preview digest. |
|
|
315
315
|
| `setup_record_git_initialized` | Yes | Record the verified Git-initialization checkpoint. |
|
|
316
316
|
| `setup_record_commit` | Yes | Record the already-created setup commit SHA and complete setup state. |
|
package/dist/cadre-cli.mjs
CHANGED
|
@@ -74,7 +74,7 @@ import { dirname, extname, join as join2, relative, resolve as resolve2, sep } f
|
|
|
74
74
|
import { fileURLToPath } from "node:url";
|
|
75
75
|
|
|
76
76
|
// src/domain/version.ts
|
|
77
|
-
var CADRE_RUNTIME_VERSION = "3.
|
|
77
|
+
var CADRE_RUNTIME_VERSION = "3.3.0";
|
|
78
78
|
var TEMPLATE_SET_VERSION = "v1";
|
|
79
79
|
|
|
80
80
|
// src/domain/templates.ts
|
package/dist/cadre-mcp.mjs
CHANGED
|
@@ -405,11 +405,11 @@ var require_codegen = __commonJS({
|
|
|
405
405
|
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
406
406
|
return `${varKind} ${this.name}${rhs};` + _n;
|
|
407
407
|
}
|
|
408
|
-
optimizeNames(names,
|
|
408
|
+
optimizeNames(names, constants2) {
|
|
409
409
|
if (!names[this.name.str])
|
|
410
410
|
return;
|
|
411
411
|
if (this.rhs)
|
|
412
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
412
|
+
this.rhs = optimizeExpr(this.rhs, names, constants2);
|
|
413
413
|
return this;
|
|
414
414
|
}
|
|
415
415
|
get names() {
|
|
@@ -426,10 +426,10 @@ var require_codegen = __commonJS({
|
|
|
426
426
|
render({ _n }) {
|
|
427
427
|
return `${this.lhs} = ${this.rhs};` + _n;
|
|
428
428
|
}
|
|
429
|
-
optimizeNames(names,
|
|
429
|
+
optimizeNames(names, constants2) {
|
|
430
430
|
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
|
|
431
431
|
return;
|
|
432
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
432
|
+
this.rhs = optimizeExpr(this.rhs, names, constants2);
|
|
433
433
|
return this;
|
|
434
434
|
}
|
|
435
435
|
get names() {
|
|
@@ -490,8 +490,8 @@ var require_codegen = __commonJS({
|
|
|
490
490
|
optimizeNodes() {
|
|
491
491
|
return `${this.code}` ? this : void 0;
|
|
492
492
|
}
|
|
493
|
-
optimizeNames(names,
|
|
494
|
-
this.code = optimizeExpr(this.code, names,
|
|
493
|
+
optimizeNames(names, constants2) {
|
|
494
|
+
this.code = optimizeExpr(this.code, names, constants2);
|
|
495
495
|
return this;
|
|
496
496
|
}
|
|
497
497
|
get names() {
|
|
@@ -520,12 +520,12 @@ var require_codegen = __commonJS({
|
|
|
520
520
|
}
|
|
521
521
|
return nodes.length > 0 ? this : void 0;
|
|
522
522
|
}
|
|
523
|
-
optimizeNames(names,
|
|
523
|
+
optimizeNames(names, constants2) {
|
|
524
524
|
const { nodes } = this;
|
|
525
525
|
let i = nodes.length;
|
|
526
526
|
while (i--) {
|
|
527
527
|
const n = nodes[i];
|
|
528
|
-
if (n.optimizeNames(names,
|
|
528
|
+
if (n.optimizeNames(names, constants2))
|
|
529
529
|
continue;
|
|
530
530
|
subtractNames(names, n.names);
|
|
531
531
|
nodes.splice(i, 1);
|
|
@@ -578,12 +578,12 @@ var require_codegen = __commonJS({
|
|
|
578
578
|
return void 0;
|
|
579
579
|
return this;
|
|
580
580
|
}
|
|
581
|
-
optimizeNames(names,
|
|
581
|
+
optimizeNames(names, constants2) {
|
|
582
582
|
var _a3;
|
|
583
|
-
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names,
|
|
584
|
-
if (!(super.optimizeNames(names,
|
|
583
|
+
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants2);
|
|
584
|
+
if (!(super.optimizeNames(names, constants2) || this.else))
|
|
585
585
|
return;
|
|
586
|
-
this.condition = optimizeExpr(this.condition, names,
|
|
586
|
+
this.condition = optimizeExpr(this.condition, names, constants2);
|
|
587
587
|
return this;
|
|
588
588
|
}
|
|
589
589
|
get names() {
|
|
@@ -606,10 +606,10 @@ var require_codegen = __commonJS({
|
|
|
606
606
|
render(opts) {
|
|
607
607
|
return `for(${this.iteration})` + super.render(opts);
|
|
608
608
|
}
|
|
609
|
-
optimizeNames(names,
|
|
610
|
-
if (!super.optimizeNames(names,
|
|
609
|
+
optimizeNames(names, constants2) {
|
|
610
|
+
if (!super.optimizeNames(names, constants2))
|
|
611
611
|
return;
|
|
612
|
-
this.iteration = optimizeExpr(this.iteration, names,
|
|
612
|
+
this.iteration = optimizeExpr(this.iteration, names, constants2);
|
|
613
613
|
return this;
|
|
614
614
|
}
|
|
615
615
|
get names() {
|
|
@@ -645,10 +645,10 @@ var require_codegen = __commonJS({
|
|
|
645
645
|
render(opts) {
|
|
646
646
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
647
647
|
}
|
|
648
|
-
optimizeNames(names,
|
|
649
|
-
if (!super.optimizeNames(names,
|
|
648
|
+
optimizeNames(names, constants2) {
|
|
649
|
+
if (!super.optimizeNames(names, constants2))
|
|
650
650
|
return;
|
|
651
|
-
this.iterable = optimizeExpr(this.iterable, names,
|
|
651
|
+
this.iterable = optimizeExpr(this.iterable, names, constants2);
|
|
652
652
|
return this;
|
|
653
653
|
}
|
|
654
654
|
get names() {
|
|
@@ -690,11 +690,11 @@ var require_codegen = __commonJS({
|
|
|
690
690
|
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
|
|
691
691
|
return this;
|
|
692
692
|
}
|
|
693
|
-
optimizeNames(names,
|
|
693
|
+
optimizeNames(names, constants2) {
|
|
694
694
|
var _a3, _b;
|
|
695
|
-
super.optimizeNames(names,
|
|
696
|
-
(_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names,
|
|
697
|
-
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names,
|
|
695
|
+
super.optimizeNames(names, constants2);
|
|
696
|
+
(_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants2);
|
|
697
|
+
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants2);
|
|
698
698
|
return this;
|
|
699
699
|
}
|
|
700
700
|
get names() {
|
|
@@ -995,7 +995,7 @@ var require_codegen = __commonJS({
|
|
|
995
995
|
function addExprNames(names, from) {
|
|
996
996
|
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
997
997
|
}
|
|
998
|
-
function optimizeExpr(expr, names,
|
|
998
|
+
function optimizeExpr(expr, names, constants2) {
|
|
999
999
|
if (expr instanceof code_1.Name)
|
|
1000
1000
|
return replaceName(expr);
|
|
1001
1001
|
if (!canOptimize(expr))
|
|
@@ -1010,14 +1010,14 @@ var require_codegen = __commonJS({
|
|
|
1010
1010
|
return items;
|
|
1011
1011
|
}, []));
|
|
1012
1012
|
function replaceName(n) {
|
|
1013
|
-
const c =
|
|
1013
|
+
const c = constants2[n.str];
|
|
1014
1014
|
if (c === void 0 || names[n.str] !== 1)
|
|
1015
1015
|
return n;
|
|
1016
1016
|
delete names[n.str];
|
|
1017
1017
|
return c;
|
|
1018
1018
|
}
|
|
1019
1019
|
function canOptimize(e) {
|
|
1020
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 &&
|
|
1020
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants2[c.str] !== void 0);
|
|
1021
1021
|
}
|
|
1022
1022
|
}
|
|
1023
1023
|
function subtractNames(names, from) {
|
|
@@ -2979,7 +2979,7 @@ var require_compile = __commonJS({
|
|
|
2979
2979
|
const schOrFunc = root.refs[ref];
|
|
2980
2980
|
if (schOrFunc)
|
|
2981
2981
|
return schOrFunc;
|
|
2982
|
-
let _sch =
|
|
2982
|
+
let _sch = resolve12.call(this, root, ref);
|
|
2983
2983
|
if (_sch === void 0) {
|
|
2984
2984
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
2985
2985
|
const { schemaId } = this.opts;
|
|
@@ -3006,7 +3006,7 @@ var require_compile = __commonJS({
|
|
|
3006
3006
|
function sameSchemaEnv(s1, s2) {
|
|
3007
3007
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
3008
3008
|
}
|
|
3009
|
-
function
|
|
3009
|
+
function resolve12(root, ref) {
|
|
3010
3010
|
let sch;
|
|
3011
3011
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
3012
3012
|
ref = sch;
|
|
@@ -3637,7 +3637,7 @@ var require_fast_uri = __commonJS({
|
|
|
3637
3637
|
}
|
|
3638
3638
|
return uri;
|
|
3639
3639
|
}
|
|
3640
|
-
function
|
|
3640
|
+
function resolve12(baseURI, relativeURI, options) {
|
|
3641
3641
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
3642
3642
|
const resolved = resolveComponent(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
3643
3643
|
schemelessOptions.skipEscape = true;
|
|
@@ -3895,7 +3895,7 @@ var require_fast_uri = __commonJS({
|
|
|
3895
3895
|
var fastUri = {
|
|
3896
3896
|
SCHEMES,
|
|
3897
3897
|
normalize,
|
|
3898
|
-
resolve:
|
|
3898
|
+
resolve: resolve12,
|
|
3899
3899
|
resolveComponent,
|
|
3900
3900
|
equal,
|
|
3901
3901
|
serialize,
|
|
@@ -28843,7 +28843,7 @@ var Protocol = class {
|
|
|
28843
28843
|
return;
|
|
28844
28844
|
}
|
|
28845
28845
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
28846
|
-
await new Promise((
|
|
28846
|
+
await new Promise((resolve12) => setTimeout(resolve12, pollInterval));
|
|
28847
28847
|
options?.signal?.throwIfAborted();
|
|
28848
28848
|
}
|
|
28849
28849
|
} catch (error51) {
|
|
@@ -28860,7 +28860,7 @@ var Protocol = class {
|
|
|
28860
28860
|
*/
|
|
28861
28861
|
request(request, resultSchema, options) {
|
|
28862
28862
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
28863
|
-
return new Promise((
|
|
28863
|
+
return new Promise((resolve12, reject) => {
|
|
28864
28864
|
const earlyReject = (error51) => {
|
|
28865
28865
|
reject(error51);
|
|
28866
28866
|
};
|
|
@@ -28938,7 +28938,7 @@ var Protocol = class {
|
|
|
28938
28938
|
if (!parseResult.success) {
|
|
28939
28939
|
reject(parseResult.error);
|
|
28940
28940
|
} else {
|
|
28941
|
-
|
|
28941
|
+
resolve12(parseResult.data);
|
|
28942
28942
|
}
|
|
28943
28943
|
} catch (error51) {
|
|
28944
28944
|
reject(error51);
|
|
@@ -29199,12 +29199,12 @@ var Protocol = class {
|
|
|
29199
29199
|
}
|
|
29200
29200
|
} catch {
|
|
29201
29201
|
}
|
|
29202
|
-
return new Promise((
|
|
29202
|
+
return new Promise((resolve12, reject) => {
|
|
29203
29203
|
if (signal.aborted) {
|
|
29204
29204
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
29205
29205
|
return;
|
|
29206
29206
|
}
|
|
29207
|
-
const timeoutId = setTimeout(
|
|
29207
|
+
const timeoutId = setTimeout(resolve12, interval);
|
|
29208
29208
|
signal.addEventListener("abort", () => {
|
|
29209
29209
|
clearTimeout(timeoutId);
|
|
29210
29210
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -30295,7 +30295,7 @@ var McpServer = class {
|
|
|
30295
30295
|
let task = createTaskResult.task;
|
|
30296
30296
|
const pollInterval = task.pollInterval ?? 5e3;
|
|
30297
30297
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
30298
|
-
await new Promise((
|
|
30298
|
+
await new Promise((resolve12) => setTimeout(resolve12, pollInterval));
|
|
30299
30299
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
30300
30300
|
if (!updatedTask) {
|
|
30301
30301
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -30959,20 +30959,21 @@ var StdioServerTransport = class {
|
|
|
30959
30959
|
this.onclose?.();
|
|
30960
30960
|
}
|
|
30961
30961
|
send(message) {
|
|
30962
|
-
return new Promise((
|
|
30962
|
+
return new Promise((resolve12) => {
|
|
30963
30963
|
const json3 = serializeMessage(message);
|
|
30964
30964
|
if (this._stdout.write(json3)) {
|
|
30965
|
-
|
|
30965
|
+
resolve12();
|
|
30966
30966
|
} else {
|
|
30967
|
-
this._stdout.once("drain",
|
|
30967
|
+
this._stdout.once("drain", resolve12);
|
|
30968
30968
|
}
|
|
30969
30969
|
});
|
|
30970
30970
|
}
|
|
30971
30971
|
};
|
|
30972
30972
|
|
|
30973
30973
|
// src/mcp/server.ts
|
|
30974
|
-
import {
|
|
30975
|
-
import {
|
|
30974
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
30975
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
30976
|
+
import { join as join9, resolve as resolve11 } from "node:path";
|
|
30976
30977
|
import { pathToFileURL } from "node:url";
|
|
30977
30978
|
|
|
30978
30979
|
// src/domain/init.ts
|
|
@@ -30994,7 +30995,7 @@ import { existsSync as existsSync5, lstatSync as lstatSync2, readFileSync as rea
|
|
|
30994
30995
|
import { join as join3, resolve as resolve5 } from "node:path";
|
|
30995
30996
|
|
|
30996
30997
|
// src/domain/version.ts
|
|
30997
|
-
var CADRE_RUNTIME_VERSION = "3.
|
|
30998
|
+
var CADRE_RUNTIME_VERSION = "3.3.0";
|
|
30998
30999
|
var TEMPLATE_SET_VERSION = "v1";
|
|
30999
31000
|
|
|
31000
31001
|
// src/domain/plan.ts
|
|
@@ -31759,6 +31760,66 @@ function deriveExecutionStatus(journal) {
|
|
|
31759
31760
|
eventGuidance
|
|
31760
31761
|
};
|
|
31761
31762
|
}
|
|
31763
|
+
function executionSchedulerView(journal, focusNodeIds = []) {
|
|
31764
|
+
const status = deriveExecutionStatus(journal);
|
|
31765
|
+
const relevant = /* @__PURE__ */ new Set([
|
|
31766
|
+
...status.active,
|
|
31767
|
+
...status.blocked,
|
|
31768
|
+
...focusNodeIds
|
|
31769
|
+
]);
|
|
31770
|
+
return {
|
|
31771
|
+
readyPhases: status.readyPhases,
|
|
31772
|
+
readyTasks: status.readyTasks,
|
|
31773
|
+
active: status.active,
|
|
31774
|
+
blocked: status.blocked,
|
|
31775
|
+
eventGuidance: Object.fromEntries(
|
|
31776
|
+
Object.entries(status.eventGuidance).filter(([nodeId]) => relevant.has(nodeId))
|
|
31777
|
+
)
|
|
31778
|
+
};
|
|
31779
|
+
}
|
|
31780
|
+
function compactExecutionStatus(journal, nodeId) {
|
|
31781
|
+
if (nodeId && !journal.nodes[nodeId]) throw new Error(`unknown execution node ${nodeId}`);
|
|
31782
|
+
const derivedStatus = executionSchedulerView(journal, nodeId ? [nodeId] : []);
|
|
31783
|
+
const actionableIds = /* @__PURE__ */ new Set([
|
|
31784
|
+
...derivedStatus.active,
|
|
31785
|
+
...derivedStatus.blocked
|
|
31786
|
+
]);
|
|
31787
|
+
const actionableNodes = [...actionableIds].map((id) => {
|
|
31788
|
+
const node = journal.nodes[id];
|
|
31789
|
+
return {
|
|
31790
|
+
id: node.id,
|
|
31791
|
+
kind: node.kind,
|
|
31792
|
+
phaseId: node.phaseId,
|
|
31793
|
+
status: node.status,
|
|
31794
|
+
dependencies: node.dependencies,
|
|
31795
|
+
...node.workerId ? { workerId: node.workerId } : {},
|
|
31796
|
+
...node.worktreePath ? { worktreePath: node.worktreePath } : {},
|
|
31797
|
+
...node.branch ? { branch: node.branch } : {},
|
|
31798
|
+
...node.blocker ? { blocker: node.blocker } : {}
|
|
31799
|
+
};
|
|
31800
|
+
});
|
|
31801
|
+
const counts = {};
|
|
31802
|
+
for (const node of Object.values(journal.nodes)) counts[node.status] = (counts[node.status] ?? 0) + 1;
|
|
31803
|
+
return {
|
|
31804
|
+
execution: {
|
|
31805
|
+
executionId: journal.executionId,
|
|
31806
|
+
trackId: journal.trackId,
|
|
31807
|
+
status: journal.status,
|
|
31808
|
+
checkpoint: journal.checkpoint,
|
|
31809
|
+
requestedMode: journal.requestedMode,
|
|
31810
|
+
effectiveMode: journal.effectiveMode,
|
|
31811
|
+
approvalMode: journal.approvalMode,
|
|
31812
|
+
maxWorkers: journal.maxWorkers,
|
|
31813
|
+
planRevision: journal.planRevision,
|
|
31814
|
+
startedAt: journal.startedAt,
|
|
31815
|
+
completedAt: journal.completedAt
|
|
31816
|
+
},
|
|
31817
|
+
counts,
|
|
31818
|
+
actionableNodes,
|
|
31819
|
+
...nodeId ? { node: journal.nodes[nodeId] } : {},
|
|
31820
|
+
derivedStatus
|
|
31821
|
+
};
|
|
31822
|
+
}
|
|
31762
31823
|
function executionStatus(projectRoot, trackId, executionId) {
|
|
31763
31824
|
const journal = readExecution(projectRoot, trackId, executionId);
|
|
31764
31825
|
return { journal, ...deriveExecutionStatus(journal) };
|
|
@@ -31876,21 +31937,51 @@ function checkpointUpdates(journal, input) {
|
|
|
31876
31937
|
}
|
|
31877
31938
|
function previewExecutionCheckpoint(input) {
|
|
31878
31939
|
const journal = readExecution(input.projectRoot, input.trackId, input.executionId);
|
|
31879
|
-
|
|
31940
|
+
const from = journal.nodes[input.nodeId]?.status;
|
|
31941
|
+
if (!from) throw new Error(`unknown execution node ${input.nodeId}`);
|
|
31942
|
+
const updates = checkpointUpdates(journal, input);
|
|
31943
|
+
const proposal = previewExecutionNodesUpdate({
|
|
31880
31944
|
projectRoot: input.projectRoot,
|
|
31881
31945
|
trackId: input.trackId,
|
|
31882
31946
|
executionId: input.executionId,
|
|
31883
|
-
updates
|
|
31947
|
+
updates
|
|
31884
31948
|
});
|
|
31949
|
+
const statuses = updates.map((update) => update.status);
|
|
31950
|
+
return {
|
|
31951
|
+
...proposal,
|
|
31952
|
+
transition: {
|
|
31953
|
+
nodeId: input.nodeId,
|
|
31954
|
+
event: input.event,
|
|
31955
|
+
from,
|
|
31956
|
+
through: statuses.slice(0, -1),
|
|
31957
|
+
to: statuses.at(-1),
|
|
31958
|
+
checkpoint: proposal.journal.checkpoint
|
|
31959
|
+
}
|
|
31960
|
+
};
|
|
31885
31961
|
}
|
|
31886
31962
|
function applyExecutionCheckpoint(input, proposalDigest) {
|
|
31887
31963
|
const journal = readExecution(input.projectRoot, input.trackId, input.executionId);
|
|
31888
|
-
|
|
31964
|
+
const from = journal.nodes[input.nodeId]?.status;
|
|
31965
|
+
if (!from) throw new Error(`unknown execution node ${input.nodeId}`);
|
|
31966
|
+
const updates = checkpointUpdates(journal, input);
|
|
31967
|
+
const applied = applyExecutionNodesUpdate({
|
|
31889
31968
|
projectRoot: input.projectRoot,
|
|
31890
31969
|
trackId: input.trackId,
|
|
31891
31970
|
executionId: input.executionId,
|
|
31892
|
-
updates
|
|
31971
|
+
updates
|
|
31893
31972
|
}, proposalDigest);
|
|
31973
|
+
const statuses = updates.map((update) => update.status);
|
|
31974
|
+
return {
|
|
31975
|
+
...applied,
|
|
31976
|
+
transition: {
|
|
31977
|
+
nodeId: input.nodeId,
|
|
31978
|
+
event: input.event,
|
|
31979
|
+
from,
|
|
31980
|
+
through: statuses.slice(0, -1),
|
|
31981
|
+
to: statuses.at(-1),
|
|
31982
|
+
checkpoint: applied.journal.checkpoint
|
|
31983
|
+
}
|
|
31984
|
+
};
|
|
31894
31985
|
}
|
|
31895
31986
|
function deriveExecutionFinishInput(input) {
|
|
31896
31987
|
return {
|
|
@@ -33896,32 +33987,197 @@ function normalizeWorkflowElicitation(input, elicited) {
|
|
|
33896
33987
|
}
|
|
33897
33988
|
|
|
33898
33989
|
// src/mcp/proposals.ts
|
|
33899
|
-
import {
|
|
33900
|
-
|
|
33990
|
+
import { randomBytes } from "node:crypto";
|
|
33991
|
+
import {
|
|
33992
|
+
chmodSync,
|
|
33993
|
+
closeSync,
|
|
33994
|
+
existsSync as existsSync10,
|
|
33995
|
+
fstatSync,
|
|
33996
|
+
fsyncSync,
|
|
33997
|
+
lstatSync as lstatSync6,
|
|
33998
|
+
mkdirSync as mkdirSync4,
|
|
33999
|
+
openSync,
|
|
34000
|
+
readFileSync as readFileSync8,
|
|
34001
|
+
readdirSync as readdirSync7,
|
|
34002
|
+
unlinkSync as unlinkSync2,
|
|
34003
|
+
writeFileSync as writeFileSync5
|
|
34004
|
+
} from "node:fs";
|
|
34005
|
+
import { homedir as homedir2 } from "node:os";
|
|
34006
|
+
import { constants } from "node:fs";
|
|
34007
|
+
import { join as join8, resolve as resolve10 } from "node:path";
|
|
34008
|
+
var TOKEN_PREFIX = "cadre_pt1_";
|
|
34009
|
+
var TOKEN_PATTERN = /^cadre_pt1_[A-Za-z0-9_-]{32}$/;
|
|
34010
|
+
var RECORD_PATTERN = /^cadre_pt1_[A-Za-z0-9_-]{32}\.json$/;
|
|
33901
34011
|
var MAX_PROPOSAL_BYTES = 8 * 1024 * 1024;
|
|
34012
|
+
var DEFAULT_MAX_RETAINED_PROPOSALS = 256;
|
|
34013
|
+
var DEFAULT_MAX_RETAINED_BYTES = 32 * 1024 * 1024;
|
|
34014
|
+
var DEFAULT_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
33902
34015
|
var envelopeSchema = external_exports.object({
|
|
33903
|
-
version: external_exports.literal(
|
|
34016
|
+
version: external_exports.literal(2),
|
|
33904
34017
|
kind: external_exports.string().min(1),
|
|
33905
34018
|
input: external_exports.unknown(),
|
|
33906
|
-
digest: external_exports.string().regex(/^[0-9a-f]{64}$/)
|
|
33907
|
-
|
|
33908
|
-
|
|
33909
|
-
|
|
33910
|
-
|
|
33911
|
-
|
|
33912
|
-
|
|
33913
|
-
|
|
33914
|
-
|
|
33915
|
-
|
|
33916
|
-
|
|
33917
|
-
|
|
33918
|
-
|
|
33919
|
-
|
|
34019
|
+
digest: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
34020
|
+
createdAt: external_exports.iso.datetime()
|
|
34021
|
+
});
|
|
34022
|
+
var proposalTokenSchema = external_exports.string().regex(TOKEN_PATTERN, "invalid proposal token format");
|
|
34023
|
+
function defaultProposalRoot() {
|
|
34024
|
+
const cadreHome = process.env.CADRE_HOME ? resolve10(process.env.CADRE_HOME) : join8(homedir2(), ".cadre");
|
|
34025
|
+
return join8(cadreHome, "runtime", "proposals");
|
|
34026
|
+
}
|
|
34027
|
+
var ProposalTokenStore = class {
|
|
34028
|
+
root;
|
|
34029
|
+
maxRetainedProposals;
|
|
34030
|
+
maxRetainedBytes;
|
|
34031
|
+
maxAgeMs;
|
|
34032
|
+
now;
|
|
34033
|
+
constructor(options = {}) {
|
|
34034
|
+
this.root = resolve10(options.root ?? defaultProposalRoot());
|
|
34035
|
+
this.maxRetainedProposals = options.maxRetainedProposals ?? DEFAULT_MAX_RETAINED_PROPOSALS;
|
|
34036
|
+
this.maxRetainedBytes = options.maxRetainedBytes ?? DEFAULT_MAX_RETAINED_BYTES;
|
|
34037
|
+
this.maxAgeMs = options.maxAgeMs ?? DEFAULT_MAX_AGE_MS;
|
|
34038
|
+
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
34039
|
+
if (!Number.isInteger(this.maxRetainedProposals) || this.maxRetainedProposals < 1) {
|
|
34040
|
+
throw new Error("maxRetainedProposals must be a positive integer");
|
|
34041
|
+
}
|
|
34042
|
+
if (!Number.isInteger(this.maxRetainedBytes) || this.maxRetainedBytes < MAX_PROPOSAL_BYTES) {
|
|
34043
|
+
throw new Error(`maxRetainedBytes must be at least ${MAX_PROPOSAL_BYTES}`);
|
|
34044
|
+
}
|
|
34045
|
+
if (!Number.isFinite(this.maxAgeMs) || this.maxAgeMs <= 0) {
|
|
34046
|
+
throw new Error("maxAgeMs must be positive");
|
|
34047
|
+
}
|
|
34048
|
+
}
|
|
34049
|
+
issue(kind, input, digest) {
|
|
34050
|
+
const createdAt = this.now().toISOString();
|
|
34051
|
+
const serialized = `${JSON.stringify({ version: 2, kind, input, digest, createdAt })}
|
|
34052
|
+
`;
|
|
34053
|
+
const bytes = Buffer.byteLength(serialized, "utf8");
|
|
34054
|
+
if (bytes > MAX_PROPOSAL_BYTES) throw new Error("proposal is too large");
|
|
34055
|
+
envelopeSchema.parse(JSON.parse(serialized));
|
|
34056
|
+
this.prepareRoot();
|
|
34057
|
+
this.makeRoom(bytes);
|
|
34058
|
+
for (; ; ) {
|
|
34059
|
+
const token = `${TOKEN_PREFIX}${randomBytes(24).toString("base64url")}`;
|
|
34060
|
+
const path = this.pathFor(token);
|
|
34061
|
+
let descriptor = null;
|
|
34062
|
+
try {
|
|
34063
|
+
descriptor = openSync(
|
|
34064
|
+
path,
|
|
34065
|
+
constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY | constants.O_NOFOLLOW,
|
|
34066
|
+
384
|
|
34067
|
+
);
|
|
34068
|
+
writeFileSync5(descriptor, serialized, "utf8");
|
|
34069
|
+
fsyncSync(descriptor);
|
|
34070
|
+
return token;
|
|
34071
|
+
} catch (error51) {
|
|
34072
|
+
if (error51.code !== "EEXIST") throw error51;
|
|
34073
|
+
} finally {
|
|
34074
|
+
if (descriptor !== null) closeSync(descriptor);
|
|
34075
|
+
}
|
|
34076
|
+
}
|
|
33920
34077
|
}
|
|
33921
|
-
|
|
33922
|
-
|
|
33923
|
-
|
|
33924
|
-
|
|
34078
|
+
resolve(kind, token) {
|
|
34079
|
+
if (!TOKEN_PATTERN.test(token)) throw new Error("invalid proposal token format");
|
|
34080
|
+
this.prepareRoot();
|
|
34081
|
+
const path = this.pathFor(token);
|
|
34082
|
+
if (!existsSync10(path)) {
|
|
34083
|
+
throw new Error(
|
|
34084
|
+
"proposal token is unknown or no longer retained; call the matching preview tool again"
|
|
34085
|
+
);
|
|
34086
|
+
}
|
|
34087
|
+
let descriptor = null;
|
|
34088
|
+
try {
|
|
34089
|
+
descriptor = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
34090
|
+
const stat = fstatSync(descriptor);
|
|
34091
|
+
if (!stat.isFile()) throw new Error("proposal token does not reference a regular runtime record");
|
|
34092
|
+
if ((stat.mode & 63) !== 0) throw new Error("proposal runtime record permissions are too broad");
|
|
34093
|
+
if (typeof process.getuid === "function" && stat.uid !== process.getuid()) {
|
|
34094
|
+
throw new Error("proposal runtime record is owned by another user");
|
|
34095
|
+
}
|
|
34096
|
+
if (stat.size > MAX_PROPOSAL_BYTES) throw new Error("proposal record is too large");
|
|
34097
|
+
const envelope = envelopeSchema.parse(JSON.parse(readFileSync8(descriptor, "utf8")));
|
|
34098
|
+
if (this.now().getTime() - Date.parse(envelope.createdAt) > this.maxAgeMs) {
|
|
34099
|
+
closeSync(descriptor);
|
|
34100
|
+
descriptor = null;
|
|
34101
|
+
this.unlinkRecord(path);
|
|
34102
|
+
throw new Error("proposal token has expired; call the matching preview tool again");
|
|
34103
|
+
}
|
|
34104
|
+
if (envelope.kind !== kind) throw new Error(`proposal token is for ${envelope.kind}, not ${kind}`);
|
|
34105
|
+
return { input: envelope.input, digest: envelope.digest };
|
|
34106
|
+
} catch (error51) {
|
|
34107
|
+
if (error51.code === "ELOOP") {
|
|
34108
|
+
throw new Error("refusing proposal token through a symbolic link");
|
|
34109
|
+
}
|
|
34110
|
+
if (error51.code === "ENOENT") {
|
|
34111
|
+
throw new Error(
|
|
34112
|
+
"proposal token is unknown or no longer retained; call the matching preview tool again"
|
|
34113
|
+
);
|
|
34114
|
+
}
|
|
34115
|
+
throw error51;
|
|
34116
|
+
} finally {
|
|
34117
|
+
if (descriptor !== null) closeSync(descriptor);
|
|
34118
|
+
}
|
|
34119
|
+
}
|
|
34120
|
+
prepareRoot() {
|
|
34121
|
+
mkdirSync4(this.root, { recursive: true, mode: 448 });
|
|
34122
|
+
const stat = lstatSync6(this.root);
|
|
34123
|
+
if (!stat.isDirectory() || stat.isSymbolicLink()) {
|
|
34124
|
+
throw new Error(`proposal runtime root is not a regular directory: ${this.root}`);
|
|
34125
|
+
}
|
|
34126
|
+
if (typeof process.getuid === "function" && stat.uid !== process.getuid()) {
|
|
34127
|
+
throw new Error(`proposal runtime root is owned by another user: ${this.root}`);
|
|
34128
|
+
}
|
|
34129
|
+
if ((stat.mode & 63) !== 0) chmodSync(this.root, 448);
|
|
34130
|
+
}
|
|
34131
|
+
pathFor(token) {
|
|
34132
|
+
return join8(this.root, `${token}.json`);
|
|
34133
|
+
}
|
|
34134
|
+
records() {
|
|
34135
|
+
const records = [];
|
|
34136
|
+
for (const entry of readdirSync7(this.root)) {
|
|
34137
|
+
if (!RECORD_PATTERN.test(entry)) continue;
|
|
34138
|
+
const path = join8(this.root, entry);
|
|
34139
|
+
let stat;
|
|
34140
|
+
try {
|
|
34141
|
+
stat = lstatSync6(path);
|
|
34142
|
+
} catch (error51) {
|
|
34143
|
+
if (error51.code === "ENOENT") continue;
|
|
34144
|
+
throw error51;
|
|
34145
|
+
}
|
|
34146
|
+
if (!stat.isFile() || stat.isSymbolicLink()) continue;
|
|
34147
|
+
let createdAt = stat.mtimeMs;
|
|
34148
|
+
try {
|
|
34149
|
+
const envelope = envelopeSchema.parse(JSON.parse(readFileSync8(path, "utf8")));
|
|
34150
|
+
createdAt = Date.parse(envelope.createdAt);
|
|
34151
|
+
} catch {
|
|
34152
|
+
}
|
|
34153
|
+
records.push({ path, bytes: stat.size, createdAt });
|
|
34154
|
+
}
|
|
34155
|
+
return records.sort((left, right) => left.createdAt - right.createdAt);
|
|
34156
|
+
}
|
|
34157
|
+
makeRoom(incomingBytes) {
|
|
34158
|
+
const now = this.now().getTime();
|
|
34159
|
+
let records = this.records();
|
|
34160
|
+
for (const record2 of records) {
|
|
34161
|
+
if (now - record2.createdAt <= this.maxAgeMs) continue;
|
|
34162
|
+
this.unlinkRecord(record2.path);
|
|
34163
|
+
}
|
|
34164
|
+
records = this.records();
|
|
34165
|
+
let retainedBytes = records.reduce((total, record2) => total + record2.bytes, 0);
|
|
34166
|
+
while (records.length >= this.maxRetainedProposals || retainedBytes + incomingBytes > this.maxRetainedBytes) {
|
|
34167
|
+
const oldest = records.shift();
|
|
34168
|
+
if (!oldest) break;
|
|
34169
|
+
this.unlinkRecord(oldest.path);
|
|
34170
|
+
retainedBytes -= oldest.bytes;
|
|
34171
|
+
}
|
|
34172
|
+
}
|
|
34173
|
+
unlinkRecord(path) {
|
|
34174
|
+
try {
|
|
34175
|
+
unlinkSync2(path);
|
|
34176
|
+
} catch (error51) {
|
|
34177
|
+
if (error51.code !== "ENOENT") throw error51;
|
|
34178
|
+
}
|
|
34179
|
+
}
|
|
34180
|
+
};
|
|
33925
34181
|
|
|
33926
34182
|
// src/mcp/server.ts
|
|
33927
34183
|
function result(value, summary) {
|
|
@@ -33930,11 +34186,15 @@ function result(value, summary) {
|
|
|
33930
34186
|
structuredContent: value
|
|
33931
34187
|
};
|
|
33932
34188
|
}
|
|
33933
|
-
function
|
|
33934
|
-
return
|
|
33935
|
-
|
|
33936
|
-
|
|
33937
|
-
}
|
|
34189
|
+
function sha256(content) {
|
|
34190
|
+
return createHash8("sha256").update(content).digest("hex");
|
|
34191
|
+
}
|
|
34192
|
+
function artifact(path, content) {
|
|
34193
|
+
return { path, sha256: sha256(content) };
|
|
34194
|
+
}
|
|
34195
|
+
function jsonArtifact(path, value) {
|
|
34196
|
+
return artifact(path, `${JSON.stringify(value, null, 2)}
|
|
34197
|
+
`);
|
|
33938
34198
|
}
|
|
33939
34199
|
function proposalInputSchema() {
|
|
33940
34200
|
return { proposalToken: proposalTokenSchema };
|
|
@@ -33971,6 +34231,13 @@ var PLAN_VALIDATION_STATUSES = [
|
|
|
33971
34231
|
];
|
|
33972
34232
|
var MAX_DRAFT_PLAN_CHARACTERS = 256 * 1024;
|
|
33973
34233
|
function createCadreServer() {
|
|
34234
|
+
const proposalTokens = new ProposalTokenStore();
|
|
34235
|
+
function proposalResult(kind, input, value) {
|
|
34236
|
+
return result({
|
|
34237
|
+
...value,
|
|
34238
|
+
proposalToken: proposalTokens.issue(kind, input, value.digest)
|
|
34239
|
+
});
|
|
34240
|
+
}
|
|
33974
34241
|
const server = new McpServer(
|
|
33975
34242
|
{ name: "cadre", version: CADRE_RUNTIME_VERSION },
|
|
33976
34243
|
{
|
|
@@ -34098,9 +34365,9 @@ function createCadreServer() {
|
|
|
34098
34365
|
}, async ({ projectRoot, trackId }) => {
|
|
34099
34366
|
try {
|
|
34100
34367
|
const root = safeProjectRoot(projectRoot);
|
|
34101
|
-
const statePath =
|
|
34102
|
-
const planPath =
|
|
34103
|
-
const state = JSON.parse(
|
|
34368
|
+
const statePath = join9(root, ".cadre", "tracks", trackId, "state.json");
|
|
34369
|
+
const planPath = join9(root, ".cadre", "tracks", trackId, "plan.md");
|
|
34370
|
+
const state = JSON.parse(readFileSync9(statePath, "utf8"));
|
|
34104
34371
|
const errors = [];
|
|
34105
34372
|
const graph = parsePlan(planPath, errors);
|
|
34106
34373
|
validatePlanGraph(planPath, graph, state.status ?? "planned", errors);
|
|
@@ -34144,7 +34411,18 @@ function createCadreServer() {
|
|
|
34144
34411
|
}, async (input) => {
|
|
34145
34412
|
try {
|
|
34146
34413
|
const derived = deriveReviewCompleteInput(input);
|
|
34147
|
-
|
|
34414
|
+
const preview = previewReviewComplete(derived);
|
|
34415
|
+
return proposalResult("review_complete", derived, {
|
|
34416
|
+
digest: preview.digest,
|
|
34417
|
+
trackId: derived.trackId,
|
|
34418
|
+
reviewedHead: derived.reviewedHead,
|
|
34419
|
+
commitRange: derived.commitRange,
|
|
34420
|
+
targetStatus: preview.state.status,
|
|
34421
|
+
files: [
|
|
34422
|
+
jsonArtifact(preview.statePath, preview.state),
|
|
34423
|
+
artifact(preview.tracksPath, preview.tracksContent)
|
|
34424
|
+
]
|
|
34425
|
+
});
|
|
34148
34426
|
} catch (error51) {
|
|
34149
34427
|
return failure(error51);
|
|
34150
34428
|
}
|
|
@@ -34156,8 +34434,18 @@ function createCadreServer() {
|
|
|
34156
34434
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
|
|
34157
34435
|
}, async ({ proposalToken }) => {
|
|
34158
34436
|
try {
|
|
34159
|
-
const proposal =
|
|
34160
|
-
|
|
34437
|
+
const proposal = proposalTokens.resolve("review_complete", proposalToken);
|
|
34438
|
+
const applied = applyReviewComplete(proposal.input, proposal.digest);
|
|
34439
|
+
return result({
|
|
34440
|
+
trackId: proposal.input.trackId,
|
|
34441
|
+
status: applied.state.status,
|
|
34442
|
+
files: [
|
|
34443
|
+
jsonArtifact(applied.statePath, applied.state),
|
|
34444
|
+
artifact(applied.tracksPath, applied.tracksContent)
|
|
34445
|
+
],
|
|
34446
|
+
valid: applied.valid,
|
|
34447
|
+
derivedStateCurrent: applied.derivedStateCurrent
|
|
34448
|
+
});
|
|
34161
34449
|
} catch (error51) {
|
|
34162
34450
|
return failure(error51);
|
|
34163
34451
|
}
|
|
@@ -34183,7 +34471,23 @@ function createCadreServer() {
|
|
|
34183
34471
|
}, async (input) => {
|
|
34184
34472
|
try {
|
|
34185
34473
|
const derived = deriveArchiveBatchInput(input);
|
|
34186
|
-
|
|
34474
|
+
const preview = previewArchiveBatch(derived);
|
|
34475
|
+
return proposalResult("archive_batch", derived, {
|
|
34476
|
+
digest: preview.digest,
|
|
34477
|
+
batchId: derived.batchId,
|
|
34478
|
+
selectedTracks: derived.selectedTracks,
|
|
34479
|
+
operationPath: preview.operationPath,
|
|
34480
|
+
checkpoint: preview.operation.checkpoint,
|
|
34481
|
+
resuming: preview.resuming,
|
|
34482
|
+
moves: preview.moves.map(({ trackId, sourcePath, targetPath, needsMove }) => ({
|
|
34483
|
+
trackId,
|
|
34484
|
+
sourcePath,
|
|
34485
|
+
targetPath,
|
|
34486
|
+
needsMove
|
|
34487
|
+
})),
|
|
34488
|
+
writes: preview.writes.map((write) => artifact(write.path, write.content)),
|
|
34489
|
+
tracks: artifact(preview.tracksPath, preview.tracksContent)
|
|
34490
|
+
});
|
|
34187
34491
|
} catch (error51) {
|
|
34188
34492
|
return failure(error51);
|
|
34189
34493
|
}
|
|
@@ -34195,8 +34499,19 @@ function createCadreServer() {
|
|
|
34195
34499
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
|
|
34196
34500
|
}, async ({ proposalToken }) => {
|
|
34197
34501
|
try {
|
|
34198
|
-
const proposal =
|
|
34199
|
-
|
|
34502
|
+
const proposal = proposalTokens.resolve("archive_batch", proposalToken);
|
|
34503
|
+
const applied = applyArchiveBatch(proposal.input, proposal.digest);
|
|
34504
|
+
return result({
|
|
34505
|
+
batchId: proposal.input.batchId,
|
|
34506
|
+
selectedTracks: proposal.input.selectedTracks,
|
|
34507
|
+
operationPath: applied.operationPath,
|
|
34508
|
+
checkpoint: applied.operation.checkpoint,
|
|
34509
|
+
moves: applied.moves.map(({ trackId, targetPath }) => ({ trackId, targetPath })),
|
|
34510
|
+
writes: applied.writes.map((write) => artifact(write.path, write.content)),
|
|
34511
|
+
tracks: artifact(applied.tracksPath, applied.tracksContent),
|
|
34512
|
+
valid: applied.valid,
|
|
34513
|
+
derivedStateCurrent: applied.derivedStateCurrent
|
|
34514
|
+
});
|
|
34200
34515
|
} catch (error51) {
|
|
34201
34516
|
return failure(error51);
|
|
34202
34517
|
}
|
|
@@ -34213,7 +34528,18 @@ function createCadreServer() {
|
|
|
34213
34528
|
}, async (input) => {
|
|
34214
34529
|
try {
|
|
34215
34530
|
const derived = deriveArchiveBatchRecordInput(input);
|
|
34216
|
-
|
|
34531
|
+
const preview = previewArchiveBatchRecord(derived);
|
|
34532
|
+
return proposalResult("archive_batch_record", derived, {
|
|
34533
|
+
digest: preview.digest,
|
|
34534
|
+
batchId: derived.batchId,
|
|
34535
|
+
archiveCommit: derived.archiveCommit,
|
|
34536
|
+
checkpoint: preview.operation.checkpoint,
|
|
34537
|
+
files: [
|
|
34538
|
+
jsonArtifact(preview.operationPath, preview.operation),
|
|
34539
|
+
jsonArtifact(preview.projectPath, preview.project),
|
|
34540
|
+
...preview.states.map((state) => jsonArtifact(state.path, state.state))
|
|
34541
|
+
]
|
|
34542
|
+
});
|
|
34217
34543
|
} catch (error51) {
|
|
34218
34544
|
return failure(error51);
|
|
34219
34545
|
}
|
|
@@ -34225,8 +34551,20 @@ function createCadreServer() {
|
|
|
34225
34551
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
|
|
34226
34552
|
}, async ({ proposalToken }) => {
|
|
34227
34553
|
try {
|
|
34228
|
-
const proposal =
|
|
34229
|
-
|
|
34554
|
+
const proposal = proposalTokens.resolve("archive_batch_record", proposalToken);
|
|
34555
|
+
const applied = applyArchiveBatchRecord(proposal.input, proposal.digest);
|
|
34556
|
+
return result({
|
|
34557
|
+
batchId: proposal.input.batchId,
|
|
34558
|
+
archiveCommit: proposal.input.archiveCommit,
|
|
34559
|
+
checkpoint: applied.operation.checkpoint,
|
|
34560
|
+
files: [
|
|
34561
|
+
jsonArtifact(applied.operationPath, applied.operation),
|
|
34562
|
+
jsonArtifact(applied.projectPath, applied.project),
|
|
34563
|
+
...applied.states.map((state) => jsonArtifact(state.path, state.state))
|
|
34564
|
+
],
|
|
34565
|
+
valid: applied.valid,
|
|
34566
|
+
derivedStateCurrent: applied.derivedStateCurrent
|
|
34567
|
+
});
|
|
34230
34568
|
} catch (error51) {
|
|
34231
34569
|
return failure(error51);
|
|
34232
34570
|
}
|
|
@@ -34246,7 +34584,23 @@ function createCadreServer() {
|
|
|
34246
34584
|
}, async (input) => {
|
|
34247
34585
|
try {
|
|
34248
34586
|
const derived = deriveExecutionStartInput(input);
|
|
34249
|
-
|
|
34587
|
+
const preview = previewExecutionStart(derived);
|
|
34588
|
+
return proposalResult("execution_start", derived, {
|
|
34589
|
+
digest: preview.digest,
|
|
34590
|
+
journalPath: preview.journalPath,
|
|
34591
|
+
statePath: preview.statePath,
|
|
34592
|
+
execution: {
|
|
34593
|
+
executionId: preview.journal.executionId,
|
|
34594
|
+
trackId: preview.journal.trackId,
|
|
34595
|
+
checkpoint: preview.journal.checkpoint,
|
|
34596
|
+
requestedMode: preview.journal.requestedMode,
|
|
34597
|
+
effectiveMode: preview.journal.effectiveMode,
|
|
34598
|
+
approvalMode: preview.journal.approvalMode,
|
|
34599
|
+
maxWorkers: preview.journal.maxWorkers,
|
|
34600
|
+
nodeCount: Object.keys(preview.journal.nodes).length
|
|
34601
|
+
},
|
|
34602
|
+
derivedStatus: executionSchedulerView(preview.journal)
|
|
34603
|
+
});
|
|
34250
34604
|
} catch (error51) {
|
|
34251
34605
|
return failure(error51);
|
|
34252
34606
|
}
|
|
@@ -34258,8 +34612,19 @@ function createCadreServer() {
|
|
|
34258
34612
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
|
|
34259
34613
|
}, async ({ proposalToken }) => {
|
|
34260
34614
|
try {
|
|
34261
|
-
const proposal =
|
|
34262
|
-
|
|
34615
|
+
const proposal = proposalTokens.resolve("execution_start", proposalToken);
|
|
34616
|
+
const applied = applyExecutionStart(proposal.input, proposal.digest);
|
|
34617
|
+
return result({
|
|
34618
|
+
journalPath: applied.journalPath,
|
|
34619
|
+
statePath: applied.statePath,
|
|
34620
|
+
execution: {
|
|
34621
|
+
executionId: applied.journal.executionId,
|
|
34622
|
+
trackId: applied.journal.trackId,
|
|
34623
|
+
checkpoint: applied.journal.checkpoint,
|
|
34624
|
+
nodeCount: Object.keys(applied.journal.nodes).length
|
|
34625
|
+
},
|
|
34626
|
+
derivedStatus: executionSchedulerView(applied.journal)
|
|
34627
|
+
});
|
|
34263
34628
|
} catch (error51) {
|
|
34264
34629
|
return failure(error51);
|
|
34265
34630
|
}
|
|
@@ -34288,10 +34653,16 @@ function createCadreServer() {
|
|
|
34288
34653
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34289
34654
|
}, async (input) => {
|
|
34290
34655
|
try {
|
|
34656
|
+
const preview = previewExecutionCheckpoint(input);
|
|
34291
34657
|
return proposalResult(
|
|
34292
34658
|
"execution_checkpoint",
|
|
34293
34659
|
input,
|
|
34294
|
-
|
|
34660
|
+
{
|
|
34661
|
+
path: preview.path,
|
|
34662
|
+
digest: preview.digest,
|
|
34663
|
+
transition: preview.transition,
|
|
34664
|
+
checkpoint: preview.journal.checkpoint
|
|
34665
|
+
}
|
|
34295
34666
|
);
|
|
34296
34667
|
} catch (error51) {
|
|
34297
34668
|
return failure(error51);
|
|
@@ -34304,8 +34675,14 @@ function createCadreServer() {
|
|
|
34304
34675
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
|
|
34305
34676
|
}, async ({ proposalToken }) => {
|
|
34306
34677
|
try {
|
|
34307
|
-
const proposal =
|
|
34308
|
-
|
|
34678
|
+
const proposal = proposalTokens.resolve("execution_checkpoint", proposalToken);
|
|
34679
|
+
const applied = applyExecutionCheckpoint(proposal.input, proposal.digest);
|
|
34680
|
+
return result({
|
|
34681
|
+
path: applied.path,
|
|
34682
|
+
transition: applied.transition,
|
|
34683
|
+
checkpoint: applied.journal.checkpoint,
|
|
34684
|
+
derivedStatus: executionSchedulerView(applied.journal, [proposal.input.nodeId])
|
|
34685
|
+
});
|
|
34309
34686
|
} catch (error51) {
|
|
34310
34687
|
return failure(error51);
|
|
34311
34688
|
}
|
|
@@ -34316,12 +34693,14 @@ function createCadreServer() {
|
|
|
34316
34693
|
inputSchema: {
|
|
34317
34694
|
projectRoot: external_exports.string().min(1),
|
|
34318
34695
|
trackId: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
34319
|
-
executionId: external_exports.string().regex(/^[0-9A-Za-z]+(?:-[0-9A-Za-z]+)*$/)
|
|
34696
|
+
executionId: external_exports.string().regex(/^[0-9A-Za-z]+(?:-[0-9A-Za-z]+)*$/),
|
|
34697
|
+
nodeId: external_exports.string().regex(/^(?:P\d+|T\d+\.\d+)$/).optional()
|
|
34320
34698
|
},
|
|
34321
34699
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34322
34700
|
}, async (input) => {
|
|
34323
34701
|
try {
|
|
34324
|
-
|
|
34702
|
+
const status = executionStatus(input.projectRoot, input.trackId, input.executionId);
|
|
34703
|
+
return result(compactExecutionStatus(status.journal, input.nodeId));
|
|
34325
34704
|
} catch (error51) {
|
|
34326
34705
|
return failure(error51);
|
|
34327
34706
|
}
|
|
@@ -34339,7 +34718,20 @@ function createCadreServer() {
|
|
|
34339
34718
|
}, async (input) => {
|
|
34340
34719
|
try {
|
|
34341
34720
|
const derived = deriveExecutionFinishInput(input);
|
|
34342
|
-
|
|
34721
|
+
const preview = previewExecutionFinish(derived);
|
|
34722
|
+
return proposalResult("execution_finish", derived, {
|
|
34723
|
+
digest: preview.digest,
|
|
34724
|
+
executionId: derived.executionId,
|
|
34725
|
+
targetStatus: preview.state.status,
|
|
34726
|
+
headCommit: derived.headCommit,
|
|
34727
|
+
completedAt: derived.completedAt,
|
|
34728
|
+
files: [
|
|
34729
|
+
jsonArtifact(preview.journalPath, preview.journal),
|
|
34730
|
+
jsonArtifact(preview.statePath, preview.state),
|
|
34731
|
+
artifact(preview.planPath, preview.planContent),
|
|
34732
|
+
artifact(preview.tracksPath, preview.tracksContent)
|
|
34733
|
+
]
|
|
34734
|
+
});
|
|
34343
34735
|
} catch (error51) {
|
|
34344
34736
|
return failure(error51);
|
|
34345
34737
|
}
|
|
@@ -34351,8 +34743,20 @@ function createCadreServer() {
|
|
|
34351
34743
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
|
|
34352
34744
|
}, async ({ proposalToken }) => {
|
|
34353
34745
|
try {
|
|
34354
|
-
const proposal =
|
|
34355
|
-
|
|
34746
|
+
const proposal = proposalTokens.resolve("execution_finish", proposalToken);
|
|
34747
|
+
const applied = applyExecutionFinish(proposal.input, proposal.digest);
|
|
34748
|
+
return result({
|
|
34749
|
+
executionId: proposal.input.executionId,
|
|
34750
|
+
status: applied.journal.status,
|
|
34751
|
+
checkpoint: applied.journal.checkpoint,
|
|
34752
|
+
headCommit: applied.journal.headCommit,
|
|
34753
|
+
files: [
|
|
34754
|
+
jsonArtifact(applied.journalPath, applied.journal),
|
|
34755
|
+
jsonArtifact(applied.statePath, applied.state),
|
|
34756
|
+
artifact(applied.planPath, applied.planContent),
|
|
34757
|
+
artifact(applied.tracksPath, applied.tracksContent)
|
|
34758
|
+
]
|
|
34759
|
+
});
|
|
34356
34760
|
} catch (error51) {
|
|
34357
34761
|
return failure(error51);
|
|
34358
34762
|
}
|
|
@@ -34382,7 +34786,7 @@ function createCadreServer() {
|
|
|
34382
34786
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
34383
34787
|
}, async ({ proposalToken }) => {
|
|
34384
34788
|
try {
|
|
34385
|
-
const proposal =
|
|
34789
|
+
const proposal = proposalTokens.resolve("worktree_create", proposalToken);
|
|
34386
34790
|
return result(applyWorktreeCreate(proposal.input, proposal.digest));
|
|
34387
34791
|
} catch (error51) {
|
|
34388
34792
|
return failure(error51);
|
|
@@ -34407,7 +34811,7 @@ function createCadreServer() {
|
|
|
34407
34811
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
|
|
34408
34812
|
}, async ({ proposalToken }) => {
|
|
34409
34813
|
try {
|
|
34410
|
-
const proposal =
|
|
34814
|
+
const proposal = proposalTokens.resolve("worktree_integrate", proposalToken);
|
|
34411
34815
|
return result(applyWorktreeIntegration(proposal.input, proposal.digest));
|
|
34412
34816
|
} catch (error51) {
|
|
34413
34817
|
return failure(error51);
|
|
@@ -34432,7 +34836,7 @@ function createCadreServer() {
|
|
|
34432
34836
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false }
|
|
34433
34837
|
}, async ({ proposalToken }) => {
|
|
34434
34838
|
try {
|
|
34435
|
-
const proposal =
|
|
34839
|
+
const proposal = proposalTokens.resolve("worktree_cleanup", proposalToken);
|
|
34436
34840
|
return result(applyWorktreeCleanup(proposal.input, proposal.digest));
|
|
34437
34841
|
} catch (error51) {
|
|
34438
34842
|
return failure(error51);
|
|
@@ -34467,7 +34871,13 @@ function createCadreServer() {
|
|
|
34467
34871
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
34468
34872
|
}, async (input) => {
|
|
34469
34873
|
try {
|
|
34470
|
-
|
|
34874
|
+
const preview = previewProjectInit(input);
|
|
34875
|
+
return proposalResult("project_init", input, {
|
|
34876
|
+
runtimeVersion: preview.runtimeVersion,
|
|
34877
|
+
templateSetVersion: preview.templateSetVersion,
|
|
34878
|
+
files: preview.files.map(({ path, sha256: digest }) => ({ path, sha256: digest })),
|
|
34879
|
+
digest: preview.digest
|
|
34880
|
+
});
|
|
34471
34881
|
} catch (error51) {
|
|
34472
34882
|
return failure(error51);
|
|
34473
34883
|
}
|
|
@@ -34479,8 +34889,14 @@ function createCadreServer() {
|
|
|
34479
34889
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
|
|
34480
34890
|
}, async ({ proposalToken }) => {
|
|
34481
34891
|
try {
|
|
34482
|
-
const proposal =
|
|
34483
|
-
|
|
34892
|
+
const proposal = proposalTokens.resolve("project_init", proposalToken);
|
|
34893
|
+
const applied = applyProjectInit(proposal.input, proposal.digest);
|
|
34894
|
+
return result({
|
|
34895
|
+
runtimeVersion: applied.runtimeVersion,
|
|
34896
|
+
templateSetVersion: applied.templateSetVersion,
|
|
34897
|
+
files: applied.files.map(({ path, sha256: digest }) => ({ path, sha256: digest })),
|
|
34898
|
+
digest: applied.digest
|
|
34899
|
+
});
|
|
34484
34900
|
} catch (error51) {
|
|
34485
34901
|
return failure(error51);
|
|
34486
34902
|
}
|
|
@@ -34518,7 +34934,12 @@ function createCadreServer() {
|
|
|
34518
34934
|
}, async ({ projectRoot }) => {
|
|
34519
34935
|
try {
|
|
34520
34936
|
const input = { projectRoot: safeProjectRoot(projectRoot) };
|
|
34521
|
-
|
|
34937
|
+
const preview = renderTracksPreview(input.projectRoot);
|
|
34938
|
+
return proposalResult("tracks_render", input, {
|
|
34939
|
+
path: preview.path,
|
|
34940
|
+
sha256: sha256(preview.content),
|
|
34941
|
+
digest: preview.digest
|
|
34942
|
+
});
|
|
34522
34943
|
} catch (error51) {
|
|
34523
34944
|
return failure(error51);
|
|
34524
34945
|
}
|
|
@@ -34530,7 +34951,7 @@ function createCadreServer() {
|
|
|
34530
34951
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
|
|
34531
34952
|
}, async ({ proposalToken }) => {
|
|
34532
34953
|
try {
|
|
34533
|
-
const proposal =
|
|
34954
|
+
const proposal = proposalTokens.resolve("tracks_render", proposalToken);
|
|
34534
34955
|
return result({ path: writeTracks(proposal.input.projectRoot, proposal.digest) });
|
|
34535
34956
|
} catch (error51) {
|
|
34536
34957
|
return failure(error51);
|
|
@@ -34542,7 +34963,7 @@ async function runCadreServer() {
|
|
|
34542
34963
|
const server = createCadreServer();
|
|
34543
34964
|
await server.connect(new StdioServerTransport());
|
|
34544
34965
|
}
|
|
34545
|
-
if (process.argv[1] && import.meta.url === pathToFileURL(
|
|
34966
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(resolve11(process.argv[1])).href) {
|
|
34546
34967
|
runCadreServer().catch((error51) => {
|
|
34547
34968
|
process.stderr.write(`${error51 instanceof Error ? error51.message : String(error51)}
|
|
34548
34969
|
`);
|
package/package.json
CHANGED
|
@@ -49,7 +49,7 @@ Before creating workers, inspect the approved plan, repository scripts, lockfile
|
|
|
49
49
|
|
|
50
50
|
## Schedule the DAG
|
|
51
51
|
|
|
52
|
-
The Cadre tools named in this skill are declared contracts: call them directly. Do not list the global tool catalog, rediscover schemas, or probe previews to learn legal transitions. Call `execution_status` when resuming or when no mutation response is available. Use `execution_checkpoint_preview` with a semantic event (`start`, `record_commit`, `record_integration`, `record_verification`, `complete`, `block`, or `resume`); it expands the event into all required legal transitions. Pass only its `proposalToken` to `execution_checkpoint_apply`, then reuse the returned `derivedStatus
|
|
52
|
+
The Cadre tools named in this skill are declared contracts: call them directly. Do not list the global tool catalog, rediscover schemas, or probe previews to learn legal transitions. Call compact `execution_status` when resuming or when no mutation response is available; pass `nodeId` only when focused detail is required. Use `execution_checkpoint_preview` with a semantic event (`start`, `record_commit`, `record_integration`, `record_verification`, `complete`, `block`, or `resume`); it expands the event into all required legal transitions and returns a compact receipt. Pass only its `proposalToken` to `execution_checkpoint_apply`, then reuse the returned compact `derivedStatus`; do not request the complete journal after each event.
|
|
53
53
|
|
|
54
54
|
Never checkpoint evidence before it exists. `record_commit` consumes the verified commit and its authorization; `record_integration` consumes the merge commit and post-merge verification; `record_verification` records a manual barrier. Plan display order breaks scheduling ties only.
|
|
55
55
|
|