@isaacriehm/cairn-core 0.7.0 → 0.7.2
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/align-undo/undo.js +2 -2
- package/dist/align-undo/undo.js.map +1 -1
- package/dist/attention/bulk-accept.js +48 -40
- package/dist/attention/bulk-accept.js.map +1 -1
- package/dist/attention/dedup.js +23 -10
- package/dist/attention/dedup.js.map +1 -1
- package/dist/attention/restore.js +2 -2
- package/dist/attention/restore.js.map +1 -1
- package/dist/attention/scoring.js +1 -1
- package/dist/attention/scoring.js.map +1 -1
- package/dist/attention/serve/api.d.ts +1 -0
- package/dist/attention/serve/api.js +127 -80
- package/dist/attention/serve/api.js.map +1 -1
- package/dist/attention/serve/index.d.ts +1 -0
- package/dist/attention/serve/index.js +21 -7
- package/dist/attention/serve/index.js.map +1 -1
- package/dist/attention/source-strip.js +41 -46
- package/dist/attention/source-strip.js.map +1 -1
- package/dist/claude/cache.d.ts +10 -19
- package/dist/claude/cache.js +0 -0
- package/dist/claude/cache.js.map +1 -1
- package/dist/claude/runner.d.ts +4 -6
- package/dist/claude/runner.js +242 -203
- package/dist/claude/runner.js.map +1 -1
- package/dist/claude/types.d.ts +5 -5
- package/dist/context/handoff-builder.d.ts +28 -4
- package/dist/context/handoff-builder.js +75 -157
- package/dist/context/handoff-builder.js.map +1 -1
- package/dist/context/spec-delta.js +61 -9
- package/dist/context/spec-delta.js.map +1 -1
- package/dist/context/task-summary.js +5 -1
- package/dist/context/task-summary.js.map +1 -1
- package/dist/decision-capture/id.js +1 -1
- package/dist/decision-capture/id.js.map +1 -1
- package/dist/doctor/index.d.ts +9 -11
- package/dist/doctor/index.js +118 -175
- package/dist/doctor/index.js.map +1 -1
- package/dist/drain/drain.d.ts +1 -1
- package/dist/drain/drain.js +16 -16
- package/dist/drain/drain.js.map +1 -1
- package/dist/drain/index.d.ts +1 -1
- package/dist/drain/index.js +1 -1
- package/dist/events/reader.d.ts +9 -10
- package/dist/events/reader.js +46 -57
- package/dist/events/reader.js.map +1 -1
- package/dist/events/writer.js +1 -1
- package/dist/events/writer.js.map +1 -1
- package/dist/fix-align/index.d.ts +1 -1
- package/dist/fix-align/index.js +1 -1
- package/dist/fix-align/run.d.ts +1 -1
- package/dist/fix-align/run.js +4 -3
- package/dist/fix-align/run.js.map +1 -1
- package/dist/fix-align/sentinel.d.ts +1 -2
- package/dist/fix-align/sentinel.js +3 -4
- package/dist/fix-align/sentinel.js.map +1 -1
- package/dist/gc/apply.js +1 -1
- package/dist/gc/apply.js.map +1 -1
- package/dist/gc/attested-commits.d.ts +19 -0
- package/dist/gc/attested-commits.js +48 -0
- package/dist/gc/attested-commits.js.map +1 -0
- package/dist/gc/canary.d.ts +11 -21
- package/dist/gc/canary.js +18 -24
- package/dist/gc/canary.js.map +1 -1
- package/dist/gc/citation-integrity.d.ts +11 -14
- package/dist/gc/citation-integrity.js +124 -125
- package/dist/gc/citation-integrity.js.map +1 -1
- package/dist/gc/classify.d.ts +1 -1
- package/dist/gc/classify.js +2 -2
- package/dist/gc/classify.js.map +1 -1
- package/dist/gc/completion-integrity.d.ts +6 -7
- package/dist/gc/completion-integrity.js +45 -53
- package/dist/gc/completion-integrity.js.map +1 -1
- package/dist/gc/doc-gardening.js +1 -9
- package/dist/gc/doc-gardening.js.map +1 -1
- package/dist/gc/frontmatter.js +2 -2
- package/dist/gc/frontmatter.js.map +1 -1
- package/dist/gc/index.d.ts +7 -6
- package/dist/gc/index.js +3 -2
- package/dist/gc/index.js.map +1 -1
- package/dist/gc/quality-update.d.ts +6 -10
- package/dist/gc/quality-update.js +12 -15
- package/dist/gc/quality-update.js.map +1 -1
- package/dist/gc/scope-coverage.js +1 -1
- package/dist/gc/scope-coverage.js.map +1 -1
- package/dist/gc/stub-hits.d.ts +7 -25
- package/dist/gc/stub-hits.js +14 -40
- package/dist/gc/stub-hits.js.map +1 -1
- package/dist/gc/sweep.js +15 -6
- package/dist/gc/sweep.js.map +1 -1
- package/dist/gc/types.d.ts +5 -5
- package/dist/gc/types.js +2 -2
- package/dist/gc/walk-source.js +8 -28
- package/dist/gc/walk-source.js.map +1 -1
- package/dist/hooks/defer.d.ts +9 -20
- package/dist/hooks/defer.js +10 -27
- package/dist/hooks/defer.js.map +1 -1
- package/dist/hooks/post-tool-use/allowlist-reader.d.ts +2 -1
- package/dist/hooks/post-tool-use/allowlist-reader.js +49 -34
- package/dist/hooks/post-tool-use/allowlist-reader.js.map +1 -1
- package/dist/hooks/post-tool-use/index.d.ts +3 -4
- package/dist/hooks/post-tool-use/index.js +3 -3
- package/dist/hooks/post-tool-use/index.js.map +1 -1
- package/dist/hooks/post-tool-use/legend-builder.d.ts +2 -2
- package/dist/hooks/post-tool-use/legend-builder.js +2 -2
- package/dist/hooks/post-tool-use/legend-builder.js.map +1 -1
- package/dist/hooks/post-tool-use/post-write.d.ts +8 -0
- package/dist/hooks/post-tool-use/post-write.js +112 -0
- package/dist/hooks/post-tool-use/post-write.js.map +1 -0
- package/dist/hooks/post-tool-use/read-enricher.d.ts +10 -5
- package/dist/hooks/post-tool-use/read-enricher.js +114 -155
- package/dist/hooks/post-tool-use/read-enricher.js.map +1 -1
- package/dist/hooks/post-tool-use/sot-align.d.ts +12 -0
- package/dist/hooks/post-tool-use/sot-align.js +73 -49
- package/dist/hooks/post-tool-use/sot-align.js.map +1 -1
- package/dist/hooks/post-tool-use/write-guardian.d.ts +40 -8
- package/dist/hooks/post-tool-use/write-guardian.js +202 -254
- package/dist/hooks/post-tool-use/write-guardian.js.map +1 -1
- package/dist/hooks/pre-commit/sot-align-precommit.js +2 -2
- package/dist/hooks/pre-commit/sot-align-precommit.js.map +1 -1
- package/dist/hooks/runners/index.d.ts +2 -2
- package/dist/hooks/runners/index.js +1 -1
- package/dist/hooks/runners/index.js.map +1 -1
- package/dist/hooks/runners/payload.d.ts +34 -19
- package/dist/hooks/runners/payload.js +47 -44
- package/dist/hooks/runners/payload.js.map +1 -1
- package/dist/hooks/runners/session-end.js +12 -11
- package/dist/hooks/runners/session-end.js.map +1 -1
- package/dist/hooks/runners/session-start.d.ts +4 -2
- package/dist/hooks/runners/session-start.js +88 -261
- package/dist/hooks/runners/session-start.js.map +1 -1
- package/dist/hooks/runners/stop.js +27 -8
- package/dist/hooks/runners/stop.js.map +1 -1
- package/dist/hooks/runners/user-prompt-submit.js +7 -1
- package/dist/hooks/runners/user-prompt-submit.js.map +1 -1
- package/dist/hooks/sot-align-common.d.ts +1 -2
- package/dist/hooks/sot-align-common.js +2 -2
- package/dist/hooks/sot-align-common.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/init/baseline-audit.d.ts +14 -58
- package/dist/init/baseline-audit.js +92 -320
- package/dist/init/baseline-audit.js.map +1 -1
- package/dist/init/brand-derive.d.ts +11 -15
- package/dist/init/brand-derive.js +21 -46
- package/dist/init/brand-derive.js.map +1 -1
- package/dist/init/brand-setup.d.ts +1 -1
- package/dist/init/brand-setup.js +1 -1
- package/dist/init/detect.d.ts +25 -6
- package/dist/init/detect.js +107 -136
- package/dist/init/detect.js.map +1 -1
- package/dist/init/index.d.ts +2 -2
- package/dist/init/index.js +1 -1
- package/dist/init/index.js.map +1 -1
- package/dist/init/ingest-docs.d.ts +2 -2
- package/dist/init/ingest-docs.js +31 -43
- package/dist/init/ingest-docs.js.map +1 -1
- package/dist/init/init.d.ts +21 -21
- package/dist/init/init.js +41 -61
- package/dist/init/init.js.map +1 -1
- package/dist/init/mapper-merge.js +1 -1
- package/dist/init/mapper-merge.js.map +1 -1
- package/dist/init/mapper-parallel.d.ts +1 -1
- package/dist/init/mapper-parallel.js +2 -1
- package/dist/init/mapper-parallel.js.map +1 -1
- package/dist/init/mapper.js +1 -1
- package/dist/init/mapper.js.map +1 -1
- package/dist/init/multi-dev/install.d.ts +5 -5
- package/dist/init/multi-dev/install.js +4 -4
- package/dist/init/overlay.js +1 -0
- package/dist/init/overlay.js.map +1 -1
- package/dist/init/phases/1-detect.js +1 -1
- package/dist/init/phases/1-detect.js.map +1 -1
- package/dist/init/phases/{7c-rules-merge.d.ts → 10-rules-merge.d.ts} +2 -2
- package/dist/init/phases/{7c-rules-merge.js → 10-rules-merge.js} +6 -12
- package/dist/init/phases/10-rules-merge.js.map +1 -0
- package/dist/init/phases/11-baseline.d.ts +7 -0
- package/dist/init/phases/{8-baseline.js → 11-baseline.js} +5 -9
- package/dist/init/phases/11-baseline.js.map +1 -0
- package/dist/init/phases/12-strip.d.ts +10 -0
- package/dist/init/phases/{10-strip.js → 12-strip.js} +10 -14
- package/dist/init/phases/12-strip.js.map +1 -0
- package/dist/init/phases/{12-multidev.d.ts → 13-multidev.d.ts} +2 -2
- package/dist/init/phases/{12-multidev.js → 13-multidev.js} +4 -4
- package/dist/init/phases/{12-multidev.js.map → 13-multidev.js.map} +1 -1
- package/dist/init/phases/3-mapper.d.ts +1 -1
- package/dist/init/phases/3-mapper.js +2 -2
- package/dist/init/phases/3-mapper.js.map +1 -1
- package/dist/init/phases/{3b-seed.d.ts → 4-seed.d.ts} +2 -2
- package/dist/init/phases/{3b-seed.js → 4-seed.js} +7 -7
- package/dist/init/phases/4-seed.js.map +1 -0
- package/dist/init/phases/{4-pilot.d.ts → 5-pilot.d.ts} +2 -2
- package/dist/init/phases/{4-pilot.js → 5-pilot.js} +9 -9
- package/dist/init/phases/{4-pilot.js.map → 5-pilot.js.map} +1 -1
- package/dist/init/phases/{5-brand.d.ts → 6-brand.d.ts} +2 -7
- package/dist/init/phases/{5-brand.js → 6-brand.js} +6 -14
- package/dist/init/phases/6-brand.js.map +1 -0
- package/dist/init/phases/{5b-topic-index.d.ts → 7-topic-index.d.ts} +2 -11
- package/dist/init/phases/{5b-topic-index.js → 7-topic-index.js} +9 -18
- package/dist/init/phases/7-topic-index.js.map +1 -0
- package/dist/init/phases/8-docs-ingest.d.ts +10 -0
- package/dist/init/phases/{6-docs-ingest.js → 8-docs-ingest.js} +6 -11
- package/dist/init/phases/8-docs-ingest.js.map +1 -0
- package/dist/init/phases/9-source-comments.d.ts +6 -0
- package/dist/init/phases/{7b-source-comments.js → 9-source-comments.js} +7 -26
- package/dist/init/phases/9-source-comments.js.map +1 -0
- package/dist/init/phases/index.d.ts +12 -12
- package/dist/init/phases/index.js +11 -11
- package/dist/init/phases/index.js.map +1 -1
- package/dist/init/phases/{parallel-678.d.ts → parallel-8910.d.ts} +7 -8
- package/dist/init/phases/{parallel-678.js → parallel-8910.js} +26 -44
- package/dist/init/phases/parallel-8910.js.map +1 -0
- package/dist/init/phases/source-comments-output-io.d.ts +3 -3
- package/dist/init/phases/source-comments-output-io.js +3 -3
- package/dist/init/phases/types.d.ts +1 -1
- package/dist/init/phases/types.js +10 -10
- package/dist/init/phases/types.js.map +1 -1
- package/dist/init/rules-merge/discover.d.ts +2 -2
- package/dist/init/rules-merge/discover.js +28 -43
- package/dist/init/rules-merge/discover.js.map +1 -1
- package/dist/init/rules-merge/ingest.d.ts +6 -6
- package/dist/init/rules-merge/ingest.js +9 -10
- package/dist/init/rules-merge/ingest.js.map +1 -1
- package/dist/init/rules-merge/keep-markers.d.ts +1 -1
- package/dist/init/rules-merge/keep-markers.js +1 -1
- package/dist/init/rules-merge/regenerate.d.ts +3 -3
- package/dist/init/rules-merge/regenerate.js +3 -3
- package/dist/init/seed.js +17 -24
- package/dist/init/seed.js.map +1 -1
- package/dist/init/sot-emit.d.ts +27 -9
- package/dist/init/sot-emit.js +39 -7
- package/dist/init/sot-emit.js.map +1 -1
- package/dist/init/source-comments/classify.d.ts +2 -2
- package/dist/init/source-comments/classify.js +9 -1
- package/dist/init/source-comments/classify.js.map +1 -1
- package/dist/init/source-comments/index.d.ts +1 -1
- package/dist/init/source-comments/index.js.map +1 -1
- package/dist/init/source-comments/ingest.d.ts +2 -2
- package/dist/init/source-comments/ingest.js +6 -8
- package/dist/init/source-comments/ingest.js.map +1 -1
- package/dist/init/source-comments/strip-replace.js +3 -2
- package/dist/init/source-comments/strip-replace.js.map +1 -1
- package/dist/init/source-comments/walker.d.ts +3 -26
- package/dist/init/source-comments/walker.js +18 -30
- package/dist/init/source-comments/walker.js.map +1 -1
- package/dist/init/topic-index/index.d.ts +1 -1
- package/dist/init/topic-index/index.js +3 -3
- package/dist/init/topic-index/index.js.map +1 -1
- package/dist/init/topic-index/judge.d.ts +5 -9
- package/dist/init/topic-index/judge.js +17 -22
- package/dist/init/topic-index/judge.js.map +1 -1
- package/dist/init/topic-index/resolve.d.ts +5 -4
- package/dist/init/topic-index/resolve.js +6 -6
- package/dist/init/topic-index/resolve.js.map +1 -1
- package/dist/init/topic-index/walk.d.ts +6 -6
- package/dist/init/topic-index/walk.js +9 -9
- package/dist/init/topic-index/walk.js.map +1 -1
- package/dist/join/index.js +5 -1
- package/dist/join/index.js.map +1 -1
- package/dist/lock.js +4 -1
- package/dist/lock.js.map +1 -1
- package/dist/logger.js +3 -0
- package/dist/logger.js.map +1 -1
- package/dist/mcp/history/summarizer.js +1 -1
- package/dist/mcp/history/summarizer.js.map +1 -1
- package/dist/mcp/history/walker.js +1 -1
- package/dist/mcp/history/walker.js.map +1 -1
- package/dist/mcp/path-allowlist.js +1 -1
- package/dist/mcp/path-allowlist.js.map +1 -1
- package/dist/mcp/schemas.d.ts +16 -38
- package/dist/mcp/schemas.js +8 -22
- package/dist/mcp/schemas.js.map +1 -1
- package/dist/mcp/server.js +10 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/archive.js +1 -1
- package/dist/mcp/tools/archive.js.map +1 -1
- package/dist/mcp/tools/attention-wait.js +12 -2
- package/dist/mcp/tools/attention-wait.js.map +1 -1
- package/dist/mcp/tools/bulk-accept-attention.js +29 -30
- package/dist/mcp/tools/bulk-accept-attention.js.map +1 -1
- package/dist/mcp/tools/canonical-for-topic.js +37 -15
- package/dist/mcp/tools/canonical-for-topic.js.map +1 -1
- package/dist/mcp/tools/decision-get.js +2 -2
- package/dist/mcp/tools/decision-get.js.map +1 -1
- package/dist/mcp/tools/decisions-for-symbol.js +2 -2
- package/dist/mcp/tools/decisions-for-symbol.js.map +1 -1
- package/dist/mcp/tools/get-full.js +1 -1
- package/dist/mcp/tools/get-full.js.map +1 -1
- package/dist/mcp/tools/ground-get.js +1 -1
- package/dist/mcp/tools/ground-get.js.map +1 -1
- package/dist/mcp/tools/in-scope.d.ts +8 -0
- package/dist/mcp/tools/in-scope.js +125 -0
- package/dist/mcp/tools/in-scope.js.map +1 -0
- package/dist/mcp/tools/index.js +7 -12
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/init-phases.d.ts +18 -10
- package/dist/mcp/tools/init-phases.js +139 -192
- package/dist/mcp/tools/init-phases.js.map +1 -1
- package/dist/mcp/tools/invariant-get.js +2 -2
- package/dist/mcp/tools/invariant-get.js.map +1 -1
- package/dist/mcp/tools/record-decision.d.ts +4 -3
- package/dist/mcp/tools/record-decision.js +111 -36
- package/dist/mcp/tools/record-decision.js.map +1 -1
- package/dist/mcp/tools/reject-candidate.d.ts +1 -1
- package/dist/mcp/tools/reject-candidate.js +3 -3
- package/dist/mcp/tools/reject-candidate.js.map +1 -1
- package/dist/mcp/tools/resolve-attention.d.ts +5 -18
- package/dist/mcp/tools/resolve-attention.js +58 -158
- package/dist/mcp/tools/resolve-attention.js.map +1 -1
- package/dist/mcp/tools/search-candidates.d.ts +1 -1
- package/dist/mcp/tools/search-candidates.js +4 -4
- package/dist/mcp/tools/search-candidates.js.map +1 -1
- package/dist/mcp/tools/search.js +5 -4
- package/dist/mcp/tools/search.js.map +1 -1
- package/dist/mcp/tools/supersedes-chain.js +2 -2
- package/dist/mcp/tools/supersedes-chain.js.map +1 -1
- package/dist/mcp/tools/task-create.d.ts +1 -0
- package/dist/mcp/tools/task-create.js +2 -0
- package/dist/mcp/tools/task-create.js.map +1 -1
- package/dist/mcp/tools/timeline.js +1 -1
- package/dist/mcp/tools/timeline.js.map +1 -1
- package/dist/mcp/tools/types.d.ts +1 -0
- package/dist/mcp/tools/types.js +9 -1
- package/dist/mcp/tools/types.js.map +1 -1
- package/dist/sensors/attestation.d.ts +1 -1
- package/dist/sensors/attestation.js +2 -2
- package/dist/sensors/attestation.js.map +1 -1
- package/dist/sensors/catalog.d.ts +26 -28
- package/dist/sensors/catalog.js +79 -81
- package/dist/sensors/catalog.js.map +1 -1
- package/dist/sensors/decisions.d.ts +1 -1
- package/dist/sensors/decisions.js +15 -14
- package/dist/sensors/decisions.js.map +1 -1
- package/dist/sensors/diff.js +46 -22
- package/dist/sensors/diff.js.map +1 -1
- package/dist/sensors/runner.d.ts +2 -2
- package/dist/sensors/runner.js +3 -3
- package/dist/sensors/shell.d.ts +4 -0
- package/dist/sensors/shell.js +16 -0
- package/dist/sensors/shell.js.map +1 -0
- package/dist/sensors/structural.d.ts +3 -2
- package/dist/sensors/structural.js +3 -11
- package/dist/sensors/structural.js.map +1 -1
- package/dist/sensors/stub-catalog.d.ts +2 -1
- package/dist/sensors/stub-catalog.js +2 -9
- package/dist/sensors/stub-catalog.js.map +1 -1
- package/dist/sensors/types.d.ts +3 -4
- package/dist/sensors/types.js +1 -2
- package/dist/sensors/types.js.map +1 -1
- package/dist/session-start/build.js +1 -1
- package/dist/session-start/build.js.map +1 -1
- package/dist/status-line/event-queue.js +1 -1
- package/dist/status-line/index.d.ts +1 -1
- package/package.json +3 -2
- package/templates/.cairn/config/sensors.yaml +8 -8
- package/templates/attention-ui/app.js +61 -36
- package/dist/fs.d.ts +0 -5
- package/dist/fs.js +0 -11
- package/dist/fs.js.map +0 -1
- package/dist/ground/alignment-pending.d.ts +0 -28
- package/dist/ground/alignment-pending.js +0 -83
- package/dist/ground/alignment-pending.js.map +0 -1
- package/dist/ground/anchor-map.d.ts +0 -14
- package/dist/ground/anchor-map.js +0 -56
- package/dist/ground/anchor-map.js.map +0 -1
- package/dist/ground/drift.d.ts +0 -8
- package/dist/ground/drift.js +0 -23
- package/dist/ground/drift.js.map +0 -1
- package/dist/ground/file-candidates-map.d.ts +0 -23
- package/dist/ground/file-candidates-map.js +0 -76
- package/dist/ground/file-candidates-map.js.map +0 -1
- package/dist/ground/frontmatter.d.ts +0 -32
- package/dist/ground/frontmatter.js +0 -77
- package/dist/ground/frontmatter.js.map +0 -1
- package/dist/ground/glob.d.ts +0 -10
- package/dist/ground/glob.js +0 -46
- package/dist/ground/glob.js.map +0 -1
- package/dist/ground/index.d.ts +0 -25
- package/dist/ground/index.js +0 -19
- package/dist/ground/index.js.map +0 -1
- package/dist/ground/ledgers.d.ts +0 -14
- package/dist/ground/ledgers.js +0 -105
- package/dist/ground/ledgers.js.map +0 -1
- package/dist/ground/manifest.d.ts +0 -10
- package/dist/ground/manifest.js +0 -84
- package/dist/ground/manifest.js.map +0 -1
- package/dist/ground/paths.d.ts +0 -43
- package/dist/ground/paths.js +0 -109
- package/dist/ground/paths.js.map +0 -1
- package/dist/ground/quality-grades.d.ts +0 -11
- package/dist/ground/quality-grades.js +0 -100
- package/dist/ground/quality-grades.js.map +0 -1
- package/dist/ground/rejected.d.ts +0 -42
- package/dist/ground/rejected.js +0 -100
- package/dist/ground/rejected.js.map +0 -1
- package/dist/ground/schemas.d.ts +0 -582
- package/dist/ground/schemas.js +0 -372
- package/dist/ground/schemas.js.map +0 -1
- package/dist/ground/scope-index.d.ts +0 -96
- package/dist/ground/scope-index.js +0 -290
- package/dist/ground/scope-index.js.map +0 -1
- package/dist/ground/slug.d.ts +0 -60
- package/dist/ground/slug.js +0 -103
- package/dist/ground/slug.js.map +0 -1
- package/dist/ground/sot-bindings.d.ts +0 -14
- package/dist/ground/sot-bindings.js +0 -79
- package/dist/ground/sot-bindings.js.map +0 -1
- package/dist/ground/sot-cache.d.ts +0 -18
- package/dist/ground/sot-cache.js +0 -62
- package/dist/ground/sot-cache.js.map +0 -1
- package/dist/ground/topic-index.d.ts +0 -27
- package/dist/ground/topic-index.js +0 -82
- package/dist/ground/topic-index.js.map +0 -1
- package/dist/ground/walk.d.ts +0 -7
- package/dist/ground/walk.js +0 -53
- package/dist/ground/walk.js.map +0 -1
- package/dist/hooks/post-tool-use/ledger-cache.d.ts +0 -53
- package/dist/hooks/post-tool-use/ledger-cache.js +0 -338
- package/dist/hooks/post-tool-use/ledger-cache.js.map +0 -1
- package/dist/init/phases/10-strip.d.ts +0 -11
- package/dist/init/phases/10-strip.js.map +0 -1
- package/dist/init/phases/3b-seed.js.map +0 -1
- package/dist/init/phases/5-brand.js.map +0 -1
- package/dist/init/phases/5b-topic-index.js.map +0 -1
- package/dist/init/phases/6-docs-ingest.d.ts +0 -15
- package/dist/init/phases/6-docs-ingest.js.map +0 -1
- package/dist/init/phases/7b-source-comments.d.ts +0 -15
- package/dist/init/phases/7b-source-comments.js.map +0 -1
- package/dist/init/phases/7c-rules-merge.js.map +0 -1
- package/dist/init/phases/8-baseline.d.ts +0 -10
- package/dist/init/phases/8-baseline.js.map +0 -1
- package/dist/init/phases/parallel-678.js.map +0 -1
- package/dist/mcp/tools/decisions-in-scope.d.ts +0 -7
- package/dist/mcp/tools/decisions-in-scope.js +0 -66
- package/dist/mcp/tools/decisions-in-scope.js.map +0 -1
- package/dist/mcp/tools/invariants-in-scope.d.ts +0 -7
- package/dist/mcp/tools/invariants-in-scope.js +0 -81
- package/dist/mcp/tools/invariants-in-scope.js.map +0 -1
- package/dist/mcp/tools/propose-decision.d.ts +0 -34
- package/dist/mcp/tools/propose-decision.js +0 -200
- package/dist/mcp/tools/propose-decision.js.map +0 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { decisionsDir, invariantsDir, matchAnyGlob, parseFrontmatter, } from "@isaacriehm/cairn-state";
|
|
4
|
+
import { DecisionFrontmatter, InvariantFrontmatter, readScopeIndex, } from "@isaacriehm/cairn-state";
|
|
5
|
+
import { inScopeInput } from "../schemas.js";
|
|
6
|
+
async function handler(ctx, input) {
|
|
7
|
+
const types = new Set(input.types ?? ["decision", "invariant"]);
|
|
8
|
+
const path_globs = input.path_globs;
|
|
9
|
+
const statusFilter = input.status ? new Set(input.status) : null;
|
|
10
|
+
const scopeIndex = readScopeIndex(ctx.repoRoot);
|
|
11
|
+
const decIndexHits = new Set();
|
|
12
|
+
const invIndexHits = new Set();
|
|
13
|
+
if (scopeIndex !== null) {
|
|
14
|
+
for (const [filePath, entry] of Object.entries(scopeIndex.files)) {
|
|
15
|
+
if (entry.unscoped === true)
|
|
16
|
+
continue;
|
|
17
|
+
const matches = path_globs.some((g) => matchAnyGlob(g, [filePath]));
|
|
18
|
+
if (!matches)
|
|
19
|
+
continue;
|
|
20
|
+
for (const id of entry.decisions)
|
|
21
|
+
decIndexHits.add(id);
|
|
22
|
+
for (const id of entry.invariants)
|
|
23
|
+
invIndexHits.add(id);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const out = [];
|
|
27
|
+
// Decisions
|
|
28
|
+
if (types.has("decision")) {
|
|
29
|
+
const dir = decisionsDir(ctx.repoRoot);
|
|
30
|
+
if (existsSync(dir)) {
|
|
31
|
+
const wantStatus = statusFilter ?? new Set(["accepted"]);
|
|
32
|
+
for (const entry of readdirSync(dir, {
|
|
33
|
+
withFileTypes: true,
|
|
34
|
+
encoding: "utf8",
|
|
35
|
+
})) {
|
|
36
|
+
if (!entry.isFile() || !entry.name.endsWith(".md"))
|
|
37
|
+
continue;
|
|
38
|
+
const abs = join(dir, entry.name);
|
|
39
|
+
const parsed = parseFrontmatter(readFileSync(abs, "utf8"));
|
|
40
|
+
const fm = DecisionFrontmatter.safeParse(parsed.frontmatter);
|
|
41
|
+
if (!fm.success)
|
|
42
|
+
continue;
|
|
43
|
+
if (!wantStatus.has(fm.data.status))
|
|
44
|
+
continue;
|
|
45
|
+
const scope = fm.data.scope_globs ?? [];
|
|
46
|
+
const overlap = scope.length === 0
|
|
47
|
+
? false
|
|
48
|
+
: scope.some((scopeGlob) => path_globs.some((req) => matchAnyGlob(scopeGlob, [req]) ||
|
|
49
|
+
matchAnyGlob(req, [scopeGlob])));
|
|
50
|
+
const indexHit = decIndexHits.has(fm.data.id);
|
|
51
|
+
if (!overlap && !indexHit)
|
|
52
|
+
continue;
|
|
53
|
+
out.push({
|
|
54
|
+
id: fm.data.id,
|
|
55
|
+
kind: "decision",
|
|
56
|
+
title: fm.data.title,
|
|
57
|
+
status: fm.data.status,
|
|
58
|
+
...(fm.data.scope_globs ? { scope_globs: fm.data.scope_globs } : {}),
|
|
59
|
+
...(fm.data.decided_at ? { decided_at: fm.data.decided_at } : {}),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Invariants
|
|
65
|
+
if (types.has("invariant")) {
|
|
66
|
+
const iDir = invariantsDir(ctx.repoRoot);
|
|
67
|
+
const dDir = decisionsDir(ctx.repoRoot);
|
|
68
|
+
if (existsSync(iDir)) {
|
|
69
|
+
const wantStatus = statusFilter ?? new Set(["active"]);
|
|
70
|
+
const decisionScopeById = new Map();
|
|
71
|
+
if (existsSync(dDir)) {
|
|
72
|
+
for (const entry of readdirSync(dDir, {
|
|
73
|
+
withFileTypes: true,
|
|
74
|
+
encoding: "utf8",
|
|
75
|
+
})) {
|
|
76
|
+
if (!entry.isFile() || !entry.name.endsWith(".md"))
|
|
77
|
+
continue;
|
|
78
|
+
const parsed = parseFrontmatter(readFileSync(join(dDir, entry.name), "utf8"));
|
|
79
|
+
const fm = DecisionFrontmatter.safeParse(parsed.frontmatter);
|
|
80
|
+
if (!fm.success)
|
|
81
|
+
continue;
|
|
82
|
+
decisionScopeById.set(fm.data.id, fm.data.scope_globs ?? []);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
for (const entry of readdirSync(iDir, {
|
|
86
|
+
withFileTypes: true,
|
|
87
|
+
encoding: "utf8",
|
|
88
|
+
})) {
|
|
89
|
+
if (!entry.isFile() || !entry.name.endsWith(".md"))
|
|
90
|
+
continue;
|
|
91
|
+
const parsed = parseFrontmatter(readFileSync(join(iDir, entry.name), "utf8"));
|
|
92
|
+
const fm = InvariantFrontmatter.safeParse(parsed.frontmatter);
|
|
93
|
+
if (!fm.success)
|
|
94
|
+
continue;
|
|
95
|
+
const status = fm.data.status ?? "active";
|
|
96
|
+
if (!wantStatus.has(status))
|
|
97
|
+
continue;
|
|
98
|
+
const sourceDecision = fm.data.source_decision ?? null;
|
|
99
|
+
const scope = sourceDecision
|
|
100
|
+
? decisionScopeById.get(sourceDecision) ?? []
|
|
101
|
+
: [];
|
|
102
|
+
const overlap = scope.some((scopeGlob) => path_globs.some((req) => matchAnyGlob(scopeGlob, [req]) || matchAnyGlob(req, [scopeGlob])));
|
|
103
|
+
const indexHit = invIndexHits.has(fm.data.id);
|
|
104
|
+
if (!overlap && !indexHit)
|
|
105
|
+
continue;
|
|
106
|
+
out.push({
|
|
107
|
+
id: fm.data.id,
|
|
108
|
+
kind: "invariant",
|
|
109
|
+
title: fm.data.title,
|
|
110
|
+
status,
|
|
111
|
+
source_decision: sourceDecision,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
out.sort((a, b) => a.id.localeCompare(b.id));
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
export const inScopeTool = {
|
|
120
|
+
name: "cairn_in_scope",
|
|
121
|
+
description: "List decisions and/or invariants whose scope overlaps the given path_globs. Returns summaries with ID, title, and status.",
|
|
122
|
+
inputSchema: inScopeInput,
|
|
123
|
+
handler,
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=in-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-scope.js","sourceRoot":"","sources":["../../../src/mcp/tools/in-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,YAAY,E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,MAAM,CAAC,MAAM,WAAW,GAAmB;IACzC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,2HAA2H;IAC7H,WAAW,EAAE,YAAY;IACzB,OAAO;CACR,CAAC"}
|
package/dist/mcp/tools/index.js
CHANGED
|
@@ -8,13 +8,11 @@ import { bulkAcceptAttentionTool } from "./bulk-accept-attention.js";
|
|
|
8
8
|
import { canonicalForTopicTool } from "./canonical-for-topic.js";
|
|
9
9
|
import { decisionGetTool } from "./decision-get.js";
|
|
10
10
|
import { decisionsForSymbolTool } from "./decisions-for-symbol.js";
|
|
11
|
-
import { decisionsInScopeTool } from "./decisions-in-scope.js";
|
|
12
11
|
import { getFullTool } from "./get-full.js";
|
|
13
12
|
import { groundGetTool } from "./ground-get.js";
|
|
14
|
-
import {
|
|
13
|
+
import { inScopeTool } from "./in-scope.js";
|
|
14
|
+
import { initResumeTool, initRunTool, } from "./init-phases.js";
|
|
15
15
|
import { invariantGetTool } from "./invariant-get.js";
|
|
16
|
-
import { invariantsInScopeTool } from "./invariants-in-scope.js";
|
|
17
|
-
import { proposeDecisionTool } from "./propose-decision.js";
|
|
18
16
|
import { queryHistoryTool } from "./query-history.js";
|
|
19
17
|
import { recordDecisionTool } from "./record-decision.js";
|
|
20
18
|
import { rejectCandidateTool } from "./reject-candidate.js";
|
|
@@ -27,27 +25,25 @@ import { timelineTool } from "./timeline.js";
|
|
|
27
25
|
export const allTools = [
|
|
28
26
|
// Read — graph traversal
|
|
29
27
|
decisionGetTool,
|
|
30
|
-
decisionsInScopeTool,
|
|
31
28
|
decisionsForSymbolTool,
|
|
32
29
|
canonicalForTopicTool,
|
|
33
30
|
groundGetTool,
|
|
34
31
|
supersedesChainTool,
|
|
35
32
|
invariantGetTool,
|
|
36
|
-
|
|
33
|
+
inScopeTool,
|
|
37
34
|
// Read — 3-layer progressive
|
|
38
35
|
searchTool,
|
|
39
36
|
timelineTool,
|
|
40
37
|
getFullTool,
|
|
41
38
|
// Read — historical (gated)
|
|
42
39
|
queryHistoryTool,
|
|
43
|
-
// Read — phase 6 candidate surface
|
|
40
|
+
// Read — phase 6 candidate surface
|
|
44
41
|
searchCandidatesTool,
|
|
45
42
|
// Write
|
|
46
43
|
recordDecisionTool,
|
|
47
44
|
taskCreateTool,
|
|
48
45
|
archiveTool,
|
|
49
|
-
// Write — phase 6 candidate surface
|
|
50
|
-
proposeDecisionTool,
|
|
46
|
+
// Write — phase 6 candidate surface
|
|
51
47
|
rejectCandidateTool,
|
|
52
48
|
// Write — plugin-era
|
|
53
49
|
resolveAttentionTool,
|
|
@@ -58,9 +54,8 @@ export const allTools = [
|
|
|
58
54
|
attentionWaitTool,
|
|
59
55
|
// Write — Layer C SessionStart drain
|
|
60
56
|
alignDrainTool,
|
|
61
|
-
// Write — init pipeline (v0.2
|
|
57
|
+
// Write — init pipeline (v0.7.2 single-umbrella surface)
|
|
62
58
|
initResumeTool,
|
|
63
|
-
|
|
64
|
-
...initPhaseTools,
|
|
59
|
+
initRunTool,
|
|
65
60
|
];
|
|
66
61
|
//# sourceMappingURL=index.js.map
|
|
@@ -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;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E,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,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,WAAW;IACX,oCAAoC;IACpC,mBAAmB;IACnB,qBAAqB;IACrB,oBAAoB;IACpB,uBAAuB;IACvB,kBAAkB;IAClB,oBAAoB;IACpB,kBAAkB;IAClB,iBAAiB;IACjB,qCAAqC;IACrC,cAAc;IACd,yDAAyD;IACzD,cAAc;IACd,WAAW;CACZ,CAAC"}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MCP tools for the v0.3.5 init pipeline.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Two tools, single surface:
|
|
5
|
+
* 1. `cairn_init_resume` → { status, nextPhase, repoRoot }
|
|
6
|
+
* 2. `cairn_init_run({ phase, answer? })` → { status, nextPhase | question | error }
|
|
7
|
+
*
|
|
8
|
+
* The cairn-adopt skill drives the pipeline by:
|
|
7
9
|
* 1. cairn_init_resume → { status, nextPhase, repoRoot }
|
|
8
|
-
* 2.
|
|
10
|
+
* 2. cairn_init_run({ phase }) → { status, nextPhase | question | error }
|
|
9
11
|
* 3. AskUserQuestion if needs_input → re-call same tool with { answer }
|
|
10
12
|
* 4. loop on complete + advance until nextPhase === null
|
|
11
13
|
*
|
|
14
|
+
* Phase 8 (`8-docs-ingest`) is special: `cairn_init_run` internally
|
|
15
|
+
* dispatches the parallel 8/9/10 runner so the three Haiku-batched
|
|
16
|
+
* ingestion phases overlap on wall-clock. The combined result advances
|
|
17
|
+
* to `11-baseline`. The skill doesn't need a separate code path for
|
|
18
|
+
* this — `cairn_init_run` is the only umbrella.
|
|
19
|
+
*
|
|
12
20
|
* State persists to .cairn/init-state.json after every successful
|
|
13
21
|
* phase result so the operator can crash-recover. The skill no longer
|
|
14
|
-
* threads state through arguments —
|
|
15
|
-
* and only
|
|
22
|
+
* threads state through arguments — `cairn_init_run` reads state from
|
|
23
|
+
* disk and only needs an optional `answer` field for needs_input phases.
|
|
16
24
|
*
|
|
17
25
|
* Why no state echo: returning the full state in tool responses
|
|
18
26
|
* triggered MCP-level spillover-to-file once mapper output landed,
|
|
@@ -25,15 +33,15 @@
|
|
|
25
33
|
* `outputs: {}` would overwrite the on-disk state and lose all prior
|
|
26
34
|
* phase outputs — a single bad call could nuke a 90KB mapper run.
|
|
27
35
|
*/
|
|
28
|
-
import { type PhaseState } from "../../init/index.js";
|
|
36
|
+
import { type PhaseId, type PhaseState } from "../../init/index.js";
|
|
29
37
|
import type { ToolDef } from "./types.js";
|
|
30
|
-
interface
|
|
38
|
+
interface PhaseRunInput {
|
|
39
|
+
phase: PhaseId;
|
|
31
40
|
state?: PhaseState;
|
|
32
41
|
answer?: string;
|
|
33
42
|
}
|
|
34
43
|
interface ResumeToolInput {
|
|
35
44
|
}
|
|
36
|
-
export declare const
|
|
37
|
-
export declare const initParallel678Tool: ToolDef<PhaseToolInput>;
|
|
45
|
+
export declare const initRunTool: ToolDef<PhaseRunInput>;
|
|
38
46
|
export declare const initResumeTool: ToolDef<ResumeToolInput>;
|
|
39
47
|
export {};
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MCP tools for the v0.3.5 init pipeline.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Two tools, single surface:
|
|
5
|
+
* 1. `cairn_init_resume` → { status, nextPhase, repoRoot }
|
|
6
|
+
* 2. `cairn_init_run({ phase, answer? })` → { status, nextPhase | question | error }
|
|
7
|
+
*
|
|
8
|
+
* The cairn-adopt skill drives the pipeline by:
|
|
7
9
|
* 1. cairn_init_resume → { status, nextPhase, repoRoot }
|
|
8
|
-
* 2.
|
|
10
|
+
* 2. cairn_init_run({ phase }) → { status, nextPhase | question | error }
|
|
9
11
|
* 3. AskUserQuestion if needs_input → re-call same tool with { answer }
|
|
10
12
|
* 4. loop on complete + advance until nextPhase === null
|
|
11
13
|
*
|
|
14
|
+
* Phase 8 (`8-docs-ingest`) is special: `cairn_init_run` internally
|
|
15
|
+
* dispatches the parallel 8/9/10 runner so the three Haiku-batched
|
|
16
|
+
* ingestion phases overlap on wall-clock. The combined result advances
|
|
17
|
+
* to `11-baseline`. The skill doesn't need a separate code path for
|
|
18
|
+
* this — `cairn_init_run` is the only umbrella.
|
|
19
|
+
*
|
|
12
20
|
* State persists to .cairn/init-state.json after every successful
|
|
13
21
|
* phase result so the operator can crash-recover. The skill no longer
|
|
14
|
-
* threads state through arguments —
|
|
15
|
-
* and only
|
|
22
|
+
* threads state through arguments — `cairn_init_run` reads state from
|
|
23
|
+
* disk and only needs an optional `answer` field for needs_input phases.
|
|
16
24
|
*
|
|
17
25
|
* Why no state echo: returning the full state in tool responses
|
|
18
26
|
* triggered MCP-level spillover-to-file once mapper output landed,
|
|
@@ -26,7 +34,7 @@
|
|
|
26
34
|
* phase outputs — a single bad call could nuke a 90KB mapper run.
|
|
27
35
|
*/
|
|
28
36
|
import { z } from "zod";
|
|
29
|
-
import { PHASE_IDS, clearProgress, freshPhaseState, readPhaseState, resumePhases,
|
|
37
|
+
import { PHASE_IDS, clearProgress, freshPhaseState, readPhaseState, resumePhases, runPhase1Detect, runPhase2Walker, runPhase3Mapper, runPhase4Seed, runPhase5Pilot, runPhase6Brand, runPhase7TopicIndex, runPhase8DocsIngest, runPhase9SourceComments, runPhase10RulesMerge, runPhase11Baseline, runPhase12Strip, runPhase13Multidev, runPhases8910Parallel, writePhaseState, writeProgress, } from "../../init/index.js";
|
|
30
38
|
import { mcpError } from "../errors.js";
|
|
31
39
|
const phaseIdEnum = z.enum(PHASE_IDS);
|
|
32
40
|
const phaseStateSchema = z.object({
|
|
@@ -37,10 +45,12 @@ const phaseStateSchema = z.object({
|
|
|
37
45
|
startedAt: z.string().min(1),
|
|
38
46
|
schemaVersion: z.literal(1),
|
|
39
47
|
});
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
//
|
|
48
|
+
const phaseRunInput = {
|
|
49
|
+
phase: phaseIdEnum,
|
|
50
|
+
// State is optional — `cairn_init_run` reads .cairn/init-state.json
|
|
51
|
+
// by default. Callers can still pass an explicit state object (smoke
|
|
52
|
+
// tests, debug tooling) but the cairn-adopt skill should pass nothing
|
|
53
|
+
// here.
|
|
44
54
|
state: phaseStateSchema.optional(),
|
|
45
55
|
// Operator answer for needs_input phases. The wrapper splices this
|
|
46
56
|
// into state.answer before invoking the phase runner.
|
|
@@ -51,16 +61,16 @@ const RUNNERS = {
|
|
|
51
61
|
"1-detect": runPhase1Detect,
|
|
52
62
|
"2-walker": runPhase2Walker,
|
|
53
63
|
"3-mapper": runPhase3Mapper,
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
+
"4-seed": runPhase4Seed,
|
|
65
|
+
"5-pilot": runPhase5Pilot,
|
|
66
|
+
"6-brand": runPhase6Brand,
|
|
67
|
+
"7-topic-index": runPhase7TopicIndex,
|
|
68
|
+
"8-docs-ingest": runPhase8DocsIngest,
|
|
69
|
+
"9-source-comments": runPhase9SourceComments,
|
|
70
|
+
"10-rules-merge": runPhase10RulesMerge,
|
|
71
|
+
"11-baseline": runPhase11Baseline,
|
|
72
|
+
"12-strip": runPhase12Strip,
|
|
73
|
+
"13-multidev": runPhase13Multidev,
|
|
64
74
|
};
|
|
65
75
|
function toSlim(result) {
|
|
66
76
|
if (result.status === "complete") {
|
|
@@ -71,92 +81,116 @@ function toSlim(result) {
|
|
|
71
81
|
}
|
|
72
82
|
return { status: "error", error: result.error };
|
|
73
83
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return mcpError("VALIDATION_FAILED", `state.repoRoot ${state.repoRoot} does not match MCP context ${ctx.repoRoot}`);
|
|
98
|
-
}
|
|
99
|
-
// Splice the operator's answer into state for needs_input phases.
|
|
100
|
-
// The runner clears `state.answer` once it has consumed it (via
|
|
101
|
-
// `advancePhase`), so passing an answer to a phase that doesn't
|
|
102
|
-
// expect one is a no-op rather than a hazard.
|
|
103
|
-
const stateForRun = input.answer !== undefined && input.answer.length > 0
|
|
104
|
-
? { ...state, answer: input.answer }
|
|
105
|
-
: state;
|
|
106
|
-
const runner = RUNNERS[id];
|
|
107
|
-
// Coarse-grained statusline coverage: every phase gets at least
|
|
108
|
-
// one heartbeat write (batch=1, total=1) at entry so the operator
|
|
109
|
-
// sees the current phase id mid-init even for fast phases. The
|
|
110
|
-
// long phases (3-mapper, 6-docs-ingest, 7b-source-comments,
|
|
111
|
-
// 7c-rules-merge) overwrite with finer-grained per-batch progress
|
|
112
|
-
// from inside the runner. clearProgress at the end of every
|
|
113
|
-
// phase ensures stale heartbeats don't survive into the next.
|
|
114
|
-
const isLongPhase = id === "3-mapper" ||
|
|
115
|
-
id === "6-docs-ingest" ||
|
|
116
|
-
id === "7b-source-comments" ||
|
|
117
|
-
id === "7c-rules-merge";
|
|
118
|
-
if (!isLongPhase) {
|
|
119
|
-
writeProgress(state.repoRoot, {
|
|
120
|
-
phase: id,
|
|
121
|
-
batch: 1,
|
|
122
|
-
total: 1,
|
|
123
|
-
startedAt: Date.now(),
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
const t0 = performance.now();
|
|
127
|
-
const result = await runner(stateForRun);
|
|
128
|
-
const durationMs = Math.round(performance.now() - t0);
|
|
129
|
-
clearProgress(state.repoRoot);
|
|
130
|
-
// Stamp `duration_ms` on the phase's output entry so init-state.json
|
|
131
|
-
// carries an ETA-auditable record for every phase, not just the ones
|
|
132
|
-
// that bother to track time internally (3-mapper). The result.state
|
|
133
|
-
// returned by the runner is freshly constructed; mutating its
|
|
134
|
-
// current-phase entry is safe and doesn't ripple to prior phases.
|
|
135
|
-
if (result.status !== "error") {
|
|
136
|
-
const phaseOut = result.state.outputs[id];
|
|
137
|
-
if (typeof phaseOut === "object" && phaseOut !== null) {
|
|
138
|
-
const obj = phaseOut;
|
|
139
|
-
if (obj["duration_ms"] === undefined) {
|
|
140
|
-
obj["duration_ms"] = durationMs;
|
|
141
|
-
}
|
|
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;
|
|
142
107
|
}
|
|
143
108
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
+
async function handlePhaseRun(ctx, id, input) {
|
|
120
|
+
// Resolve state: prefer the explicit arg (smoke tests, debug
|
|
121
|
+
// tooling), fall back to disk (cairn-adopt skill default).
|
|
122
|
+
let state = input.state ?? null;
|
|
123
|
+
if (state === null) {
|
|
124
|
+
state = readPhaseState(ctx.repoRoot);
|
|
125
|
+
}
|
|
126
|
+
if (state === null) {
|
|
127
|
+
return mcpError("VALIDATION_FAILED", `cairn_init_run for phase ${id} found no init state at .cairn/init-state.json. Call cairn_init_resume to start a fresh pipeline.`);
|
|
128
|
+
}
|
|
129
|
+
// Sanity: the tool's id must match the phase id baked into state.
|
|
130
|
+
if (state.currentPhase !== id) {
|
|
131
|
+
return mcpError("VALIDATION_FAILED", `cairn_init_run for phase ${id} requires state.currentPhase=${id}, got ${state.currentPhase}`);
|
|
132
|
+
}
|
|
133
|
+
// The state's repoRoot drives the phase, but we sanity-check it
|
|
134
|
+
// against the MCP context's repoRoot so a misaddressed call
|
|
135
|
+
// (e.g. an old state file from a different repo) gets caught.
|
|
136
|
+
if (state.repoRoot !== ctx.repoRoot) {
|
|
137
|
+
return mcpError("VALIDATION_FAILED", `state.repoRoot ${state.repoRoot} does not match MCP context ${ctx.repoRoot}`);
|
|
138
|
+
}
|
|
139
|
+
// Splice the operator's answer into state for needs_input phases.
|
|
140
|
+
const stateForRun = input.answer !== undefined && input.answer.length > 0
|
|
141
|
+
? { ...state, answer: input.answer }
|
|
142
|
+
: 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
|
+
const runner = RUNNERS[id];
|
|
150
|
+
// Coarse-grained statusline coverage
|
|
151
|
+
const isLongPhase = id === "3-mapper" ||
|
|
152
|
+
id === "9-source-comments" ||
|
|
153
|
+
id === "10-rules-merge";
|
|
154
|
+
if (!isLongPhase) {
|
|
155
|
+
writeProgress(state.repoRoot, {
|
|
156
|
+
phase: id,
|
|
157
|
+
batch: 1,
|
|
158
|
+
total: 1,
|
|
159
|
+
startedAt: Date.now(),
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
const t0 = performance.now();
|
|
163
|
+
const result = await runner(stateForRun);
|
|
164
|
+
const durationMs = Math.round(performance.now() - t0);
|
|
165
|
+
clearProgress(state.repoRoot);
|
|
166
|
+
// Stamp `duration_ms` on the phase's output entry
|
|
167
|
+
if (result.status !== "error") {
|
|
168
|
+
const phaseOut = result.state.outputs[id];
|
|
169
|
+
if (typeof phaseOut === "object" && phaseOut !== null) {
|
|
170
|
+
const obj = phaseOut;
|
|
171
|
+
if (obj.duration_ms === undefined) {
|
|
172
|
+
obj.duration_ms = durationMs;
|
|
155
173
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// Persist state ONLY on non-error results.
|
|
177
|
+
if (result.status !== "error") {
|
|
178
|
+
try {
|
|
179
|
+
writePhaseState(result.state);
|
|
180
|
+
}
|
|
181
|
+
catch (err) {
|
|
182
|
+
return mcpError("INTERNAL_ERROR", `failed to persist init state: ${err instanceof Error ? err.message : String(err)}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return toSlim(result);
|
|
186
|
+
}
|
|
187
|
+
function makePhaseRunTool() {
|
|
188
|
+
return {
|
|
189
|
+
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 internally fans out to phases 8/9/10 in parallel and advances to 11-baseline; every other phase runs sequentially. The cairn-adopt skill loops on this tool until nextPhase === null.",
|
|
191
|
+
inputSchema: phaseRunInput,
|
|
192
|
+
handler: async (ctx, input) => {
|
|
193
|
+
return handlePhaseRun(ctx, input.phase, input);
|
|
160
194
|
},
|
|
161
195
|
};
|
|
162
196
|
}
|
|
@@ -180,93 +214,6 @@ function makeResumeTool() {
|
|
|
180
214
|
},
|
|
181
215
|
};
|
|
182
216
|
}
|
|
183
|
-
|
|
184
|
-
// Tool names go through MCP's allowed-character set — the dash in
|
|
185
|
-
// "7b-source-comments" is fine but we underscore for consistency
|
|
186
|
-
// with cairn_init_resume / cairn_record_decision conventions.
|
|
187
|
-
return id.replace(/-/g, "_");
|
|
188
|
-
}
|
|
189
|
-
function phaseDescription(id) {
|
|
190
|
-
switch (id) {
|
|
191
|
-
case "1-detect":
|
|
192
|
-
return "Phase 1-detect — scan the project's environment + stack signatures. Always advances; no operator input.";
|
|
193
|
-
case "2-walker":
|
|
194
|
-
return "Phase 2-walker — build the repo summary (manifest previews, by-extension counts, framework signals). Always advances.";
|
|
195
|
-
case "3-mapper":
|
|
196
|
-
return "Phase 3-mapper — Sonnet-driven domain map (chunked across module slices). Long-running; no operator input.";
|
|
197
|
-
case "3b-seed":
|
|
198
|
-
return "Phase 3b-seed — write .cairn/ skeleton + config.yaml + scope-index from templates and mapper output. Always advances; no operator input.";
|
|
199
|
-
case "4-pilot":
|
|
200
|
-
return "Phase 4-pilot — operator picks the seed module from mapper's top candidates (1 question).";
|
|
201
|
-
case "5-brand":
|
|
202
|
-
return "Phase 5-brand — operator picks how to populate the brand DEC drafts: skip / auto-fill / manual (1 question).";
|
|
203
|
-
case "5b-topic-index":
|
|
204
|
-
return "Phase 5b-topic-index — cross-source dedup pre-pass. Walks docs/*.md + CLAUDE.md + AGENTS.md + .claude/rules/* and emits topic-index.yaml + anchor-map.yaml so phases 6/7b/7c can dedup-by-topic instead of one DEC per source.";
|
|
205
|
-
case "6-docs-ingest":
|
|
206
|
-
return "Phase 6-docs-ingest — Haiku batch over README + docs/ → DEC drafts + canonical-map topics. No operator input.";
|
|
207
|
-
case "7b-source-comments":
|
|
208
|
-
return "Phase 7b-source-comments — Haiku batch over docblock-class source comments → DEC drafts + invariant proposals.";
|
|
209
|
-
case "7c-rules-merge":
|
|
210
|
-
return "Phase 7c-rules-merge — Haiku batch over CLAUDE.md / AGENTS.md / .claude/rules/* → propose net-new rules + flag conflicts.";
|
|
211
|
-
case "8-baseline":
|
|
212
|
-
return "Phase 8-baseline — first sensor sweep against synthetic full-tree diff. No operator input.";
|
|
213
|
-
case "10-strip":
|
|
214
|
-
return "Phase 10-strip — per-module strip-replace consent for source-comment essays. Operator picks strip / keep / skip per flagged module.";
|
|
215
|
-
case "12-multidev":
|
|
216
|
-
return "Phase 12-multidev — detect per-host package manager(s) and emit JOIN.md hints for new contributors. No filesystem mutations. Idempotent.";
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Combined parallel runner for the post-pilot ingestion window. Runs
|
|
221
|
-
* phases 6-docs-ingest, 7b-source-comments, and 7c-rules-merge in
|
|
222
|
-
* parallel inside a single MCP call. The cairn-adopt skill prefers
|
|
223
|
-
* this tool when state.currentPhase=6-docs-ingest; the per-phase
|
|
224
|
-
* sequential tools remain registered for fallback / debug paths.
|
|
225
|
-
*/
|
|
226
|
-
function makeParallel678Tool() {
|
|
227
|
-
return {
|
|
228
|
-
name: "cairn_init_phases_678_parallel",
|
|
229
|
-
description: "Run phases 6-docs-ingest, 7b-source-comments, and 7c-rules-merge concurrently. Pre-scans existing DEC + INV ids and threads shared Sets through all three so id allocations don't collide. Returns the combined slim response with nextPhase=8-baseline. Skill prefers this when state.currentPhase=6-docs-ingest; the per-phase sequential tools stay available for fallback. Wall-clock saves the smaller-two phases' time on real-world adoptions.",
|
|
230
|
-
inputSchema: initPhaseInput,
|
|
231
|
-
handler: async (ctx, input) => {
|
|
232
|
-
let state = input.state ?? null;
|
|
233
|
-
if (state === null) {
|
|
234
|
-
state = readPhaseState(ctx.repoRoot);
|
|
235
|
-
}
|
|
236
|
-
if (state === null) {
|
|
237
|
-
return mcpError("VALIDATION_FAILED", "cairn_init_phases_678_parallel found no init state at .cairn/init-state.json. Call cairn_init_resume to start a fresh pipeline.");
|
|
238
|
-
}
|
|
239
|
-
if (state.currentPhase !== "6-docs-ingest") {
|
|
240
|
-
return mcpError("VALIDATION_FAILED", `cairn_init_phases_678_parallel requires state.currentPhase=6-docs-ingest, got ${state.currentPhase}`);
|
|
241
|
-
}
|
|
242
|
-
if (state.repoRoot !== ctx.repoRoot) {
|
|
243
|
-
return mcpError("VALIDATION_FAILED", `state.repoRoot ${state.repoRoot} does not match MCP context ${ctx.repoRoot}`);
|
|
244
|
-
}
|
|
245
|
-
const t0 = performance.now();
|
|
246
|
-
const result = await runPhases678Parallel(state);
|
|
247
|
-
const durationMs = Math.round(performance.now() - t0);
|
|
248
|
-
if (result.status !== "error") {
|
|
249
|
-
for (const id of ["6-docs-ingest", "7b-source-comments", "7c-rules-merge"]) {
|
|
250
|
-
const phaseOut = result.state.outputs[id];
|
|
251
|
-
if (typeof phaseOut === "object" && phaseOut !== null) {
|
|
252
|
-
const obj = phaseOut;
|
|
253
|
-
if (obj["duration_ms"] === undefined) {
|
|
254
|
-
obj["duration_ms"] = durationMs;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
try {
|
|
259
|
-
writePhaseState(result.state);
|
|
260
|
-
}
|
|
261
|
-
catch (err) {
|
|
262
|
-
return mcpError("INTERNAL_ERROR", `failed to persist init state: ${err instanceof Error ? err.message : String(err)}`);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return toSlim(result);
|
|
266
|
-
},
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
export const initPhaseTools = PHASE_IDS.map((id) => makePhaseTool(id));
|
|
270
|
-
export const initParallel678Tool = makeParallel678Tool();
|
|
217
|
+
export const initRunTool = makePhaseRunTool();
|
|
271
218
|
export const initResumeTool = makeResumeTool();
|
|
272
219
|
//# sourceMappingURL=init-phases.js.map
|