@isaacriehm/cairn-core 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/align-undo/undo.js +2 -2
- package/dist/align-undo/undo.js.map +1 -1
- package/dist/attention/bulk-accept.js +104 -55
- package/dist/attention/bulk-accept.js.map +1 -1
- package/dist/attention/dedup.js +23 -10
- package/dist/attention/dedup.js.map +1 -1
- package/dist/attention/restore.js +2 -2
- package/dist/attention/restore.js.map +1 -1
- package/dist/attention/scoring.js +1 -1
- package/dist/attention/scoring.js.map +1 -1
- package/dist/attention/serve/api.d.ts +1 -0
- package/dist/attention/serve/api.js +130 -77
- package/dist/attention/serve/api.js.map +1 -1
- package/dist/attention/serve/index.d.ts +1 -0
- package/dist/attention/serve/index.js +21 -7
- package/dist/attention/serve/index.js.map +1 -1
- package/dist/attention/source-strip.js +41 -46
- package/dist/attention/source-strip.js.map +1 -1
- package/dist/claude/cache.d.ts +10 -19
- package/dist/claude/cache.js +0 -0
- package/dist/claude/cache.js.map +1 -1
- package/dist/claude/runner.d.ts +4 -6
- package/dist/claude/runner.js +242 -203
- package/dist/claude/runner.js.map +1 -1
- package/dist/claude/types.d.ts +5 -5
- package/dist/context/handoff-builder.d.ts +28 -4
- package/dist/context/handoff-builder.js +75 -157
- package/dist/context/handoff-builder.js.map +1 -1
- package/dist/context/spec-delta.js +61 -9
- package/dist/context/spec-delta.js.map +1 -1
- package/dist/context/task-summary.js +5 -1
- package/dist/context/task-summary.js.map +1 -1
- package/dist/decision-capture/id.js +1 -1
- package/dist/decision-capture/id.js.map +1 -1
- package/dist/doctor/index.d.ts +9 -11
- package/dist/doctor/index.js +118 -175
- package/dist/doctor/index.js.map +1 -1
- package/dist/drain/drain.d.ts +1 -1
- package/dist/drain/drain.js +16 -16
- package/dist/drain/drain.js.map +1 -1
- package/dist/drain/index.d.ts +1 -1
- package/dist/drain/index.js +1 -1
- package/dist/events/reader.d.ts +9 -10
- package/dist/events/reader.js +46 -57
- package/dist/events/reader.js.map +1 -1
- package/dist/events/writer.js +1 -1
- package/dist/events/writer.js.map +1 -1
- package/dist/fix-align/index.d.ts +1 -1
- package/dist/fix-align/index.js +1 -1
- package/dist/fix-align/run.d.ts +1 -1
- package/dist/fix-align/run.js +4 -3
- package/dist/fix-align/run.js.map +1 -1
- package/dist/fix-align/sentinel.d.ts +1 -2
- package/dist/fix-align/sentinel.js +3 -4
- package/dist/fix-align/sentinel.js.map +1 -1
- package/dist/gc/apply.js +1 -1
- package/dist/gc/apply.js.map +1 -1
- package/dist/gc/attested-commits.d.ts +19 -0
- package/dist/gc/attested-commits.js +48 -0
- package/dist/gc/attested-commits.js.map +1 -0
- package/dist/gc/canary.d.ts +11 -21
- package/dist/gc/canary.js +18 -24
- package/dist/gc/canary.js.map +1 -1
- package/dist/gc/citation-integrity.d.ts +11 -14
- package/dist/gc/citation-integrity.js +124 -125
- package/dist/gc/citation-integrity.js.map +1 -1
- package/dist/gc/classify.d.ts +1 -1
- package/dist/gc/classify.js +2 -2
- package/dist/gc/classify.js.map +1 -1
- package/dist/gc/completion-integrity.d.ts +6 -7
- package/dist/gc/completion-integrity.js +45 -53
- package/dist/gc/completion-integrity.js.map +1 -1
- package/dist/gc/doc-gardening.js +1 -9
- package/dist/gc/doc-gardening.js.map +1 -1
- package/dist/gc/frontmatter.js +2 -2
- package/dist/gc/frontmatter.js.map +1 -1
- package/dist/gc/index.d.ts +7 -6
- package/dist/gc/index.js +3 -2
- package/dist/gc/index.js.map +1 -1
- package/dist/gc/quality-update.d.ts +6 -10
- package/dist/gc/quality-update.js +12 -15
- package/dist/gc/quality-update.js.map +1 -1
- package/dist/gc/scope-coverage.js +1 -1
- package/dist/gc/scope-coverage.js.map +1 -1
- package/dist/gc/stub-hits.d.ts +7 -25
- package/dist/gc/stub-hits.js +14 -40
- package/dist/gc/stub-hits.js.map +1 -1
- package/dist/gc/sweep.js +15 -6
- package/dist/gc/sweep.js.map +1 -1
- package/dist/gc/types.d.ts +5 -5
- package/dist/gc/types.js +2 -2
- package/dist/gc/walk-source.js +8 -28
- package/dist/gc/walk-source.js.map +1 -1
- package/dist/hooks/defer.d.ts +9 -20
- package/dist/hooks/defer.js +10 -27
- package/dist/hooks/defer.js.map +1 -1
- package/dist/hooks/post-tool-use/allowlist-reader.d.ts +2 -1
- package/dist/hooks/post-tool-use/allowlist-reader.js +49 -34
- package/dist/hooks/post-tool-use/allowlist-reader.js.map +1 -1
- package/dist/hooks/post-tool-use/index.d.ts +3 -4
- package/dist/hooks/post-tool-use/index.js +3 -3
- package/dist/hooks/post-tool-use/index.js.map +1 -1
- package/dist/hooks/post-tool-use/legend-builder.d.ts +11 -2
- package/dist/hooks/post-tool-use/legend-builder.js +27 -2
- package/dist/hooks/post-tool-use/legend-builder.js.map +1 -1
- package/dist/hooks/post-tool-use/post-write.d.ts +8 -0
- package/dist/hooks/post-tool-use/post-write.js +112 -0
- package/dist/hooks/post-tool-use/post-write.js.map +1 -0
- package/dist/hooks/post-tool-use/read-enricher.d.ts +10 -5
- package/dist/hooks/post-tool-use/read-enricher.js +114 -149
- package/dist/hooks/post-tool-use/read-enricher.js.map +1 -1
- package/dist/hooks/post-tool-use/sot-align.d.ts +12 -0
- package/dist/hooks/post-tool-use/sot-align.js +73 -49
- package/dist/hooks/post-tool-use/sot-align.js.map +1 -1
- package/dist/hooks/post-tool-use/write-guardian.d.ts +40 -8
- package/dist/hooks/post-tool-use/write-guardian.js +202 -254
- package/dist/hooks/post-tool-use/write-guardian.js.map +1 -1
- package/dist/hooks/pre-commit/sot-align-precommit.js +2 -2
- package/dist/hooks/pre-commit/sot-align-precommit.js.map +1 -1
- package/dist/hooks/runners/index.d.ts +2 -2
- package/dist/hooks/runners/index.js +1 -1
- package/dist/hooks/runners/index.js.map +1 -1
- package/dist/hooks/runners/payload.d.ts +34 -19
- package/dist/hooks/runners/payload.js +47 -44
- package/dist/hooks/runners/payload.js.map +1 -1
- package/dist/hooks/runners/session-end.js +12 -11
- package/dist/hooks/runners/session-end.js.map +1 -1
- package/dist/hooks/runners/session-start.d.ts +4 -2
- package/dist/hooks/runners/session-start.js +88 -261
- package/dist/hooks/runners/session-start.js.map +1 -1
- package/dist/hooks/runners/stop.js +27 -8
- package/dist/hooks/runners/stop.js.map +1 -1
- package/dist/hooks/runners/user-prompt-submit.js +7 -1
- package/dist/hooks/runners/user-prompt-submit.js.map +1 -1
- package/dist/hooks/sot-align-common.d.ts +1 -2
- package/dist/hooks/sot-align-common.js +2 -2
- package/dist/hooks/sot-align-common.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/init/baseline-audit.d.ts +14 -58
- package/dist/init/baseline-audit.js +92 -320
- package/dist/init/baseline-audit.js.map +1 -1
- package/dist/init/brand-derive.d.ts +11 -15
- package/dist/init/brand-derive.js +21 -46
- package/dist/init/brand-derive.js.map +1 -1
- package/dist/init/brand-setup.d.ts +1 -1
- package/dist/init/brand-setup.js +1 -1
- package/dist/init/detect.d.ts +25 -6
- package/dist/init/detect.js +107 -136
- package/dist/init/detect.js.map +1 -1
- package/dist/init/index.d.ts +4 -4
- package/dist/init/index.js +2 -2
- package/dist/init/index.js.map +1 -1
- package/dist/init/ingest-docs.d.ts +83 -23
- package/dist/init/ingest-docs.js +648 -136
- package/dist/init/ingest-docs.js.map +1 -1
- package/dist/init/init.d.ts +29 -20
- package/dist/init/init.js +132 -290
- package/dist/init/init.js.map +1 -1
- package/dist/init/mapper-merge.js +1 -1
- package/dist/init/mapper-merge.js.map +1 -1
- package/dist/init/mapper-parallel.d.ts +1 -1
- package/dist/init/mapper-parallel.js +10 -1
- package/dist/init/mapper-parallel.js.map +1 -1
- package/dist/init/mapper.js +1 -1
- package/dist/init/mapper.js.map +1 -1
- package/dist/init/multi-dev/install.d.ts +5 -5
- package/dist/init/multi-dev/install.js +4 -4
- package/dist/init/overlay.js +1 -0
- package/dist/init/overlay.js.map +1 -1
- package/dist/init/phases/1-detect.js +1 -1
- package/dist/init/phases/1-detect.js.map +1 -1
- package/dist/init/phases/{7c-rules-merge.d.ts → 10-rules-merge.d.ts} +2 -2
- package/dist/init/phases/{7c-rules-merge.js → 10-rules-merge.js} +6 -12
- package/dist/init/phases/10-rules-merge.js.map +1 -0
- package/dist/init/phases/11-baseline.d.ts +7 -0
- package/dist/init/phases/{8-baseline.js → 11-baseline.js} +5 -9
- package/dist/init/phases/11-baseline.js.map +1 -0
- package/dist/init/phases/12-strip.d.ts +10 -0
- package/dist/init/phases/{10-strip.js → 12-strip.js} +10 -14
- package/dist/init/phases/12-strip.js.map +1 -0
- package/dist/init/phases/{12-multidev.d.ts → 13-multidev.d.ts} +2 -2
- package/dist/init/phases/{12-multidev.js → 13-multidev.js} +4 -4
- package/dist/init/phases/{12-multidev.js.map → 13-multidev.js.map} +1 -1
- package/dist/init/phases/3-mapper.d.ts +1 -1
- package/dist/init/phases/3-mapper.js +2 -2
- package/dist/init/phases/3-mapper.js.map +1 -1
- package/dist/init/phases/{3b-seed.d.ts → 4-seed.d.ts} +2 -2
- package/dist/init/phases/{3b-seed.js → 4-seed.js} +7 -7
- package/dist/init/phases/4-seed.js.map +1 -0
- package/dist/init/phases/{4-pilot.d.ts → 5-pilot.d.ts} +2 -2
- package/dist/init/phases/{4-pilot.js → 5-pilot.js} +9 -9
- package/dist/init/phases/{4-pilot.js.map → 5-pilot.js.map} +1 -1
- package/dist/init/phases/{5-brand.d.ts → 6-brand.d.ts} +2 -7
- package/dist/init/phases/{5-brand.js → 6-brand.js} +6 -14
- package/dist/init/phases/6-brand.js.map +1 -0
- package/dist/init/phases/{5b-topic-index.d.ts → 7-topic-index.d.ts} +2 -11
- package/dist/init/phases/{5b-topic-index.js → 7-topic-index.js} +9 -18
- package/dist/init/phases/7-topic-index.js.map +1 -0
- package/dist/init/phases/8-docs-ingest.d.ts +10 -0
- package/dist/init/phases/{6-docs-ingest.js → 8-docs-ingest.js} +12 -14
- package/dist/init/phases/8-docs-ingest.js.map +1 -0
- package/dist/init/phases/9-source-comments.d.ts +6 -0
- package/dist/init/phases/{7b-source-comments.js → 9-source-comments.js} +7 -26
- package/dist/init/phases/9-source-comments.js.map +1 -0
- package/dist/init/phases/index.d.ts +12 -12
- package/dist/init/phases/index.js +11 -11
- package/dist/init/phases/index.js.map +1 -1
- package/dist/init/phases/{parallel-678.d.ts → parallel-8910.d.ts} +7 -8
- package/dist/init/phases/{parallel-678.js → parallel-8910.js} +34 -46
- package/dist/init/phases/parallel-8910.js.map +1 -0
- package/dist/init/phases/source-comments-output-io.d.ts +3 -3
- package/dist/init/phases/source-comments-output-io.js +3 -3
- package/dist/init/phases/types.d.ts +1 -1
- package/dist/init/phases/types.js +10 -10
- package/dist/init/phases/types.js.map +1 -1
- package/dist/init/rules-merge/discover.d.ts +2 -2
- package/dist/init/rules-merge/discover.js +28 -43
- package/dist/init/rules-merge/discover.js.map +1 -1
- package/dist/init/rules-merge/ingest.d.ts +6 -6
- package/dist/init/rules-merge/ingest.js +9 -10
- package/dist/init/rules-merge/ingest.js.map +1 -1
- package/dist/init/rules-merge/keep-markers.d.ts +1 -1
- package/dist/init/rules-merge/keep-markers.js +1 -1
- package/dist/init/rules-merge/regenerate.d.ts +3 -3
- package/dist/init/rules-merge/regenerate.js +3 -3
- package/dist/init/seed.js +17 -24
- package/dist/init/seed.js.map +1 -1
- package/dist/init/sot-emit.d.ts +48 -8
- package/dist/init/sot-emit.js +88 -10
- package/dist/init/sot-emit.js.map +1 -1
- package/dist/init/source-comments/classify.d.ts +2 -2
- package/dist/init/source-comments/classify.js +9 -1
- package/dist/init/source-comments/classify.js.map +1 -1
- package/dist/init/source-comments/index.d.ts +1 -1
- package/dist/init/source-comments/index.js.map +1 -1
- package/dist/init/source-comments/ingest.d.ts +2 -2
- package/dist/init/source-comments/ingest.js +110 -12
- package/dist/init/source-comments/ingest.js.map +1 -1
- package/dist/init/source-comments/strip-replace.js +3 -2
- package/dist/init/source-comments/strip-replace.js.map +1 -1
- package/dist/init/source-comments/walker.d.ts +3 -26
- package/dist/init/source-comments/walker.js +18 -30
- package/dist/init/source-comments/walker.js.map +1 -1
- package/dist/init/topic-index/index.d.ts +15 -1
- package/dist/init/topic-index/index.js +84 -5
- package/dist/init/topic-index/index.js.map +1 -1
- package/dist/init/topic-index/judge.d.ts +5 -9
- package/dist/init/topic-index/judge.js +25 -17
- package/dist/init/topic-index/judge.js.map +1 -1
- package/dist/init/topic-index/resolve.d.ts +23 -3
- package/dist/init/topic-index/resolve.js +102 -16
- package/dist/init/topic-index/resolve.js.map +1 -1
- package/dist/init/topic-index/walk.d.ts +36 -4
- package/dist/init/topic-index/walk.js +78 -12
- package/dist/init/topic-index/walk.js.map +1 -1
- package/dist/lock.js +4 -1
- package/dist/lock.js.map +1 -1
- package/dist/logger.js +3 -0
- package/dist/logger.js.map +1 -1
- package/dist/mcp/history/summarizer.js +6 -1
- package/dist/mcp/history/summarizer.js.map +1 -1
- package/dist/mcp/history/walker.js +1 -1
- package/dist/mcp/history/walker.js.map +1 -1
- package/dist/mcp/path-allowlist.js +1 -1
- package/dist/mcp/path-allowlist.js.map +1 -1
- package/dist/mcp/schemas.d.ts +47 -21
- package/dist/mcp/schemas.js +38 -9
- package/dist/mcp/schemas.js.map +1 -1
- package/dist/mcp/server.js +10 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/archive.js +1 -1
- package/dist/mcp/tools/archive.js.map +1 -1
- package/dist/mcp/tools/attention-wait.js +12 -2
- package/dist/mcp/tools/attention-wait.js.map +1 -1
- package/dist/mcp/tools/bulk-accept-attention.js +29 -30
- package/dist/mcp/tools/bulk-accept-attention.js.map +1 -1
- package/dist/mcp/tools/canonical-for-topic.js +37 -15
- package/dist/mcp/tools/canonical-for-topic.js.map +1 -1
- package/dist/mcp/tools/decision-get.js +2 -2
- package/dist/mcp/tools/decision-get.js.map +1 -1
- package/dist/mcp/tools/decisions-for-symbol.js +2 -2
- package/dist/mcp/tools/decisions-for-symbol.js.map +1 -1
- package/dist/mcp/tools/get-full.js +1 -1
- package/dist/mcp/tools/get-full.js.map +1 -1
- package/dist/mcp/tools/ground-get.js +1 -1
- package/dist/mcp/tools/ground-get.js.map +1 -1
- package/dist/mcp/tools/in-scope.d.ts +8 -0
- package/dist/mcp/tools/in-scope.js +125 -0
- package/dist/mcp/tools/in-scope.js.map +1 -0
- package/dist/mcp/tools/index.js +11 -6
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/init-phases.d.ts +3 -2
- package/dist/mcp/tools/init-phases.js +125 -124
- package/dist/mcp/tools/init-phases.js.map +1 -1
- package/dist/mcp/tools/invariant-get.js +2 -2
- package/dist/mcp/tools/invariant-get.js.map +1 -1
- package/dist/mcp/tools/record-decision.d.ts +4 -3
- package/dist/mcp/tools/record-decision.js +111 -36
- package/dist/mcp/tools/record-decision.js.map +1 -1
- package/dist/mcp/tools/reject-candidate.d.ts +24 -0
- package/dist/mcp/tools/reject-candidate.js +71 -0
- package/dist/mcp/tools/reject-candidate.js.map +1 -0
- package/dist/mcp/tools/resolve-attention.d.ts +5 -18
- package/dist/mcp/tools/resolve-attention.js +58 -158
- package/dist/mcp/tools/resolve-attention.js.map +1 -1
- package/dist/mcp/tools/search-candidates.d.ts +20 -0
- package/dist/mcp/tools/search-candidates.js +93 -0
- package/dist/mcp/tools/search-candidates.js.map +1 -0
- package/dist/mcp/tools/search.js +5 -4
- package/dist/mcp/tools/search.js.map +1 -1
- package/dist/mcp/tools/supersedes-chain.js +2 -2
- package/dist/mcp/tools/supersedes-chain.js.map +1 -1
- package/dist/mcp/tools/task-create.d.ts +1 -0
- package/dist/mcp/tools/task-create.js +2 -0
- package/dist/mcp/tools/task-create.js.map +1 -1
- package/dist/mcp/tools/timeline.js +1 -1
- package/dist/mcp/tools/timeline.js.map +1 -1
- package/dist/mcp/tools/types.d.ts +1 -0
- package/dist/mcp/tools/types.js +9 -1
- package/dist/mcp/tools/types.js.map +1 -1
- package/dist/sensors/attestation.d.ts +1 -1
- package/dist/sensors/attestation.js +2 -2
- package/dist/sensors/attestation.js.map +1 -1
- package/dist/sensors/catalog.d.ts +26 -28
- package/dist/sensors/catalog.js +79 -81
- package/dist/sensors/catalog.js.map +1 -1
- package/dist/sensors/decisions.d.ts +1 -1
- package/dist/sensors/decisions.js +15 -14
- package/dist/sensors/decisions.js.map +1 -1
- package/dist/sensors/diff.js +46 -22
- package/dist/sensors/diff.js.map +1 -1
- package/dist/sensors/runner.d.ts +2 -2
- package/dist/sensors/runner.js +3 -3
- package/dist/sensors/shell.d.ts +4 -0
- package/dist/sensors/shell.js +16 -0
- package/dist/sensors/shell.js.map +1 -0
- package/dist/sensors/structural.d.ts +3 -2
- package/dist/sensors/structural.js +3 -11
- package/dist/sensors/structural.js.map +1 -1
- package/dist/sensors/stub-catalog.d.ts +2 -1
- package/dist/sensors/stub-catalog.js +2 -9
- package/dist/sensors/stub-catalog.js.map +1 -1
- package/dist/sensors/types.d.ts +3 -4
- package/dist/sensors/types.js +1 -2
- package/dist/sensors/types.js.map +1 -1
- package/dist/session-start/build.js +1 -1
- package/dist/session-start/build.js.map +1 -1
- package/dist/status-line/event-queue.js +1 -1
- package/dist/status-line/index.d.ts +1 -1
- package/package.json +3 -2
- package/templates/.cairn/config/sensors.yaml +8 -8
- package/templates/attention-ui/app.js +101 -39
- package/dist/fs.d.ts +0 -5
- package/dist/fs.js +0 -11
- package/dist/fs.js.map +0 -1
- package/dist/ground/alignment-pending.d.ts +0 -28
- package/dist/ground/alignment-pending.js +0 -83
- package/dist/ground/alignment-pending.js.map +0 -1
- package/dist/ground/anchor-map.d.ts +0 -14
- package/dist/ground/anchor-map.js +0 -56
- package/dist/ground/anchor-map.js.map +0 -1
- package/dist/ground/drift.d.ts +0 -8
- package/dist/ground/drift.js +0 -23
- package/dist/ground/drift.js.map +0 -1
- package/dist/ground/frontmatter.d.ts +0 -32
- package/dist/ground/frontmatter.js +0 -77
- package/dist/ground/frontmatter.js.map +0 -1
- package/dist/ground/glob.d.ts +0 -10
- package/dist/ground/glob.js +0 -46
- package/dist/ground/glob.js.map +0 -1
- package/dist/ground/index.d.ts +0 -23
- package/dist/ground/index.js +0 -17
- package/dist/ground/index.js.map +0 -1
- package/dist/ground/ledgers.d.ts +0 -14
- package/dist/ground/ledgers.js +0 -105
- package/dist/ground/ledgers.js.map +0 -1
- package/dist/ground/manifest.d.ts +0 -10
- package/dist/ground/manifest.js +0 -84
- package/dist/ground/manifest.js.map +0 -1
- package/dist/ground/paths.d.ts +0 -41
- package/dist/ground/paths.js +0 -103
- package/dist/ground/paths.js.map +0 -1
- package/dist/ground/quality-grades.d.ts +0 -11
- package/dist/ground/quality-grades.js +0 -100
- package/dist/ground/quality-grades.js.map +0 -1
- package/dist/ground/schemas.d.ts +0 -502
- package/dist/ground/schemas.js +0 -318
- package/dist/ground/schemas.js.map +0 -1
- package/dist/ground/scope-index.d.ts +0 -96
- package/dist/ground/scope-index.js +0 -290
- package/dist/ground/scope-index.js.map +0 -1
- package/dist/ground/slug.d.ts +0 -60
- package/dist/ground/slug.js +0 -103
- package/dist/ground/slug.js.map +0 -1
- package/dist/ground/sot-bindings.d.ts +0 -14
- package/dist/ground/sot-bindings.js +0 -79
- package/dist/ground/sot-bindings.js.map +0 -1
- package/dist/ground/sot-cache.d.ts +0 -18
- package/dist/ground/sot-cache.js +0 -62
- package/dist/ground/sot-cache.js.map +0 -1
- package/dist/ground/topic-index.d.ts +0 -27
- package/dist/ground/topic-index.js +0 -82
- package/dist/ground/topic-index.js.map +0 -1
- package/dist/ground/walk.d.ts +0 -7
- package/dist/ground/walk.js +0 -53
- package/dist/ground/walk.js.map +0 -1
- package/dist/hooks/post-tool-use/ledger-cache.d.ts +0 -40
- package/dist/hooks/post-tool-use/ledger-cache.js +0 -290
- package/dist/hooks/post-tool-use/ledger-cache.js.map +0 -1
- package/dist/init/phases/10-strip.d.ts +0 -11
- package/dist/init/phases/10-strip.js.map +0 -1
- package/dist/init/phases/3b-seed.js.map +0 -1
- package/dist/init/phases/5-brand.js.map +0 -1
- package/dist/init/phases/5b-topic-index.js.map +0 -1
- package/dist/init/phases/6-docs-ingest.d.ts +0 -10
- package/dist/init/phases/6-docs-ingest.js.map +0 -1
- package/dist/init/phases/7b-source-comments.d.ts +0 -15
- package/dist/init/phases/7b-source-comments.js.map +0 -1
- package/dist/init/phases/7c-rules-merge.js.map +0 -1
- package/dist/init/phases/8-baseline.d.ts +0 -10
- package/dist/init/phases/8-baseline.js.map +0 -1
- package/dist/init/phases/parallel-678.js.map +0 -1
- package/dist/mcp/tools/decisions-in-scope.d.ts +0 -7
- package/dist/mcp/tools/decisions-in-scope.js +0 -66
- package/dist/mcp/tools/decisions-in-scope.js.map +0 -1
- package/dist/mcp/tools/invariants-in-scope.d.ts +0 -7
- package/dist/mcp/tools/invariants-in-scope.js +0 -81
- package/dist/mcp/tools/invariants-in-scope.js.map +0 -1
|
@@ -3,150 +3,214 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Scans the just-written content for internal-only copy patterns
|
|
5
5
|
* leaking into a user-facing surface (TODO/FIXME comments, cairn
|
|
6
|
-
* citations, snake_case
|
|
7
|
-
*
|
|
8
|
-
* file's scope-index entry and renders a "decisions/invariants in
|
|
9
|
-
* scope" reminder.
|
|
6
|
+
* citations, snake_case keys in CamelCase schemas). Blocks with a
|
|
7
|
+
* warning/hint in Shape-B `additionalContext`.
|
|
10
8
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* This hook is critical for maintaining "ground state" integrity:
|
|
10
|
+
* 1. Safety — prevent internal technical debt leaking to users.
|
|
11
|
+
* 2. Context — remind the agent about in-scope decisions for the file.
|
|
12
|
+
* 3. Bootstrap — suggest `cairn init` if a write lands in a project
|
|
13
|
+
* the agent should adopt but hasn't yet.
|
|
14
14
|
*
|
|
15
|
-
* Spec: docs/
|
|
15
|
+
* Spec: docs/WRITE_GUARDIAN_SPEC.md.
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { syncFileScopeFromContent } from "../../ground/scope-index.js";
|
|
17
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
18
|
+
import { basename, relative, resolve, dirname, join } from "node:path";
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
import { getScopeIndexEntry, matchAnyGlob, } from "@isaacriehm/cairn-state";
|
|
21
|
+
import { readHookStdin, emitShapeB, appendTelemetry, } from "../runners/payload.js";
|
|
23
22
|
import { resolveRepoRoot } from "../../session-start/index.js";
|
|
24
|
-
import { readCopySafetyConfig
|
|
23
|
+
import { readCopySafetyConfig } from "./allowlist-reader.js";
|
|
25
24
|
import { scanForCopyLeakage } from "./copy-scanner.js";
|
|
26
|
-
import {
|
|
25
|
+
import { logger } from "../../logger.js";
|
|
26
|
+
const ClaudePostToolUsePayloadSchema = z.object({
|
|
27
|
+
session_id: z.string().optional(),
|
|
28
|
+
transcript_path: z.string().optional(),
|
|
29
|
+
cwd: z.string().optional(),
|
|
30
|
+
hook_event_name: z.string().optional(),
|
|
31
|
+
tool_name: z.string().optional(),
|
|
32
|
+
tool_input: z.object({
|
|
33
|
+
file_path: z.string().optional(),
|
|
34
|
+
new_string: z.string().optional(),
|
|
35
|
+
}).passthrough().optional(),
|
|
36
|
+
tool_response: z.object({
|
|
37
|
+
content: z.string().optional(),
|
|
38
|
+
text: z.string().optional(),
|
|
39
|
+
output: z.string().optional(),
|
|
40
|
+
}).passthrough().optional(),
|
|
41
|
+
}).passthrough();
|
|
42
|
+
const log = logger("hooks.post-tool-use.write-guardian");
|
|
43
|
+
/**
|
|
44
|
+
* Hook entry point.
|
|
45
|
+
*/
|
|
46
|
+
export async function runWriteGuardian() {
|
|
47
|
+
const ts = new Date().toISOString();
|
|
48
|
+
let outcome = { skip: "unknown" };
|
|
49
|
+
let repoRootForTrace = null;
|
|
50
|
+
let sessionForTrace = null;
|
|
51
|
+
try {
|
|
52
|
+
const raw = await readHookStdin();
|
|
53
|
+
const payload = parsePayload(raw);
|
|
54
|
+
sessionForTrace = payload.session_id ?? null;
|
|
55
|
+
if (payload.tool_name !== "Write" && payload.tool_name !== "Edit") {
|
|
56
|
+
outcome = { skip: "non-write-tool", tool_name: payload.tool_name };
|
|
57
|
+
emitShapeB("", "PostToolUse");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const filePath = payload.tool_input?.file_path;
|
|
61
|
+
const content = pickContent(payload.tool_response);
|
|
62
|
+
if (filePath === undefined || content === undefined || content.length === 0) {
|
|
63
|
+
outcome = {
|
|
64
|
+
skip: "no-content",
|
|
65
|
+
file_path: filePath ?? null,
|
|
66
|
+
content_present: content !== undefined,
|
|
67
|
+
};
|
|
68
|
+
emitShapeB("", "PostToolUse");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const cwd = payload.cwd ?? process.cwd();
|
|
72
|
+
const repoRoot = resolveRepoRoot(cwd);
|
|
73
|
+
repoRootForTrace = repoRoot;
|
|
74
|
+
if (repoRoot === null) {
|
|
75
|
+
outcome = { skip: "not-adopted", cwd };
|
|
76
|
+
emitShapeB("", "PostToolUse");
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const relPath = relative(repoRoot, resolve(cwd, filePath));
|
|
80
|
+
const result = executeWriteGuardian({
|
|
81
|
+
repoRoot,
|
|
82
|
+
relPath,
|
|
83
|
+
content,
|
|
84
|
+
payload,
|
|
85
|
+
});
|
|
86
|
+
outcome = {
|
|
87
|
+
ok: true,
|
|
88
|
+
path: relPath,
|
|
89
|
+
guardian_kind: result.kind,
|
|
90
|
+
message_chars: result.message?.length ?? 0,
|
|
91
|
+
};
|
|
92
|
+
if (result.kind === "none") {
|
|
93
|
+
emitShapeB("", "PostToolUse");
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
emitShapeB(result.message ?? "", "PostToolUse");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
101
|
+
outcome = { error: message };
|
|
102
|
+
log.error({ err: message }, "write-guardian hook failed");
|
|
103
|
+
emitShapeB("", "PostToolUse");
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
if (repoRootForTrace !== null) {
|
|
107
|
+
appendTelemetry({
|
|
108
|
+
repoRoot: repoRootForTrace,
|
|
109
|
+
sessionId: sessionForTrace,
|
|
110
|
+
kind: "write-guardian",
|
|
111
|
+
durationMs: Date.now() - Date.parse(ts),
|
|
112
|
+
source: "hook",
|
|
113
|
+
warnings: [],
|
|
114
|
+
extra: outcome,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export function executeWriteGuardian(args) {
|
|
120
|
+
const { repoRoot, relPath, content, payload } = args;
|
|
121
|
+
const filePath = relPath;
|
|
122
|
+
const copyConfig = readCopySafetyConfig(repoRoot);
|
|
123
|
+
const shouldScanCopy = copyConfig.enabled && matchAnyGlob(relPath, copyConfig.globs);
|
|
124
|
+
let issues = [];
|
|
125
|
+
if (shouldScanCopy) {
|
|
126
|
+
const raw = scanForCopyLeakage(content, filePath);
|
|
127
|
+
const allowlist = new Set(copyConfig.allowlist);
|
|
128
|
+
issues = raw.filter((i) => !allowlist.has(i.match));
|
|
129
|
+
}
|
|
130
|
+
const cachedEntry = getScopeIndexEntry(repoRoot, relPath);
|
|
131
|
+
const scopeHint = cachedEntry !== null &&
|
|
132
|
+
(cachedEntry.decisions.length > 0 || cachedEntry.invariants.length > 0)
|
|
133
|
+
? {
|
|
134
|
+
decisions: cachedEntry.decisions,
|
|
135
|
+
invariants: cachedEntry.invariants,
|
|
136
|
+
}
|
|
137
|
+
: null;
|
|
138
|
+
const sessionId = payload.session_id ?? null;
|
|
139
|
+
// Bypass detection
|
|
140
|
+
if (isProjectTrackedFile(repoRoot, relPath) &&
|
|
141
|
+
!hasTightenedActiveTask(repoRoot) &&
|
|
142
|
+
!bypassAlreadyWarned(repoRoot, sessionId)) {
|
|
143
|
+
markBypassWarned(repoRoot, sessionId);
|
|
144
|
+
return { kind: "block", message: renderBypassBlockReason(relPath) };
|
|
145
|
+
}
|
|
146
|
+
const sections = [];
|
|
147
|
+
if (issues.length > 0) {
|
|
148
|
+
sections.push(renderCopySafetySection(basename(filePath), issues));
|
|
149
|
+
}
|
|
150
|
+
if (scopeHint !== null) {
|
|
151
|
+
sections.push(renderScopeSection(scopeHint));
|
|
152
|
+
}
|
|
153
|
+
if (sections.length === 0)
|
|
154
|
+
return { kind: "none" };
|
|
155
|
+
const block = sections.join("\n\n") + "\n\nWrite succeeded. Review before committing.";
|
|
156
|
+
return { kind: "hint", message: block };
|
|
157
|
+
}
|
|
27
158
|
function parsePayload(text) {
|
|
28
159
|
if (text.trim().length === 0)
|
|
29
160
|
return {};
|
|
30
161
|
try {
|
|
31
|
-
const
|
|
32
|
-
|
|
162
|
+
const raw = JSON.parse(text);
|
|
163
|
+
const result = ClaudePostToolUsePayloadSchema.safeParse(raw);
|
|
164
|
+
return result.success ? result.data : {};
|
|
33
165
|
}
|
|
34
166
|
catch {
|
|
35
167
|
return {};
|
|
36
168
|
}
|
|
37
169
|
}
|
|
38
170
|
function pickContent(resp) {
|
|
39
|
-
if (
|
|
171
|
+
if (resp === undefined)
|
|
40
172
|
return undefined;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
173
|
+
if (typeof resp.content === "string" && resp.content.length > 0)
|
|
174
|
+
return resp.content;
|
|
175
|
+
if (typeof resp.text === "string" && resp.text.length > 0)
|
|
176
|
+
return resp.text;
|
|
177
|
+
if (typeof resp.output === "string" && resp.output.length > 0)
|
|
178
|
+
return resp.output;
|
|
47
179
|
return undefined;
|
|
48
180
|
}
|
|
49
|
-
function
|
|
50
|
-
const rel = relative(repoRoot, filePath);
|
|
51
|
-
if (rel.startsWith("..") || rel.length === 0)
|
|
52
|
-
return filePath;
|
|
53
|
-
return rel.replace(/\\/g, "/");
|
|
54
|
-
}
|
|
55
|
-
function emitShapeB(additionalContext) {
|
|
56
|
-
const out = {
|
|
57
|
-
continue: true,
|
|
58
|
-
hookSpecificOutput: {
|
|
59
|
-
hookEventName: "PostToolUse",
|
|
60
|
-
additionalContext,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
process.stdout.write(JSON.stringify(out));
|
|
64
|
-
process.stdout.write("\n");
|
|
65
|
-
}
|
|
66
|
-
function emitBlock(reason) {
|
|
67
|
-
const out = {
|
|
68
|
-
continue: false,
|
|
69
|
-
decision: "block",
|
|
70
|
-
reason,
|
|
71
|
-
};
|
|
72
|
-
process.stdout.write(JSON.stringify(out));
|
|
73
|
-
process.stdout.write("\n");
|
|
74
|
-
}
|
|
75
|
-
function filterAllowed(issues, config) {
|
|
76
|
-
if (config.allowlist.length === 0)
|
|
77
|
-
return issues;
|
|
78
|
-
const allowed = new Set(config.allowlist);
|
|
79
|
-
return issues.filter((i) => !allowed.has(i.match));
|
|
80
|
-
}
|
|
81
|
-
function renderCopySafetySection(fileName, issues) {
|
|
181
|
+
function renderCopySafetySection(filename, issues) {
|
|
82
182
|
const lines = [];
|
|
83
|
-
lines.push(
|
|
84
|
-
|
|
85
|
-
|
|
183
|
+
lines.push(`## Copy safety — ${filename}`);
|
|
184
|
+
lines.push("");
|
|
185
|
+
for (const i of issues) {
|
|
186
|
+
lines.push(`- ${i.pattern}: ${i.match} (line ${i.line})`);
|
|
86
187
|
}
|
|
87
188
|
return lines.join("\n");
|
|
88
189
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
* authority. The only universal exclusion is `.cairn/` itself
|
|
96
|
-
* (cairn's state dir, which the agent legitimately writes during
|
|
97
|
-
* adoption + attention flows without going through cairn-direction).
|
|
98
|
-
*
|
|
99
|
-
* `git check-ignore` exit codes:
|
|
100
|
-
* 0 = path IS ignored (skip)
|
|
101
|
-
* 1 = path NOT ignored (project content → bypass-eligible)
|
|
102
|
-
* 128 = error / not in git repo (fail-safe to skip)
|
|
103
|
-
*/
|
|
104
|
-
function isProjectTrackedFile(repoRoot, relPath) {
|
|
105
|
-
if (relPath === ".cairn" || relPath.startsWith(".cairn/"))
|
|
106
|
-
return false;
|
|
107
|
-
const r = spawnSync("git", ["check-ignore", "-q", "--", relPath], {
|
|
108
|
-
cwd: repoRoot,
|
|
109
|
-
});
|
|
110
|
-
return r.status === 1;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Per-session sentinel that dedupes the bypass warning: first
|
|
114
|
-
* untightened-edit fires + creates the file; subsequent edits in the
|
|
115
|
-
* same session see the file and skip the warning section. Stop hook
|
|
116
|
-
* scope reminder + copy-safety still emit normally.
|
|
117
|
-
*
|
|
118
|
-
* Cleared naturally when the session ends (`.cairn/sessions/<sid>/`
|
|
119
|
-
* is removed by the SessionEnd hook). When `cairn-direction` later
|
|
120
|
-
* writes `spec.tightened.md`, `hasTightenedActiveTask` returns true
|
|
121
|
-
* and the bypass branch is skipped regardless of the sentinel.
|
|
122
|
-
*/
|
|
123
|
-
function bypassSentinelPath(repoRoot, sessionId) {
|
|
124
|
-
if (sessionId === null || sessionId.length === 0)
|
|
125
|
-
return null;
|
|
126
|
-
return join(repoRoot, ".cairn", "sessions", sessionId, "bypass-warned");
|
|
127
|
-
}
|
|
128
|
-
function bypassAlreadyWarned(repoRoot, sessionId) {
|
|
129
|
-
const p = bypassSentinelPath(repoRoot, sessionId);
|
|
130
|
-
return p !== null && existsSync(p);
|
|
131
|
-
}
|
|
132
|
-
function markBypassWarned(repoRoot, sessionId) {
|
|
133
|
-
const p = bypassSentinelPath(repoRoot, sessionId);
|
|
134
|
-
if (p === null)
|
|
135
|
-
return;
|
|
136
|
-
try {
|
|
137
|
-
mkdirSync(dirname(p), { recursive: true });
|
|
138
|
-
writeFileSync(p, new Date().toISOString(), "utf8");
|
|
190
|
+
function renderScopeSection(hint) {
|
|
191
|
+
const lines = [];
|
|
192
|
+
lines.push("## In-scope decisions/invariants for this file");
|
|
193
|
+
lines.push("");
|
|
194
|
+
for (const d of hint.decisions) {
|
|
195
|
+
lines.push(`- §${d}`);
|
|
139
196
|
}
|
|
140
|
-
|
|
141
|
-
|
|
197
|
+
for (const i of hint.invariants) {
|
|
198
|
+
lines.push(`- §${i}`);
|
|
142
199
|
}
|
|
200
|
+
return lines.join("\n");
|
|
143
201
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
202
|
+
function renderBypassBlockReason(relPath) {
|
|
203
|
+
return (`## STOP — BYPASS DETECTED\n\n` +
|
|
204
|
+
`You are attempting to write to a tracked source file (\`${relPath}\`) ` +
|
|
205
|
+
`without an active task. This bypasses the cairn-direction skill and ` +
|
|
206
|
+
`breaks ground-state continuity.\n\n` +
|
|
207
|
+
`1. Call cairn_task_create first to define your intent.\n` +
|
|
208
|
+
`2. Then proceed with your changes.\n\n` +
|
|
209
|
+
`If this is a trivial edit or you are explicitly bypassing, retry the write. ` +
|
|
210
|
+
`This warning is only shown once per session.`);
|
|
211
|
+
}
|
|
212
|
+
import { spawnSync } from "node:child_process";
|
|
213
|
+
import { readdirSync } from "node:fs";
|
|
150
214
|
function hasTightenedActiveTask(repoRoot) {
|
|
151
215
|
const tasksDir = join(repoRoot, ".cairn", "tasks", "active");
|
|
152
216
|
if (!existsSync(tasksDir))
|
|
@@ -161,146 +225,30 @@ function hasTightenedActiveTask(repoRoot) {
|
|
|
161
225
|
for (const entry of entries) {
|
|
162
226
|
if (!entry.isDirectory())
|
|
163
227
|
continue;
|
|
164
|
-
|
|
165
|
-
if (existsSync(join(taskDir, "spec.tightened.md")) &&
|
|
166
|
-
existsSync(join(taskDir, "status.yaml"))) {
|
|
228
|
+
if (existsSync(join(tasksDir, entry.name, "spec.tightened.md")))
|
|
167
229
|
return true;
|
|
168
|
-
}
|
|
169
230
|
}
|
|
170
231
|
return false;
|
|
171
232
|
}
|
|
172
|
-
function
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
"but the cairn-direction skill never wrote a spec for this work — so the change is unattested.",
|
|
180
|
-
"",
|
|
181
|
-
"Recover NOW (before any further mutation):",
|
|
182
|
-
" 1. `git -C <repoRoot> checkout -- " + relPath + "` to revert the unattested edit",
|
|
183
|
-
" 2. Call the `cairn_task_create` MCP tool with the operator's original prompt as the `goal`",
|
|
184
|
-
" and a kebab `slug` (2-4 words). The server writes spec.tightened.md + status.yaml under",
|
|
185
|
-
" `.cairn/tasks/active/<task_id>/` with the correct format.",
|
|
186
|
-
" 3. Re-apply the Edit; this hook will pass on next mutation.",
|
|
187
|
-
"",
|
|
188
|
-
"If the Edit is correct as-is and you simply forgot to tighten:",
|
|
189
|
-
" - Skip the revert; call `cairn_task_create` now to retroactively register the work.",
|
|
190
|
-
"",
|
|
191
|
-
"Subsequent edits in this session will not re-trigger this block (sentinel set).",
|
|
192
|
-
].join("\n");
|
|
233
|
+
function isProjectTrackedFile(repoRoot, relPath) {
|
|
234
|
+
if (relPath === ".cairn" || relPath.startsWith(".cairn/"))
|
|
235
|
+
return false;
|
|
236
|
+
const r = spawnSync("git", ["check-ignore", "-q", "--", relPath], {
|
|
237
|
+
cwd: repoRoot,
|
|
238
|
+
});
|
|
239
|
+
return r.status === 1;
|
|
193
240
|
}
|
|
194
|
-
function
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
if (scopeHint.invariants.length > 0) {
|
|
201
|
-
const formatted = scopeHint.invariants
|
|
202
|
-
.map((v) => (v.startsWith("§") ? v : `§${v}`))
|
|
203
|
-
.join(", ");
|
|
204
|
-
lines.push(` invariants: ${formatted}`);
|
|
205
|
-
}
|
|
206
|
-
return lines.join("\n");
|
|
241
|
+
function bypassAlreadyWarned(repoRoot, sessionId) {
|
|
242
|
+
if (sessionId === null)
|
|
243
|
+
return false;
|
|
244
|
+
const path = join(repoRoot, ".cairn", "cache", `bypass-warned-${sessionId}`);
|
|
245
|
+
return existsSync(path);
|
|
207
246
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
emitShapeB("");
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
const filePath = typeof payload.tool_input?.file_path === "string"
|
|
218
|
-
? payload.tool_input.file_path
|
|
219
|
-
: undefined;
|
|
220
|
-
if (filePath === undefined) {
|
|
221
|
-
emitShapeB("");
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
let content = pickContent(payload.tool_response);
|
|
225
|
-
if ((content === undefined || content.length === 0) &&
|
|
226
|
-
toolName === "Edit") {
|
|
227
|
-
const ns = payload.tool_input?.new_string;
|
|
228
|
-
if (typeof ns === "string" && ns.length > 0)
|
|
229
|
-
content = ns;
|
|
230
|
-
}
|
|
231
|
-
if (content === undefined || content.length === 0) {
|
|
232
|
-
emitShapeB("");
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
const repoRoot = resolveRepoRoot(filePath);
|
|
236
|
-
if (repoRoot === null) {
|
|
237
|
-
emitShapeB("");
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
const relPath = computeRelPath(repoRoot, filePath);
|
|
241
|
-
const config = readCopySafetyConfig(repoRoot);
|
|
242
|
-
const inGlobs = config.enabled && matchAnyGlob(relPath, config.globs);
|
|
243
|
-
let issues = [];
|
|
244
|
-
if (inGlobs) {
|
|
245
|
-
const raw = scanForCopyLeakage(content, filePath);
|
|
246
|
-
issues = filterAllowed(raw, config);
|
|
247
|
-
}
|
|
248
|
-
// Deterministic scope-index sync — fold any §INV/§DEC tokens in the
|
|
249
|
-
// just-written content into this file's scope-index entry so the
|
|
250
|
-
// in-scope MCP tools never lag behind source-cite reality between
|
|
251
|
-
// SessionStart rescans. Defer-fail: scope sync must NEVER block
|
|
252
|
-
// the write hint, so wrap and swallow errors.
|
|
253
|
-
try {
|
|
254
|
-
syncFileScopeFromContent(repoRoot, relPath, content);
|
|
255
|
-
}
|
|
256
|
-
catch {
|
|
257
|
-
// ignore — guardian is a hint, scope sync is best-effort
|
|
258
|
-
}
|
|
259
|
-
const cachedEntry = getScopeIndexEntry(repoRoot, relPath);
|
|
260
|
-
// Suppress the scope reminder when the entry exists but has no
|
|
261
|
-
// rules attached — printing a header with no items below is just
|
|
262
|
-
// visual noise. Mirrors legend-builder's guard.
|
|
263
|
-
const scopeHint = cachedEntry !== null &&
|
|
264
|
-
(cachedEntry.decisions.length > 0 || cachedEntry.invariants.length > 0)
|
|
265
|
-
? {
|
|
266
|
-
decisions: cachedEntry.decisions,
|
|
267
|
-
invariants: cachedEntry.invariants,
|
|
268
|
-
}
|
|
269
|
-
: null;
|
|
270
|
-
const sessionId = typeof payload.session_id === "string" ? payload.session_id : null;
|
|
271
|
-
// Bypass detection: Edit on tracked source without a tightened
|
|
272
|
-
// active task. Strong-deterministic signal via `decision: "block"`
|
|
273
|
-
// so the model treats it as an error, not a hint. One block per
|
|
274
|
-
// session per untightened-state — sentinel dedupes follow-up edits.
|
|
275
|
-
if (isProjectTrackedFile(repoRoot, relPath) &&
|
|
276
|
-
!hasTightenedActiveTask(repoRoot) &&
|
|
277
|
-
!bypassAlreadyWarned(repoRoot, sessionId)) {
|
|
278
|
-
markBypassWarned(repoRoot, sessionId);
|
|
279
|
-
emitBlock(renderBypassBlockReason(relPath));
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
const sections = [];
|
|
283
|
-
if (issues.length > 0) {
|
|
284
|
-
sections.push(renderCopySafetySection(basename(filePath), issues));
|
|
285
|
-
}
|
|
286
|
-
if (scopeHint !== null) {
|
|
287
|
-
sections.push(renderScopeSection(scopeHint));
|
|
288
|
-
}
|
|
289
|
-
if (sections.length === 0) {
|
|
290
|
-
emitShapeB("");
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
const block = sections.join("\n\n") + "\n\nWrite succeeded. Review before committing.";
|
|
294
|
-
emitShapeB(block);
|
|
295
|
-
}
|
|
296
|
-
catch {
|
|
297
|
-
// Defer-fail gracefully — guardian is a hint, NOT a gate.
|
|
298
|
-
try {
|
|
299
|
-
emitShapeB("");
|
|
300
|
-
}
|
|
301
|
-
catch {
|
|
302
|
-
// Last-resort: nothing we can do.
|
|
303
|
-
}
|
|
304
|
-
}
|
|
247
|
+
function markBypassWarned(repoRoot, sessionId) {
|
|
248
|
+
if (sessionId === null)
|
|
249
|
+
return;
|
|
250
|
+
const path = join(repoRoot, ".cairn", "cache", `bypass-warned-${sessionId}`);
|
|
251
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
252
|
+
writeFileSync(path, "true", "utf8");
|
|
305
253
|
}
|
|
306
254
|
//# sourceMappingURL=write-guardian.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-guardian.js","sourceRoot":"","sources":["../../../src/hooks/post-tool-use/write-guardian.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"write-guardian.js","sourceRoot":"","sources":["../../../src/hooks/post-tool-use/write-guardian.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAgB,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EAEb,UAAU,EACV,eAAe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Sync } from "node:child_process";
|
|
|
32
32
|
import { appendFileSync, existsSync, mkdirSync, mkdtempSync, rmSync, } from "node:fs";
|
|
33
33
|
import { tmpdir } from "node:os";
|
|
34
34
|
import { dirname, join } from "node:path";
|
|
35
|
-
import { writeFileSafe } from "
|
|
35
|
+
import { writeFileSafe } from "@isaacriehm/cairn-state";
|
|
36
36
|
import { resolveRepoRoot } from "../../session-start/index.js";
|
|
37
|
-
import { bodyContentHash, layerADeferredLogPath, preCommitDeferredLogPath, PreCommitDriftLogEntry, readSotCache, recordDriftEvent, } from "
|
|
37
|
+
import { bodyContentHash, layerADeferredLogPath, preCommitDeferredLogPath, PreCommitDriftLogEntry, readSotCache, recordDriftEvent, } from "@isaacriehm/cairn-state";
|
|
38
38
|
import { logger } from "../../logger.js";
|
|
39
39
|
import { tokenize } from "../../text/jaccard.js";
|
|
40
40
|
import { TIER2_JACCARD_FLOOR, TOP_K_CANDIDATES, extractBlocks, isMarkdownPath, tier1PickWithBody, topKCandidates, } from "../sot-align-common.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sot-align-precommit.js","sourceRoot":"","sources":["../../../src/hooks/pre-commit/sot-align-precommit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,cAAc,EACd,UAAU,EACV,SAAS,EACT,WAAW,EACX,MAAM,GAEP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"sot-align-precommit.js","sourceRoot":"","sources":["../../../src/hooks/pre-commit/sot-align-precommit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6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AAK,KAAK,IAAI;YACZ,CAAC,CAAC,6DAA6D;YAC/D,CAAC,CAAC,0DAA0D,KAAK,EAAE;QACvE,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,KAAK,IAAI,SAAS;KAC3B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -11,5 +11,5 @@ export { renderBypassHint, scanBypassedCommits, } from "../bypass-detection.js";
|
|
|
11
11
|
export type { BypassedCommit, ScanBypassResult, } from "../bypass-detection.js";
|
|
12
12
|
export { seedAttestedCommits } from "../seed-attested.js";
|
|
13
13
|
export type { SeedAttestedResult, SeedAttestedStatus } from "../seed-attested.js";
|
|
14
|
-
export { CAIRN_HOOK_VERSION, emitShapeB, parseHookPayload, readHookStdin,
|
|
15
|
-
export type { ClaudeHookPayload
|
|
14
|
+
export { CAIRN_HOOK_VERSION, emitShapeB, parseHookPayload, readHookStdin, appendTelemetry, } from "./payload.js";
|
|
15
|
+
export type { ClaudeHookPayload } from "./payload.js";
|