@isaacriehm/cairn-core 0.7.3 → 0.9.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/dist/.tsbuildinfo +1 -1
- package/dist/attention/bulk-accept.d.ts +0 -2
- package/dist/attention/bulk-accept.js +0 -3
- package/dist/attention/bulk-accept.js.map +1 -1
- package/dist/attention/scoring.d.ts +1 -3
- package/dist/attention/scoring.js +1 -12
- package/dist/attention/scoring.js.map +1 -1
- package/dist/claude/cache.js +1 -0
- package/dist/claude/cache.js.map +1 -1
- package/dist/claude/runner.js +25 -1
- package/dist/claude/runner.js.map +1 -1
- package/dist/claude/types.d.ts +8 -0
- package/dist/doctor/index.js +57 -0
- package/dist/doctor/index.js.map +1 -1
- package/dist/gc/citation-integrity.js +3 -1
- package/dist/gc/citation-integrity.js.map +1 -1
- package/dist/gc/doc-claims.d.ts +31 -0
- package/dist/gc/doc-claims.js +213 -0
- package/dist/gc/doc-claims.js.map +1 -0
- package/dist/gc/doc-source-drift.d.ts +31 -0
- package/dist/gc/doc-source-drift.js +190 -0
- package/dist/gc/doc-source-drift.js.map +1 -0
- package/dist/gc/index.d.ts +4 -0
- package/dist/gc/index.js +2 -0
- package/dist/gc/index.js.map +1 -1
- package/dist/gc/sweep.js +18 -0
- package/dist/gc/sweep.js.map +1 -1
- package/dist/gc/types.d.ts +2 -2
- package/dist/hooks/runners/context-threshold.d.ts +63 -0
- package/dist/hooks/runners/context-threshold.js +179 -0
- package/dist/hooks/runners/context-threshold.js.map +1 -0
- package/dist/hooks/runners/gc-autotrigger.d.ts +49 -0
- package/dist/hooks/runners/gc-autotrigger.js +87 -0
- package/dist/hooks/runners/gc-autotrigger.js.map +1 -0
- package/dist/hooks/runners/index.d.ts +2 -0
- package/dist/hooks/runners/index.js +1 -0
- package/dist/hooks/runners/index.js.map +1 -1
- package/dist/hooks/runners/payload.d.ts +10 -0
- package/dist/hooks/runners/payload.js +13 -0
- package/dist/hooks/runners/payload.js.map +1 -1
- package/dist/hooks/runners/session-end.js +2 -4
- package/dist/hooks/runners/session-end.js.map +1 -1
- package/dist/hooks/runners/session-start.js +157 -9
- package/dist/hooks/runners/session-start.js.map +1 -1
- package/dist/hooks/runners/stop.js +119 -0
- package/dist/hooks/runners/stop.js.map +1 -1
- package/dist/init/brand-derive.js +6 -1
- package/dist/init/brand-derive.js.map +1 -1
- package/dist/init/brand-setup.d.ts +12 -1
- package/dist/init/brand-setup.js +36 -1
- package/dist/init/brand-setup.js.map +1 -1
- package/dist/init/curator/corpus.d.ts +92 -0
- package/dist/init/curator/corpus.js +171 -0
- package/dist/init/curator/corpus.js.map +1 -0
- package/dist/init/curator/emit.d.ts +42 -0
- package/dist/init/curator/emit.js +230 -0
- package/dist/init/curator/emit.js.map +1 -0
- package/dist/init/curator/index.d.ts +1 -0
- package/dist/init/curator/index.js +2 -0
- package/dist/init/curator/index.js.map +1 -0
- package/dist/init/curator/regex-prefilter.d.ts +54 -0
- package/dist/init/curator/regex-prefilter.js +185 -0
- package/dist/init/curator/regex-prefilter.js.map +1 -0
- package/dist/init/curator/validate.d.ts +46 -0
- package/dist/init/curator/validate.js +100 -0
- package/dist/init/curator/validate.js.map +1 -0
- package/dist/init/curator/walker.d.ts +36 -0
- package/dist/init/curator/walker.js +380 -0
- package/dist/init/curator/walker.js.map +1 -0
- package/dist/init/eta-calibration.d.ts +39 -0
- package/dist/init/eta-calibration.js +143 -0
- package/dist/init/eta-calibration.js.map +1 -0
- package/dist/init/index.d.ts +8 -3
- package/dist/init/index.js +4 -1
- package/dist/init/index.js.map +1 -1
- package/dist/init/ingest-docs.d.ts +6 -1
- package/dist/init/ingest-docs.js.map +1 -1
- package/dist/init/init.js +15 -26
- package/dist/init/init.js.map +1 -1
- package/dist/init/mapper-merge.d.ts +4 -6
- package/dist/init/mapper-merge.js +11 -34
- package/dist/init/mapper-merge.js.map +1 -1
- package/dist/init/mapper-parallel.d.ts +0 -1
- package/dist/init/mapper-parallel.js +20 -12
- package/dist/init/mapper-parallel.js.map +1 -1
- package/dist/init/mapper-prompts.d.ts +1 -4
- package/dist/init/mapper-prompts.js +2 -6
- package/dist/init/mapper-prompts.js.map +1 -1
- package/dist/init/mapper.d.ts +8 -7
- package/dist/init/mapper.js +23 -15
- package/dist/init/mapper.js.map +1 -1
- package/dist/init/overlay.js +0 -1
- package/dist/init/overlay.js.map +1 -1
- package/dist/init/phases/1-detect.d.ts +17 -4
- package/dist/init/phases/1-detect.js +48 -4
- package/dist/init/phases/1-detect.js.map +1 -1
- package/dist/init/phases/10-rules-merge.d.ts +7 -2
- package/dist/init/phases/10-rules-merge.js +17 -32
- package/dist/init/phases/10-rules-merge.js.map +1 -1
- package/dist/init/phases/11-baseline.js.map +1 -1
- package/dist/init/phases/12-strip.js +14 -1
- package/dist/init/phases/12-strip.js.map +1 -1
- package/dist/init/phases/13-multidev.d.ts +5 -1
- package/dist/init/phases/13-multidev.js +23 -2
- package/dist/init/phases/13-multidev.js.map +1 -1
- package/dist/init/phases/3-mapper.js.map +1 -1
- package/dist/init/phases/4-seed.js +2 -3
- package/dist/init/phases/4-seed.js.map +1 -1
- package/dist/init/phases/5-preflight.d.ts +42 -0
- package/dist/init/phases/5-preflight.js +244 -0
- package/dist/init/phases/5-preflight.js.map +1 -0
- package/dist/init/phases/6-brand.js +2 -4
- package/dist/init/phases/6-brand.js.map +1 -1
- package/dist/init/phases/7-topic-index.d.ts +6 -0
- package/dist/init/phases/7-topic-index.js +13 -0
- package/dist/init/phases/7-topic-index.js.map +1 -1
- package/dist/init/phases/8-docs-ingest.d.ts +6 -5
- package/dist/init/phases/8-docs-ingest.js +16 -43
- package/dist/init/phases/8-docs-ingest.js.map +1 -1
- package/dist/init/phases/9a-walker.d.ts +15 -0
- package/dist/init/phases/9a-walker.js +63 -0
- package/dist/init/phases/9a-walker.js.map +1 -0
- package/dist/init/phases/9b-curate.d.ts +19 -0
- package/dist/init/phases/9b-curate.js +79 -0
- package/dist/init/phases/9b-curate.js.map +1 -0
- package/dist/init/phases/9c-emit.d.ts +13 -0
- package/dist/init/phases/9c-emit.js +57 -0
- package/dist/init/phases/9c-emit.js.map +1 -0
- package/dist/init/phases/index.d.ts +6 -5
- package/dist/init/phases/index.js +4 -4
- package/dist/init/phases/index.js.map +1 -1
- package/dist/init/phases/mapper-output-io.d.ts +5 -5
- package/dist/init/phases/mapper-output-io.js +5 -5
- package/dist/init/phases/orchestrator.d.ts +10 -0
- package/dist/init/phases/orchestrator.js +13 -1
- package/dist/init/phases/orchestrator.js.map +1 -1
- package/dist/init/phases/state-io.js +1 -1
- package/dist/init/phases/types.d.ts +115 -9
- package/dist/init/phases/types.js +4 -2
- package/dist/init/phases/types.js.map +1 -1
- package/dist/init/post-git-init.d.ts +53 -0
- package/dist/init/post-git-init.js +74 -0
- package/dist/init/post-git-init.js.map +1 -0
- package/dist/init/preflight-guards.d.ts +11 -2
- package/dist/init/preflight-guards.js +27 -5
- package/dist/init/preflight-guards.js.map +1 -1
- package/dist/init/rules-merge/index.d.ts +1 -1
- package/dist/init/rules-merge/ingest.d.ts +6 -1
- package/dist/init/rules-merge/ingest.js.map +1 -1
- package/dist/init/skill-budget.d.ts +39 -0
- package/dist/init/skill-budget.js +99 -0
- package/dist/init/skill-budget.js.map +1 -0
- package/dist/init/source-comments/ingest.d.ts +0 -2
- package/dist/init/source-comments/ingest.js.map +1 -1
- package/dist/init/source-comments/walker.js +2 -2
- package/dist/init/topic-index/index.d.ts +8 -0
- package/dist/init/topic-index/index.js +10 -2
- package/dist/init/topic-index/index.js.map +1 -1
- package/dist/init/topic-index/judge.d.ts +15 -0
- package/dist/init/topic-index/judge.js +15 -1
- package/dist/init/topic-index/judge.js.map +1 -1
- package/dist/init/topic-index/resolve.js +41 -14
- package/dist/init/topic-index/resolve.js.map +1 -1
- package/dist/init/types.d.ts +9 -0
- package/dist/init/walker.d.ts +1 -1
- package/dist/init/walker.js +1 -1
- package/dist/init/workflow-block.d.ts +5 -6
- package/dist/init/workflow-block.js +5 -9
- package/dist/init/workflow-block.js.map +1 -1
- package/dist/mcp/bootstrap-guard.js +2 -2
- package/dist/mcp/bootstrap-guard.js.map +1 -1
- package/dist/mcp/schemas.d.ts +34 -0
- package/dist/mcp/schemas.js +50 -0
- package/dist/mcp/schemas.js.map +1 -1
- package/dist/mcp/telemetry.d.ts +1 -1
- package/dist/mcp/tools/bootstrap-retry.d.ts +23 -0
- package/dist/mcp/tools/bootstrap-retry.js +53 -0
- package/dist/mcp/tools/bootstrap-retry.js.map +1 -0
- package/dist/mcp/tools/bulk-accept-attention.d.ts +1 -1
- package/dist/mcp/tools/bulk-accept-attention.js +4 -6
- package/dist/mcp/tools/bulk-accept-attention.js.map +1 -1
- package/dist/mcp/tools/index.js +10 -0
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/init-phases.d.ts +7 -6
- package/dist/mcp/tools/init-phases.js +36 -65
- package/dist/mcp/tools/init-phases.js.map +1 -1
- package/dist/mcp/tools/resume.d.ts +21 -0
- package/dist/mcp/tools/resume.js +88 -0
- package/dist/mcp/tools/resume.js.map +1 -0
- package/dist/mcp/tools/task-complete.d.ts +23 -0
- package/dist/mcp/tools/task-complete.js +51 -0
- package/dist/mcp/tools/task-complete.js.map +1 -0
- package/dist/mcp/tools/task-create.js +17 -11
- package/dist/mcp/tools/task-create.js.map +1 -1
- package/dist/mcp/tools/task-journal-append.d.ts +22 -0
- package/dist/mcp/tools/task-journal-append.js +44 -0
- package/dist/mcp/tools/task-journal-append.js.map +1 -0
- package/dist/paths/index.js +1 -1
- package/dist/paths/index.js.map +1 -1
- package/dist/status-line/format.js +20 -0
- package/dist/status-line/format.js.map +1 -1
- package/dist/tasks/index.d.ts +2 -0
- package/dist/tasks/index.js +2 -0
- package/dist/tasks/index.js.map +1 -0
- package/dist/tasks/lifecycle.d.ts +107 -0
- package/dist/tasks/lifecycle.js +302 -0
- package/dist/tasks/lifecycle.js.map +1 -0
- package/dist/trace/index.d.ts +1 -1
- package/dist/trace/index.js +2 -2
- package/dist/trace/index.js.map +1 -1
- package/package.json +2 -2
- package/templates/.cairn/config/trust-policy.yaml +0 -3
- package/templates/.cairn/config/workflow.md +0 -1
- package/templates/.cairn/ground/canonical-map/topics.yaml +0 -12
- package/dist/init/phases/5-pilot.d.ts +0 -10
- package/dist/init/phases/5-pilot.js +0 -108
- package/dist/init/phases/5-pilot.js.map +0 -1
- package/dist/init/phases/9-source-comments.d.ts +0 -6
- package/dist/init/phases/9-source-comments.js +0 -55
- package/dist/init/phases/9-source-comments.js.map +0 -1
- package/dist/init/phases/parallel-8910.d.ts +0 -27
- package/dist/init/phases/parallel-8910.js +0 -172
- package/dist/init/phases/parallel-8910.js.map +0 -1
- package/dist/init/phases/source-comments-output-io.d.ts +0 -84
- package/dist/init/phases/source-comments-output-io.js +0 -81
- package/dist/init/phases/source-comments-output-io.js.map +0 -1
- package/templates/.cairn/ground/capabilities/mcp-tools.yaml +0 -29
- package/templates/.cairn/ground/capabilities/skills.yaml +0 -25
- package/templates/.cairn/ground/capabilities/snippets.yaml +0 -29
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cairn_bootstrap_retry — manual retry for per-clone bootstrap.
|
|
3
|
+
*
|
|
4
|
+
* Spec: PLUGIN_ARCHITECTURE §11 (no CLI subcommand exposure to operator) +
|
|
5
|
+
* §17 Layer 2 (per-clone bootstrap).
|
|
6
|
+
*
|
|
7
|
+
* Surface: when `requireBootstrap` returns `BOOTSTRAP_REQUIRED` because
|
|
8
|
+
* the auto-join path failed (most commonly: hooks dir missing or
|
|
9
|
+
* `git config core.hooksPath` blocked), this tool re-runs the join
|
|
10
|
+
* sequence inline so the operator never sees a CLI subcommand. The
|
|
11
|
+
* `cairn-attention` skill's Step 0 calls this tool when the bootstrap
|
|
12
|
+
* banner is in `additionalContext`; SessionStart's degraded-mode
|
|
13
|
+
* banner cites this tool name as the recovery path.
|
|
14
|
+
*
|
|
15
|
+
* Idempotent. The bootstrap guard is intentionally NOT called here —
|
|
16
|
+
* its sole purpose is to retry bootstrap, so guarding it would be a
|
|
17
|
+
* loop.
|
|
18
|
+
*/
|
|
19
|
+
import { runJoin } from "../../join/index.js";
|
|
20
|
+
const inputShape = {};
|
|
21
|
+
async function handler(ctx, _input) {
|
|
22
|
+
const result = runJoin({ repoRoot: ctx.repoRoot });
|
|
23
|
+
const failedSteps = result.steps
|
|
24
|
+
.filter((s) => s.status === "error")
|
|
25
|
+
.map((s) => `${s.step}: ${s.detail}`);
|
|
26
|
+
if (result.bootstrapped) {
|
|
27
|
+
return {
|
|
28
|
+
ok: true,
|
|
29
|
+
bootstrapped: true,
|
|
30
|
+
repo_root: result.repoRoot,
|
|
31
|
+
project_cairn_version: result.projectCairnVersion,
|
|
32
|
+
cli_version: result.cliVersion,
|
|
33
|
+
steps: result.steps,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
ok: false,
|
|
38
|
+
error: "BOOTSTRAP_FAILED",
|
|
39
|
+
bootstrapped: false,
|
|
40
|
+
repo_root: result.repoRoot,
|
|
41
|
+
project_cairn_version: result.projectCairnVersion,
|
|
42
|
+
cli_version: result.cliVersion,
|
|
43
|
+
steps: result.steps,
|
|
44
|
+
failed_steps: failedSteps,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export const bootstrapRetryTool = {
|
|
48
|
+
name: "cairn_bootstrap_retry",
|
|
49
|
+
description: "Retry per-clone bootstrap inline when SessionStart's auto-bootstrap or a write-tool's lazy bootstrap failed. Idempotent. Returns step-by-step status; on success, subsequent MCP write tools no longer return BOOTSTRAP_REQUIRED.",
|
|
50
|
+
inputSchema: inputShape,
|
|
51
|
+
handler,
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=bootstrap-retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap-retry.js","sourceRoot":"","sources":["../../../src/mcp/tools/bootstrap-retry.ts"],"names":[],"mappings":"AAAA;;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
4
|
* Wraps `bulkAcceptObvious` so the cairn-attention skill can drain
|
|
5
5
|
* obvious DEC drafts in one tool call instead of N rounds of
|
|
6
6
|
* `cairn_resolve_attention(choice="a")` per draft. Loads the project
|
|
7
|
-
* globs
|
|
7
|
+
* globs from `.cairn/config.yaml` so the scoring
|
|
8
8
|
* heuristic has the same context the cli subcommand does.
|
|
9
9
|
*
|
|
10
10
|
* Returns a slim count-distribution shape — no draft bodies, no file
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Wraps `bulkAcceptObvious` so the cairn-attention skill can drain
|
|
5
5
|
* obvious DEC drafts in one tool call instead of N rounds of
|
|
6
6
|
* `cairn_resolve_attention(choice="a")` per draft. Loads the project
|
|
7
|
-
* globs
|
|
7
|
+
* globs from `.cairn/config.yaml` so the scoring
|
|
8
8
|
* heuristic has the same context the cli subcommand does.
|
|
9
9
|
*
|
|
10
10
|
* Returns a slim count-distribution shape — no draft bodies, no file
|
|
@@ -31,7 +31,6 @@ const ConfigSchema = z.object({
|
|
|
31
31
|
}).optional(),
|
|
32
32
|
high_stakes_globs: z.array(z.string()).optional(),
|
|
33
33
|
off_limits: z.array(z.string()).optional(),
|
|
34
|
-
pilot_module: z.string().optional(),
|
|
35
34
|
}).passthrough();
|
|
36
35
|
function loadProjectGlobs(repoRoot) {
|
|
37
36
|
const configPath = join(repoRoot, ".cairn", "config.yaml");
|
|
@@ -66,18 +65,17 @@ function loadProjectGlobs(repoRoot) {
|
|
|
66
65
|
globs.high_stakes_globs = pg.high_stakes_globs;
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
|
-
return
|
|
68
|
+
return { globs };
|
|
70
69
|
}
|
|
71
70
|
export const bulkAcceptAttentionTool = {
|
|
72
71
|
name: "cairn_bulk_accept_attention",
|
|
73
|
-
description: "Score every DEC draft + invariant in `.cairn/ground/decisions/_inbox/` and `.cairn/ground/invariants/` against a confidence heuristic (file in high_stakes_globs /
|
|
72
|
+
description: "Score every DEC draft + invariant in `.cairn/ground/decisions/_inbox/` and `.cairn/ground/invariants/` against a confidence heuristic (file in high_stakes_globs / route or dto globs, prose substantiveness, decision verbs, JSDoc tags). Auto-promote DEC drafts at or above `threshold` (default 'high') out of the inbox to accepted state and rebuild the decisions ledger. Stamp `capture_confidence` on every draft + invariant so subsequent attention surfaces can sort. Use this once per adoption to drain the obvious classifications before per-item triage. Returns count distributions and the accepted ID list. `dryRun: true` reports the same distribution without writing.",
|
|
74
73
|
inputSchema: inputShape,
|
|
75
74
|
handler: async (ctx, input) => {
|
|
76
|
-
const { globs
|
|
75
|
+
const { globs } = loadProjectGlobs(ctx.repoRoot);
|
|
77
76
|
return bulkAcceptObvious({
|
|
78
77
|
repoRoot: ctx.repoRoot,
|
|
79
78
|
globs,
|
|
80
|
-
...(pilotModule !== undefined ? { pilotModule } : {}),
|
|
81
79
|
threshold: input.threshold ?? "high",
|
|
82
80
|
...(input.dryRun !== undefined ? { dryRun: input.dryRun } : {}),
|
|
83
81
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulk-accept-attention.js","sourceRoot":"","sources":["../../../src/mcp/tools/bulk-accept-attention.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,GAGlB,MAAM,0BAA0B,CAAC;AAKlC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;AAE3D,MAAM,UAAU,GAAG;IACjB,SAAS,EAAE,gBAAgB,CAAC,QAAQ,EAAE;IACtC,MAAM,EAAE,CAAC,CAAC,O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AC7B,MAAM,EAAE,KAAK,EAAE,GAAG,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACjD,OAAO,iBAAiB,CAAC;YACvB,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,KAAK;YACL,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,MAAM;YACpC,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChE,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
package/dist/mcp/tools/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { attentionDedupTool } from "./attention-dedup.js";
|
|
|
4
4
|
import { attentionRestoreTool } from "./attention-restore.js";
|
|
5
5
|
import { attentionServeTool } from "./attention-serve.js";
|
|
6
6
|
import { attentionWaitTool } from "./attention-wait.js";
|
|
7
|
+
import { bootstrapRetryTool } from "./bootstrap-retry.js";
|
|
7
8
|
import { bulkAcceptAttentionTool } from "./bulk-accept-attention.js";
|
|
8
9
|
import { canonicalForTopicTool } from "./canonical-for-topic.js";
|
|
9
10
|
import { decisionGetTool } from "./decision-get.js";
|
|
@@ -20,7 +21,10 @@ import { resolveAttentionTool } from "./resolve-attention.js";
|
|
|
20
21
|
import { searchTool } from "./search.js";
|
|
21
22
|
import { searchCandidatesTool } from "./search-candidates.js";
|
|
22
23
|
import { supersedesChainTool } from "./supersedes-chain.js";
|
|
24
|
+
import { resumeTool } from "./resume.js";
|
|
25
|
+
import { taskCompleteTool } from "./task-complete.js";
|
|
23
26
|
import { taskCreateTool } from "./task-create.js";
|
|
27
|
+
import { taskJournalAppendTool } from "./task-journal-append.js";
|
|
24
28
|
import { timelineTool } from "./timeline.js";
|
|
25
29
|
export const allTools = [
|
|
26
30
|
// Read — graph traversal
|
|
@@ -42,7 +46,11 @@ export const allTools = [
|
|
|
42
46
|
// Write
|
|
43
47
|
recordDecisionTool,
|
|
44
48
|
taskCreateTool,
|
|
49
|
+
taskCompleteTool,
|
|
50
|
+
taskJournalAppendTool,
|
|
45
51
|
archiveTool,
|
|
52
|
+
// Read — resume layer
|
|
53
|
+
resumeTool,
|
|
46
54
|
// Write — phase 6 candidate surface
|
|
47
55
|
rejectCandidateTool,
|
|
48
56
|
// Write — plugin-era
|
|
@@ -54,6 +62,8 @@ export const allTools = [
|
|
|
54
62
|
attentionWaitTool,
|
|
55
63
|
// Write — Layer C SessionStart drain
|
|
56
64
|
alignDrainTool,
|
|
65
|
+
// Write — bootstrap recovery (replaces CLI exposure in BOOTSTRAP_REQUIRED)
|
|
66
|
+
bootstrapRetryTool,
|
|
57
67
|
// Write — init pipeline (v0.7.2 single-umbrella surface)
|
|
58
68
|
initResumeTool,
|
|
59
69
|
initRunTool,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAi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U,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,CAAC,MAAM,QAAQ,GAAqB;IACxC,yBAAyB;IACzB,eAAe;IACf,sBAAsB;IACtB,qBAAqB;IACrB,aAAa;IACb,mBAAmB;IACnB,gBAAgB;IAChB,WAAW;IACX,6BAA6B;IAC7B,UAAU;IACV,YAAY;IACZ,WAAW;IACX,4BAA4B;IAC5B,gBAAgB;IAChB,mCAAmC;IACnC,oBAAoB;IACpB,QAAQ;IACR,kBAAkB;IAClB,cAAc;IACd,gBAAgB;IAChB,qBAAqB;IACrB,WAAW;IACX,sBAAsB;IACtB,UAAU;IACV,oCAAoC;IACpC,mBAAmB;IACnB,qBAAqB;IACrB,oBAAoB;IACpB,uBAAuB;IACvB,kBAAkB;IAClB,oBAAoB;IACpB,kBAAkB;IAClB,iBAAiB;IACjB,qCAAqC;IACrC,cAAc;IACd,2EAA2E;IAC3E,kBAAkB;IAClB,yDAAyD;IACzD,cAAc;IACd,WAAW;CACZ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP tools for the v0.
|
|
2
|
+
* MCP tools for the v0.9.0 init pipeline.
|
|
3
3
|
*
|
|
4
4
|
* Two tools, single surface:
|
|
5
5
|
* 1. `cairn_init_resume` → { status, nextPhase, repoRoot }
|
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
* 3. AskUserQuestion if needs_input → re-call same tool with { answer }
|
|
12
12
|
* 4. loop on complete + advance until nextPhase === null
|
|
13
13
|
*
|
|
14
|
-
* Phase
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
* Phase 9b-curate is a skill-driven pseudo-phase: between Phase 9a
|
|
15
|
+
* (walker) and Phase 9c (emit), the cairn-adopt skill spawns
|
|
16
|
+
* `cairn:curator-map` and `cairn:curator-reduce` subagents that write
|
|
17
|
+
* `.cairn/init/curator/final.jsonl`. The 9b runner only confirms the
|
|
18
|
+
* file exists + counts entries before advancing; the heavy work
|
|
19
|
+
* happens outside the MCP server.
|
|
19
20
|
*
|
|
20
21
|
* State persists to .cairn/init-state.json after every successful
|
|
21
22
|
* phase result so the operator can crash-recover. The skill no longer
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP tools for the v0.
|
|
2
|
+
* MCP tools for the v0.9.0 init pipeline.
|
|
3
3
|
*
|
|
4
4
|
* Two tools, single surface:
|
|
5
5
|
* 1. `cairn_init_resume` → { status, nextPhase, repoRoot }
|
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
* 3. AskUserQuestion if needs_input → re-call same tool with { answer }
|
|
12
12
|
* 4. loop on complete + advance until nextPhase === null
|
|
13
13
|
*
|
|
14
|
-
* Phase
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
* Phase 9b-curate is a skill-driven pseudo-phase: between Phase 9a
|
|
15
|
+
* (walker) and Phase 9c (emit), the cairn-adopt skill spawns
|
|
16
|
+
* `cairn:curator-map` and `cairn:curator-reduce` subagents that write
|
|
17
|
+
* `.cairn/init/curator/final.jsonl`. The 9b runner only confirms the
|
|
18
|
+
* file exists + counts entries before advancing; the heavy work
|
|
19
|
+
* happens outside the MCP server.
|
|
19
20
|
*
|
|
20
21
|
* State persists to .cairn/init-state.json after every successful
|
|
21
22
|
* phase result so the operator can crash-recover. The skill no longer
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
* phase outputs — a single bad call could nuke a 90KB mapper run.
|
|
35
36
|
*/
|
|
36
37
|
import { z } from "zod";
|
|
37
|
-
import { PHASE_IDS, clearProgress, freshPhaseState, readPhaseState, resumePhases, runPhase1Detect, runPhase2Walker, runPhase3Mapper, runPhase4Seed,
|
|
38
|
+
import { PHASE_IDS, clearProgress, freshPhaseState, readPhaseState, resumePhases, runPhase1Detect, runPhase2Walker, runPhase3Mapper, runPhase4Seed, runPhase5Preflight, runPhase6Brand, runPhase7TopicIndex, runPhase8DocsIngest, runPhase9aWalker, runPhase9bCurate, runPhase9cEmit, runPhase10RulesMerge, runPhase11Baseline, runPhase12Strip, runPhase13Multidev, writePhaseState, writeProgress, } from "../../init/index.js";
|
|
38
39
|
import { mcpError } from "../errors.js";
|
|
39
40
|
const phaseIdEnum = z.enum(PHASE_IDS);
|
|
40
41
|
const phaseStateSchema = z.object({
|
|
@@ -43,7 +44,7 @@ const phaseStateSchema = z.object({
|
|
|
43
44
|
outputs: z.record(z.string(), z.unknown()),
|
|
44
45
|
answer: z.string().optional(),
|
|
45
46
|
startedAt: z.string().min(1),
|
|
46
|
-
schemaVersion: z.literal(
|
|
47
|
+
schemaVersion: z.literal(3),
|
|
47
48
|
});
|
|
48
49
|
const phaseRunInput = {
|
|
49
50
|
phase: phaseIdEnum,
|
|
@@ -62,11 +63,13 @@ const RUNNERS = {
|
|
|
62
63
|
"2-walker": runPhase2Walker,
|
|
63
64
|
"3-mapper": runPhase3Mapper,
|
|
64
65
|
"4-seed": runPhase4Seed,
|
|
65
|
-
"5-
|
|
66
|
+
"5-preflight": runPhase5Preflight,
|
|
66
67
|
"6-brand": runPhase6Brand,
|
|
67
68
|
"7-topic-index": runPhase7TopicIndex,
|
|
68
69
|
"8-docs-ingest": runPhase8DocsIngest,
|
|
69
|
-
"
|
|
70
|
+
"9a-walker": runPhase9aWalker,
|
|
71
|
+
"9b-curate": runPhase9bCurate,
|
|
72
|
+
"9c-emit": runPhase9cEmit,
|
|
70
73
|
"10-rules-merge": runPhase10RulesMerge,
|
|
71
74
|
"11-baseline": runPhase11Baseline,
|
|
72
75
|
"12-strip": runPhase12Strip,
|
|
@@ -81,41 +84,6 @@ function toSlim(result) {
|
|
|
81
84
|
}
|
|
82
85
|
return { status: "error", error: result.error };
|
|
83
86
|
}
|
|
84
|
-
/**
|
|
85
|
-
* Phase 8 fans out to phases 8/9/10 in parallel. Centralized here so
|
|
86
|
-
* `cairn_init_run` callers don't have to special-case the gate.
|
|
87
|
-
*/
|
|
88
|
-
async function handlePhase8Parallel(ctx, state) {
|
|
89
|
-
if (state.repoRoot !== ctx.repoRoot) {
|
|
90
|
-
return mcpError("VALIDATION_FAILED", `state.repoRoot ${state.repoRoot} does not match MCP context ${ctx.repoRoot}`);
|
|
91
|
-
}
|
|
92
|
-
const t0 = performance.now();
|
|
93
|
-
const result = await runPhases8910Parallel(state);
|
|
94
|
-
const durationMs = Math.round(performance.now() - t0);
|
|
95
|
-
clearProgress(state.repoRoot);
|
|
96
|
-
if (result.status !== "error") {
|
|
97
|
-
for (const id of [
|
|
98
|
-
"8-docs-ingest",
|
|
99
|
-
"9-source-comments",
|
|
100
|
-
"10-rules-merge",
|
|
101
|
-
]) {
|
|
102
|
-
const phaseOut = result.state.outputs[id];
|
|
103
|
-
if (typeof phaseOut === "object" && phaseOut !== null) {
|
|
104
|
-
const obj = phaseOut;
|
|
105
|
-
if (obj["duration_ms"] === undefined) {
|
|
106
|
-
obj["duration_ms"] = durationMs;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
try {
|
|
111
|
-
writePhaseState(result.state);
|
|
112
|
-
}
|
|
113
|
-
catch (err) {
|
|
114
|
-
return mcpError("INTERNAL_ERROR", `failed to persist init state: ${err instanceof Error ? err.message : String(err)}`);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return toSlim(result);
|
|
118
|
-
}
|
|
119
87
|
async function handlePhaseRun(ctx, id, input) {
|
|
120
88
|
// Resolve state: prefer the explicit arg (smoke tests, debug
|
|
121
89
|
// tooling), fall back to disk (cairn-adopt skill default).
|
|
@@ -140,17 +108,9 @@ async function handlePhaseRun(ctx, id, input) {
|
|
|
140
108
|
const stateForRun = input.answer !== undefined && input.answer.length > 0
|
|
141
109
|
? { ...state, answer: input.answer }
|
|
142
110
|
: state;
|
|
143
|
-
// Phase 8 dispatches the parallel 8/9/10 runner — the three Haiku-
|
|
144
|
-
// batched ingestion phases overlap on wall-clock and the combined
|
|
145
|
-
// result advances to `11-baseline`. No separate MCP tool needed.
|
|
146
|
-
if (id === "8-docs-ingest") {
|
|
147
|
-
return handlePhase8Parallel(ctx, stateForRun);
|
|
148
|
-
}
|
|
149
111
|
const runner = RUNNERS[id];
|
|
150
112
|
// Coarse-grained statusline coverage
|
|
151
|
-
const isLongPhase = id === "3-mapper" ||
|
|
152
|
-
id === "9-source-comments" ||
|
|
153
|
-
id === "10-rules-merge";
|
|
113
|
+
const isLongPhase = id === "3-mapper" || id === "9a-walker" || id === "9c-emit";
|
|
154
114
|
if (!isLongPhase) {
|
|
155
115
|
writeProgress(state.repoRoot, {
|
|
156
116
|
phase: id,
|
|
@@ -166,11 +126,8 @@ async function handlePhaseRun(ctx, id, input) {
|
|
|
166
126
|
// Stamp `duration_ms` on the phase's output entry
|
|
167
127
|
if (result.status !== "error") {
|
|
168
128
|
const phaseOut = result.state.outputs[id];
|
|
169
|
-
if (typeof phaseOut === "object" && phaseOut !== null) {
|
|
170
|
-
|
|
171
|
-
if (obj.duration_ms === undefined) {
|
|
172
|
-
obj.duration_ms = durationMs;
|
|
173
|
-
}
|
|
129
|
+
if (typeof phaseOut === "object" && phaseOut !== null && !("duration_ms" in phaseOut)) {
|
|
130
|
+
Object.assign(phaseOut, { duration_ms: durationMs });
|
|
174
131
|
}
|
|
175
132
|
}
|
|
176
133
|
// Persist state ONLY on non-error results.
|
|
@@ -187,7 +144,7 @@ async function handlePhaseRun(ctx, id, input) {
|
|
|
187
144
|
function makePhaseRunTool() {
|
|
188
145
|
return {
|
|
189
146
|
name: "cairn_init_run",
|
|
190
|
-
description: "Run the next initialization phase. Call cairn_init_resume to find the next phase, then invoke this tool with that phase ID. Phase 8-docs-ingest
|
|
147
|
+
description: "Run the next initialization phase. Call cairn_init_resume to find the next phase, then invoke this tool with that phase ID. Phase 8-docs-ingest and 10-rules-merge are no-op markers in v0.9.0 (the curator pipeline 9a-walker → 9b-curate → 9c-emit subsumes both); 10-rules-merge advances to 11-baseline. Phase 9b-curate is a skill-driven pseudo-phase: the cairn-adopt skill must dispatch curator-map + curator-reduce subagents and write .cairn/init/curator/final.jsonl before invoking it. The cairn-adopt skill loops on this tool until nextPhase === null.",
|
|
191
148
|
inputSchema: phaseRunInput,
|
|
192
149
|
handler: async (ctx, input) => {
|
|
193
150
|
return handlePhaseRun(ctx, input.phase, input);
|
|
@@ -197,19 +154,33 @@ function makePhaseRunTool() {
|
|
|
197
154
|
function makeResumeTool() {
|
|
198
155
|
return {
|
|
199
156
|
name: "cairn_init_resume",
|
|
200
|
-
description: "Read the on-disk init state for the current repo and return the next phase to invoke. The cairn-adopt skill calls this once at the start of the pipeline (and after any operator interruption) to find where to pick up. Returns { status: 'ready' | 'done', nextPhase: PhaseId | null, repoRoot }.",
|
|
157
|
+
description: "Read the on-disk init state for the current repo and return the next phase to invoke. The cairn-adopt skill calls this once at the start of the pipeline (and after any operator interruption) to find where to pick up. Returns { status: 'ready' | 'done', nextPhase: PhaseId | null, repoRoot }. For a fresh start (no `.cairn/init-state.json`), the tool persists a fresh PhaseState to disk so the very next `cairn_init_run` call can read it back without the skill having to thread state through tool arguments.",
|
|
201
158
|
inputSchema: initResumeInput,
|
|
202
159
|
handler: async (ctx) => {
|
|
203
160
|
const report = resumePhases(ctx.repoRoot);
|
|
204
161
|
// For a fresh start, ensure state.repoRoot matches ctx.repoRoot
|
|
205
162
|
// (resumePhases uses freshPhaseState(ctx.repoRoot) for this case).
|
|
206
|
-
const
|
|
207
|
-
? freshPhaseState(ctx.repoRoot)
|
|
208
|
-
: report.state
|
|
163
|
+
const stateForCtx = report.state.repoRoot !== ctx.repoRoot
|
|
164
|
+
? freshPhaseState(ctx.repoRoot)
|
|
165
|
+
: report.state;
|
|
166
|
+
// Persist fresh state to disk so the next `cairn_init_run` call
|
|
167
|
+
// (which by SKILL.md contract omits the `state` arg) finds
|
|
168
|
+
// something to read. Without this, the loop deadlocks at Phase
|
|
169
|
+
// 1-detect with `VALIDATION_FAILED ... no init state at
|
|
170
|
+
// .cairn/init-state.json` on every fresh adoption.
|
|
171
|
+
const onDisk = readPhaseState(ctx.repoRoot);
|
|
172
|
+
if (onDisk === null) {
|
|
173
|
+
try {
|
|
174
|
+
writePhaseState(stateForCtx);
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
return mcpError("INTERNAL_ERROR", `failed to seed init state: ${err instanceof Error ? err.message : String(err)}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
209
180
|
return {
|
|
210
181
|
status: report.status,
|
|
211
182
|
nextPhase: report.nextPhase,
|
|
212
|
-
repoRoot,
|
|
183
|
+
repoRoot: stateForCtx.repoRoot,
|
|
213
184
|
};
|
|
214
185
|
},
|
|
215
186
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-phases.js","sourceRoot":"","sources":["../../../src/mcp/tools/init-phases.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"init-phases.js","sourceRoot":"","sources":["../../../src/mcp/tools/init-phases.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,SAAS,EACT,aAAa,EACb,eAAe,EACf,cAAc,EACd,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,aAAa,GAMd,MA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AC,MAAM,CAAC,KAAK,CAAC;YACnB,gEAAgE;YAChE,2DAA2D;YAC3D,+DAA+D;YAC/D,wDAAwD;YACxD,mDAAmD;YACnD,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC5C,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBACpB,IAAI,CAAC;oBACH,eAAe,CAAC,WAAW,CAAC,CAAC;gBAC/B,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,OAAO,QAAQ,CACb,gBAAgB,EAChB,8BAA8B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACjF,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,OAAO;gBACL,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,QAAQ,EAAE,WAAW,CAAC,QAAQ;aAC/B,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAA2B,gBAAgB,EAAE,CAAC;AACtE,MAAM,CAAC,MAAM,cAAc,GAA6B,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cairn_resume` — read the active task's journal + spec and emit a
|
|
3
|
+
* resume payload that primes a fresh-context session cold.
|
|
4
|
+
*
|
|
5
|
+
* Called by the `/cairn-resume <task_id>` slash command after the
|
|
6
|
+
* operator `/clear`s mid-task. SessionStart hook also calls this
|
|
7
|
+
* automatically when it detects an active task whose journal has
|
|
8
|
+
* entries from a prior session_id.
|
|
9
|
+
*
|
|
10
|
+
* The payload is structured so the slash-command body can render a
|
|
11
|
+
* tight resume context block: title, goal, what's been done, what's
|
|
12
|
+
* next, in-scope decisions/invariants. No Haiku call — pure read.
|
|
13
|
+
*/
|
|
14
|
+
import type { ToolDef } from "./types.js";
|
|
15
|
+
interface Input {
|
|
16
|
+
task_id?: string;
|
|
17
|
+
/** Cap on most-recent journal entries returned. Default 7. */
|
|
18
|
+
max_entries?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare const resumeTool: ToolDef<Input>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cairn_resume` — read the active task's journal + spec and emit a
|
|
3
|
+
* resume payload that primes a fresh-context session cold.
|
|
4
|
+
*
|
|
5
|
+
* Called by the `/cairn-resume <task_id>` slash command after the
|
|
6
|
+
* operator `/clear`s mid-task. SessionStart hook also calls this
|
|
7
|
+
* automatically when it detects an active task whose journal has
|
|
8
|
+
* entries from a prior session_id.
|
|
9
|
+
*
|
|
10
|
+
* The payload is structured so the slash-command body can render a
|
|
11
|
+
* tight resume context block: title, goal, what's been done, what's
|
|
12
|
+
* next, in-scope decisions/invariants. No Haiku call — pure read.
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import { parse as parseYaml } from "yaml";
|
|
17
|
+
import { mcpError } from "../errors.js";
|
|
18
|
+
import { resumeInput } from "../schemas.js";
|
|
19
|
+
import { findCurrentActiveTask, readTaskJournal, } from "../../tasks/index.js";
|
|
20
|
+
async function handler(ctx, input) {
|
|
21
|
+
const taskId = input.task_id ?? findCurrentActiveTask(ctx.repoRoot);
|
|
22
|
+
if (taskId === null) {
|
|
23
|
+
return mcpError("TASK_NOT_FOUND", "no active task to resume");
|
|
24
|
+
}
|
|
25
|
+
const taskDir = join(ctx.repoRoot, ".cairn", "tasks", "active", taskId);
|
|
26
|
+
if (!existsSync(taskDir)) {
|
|
27
|
+
return mcpError("TASK_NOT_FOUND", `active task directory missing: .cairn/tasks/active/${taskId}/`);
|
|
28
|
+
}
|
|
29
|
+
const specPath = join(taskDir, "spec.tightened.md");
|
|
30
|
+
let title = taskId;
|
|
31
|
+
let goal = "(spec not found)";
|
|
32
|
+
let inScopeDecisions = [];
|
|
33
|
+
let inScopeInvariants = [];
|
|
34
|
+
let targetPathGlobs = [];
|
|
35
|
+
if (existsSync(specPath)) {
|
|
36
|
+
const raw = readFileSync(specPath, "utf8");
|
|
37
|
+
const fmMatch = raw.match(/^---\r?\n([\s\S]*?)\n---\r?\n([\s\S]*)$/);
|
|
38
|
+
if (fmMatch) {
|
|
39
|
+
try {
|
|
40
|
+
const fm = parseYaml(fmMatch[1] ?? "");
|
|
41
|
+
if (typeof fm.title === "string")
|
|
42
|
+
title = fm.title;
|
|
43
|
+
if (Array.isArray(fm.in_scope_decisions)) {
|
|
44
|
+
inScopeDecisions = fm.in_scope_decisions.filter((x) => typeof x === "string");
|
|
45
|
+
}
|
|
46
|
+
if (Array.isArray(fm.in_scope_invariants)) {
|
|
47
|
+
inScopeInvariants = fm.in_scope_invariants.filter((x) => typeof x === "string");
|
|
48
|
+
}
|
|
49
|
+
if (Array.isArray(fm.target_path_globs)) {
|
|
50
|
+
targetPathGlobs = fm.target_path_globs.filter((x) => typeof x === "string");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// malformed frontmatter — fall through with defaults
|
|
55
|
+
}
|
|
56
|
+
const body = fmMatch[2] ?? "";
|
|
57
|
+
const goalMatch = body.match(/##\s+Goal\s*\r?\n+([\s\S]*?)(?:\r?\n##\s+|$)/);
|
|
58
|
+
if (goalMatch && goalMatch[1] !== undefined) {
|
|
59
|
+
goal = goalMatch[1].trim();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const journal = readTaskJournal(ctx.repoRoot, taskId, "active");
|
|
64
|
+
const cap = Math.max(1, Math.min(50, input.max_entries ?? 7));
|
|
65
|
+
const recent = journal.slice(-cap);
|
|
66
|
+
const lastEntry = journal.length > 0 ? journal[journal.length - 1] : null;
|
|
67
|
+
const nextStep = lastEntry?.next_step ?? null;
|
|
68
|
+
const payload = {
|
|
69
|
+
ok: true,
|
|
70
|
+
task_id: taskId,
|
|
71
|
+
title,
|
|
72
|
+
goal,
|
|
73
|
+
in_scope_decisions: inScopeDecisions,
|
|
74
|
+
in_scope_invariants: inScopeInvariants,
|
|
75
|
+
target_path_globs: targetPathGlobs,
|
|
76
|
+
recent_entries: recent,
|
|
77
|
+
next_step: nextStep,
|
|
78
|
+
total_entries: journal.length,
|
|
79
|
+
};
|
|
80
|
+
return payload;
|
|
81
|
+
}
|
|
82
|
+
export const resumeTool = {
|
|
83
|
+
name: "cairn_resume",
|
|
84
|
+
description: "Read the active task's journal + tightened spec and emit a resume payload (title, goal, in-scope DECs/INVs, last N journal entries, last-known next_step). Used after `/clear` to rebuild operator context cold. `task_id` defaults to the most-recently-touched active task.",
|
|
85
|
+
inputSchema: resumeInput,
|
|
86
|
+
handler,
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=resume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume.js","sourceRoot":"","sources":["../../../src/mcp/tools/resume.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EACL,qBAAqB,EACrB,eAAe,GAEhB,MAAM,sBAAsB,CAAC;AA4B9B,KAAK,UAAU,OAAO,CAAC,GAAe,EAAE,KAAY;IAClD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,IAAI,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpE,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAA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CAAC;IAC1E,MAAM,QAAQ,GAAG,SAAS,EAAE,SAAS,IAAI,IAAI,CAAC;IAE9C,MAAM,OAAO,GAAkB;QAC7B,EAAE,EAAE,IAAI;QACR,OAAO,EAAE,MAAM;QACf,KAAK;QACL,IAAI;QACJ,kBAAkB,EAAE,gBAAgB;QACpC,mBAAmB,EAAE,iBAAiB;QACtC,iBAAiB,EAAE,eAAe;QAClC,cAAc,EAAE,MAAM;QACtB,SAAS,EAAE,QAAQ;QACnB,aAAa,EAAE,OAAO,CAAC,MAAM;KAC9B,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAmB;IACxC,IAAI,EAAE,cAAc;IACpB,WAAW,EACT,+QAA+Q;IACjR,WAAW,EAAE,WAAW;IACxB,OAAO;CACR,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cairn_task_complete` — graduate an active task to a terminal phase
|
|
3
|
+
* and move its directory to `.cairn/tasks/done/`.
|
|
4
|
+
*
|
|
5
|
+
* Tasks created by `cairn_task_create` start at `phase: running`.
|
|
6
|
+
* This tool is the explicit terminal write — called by the reviewer
|
|
7
|
+
* subagent after attestation, by the cairn-direction skill on a
|
|
8
|
+
* confirmed pivot, or by the Stop-hook auto-graduator when the
|
|
9
|
+
* reviewer attestation lands.
|
|
10
|
+
*
|
|
11
|
+
* Outcomes:
|
|
12
|
+
* - `succeeded` — work complete, attestation present
|
|
13
|
+
* - `failed` — work attempted but did not pass acceptance
|
|
14
|
+
* - `aborted` — task abandoned (operator pivoted, scope removed)
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolDef } from "./types.js";
|
|
17
|
+
interface Input {
|
|
18
|
+
task_id: string;
|
|
19
|
+
outcome: "succeeded" | "failed" | "aborted";
|
|
20
|
+
summary?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare const taskCompleteTool: ToolDef<Input>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cairn_task_complete` — graduate an active task to a terminal phase
|
|
3
|
+
* and move its directory to `.cairn/tasks/done/`.
|
|
4
|
+
*
|
|
5
|
+
* Tasks created by `cairn_task_create` start at `phase: running`.
|
|
6
|
+
* This tool is the explicit terminal write — called by the reviewer
|
|
7
|
+
* subagent after attestation, by the cairn-direction skill on a
|
|
8
|
+
* confirmed pivot, or by the Stop-hook auto-graduator when the
|
|
9
|
+
* reviewer attestation lands.
|
|
10
|
+
*
|
|
11
|
+
* Outcomes:
|
|
12
|
+
* - `succeeded` — work complete, attestation present
|
|
13
|
+
* - `failed` — work attempted but did not pass acceptance
|
|
14
|
+
* - `aborted` — task abandoned (operator pivoted, scope removed)
|
|
15
|
+
*/
|
|
16
|
+
import { requireBootstrap } from "../bootstrap-guard.js";
|
|
17
|
+
import { mcpError } from "../errors.js";
|
|
18
|
+
import { taskCompleteInput } from "../schemas.js";
|
|
19
|
+
import { completeTask } from "../../tasks/index.js";
|
|
20
|
+
async function handler(ctx, input) {
|
|
21
|
+
const block = requireBootstrap(ctx.repoRoot);
|
|
22
|
+
if (block !== null)
|
|
23
|
+
return block;
|
|
24
|
+
const result = completeTask({
|
|
25
|
+
repoRoot: ctx.repoRoot,
|
|
26
|
+
taskId: input.task_id,
|
|
27
|
+
outcome: input.outcome,
|
|
28
|
+
...(input.summary !== undefined ? { summary: input.summary } : {}),
|
|
29
|
+
source: "cairn_task_complete",
|
|
30
|
+
});
|
|
31
|
+
if (!result.ok) {
|
|
32
|
+
if (result.code === "TASK_NOT_FOUND" || result.code === "ALREADY_COMPLETED") {
|
|
33
|
+
return mcpError("TASK_NOT_FOUND", result.message);
|
|
34
|
+
}
|
|
35
|
+
return mcpError("INTERNAL_ERROR", result.message);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
ok: true,
|
|
39
|
+
task_id: result.taskId,
|
|
40
|
+
outcome: result.outcome,
|
|
41
|
+
completed_at: result.completedAt,
|
|
42
|
+
moved_to: result.movedTo,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export const taskCompleteTool = {
|
|
46
|
+
name: "cairn_task_complete",
|
|
47
|
+
description: "Graduate an active task (`.cairn/tasks/active/<task_id>/`) to a terminal phase (succeeded / failed / aborted) and move its directory to `.cairn/tasks/done/`. Called by the reviewer subagent after writing attestation.yaml, by the cairn-direction skill on a confirmed pivot, or by the Stop-hook auto-graduator. Returns TASK_NOT_FOUND if the task was already completed.",
|
|
48
|
+
inputSchema: taskCompleteInput,
|
|
49
|
+
handler,
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=task-complete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-complete.js","sourceRoot":"","sources":["../../../src/mcp/tools/task-complete.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD,KAAK,UAAU,OAAO,CAAC,GAAe,EAAE,KAAY;IAClD,MAAM,KAAK,GAAG,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAEjC,MAAM,MAAM,GAAG,YAAY,CAAC;QAC1B,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,MAAM,EAAE,KAAK,CAAC,OAAO;QACrB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,MAAM,EAAE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