@isaacriehm/cairn-core 0.1.10 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/claude/runner.d.ts +1 -1
- package/dist/claude/runner.js +62 -1
- package/dist/claude/runner.js.map +1 -1
- package/dist/claude/types.d.ts +14 -7
- package/dist/claude/types.js +5 -7
- package/dist/claude/types.js.map +1 -1
- package/dist/context/index.d.ts +4 -4
- package/dist/context/index.js +3 -4
- package/dist/context/index.js.map +1 -1
- package/dist/context/spec-delta.js +3 -4
- package/dist/context/spec-delta.js.map +1 -1
- package/dist/context/task-summary.d.ts +18 -0
- package/dist/context/task-summary.js +89 -0
- package/dist/context/task-summary.js.map +1 -0
- package/dist/decision-capture/id.d.ts +21 -4
- package/dist/decision-capture/id.js +56 -5
- package/dist/decision-capture/id.js.map +1 -1
- package/dist/decision-capture/index.d.ts +7 -22
- package/dist/decision-capture/index.js +7 -17
- package/dist/decision-capture/index.js.map +1 -1
- package/dist/doctor/index.d.ts +2 -2
- package/dist/doctor/index.js +5 -60
- package/dist/doctor/index.js.map +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +1 -1
- package/dist/events/writer.d.ts +1 -1
- package/dist/events/writer.js +1 -1
- package/dist/gc/canary.d.ts +13 -23
- package/dist/gc/canary.js +36 -92
- package/dist/gc/canary.js.map +1 -1
- package/dist/gc/citation-integrity.d.ts +6 -6
- package/dist/gc/citation-integrity.js +64 -20
- package/dist/gc/citation-integrity.js.map +1 -1
- package/dist/gc/frontmatter.js +1 -1
- package/dist/gc/generator-drift.js +1 -1
- package/dist/gc/generator-drift.js.map +1 -1
- package/dist/gc/index.d.ts +2 -2
- package/dist/gc/index.js +1 -1
- package/dist/gc/index.js.map +1 -1
- package/dist/gc/quality-update.d.ts +4 -4
- package/dist/gc/quality-update.js +5 -5
- package/dist/gc/quality-update.js.map +1 -1
- package/dist/gc/types.d.ts +1 -30
- package/dist/ground/index.d.ts +2 -2
- package/dist/ground/index.js +1 -1
- package/dist/ground/index.js.map +1 -1
- package/dist/ground/ledgers.d.ts +0 -4
- package/dist/ground/ledgers.js +10 -8
- package/dist/ground/ledgers.js.map +1 -1
- package/dist/ground/manifest.js +0 -4
- package/dist/ground/manifest.js.map +1 -1
- package/dist/ground/paths.js +0 -1
- package/dist/ground/paths.js.map +1 -1
- package/dist/ground/quality-grades.js +3 -1
- package/dist/ground/quality-grades.js.map +1 -1
- package/dist/ground/schemas.d.ts +2 -7
- package/dist/ground/schemas.js +7 -2
- package/dist/ground/schemas.js.map +1 -1
- package/dist/ground/scope-index.d.ts +62 -14
- package/dist/ground/scope-index.js +215 -45
- package/dist/ground/scope-index.js.map +1 -1
- package/dist/hooks/bypass-detection.js +14 -17
- package/dist/hooks/bypass-detection.js.map +1 -1
- package/dist/hooks/defer.d.ts +50 -0
- package/dist/hooks/defer.js +87 -0
- package/dist/hooks/defer.js.map +1 -0
- package/dist/hooks/post-tool-use/citation-scanner.d.ts +7 -5
- package/dist/hooks/post-tool-use/citation-scanner.js +15 -9
- package/dist/hooks/post-tool-use/citation-scanner.js.map +1 -1
- package/dist/hooks/post-tool-use/copy-scanner.js +1 -1
- package/dist/hooks/post-tool-use/copy-scanner.js.map +1 -1
- package/dist/hooks/post-tool-use/ledger-cache.d.ts +10 -2
- package/dist/hooks/post-tool-use/ledger-cache.js +58 -4
- package/dist/hooks/post-tool-use/ledger-cache.js.map +1 -1
- package/dist/hooks/post-tool-use/legend-builder.d.ts +3 -3
- package/dist/hooks/post-tool-use/legend-builder.js +30 -8
- package/dist/hooks/post-tool-use/legend-builder.js.map +1 -1
- package/dist/hooks/post-tool-use/read-enricher.d.ts +1 -1
- package/dist/hooks/post-tool-use/read-enricher.js +68 -21
- package/dist/hooks/post-tool-use/read-enricher.js.map +1 -1
- package/dist/hooks/post-tool-use/write-guardian.js +148 -18
- package/dist/hooks/post-tool-use/write-guardian.js.map +1 -1
- package/dist/hooks/runners/index.d.ts +3 -0
- package/dist/hooks/runners/index.js +2 -0
- package/dist/hooks/runners/index.js.map +1 -1
- package/dist/hooks/runners/payload.d.ts +1 -1
- package/dist/hooks/runners/payload.js +27 -12
- package/dist/hooks/runners/payload.js.map +1 -1
- package/dist/hooks/runners/session-start.js +250 -75
- package/dist/hooks/runners/session-start.js.map +1 -1
- package/dist/hooks/runners/stop.d.ts +9 -12
- package/dist/hooks/runners/stop.js +129 -41
- package/dist/hooks/runners/stop.js.map +1 -1
- package/dist/hooks/runners/user-prompt-submit.d.ts +15 -0
- package/dist/hooks/runners/user-prompt-submit.js +149 -0
- package/dist/hooks/runners/user-prompt-submit.js.map +1 -0
- package/dist/hooks/seed-attested.d.ts +25 -0
- package/dist/hooks/seed-attested.js +84 -0
- package/dist/hooks/seed-attested.js.map +1 -0
- package/dist/hooks/user-prompt-submit.d.ts +7 -0
- package/dist/hooks/user-prompt-submit.js +12 -0
- package/dist/hooks/user-prompt-submit.js.map +1 -0
- package/dist/index.d.ts +3 -6
- package/dist/index.js +14 -12
- package/dist/index.js.map +1 -1
- package/dist/init/baseline-audit.d.ts +5 -1
- package/dist/init/baseline-audit.js +25 -2
- package/dist/init/baseline-audit.js.map +1 -1
- package/dist/init/glob-inference.d.ts +16 -0
- package/dist/init/glob-inference.js +108 -0
- package/dist/init/glob-inference.js.map +1 -0
- package/dist/init/index.d.ts +4 -0
- package/dist/init/index.js +2 -0
- package/dist/init/index.js.map +1 -1
- package/dist/init/ingest-docs.d.ts +1 -1
- package/dist/init/ingest-docs.js +19 -6
- package/dist/init/ingest-docs.js.map +1 -1
- package/dist/init/init.js +17 -94
- package/dist/init/init.js.map +1 -1
- package/dist/init/mapper-merge.d.ts +8 -2
- package/dist/init/mapper-merge.js +50 -32
- package/dist/init/mapper-merge.js.map +1 -1
- package/dist/init/mapper-parallel.d.ts +2 -3
- package/dist/init/mapper-parallel.js +9 -38
- package/dist/init/mapper-parallel.js.map +1 -1
- package/dist/init/mapper-prompts.js +1 -1
- package/dist/init/mapper-prompts.js.map +1 -1
- package/dist/init/mapper.d.ts +7 -128
- package/dist/init/mapper.js +30 -7
- package/dist/init/mapper.js.map +1 -1
- package/dist/init/module-slicer.d.ts +1 -1
- package/dist/init/module-slicer.js +1 -1
- package/dist/init/multi-dev/install.d.ts +9 -10
- package/dist/init/multi-dev/install.js +15 -84
- package/dist/init/multi-dev/install.js.map +1 -1
- package/dist/init/overlay.d.ts +14 -0
- package/dist/init/overlay.js +65 -0
- package/dist/init/overlay.js.map +1 -0
- package/dist/init/phases/1-detect.d.ts +10 -0
- package/dist/init/phases/1-detect.js +36 -0
- package/dist/init/phases/1-detect.js.map +1 -0
- package/dist/init/phases/10-strip.d.ts +11 -0
- package/dist/init/phases/10-strip.js +79 -0
- package/dist/init/phases/10-strip.js.map +1 -0
- package/dist/init/phases/12-multidev.d.ts +6 -0
- package/dist/init/phases/12-multidev.js +34 -0
- package/dist/init/phases/12-multidev.js.map +1 -0
- package/dist/init/phases/2-walker.d.ts +8 -0
- package/dist/init/phases/2-walker.js +34 -0
- package/dist/init/phases/2-walker.js.map +1 -0
- package/dist/init/phases/3-mapper.d.ts +14 -0
- package/dist/init/phases/3-mapper.js +56 -0
- package/dist/init/phases/3-mapper.js.map +1 -0
- package/dist/init/phases/3b-seed.d.ts +18 -0
- package/dist/init/phases/3b-seed.js +140 -0
- package/dist/init/phases/3b-seed.js.map +1 -0
- package/dist/init/phases/4-pilot.d.ts +10 -0
- package/dist/init/phases/4-pilot.js +108 -0
- package/dist/init/phases/4-pilot.js.map +1 -0
- package/dist/init/phases/5-brand.d.ts +10 -0
- package/dist/init/phases/5-brand.js +66 -0
- package/dist/init/phases/5-brand.js.map +1 -0
- package/dist/init/phases/6-docs-ingest.d.ts +11 -0
- package/dist/init/phases/6-docs-ingest.js +39 -0
- package/dist/init/phases/6-docs-ingest.js.map +1 -0
- package/dist/init/phases/7b-source-comments.d.ts +6 -0
- package/dist/init/phases/7b-source-comments.js +34 -0
- package/dist/init/phases/7b-source-comments.js.map +1 -0
- package/dist/init/phases/7c-rules-merge.d.ts +6 -0
- package/dist/init/phases/7c-rules-merge.js +34 -0
- package/dist/init/phases/7c-rules-merge.js.map +1 -0
- package/dist/init/phases/8-baseline.d.ts +10 -0
- package/dist/init/phases/8-baseline.js +52 -0
- package/dist/init/phases/8-baseline.js.map +1 -0
- package/dist/init/phases/index.d.ts +15 -0
- package/dist/init/phases/index.js +16 -0
- package/dist/init/phases/index.js.map +1 -0
- package/dist/init/phases/orchestrator.d.ts +49 -0
- package/dist/init/phases/orchestrator.js +85 -0
- package/dist/init/phases/orchestrator.js.map +1 -0
- package/dist/init/phases/state-io.d.ts +19 -0
- package/dist/init/phases/state-io.js +73 -0
- package/dist/init/phases/state-io.js.map +1 -0
- package/dist/init/phases/types.d.ts +93 -0
- package/dist/init/phases/types.js +30 -0
- package/dist/init/phases/types.js.map +1 -0
- package/dist/init/prompts.d.ts +6 -8
- package/dist/init/prompts.js +3 -6
- package/dist/init/prompts.js.map +1 -1
- package/dist/init/rules-merge/ingest.js +1 -1
- package/dist/init/seed.js +11 -2
- package/dist/init/seed.js.map +1 -1
- package/dist/init/source-comments/classify.d.ts +1 -41
- package/dist/init/source-comments/classify.js +68 -37
- package/dist/init/source-comments/classify.js.map +1 -1
- package/dist/init/source-comments/index.d.ts +2 -2
- package/dist/init/source-comments/index.js +2 -2
- package/dist/init/source-comments/index.js.map +1 -1
- package/dist/init/source-comments/ingest.d.ts +38 -2
- package/dist/init/source-comments/ingest.js +237 -4
- package/dist/init/source-comments/ingest.js.map +1 -1
- package/dist/init/source-comments/strip-replace.d.ts +10 -19
- package/dist/init/source-comments/strip-replace.js +26 -2
- package/dist/init/source-comments/strip-replace.js.map +1 -1
- package/dist/init/source-comments/walker.d.ts +9 -2
- package/dist/init/source-comments/walker.js +38 -19
- package/dist/init/source-comments/walker.js.map +1 -1
- package/dist/init/submodules.d.ts +3 -2
- package/dist/init/types.d.ts +3 -5
- package/dist/init/types.js +3 -5
- package/dist/init/types.js.map +1 -1
- package/dist/init/visual.d.ts +4 -9
- package/dist/init/visual.js +1 -16
- package/dist/init/visual.js.map +1 -1
- package/dist/init/walker.d.ts +0 -6
- package/dist/init/walker.js +2 -3
- package/dist/init/walker.js.map +1 -1
- package/dist/join/index.js +49 -2
- package/dist/join/index.js.map +1 -1
- package/dist/logger.d.ts +1 -2
- package/dist/logger.js +5 -6
- package/dist/logger.js.map +1 -1
- package/dist/mcp/context.d.ts +2 -3
- package/dist/mcp/context.js.map +1 -1
- package/dist/mcp/errors.d.ts +1 -1
- package/dist/mcp/errors.js.map +1 -1
- package/dist/mcp/history/prompt.d.ts +2 -1
- package/dist/mcp/history/walker.js +1 -1
- package/dist/mcp/history/walker.js.map +1 -1
- package/dist/mcp/path-allowlist.d.ts +0 -6
- package/dist/mcp/path-allowlist.js +0 -10
- package/dist/mcp/path-allowlist.js.map +1 -1
- package/dist/mcp/schemas.d.ts +34 -72
- package/dist/mcp/schemas.js +40 -70
- package/dist/mcp/schemas.js.map +1 -1
- package/dist/mcp/serve.d.ts +1 -1
- package/dist/mcp/serve.js +2 -5
- package/dist/mcp/serve.js.map +1 -1
- package/dist/mcp/server.js +10 -4
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/telemetry.d.ts +8 -1
- package/dist/mcp/telemetry.js +16 -0
- package/dist/mcp/telemetry.js.map +1 -1
- package/dist/mcp/tools/decision-get.js +37 -29
- package/dist/mcp/tools/decision-get.js.map +1 -1
- package/dist/mcp/tools/decisions-in-scope.js +22 -3
- package/dist/mcp/tools/decisions-in-scope.js.map +1 -1
- package/dist/mcp/tools/ground-get.js +2 -2
- package/dist/mcp/tools/ground-get.js.map +1 -1
- package/dist/mcp/tools/index.js +6 -2
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/init-phases.d.ts +24 -0
- package/dist/mcp/tools/init-phases.js +140 -0
- package/dist/mcp/tools/init-phases.js.map +1 -0
- package/dist/mcp/tools/invariant-get.js +1 -1
- package/dist/mcp/tools/invariant-get.js.map +1 -1
- package/dist/mcp/tools/invariants-in-scope.js +26 -7
- package/dist/mcp/tools/invariants-in-scope.js.map +1 -1
- package/dist/mcp/tools/query-history.js +3 -3
- package/dist/mcp/tools/query-history.js.map +1 -1
- package/dist/mcp/tools/resolve-attention.d.ts +6 -4
- package/dist/mcp/tools/resolve-attention.js +253 -24
- package/dist/mcp/tools/resolve-attention.js.map +1 -1
- package/dist/mcp/tools/search.js +3 -4
- package/dist/mcp/tools/search.js.map +1 -1
- package/dist/mcp/tools/task-create.d.ts +15 -0
- package/dist/mcp/tools/task-create.js +96 -0
- package/dist/mcp/tools/task-create.js.map +1 -0
- package/dist/mcp/tools/timeline.js +3 -7
- package/dist/mcp/tools/timeline.js.map +1 -1
- package/dist/profiles/types.d.ts +2 -2
- package/dist/profiles/types.js +1 -1
- package/dist/sensors/catalog.js +8 -3
- package/dist/sensors/catalog.js.map +1 -1
- package/dist/session/id.d.ts +1 -3
- package/dist/session/id.js +1 -1
- package/dist/session/id.js.map +1 -1
- package/dist/session-start/build.d.ts +7 -11
- package/dist/session-start/build.js +62 -34
- package/dist/session-start/build.js.map +1 -1
- package/dist/session-start/index.d.ts +2 -2
- package/dist/session-start/index.js +2 -2
- package/dist/session-start/index.js.map +1 -1
- package/dist/session-start/templates.d.ts +20 -4
- package/dist/session-start/templates.js +45 -35
- package/dist/session-start/templates.js.map +1 -1
- package/dist/status-line/format.d.ts +20 -9
- package/dist/status-line/format.js +45 -35
- package/dist/status-line/format.js.map +1 -1
- package/dist/status-line/index.d.ts +3 -4
- package/dist/status-line/index.js +1 -1
- package/dist/status-line/index.js.map +1 -1
- package/dist/status-line/reader.d.ts +9 -6
- package/dist/status-line/reader.js +50 -18
- package/dist/status-line/reader.js.map +1 -1
- package/dist/status-line/writer.d.ts +6 -9
- package/dist/status-line/writer.js +10 -12
- package/dist/status-line/writer.js.map +1 -1
- package/dist/trace/index.d.ts +44 -0
- package/dist/trace/index.js +51 -0
- package/dist/trace/index.js.map +1 -0
- package/package.json +2 -3
- package/templates/.archive/README.md +3 -3
- package/templates/.cairn/JOIN.md +3 -9
- package/templates/.cairn/config/sensors.yaml +16 -19
- package/templates/.cairn/config/stub-patterns.yaml +4 -4
- package/templates/.cairn/config/trust-policy.yaml +3 -35
- package/templates/.cairn/config/workflow.md +13 -194
- package/templates/.cairn/git-hooks/commit-msg +15 -4
- package/templates/.cairn/git-hooks/pre-commit +22 -13
- package/templates/.cairn/ground/canonical-map/topics.yaml +3 -26
- package/templates/.cairn/ground/capabilities/snippets.yaml +0 -1
- package/templates/.cairn/ground/manifest.yaml +5 -8
- package/templates/.cairn/ground/product/personas.yaml +0 -1
- package/dist/context/checkpoint.d.ts +0 -10
- package/dist/context/checkpoint.js +0 -29
- package/dist/context/checkpoint.js.map +0 -1
- package/dist/decision-capture/capture.d.ts +0 -57
- package/dist/decision-capture/capture.js +0 -186
- package/dist/decision-capture/capture.js.map +0 -1
- package/dist/decision-capture/extractor.d.ts +0 -20
- package/dist/decision-capture/extractor.js +0 -103
- package/dist/decision-capture/extractor.js.map +0 -1
- package/dist/decision-capture/prompt.d.ts +0 -15
- package/dist/decision-capture/prompt.js +0 -68
- package/dist/decision-capture/prompt.js.map +0 -1
- package/dist/decision-capture/refinement-prompt.d.ts +0 -25
- package/dist/decision-capture/refinement-prompt.js +0 -146
- package/dist/decision-capture/refinement-prompt.js.map +0 -1
- package/dist/decision-capture/refinement-schema.d.ts +0 -52
- package/dist/decision-capture/refinement-schema.js +0 -61
- package/dist/decision-capture/refinement-schema.js.map +0 -1
- package/dist/decision-capture/refinement.d.ts +0 -60
- package/dist/decision-capture/refinement.js +0 -439
- package/dist/decision-capture/refinement.js.map +0 -1
- package/dist/decision-capture/schema.d.ts +0 -70
- package/dist/decision-capture/schema.js +0 -71
- package/dist/decision-capture/schema.js.map +0 -1
- package/dist/decision-capture/types.d.ts +0 -201
- package/dist/decision-capture/types.js +0 -20
- package/dist/decision-capture/types.js.map +0 -1
- package/dist/decision-capture/writer.d.ts +0 -90
- package/dist/decision-capture/writer.js +0 -267
- package/dist/decision-capture/writer.js.map +0 -1
- package/dist/frontend-types.d.ts +0 -243
- package/dist/frontend-types.js +0 -15
- package/dist/frontend-types.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -12
- package/dist/hooks/index.js +0 -13
- package/dist/hooks/index.js.map +0 -1
- package/dist/inbox.d.ts +0 -17
- package/dist/inbox.js +0 -30
- package/dist/inbox.js.map +0 -1
- package/dist/mcp/tools/append-run-note.d.ts +0 -18
- package/dist/mcp/tools/append-run-note.js +0 -47
- package/dist/mcp/tools/append-run-note.js.map +0 -1
- package/dist/mcp/tools/append.d.ts +0 -8
- package/dist/mcp/tools/append.js +0 -37
- package/dist/mcp/tools/append.js.map +0 -1
- package/dist/mcp/tools/ask-operator.d.ts +0 -34
- package/dist/mcp/tools/ask-operator.js +0 -97
- package/dist/mcp/tools/ask-operator.js.map +0 -1
- package/dist/mcp/tools/drop-task.d.ts +0 -12
- package/dist/mcp/tools/drop-task.js +0 -68
- package/dist/mcp/tools/drop-task.js.map +0 -1
- package/dist/mcp/tools/record-run-event.d.ts +0 -10
- package/dist/mcp/tools/record-run-event.js +0 -32
- package/dist/mcp/tools/record-run-event.js.map +0 -1
- package/dist/prompt.d.ts +0 -19
- package/dist/prompt.js +0 -50
- package/dist/prompt.js.map +0 -1
- package/dist/tier0/classify.d.ts +0 -10
- package/dist/tier0/classify.js +0 -110
- package/dist/tier0/classify.js.map +0 -1
- package/dist/tier0/index.d.ts +0 -2
- package/dist/tier0/index.js +0 -2
- package/dist/tier0/index.js.map +0 -1
- package/dist/tier0/types.d.ts +0 -24
- package/dist/tier0/types.js +0 -9
- package/dist/tier0/types.js.map +0 -1
- package/dist/tightener/index.d.ts +0 -4
- package/dist/tightener/index.js +0 -4
- package/dist/tightener/index.js.map +0 -1
- package/dist/tightener/prompt.d.ts +0 -3
- package/dist/tightener/prompt.js +0 -67
- package/dist/tightener/prompt.js.map +0 -1
- package/dist/tightener/schema.d.ts +0 -68
- package/dist/tightener/schema.js +0 -44
- package/dist/tightener/schema.js.map +0 -1
- package/dist/tightener/tighten.d.ts +0 -2
- package/dist/tightener/tighten.js +0 -66
- package/dist/tightener/tighten.js.map +0 -1
- package/dist/tightener/types.d.ts +0 -74
- package/dist/tightener/types.js +0 -6
- package/dist/tightener/types.js.map +0 -1
- package/templates/.claude/settings.json +0 -57
- package/templates/.mcp.json +0 -8
- package/templates/README.md +0 -24
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestrator entry points for the MCP-native init pipeline.
|
|
3
|
+
*
|
|
4
|
+
* `resumePhases(repoRoot)` is the single readable surface for the
|
|
5
|
+
* cairn-adopt skill — it reads any persisted state, returns the next
|
|
6
|
+
* phase id, and (for fresh starts) constructs the initial PhaseState.
|
|
7
|
+
*
|
|
8
|
+
* Phase functions live in sibling files (one per id, see types.ts
|
|
9
|
+
* PHASE_IDS). The orchestrator does not invoke them directly; the
|
|
10
|
+
* skill driver calls each phase's MCP tool with the state returned
|
|
11
|
+
* from `resumePhases` and threads results forward.
|
|
12
|
+
*/
|
|
13
|
+
import { type PhaseId, type PhaseState, type ResumeReport } from "./types.js";
|
|
14
|
+
/**
|
|
15
|
+
* Construct the fresh state for a brand-new init run. No filesystem
|
|
16
|
+
* IO — the caller persists this via `writePhaseState` once phase
|
|
17
|
+
* 1-detect has created `.cairn/`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function freshPhaseState(repoRoot: string): PhaseState;
|
|
20
|
+
/**
|
|
21
|
+
* Read whatever init state is on disk for `repoRoot` and return the
|
|
22
|
+
* next phase the skill driver should invoke. If no state exists, the
|
|
23
|
+
* first phase becomes "ready".
|
|
24
|
+
*
|
|
25
|
+
* The persisted `state.currentPhase` IS the next phase to run:
|
|
26
|
+
* - On "complete", the phase function calls `advancePhase` to
|
|
27
|
+
* increment `currentPhase` to the successor before persisting.
|
|
28
|
+
* - On "needs_input", `currentPhase` stays put — the operator's
|
|
29
|
+
* answer feeds back into the same phase.
|
|
30
|
+
*
|
|
31
|
+
* The init-phases MCP tool clears the state file as soon as the final
|
|
32
|
+
* phase returns nextPhase=null, so a "done" report only fires when
|
|
33
|
+
* cleanup itself failed. We model that as "ready" pointing at the last
|
|
34
|
+
* phase id; the skill re-invokes (idempotent) and then clearPhaseState
|
|
35
|
+
* runs again.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resumePhases(repoRoot: string): ResumeReport;
|
|
38
|
+
/**
|
|
39
|
+
* Compute the phase id that follows `current` in PHASE_IDS, or null
|
|
40
|
+
* when `current` is already the last id. Pure function — useful from
|
|
41
|
+
* inside individual phase functions when stamping their PhaseResult.
|
|
42
|
+
*/
|
|
43
|
+
export declare function nextPhaseAfter(current: PhaseId): PhaseId | null;
|
|
44
|
+
/**
|
|
45
|
+
* Advance `state.currentPhase` to the next phase id. Returns a new
|
|
46
|
+
* state; does not mutate the input. Used by phase functions when
|
|
47
|
+
* stamping a "complete" result that hands off to the next phase.
|
|
48
|
+
*/
|
|
49
|
+
export declare function advancePhase(state: PhaseState): PhaseState;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestrator entry points for the MCP-native init pipeline.
|
|
3
|
+
*
|
|
4
|
+
* `resumePhases(repoRoot)` is the single readable surface for the
|
|
5
|
+
* cairn-adopt skill — it reads any persisted state, returns the next
|
|
6
|
+
* phase id, and (for fresh starts) constructs the initial PhaseState.
|
|
7
|
+
*
|
|
8
|
+
* Phase functions live in sibling files (one per id, see types.ts
|
|
9
|
+
* PHASE_IDS). The orchestrator does not invoke them directly; the
|
|
10
|
+
* skill driver calls each phase's MCP tool with the state returned
|
|
11
|
+
* from `resumePhases` and threads results forward.
|
|
12
|
+
*/
|
|
13
|
+
import { PHASE_IDS } from "./types.js";
|
|
14
|
+
import { readPhaseState } from "./state-io.js";
|
|
15
|
+
/**
|
|
16
|
+
* Construct the fresh state for a brand-new init run. No filesystem
|
|
17
|
+
* IO — the caller persists this via `writePhaseState` once phase
|
|
18
|
+
* 1-detect has created `.cairn/`.
|
|
19
|
+
*/
|
|
20
|
+
export function freshPhaseState(repoRoot) {
|
|
21
|
+
return {
|
|
22
|
+
repoRoot,
|
|
23
|
+
currentPhase: PHASE_IDS[0],
|
|
24
|
+
outputs: {},
|
|
25
|
+
startedAt: new Date().toISOString(),
|
|
26
|
+
schemaVersion: 1,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Read whatever init state is on disk for `repoRoot` and return the
|
|
31
|
+
* next phase the skill driver should invoke. If no state exists, the
|
|
32
|
+
* first phase becomes "ready".
|
|
33
|
+
*
|
|
34
|
+
* The persisted `state.currentPhase` IS the next phase to run:
|
|
35
|
+
* - On "complete", the phase function calls `advancePhase` to
|
|
36
|
+
* increment `currentPhase` to the successor before persisting.
|
|
37
|
+
* - On "needs_input", `currentPhase` stays put — the operator's
|
|
38
|
+
* answer feeds back into the same phase.
|
|
39
|
+
*
|
|
40
|
+
* The init-phases MCP tool clears the state file as soon as the final
|
|
41
|
+
* phase returns nextPhase=null, so a "done" report only fires when
|
|
42
|
+
* cleanup itself failed. We model that as "ready" pointing at the last
|
|
43
|
+
* phase id; the skill re-invokes (idempotent) and then clearPhaseState
|
|
44
|
+
* runs again.
|
|
45
|
+
*/
|
|
46
|
+
export function resumePhases(repoRoot) {
|
|
47
|
+
const persisted = readPhaseState(repoRoot);
|
|
48
|
+
if (persisted === null) {
|
|
49
|
+
return {
|
|
50
|
+
status: "ready",
|
|
51
|
+
nextPhase: PHASE_IDS[0],
|
|
52
|
+
state: freshPhaseState(repoRoot),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
status: "ready",
|
|
57
|
+
nextPhase: persisted.currentPhase,
|
|
58
|
+
state: persisted,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Compute the phase id that follows `current` in PHASE_IDS, or null
|
|
63
|
+
* when `current` is already the last id. Pure function — useful from
|
|
64
|
+
* inside individual phase functions when stamping their PhaseResult.
|
|
65
|
+
*/
|
|
66
|
+
export function nextPhaseAfter(current) {
|
|
67
|
+
const idx = PHASE_IDS.indexOf(current);
|
|
68
|
+
if (idx === -1)
|
|
69
|
+
return null;
|
|
70
|
+
if (idx === PHASE_IDS.length - 1)
|
|
71
|
+
return null;
|
|
72
|
+
return PHASE_IDS[idx + 1] ?? null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Advance `state.currentPhase` to the next phase id. Returns a new
|
|
76
|
+
* state; does not mutate the input. Used by phase functions when
|
|
77
|
+
* stamping a "complete" result that hands off to the next phase.
|
|
78
|
+
*/
|
|
79
|
+
export function advancePhase(state) {
|
|
80
|
+
const next = nextPhaseAfter(state.currentPhase);
|
|
81
|
+
if (next === null)
|
|
82
|
+
return state;
|
|
83
|
+
return { ...state, currentPhase: next, answer: undefined };
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=orchestrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../../src/init/phases/orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAoD,MAAM,YAAY,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO;QACL,QAAQ;QACR,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;QAC1B,OAAO,EAAE,EAAE;QACX,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,aAAa,EAAE,CAAC;KACjB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC3C,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,OAAO;YACL,MAAM,EAAE,OAAO;YACf,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;YACvB,KAAK,EAAE,eAAe,CAAC,QAAQ,CAAC;SACjC,CAAC;IACJ,CAAC;IACD,OAAO;QACL,MAAM,EAAE,OAAO;QACf,SAAS,EAAE,SAAS,CAAC,YAAY;QACjC,KAAK,EAAE,SAAS;KACjB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,IAAI,GAAG,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5B,IAAI,GAAG,KAAK,SAAS,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9C,OAAO,SAAS,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC;AACpC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAiB;IAC5C,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAChD,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAChC,OAAO,EAAE,GAAG,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State persistence for the MCP-native init pipeline.
|
|
3
|
+
*
|
|
4
|
+
* State lives at `.cairn/init-state.json` once that directory exists
|
|
5
|
+
* (after phase 1-detect creates it). Before that, no state file is
|
|
6
|
+
* written — `readPhaseState` returns null and the orchestrator starts
|
|
7
|
+
* fresh at "1-detect". After the final phase succeeds the state file
|
|
8
|
+
* is removed by `clearPhaseState`.
|
|
9
|
+
*/
|
|
10
|
+
import { type PhaseState } from "./types.js";
|
|
11
|
+
/** Filename relative to repoRoot. */
|
|
12
|
+
export declare const INIT_STATE_PATH: string;
|
|
13
|
+
export declare function phaseStateAbsPath(repoRoot: string): string;
|
|
14
|
+
/** Read the on-disk init state. Returns null if missing or unreadable. */
|
|
15
|
+
export declare function readPhaseState(repoRoot: string): PhaseState | null;
|
|
16
|
+
/** Atomically write the init state. Creates `.cairn/` if needed. */
|
|
17
|
+
export declare function writePhaseState(state: PhaseState): string;
|
|
18
|
+
/** Remove the init state file. No-op if it doesn't exist. */
|
|
19
|
+
export declare function clearPhaseState(repoRoot: string): void;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State persistence for the MCP-native init pipeline.
|
|
3
|
+
*
|
|
4
|
+
* State lives at `.cairn/init-state.json` once that directory exists
|
|
5
|
+
* (after phase 1-detect creates it). Before that, no state file is
|
|
6
|
+
* written — `readPhaseState` returns null and the orchestrator starts
|
|
7
|
+
* fresh at "1-detect". After the final phase succeeds the state file
|
|
8
|
+
* is removed by `clearPhaseState`.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync, } from "node:fs";
|
|
11
|
+
import { dirname, join } from "node:path";
|
|
12
|
+
import { PHASE_IDS } from "./types.js";
|
|
13
|
+
/** Filename relative to repoRoot. */
|
|
14
|
+
export const INIT_STATE_PATH = join(".cairn", "init-state.json");
|
|
15
|
+
export function phaseStateAbsPath(repoRoot) {
|
|
16
|
+
return join(repoRoot, INIT_STATE_PATH);
|
|
17
|
+
}
|
|
18
|
+
/** Read the on-disk init state. Returns null if missing or unreadable. */
|
|
19
|
+
export function readPhaseState(repoRoot) {
|
|
20
|
+
const abs = phaseStateAbsPath(repoRoot);
|
|
21
|
+
if (!existsSync(abs))
|
|
22
|
+
return null;
|
|
23
|
+
let parsed;
|
|
24
|
+
try {
|
|
25
|
+
parsed = JSON.parse(readFileSync(abs, "utf8"));
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if (!isPhaseState(parsed))
|
|
31
|
+
return null;
|
|
32
|
+
return parsed;
|
|
33
|
+
}
|
|
34
|
+
/** Atomically write the init state. Creates `.cairn/` if needed. */
|
|
35
|
+
export function writePhaseState(state) {
|
|
36
|
+
const abs = phaseStateAbsPath(state.repoRoot);
|
|
37
|
+
mkdirSync(dirname(abs), { recursive: true });
|
|
38
|
+
const tmp = `${abs}.tmp`;
|
|
39
|
+
writeFileSync(tmp, JSON.stringify(state, null, 2), "utf8");
|
|
40
|
+
// POSIX rename is atomic on the same filesystem (always true here:
|
|
41
|
+
// tmp + final are in the same .cairn/ dir).
|
|
42
|
+
renameSync(tmp, abs);
|
|
43
|
+
return abs;
|
|
44
|
+
}
|
|
45
|
+
/** Remove the init state file. No-op if it doesn't exist. */
|
|
46
|
+
export function clearPhaseState(repoRoot) {
|
|
47
|
+
rmSync(phaseStateAbsPath(repoRoot), { force: true });
|
|
48
|
+
}
|
|
49
|
+
function isPhaseId(v) {
|
|
50
|
+
return typeof v === "string" && PHASE_IDS.includes(v);
|
|
51
|
+
}
|
|
52
|
+
function isStringOrUndef(v) {
|
|
53
|
+
return v === undefined || typeof v === "string";
|
|
54
|
+
}
|
|
55
|
+
function isPhaseState(x) {
|
|
56
|
+
if (x === null || typeof x !== "object")
|
|
57
|
+
return false;
|
|
58
|
+
const o = x;
|
|
59
|
+
if (o["schemaVersion"] !== 1)
|
|
60
|
+
return false;
|
|
61
|
+
if (typeof o["repoRoot"] !== "string")
|
|
62
|
+
return false;
|
|
63
|
+
if (!isPhaseId(o["currentPhase"]))
|
|
64
|
+
return false;
|
|
65
|
+
if (typeof o["outputs"] !== "object" || o["outputs"] === null)
|
|
66
|
+
return false;
|
|
67
|
+
if (!isStringOrUndef(o["answer"]))
|
|
68
|
+
return false;
|
|
69
|
+
if (typeof o["startedAt"] !== "string")
|
|
70
|
+
return false;
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=state-io.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-io.js","sourceRoot":"","sources":["../../../src/init/phases/state-io.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAiC,MAAM,YAAY,CAAC;AAEtE,qCAAqC;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;AAEjE,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,OAAO,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;AACzC,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,MAAM,GAAG,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAClC,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C,MAAM,GAAG,GAAG,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC9C,SAAS,CAAC,O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I;QAAE,OAAO,KAAK,CAAC;IAC5E,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAChD,IAAI,OAAO,CAAC,CAAC,WAAW,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACrD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase types for the MCP-native init pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Each phase is a function `(ctx, state) → PhaseResult` registered as
|
|
5
|
+
* an MCP tool. The cairn-adopt skill drives the pipeline by invoking
|
|
6
|
+
* `cairn_init_resume` to read the next phase id, then calling the
|
|
7
|
+
* phase tool. When the phase returns `needs_input`, the skill renders
|
|
8
|
+
* an inline `AskUserQuestion`, threads the answer back, and re-invokes
|
|
9
|
+
* the same phase tool until it returns `complete` with the next id.
|
|
10
|
+
*
|
|
11
|
+
* State persists to `.cairn/init-state.json` between phases so the
|
|
12
|
+
* pipeline is crash-safe — operator can `/exit` Claude Code mid-init
|
|
13
|
+
* and pick up at the same phase on the next session.
|
|
14
|
+
*/
|
|
15
|
+
/** Phase ids in execution order. */
|
|
16
|
+
export declare const PHASE_IDS: readonly ["1-detect", "2-walker", "3-mapper", "3b-seed", "4-pilot", "5-brand", "6-docs-ingest", "7b-source-comments", "7c-rules-merge", "8-baseline", "10-strip", "12-multidev"];
|
|
17
|
+
export type PhaseId = (typeof PHASE_IDS)[number];
|
|
18
|
+
/** Inline A/B/C question rendered via AskUserQuestion in the skill. */
|
|
19
|
+
export interface PhaseQuestion {
|
|
20
|
+
/** Stable identifier so the skill can correlate answers across re-invocations. */
|
|
21
|
+
id: string;
|
|
22
|
+
/** Operator-facing prompt — full English, not caveman. */
|
|
23
|
+
prompt: string;
|
|
24
|
+
/** Options labeled A/B/C/... */
|
|
25
|
+
options: PhaseOption[];
|
|
26
|
+
/** Default option id (used when operator skips or auto-pilot is set). */
|
|
27
|
+
default: string;
|
|
28
|
+
}
|
|
29
|
+
export interface PhaseOption {
|
|
30
|
+
/** Internal id stored back into state.answer when chosen. */
|
|
31
|
+
id: string;
|
|
32
|
+
/** Operator-visible label. */
|
|
33
|
+
label: string;
|
|
34
|
+
/** Optional secondary line — displayed under the label. */
|
|
35
|
+
detail?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* State carried between phase invocations. `outputs` accumulates each
|
|
39
|
+
* phase's typed result keyed by phase id; `answer` is set by the skill
|
|
40
|
+
* driver when re-invoking a phase that returned `needs_input`.
|
|
41
|
+
*/
|
|
42
|
+
export interface PhaseState {
|
|
43
|
+
/** Repo root the pipeline is operating against. */
|
|
44
|
+
repoRoot: string;
|
|
45
|
+
/** The phase currently executing. */
|
|
46
|
+
currentPhase: PhaseId;
|
|
47
|
+
/** Accumulated outputs keyed by phase id. */
|
|
48
|
+
outputs: PhaseOutputs;
|
|
49
|
+
/** Operator's answer to the last `needs_input` question (if any). */
|
|
50
|
+
answer?: string | undefined;
|
|
51
|
+
/** When the pipeline started (ISO-8601). */
|
|
52
|
+
startedAt: string;
|
|
53
|
+
/** Schema version for the on-disk state file (bump on breaking change). */
|
|
54
|
+
schemaVersion: 1;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Phase outputs are deliberately loose-typed — each phase function
|
|
58
|
+
* stamps its own typed result under its id. Downstream phases read
|
|
59
|
+
* via type-narrowing helpers in their own modules.
|
|
60
|
+
*/
|
|
61
|
+
export type PhaseOutputs = {
|
|
62
|
+
-readonly [K in PhaseId]?: unknown;
|
|
63
|
+
};
|
|
64
|
+
/** Discriminated union returned by every phase function. */
|
|
65
|
+
export type PhaseResult = {
|
|
66
|
+
readonly status: "complete";
|
|
67
|
+
/** Next phase id to invoke; null = pipeline done. */
|
|
68
|
+
readonly nextPhase: PhaseId | null;
|
|
69
|
+
readonly state: PhaseState;
|
|
70
|
+
} | {
|
|
71
|
+
readonly status: "needs_input";
|
|
72
|
+
readonly question: PhaseQuestion;
|
|
73
|
+
readonly state: PhaseState;
|
|
74
|
+
} | {
|
|
75
|
+
readonly status: "error";
|
|
76
|
+
readonly error: PhaseError;
|
|
77
|
+
readonly state: PhaseState;
|
|
78
|
+
};
|
|
79
|
+
/** Phase failure mode — propagates back to the skill for operator surfacing. */
|
|
80
|
+
export interface PhaseError {
|
|
81
|
+
/** Stable error code; the skill can pattern-match for retry semantics. */
|
|
82
|
+
code: string;
|
|
83
|
+
/** Operator-facing message. */
|
|
84
|
+
message: string;
|
|
85
|
+
/** Optional captured stderr / stack for diagnostics. */
|
|
86
|
+
detail?: string;
|
|
87
|
+
}
|
|
88
|
+
/** Step the orchestrator is reporting on. Used by the resume entry point. */
|
|
89
|
+
export interface ResumeReport {
|
|
90
|
+
readonly status: "ready" | "done";
|
|
91
|
+
readonly nextPhase: PhaseId | null;
|
|
92
|
+
readonly state: PhaseState;
|
|
93
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase types for the MCP-native init pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Each phase is a function `(ctx, state) → PhaseResult` registered as
|
|
5
|
+
* an MCP tool. The cairn-adopt skill drives the pipeline by invoking
|
|
6
|
+
* `cairn_init_resume` to read the next phase id, then calling the
|
|
7
|
+
* phase tool. When the phase returns `needs_input`, the skill renders
|
|
8
|
+
* an inline `AskUserQuestion`, threads the answer back, and re-invokes
|
|
9
|
+
* the same phase tool until it returns `complete` with the next id.
|
|
10
|
+
*
|
|
11
|
+
* State persists to `.cairn/init-state.json` between phases so the
|
|
12
|
+
* pipeline is crash-safe — operator can `/exit` Claude Code mid-init
|
|
13
|
+
* and pick up at the same phase on the next session.
|
|
14
|
+
*/
|
|
15
|
+
/** Phase ids in execution order. */
|
|
16
|
+
export const PHASE_IDS = [
|
|
17
|
+
"1-detect",
|
|
18
|
+
"2-walker",
|
|
19
|
+
"3-mapper",
|
|
20
|
+
"3b-seed",
|
|
21
|
+
"4-pilot",
|
|
22
|
+
"5-brand",
|
|
23
|
+
"6-docs-ingest",
|
|
24
|
+
"7b-source-comments",
|
|
25
|
+
"7c-rules-merge",
|
|
26
|
+
"8-baseline",
|
|
27
|
+
"10-strip",
|
|
28
|
+
"12-multidev",
|
|
29
|
+
];
|
|
30
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/init/phases/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,oCAAoC;AACpC,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,UAAU;IACV,UAAU;IACV,UAAU;IACV,SAAS;IACT,SAAS;IACT,SAAS;IACT,eAAe;IACf,oBAAoB;IACpB,gBAAgB;IAChB,YAAY;IACZ,UAAU;IACV,aAAa;CACL,CAAC"}
|
package/dist/init/prompts.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Inquirer-driven prompts for `cairn init`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* `mode: "auto"` short-circuits prompts so smokes / scripted adoption can
|
|
9
|
-
* run non-interactively.
|
|
4
|
+
* Uses `@inquirer/prompts` for operator-facing dialogs. `mode: "auto"`
|
|
5
|
+
* short-circuits prompts so smokes / scripted adoption can run
|
|
6
|
+
* non-interactively.
|
|
10
7
|
*/
|
|
11
8
|
export type PromptMode = "interactive" | "auto";
|
|
12
9
|
export interface Choice<T extends string = string> {
|
|
@@ -30,7 +27,7 @@ export interface PromptOptions<T extends string> {
|
|
|
30
27
|
auto: T;
|
|
31
28
|
}
|
|
32
29
|
export declare function squareIntoSquareHole<T extends string>(opts: PromptOptions<T>): Promise<T>;
|
|
33
|
-
|
|
30
|
+
interface FreeTextOptions {
|
|
34
31
|
mode: PromptMode;
|
|
35
32
|
prompt: string;
|
|
36
33
|
defaultValue: string;
|
|
@@ -38,7 +35,7 @@ export interface FreeTextOptions {
|
|
|
38
35
|
auto?: string;
|
|
39
36
|
}
|
|
40
37
|
export declare function freeTextWithDefault(opts: FreeTextOptions): Promise<string>;
|
|
41
|
-
|
|
38
|
+
interface YesNoOptions {
|
|
42
39
|
mode: PromptMode;
|
|
43
40
|
prompt: string;
|
|
44
41
|
defaultYes?: boolean;
|
|
@@ -59,3 +56,4 @@ export declare function editYaml(opts: EditorOptions): Promise<string>;
|
|
|
59
56
|
export declare function info(line: string): void;
|
|
60
57
|
export declare function header(line: string): void;
|
|
61
58
|
export declare function done(line: string): void;
|
|
59
|
+
export {};
|
package/dist/init/prompts.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Inquirer-driven prompts for `cairn init`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* `mode: "auto"` short-circuits prompts so smokes / scripted adoption can
|
|
9
|
-
* run non-interactively.
|
|
4
|
+
* Uses `@inquirer/prompts` for operator-facing dialogs. `mode: "auto"`
|
|
5
|
+
* short-circuits prompts so smokes / scripted adoption can run
|
|
6
|
+
* non-interactively.
|
|
10
7
|
*/
|
|
11
8
|
import { confirm, editor, input, select } from "@inquirer/prompts";
|
|
12
9
|
export async function squareIntoSquareHole(opts) {
|
package/dist/init/prompts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/init/prompts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/init/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AA0BnE,MAAM,CAAC,KAAK,UAAU,oBAAoB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ields:
|
|
60
60
|
- proposed_dec_title 5-10 word imperative title (only when kind = "rule-net-new")
|
|
61
61
|
- proposed_rationale 2-3 sentence summary (only when kind = "rule-net-new")
|
|
62
|
-
- conflicts_with DEC-NNNN or §
|
|
62
|
+
- conflicts_with DEC-NNNN or §INV-NNNN id (only when kind = "rule-conflict")
|
|
63
63
|
|
|
64
64
|
Be conservative. When in doubt, "informational".`;
|
|
65
65
|
/* -------------------------------------------------------------------------- */
|
package/dist/init/seed.js
CHANGED
|
@@ -10,8 +10,17 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync,
|
|
|
10
10
|
import { dirname, join, relative } from "node:path";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* dist/init/seed.js → walk up to package root, then into templates/.
|
|
15
|
+
* The Claude Code plugin bundle co-locates templates beside the bundle
|
|
16
|
+
* (packages/cairn-frontend-claudecode/dist/templates/) — esbuild
|
|
17
|
+
* --define flips the lookup so the bundled binary finds them as a
|
|
18
|
+
* sibling of dist/cli.cjs rather than two levels up from a per-module
|
|
19
|
+
* dist file.
|
|
20
|
+
*/
|
|
21
|
+
const TEMPLATES_ROOT = typeof __CAIRN_BUNDLED__ !== "undefined" && __CAIRN_BUNDLED__
|
|
22
|
+
? join(HERE, "templates")
|
|
23
|
+
: join(HERE, "..", "..", "templates");
|
|
15
24
|
export function seedCairnLayout(opts) {
|
|
16
25
|
const written = [];
|
|
17
26
|
const collisions = [];
|
package/dist/init/seed.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.js","sourceRoot":"","sources":["../../src/init/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,aAAa,GACd,MAAM,S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AC;SACnD,OAAO,CAAC,mBAAmB,EAAE,KAAK,IAAI,CAAC,WAAW,IAAI,CAAC;SACvD,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,IAAI,CAAC,GAAW,EAAE,MAA6B;IACtD,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YACpB,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACpB,CAAC;aAAM,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,aAAa;IAC3B,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,GAAW;IACvC,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,CACL,IAAI,KAAK,6BAA6B;QACtC,IAAI,KAAK,8BAA8B;QACvC,IAAI,KAAK,6BAA6B,CACvC,CAAC;AACJ,CAAC"}
|
|
@@ -20,7 +20,7 @@ export interface CommentClassification {
|
|
|
20
20
|
kind: CommentClassKind;
|
|
21
21
|
/** Proposed DEC draft title — non-empty only when classifier suggests one. */
|
|
22
22
|
suggestedDecDraft: string;
|
|
23
|
-
/** Proposed §
|
|
23
|
+
/** Proposed §INV invariant body — non-empty only when classifier suggests one. */
|
|
24
24
|
suggestedInvariant: string;
|
|
25
25
|
/** Canonical-map topic slug. */
|
|
26
26
|
suggestedCanonicalTopic: string;
|
|
@@ -56,43 +56,3 @@ export interface ClassifyResult {
|
|
|
56
56
|
batchesFailed: number;
|
|
57
57
|
}
|
|
58
58
|
export declare function classifyBlocks(args: ClassifyArgs): Promise<ClassifyResult>;
|
|
59
|
-
declare function buildBatchPrompt(batch: CommentBlock[]): string;
|
|
60
|
-
export declare const _internal: {
|
|
61
|
-
buildBatchPrompt: typeof buildBatchPrompt;
|
|
62
|
-
BATCH_SIZE: number;
|
|
63
|
-
BATCH_SCHEMA: {
|
|
64
|
-
readonly type: "object";
|
|
65
|
-
readonly additionalProperties: false;
|
|
66
|
-
readonly required: readonly ["results"];
|
|
67
|
-
readonly properties: {
|
|
68
|
-
readonly results: {
|
|
69
|
-
readonly type: "array";
|
|
70
|
-
readonly items: {
|
|
71
|
-
readonly type: "object";
|
|
72
|
-
readonly additionalProperties: false;
|
|
73
|
-
readonly required: readonly ["block_id", "kind"];
|
|
74
|
-
readonly properties: {
|
|
75
|
-
readonly block_id: {
|
|
76
|
-
readonly type: "string";
|
|
77
|
-
};
|
|
78
|
-
readonly kind: {
|
|
79
|
-
readonly type: "string";
|
|
80
|
-
readonly enum: readonly ["rationale", "constraint", "citation", "license", "other"];
|
|
81
|
-
};
|
|
82
|
-
readonly suggested_dec_draft: {
|
|
83
|
-
readonly type: "string";
|
|
84
|
-
};
|
|
85
|
-
readonly suggested_invariant: {
|
|
86
|
-
readonly type: "string";
|
|
87
|
-
};
|
|
88
|
-
readonly suggested_canonical_topic: {
|
|
89
|
-
readonly type: "string";
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
SYSTEM_PROMPT: string;
|
|
97
|
-
};
|
|
98
|
-
export {};
|