@sledorze/cairn 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -18
- package/dist/cli.js +69378 -70958
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +10 -10
- package/dist/config.js.map +1 -1
- package/dist/core/Config.d.ts +22 -22
- package/dist/core/Config.d.ts.map +1 -1
- package/dist/core/Config.js +33 -33
- package/dist/core/Config.js.map +1 -1
- package/dist/core/glob.bench.js +1 -1
- package/dist/core/glob.d.ts.map +1 -1
- package/dist/core/hashing.d.ts +3 -0
- package/dist/core/hashing.d.ts.map +1 -0
- package/dist/core/hashing.js +16 -0
- package/dist/core/hashing.js.map +1 -0
- package/dist/core/links/Anchors.d.ts +30 -0
- package/dist/core/links/Anchors.d.ts.map +1 -0
- package/dist/core/links/Anchors.js +119 -0
- package/dist/core/links/Anchors.js.map +1 -0
- package/dist/core/links/MarkdownLinks.bench.d.ts.map +1 -0
- package/dist/core/{MarkdownLinks.bench.js → links/MarkdownLinks.bench.js} +1 -1
- package/dist/core/links/MarkdownLinks.bench.js.map +1 -0
- package/dist/core/links/MarkdownLinks.d.ts +121 -0
- package/dist/core/links/MarkdownLinks.d.ts.map +1 -0
- package/dist/core/links/MarkdownLinks.js +228 -0
- package/dist/core/links/MarkdownLinks.js.map +1 -0
- package/dist/core/links/RefStore.d.ts +32 -0
- package/dist/core/links/RefStore.d.ts.map +1 -0
- package/dist/core/links/RefStore.js +60 -0
- package/dist/core/links/RefStore.js.map +1 -0
- package/dist/core/links/markdownFences.d.ts +10 -0
- package/dist/core/links/markdownFences.d.ts.map +1 -0
- package/dist/core/links/markdownFences.js +51 -0
- package/dist/core/links/markdownFences.js.map +1 -0
- package/dist/core/paths.d.ts +8 -0
- package/dist/core/paths.d.ts.map +1 -1
- package/dist/core/paths.js +13 -0
- package/dist/core/paths.js.map +1 -1
- package/dist/core/sidecar.d.ts +45 -0
- package/dist/core/sidecar.d.ts.map +1 -0
- package/dist/core/sidecar.js +83 -0
- package/dist/core/sidecar.js.map +1 -0
- package/dist/core/{DocSummaries.d.ts → summaries/DocSummaries.d.ts} +13 -3
- package/dist/core/summaries/DocSummaries.d.ts.map +1 -0
- package/dist/core/{DocSummaries.js → summaries/DocSummaries.js} +31 -11
- package/dist/core/summaries/DocSummaries.js.map +1 -0
- package/dist/core/summaries/StampStore.d.ts +19 -0
- package/dist/core/summaries/StampStore.d.ts.map +1 -0
- package/dist/core/summaries/StampStore.js +34 -0
- package/dist/core/summaries/StampStore.js.map +1 -0
- package/dist/core/summaries/SummaryTree.bench.d.ts.map +1 -0
- package/dist/core/{SummaryTree.bench.js → summaries/SummaryTree.bench.js} +24 -14
- package/dist/core/summaries/SummaryTree.bench.js.map +1 -0
- package/dist/core/{SummaryTree.d.ts → summaries/SummaryTree.d.ts} +10 -1
- package/dist/core/summaries/SummaryTree.d.ts.map +1 -0
- package/dist/core/{SummaryTree.js → summaries/SummaryTree.js} +35 -9
- package/dist/core/summaries/SummaryTree.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/init/content.d.ts +2 -2
- package/dist/init/content.d.ts.map +1 -1
- package/dist/init/content.js +45 -15
- package/dist/init/content.js.map +1 -1
- package/dist/init/generate.d.ts +1 -1
- package/dist/init/generate.d.ts.map +1 -1
- package/dist/init/generate.js +1 -1
- package/dist/io/DocsFs.d.ts +2 -3
- package/dist/io/DocsFs.d.ts.map +1 -1
- package/dist/io/DocsFs.js +15 -5
- package/dist/io/DocsFs.js.map +1 -1
- package/dist/program/JsonReport.d.ts +2 -2
- package/dist/program/JsonReport.d.ts.map +1 -1
- package/dist/program/JsonReport.js +2 -2
- package/dist/program/JsonReport.js.map +1 -1
- package/dist/program/{CheckLinks.d.ts → links/CheckLinks.d.ts} +9 -4
- package/dist/program/links/CheckLinks.d.ts.map +1 -0
- package/dist/program/links/CheckLinks.js +243 -0
- package/dist/program/links/CheckLinks.js.map +1 -0
- package/dist/program/links/CheckRefs.d.ts +47 -0
- package/dist/program/links/CheckRefs.d.ts.map +1 -0
- package/dist/program/links/CheckRefs.js +151 -0
- package/dist/program/links/CheckRefs.js.map +1 -0
- package/dist/program/locale.d.ts.map +1 -1
- package/dist/program/summaries/CheckSummaries.bench.d.ts +2 -0
- package/dist/program/summaries/CheckSummaries.bench.d.ts.map +1 -0
- package/dist/program/summaries/CheckSummaries.bench.js +94 -0
- package/dist/program/summaries/CheckSummaries.bench.js.map +1 -0
- package/dist/program/summaries/CheckSummaries.d.ts +58 -0
- package/dist/program/summaries/CheckSummaries.d.ts.map +1 -0
- package/dist/program/summaries/CheckSummaries.js +302 -0
- package/dist/program/summaries/CheckSummaries.js.map +1 -0
- package/package.json +7 -8
- package/schema/cairn.schema.json +35 -38
- package/dist/core/DocSummaries.d.ts.map +0 -1
- package/dist/core/DocSummaries.js.map +0 -1
- package/dist/core/MarkdownLinks.bench.d.ts.map +0 -1
- package/dist/core/MarkdownLinks.bench.js.map +0 -1
- package/dist/core/MarkdownLinks.d.ts +0 -51
- package/dist/core/MarkdownLinks.d.ts.map +0 -1
- package/dist/core/MarkdownLinks.js +0 -115
- package/dist/core/MarkdownLinks.js.map +0 -1
- package/dist/core/SummaryTree.bench.d.ts.map +0 -1
- package/dist/core/SummaryTree.bench.js.map +0 -1
- package/dist/core/SummaryTree.d.ts.map +0 -1
- package/dist/core/SummaryTree.js.map +0 -1
- package/dist/program/CheckLinks.d.ts.map +0 -1
- package/dist/program/CheckLinks.js +0 -122
- package/dist/program/CheckLinks.js.map +0 -1
- package/dist/program/CheckSummaries.d.ts +0 -38
- package/dist/program/CheckSummaries.d.ts.map +0 -1
- package/dist/program/CheckSummaries.js +0 -198
- package/dist/program/CheckSummaries.js.map +0 -1
- /package/dist/core/{MarkdownLinks.bench.d.ts → links/MarkdownLinks.bench.d.ts} +0 -0
- /package/dist/core/{SummaryTree.bench.d.ts → summaries/SummaryTree.bench.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -16,15 +16,18 @@ compares modification times. But **git does not preserve mtimes**: after a clone
|
|
|
16
16
|
checkout, every file looks freshly written, so a time-based check silently passes on
|
|
17
17
|
summaries that are actually stale. The bug you meant to catch ships anyway.
|
|
18
18
|
|
|
19
|
-
`cairn` checks **content**, not clocks.
|
|
20
|
-
|
|
19
|
+
`cairn` checks **content**, not clocks. The SHA-256 of the source each summary
|
|
20
|
+
summarizes is recorded in a hidden sidecar under `.cairn/`, mirroring your docs tree —
|
|
21
|
+
never inside the summary itself, so the tracking system leaves zero bytes in the docs
|
|
22
|
+
you write:
|
|
21
23
|
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
+
```
|
|
25
|
+
.cairn/docs/guide.summary.md.json → {"sha256": "3f9a…(64 hex)", "version": 1}
|
|
24
26
|
```
|
|
25
27
|
|
|
26
|
-
The checker recomputes the source hash and compares
|
|
27
|
-
missing — and it behaves identically on your laptop and in CI,
|
|
28
|
+
The checker recomputes the source hash and compares it to the sidecar. Mismatch means
|
|
29
|
+
stale, missing means missing — and it behaves identically on your laptop and in CI,
|
|
30
|
+
before and after a clone. Commit `.cairn/` alongside your docs; it isn't gitignored.
|
|
28
31
|
|
|
29
32
|
## Install
|
|
30
33
|
|
|
@@ -42,24 +45,72 @@ The round-trip when you touch a doc:
|
|
|
42
45
|
|
|
43
46
|
1. **Edit** `docs/guide.md`.
|
|
44
47
|
2. `npx cairn check` **flags it stale** — the source hash no longer matches the
|
|
45
|
-
|
|
48
|
+
sidecar recorded for `guide.summary.md`.
|
|
46
49
|
3. **Write** the updated `guide.summary.md` (and update any parent `_SUMMARY.md`).
|
|
47
|
-
4. **Stamp**: `npx cairn check --summaries-only --stamp` rewrites the
|
|
48
|
-
|
|
50
|
+
4. **Stamp**: `npx cairn check --summaries-only --stamp` rewrites the `.cairn/`
|
|
51
|
+
sidecar hashes bottom-up — your summary's content is never touched.
|
|
49
52
|
5. **Check** again — `npx cairn check` exits 0. Green.
|
|
50
53
|
|
|
51
|
-
You author the prose; the tool verifies and stamps. It never invents content
|
|
54
|
+
You author the prose; the tool verifies and stamps. It never invents content, and it
|
|
55
|
+
never writes into content either.
|
|
52
56
|
|
|
53
57
|
### Commands
|
|
54
58
|
|
|
55
|
-
| Command | What it does
|
|
56
|
-
| ----------------------------------------- |
|
|
57
|
-
| `cairn check` | Check summaries + links; exit 1 on any problem
|
|
58
|
-
| `cairn check --summaries-only` | Check only summary freshness
|
|
59
|
-
| `cairn check --links-only` | Check only Markdown links
|
|
60
|
-
| `cairn check --links-only --fix` | Auto-repair unambiguous dead links
|
|
61
|
-
| `cairn check --summaries-only --stamp` | Rewrite
|
|
62
|
-
| `cairn
|
|
59
|
+
| Command | What it does |
|
|
60
|
+
| ----------------------------------------- | ------------------------------------------------------------------------- |
|
|
61
|
+
| `cairn check` | Check summaries + links; exit 1 on any problem |
|
|
62
|
+
| `cairn check --summaries-only` | Check only summary freshness |
|
|
63
|
+
| `cairn check --links-only` | Check only Markdown links |
|
|
64
|
+
| `cairn check --links-only --fix` | Auto-repair unambiguous dead links |
|
|
65
|
+
| `cairn check --summaries-only --stamp` | Rewrite the `.cairn/` sidecar hash of existing summaries, bottom-up |
|
|
66
|
+
| `cairn check --prune` | Delete orphan summaries and orphan `.cairn/` sidecars |
|
|
67
|
+
| `cairn check --migrate-stamps` | Optional: same self-healing `--stamp` already does, as its own named step |
|
|
68
|
+
| `cairn check --refs --stamp` | Opt-in: record each real reference target's content hash |
|
|
69
|
+
| `cairn check --refs` | Opt-in: report references whose target content has drifted since |
|
|
70
|
+
| `cairn init --agent claude\|copilot\|all` | Scaffold agent guidance files |
|
|
71
|
+
|
|
72
|
+
### Link checking
|
|
73
|
+
|
|
74
|
+
A dead link is only the most obvious way a reference rots. `cairn check` (or
|
|
75
|
+
`--links-only`) verifies, for every relative Markdown link:
|
|
76
|
+
|
|
77
|
+
- **The path resolves** — including targets _outside_ your configured `roots`, as long as
|
|
78
|
+
they stay inside the repository checkout (e.g. a doc in `docs/` linking to `../src/foo.ts`).
|
|
79
|
+
Nothing outside the checkout root is ever touched, even to check existence — this bound is
|
|
80
|
+
deliberate: CI runs over untrusted PR content, and an unbounded filesystem check would be
|
|
81
|
+
an existence oracle.
|
|
82
|
+
- **The `#heading` fragment exists** — same-page (`[intro](#getting-started)`) and
|
|
83
|
+
cross-file (`[intro](./guide.md#getting-started)`), slugged the same way GitHub does.
|
|
84
|
+
- **A `#L10`/`#L10-L20` line-fragment is in range**, for links to source files outside `roots`.
|
|
85
|
+
|
|
86
|
+
A broken heading or out-of-range line reports with the reason (`path` / `anchor` / `line`)
|
|
87
|
+
and, where possible, what's actually there (the target's real headings, or its real line
|
|
88
|
+
count) — so fixing it doesn't require opening the target file first.
|
|
89
|
+
|
|
90
|
+
`cairn check --refs` is a separate, **opt-in** signal, off by default and not part of the
|
|
91
|
+
`path`/`anchor`/`line` checks above: it tracks the _content_ of what a link points to, not
|
|
92
|
+
just whether the link resolves. `--refs --stamp` records a hash of every reference target;
|
|
93
|
+
a later `--refs` run reports any that changed since — "this doc's claim about that file may
|
|
94
|
+
be stale," distinct from a broken link (the link still resolves; what it once meant may not
|
|
95
|
+
still hold). Still v1/experimental (whole-file hashing only — a one-line unrelated change to
|
|
96
|
+
a large target file is reported the same as a change to the exact part being referenced).
|
|
97
|
+
|
|
98
|
+
### Upgrading from an older cairn
|
|
99
|
+
|
|
100
|
+
**If you're upgrading past `0.3.0`**: link checking got stricter. Anchors and links outside
|
|
101
|
+
`roots` were previously accepted unconditionally, whether or not they actually resolved —
|
|
102
|
+
`cairn` simply never looked. If `cairn check` newly fails after upgrading, the links it's
|
|
103
|
+
flagging were already broken; nothing about your docs changed, only the tool's ability to
|
|
104
|
+
notice did. Fix the flagged link/anchor, or, if a genuine false positive (e.g. a symbol-level
|
|
105
|
+
anchor like `x.ts#someExport` — deliberately never checked, see the source's own scenario
|
|
106
|
+
notes), please open an issue.
|
|
107
|
+
|
|
108
|
+
Nothing to look up for the summary/stamp side. If a summary still carries the old in-content
|
|
109
|
+
`<!-- source-sha256: ... -->` comment, the ordinary `--stamp` command strips it and
|
|
110
|
+
writes the `.cairn/` sidecar in the same run — automatically, every time. There is no
|
|
111
|
+
separate migration step to discover: whatever `stampCommand` your repo already runs
|
|
112
|
+
already handles it. `--migrate-stamps` exists only as an optional, explicitly-named
|
|
113
|
+
alias for the same behavior, for anyone who wants the cleanup reported as its own step.
|
|
63
114
|
|
|
64
115
|
## The two summary kinds
|
|
65
116
|
|