@isaacriehm/cairn-core 0.1.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/LICENSE +21 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/claude/error.d.ts +33 -0
- package/dist/claude/error.js +58 -0
- package/dist/claude/error.js.map +1 -0
- package/dist/claude/index.d.ts +3 -0
- package/dist/claude/index.js +3 -0
- package/dist/claude/index.js.map +1 -0
- package/dist/claude/runner.d.ts +11 -0
- package/dist/claude/runner.js +132 -0
- package/dist/claude/runner.js.map +1 -0
- package/dist/claude/types.d.ts +52 -0
- package/dist/claude/types.js +14 -0
- package/dist/claude/types.js.map +1 -0
- package/dist/context/checkpoint.d.ts +10 -0
- package/dist/context/checkpoint.js +29 -0
- package/dist/context/checkpoint.js.map +1 -0
- package/dist/context/handoff-builder.d.ts +11 -0
- package/dist/context/handoff-builder.js +268 -0
- package/dist/context/handoff-builder.js.map +1 -0
- package/dist/context/index.d.ts +11 -0
- package/dist/context/index.js +11 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/spec-delta.d.ts +47 -0
- package/dist/context/spec-delta.js +237 -0
- package/dist/context/spec-delta.js.map +1 -0
- package/dist/decision-capture/capture.d.ts +57 -0
- package/dist/decision-capture/capture.js +186 -0
- package/dist/decision-capture/capture.js.map +1 -0
- package/dist/decision-capture/extractor.d.ts +20 -0
- package/dist/decision-capture/extractor.js +103 -0
- package/dist/decision-capture/extractor.js.map +1 -0
- package/dist/decision-capture/id.d.ts +21 -0
- package/dist/decision-capture/id.js +60 -0
- package/dist/decision-capture/id.js.map +1 -0
- package/dist/decision-capture/index.d.ts +25 -0
- package/dist/decision-capture/index.js +21 -0
- package/dist/decision-capture/index.js.map +1 -0
- package/dist/decision-capture/prompt.d.ts +15 -0
- package/dist/decision-capture/prompt.js +68 -0
- package/dist/decision-capture/prompt.js.map +1 -0
- package/dist/decision-capture/refinement-prompt.d.ts +25 -0
- package/dist/decision-capture/refinement-prompt.js +146 -0
- package/dist/decision-capture/refinement-prompt.js.map +1 -0
- package/dist/decision-capture/refinement-schema.d.ts +52 -0
- package/dist/decision-capture/refinement-schema.js +61 -0
- package/dist/decision-capture/refinement-schema.js.map +1 -0
- package/dist/decision-capture/refinement.d.ts +60 -0
- package/dist/decision-capture/refinement.js +439 -0
- package/dist/decision-capture/refinement.js.map +1 -0
- package/dist/decision-capture/schema.d.ts +70 -0
- package/dist/decision-capture/schema.js +71 -0
- package/dist/decision-capture/schema.js.map +1 -0
- package/dist/decision-capture/types.d.ts +201 -0
- package/dist/decision-capture/types.js +20 -0
- package/dist/decision-capture/types.js.map +1 -0
- package/dist/decision-capture/writer.d.ts +90 -0
- package/dist/decision-capture/writer.js +267 -0
- package/dist/decision-capture/writer.js.map +1 -0
- package/dist/doctor/index.d.ts +48 -0
- package/dist/doctor/index.js +460 -0
- package/dist/doctor/index.js.map +1 -0
- package/dist/events/index.d.ts +15 -0
- package/dist/events/index.js +14 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/paths.d.ts +2 -0
- package/dist/events/paths.js +6 -0
- package/dist/events/paths.js.map +1 -0
- package/dist/events/reader.d.ts +40 -0
- package/dist/events/reader.js +139 -0
- package/dist/events/reader.js.map +1 -0
- package/dist/events/writer.d.ts +61 -0
- package/dist/events/writer.js +68 -0
- package/dist/events/writer.js.map +1 -0
- package/dist/frontend-types.d.ts +243 -0
- package/dist/frontend-types.js +15 -0
- package/dist/frontend-types.js.map +1 -0
- package/dist/gc/apply.d.ts +26 -0
- package/dist/gc/apply.js +48 -0
- package/dist/gc/apply.js.map +1 -0
- package/dist/gc/canary.d.ts +42 -0
- package/dist/gc/canary.js +134 -0
- package/dist/gc/canary.js.map +1 -0
- package/dist/gc/citation-integrity.d.ts +24 -0
- package/dist/gc/citation-integrity.js +151 -0
- package/dist/gc/citation-integrity.js.map +1 -0
- package/dist/gc/classify.d.ts +25 -0
- package/dist/gc/classify.js +89 -0
- package/dist/gc/classify.js.map +1 -0
- package/dist/gc/completion-integrity.d.ts +22 -0
- package/dist/gc/completion-integrity.js +165 -0
- package/dist/gc/completion-integrity.js.map +1 -0
- package/dist/gc/doc-gardening.d.ts +29 -0
- package/dist/gc/doc-gardening.js +146 -0
- package/dist/gc/doc-gardening.js.map +1 -0
- package/dist/gc/frontmatter.d.ts +35 -0
- package/dist/gc/frontmatter.js +105 -0
- package/dist/gc/frontmatter.js.map +1 -0
- package/dist/gc/generator-drift.d.ts +28 -0
- package/dist/gc/generator-drift.js +53 -0
- package/dist/gc/generator-drift.js.map +1 -0
- package/dist/gc/index.d.ts +42 -0
- package/dist/gc/index.js +30 -0
- package/dist/gc/index.js.map +1 -0
- package/dist/gc/quality-update.d.ts +23 -0
- package/dist/gc/quality-update.js +69 -0
- package/dist/gc/quality-update.js.map +1 -0
- package/dist/gc/scope-coverage.d.ts +20 -0
- package/dist/gc/scope-coverage.js +70 -0
- package/dist/gc/scope-coverage.js.map +1 -0
- package/dist/gc/stub-hits.d.ts +31 -0
- package/dist/gc/stub-hits.js +78 -0
- package/dist/gc/stub-hits.js.map +1 -0
- package/dist/gc/sweep.d.ts +56 -0
- package/dist/gc/sweep.js +205 -0
- package/dist/gc/sweep.js.map +1 -0
- package/dist/gc/types.d.ts +129 -0
- package/dist/gc/types.js +26 -0
- package/dist/gc/types.js.map +1 -0
- package/dist/gc/walk-source.d.ts +14 -0
- package/dist/gc/walk-source.js +59 -0
- package/dist/gc/walk-source.js.map +1 -0
- package/dist/ground/drift.d.ts +8 -0
- package/dist/ground/drift.js +23 -0
- package/dist/ground/drift.js.map +1 -0
- package/dist/ground/frontmatter.d.ts +20 -0
- package/dist/ground/frontmatter.js +49 -0
- package/dist/ground/frontmatter.js.map +1 -0
- package/dist/ground/glob.d.ts +10 -0
- package/dist/ground/glob.js +46 -0
- package/dist/ground/glob.js.map +1 -0
- package/dist/ground/index.d.ts +16 -0
- package/dist/ground/index.js +11 -0
- package/dist/ground/index.js.map +1 -0
- package/dist/ground/ledgers.d.ts +18 -0
- package/dist/ground/ledgers.js +103 -0
- package/dist/ground/ledgers.js.map +1 -0
- package/dist/ground/manifest.d.ts +10 -0
- package/dist/ground/manifest.js +88 -0
- package/dist/ground/manifest.js.map +1 -0
- package/dist/ground/paths.d.ts +20 -0
- package/dist/ground/paths.js +61 -0
- package/dist/ground/paths.js.map +1 -0
- package/dist/ground/quality-grades.d.ts +11 -0
- package/dist/ground/quality-grades.js +98 -0
- package/dist/ground/quality-grades.js.map +1 -0
- package/dist/ground/schemas.d.ts +306 -0
- package/dist/ground/schemas.js +188 -0
- package/dist/ground/schemas.js.map +1 -0
- package/dist/ground/scope-index.d.ts +48 -0
- package/dist/ground/scope-index.js +120 -0
- package/dist/ground/scope-index.js.map +1 -0
- package/dist/ground/walk.d.ts +7 -0
- package/dist/ground/walk.js +53 -0
- package/dist/ground/walk.js.map +1 -0
- package/dist/hooks/bypass-detection.d.ts +28 -0
- package/dist/hooks/bypass-detection.js +106 -0
- package/dist/hooks/bypass-detection.js.map +1 -0
- package/dist/hooks/index.d.ts +12 -0
- package/dist/hooks/index.js +13 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/post-tool-use/allowlist-reader.d.ts +14 -0
- package/dist/hooks/post-tool-use/allowlist-reader.js +69 -0
- package/dist/hooks/post-tool-use/allowlist-reader.js.map +1 -0
- package/dist/hooks/post-tool-use/citation-scanner.d.ts +23 -0
- package/dist/hooks/post-tool-use/citation-scanner.js +59 -0
- package/dist/hooks/post-tool-use/citation-scanner.js.map +1 -0
- package/dist/hooks/post-tool-use/copy-scanner.d.ts +25 -0
- package/dist/hooks/post-tool-use/copy-scanner.js +192 -0
- package/dist/hooks/post-tool-use/copy-scanner.js.map +1 -0
- package/dist/hooks/post-tool-use/index.d.ts +19 -0
- package/dist/hooks/post-tool-use/index.js +15 -0
- package/dist/hooks/post-tool-use/index.js.map +1 -0
- package/dist/hooks/post-tool-use/ledger-cache.d.ts +32 -0
- package/dist/hooks/post-tool-use/ledger-cache.js +236 -0
- package/dist/hooks/post-tool-use/ledger-cache.js.map +1 -0
- package/dist/hooks/post-tool-use/legend-builder.d.ts +15 -0
- package/dist/hooks/post-tool-use/legend-builder.js +84 -0
- package/dist/hooks/post-tool-use/legend-builder.js.map +1 -0
- package/dist/hooks/post-tool-use/read-enricher.d.ts +13 -0
- package/dist/hooks/post-tool-use/read-enricher.js +157 -0
- package/dist/hooks/post-tool-use/read-enricher.js.map +1 -0
- package/dist/hooks/post-tool-use/write-guardian.d.ts +17 -0
- package/dist/hooks/post-tool-use/write-guardian.js +176 -0
- package/dist/hooks/post-tool-use/write-guardian.js.map +1 -0
- package/dist/hooks/read-enrich.d.ts +6 -0
- package/dist/hooks/read-enrich.js +11 -0
- package/dist/hooks/read-enrich.js.map +1 -0
- package/dist/hooks/runners/index.d.ts +12 -0
- package/dist/hooks/runners/index.js +11 -0
- package/dist/hooks/runners/index.js.map +1 -0
- package/dist/hooks/runners/payload.d.ts +32 -0
- package/dist/hooks/runners/payload.js +70 -0
- package/dist/hooks/runners/payload.js.map +1 -0
- package/dist/hooks/runners/session-end.d.ts +7 -0
- package/dist/hooks/runners/session-end.js +42 -0
- package/dist/hooks/runners/session-end.js.map +1 -0
- package/dist/hooks/runners/session-start.d.ts +10 -0
- package/dist/hooks/runners/session-start.js +167 -0
- package/dist/hooks/runners/session-start.js.map +1 -0
- package/dist/hooks/runners/stop.d.ts +18 -0
- package/dist/hooks/runners/stop.js +165 -0
- package/dist/hooks/runners/stop.js.map +1 -0
- package/dist/hooks/session-end.d.ts +5 -0
- package/dist/hooks/session-end.js +10 -0
- package/dist/hooks/session-end.js.map +1 -0
- package/dist/hooks/session-start.d.ts +7 -0
- package/dist/hooks/session-start.js +12 -0
- package/dist/hooks/session-start.js.map +1 -0
- package/dist/hooks/stop.d.ts +5 -0
- package/dist/hooks/stop.js +10 -0
- package/dist/hooks/stop.js.map +1 -0
- package/dist/hooks/write-guard.d.ts +6 -0
- package/dist/hooks/write-guard.js +11 -0
- package/dist/hooks/write-guard.js.map +1 -0
- package/dist/inbox.d.ts +17 -0
- package/dist/inbox.js +30 -0
- package/dist/inbox.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/init/baseline-audit.d.ts +71 -0
- package/dist/init/baseline-audit.js +377 -0
- package/dist/init/baseline-audit.js.map +1 -0
- package/dist/init/brand-setup.d.ts +44 -0
- package/dist/init/brand-setup.js +201 -0
- package/dist/init/brand-setup.js.map +1 -0
- package/dist/init/daemon-autostart.d.ts +16 -0
- package/dist/init/daemon-autostart.js +95 -0
- package/dist/init/daemon-autostart.js.map +1 -0
- package/dist/init/detect.d.ts +25 -0
- package/dist/init/detect.js +319 -0
- package/dist/init/detect.js.map +1 -0
- package/dist/init/index.d.ts +32 -0
- package/dist/init/index.js +18 -0
- package/dist/init/index.js.map +1 -0
- package/dist/init/ingest-docs.d.ts +74 -0
- package/dist/init/ingest-docs.js +499 -0
- package/dist/init/ingest-docs.js.map +1 -0
- package/dist/init/init.d.ts +165 -0
- package/dist/init/init.js +1166 -0
- package/dist/init/init.js.map +1 -0
- package/dist/init/mapper-legacy.d.ts +148 -0
- package/dist/init/mapper-legacy.js +238 -0
- package/dist/init/mapper-legacy.js.map +1 -0
- package/dist/init/mapper-merge.d.ts +38 -0
- package/dist/init/mapper-merge.js +238 -0
- package/dist/init/mapper-merge.js.map +1 -0
- package/dist/init/mapper-parallel.d.ts +48 -0
- package/dist/init/mapper-parallel.js +409 -0
- package/dist/init/mapper-parallel.js.map +1 -0
- package/dist/init/mapper-prompts.d.ts +135 -0
- package/dist/init/mapper-prompts.js +189 -0
- package/dist/init/mapper-prompts.js.map +1 -0
- package/dist/init/mapper.d.ts +211 -0
- package/dist/init/mapper.js +151 -0
- package/dist/init/mapper.js.map +1 -0
- package/dist/init/module-slicer.d.ts +39 -0
- package/dist/init/module-slicer.js +809 -0
- package/dist/init/module-slicer.js.map +1 -0
- package/dist/init/multi-dev/index.d.ts +2 -0
- package/dist/init/multi-dev/index.js +2 -0
- package/dist/init/multi-dev/index.js.map +1 -0
- package/dist/init/multi-dev/install.d.ts +40 -0
- package/dist/init/multi-dev/install.js +139 -0
- package/dist/init/multi-dev/install.js.map +1 -0
- package/dist/init/preflight-guards.d.ts +42 -0
- package/dist/init/preflight-guards.js +108 -0
- package/dist/init/preflight-guards.js.map +1 -0
- package/dist/init/prompts.d.ts +61 -0
- package/dist/init/prompts.js +66 -0
- package/dist/init/prompts.js.map +1 -0
- package/dist/init/rules-merge/discover.d.ts +21 -0
- package/dist/init/rules-merge/discover.js +78 -0
- package/dist/init/rules-merge/discover.js.map +1 -0
- package/dist/init/rules-merge/index.d.ts +10 -0
- package/dist/init/rules-merge/index.js +6 -0
- package/dist/init/rules-merge/index.js.map +1 -0
- package/dist/init/rules-merge/ingest.d.ts +56 -0
- package/dist/init/rules-merge/ingest.js +336 -0
- package/dist/init/rules-merge/ingest.js.map +1 -0
- package/dist/init/rules-merge/keep-markers.d.ts +39 -0
- package/dist/init/rules-merge/keep-markers.js +97 -0
- package/dist/init/rules-merge/keep-markers.js.map +1 -0
- package/dist/init/rules-merge/parse-sections.d.ts +24 -0
- package/dist/init/rules-merge/parse-sections.js +71 -0
- package/dist/init/rules-merge/parse-sections.js.map +1 -0
- package/dist/init/rules-merge/regenerate.d.ts +33 -0
- package/dist/init/rules-merge/regenerate.js +163 -0
- package/dist/init/rules-merge/regenerate.js.map +1 -0
- package/dist/init/secrets.d.ts +18 -0
- package/dist/init/secrets.js +76 -0
- package/dist/init/secrets.js.map +1 -0
- package/dist/init/seed.d.ts +21 -0
- package/dist/init/seed.js +96 -0
- package/dist/init/seed.js.map +1 -0
- package/dist/init/setup-runners.d.ts +15 -0
- package/dist/init/setup-runners.js +143 -0
- package/dist/init/setup-runners.js.map +1 -0
- package/dist/init/source-comments/classify.d.ts +98 -0
- package/dist/init/source-comments/classify.js +244 -0
- package/dist/init/source-comments/classify.js.map +1 -0
- package/dist/init/source-comments/index.d.ts +8 -0
- package/dist/init/source-comments/index.js +5 -0
- package/dist/init/source-comments/index.js.map +1 -0
- package/dist/init/source-comments/ingest.d.ts +51 -0
- package/dist/init/source-comments/ingest.js +236 -0
- package/dist/init/source-comments/ingest.js.map +1 -0
- package/dist/init/source-comments/strip-replace.d.ts +106 -0
- package/dist/init/source-comments/strip-replace.js +284 -0
- package/dist/init/source-comments/strip-replace.js.map +1 -0
- package/dist/init/source-comments/walker.d.ts +65 -0
- package/dist/init/source-comments/walker.js +777 -0
- package/dist/init/source-comments/walker.js.map +1 -0
- package/dist/init/submodules.d.ts +48 -0
- package/dist/init/submodules.js +149 -0
- package/dist/init/submodules.js.map +1 -0
- package/dist/init/types.d.ts +55 -0
- package/dist/init/types.js +10 -0
- package/dist/init/types.js.map +1 -0
- package/dist/init/visual.d.ts +69 -0
- package/dist/init/visual.js +265 -0
- package/dist/init/visual.js.map +1 -0
- package/dist/init/walker.d.ts +82 -0
- package/dist/init/walker.js +585 -0
- package/dist/init/walker.js.map +1 -0
- package/dist/init/workflow-block.d.ts +34 -0
- package/dist/init/workflow-block.js +110 -0
- package/dist/init/workflow-block.js.map +1 -0
- package/dist/join/index.d.ts +67 -0
- package/dist/join/index.js +256 -0
- package/dist/join/index.js.map +1 -0
- package/dist/lock.d.ts +39 -0
- package/dist/lock.js +129 -0
- package/dist/lock.js.map +1 -0
- package/dist/logger.d.ts +13 -0
- package/dist/logger.js +78 -0
- package/dist/logger.js.map +1 -0
- package/dist/mcp/bootstrap-guard.d.ts +29 -0
- package/dist/mcp/bootstrap-guard.js +47 -0
- package/dist/mcp/bootstrap-guard.js.map +1 -0
- package/dist/mcp/context.d.ts +23 -0
- package/dist/mcp/context.js +9 -0
- package/dist/mcp/context.js.map +1 -0
- package/dist/mcp/errors.d.ts +17 -0
- package/dist/mcp/errors.js +23 -0
- package/dist/mcp/errors.js.map +1 -0
- package/dist/mcp/history/index.d.ts +6 -0
- package/dist/mcp/history/index.js +5 -0
- package/dist/mcp/history/index.js.map +1 -0
- package/dist/mcp/history/prompt.d.ts +32 -0
- package/dist/mcp/history/prompt.js +99 -0
- package/dist/mcp/history/prompt.js.map +1 -0
- package/dist/mcp/history/schema.d.ts +58 -0
- package/dist/mcp/history/schema.js +41 -0
- package/dist/mcp/history/schema.js.map +1 -0
- package/dist/mcp/history/summarizer.d.ts +81 -0
- package/dist/mcp/history/summarizer.js +196 -0
- package/dist/mcp/history/summarizer.js.map +1 -0
- package/dist/mcp/history/walker.d.ts +57 -0
- package/dist/mcp/history/walker.js +156 -0
- package/dist/mcp/history/walker.js.map +1 -0
- package/dist/mcp/index.d.ts +13 -0
- package/dist/mcp/index.js +9 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/path-allowlist.d.ts +29 -0
- package/dist/mcp/path-allowlist.js +71 -0
- package/dist/mcp/path-allowlist.js.map +1 -0
- package/dist/mcp/result.d.ts +8 -0
- package/dist/mcp/result.js +18 -0
- package/dist/mcp/result.js.map +1 -0
- package/dist/mcp/schemas.d.ts +192 -0
- package/dist/mcp/schemas.js +174 -0
- package/dist/mcp/schemas.js.map +1 -0
- package/dist/mcp/serve.d.ts +15 -0
- package/dist/mcp/serve.js +71 -0
- package/dist/mcp/serve.js.map +1 -0
- package/dist/mcp/server.d.ts +11 -0
- package/dist/mcp/server.js +58 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/telemetry.d.ts +15 -0
- package/dist/mcp/telemetry.js +13 -0
- package/dist/mcp/telemetry.js.map +1 -0
- package/dist/mcp/tools/append-run-note.d.ts +18 -0
- package/dist/mcp/tools/append-run-note.js +47 -0
- package/dist/mcp/tools/append-run-note.js.map +1 -0
- package/dist/mcp/tools/append.d.ts +8 -0
- package/dist/mcp/tools/append.js +37 -0
- package/dist/mcp/tools/append.js.map +1 -0
- package/dist/mcp/tools/archive.d.ts +8 -0
- package/dist/mcp/tools/archive.js +72 -0
- package/dist/mcp/tools/archive.js.map +1 -0
- package/dist/mcp/tools/ask-operator.d.ts +34 -0
- package/dist/mcp/tools/ask-operator.js +97 -0
- package/dist/mcp/tools/ask-operator.js.map +1 -0
- package/dist/mcp/tools/canonical-for-topic.d.ts +6 -0
- package/dist/mcp/tools/canonical-for-topic.js +40 -0
- package/dist/mcp/tools/canonical-for-topic.js.map +1 -0
- package/dist/mcp/tools/decision-get.d.ts +6 -0
- package/dist/mcp/tools/decision-get.js +49 -0
- package/dist/mcp/tools/decision-get.js.map +1 -0
- package/dist/mcp/tools/decisions-for-symbol.d.ts +7 -0
- package/dist/mcp/tools/decisions-for-symbol.js +42 -0
- package/dist/mcp/tools/decisions-for-symbol.js.map +1 -0
- package/dist/mcp/tools/decisions-in-scope.d.ts +7 -0
- package/dist/mcp/tools/decisions-in-scope.js +47 -0
- package/dist/mcp/tools/decisions-in-scope.js.map +1 -0
- package/dist/mcp/tools/drop-task.d.ts +12 -0
- package/dist/mcp/tools/drop-task.js +68 -0
- package/dist/mcp/tools/drop-task.js.map +1 -0
- package/dist/mcp/tools/get-full.d.ts +7 -0
- package/dist/mcp/tools/get-full.js +46 -0
- package/dist/mcp/tools/get-full.js.map +1 -0
- package/dist/mcp/tools/ground-get.d.ts +7 -0
- package/dist/mcp/tools/ground-get.js +77 -0
- package/dist/mcp/tools/ground-get.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +3 -0
- package/dist/mcp/tools/index.js +40 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/invariant-get.d.ts +6 -0
- package/dist/mcp/tools/invariant-get.js +49 -0
- package/dist/mcp/tools/invariant-get.js.map +1 -0
- package/dist/mcp/tools/invariants-in-scope.d.ts +7 -0
- package/dist/mcp/tools/invariants-in-scope.js +62 -0
- package/dist/mcp/tools/invariants-in-scope.js.map +1 -0
- package/dist/mcp/tools/query-history.d.ts +20 -0
- package/dist/mcp/tools/query-history.js +51 -0
- package/dist/mcp/tools/query-history.js.map +1 -0
- package/dist/mcp/tools/record-decision.d.ts +14 -0
- package/dist/mcp/tools/record-decision.js +98 -0
- package/dist/mcp/tools/record-decision.js.map +1 -0
- package/dist/mcp/tools/record-run-event.d.ts +10 -0
- package/dist/mcp/tools/record-run-event.js +32 -0
- package/dist/mcp/tools/record-run-event.js.map +1 -0
- package/dist/mcp/tools/resolve-attention.d.ts +31 -0
- package/dist/mcp/tools/resolve-attention.js +191 -0
- package/dist/mcp/tools/resolve-attention.js.map +1 -0
- package/dist/mcp/tools/search.d.ts +9 -0
- package/dist/mcp/tools/search.js +164 -0
- package/dist/mcp/tools/search.js.map +1 -0
- package/dist/mcp/tools/supersedes-chain.d.ts +6 -0
- package/dist/mcp/tools/supersedes-chain.js +66 -0
- package/dist/mcp/tools/supersedes-chain.js.map +1 -0
- package/dist/mcp/tools/timeline.d.ts +9 -0
- package/dist/mcp/tools/timeline.js +65 -0
- package/dist/mcp/tools/timeline.js.map +1 -0
- package/dist/mcp/tools/types.d.ts +9 -0
- package/dist/mcp/tools/types.js +2 -0
- package/dist/mcp/tools/types.js.map +1 -0
- package/dist/mirror/clone.d.ts +6 -0
- package/dist/mirror/clone.js +48 -0
- package/dist/mirror/clone.js.map +1 -0
- package/dist/mirror/dirty-overlap.d.ts +13 -0
- package/dist/mirror/dirty-overlap.js +42 -0
- package/dist/mirror/dirty-overlap.js.map +1 -0
- package/dist/mirror/index.d.ts +7 -0
- package/dist/mirror/index.js +7 -0
- package/dist/mirror/index.js.map +1 -0
- package/dist/mirror/paths.d.ts +18 -0
- package/dist/mirror/paths.js +45 -0
- package/dist/mirror/paths.js.map +1 -0
- package/dist/mirror/push.d.ts +9 -0
- package/dist/mirror/push.js +27 -0
- package/dist/mirror/push.js.map +1 -0
- package/dist/mirror/state.d.ts +4 -0
- package/dist/mirror/state.js +36 -0
- package/dist/mirror/state.js.map +1 -0
- package/dist/mirror/sync.d.ts +9 -0
- package/dist/mirror/sync.js +33 -0
- package/dist/mirror/sync.js.map +1 -0
- package/dist/mirror/types.d.ts +77 -0
- package/dist/mirror/types.js +2 -0
- package/dist/mirror/types.js.map +1 -0
- package/dist/paths/index.d.ts +23 -0
- package/dist/paths/index.js +50 -0
- package/dist/paths/index.js.map +1 -0
- package/dist/profiles/index.d.ts +3 -0
- package/dist/profiles/index.js +3 -0
- package/dist/profiles/index.js.map +1 -0
- package/dist/profiles/registry.d.ts +5 -0
- package/dist/profiles/registry.js +31 -0
- package/dist/profiles/registry.js.map +1 -0
- package/dist/profiles/types.d.ts +48 -0
- package/dist/profiles/types.js +11 -0
- package/dist/profiles/types.js.map +1 -0
- package/dist/profiles/unknown.d.ts +9 -0
- package/dist/profiles/unknown.js +17 -0
- package/dist/profiles/unknown.js.map +1 -0
- package/dist/prompt.d.ts +19 -0
- package/dist/prompt.js +50 -0
- package/dist/prompt.js.map +1 -0
- package/dist/sensors/attestation.d.ts +44 -0
- package/dist/sensors/attestation.js +262 -0
- package/dist/sensors/attestation.js.map +1 -0
- package/dist/sensors/catalog.d.ts +41 -0
- package/dist/sensors/catalog.js +123 -0
- package/dist/sensors/catalog.js.map +1 -0
- package/dist/sensors/decisions.d.ts +30 -0
- package/dist/sensors/decisions.js +393 -0
- package/dist/sensors/decisions.js.map +1 -0
- package/dist/sensors/diff.d.ts +27 -0
- package/dist/sensors/diff.js +148 -0
- package/dist/sensors/diff.js.map +1 -0
- package/dist/sensors/index.d.ts +13 -0
- package/dist/sensors/index.js +9 -0
- package/dist/sensors/index.js.map +1 -0
- package/dist/sensors/remediation.d.ts +20 -0
- package/dist/sensors/remediation.js +65 -0
- package/dist/sensors/remediation.js.map +1 -0
- package/dist/sensors/runner.d.ts +44 -0
- package/dist/sensors/runner.js +95 -0
- package/dist/sensors/runner.js.map +1 -0
- package/dist/sensors/structural.d.ts +30 -0
- package/dist/sensors/structural.js +204 -0
- package/dist/sensors/structural.js.map +1 -0
- package/dist/sensors/stub-catalog.d.ts +39 -0
- package/dist/sensors/stub-catalog.js +115 -0
- package/dist/sensors/stub-catalog.js.map +1 -0
- package/dist/sensors/types.d.ts +135 -0
- package/dist/sensors/types.js +14 -0
- package/dist/sensors/types.js.map +1 -0
- package/dist/session/events-marker.d.ts +39 -0
- package/dist/session/events-marker.js +74 -0
- package/dist/session/events-marker.js.map +1 -0
- package/dist/session/id.d.ts +83 -0
- package/dist/session/id.js +166 -0
- package/dist/session/id.js.map +1 -0
- package/dist/session/index.d.ts +14 -0
- package/dist/session/index.js +13 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session-start/build.d.ts +53 -0
- package/dist/session-start/build.js +645 -0
- package/dist/session-start/build.js.map +1 -0
- package/dist/session-start/index.d.ts +18 -0
- package/dist/session-start/index.js +18 -0
- package/dist/session-start/index.js.map +1 -0
- package/dist/session-start/templates.d.ts +6 -0
- package/dist/session-start/templates.js +38 -0
- package/dist/session-start/templates.js.map +1 -0
- package/dist/status-line/format.d.ts +14 -0
- package/dist/status-line/format.js +40 -0
- package/dist/status-line/format.js.map +1 -0
- package/dist/status-line/index.d.ts +29 -0
- package/dist/status-line/index.js +14 -0
- package/dist/status-line/index.js.map +1 -0
- package/dist/status-line/reader.d.ts +13 -0
- package/dist/status-line/reader.js +76 -0
- package/dist/status-line/reader.js.map +1 -0
- package/dist/status-line/writer.d.ts +33 -0
- package/dist/status-line/writer.js +72 -0
- package/dist/status-line/writer.js.map +1 -0
- package/dist/tier0/classify.d.ts +10 -0
- package/dist/tier0/classify.js +110 -0
- package/dist/tier0/classify.js.map +1 -0
- package/dist/tier0/index.d.ts +2 -0
- package/dist/tier0/index.js +2 -0
- package/dist/tier0/index.js.map +1 -0
- package/dist/tier0/ollama.d.ts +22 -0
- package/dist/tier0/ollama.js +63 -0
- package/dist/tier0/ollama.js.map +1 -0
- package/dist/tier0/types.d.ts +24 -0
- package/dist/tier0/types.js +9 -0
- package/dist/tier0/types.js.map +1 -0
- package/dist/tightener/index.d.ts +4 -0
- package/dist/tightener/index.js +4 -0
- package/dist/tightener/index.js.map +1 -0
- package/dist/tightener/prompt.d.ts +3 -0
- package/dist/tightener/prompt.js +67 -0
- package/dist/tightener/prompt.js.map +1 -0
- package/dist/tightener/schema.d.ts +68 -0
- package/dist/tightener/schema.js +44 -0
- package/dist/tightener/schema.js.map +1 -0
- package/dist/tightener/tighten.d.ts +2 -0
- package/dist/tightener/tighten.js +66 -0
- package/dist/tightener/tighten.js.map +1 -0
- package/dist/tightener/types.d.ts +74 -0
- package/dist/tightener/types.js +6 -0
- package/dist/tightener/types.js.map +1 -0
- package/dist/voice/index.d.ts +4 -0
- package/dist/voice/index.js +4 -0
- package/dist/voice/index.js.map +1 -0
- package/dist/voice/model.d.ts +23 -0
- package/dist/voice/model.js +46 -0
- package/dist/voice/model.js.map +1 -0
- package/dist/voice/pipe.d.ts +9 -0
- package/dist/voice/pipe.js +47 -0
- package/dist/voice/pipe.js.map +1 -0
- package/dist/voice/transcribe.d.ts +3 -0
- package/dist/voice/transcribe.js +43 -0
- package/dist/voice/transcribe.js.map +1 -0
- package/dist/voice/types.d.ts +26 -0
- package/dist/voice/types.js +9 -0
- package/dist/voice/types.js.map +1 -0
- package/package.json +54 -0
- package/templates/.archive/README.md +67 -0
- package/templates/.cairn/JOIN.md +87 -0
- package/templates/.cairn/config/sensors.yaml +185 -0
- package/templates/.cairn/config/stub-patterns.yaml +231 -0
- package/templates/.cairn/config/trust-policy.yaml +95 -0
- package/templates/.cairn/config/workflow.md +230 -0
- package/templates/.cairn/git-hooks/commit-msg +17 -0
- package/templates/.cairn/git-hooks/post-commit +28 -0
- package/templates/.cairn/git-hooks/pre-commit +24 -0
- package/templates/.cairn/ground/brand/overview.md +24 -0
- package/templates/.cairn/ground/brand/voice.md +20 -0
- package/templates/.cairn/ground/canonical-map/topics.yaml +54 -0
- package/templates/.cairn/ground/capabilities/mcp-tools.yaml +4 -0
- package/templates/.cairn/ground/capabilities/skills.yaml +3 -0
- package/templates/.cairn/ground/capabilities/snippets.yaml +3 -0
- package/templates/.cairn/ground/manifest.yaml +16 -0
- package/templates/.cairn/ground/product/personas.yaml +4 -0
- package/templates/.cairn/ground/product/positioning.md +21 -0
- package/templates/.claude/settings.json +57 -0
- package/templates/.github/workflows/cairn-check.yml +31 -0
- package/templates/.mcp.json +8 -0
- package/templates/README.md +24 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decision id allocator. DEC-NNNN, monotonic, never reused.
|
|
3
|
+
*
|
|
4
|
+
* Scans `.cairn/ground/decisions/` for accepted decisions AND
|
|
5
|
+
* `.cairn/ground/decisions/_inbox/` for outstanding drafts. Either counts
|
|
6
|
+
* toward the high-water mark — a draft that's pending operator confirmation
|
|
7
|
+
* still owns its id; rejecting a draft does NOT recycle the id.
|
|
8
|
+
*
|
|
9
|
+
* Single source of truth for DEC-id allocation. The MCP `record_decision`
|
|
10
|
+
* tool calls these helpers; do NOT re-implement the scan elsewhere.
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { decisionsDir } from "../ground/paths.js";
|
|
15
|
+
const FILENAME_RE = /^DEC-(\d{4,})(?:\.draft|\.rejected)?\.md$/;
|
|
16
|
+
/**
|
|
17
|
+
* Scan both the canonical decisions dir and the `_inbox/` for
|
|
18
|
+
* DEC-NNNN-prefixed files; return the set of ids found.
|
|
19
|
+
*/
|
|
20
|
+
export function scanExistingDecisionIds(repoRoot) {
|
|
21
|
+
const dir = decisionsDir(repoRoot);
|
|
22
|
+
const inboxDir = join(dir, "_inbox");
|
|
23
|
+
const ids = new Set();
|
|
24
|
+
for (const candidateDir of [dir, inboxDir]) {
|
|
25
|
+
if (!existsSync(candidateDir))
|
|
26
|
+
continue;
|
|
27
|
+
let entries;
|
|
28
|
+
try {
|
|
29
|
+
entries = readdirSync(candidateDir, { encoding: "utf8" });
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
for (const name of entries) {
|
|
35
|
+
const match = name.match(FILENAME_RE);
|
|
36
|
+
if (!match || !match[1])
|
|
37
|
+
continue;
|
|
38
|
+
ids.add(`DEC-${match[1].padStart(4, "0")}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return ids;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Return the next free `DEC-<NNNN>` id, optionally factoring in a
|
|
45
|
+
* caller-supplied set (e.g. ids the MCP tool just validated against).
|
|
46
|
+
*/
|
|
47
|
+
export function allocateDecisionId(repoRoot, existing) {
|
|
48
|
+
const ids = existing ?? scanExistingDecisionIds(repoRoot);
|
|
49
|
+
let max = 0;
|
|
50
|
+
for (const id of ids) {
|
|
51
|
+
const m = id.match(/^DEC-(\d+)$/);
|
|
52
|
+
if (!m?.[1])
|
|
53
|
+
continue;
|
|
54
|
+
const n = Number.parseInt(m[1], 10);
|
|
55
|
+
if (Number.isFinite(n) && n > max)
|
|
56
|
+
max = n;
|
|
57
|
+
}
|
|
58
|
+
return `DEC-${(max + 1).toString().padStart(4, "0")}`;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.js","sourceRoot":"","sources":["../../src/decision-capture/id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,WAAW,GAAG,2CAA2C,CAAC;AAEhE;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAgB;IACtD,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,YAAY,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC3C,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;YAAE,SAAS;QACxC,IAAI,OAAiB,CAAC;QACtB,IAAI,CAAC;YACH,OAAO,GAAG,WAAW,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QAC5D,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACtC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;gBAAE,SAAS;YAClC,GAAG,CAAC,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAgB,EAChB,QAAsB;IAEtB,MAAM,GAAG,GAAG,QAAQ,IAAI,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAC1D,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAClC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAAE,SAAS;QACtB,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACpC,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG;YAAE,GAAG,GAAG,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 14 — decision capture flow.
|
|
3
|
+
*
|
|
4
|
+
* Public surface:
|
|
5
|
+
* - runDecisionCapture(args) → end-to-end (extract → draft → confirm → ledger)
|
|
6
|
+
* - runDecisionExtractor(input) → standalone Tier-1 call
|
|
7
|
+
* - allocateDecisionId(repoRoot) → next monotonic DEC-id
|
|
8
|
+
* - writeDecisionDraft, acceptDraft, rejectDraft — mechanical persistence
|
|
9
|
+
* - DECISION_EXTRACTOR_OUTPUT_SCHEMA, DECISION_EXTRACTOR_SYSTEM_PROMPT — for
|
|
10
|
+
* consumers that want to call `runClaude` directly
|
|
11
|
+
*/
|
|
12
|
+
export type { CandidateAssertion, DecisionCaptureResult, DecisionDraft, DecisionExtractorInput, DecisionExtractorOutput, DraftConfirmDecision, ConfirmResult, RefinementProposal, RefinementResult, RefinerInput, RefinerOutput, } from "./types.js";
|
|
13
|
+
export { allocateDecisionId, scanExistingDecisionIds } from "./id.js";
|
|
14
|
+
export { DECISION_EXTRACTOR_SYSTEM_PROMPT, buildDecisionExtractorUserPrompt, } from "./prompt.js";
|
|
15
|
+
export { DECISION_EXTRACTOR_OUTPUT_SCHEMA } from "./schema.js";
|
|
16
|
+
export { runDecisionExtractor } from "./extractor.js";
|
|
17
|
+
export type { ExtractorResult } from "./extractor.js";
|
|
18
|
+
export { acceptDraft, liftCandidatesToAssertions, rejectDraft, writeDecisionDraft, } from "./writer.js";
|
|
19
|
+
export type { AcceptDraftResult, LiftResult, LiftVerdict, WriteDecisionDraftArgs, } from "./writer.js";
|
|
20
|
+
export { runDecisionCapture } from "./capture.js";
|
|
21
|
+
export type { RunDecisionCaptureArgs } from "./capture.js";
|
|
22
|
+
export { REFINEMENT_PROPOSER_SYSTEM_PROMPT, buildRefinementProposerUserPrompt, } from "./refinement-prompt.js";
|
|
23
|
+
export { REFINEMENT_PROPOSER_OUTPUT_SCHEMA } from "./refinement-schema.js";
|
|
24
|
+
export { proposeStrictAssertions, runDecisionRefinement, } from "./refinement.js";
|
|
25
|
+
export type { ProposerResult, RunDecisionRefinementArgs, } from "./refinement.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 14 — decision capture flow.
|
|
3
|
+
*
|
|
4
|
+
* Public surface:
|
|
5
|
+
* - runDecisionCapture(args) → end-to-end (extract → draft → confirm → ledger)
|
|
6
|
+
* - runDecisionExtractor(input) → standalone Tier-1 call
|
|
7
|
+
* - allocateDecisionId(repoRoot) → next monotonic DEC-id
|
|
8
|
+
* - writeDecisionDraft, acceptDraft, rejectDraft — mechanical persistence
|
|
9
|
+
* - DECISION_EXTRACTOR_OUTPUT_SCHEMA, DECISION_EXTRACTOR_SYSTEM_PROMPT — for
|
|
10
|
+
* consumers that want to call `runClaude` directly
|
|
11
|
+
*/
|
|
12
|
+
export { allocateDecisionId, scanExistingDecisionIds } from "./id.js";
|
|
13
|
+
export { DECISION_EXTRACTOR_SYSTEM_PROMPT, buildDecisionExtractorUserPrompt, } from "./prompt.js";
|
|
14
|
+
export { DECISION_EXTRACTOR_OUTPUT_SCHEMA } from "./schema.js";
|
|
15
|
+
export { runDecisionExtractor } from "./extractor.js";
|
|
16
|
+
export { acceptDraft, liftCandidatesToAssertions, rejectDraft, writeDecisionDraft, } from "./writer.js";
|
|
17
|
+
export { runDecisionCapture } from "./capture.js";
|
|
18
|
+
export { REFINEMENT_PROPOSER_SYSTEM_PROMPT, buildRefinementProposerUserPrompt, } from "./refinement-prompt.js";
|
|
19
|
+
export { REFINEMENT_PROPOSER_OUTPUT_SCHEMA } from "./refinement-schema.js";
|
|
20
|
+
export { proposeStrictAssertions, runDecisionRefinement, } from "./refinement.js";
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decision-capture/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAgBH,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EACL,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gCAAgC,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EACL,WAAW,EACX,0BAA0B,EAC1B,WAAW,EACX,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAOrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EACL,iCAAiC,EACjC,iCAAiC,GAClC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EACL,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decision-extractor prompts.
|
|
3
|
+
*
|
|
4
|
+
* Operator submits a direction (slash arg or free-text classified as
|
|
5
|
+
* `direction`). The extractor distills it into a typed candidate the
|
|
6
|
+
* cairn materializes into a draft decision.
|
|
7
|
+
*
|
|
8
|
+
* Anti-fabrication framing: when the input isn't actually a direction
|
|
9
|
+
* (rambling, off-topic, a question), the extractor sets
|
|
10
|
+
* `not_a_decision=true` and the cairn short-circuits without writing a
|
|
11
|
+
* draft. This keeps the decisions ledger free of noise.
|
|
12
|
+
*/
|
|
13
|
+
import type { DecisionExtractorInput } from "./types.js";
|
|
14
|
+
export declare const DECISION_EXTRACTOR_SYSTEM_PROMPT = "You are the **decision-extractor** for an agent cairn. The operator just spoke a direction \u2014 a binding course-change like \"from now on, X\" or \"scrap that, go with Y\" or \"user_id always required on integration tables\". Your job is to capture it as a typed candidate decision so the cairn can present it for confirmation.\n\nYou read three things:\n1. The raw direction text the operator submitted.\n2. Author / source / received-at metadata for the audit record.\n3. (Optional) A short list of currently-accepted decisions so you can spot supersedes relationships.\n\nYou emit a single JSON object matching the supplied schema. Required fields:\n\n- `subject`: imperative one-line title. Example: \"Filter integration_oauth_tokens queries by user_id\".\n- `summary`: 2-4 sentence paragraph expanding the subject. Capture the *what* and the *why* as the operator stated them \u2014 do NOT invent rationale they didn't give.\n- `scope_globs`: repo-relative globs the decision binds. Be specific. `[\"core/src/integrations/**/*.ts\"]` is good; `[\"**/*.ts\"]` is almost always wrong. When you genuinely can't tell, emit `[]` and let the operator narrow at confirm time.\n- `supersedes`: if the input EXPLICITLY revokes a previously-accepted decision (`scrap DEC-0042`, `undo the FK denorm rule`), set the DEC-id. Otherwise null/omit.\n- `candidate_assertions`: 0-3 mechanical-sensor checks that would enforce the decision going forward. Pick the kind from the schema enum that fits. ZERO is a valid answer when the rule is purely conceptual \u2014 better than fabricating an assertion that can't actually be verified.\n- `confidence_signal`: `high` when the direction is unambiguous + scope is obvious; `medium` when one of those is shaky; `low` when both are.\n- `not_a_decision`: set TRUE if the input is rambling, off-topic, a question rather than a directive, or otherwise lacks a binding rule. The cairn will short-circuit without writing a draft. When in doubt, set true \u2014 false-positive drafts pollute the ledger; false-negatives are recoverable via re-submission.\n\nExamples of inputs that should map to `not_a_decision: true`:\n- \"what's the status?\"\n- \"I'm thinking about switching to FK denorm but not sure\" \u2190 thinking-out-loud, not yet binding\n- \"lol\"\n- \"remind me about Phase 12\"\n\nExamples that should map to `not_a_decision: false`:\n- \"scrap that \u2014 going forward, FK denormalization only\" \u2190 supersedes implicit\n- \"all integration_oauth_tokens queries must filter by user_id\" \u2190 clear assertion candidate\n- \"from now on, no new code in core/src/legacy\" \u2190 scope_globs + file_must_not_be_modified\n\nYour candidate_assertions are *proposals* \u2014 the operator gets one more chance to edit them at the confirm dialog. Don't over-commit; aim for the smallest set of assertions that mechanically captures the binding behavior, not every implication.\n\nOutput ONLY the JSON object. No prose, no code fences, no other content.";
|
|
15
|
+
export declare function buildDecisionExtractorUserPrompt(input: DecisionExtractorInput): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decision-extractor prompts.
|
|
3
|
+
*
|
|
4
|
+
* Operator submits a direction (slash arg or free-text classified as
|
|
5
|
+
* `direction`). The extractor distills it into a typed candidate the
|
|
6
|
+
* cairn materializes into a draft decision.
|
|
7
|
+
*
|
|
8
|
+
* Anti-fabrication framing: when the input isn't actually a direction
|
|
9
|
+
* (rambling, off-topic, a question), the extractor sets
|
|
10
|
+
* `not_a_decision=true` and the cairn short-circuits without writing a
|
|
11
|
+
* draft. This keeps the decisions ledger free of noise.
|
|
12
|
+
*/
|
|
13
|
+
const PER_DIRECTION_CHAR_CAP = 6_000;
|
|
14
|
+
export const DECISION_EXTRACTOR_SYSTEM_PROMPT = `You are the **decision-extractor** for an agent cairn. The operator just spoke a direction — a binding course-change like "from now on, X" or "scrap that, go with Y" or "user_id always required on integration tables". Your job is to capture it as a typed candidate decision so the cairn can present it for confirmation.
|
|
15
|
+
|
|
16
|
+
You read three things:
|
|
17
|
+
1. The raw direction text the operator submitted.
|
|
18
|
+
2. Author / source / received-at metadata for the audit record.
|
|
19
|
+
3. (Optional) A short list of currently-accepted decisions so you can spot supersedes relationships.
|
|
20
|
+
|
|
21
|
+
You emit a single JSON object matching the supplied schema. Required fields:
|
|
22
|
+
|
|
23
|
+
- \`subject\`: imperative one-line title. Example: "Filter integration_oauth_tokens queries by user_id".
|
|
24
|
+
- \`summary\`: 2-4 sentence paragraph expanding the subject. Capture the *what* and the *why* as the operator stated them — do NOT invent rationale they didn't give.
|
|
25
|
+
- \`scope_globs\`: repo-relative globs the decision binds. Be specific. \`["core/src/integrations/**/*.ts"]\` is good; \`["**/*.ts"]\` is almost always wrong. When you genuinely can't tell, emit \`[]\` and let the operator narrow at confirm time.
|
|
26
|
+
- \`supersedes\`: if the input EXPLICITLY revokes a previously-accepted decision (\`scrap DEC-0042\`, \`undo the FK denorm rule\`), set the DEC-id. Otherwise null/omit.
|
|
27
|
+
- \`candidate_assertions\`: 0-3 mechanical-sensor checks that would enforce the decision going forward. Pick the kind from the schema enum that fits. ZERO is a valid answer when the rule is purely conceptual — better than fabricating an assertion that can't actually be verified.
|
|
28
|
+
- \`confidence_signal\`: \`high\` when the direction is unambiguous + scope is obvious; \`medium\` when one of those is shaky; \`low\` when both are.
|
|
29
|
+
- \`not_a_decision\`: set TRUE if the input is rambling, off-topic, a question rather than a directive, or otherwise lacks a binding rule. The cairn will short-circuit without writing a draft. When in doubt, set true — false-positive drafts pollute the ledger; false-negatives are recoverable via re-submission.
|
|
30
|
+
|
|
31
|
+
Examples of inputs that should map to \`not_a_decision: true\`:
|
|
32
|
+
- "what's the status?"
|
|
33
|
+
- "I'm thinking about switching to FK denorm but not sure" ← thinking-out-loud, not yet binding
|
|
34
|
+
- "lol"
|
|
35
|
+
- "remind me about Phase 12"
|
|
36
|
+
|
|
37
|
+
Examples that should map to \`not_a_decision: false\`:
|
|
38
|
+
- "scrap that — going forward, FK denormalization only" ← supersedes implicit
|
|
39
|
+
- "all integration_oauth_tokens queries must filter by user_id" ← clear assertion candidate
|
|
40
|
+
- "from now on, no new code in core/src/legacy" ← scope_globs + file_must_not_be_modified
|
|
41
|
+
|
|
42
|
+
Your candidate_assertions are *proposals* — the operator gets one more chance to edit them at the confirm dialog. Don't over-commit; aim for the smallest set of assertions that mechanically captures the binding behavior, not every implication.
|
|
43
|
+
|
|
44
|
+
Output ONLY the JSON object. No prose, no code fences, no other content.`;
|
|
45
|
+
export function buildDecisionExtractorUserPrompt(input) {
|
|
46
|
+
const sections = [];
|
|
47
|
+
sections.push("## Raw direction text");
|
|
48
|
+
const text = input.raw_text.trim();
|
|
49
|
+
sections.push(text.length > PER_DIRECTION_CHAR_CAP
|
|
50
|
+
? text.slice(0, PER_DIRECTION_CHAR_CAP) +
|
|
51
|
+
`\n…[truncated; ${text.length - PER_DIRECTION_CHAR_CAP} chars elided]`
|
|
52
|
+
: text);
|
|
53
|
+
sections.push("\n## Metadata");
|
|
54
|
+
sections.push(`author: ${input.author_id}`);
|
|
55
|
+
sections.push(`source: ${input.source}`);
|
|
56
|
+
sections.push(`received_at: ${input.received_at}`);
|
|
57
|
+
if (input.accepted_decisions && input.accepted_decisions.length > 0) {
|
|
58
|
+
sections.push("\n## Currently-accepted decisions (most recent first)");
|
|
59
|
+
for (const d of input.accepted_decisions.slice(0, 10)) {
|
|
60
|
+
sections.push(`- **${d.id}** — ${d.title} (${d.scope_summary})`);
|
|
61
|
+
}
|
|
62
|
+
sections.push("\nIf the new direction explicitly revokes one of these, set `supersedes` to its id.");
|
|
63
|
+
}
|
|
64
|
+
sections.push("\n## Your task");
|
|
65
|
+
sections.push("Extract the decision per the schema. Emit ONLY the JSON object.");
|
|
66
|
+
return sections.join("\n");
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/decision-capture/prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAErC,MAAM,CAAC,MAAM,gCAAgC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yEA8ByB,CAAC;AAE1E,MAAM,UAAU,gCAAgC,CAC9C,KAA6B;IAE7B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,QAAQ,CAAC,IAAI,CACX,IAAI,CAAC,MAAM,GAAG,sBAAsB;QAClC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,sBAAsB,CAAC;YACnC,kBAAkB,IAAI,CAAC,MAAM,GAAG,sBAAsB,gBAAgB;QAC1E,CAAC,CAAC,IAAI,CACT,CAAC;IAEF,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC/B,QAAQ,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;IAC5C,QAAQ,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;IAEnD,IAAI,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpE,QAAQ,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;QACvE,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;YACtD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC;QACpE,CAAC;QACD,QAAQ,CAAC,IAAI,CACX,qFAAqF,CACtF,CAAC;IACJ,CAAC;IAED,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAChC,QAAQ,CAAC,IAAI,CACX,iEAAiE,CAClE,CAAC;IAEF,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assertion-refiner prompts.
|
|
3
|
+
*
|
|
4
|
+
* The decision-extractor (Phase 14) emits LOOSE candidate assertions —
|
|
5
|
+
* `{kind, description, parameters?}` with `parameters` schema-loose. The
|
|
6
|
+
* decision file stores them under frontmatter `candidate_assertions:`,
|
|
7
|
+
* NOT under `assertions:` which Layer-D sensors enforce.
|
|
8
|
+
*
|
|
9
|
+
* The refiner's job is to lift each candidate into a STRICT shape that
|
|
10
|
+
* matches one of the eleven `DecisionAssertion` kinds (see
|
|
11
|
+
* `src/ground/schemas.ts`). When a candidate is too vague to form
|
|
12
|
+
* confident strict params, the refiner DEMOTES it to
|
|
13
|
+
* `human_review_hint` (always soft, always passes zod). When the
|
|
14
|
+
* candidate description is sound but the strict params would need
|
|
15
|
+
* operator input the refiner can't infer, it SKIPS — the candidate
|
|
16
|
+
* survives in `candidate_assertions:` for the next refine pass.
|
|
17
|
+
*
|
|
18
|
+
* Anti-fabrication framing: prefer demote / skip over inventing wrong
|
|
19
|
+
* regex / globs / table names. A wrong assertion is a sensor that fires
|
|
20
|
+
* on every PR forever; a `human_review_hint` is at worst noise in the
|
|
21
|
+
* reviewer's pre-amble.
|
|
22
|
+
*/
|
|
23
|
+
import type { RefinerInput } from "./types.js";
|
|
24
|
+
export declare const REFINEMENT_PROPOSER_SYSTEM_PROMPT = "You are the **assertion-refiner** for an agent cairn. The operator just confirmed a binding decision; the decision-extractor proposed N loose candidate assertions to enforce it. Your job is to lift each candidate into the STRICT shape used by the cairn's mechanical sensors, OR demote / skip it.\n\n## The eleven assertion kinds\n\nEach kind requires specific fields. The cairn's zod re-validates at apply time; a malformed `strict_assertion` is auto-demoted, so don't fudge \u2014 when you don't have a confident value for a required field, set status=\"demote\" or status=\"skip\" instead.\n\n- **schema_must_contain** \u2014 { table: string, column: string, column_type?: string, nullable?: boolean }\n Migration / schema rule. Example: \"tokens table must have user_id column NOT NULL\".\n\n- **text_must_match** \u2014 { pattern: string (JS regex source), in_globs: string[] }\n Some text must appear in matching files. Example: license header in src/**/*.ts.\n\n- **text_must_not_match** \u2014 { pattern: string, in_globs: string[] }\n Some text must NOT appear. Example: \"no `process.env.` access in src/**/*.ts\".\n\n- **index_must_exist** \u2014 { table: string, columns: string[], where?: string }\n Database index. Example: \"(provider, user_id) WHERE archived_at IS NULL on tokens\".\n\n- **ast_pattern** \u2014 { language: string (\"ts\"|\"py\"|\"go\"|...), pattern: string (regex fallback), in_globs: string[] }\n Structural pattern. Example: \"all controllers extend BaseController\".\n\n- **file_must_not_be_modified** \u2014 { path: string }\n Frozen file. Example: \"core/src/legacy/billing.ts\".\n\n- **query_must_filter_by** \u2014 { orm: string (\"drizzle\"|\"prisma\"|\"sqlalchemy\"|...), in_globs: string[], table: string, columns: string[], operator: \"eq\"|\"in\"|\"between\"|\"is_not_null\", require_combination: \"and\"|\"or\" }\n ORM-level scope. Example: \"all integration_oauth_tokens queries filter by user_id eq AND provider eq\".\n\n- **route_must_have_guard** \u2014 { in_globs: string[], guard: string, require_on: string[] }\n HTTP guard. Example: \"all routes in api/*/admin.ts have RequireRole guard, require_on: [GET, POST]\".\n\n- **event_must_emit** \u2014 { in_globs: string[], after_method: string, event_key: string, payload_must_include?: string[] }\n Event emission. Example: \"after createInvoice() emit invoice.created with [invoice_id, user_id]\".\n\n- **service_method_must_call** \u2014 { in_globs: string[], in_method: string, must_call: string, before_returning?: boolean }\n Required call inside method. Example: \"in TokenService.refresh(), must call audit.log() before returning\".\n\n- **human_review_hint** \u2014 { description: string }\n Always-soft fallback. Use this for purely conceptual rules (\"prefer simple solutions\", \"avoid magic numbers in pricing logic\").\n\n## Per-candidate verdict\n\nFor each candidate, emit one proposal:\n\n```\n{\n candidate_id: <as given>,\n candidate_kind: <as given>,\n status: \"lift\" | \"demote\" | \"skip\",\n confidence_signal: \"high\" | \"medium\" | \"low\",\n strict_assertion?: { ... } // present iff status=\"lift\"\n rationale: \"one sentence explaining the choice\"\n}\n```\n\n### When to LIFT\n\nYou are confident on every required field for the candidate's kind. The description gave you concrete table / file / regex / glob names, and the decision's scope_globs lets you narrow the in_globs reasonably.\n\nIf the candidate kind is **human_review_hint**, ALWAYS lift \u2014 the kind already has a single-field shape. `description` is the candidate's existing description.\n\n### When to DEMOTE\n\nThe candidate description is sound but the strict params would require input you don't have (e.g., \"no env vars\" \u2014 needs the actual regex pattern; \"must filter by user_id\" \u2014 needs the ORM name and table name and you don't know which).\n\nDemote means: rewrite as `human_review_hint` with a description that captures the rule's intent. The operator + reviewer + UAT still see it; sensors don't enforce it. Better than a hallucinated regex that fires on every PR.\n\n### When to SKIP\n\nThe candidate is weakly-specified to the point that even `human_review_hint` would be too vague to be useful (e.g., the operator's description was \"fix the thing\", the kind doesn't match the description, etc.). Skip leaves it under `candidate_assertions:` for a future refine pass.\n\n## Confidence\n\n- `high`: required fields are explicit in the candidate description. No guesses.\n- `medium`: most fields present, one or two reasonable inferences from scope_globs / decision summary.\n- `low`: status=\"lift\" with low confidence is a defect. Use status=\"demote\" or \"skip\" instead.\n\n## Output\n\nEmit ONLY the JSON object: `{ \"proposals\": [...] }`. One proposal per input candidate, in the order given. No prose, no code fences.";
|
|
25
|
+
export declare function buildRefinementProposerUserPrompt(input: RefinerInput): string;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assertion-refiner prompts.
|
|
3
|
+
*
|
|
4
|
+
* The decision-extractor (Phase 14) emits LOOSE candidate assertions —
|
|
5
|
+
* `{kind, description, parameters?}` with `parameters` schema-loose. The
|
|
6
|
+
* decision file stores them under frontmatter `candidate_assertions:`,
|
|
7
|
+
* NOT under `assertions:` which Layer-D sensors enforce.
|
|
8
|
+
*
|
|
9
|
+
* The refiner's job is to lift each candidate into a STRICT shape that
|
|
10
|
+
* matches one of the eleven `DecisionAssertion` kinds (see
|
|
11
|
+
* `src/ground/schemas.ts`). When a candidate is too vague to form
|
|
12
|
+
* confident strict params, the refiner DEMOTES it to
|
|
13
|
+
* `human_review_hint` (always soft, always passes zod). When the
|
|
14
|
+
* candidate description is sound but the strict params would need
|
|
15
|
+
* operator input the refiner can't infer, it SKIPS — the candidate
|
|
16
|
+
* survives in `candidate_assertions:` for the next refine pass.
|
|
17
|
+
*
|
|
18
|
+
* Anti-fabrication framing: prefer demote / skip over inventing wrong
|
|
19
|
+
* regex / globs / table names. A wrong assertion is a sensor that fires
|
|
20
|
+
* on every PR forever; a `human_review_hint` is at worst noise in the
|
|
21
|
+
* reviewer's pre-amble.
|
|
22
|
+
*/
|
|
23
|
+
const PER_DECISION_CHAR_CAP = 4_000;
|
|
24
|
+
export const REFINEMENT_PROPOSER_SYSTEM_PROMPT = `You are the **assertion-refiner** for an agent cairn. The operator just confirmed a binding decision; the decision-extractor proposed N loose candidate assertions to enforce it. Your job is to lift each candidate into the STRICT shape used by the cairn's mechanical sensors, OR demote / skip it.
|
|
25
|
+
|
|
26
|
+
## The eleven assertion kinds
|
|
27
|
+
|
|
28
|
+
Each kind requires specific fields. The cairn's zod re-validates at apply time; a malformed \`strict_assertion\` is auto-demoted, so don't fudge — when you don't have a confident value for a required field, set status="demote" or status="skip" instead.
|
|
29
|
+
|
|
30
|
+
- **schema_must_contain** — { table: string, column: string, column_type?: string, nullable?: boolean }
|
|
31
|
+
Migration / schema rule. Example: "tokens table must have user_id column NOT NULL".
|
|
32
|
+
|
|
33
|
+
- **text_must_match** — { pattern: string (JS regex source), in_globs: string[] }
|
|
34
|
+
Some text must appear in matching files. Example: license header in src/**/*.ts.
|
|
35
|
+
|
|
36
|
+
- **text_must_not_match** — { pattern: string, in_globs: string[] }
|
|
37
|
+
Some text must NOT appear. Example: "no \`process.env.\` access in src/**/*.ts".
|
|
38
|
+
|
|
39
|
+
- **index_must_exist** — { table: string, columns: string[], where?: string }
|
|
40
|
+
Database index. Example: "(provider, user_id) WHERE archived_at IS NULL on tokens".
|
|
41
|
+
|
|
42
|
+
- **ast_pattern** — { language: string ("ts"|"py"|"go"|...), pattern: string (regex fallback), in_globs: string[] }
|
|
43
|
+
Structural pattern. Example: "all controllers extend BaseController".
|
|
44
|
+
|
|
45
|
+
- **file_must_not_be_modified** — { path: string }
|
|
46
|
+
Frozen file. Example: "core/src/legacy/billing.ts".
|
|
47
|
+
|
|
48
|
+
- **query_must_filter_by** — { orm: string ("drizzle"|"prisma"|"sqlalchemy"|...), in_globs: string[], table: string, columns: string[], operator: "eq"|"in"|"between"|"is_not_null", require_combination: "and"|"or" }
|
|
49
|
+
ORM-level scope. Example: "all integration_oauth_tokens queries filter by user_id eq AND provider eq".
|
|
50
|
+
|
|
51
|
+
- **route_must_have_guard** — { in_globs: string[], guard: string, require_on: string[] }
|
|
52
|
+
HTTP guard. Example: "all routes in api/*/admin.ts have RequireRole guard, require_on: [GET, POST]".
|
|
53
|
+
|
|
54
|
+
- **event_must_emit** — { in_globs: string[], after_method: string, event_key: string, payload_must_include?: string[] }
|
|
55
|
+
Event emission. Example: "after createInvoice() emit invoice.created with [invoice_id, user_id]".
|
|
56
|
+
|
|
57
|
+
- **service_method_must_call** — { in_globs: string[], in_method: string, must_call: string, before_returning?: boolean }
|
|
58
|
+
Required call inside method. Example: "in TokenService.refresh(), must call audit.log() before returning".
|
|
59
|
+
|
|
60
|
+
- **human_review_hint** — { description: string }
|
|
61
|
+
Always-soft fallback. Use this for purely conceptual rules ("prefer simple solutions", "avoid magic numbers in pricing logic").
|
|
62
|
+
|
|
63
|
+
## Per-candidate verdict
|
|
64
|
+
|
|
65
|
+
For each candidate, emit one proposal:
|
|
66
|
+
|
|
67
|
+
\`\`\`
|
|
68
|
+
{
|
|
69
|
+
candidate_id: <as given>,
|
|
70
|
+
candidate_kind: <as given>,
|
|
71
|
+
status: "lift" | "demote" | "skip",
|
|
72
|
+
confidence_signal: "high" | "medium" | "low",
|
|
73
|
+
strict_assertion?: { ... } // present iff status="lift"
|
|
74
|
+
rationale: "one sentence explaining the choice"
|
|
75
|
+
}
|
|
76
|
+
\`\`\`
|
|
77
|
+
|
|
78
|
+
### When to LIFT
|
|
79
|
+
|
|
80
|
+
You are confident on every required field for the candidate's kind. The description gave you concrete table / file / regex / glob names, and the decision's scope_globs lets you narrow the in_globs reasonably.
|
|
81
|
+
|
|
82
|
+
If the candidate kind is **human_review_hint**, ALWAYS lift — the kind already has a single-field shape. \`description\` is the candidate's existing description.
|
|
83
|
+
|
|
84
|
+
### When to DEMOTE
|
|
85
|
+
|
|
86
|
+
The candidate description is sound but the strict params would require input you don't have (e.g., "no env vars" — needs the actual regex pattern; "must filter by user_id" — needs the ORM name and table name and you don't know which).
|
|
87
|
+
|
|
88
|
+
Demote means: rewrite as \`human_review_hint\` with a description that captures the rule's intent. The operator + reviewer + UAT still see it; sensors don't enforce it. Better than a hallucinated regex that fires on every PR.
|
|
89
|
+
|
|
90
|
+
### When to SKIP
|
|
91
|
+
|
|
92
|
+
The candidate is weakly-specified to the point that even \`human_review_hint\` would be too vague to be useful (e.g., the operator's description was "fix the thing", the kind doesn't match the description, etc.). Skip leaves it under \`candidate_assertions:\` for a future refine pass.
|
|
93
|
+
|
|
94
|
+
## Confidence
|
|
95
|
+
|
|
96
|
+
- \`high\`: required fields are explicit in the candidate description. No guesses.
|
|
97
|
+
- \`medium\`: most fields present, one or two reasonable inferences from scope_globs / decision summary.
|
|
98
|
+
- \`low\`: status="lift" with low confidence is a defect. Use status="demote" or "skip" instead.
|
|
99
|
+
|
|
100
|
+
## Output
|
|
101
|
+
|
|
102
|
+
Emit ONLY the JSON object: \`{ "proposals": [...] }\`. One proposal per input candidate, in the order given. No prose, no code fences.`;
|
|
103
|
+
export function buildRefinementProposerUserPrompt(input) {
|
|
104
|
+
const sections = [];
|
|
105
|
+
sections.push(`## Decision context — ${input.decision_id}`);
|
|
106
|
+
sections.push(`subject: ${input.subject}`);
|
|
107
|
+
const summary = input.summary.trim();
|
|
108
|
+
sections.push("");
|
|
109
|
+
sections.push("summary:");
|
|
110
|
+
sections.push(summary.length > PER_DECISION_CHAR_CAP
|
|
111
|
+
? summary.slice(0, PER_DECISION_CHAR_CAP) +
|
|
112
|
+
`\n…[truncated; ${summary.length - PER_DECISION_CHAR_CAP} chars elided]`
|
|
113
|
+
: summary);
|
|
114
|
+
if (input.scope_globs.length > 0) {
|
|
115
|
+
sections.push("");
|
|
116
|
+
sections.push("scope_globs:");
|
|
117
|
+
for (const g of input.scope_globs)
|
|
118
|
+
sections.push(` - ${g}`);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
sections.push("");
|
|
122
|
+
sections.push("scope_globs: (none — operator left it unspecified)");
|
|
123
|
+
}
|
|
124
|
+
sections.push("");
|
|
125
|
+
sections.push("## Candidates to refine");
|
|
126
|
+
for (let i = 0; i < input.candidates.length; i++) {
|
|
127
|
+
const c = input.candidates[i];
|
|
128
|
+
if (c === undefined)
|
|
129
|
+
continue;
|
|
130
|
+
const id = c.id ?? `${input.decision_id}-A${(i + 1).toString().padStart(2, "0")}`;
|
|
131
|
+
sections.push("");
|
|
132
|
+
sections.push(`### ${id} (kind: ${c.kind})`);
|
|
133
|
+
sections.push(`description: ${c.description}`);
|
|
134
|
+
if (c.parameters && Object.keys(c.parameters).length > 0) {
|
|
135
|
+
sections.push("parameters (loose, from extractor):");
|
|
136
|
+
sections.push("```json");
|
|
137
|
+
sections.push(JSON.stringify(c.parameters, null, 2));
|
|
138
|
+
sections.push("```");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
sections.push("");
|
|
142
|
+
sections.push("## Your task");
|
|
143
|
+
sections.push("Emit one proposal per candidate in the order given. Use the candidate_id values shown above. Output ONLY the JSON object.");
|
|
144
|
+
return sections.join("\n");
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=refinement-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refinement-prompt.js","sourceRoot":"","sources":["../../src/decision-capture/refinement-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAEpC,MAAM,CAAC,MAAM,iCAAiC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uIA8EsF,CAAC;AAExI,MAAM,UAAU,iCAAiC,CAAC,KAAmB;IACnE,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,yBAAyB,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5D,QAAQ,CAAC,IAAI,CAAC,YAAY,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAE3C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1B,QAAQ,CAAC,IAAI,CACX,OAAO,CAAC,MAAM,GAAG,qBAAqB;QACpC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,qBAAqB,CAAC;YACrC,kBAAkB,OAAO,CAAC,MAAM,GAAG,qBAAqB,gBAAgB;QAC5E,CAAC,CAAC,OAAO,CACZ,CAAC;IAEF,IAAI,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClB,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC9B,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,WAAW;YAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC/D,CAAC;SAAM,CAAC;QACN,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClB,QAAQ,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;IACtE,CAAC;IAED,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACjD,MAAM,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC,KAAK,SAAS;YAAE,SAAS;QAC9B,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC,WAAW,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;QAClF,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClB,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QAC9C,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzD,QAAQ,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;YACrD,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACrD,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC9B,QAAQ,CAAC,IAAI,CACX,2HAA2H,CAC5H,CAAC;IAEF,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema enforced by `claude --json-schema` for the assertion-refiner
|
|
3
|
+
* proposer output.
|
|
4
|
+
*
|
|
5
|
+
* For each input candidate the proposer returns one `RefinementProposal`.
|
|
6
|
+
* The shape here is intentionally loose on `strict_assertion` — the
|
|
7
|
+
* production `DecisionAssertion` zod (see `src/ground/schemas.ts`) is the
|
|
8
|
+
* source of truth and re-validates at apply time. Forcing the discriminated
|
|
9
|
+
* union into JSON Schema and the proposer's prompt would burn tokens
|
|
10
|
+
* without buying additional safety, since malformed shapes auto-demote.
|
|
11
|
+
*
|
|
12
|
+
* The proposer's per-kind contract is encoded in the system prompt
|
|
13
|
+
* (`refinement-prompt.ts`), not here.
|
|
14
|
+
*/
|
|
15
|
+
export declare const REFINEMENT_PROPOSER_OUTPUT_SCHEMA: {
|
|
16
|
+
readonly type: "object";
|
|
17
|
+
readonly additionalProperties: false;
|
|
18
|
+
readonly properties: {
|
|
19
|
+
readonly proposals: {
|
|
20
|
+
readonly type: "array";
|
|
21
|
+
readonly items: {
|
|
22
|
+
readonly type: "object";
|
|
23
|
+
readonly additionalProperties: false;
|
|
24
|
+
readonly properties: {
|
|
25
|
+
readonly candidate_id: {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly minLength: 1;
|
|
28
|
+
};
|
|
29
|
+
readonly candidate_kind: {
|
|
30
|
+
readonly enum: readonly ["schema_must_contain", "text_must_match", "text_must_not_match", "index_must_exist", "ast_pattern", "file_must_not_be_modified", "query_must_filter_by", "route_must_have_guard", "event_must_emit", "service_method_must_call", "human_review_hint"];
|
|
31
|
+
};
|
|
32
|
+
readonly status: {
|
|
33
|
+
readonly enum: readonly ["lift", "demote", "skip"];
|
|
34
|
+
};
|
|
35
|
+
readonly confidence_signal: {
|
|
36
|
+
readonly enum: readonly ["high", "medium", "low"];
|
|
37
|
+
};
|
|
38
|
+
readonly strict_assertion: {
|
|
39
|
+
readonly type: "object";
|
|
40
|
+
readonly additionalProperties: true;
|
|
41
|
+
};
|
|
42
|
+
readonly rationale: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
readonly minLength: 1;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
readonly required: readonly ["candidate_id", "candidate_kind", "status", "confidence_signal", "rationale"];
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
readonly required: readonly ["proposals"];
|
|
52
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema enforced by `claude --json-schema` for the assertion-refiner
|
|
3
|
+
* proposer output.
|
|
4
|
+
*
|
|
5
|
+
* For each input candidate the proposer returns one `RefinementProposal`.
|
|
6
|
+
* The shape here is intentionally loose on `strict_assertion` — the
|
|
7
|
+
* production `DecisionAssertion` zod (see `src/ground/schemas.ts`) is the
|
|
8
|
+
* source of truth and re-validates at apply time. Forcing the discriminated
|
|
9
|
+
* union into JSON Schema and the proposer's prompt would burn tokens
|
|
10
|
+
* without buying additional safety, since malformed shapes auto-demote.
|
|
11
|
+
*
|
|
12
|
+
* The proposer's per-kind contract is encoded in the system prompt
|
|
13
|
+
* (`refinement-prompt.ts`), not here.
|
|
14
|
+
*/
|
|
15
|
+
export const REFINEMENT_PROPOSER_OUTPUT_SCHEMA = {
|
|
16
|
+
type: "object",
|
|
17
|
+
additionalProperties: false,
|
|
18
|
+
properties: {
|
|
19
|
+
proposals: {
|
|
20
|
+
type: "array",
|
|
21
|
+
items: {
|
|
22
|
+
type: "object",
|
|
23
|
+
additionalProperties: false,
|
|
24
|
+
properties: {
|
|
25
|
+
candidate_id: { type: "string", minLength: 1 },
|
|
26
|
+
candidate_kind: {
|
|
27
|
+
enum: [
|
|
28
|
+
"schema_must_contain",
|
|
29
|
+
"text_must_match",
|
|
30
|
+
"text_must_not_match",
|
|
31
|
+
"index_must_exist",
|
|
32
|
+
"ast_pattern",
|
|
33
|
+
"file_must_not_be_modified",
|
|
34
|
+
"query_must_filter_by",
|
|
35
|
+
"route_must_have_guard",
|
|
36
|
+
"event_must_emit",
|
|
37
|
+
"service_method_must_call",
|
|
38
|
+
"human_review_hint",
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
status: { enum: ["lift", "demote", "skip"] },
|
|
42
|
+
confidence_signal: { enum: ["high", "medium", "low"] },
|
|
43
|
+
strict_assertion: {
|
|
44
|
+
type: "object",
|
|
45
|
+
additionalProperties: true,
|
|
46
|
+
},
|
|
47
|
+
rationale: { type: "string", minLength: 1 },
|
|
48
|
+
},
|
|
49
|
+
required: [
|
|
50
|
+
"candidate_id",
|
|
51
|
+
"candidate_kind",
|
|
52
|
+
"status",
|
|
53
|
+
"confidence_signal",
|
|
54
|
+
"rationale",
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
required: ["proposals"],
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=refinement-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refinement-schema.js","sourceRoot":"","sources":["../../src/decision-capture/refinement-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,SAAS,EAAE;YACT,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,KAAK;gBAC3B,UAAU,EAAE;oBACV,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE;oBAC9C,cAAc,EAAE;wBACd,IAAI,EAAE;4BACJ,qBAAqB;4BACrB,iBAAiB;4BACjB,qBAAqB;4BACrB,kBAAkB;4BAClB,aAAa;4BACb,2BAA2B;4BAC3B,sBAAsB;4BACtB,uBAAuB;4BACvB,iBAAiB;4BACjB,0BAA0B;4BAC1B,mBAAmB;yBACpB;qBACF;oBACD,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE;oBAC5C,iBAAiB,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE;oBACtD,gBAAgB,EAAE;wBAChB,IAAI,EAAE,QAAQ;wBACd,oBAAoB,EAAE,IAAI;qBAC3B;oBACD,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE;iBAC5C;gBACD,QAAQ,EAAE;oBACR,cAAc;oBACd,gBAAgB;oBAChB,QAAQ;oBACR,mBAAmB;oBACnB,WAAW;iBACZ;aACF;SACF;KACF;IACD,QAAQ,EAAE,CAAC,WAAW,CAAC;CACf,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 14.x — assertion refinement.
|
|
3
|
+
*
|
|
4
|
+
* Lifts the loose `candidate_assertions:` set on an accepted decision into
|
|
5
|
+
* the strict `assertions:` shape that Layer-D sensors enforce.
|
|
6
|
+
*
|
|
7
|
+
* Flow:
|
|
8
|
+
* read accepted decision file
|
|
9
|
+
* → proposeStrictAssertions (Tier-1 LLM)
|
|
10
|
+
* → re-validate each lift via DecisionAssertion zod (auto-demote on fail)
|
|
11
|
+
* → adapter.requestDialog: a) approve_all b) approve_high_only
|
|
12
|
+
* c) demote_all d) skip
|
|
13
|
+
* → liftCandidatesToAssertions writes the file
|
|
14
|
+
* → ledger regenerates so the new strict assertions become live
|
|
15
|
+
*
|
|
16
|
+
* The proposer runs READ-ONLY. The writer + dialog drive everything that
|
|
17
|
+
* touches the filesystem. A proposer failure (timeout, malformed JSON,
|
|
18
|
+
* subprocess crash) does NOT roll back the prior accept — it returns
|
|
19
|
+
* `proposer_failed: true` and leaves candidates under their loose
|
|
20
|
+
* `candidate_assertions:` field for the next refine pass.
|
|
21
|
+
*/
|
|
22
|
+
import type { FrontendAdapter } from "../frontend-types.js";
|
|
23
|
+
import type { ClaudeTier } from "../claude/index.js";
|
|
24
|
+
import type { RefinementResult, RefinerInput, RefinerOutput } from "./types.js";
|
|
25
|
+
export interface ProposerResult {
|
|
26
|
+
output: RefinerOutput;
|
|
27
|
+
duration_ms: number;
|
|
28
|
+
usage?: {
|
|
29
|
+
input_tokens?: number;
|
|
30
|
+
output_tokens?: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Single Tier-1 (Haiku default) LLM call producing one proposal per
|
|
35
|
+
* input candidate. The output is gated by the JSON Schema on the CLI
|
|
36
|
+
* side and re-validated structurally here.
|
|
37
|
+
*/
|
|
38
|
+
export declare function proposeStrictAssertions(input: RefinerInput): Promise<ProposerResult>;
|
|
39
|
+
export interface RunDecisionRefinementArgs {
|
|
40
|
+
/** Repo root for the mirror checkout. */
|
|
41
|
+
repoRoot: string;
|
|
42
|
+
/** DEC-id of the accepted decision whose candidates we're refining. */
|
|
43
|
+
decisionId: string;
|
|
44
|
+
/** Adapter that owns the confirm dialog. */
|
|
45
|
+
adapter: FrontendAdapter;
|
|
46
|
+
/** Channel for the dialog (Discord thread / DM). */
|
|
47
|
+
channelId?: string;
|
|
48
|
+
/** Tier for the proposer call. Default = haiku. */
|
|
49
|
+
tier?: ClaudeTier;
|
|
50
|
+
/** Per-call timeout for the proposer. */
|
|
51
|
+
proposerTimeoutMs?: number;
|
|
52
|
+
/** Dialog timeout. Default 60_000 ms. */
|
|
53
|
+
dialogTimeoutMs?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Smokes inject a stub here so they can verify dialog branching without
|
|
56
|
+
* burning claude quota. Defaults to `proposeStrictAssertions`.
|
|
57
|
+
*/
|
|
58
|
+
proposerOverride?: typeof proposeStrictAssertions;
|
|
59
|
+
}
|
|
60
|
+
export declare function runDecisionRefinement(args: RunDecisionRefinementArgs): Promise<RefinementResult>;
|