@isaacriehm/cairn-core 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/align-undo/index.d.ts +6 -0
- package/dist/align-undo/index.js +6 -0
- package/dist/align-undo/index.js.map +1 -0
- package/dist/align-undo/log.d.ts +53 -0
- package/dist/align-undo/log.js +99 -0
- package/dist/align-undo/log.js.map +1 -0
- package/dist/align-undo/undo.d.ts +66 -0
- package/dist/align-undo/undo.js +187 -0
- package/dist/align-undo/undo.js.map +1 -0
- package/dist/attention/bulk-accept.js +1 -1
- package/dist/attention/bulk-accept.js.map +1 -1
- package/dist/attention/dedup.d.ts +2 -2
- package/dist/attention/dedup.js +16 -51
- package/dist/attention/dedup.js.map +1 -1
- package/dist/attention/index.d.ts +1 -0
- package/dist/attention/index.js +1 -0
- package/dist/attention/index.js.map +1 -1
- package/dist/attention/restore.js +1 -1
- package/dist/attention/restore.js.map +1 -1
- package/dist/attention/serve/api.d.ts +23 -0
- package/dist/attention/serve/api.js +344 -0
- package/dist/attention/serve/api.js.map +1 -0
- package/dist/attention/serve/index.d.ts +62 -0
- package/dist/attention/serve/index.js +205 -0
- package/dist/attention/serve/index.js.map +1 -0
- package/dist/decision-capture/id.d.ts +62 -25
- package/dist/decision-capture/id.js +78 -57
- package/dist/decision-capture/id.js.map +1 -1
- package/dist/decision-capture/index.d.ts +3 -3
- package/dist/decision-capture/index.js +3 -3
- package/dist/decision-capture/index.js.map +1 -1
- package/dist/drain/drain.d.ts +77 -0
- package/dist/drain/drain.js +464 -0
- package/dist/drain/drain.js.map +1 -0
- package/dist/drain/index.d.ts +5 -0
- package/dist/drain/index.js +5 -0
- package/dist/drain/index.js.map +1 -0
- package/dist/fix-align/index.d.ts +5 -0
- package/dist/fix-align/index.js +5 -0
- package/dist/fix-align/index.js.map +1 -0
- package/dist/fix-align/run.d.ts +99 -0
- package/dist/fix-align/run.js +258 -0
- package/dist/fix-align/run.js.map +1 -0
- package/dist/ground/alignment-pending.d.ts +28 -0
- package/dist/ground/alignment-pending.js +83 -0
- package/dist/ground/alignment-pending.js.map +1 -0
- package/dist/ground/anchor-map.d.ts +14 -0
- package/dist/ground/anchor-map.js +57 -0
- package/dist/ground/anchor-map.js.map +1 -0
- package/dist/ground/index.d.ts +9 -2
- package/dist/ground/index.js +8 -2
- package/dist/ground/index.js.map +1 -1
- package/dist/ground/paths.d.ts +21 -0
- package/dist/ground/paths.js +43 -0
- package/dist/ground/paths.js.map +1 -1
- package/dist/ground/schemas.d.ts +201 -0
- package/dist/ground/schemas.js +128 -3
- package/dist/ground/schemas.js.map +1 -1
- package/dist/ground/scope-index.js +2 -2
- package/dist/ground/scope-index.js.map +1 -1
- package/dist/ground/slug.d.ts +60 -0
- package/dist/ground/slug.js +103 -0
- package/dist/ground/slug.js.map +1 -0
- package/dist/ground/sot-bindings.d.ts +14 -0
- package/dist/ground/sot-bindings.js +80 -0
- package/dist/ground/sot-bindings.js.map +1 -0
- package/dist/ground/sot-cache.d.ts +18 -0
- package/dist/ground/sot-cache.js +63 -0
- package/dist/ground/sot-cache.js.map +1 -0
- package/dist/ground/topic-index.d.ts +20 -0
- package/dist/ground/topic-index.js +60 -0
- package/dist/ground/topic-index.js.map +1 -0
- package/dist/hooks/post-tool-use/citation-scanner.d.ts +1 -1
- package/dist/hooks/post-tool-use/citation-scanner.js +3 -3
- package/dist/hooks/post-tool-use/citation-scanner.js.map +1 -1
- package/dist/hooks/post-tool-use/copy-scanner.js +1 -1
- package/dist/hooks/post-tool-use/copy-scanner.js.map +1 -1
- package/dist/hooks/post-tool-use/index.d.ts +2 -0
- package/dist/hooks/post-tool-use/index.js +1 -0
- package/dist/hooks/post-tool-use/index.js.map +1 -1
- package/dist/hooks/post-tool-use/legend-builder.d.ts +1 -1
- package/dist/hooks/post-tool-use/legend-builder.js +2 -2
- package/dist/hooks/post-tool-use/legend-builder.js.map +1 -1
- package/dist/hooks/post-tool-use/sot-align.d.ts +166 -0
- package/dist/hooks/post-tool-use/sot-align.js +1311 -0
- package/dist/hooks/post-tool-use/sot-align.js.map +1 -0
- package/dist/hooks/pre-commit/index.d.ts +8 -0
- package/dist/hooks/pre-commit/index.js +8 -0
- package/dist/hooks/pre-commit/index.js.map +1 -0
- package/dist/hooks/pre-commit/sot-align-precommit.d.ts +60 -0
- package/dist/hooks/pre-commit/sot-align-precommit.js +221 -0
- package/dist/hooks/pre-commit/sot-align-precommit.js.map +1 -0
- package/dist/hooks/runners/session-start.js +41 -0
- package/dist/hooks/runners/session-start.js.map +1 -1
- package/dist/hooks/sot-align-common.d.ts +39 -0
- package/dist/hooks/sot-align-common.js +152 -0
- package/dist/hooks/sot-align-common.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/init/index.d.ts +4 -2
- package/dist/init/index.js +2 -1
- package/dist/init/index.js.map +1 -1
- package/dist/init/ingest-docs.d.ts +30 -47
- package/dist/init/ingest-docs.js +113 -406
- package/dist/init/ingest-docs.js.map +1 -1
- package/dist/init/init.d.ts +8 -0
- package/dist/init/init.js +58 -29
- package/dist/init/init.js.map +1 -1
- package/dist/init/mapper-parallel.js +1 -1
- package/dist/init/mapper-parallel.js.map +1 -1
- package/dist/init/phases/5-brand.js +1 -1
- package/dist/init/phases/5-brand.js.map +1 -1
- package/dist/init/phases/5b-topic-index.d.ts +30 -0
- package/dist/init/phases/5b-topic-index.js +62 -0
- package/dist/init/phases/5b-topic-index.js.map +1 -0
- package/dist/init/phases/6-docs-ingest.d.ts +4 -5
- package/dist/init/phases/6-docs-ingest.js +5 -6
- package/dist/init/phases/6-docs-ingest.js.map +1 -1
- package/dist/init/phases/index.d.ts +2 -0
- package/dist/init/phases/index.js +1 -0
- package/dist/init/phases/index.js.map +1 -1
- package/dist/init/phases/parallel-678.d.ts +14 -17
- package/dist/init/phases/parallel-678.js +77 -98
- package/dist/init/phases/parallel-678.js.map +1 -1
- package/dist/init/phases/source-comments-output-io.d.ts +16 -10
- package/dist/init/phases/source-comments-output-io.js +7 -10
- package/dist/init/phases/source-comments-output-io.js.map +1 -1
- package/dist/init/phases/types.d.ts +1 -1
- package/dist/init/phases/types.js +1 -0
- package/dist/init/phases/types.js.map +1 -1
- package/dist/init/rules-merge/discover.d.ts +8 -3
- package/dist/init/rules-merge/discover.js +7 -3
- package/dist/init/rules-merge/discover.js.map +1 -1
- package/dist/init/rules-merge/ingest.d.ts +81 -28
- package/dist/init/rules-merge/ingest.js +456 -155
- package/dist/init/rules-merge/ingest.js.map +1 -1
- package/dist/init/sot-emit.d.ts +84 -0
- package/dist/init/sot-emit.js +218 -0
- package/dist/init/sot-emit.js.map +1 -0
- package/dist/init/source-comments/classify.d.ts +12 -10
- package/dist/init/source-comments/classify.js +13 -25
- 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 +1 -1
- package/dist/init/source-comments/index.js.map +1 -1
- package/dist/init/source-comments/ingest.d.ts +91 -67
- package/dist/init/source-comments/ingest.js +392 -349
- package/dist/init/source-comments/ingest.js.map +1 -1
- package/dist/init/topic-index/index.d.ts +36 -0
- package/dist/init/topic-index/index.js +46 -0
- package/dist/init/topic-index/index.js.map +1 -0
- package/dist/init/topic-index/judge.d.ts +20 -0
- package/dist/init/topic-index/judge.js +65 -0
- package/dist/init/topic-index/judge.js.map +1 -0
- package/dist/init/topic-index/resolve.d.ts +50 -0
- package/dist/init/topic-index/resolve.js +196 -0
- package/dist/init/topic-index/resolve.js.map +1 -0
- package/dist/init/topic-index/walk.d.ts +43 -0
- package/dist/init/topic-index/walk.js +293 -0
- package/dist/init/topic-index/walk.js.map +1 -0
- package/dist/mcp/history/summarizer.js +1 -1
- package/dist/mcp/history/summarizer.js.map +1 -1
- package/dist/mcp/schemas.d.ts +46 -9
- package/dist/mcp/schemas.js +48 -12
- package/dist/mcp/schemas.js.map +1 -1
- package/dist/mcp/tools/align-drain.d.ts +7 -0
- package/dist/mcp/tools/align-drain.js +26 -0
- package/dist/mcp/tools/align-drain.js.map +1 -0
- package/dist/mcp/tools/archive.js +1 -1
- package/dist/mcp/tools/archive.js.map +1 -1
- package/dist/mcp/tools/attention-restore.js +1 -1
- package/dist/mcp/tools/attention-restore.js.map +1 -1
- package/dist/mcp/tools/attention-serve.d.ts +23 -0
- package/dist/mcp/tools/attention-serve.js +78 -0
- package/dist/mcp/tools/attention-serve.js.map +1 -0
- package/dist/mcp/tools/attention-wait.d.ts +18 -0
- package/dist/mcp/tools/attention-wait.js +74 -0
- package/dist/mcp/tools/attention-wait.js.map +1 -0
- package/dist/mcp/tools/index.js +7 -0
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/init-phases.js +4 -1
- package/dist/mcp/tools/init-phases.js.map +1 -1
- package/dist/mcp/tools/record-decision.js +14 -2
- package/dist/mcp/tools/record-decision.js.map +1 -1
- package/dist/mcp/tools/resolve-attention.d.ts +2 -2
- package/dist/mcp/tools/resolve-attention.js +830 -7
- package/dist/mcp/tools/resolve-attention.js.map +1 -1
- package/dist/status-line/event-queue.d.ts +40 -0
- package/dist/status-line/event-queue.js +195 -0
- package/dist/status-line/event-queue.js.map +1 -0
- package/dist/status-line/format.d.ts +1 -1
- package/dist/status-line/format.js +49 -6
- package/dist/status-line/format.js.map +1 -1
- package/dist/status-line/index.d.ts +41 -0
- package/dist/status-line/index.js +14 -0
- package/dist/status-line/index.js.map +1 -1
- package/dist/status-line/reader.js +23 -18
- package/dist/status-line/reader.js.map +1 -1
- package/dist/status-line/writer.d.ts +1 -1
- package/dist/status-line/writer.js +5 -0
- package/dist/status-line/writer.js.map +1 -1
- package/dist/text/jaccard.d.ts +19 -0
- package/dist/text/jaccard.js +68 -0
- package/dist/text/jaccard.js.map +1 -0
- package/package.json +1 -1
- package/templates/.cairn/git-hooks/pre-commit +16 -3
- package/templates/attention-ui/app.css +406 -0
- package/templates/attention-ui/app.js +384 -0
- package/templates/attention-ui/index.html +56 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layer A — live SoT alignment hook (plan §4.1).
|
|
3
|
+
*
|
|
4
|
+
* `cairn hook sot-align` runs as a PostToolUse hook on Claude Code's
|
|
5
|
+
* Write/Edit. For every prose block in the just-written file the
|
|
6
|
+
* pipeline picks one of:
|
|
7
|
+
*
|
|
8
|
+
* - **Tier 1 (deterministic, no Haiku)** — block is a verbatim/
|
|
9
|
+
* near-verbatim duplicate of an existing accepted DEC/INV body
|
|
10
|
+
* (Jaccard ≥ 0.85, 3-shingle ≥ 60%, length ratio 0.5-2.0).
|
|
11
|
+
* Auto-replace with `// §DEC-<hash>` (or `# §DEC-<hash>` per
|
|
12
|
+
* language). Statusline blip `⬡ aligned`.
|
|
13
|
+
*
|
|
14
|
+
* - **Tier 2 — Haiku dedup judge, two-pass.**
|
|
15
|
+
* Pass 1 (cheap, snippet + candidate body) → `same | different |
|
|
16
|
+
* ambiguous`. `same` → cite. `different` → next candidate.
|
|
17
|
+
* `ambiguous` → escalate to Pass 2.
|
|
18
|
+
* Pass 2 (full bodies + ±200-char source context + step-by-step
|
|
19
|
+
* prompt) → `same | different | augments | ambiguous`. `same`
|
|
20
|
+
* cite; `different` next; `augments` triggers two-stage delta:
|
|
21
|
+
* - Stage 1 — Haiku extracts the delta prose ("NO_DELTA" → same).
|
|
22
|
+
* - Stage 2 — Haiku classifies the delta `constraint | rationale`.
|
|
23
|
+
* constraint → fresh INV linked via `derived_from`; rationale
|
|
24
|
+
* → fresh DEC linked via `related`. The augmented source
|
|
25
|
+
* gains a `// §INV-<new>` / `// §DEC-<new>` cite *alongside*
|
|
26
|
+
* the existing one (existing token preserved).
|
|
27
|
+
* `ambiguous` (still!) → write to `.cairn/ground/alignment-
|
|
28
|
+
* pending/<id>.md` and surface via cairn-attention.
|
|
29
|
+
*
|
|
30
|
+
* - **Tier 3 — Haiku creation judge, two-pass.**
|
|
31
|
+
* Pass 1 → `decision | constraint | descriptive | ambiguous`.
|
|
32
|
+
* `descriptive` no-op (false-positive DEC creation pollutes
|
|
33
|
+
* ground state worse than missed capture). `ambiguous` →
|
|
34
|
+
* escalate to Pass 2 (full prose + ±200-char context + step-by-
|
|
35
|
+
* step prompt). Pass-2-still-ambiguous → alignment-pending.
|
|
36
|
+
*
|
|
37
|
+
* Hard rules:
|
|
38
|
+
* - The hook never blocks the Write. Failures degrade to no-op +
|
|
39
|
+
* log; the operator's edit always succeeds.
|
|
40
|
+
* - Per-Write call caps: max HAIKU_PASS1_CAP Pass-1 calls + max
|
|
41
|
+
* HAIKU_PASS2_CAP Pass-2 calls per Write. Excess defers to
|
|
42
|
+
* `.cairn/staleness/layer-a-deferred.jsonl` for Layer C drain.
|
|
43
|
+
* - Verdict cache at `.cairn/cache/haiku/<scope>/<blockHash>-<key>.json`
|
|
44
|
+
* so re-running the same prose hits cache instead of Haiku.
|
|
45
|
+
* - Source files outside Claude's repo (cwd) are skipped. Markdown
|
|
46
|
+
* (`.md`/`.mdx`) skipped entirely — operator-curated narrative is
|
|
47
|
+
* handled by phase 5b's topic-index + the doc-drift sensor.
|
|
48
|
+
*/
|
|
49
|
+
export interface AlignFileArgs {
|
|
50
|
+
repoRoot: string;
|
|
51
|
+
/** Repo-relative POSIX path written by Claude Code. */
|
|
52
|
+
filePath: string;
|
|
53
|
+
/** Claude Code session id (for statusline blips). */
|
|
54
|
+
sessionId: string | null;
|
|
55
|
+
/**
|
|
56
|
+
* Mock dedup judge — Pass 1. Default uses Haiku via runClaude.
|
|
57
|
+
*/
|
|
58
|
+
mockDedupJudgePass1?: (args: {
|
|
59
|
+
blockBody: string;
|
|
60
|
+
candidate: {
|
|
61
|
+
id: string;
|
|
62
|
+
body: string;
|
|
63
|
+
};
|
|
64
|
+
}) => Promise<DedupVerdictPass1>;
|
|
65
|
+
/**
|
|
66
|
+
* Mock dedup judge — Pass 2 (CoT escalation). Default uses Haiku.
|
|
67
|
+
*/
|
|
68
|
+
mockDedupJudgePass2?: (args: {
|
|
69
|
+
blockBody: string;
|
|
70
|
+
blockContext: string;
|
|
71
|
+
candidate: {
|
|
72
|
+
id: string;
|
|
73
|
+
body: string;
|
|
74
|
+
};
|
|
75
|
+
}) => Promise<DedupVerdictPass2>;
|
|
76
|
+
/**
|
|
77
|
+
* Mock delta extractor (Stage 1) — extract the prose delta when
|
|
78
|
+
* Pass 2 returns `augments`. Default uses Haiku.
|
|
79
|
+
*/
|
|
80
|
+
mockDeltaExtract?: (args: {
|
|
81
|
+
blockBody: string;
|
|
82
|
+
candidateBody: string;
|
|
83
|
+
}) => Promise<string>;
|
|
84
|
+
/**
|
|
85
|
+
* Mock delta classifier (Stage 2) — `constraint | rationale`.
|
|
86
|
+
* Default uses Haiku.
|
|
87
|
+
*/
|
|
88
|
+
mockDeltaClassify?: (args: {
|
|
89
|
+
delta: string;
|
|
90
|
+
}) => Promise<DeltaKind>;
|
|
91
|
+
/**
|
|
92
|
+
* Mock creation judge — Pass 1. Default uses Haiku via runClaude.
|
|
93
|
+
*/
|
|
94
|
+
mockCreationJudgePass1?: (args: {
|
|
95
|
+
blockBody: string;
|
|
96
|
+
file: string;
|
|
97
|
+
line: number;
|
|
98
|
+
}) => Promise<CreationVerdict>;
|
|
99
|
+
/**
|
|
100
|
+
* Mock creation judge — Pass 2 (CoT escalation). Default uses Haiku.
|
|
101
|
+
*/
|
|
102
|
+
mockCreationJudgePass2?: (args: {
|
|
103
|
+
blockBody: string;
|
|
104
|
+
blockContext: string;
|
|
105
|
+
file: string;
|
|
106
|
+
line: number;
|
|
107
|
+
}) => Promise<CreationVerdict>;
|
|
108
|
+
/**
|
|
109
|
+
* Override the per-call Pass-1 Haiku cap. Default 5 — appropriate
|
|
110
|
+
* for live PostToolUse Writes where the cost has to stay tight.
|
|
111
|
+
* Layer D (`cairn fix align`) sets this much higher (e.g. 200) so a
|
|
112
|
+
* single-file sweep can fully judge every block.
|
|
113
|
+
*/
|
|
114
|
+
pass1Cap?: number;
|
|
115
|
+
/** Override the per-call Pass-2 Haiku cap. Default 2. */
|
|
116
|
+
pass2Cap?: number;
|
|
117
|
+
/**
|
|
118
|
+
* When true, suppress the Tier 3 creation pipeline entirely — Tier 1
|
|
119
|
+
* + Tier 2 dedup still run. Layer D's `--no-creation` flag sets this
|
|
120
|
+
* so a sweep only consolidates duplicates without proposing fresh
|
|
121
|
+
* DECs from prose that doesn't match anything in the ledger yet.
|
|
122
|
+
*/
|
|
123
|
+
skipCreation?: boolean;
|
|
124
|
+
}
|
|
125
|
+
type DedupVerdictPass1 = "same" | "different" | "ambiguous";
|
|
126
|
+
type DedupVerdictPass2 = "same" | "different" | "augments" | "ambiguous";
|
|
127
|
+
type DeltaKind = "constraint" | "rationale";
|
|
128
|
+
export type CreationVerdict = "decision" | "constraint" | "descriptive" | "ambiguous";
|
|
129
|
+
/** Back-compat alias preserved for external callers. */
|
|
130
|
+
export type DedupVerdict = DedupVerdictPass1;
|
|
131
|
+
export interface AlignFileResult {
|
|
132
|
+
/** Number of prose blocks discovered in the written file. */
|
|
133
|
+
blocksConsidered: number;
|
|
134
|
+
/** Tier 1 deterministic auto-cites. */
|
|
135
|
+
tier1Aligned: number;
|
|
136
|
+
/** Tier 2 Haiku-confirmed cites. */
|
|
137
|
+
tier2Aligned: number;
|
|
138
|
+
/** Tier 3 fresh DECs emitted. */
|
|
139
|
+
decsCreated: number;
|
|
140
|
+
/** Tier 3 fresh INVs emitted. */
|
|
141
|
+
invsCreated: number;
|
|
142
|
+
/** Augments-DEC siblings (Pass 2 delta = rationale). */
|
|
143
|
+
augmentsDecs: number;
|
|
144
|
+
/** Augments-INV siblings (Pass 2 delta = constraint). */
|
|
145
|
+
augmentsInvs: number;
|
|
146
|
+
/** Blocks queued in `.cairn/ground/alignment-pending/`. */
|
|
147
|
+
pending: number;
|
|
148
|
+
/** Blocks deferred to staleness (cap exceeded). */
|
|
149
|
+
deferredToStaleness: number;
|
|
150
|
+
/** Blocks classified as descriptive (no-op). */
|
|
151
|
+
descriptive: number;
|
|
152
|
+
/** Blocks skipped for any reason — already-cited, length floor, etc. */
|
|
153
|
+
skipped: number;
|
|
154
|
+
/** Pass-1 Haiku calls made. */
|
|
155
|
+
haikuPass1Calls: number;
|
|
156
|
+
/** Pass-2 Haiku calls made. */
|
|
157
|
+
haikuPass2Calls: number;
|
|
158
|
+
/** Total Haiku calls (Pass 1 + Pass 2 + augments stages). Back-compat. */
|
|
159
|
+
haikuCalls: number;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Run the Layer A pipeline against one repo-relative file.
|
|
163
|
+
*/
|
|
164
|
+
export declare function alignFile(args: AlignFileArgs): Promise<AlignFileResult>;
|
|
165
|
+
export declare function runSotAlign(): Promise<void>;
|
|
166
|
+
export {};
|