@cr8rcho/alkahest 0.1.90 → 0.1.92
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 +1 -0
- package/dist/cli.js +10 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/presets.d.ts +13 -0
- package/dist/commands/presets.js +68 -1
- package/dist/commands/presets.js.map +1 -1
- package/dist/commands/update.js +16 -0
- package/dist/commands/update.js.map +1 -1
- package/dist/core/presetUpdate.d.ts +65 -0
- package/dist/core/presetUpdate.js +289 -0
- package/dist/core/presetUpdate.js.map +1 -0
- package/dist/core/presets.d.ts +33 -0
- package/dist/core/presets.js +3 -3
- package/dist/core/presets.js.map +1 -1
- package/dist/mcp/server.js +7 -1
- package/dist/mcp/server.js.map +1 -1
- package/package.json +4 -2
- package/presets/as-built/CHANGES.md +33 -0
- package/presets/as-built/CLAUDE-snippet.md +2 -1
- package/presets/as-built/history/0fe9dc4fc94d413f +71 -0
- package/presets/as-built/history/2eb353c13db7e5a7 +130 -0
- package/presets/as-built/history/32be1c85c4b2757d +124 -0
- package/presets/as-built/history/5a9ef521edb13aa1 +71 -0
- package/presets/as-built/history/6e0b36b4d353b6b6 +72 -0
- package/presets/as-built/history/87497464ab8cfa7d +72 -0
- package/presets/as-built/history/8a9e3845f322e51c +56 -0
- package/presets/as-built/history/8e8f6eebcb4b2a58 +24 -0
- package/presets/as-built/history/96497831c905de56 +25 -0
- package/presets/as-built/history/bd84de1dd9759c12 +65 -0
- package/presets/as-built/history/ed625ebd1209c061 +24 -0
- package/presets/as-built/history/f431a6fcf54a4906 +123 -0
- package/presets/as-built/history.json +60 -0
- package/presets/as-built/sync-docs-maps.mjs +6 -0
- package/presets/llm-wiki/CHANGES.md +8 -0
- package/presets/llm-wiki/history/44e1874c74476cd7 +57 -0
- package/presets/llm-wiki/history/59cf7b5051fce7e3 +93 -0
- package/presets/llm-wiki/history/b5f313af919c6236 +69 -0
- package/presets/llm-wiki/history.json +22 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Reference implementation (alkahest as-built preset) — mirror this repo's docs into the
|
|
3
|
+
// project's note maps:
|
|
4
|
+
// docs/decisions/NNN-*.md → note map `adr` (flat)
|
|
5
|
+
// docs/{system,components,features,modules}/*.md → note map `as-built` (folder = category)
|
|
6
|
+
//
|
|
7
|
+
// Staging transforms (the importer's rules: filename = title, frontmatter passes through):
|
|
8
|
+
// - title from the first H1 ("ADR-NNN: rest — tail" → "ADR-NNN rest"; as-built strips a
|
|
9
|
+
// "System|Component|Feature|Module — " class prefix and a " — " tail), sanitized;
|
|
10
|
+
// - the H1 line is dropped from the body (the note title renders it);
|
|
11
|
+
// - relative .md links WITHIN each set become [[wikilinks]] so the graph connects
|
|
12
|
+
// (cross-set links stay plain markdown);
|
|
13
|
+
// - the ORIGINAL repo path rides in as `source_path:` frontmatter — the staged filename
|
|
14
|
+
// is title-derived, so this is what keeps identity through a retitle (the importer
|
|
15
|
+
// matches source_path before title and renames the note in place).
|
|
16
|
+
//
|
|
17
|
+
// Re-running is safe: import is idempotent by source_path, then title.
|
|
18
|
+
// This script belongs to the repo it lives in — adapt titles/sets/maps to local conventions.
|
|
19
|
+
// Usage: node scripts/sync-docs-maps.mjs [--stage-only]
|
|
20
|
+
import { readdirSync, readFileSync, mkdirSync, writeFileSync, mkdtempSync } from "node:fs";
|
|
21
|
+
import { spawnSync } from "node:child_process";
|
|
22
|
+
import { join, dirname, basename } from "node:path";
|
|
23
|
+
import { fileURLToPath } from "node:url";
|
|
24
|
+
import { tmpdir } from "node:os";
|
|
25
|
+
|
|
26
|
+
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
27
|
+
const DOCS = join(ROOT, "docs");
|
|
28
|
+
// A fresh dir per run: a fixed shared path let another repo's copy of this script, running at the
|
|
29
|
+
// same time, restage its own docs under us, and our import pushed them into this project's maps.
|
|
30
|
+
const OUT = mkdtempSync(join(tmpdir(), "alkahest-docs-staging-"));
|
|
31
|
+
|
|
32
|
+
const sanitize = (t) =>
|
|
33
|
+
t.replace(/\(\//g, "(").replace(/[/\\:]/g, "-").replace(/`/g, "").replace(/\s+/g, " ").trim();
|
|
34
|
+
const firstH1 = (src) => (src.match(/^#\s+(.+)$/m) ?? [null, ""])[1].trim();
|
|
35
|
+
// Frontmatter rides through to the staged file — the importer strips it from the stored body
|
|
36
|
+
// and harvests its keys into note props (`tags:` is the reserved one). Split it off first so
|
|
37
|
+
// stripH1 still sees the H1 at the head of what's left.
|
|
38
|
+
const splitFm = (src) => {
|
|
39
|
+
const m = src.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n+/);
|
|
40
|
+
return m ? [m[0], src.slice(m[0].length)] : ["", src];
|
|
41
|
+
};
|
|
42
|
+
const stripH1 = (src) => {
|
|
43
|
+
const [fm, body] = splitFm(src);
|
|
44
|
+
return fm + body.replace(/^#\s+.+\n+/, "");
|
|
45
|
+
};
|
|
46
|
+
// Rename-safe identity: inject the ORIGINAL repo path as source_path: frontmatter (merged
|
|
47
|
+
// into an existing block, or a new block is minted).
|
|
48
|
+
const withSource = (staged, rel) => {
|
|
49
|
+
const [fm, body] = splitFm(staged);
|
|
50
|
+
const line = `source_path: ${rel}\n`;
|
|
51
|
+
return fm ? fm.replace(/---\r?\n*$/, (close) => line + close) + body : `---\n${line}---\n\n${staged}`;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// ---- ADRs ------------------------------------------------------------------
|
|
55
|
+
const adrDir = join(DOCS, "decisions");
|
|
56
|
+
const adrFiles = readdirSync(adrDir).filter((f) => /^\d{3}-.*\.md$/.test(f));
|
|
57
|
+
const adrTitle = {};
|
|
58
|
+
for (const f of adrFiles) {
|
|
59
|
+
const h1 = firstH1(readFileSync(join(adrDir, f), "utf8"));
|
|
60
|
+
// Convention "ADR-NNN: title — tail"; the em-dash variant "ADR-NNN — title" also parses.
|
|
61
|
+
const m = h1.match(/^ADR-(\d{3})(?::|\s+—)\s*(.+)$/);
|
|
62
|
+
const num = m ? m[1] : f.slice(0, 3);
|
|
63
|
+
adrTitle[num] = sanitize(`ADR-${num} ${(m ? m[2] : h1).split(" — ")[0].trim()}`);
|
|
64
|
+
}
|
|
65
|
+
const linkAdrs = (body) =>
|
|
66
|
+
body.replace(/\[([^\]]*)\]\((?:\.\/)?(\d{3})-[^)#\s]*\.md(?:#[^)]*)?\)/g, (all, _label, num) =>
|
|
67
|
+
adrTitle[num] ? `[[${adrTitle[num]}]]` : all);
|
|
68
|
+
mkdirSync(join(OUT, "adr"), { recursive: true });
|
|
69
|
+
for (const f of adrFiles) {
|
|
70
|
+
const t = adrTitle[f.slice(0, 3)];
|
|
71
|
+
const staged = linkAdrs(stripH1(readFileSync(join(adrDir, f), "utf8")));
|
|
72
|
+
writeFileSync(join(OUT, "adr", `${t}.md`), withSource(staged, `docs/decisions/${f}`));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ---- as-built --------------------------------------------------------------
|
|
76
|
+
const cats = ["system", "components", "features", "modules"];
|
|
77
|
+
const abTitle = {};
|
|
78
|
+
const abSrc = {};
|
|
79
|
+
for (const cat of cats) {
|
|
80
|
+
for (const f of readdirSync(join(DOCS, cat)).filter((x) => x.endsWith(".md"))) {
|
|
81
|
+
const src = readFileSync(join(DOCS, cat, f), "utf8");
|
|
82
|
+
let t = firstH1(src).replace(/^(System|Component|Feature|Module)\s*—\s*/i, "");
|
|
83
|
+
t = t.split(" — ")[0].trim() || firstH1(src);
|
|
84
|
+
abTitle[basename(f, ".md")] = sanitize(t);
|
|
85
|
+
abSrc[basename(f, ".md")] = { cat, src };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const linkAb = (body) =>
|
|
89
|
+
body.replace(/\[([^\]]*)\]\((?:\.\.\/(?:system|components|features|modules)\/|\.\/)?([a-z0-9-]+)\.md(?:#[^)]*)?\)/g,
|
|
90
|
+
(all, _label, name) => (abTitle[name] ? `[[${abTitle[name]}]]` : all));
|
|
91
|
+
for (const [name, { cat, src }] of Object.entries(abSrc)) {
|
|
92
|
+
mkdirSync(join(OUT, "as-built", cat), { recursive: true });
|
|
93
|
+
writeFileSync(join(OUT, "as-built", cat, `${abTitle[name]}.md`), withSource(linkAb(stripH1(src)), `docs/${cat}/${name}.md`));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
console.log(`staged ${adrFiles.length} ADRs + ${Object.keys(abSrc).length} as-built docs → ${OUT}`);
|
|
97
|
+
if (process.argv.includes("--stage-only")) process.exit(0);
|
|
98
|
+
|
|
99
|
+
// A full mirror is many sequential POSTs, so a transient failure is a question of when, not
|
|
100
|
+
// if. The CLI handles it per file (keeps going, prints `✗ <file>: <message>`, exits 1) — act
|
|
101
|
+
// on the exit code and retry the whole set: rows that already landed come back as updates.
|
|
102
|
+
const ATTEMPTS = 3;
|
|
103
|
+
const failed = [];
|
|
104
|
+
|
|
105
|
+
for (const [dir, map] of [["adr", "adr"], ["as-built", "as-built"]]) {
|
|
106
|
+
let ok = false;
|
|
107
|
+
for (let attempt = 1; attempt <= ATTEMPTS && !ok; attempt++) {
|
|
108
|
+
console.log(`\n== notes import ${dir} → map ${map}${attempt > 1 ? ` (retry ${attempt - 1})` : ""} ==`);
|
|
109
|
+
const run = spawnSync("alkahest", ["notes", "import", join(OUT, dir), "--map", map, "--path", ROOT], {
|
|
110
|
+
stdio: "inherit",
|
|
111
|
+
});
|
|
112
|
+
if (run.error) console.error(`[sync] could not run alkahest: ${run.error.message}`);
|
|
113
|
+
ok = !run.error && run.status === 0;
|
|
114
|
+
if (!ok && attempt < ATTEMPTS) Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 5000);
|
|
115
|
+
}
|
|
116
|
+
if (!ok) failed.push(`${dir} → ${map}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (failed.length) {
|
|
120
|
+
console.error(`\n[sync] FAILED after ${ATTEMPTS} attempts: ${failed.join(", ")}`);
|
|
121
|
+
console.error("[sync] scroll up for the per-file '✗ <file>: <message>' lines from the importer.");
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
console.log("\n[sync] both maps up to date.");
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# as-built-docs — writing instructions
|
|
2
|
+
|
|
3
|
+
You are maintaining this repository's **as-built documentation**: documents that record how
|
|
4
|
+
the system **is actually built**. Never plans, PRDs, or aspirations — present tense, code as
|
|
5
|
+
the source of truth.
|
|
6
|
+
|
|
7
|
+
## The four layers
|
|
8
|
+
|
|
9
|
+
Documents live under `docs/` in four folders, split by scope and viewpoint:
|
|
10
|
+
|
|
11
|
+
| Layer | Scope | Viewpoint | Answers |
|
|
12
|
+
|---|---|---|---|
|
|
13
|
+
| `system/` | whole app | architecture / data flow | "How is this app put together overall?" |
|
|
14
|
+
| `components/` | one UI area | what the user sees | "What is on this screen area, and what does each control do?" |
|
|
15
|
+
| `features/` | one behavior | time / user action | "When and under what conditions does this behavior run?" |
|
|
16
|
+
| `modules/` | one code layer | developer view | "What does this layer provide, and how is it separated from the rest?" |
|
|
17
|
+
|
|
18
|
+
Placement rule of thumb: what the user *sees* → `components/`; what *happens over time* →
|
|
19
|
+
`features/`; *code structure* → `modules/`; the picture that crosses all three → `system/`.
|
|
20
|
+
When a topic straddles two layers, pick one as the **main** document and leave a short
|
|
21
|
+
summary + link in the other.
|
|
22
|
+
|
|
23
|
+
## Document shape
|
|
24
|
+
|
|
25
|
+
Title each document with a **classed H1**: `# System — <name>`, `# Component — <name>`,
|
|
26
|
+
`# Feature — <name>`, `# Module — <name>`. The note-map mirror strips the class prefix,
|
|
27
|
+
so the hosted note is titled just `<name>` while the file stays unambiguous in the repo.
|
|
28
|
+
(ADRs have their own H1 shape — see the `adr` skill.)
|
|
29
|
+
|
|
30
|
+
## Bootstrap — when the repo has no docs yet
|
|
31
|
+
|
|
32
|
+
Do NOT try to document everything in one session. The first pass is deliberately small so
|
|
33
|
+
the user sees a map fast:
|
|
34
|
+
|
|
35
|
+
1. `docs/system/<app>.md` — one system map: layers, data flow, key dependencies, honest
|
|
36
|
+
Known Limitations.
|
|
37
|
+
2. Two or three `docs/modules/*.md` for the load-bearing modules only.
|
|
38
|
+
3. One decision record (see the `adr` skill): **ADR-001, an architecture snapshot** — the
|
|
39
|
+
decisions already embedded in the current code.
|
|
40
|
+
4. Add each document to the index in `docs/README.md`, then **mirror to the note maps and
|
|
41
|
+
hand the user the map link** (the mirroring rule lives in this repo's CLAUDE.md).
|
|
42
|
+
|
|
43
|
+
In the first pass, **prefer `modules/`** (plus the one `system/` map) when a topic could
|
|
44
|
+
fit several layers — grow `features/` and `components/` in later sessions, and leave their
|
|
45
|
+
index tables empty until they have documents.
|
|
46
|
+
|
|
47
|
+
Grow the rest incrementally: each later work session adds or updates only the documents its
|
|
48
|
+
code changes touch.
|
|
49
|
+
|
|
50
|
+
## Tone and rules
|
|
51
|
+
|
|
52
|
+
- **As-built, present tense** — "this is how it is built." Cite real file paths, function
|
|
53
|
+
names, and constants so readers can jump straight to code.
|
|
54
|
+
- **Decision history is a separate axis** — why / alternatives / trade-offs belong in ADRs
|
|
55
|
+
(`docs/decisions/`, see the `adr` skill), not in these documents.
|
|
56
|
+
- **Known Limitations, honestly** — the most valuable section of a post-hoc document.
|
|
57
|
+
Remove limitations you fixed; add the ones you introduced.
|
|
58
|
+
- **Overwrite freely** — these documents always describe the present. (ADRs are the
|
|
59
|
+
append-only record; never blend the two.)
|
|
60
|
+
- **Trust the code over connected tools** — an MCP server configured in your session
|
|
61
|
+
(a database MCP, for instance) may be bound to a *different* project than the repo you
|
|
62
|
+
are documenting. Verify the binding before citing anything from it, or read the schema
|
|
63
|
+
from the code instead.
|
|
64
|
+
|
|
65
|
+
## After every code change (checklist)
|
|
66
|
+
|
|
67
|
+
- [ ] Does the affected document still describe current behavior?
|
|
68
|
+
- [ ] Are its code citations (paths, names, constants) still valid?
|
|
69
|
+
- [ ] Known Limitations updated — fixed ones removed, new ones added?
|
|
70
|
+
- [ ] Cross-references from documents in other layers updated?
|
|
71
|
+
- [ ] `docs/README.md` index still accurate (add a row when adding a document)?
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# adr — decision records
|
|
2
|
+
|
|
3
|
+
ADRs (`docs/decisions/NNN-kebab-title.md`) record the **why** of decisions: context,
|
|
4
|
+
alternatives, trade-offs. They are a separate axis from as-built docs — as-built documents
|
|
5
|
+
are overwritten to stay current; ADRs are **append-only**, frozen at decision time.
|
|
6
|
+
|
|
7
|
+
## When to write one
|
|
8
|
+
|
|
9
|
+
One-line test: **if the code diff alone cannot reconstruct the "why", it deserves an ADR.**
|
|
10
|
+
|
|
11
|
+
Typical cases: data-model or structural changes; policy decisions and their reversals;
|
|
12
|
+
adopting an external dependency or license; fixing an ownership boundary ("this module is
|
|
13
|
+
the single owner of that transform"); behavior changes that trade something away; and
|
|
14
|
+
decisions deliberately **not** taken (record the reason and the revisit trigger).
|
|
15
|
+
|
|
16
|
+
Skip when: plain bug fixes, refactors, dependency bumps — anything self-evident from the
|
|
17
|
+
code and the as-built docs.
|
|
18
|
+
|
|
19
|
+
## Bootstrap — ADR-001
|
|
20
|
+
|
|
21
|
+
On a repo's first documentation pass, write **ADR-001 as an architecture snapshot**: the
|
|
22
|
+
decisions already embedded in the current code (framework, storage, module boundaries),
|
|
23
|
+
each with the alternatives it implicitly rejected. This seeds the habit of communicating
|
|
24
|
+
through decision records.
|
|
25
|
+
|
|
26
|
+
## Numbering & lifecycle
|
|
27
|
+
|
|
28
|
+
- `NNN` is zero-padded, sequential, never reused or renumbered.
|
|
29
|
+
- Never rewrite an accepted ADR. When a decision changes, write a **new** ADR that names
|
|
30
|
+
the old one in `Supersedes:`, and flip the old one's Status to `Superseded by …`
|
|
31
|
+
(keep the body — "why we did it that way once, then backed out" is the value).
|
|
32
|
+
|
|
33
|
+
## Tags (frontmatter)
|
|
34
|
+
|
|
35
|
+
Every ADR opens with a `tags:` frontmatter block. Keep the vocabulary small and stable:
|
|
36
|
+
one **surface** tag (the area of the product it touches) plus at most two **arc** tags
|
|
37
|
+
(a storyline several ADRs share). On the hosted `adr` note map each tag renders as a hub
|
|
38
|
+
node — keep every tag attached to roughly 3–12 ADRs so the map stays legible, and prefer
|
|
39
|
+
reusing an existing tag over inventing a new one.
|
|
40
|
+
|
|
41
|
+
**The vocabulary lives in `docs/decisions/README.md`'s tag table, and the repo owns it.**
|
|
42
|
+
On the bootstrap pass, seed it: derive 3–7 surface tags from the codebase's *actual* areas
|
|
43
|
+
(the folders/verticals you just documented), record them in the table, and tag ADR-001 from
|
|
44
|
+
that set. Afterwards, every ADR picks from the table; a genuinely new tag means adding its
|
|
45
|
+
row in the same commit. Arc tags are not invented up front — they emerge when several ADRs
|
|
46
|
+
turn out to share a storyline.
|
|
47
|
+
|
|
48
|
+
## Template
|
|
49
|
+
|
|
50
|
+
```markdown
|
|
51
|
+
---
|
|
52
|
+
tags: [<one surface tag>, <0-2 arc tags>]
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
# ADR-NNN: <one-line title>
|
|
56
|
+
|
|
57
|
+
* **Status**: Accepted (YYYY-MM-DD)
|
|
58
|
+
* **Date**: YYYY-MM-DD
|
|
59
|
+
* **Supersedes**: none | ADR-NNN (partial/full)
|
|
60
|
+
* **Related**: ADRs, as-built docs
|
|
61
|
+
|
|
62
|
+
***
|
|
63
|
+
|
|
64
|
+
## 1. Context
|
|
65
|
+
## 2. Decision
|
|
66
|
+
## 3. Trade-offs
|
|
67
|
+
## 4. Considered alternatives
|
|
68
|
+
## 5. Known limitations
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Keep *Trade-offs*, *Considered alternatives*, and *Known limitations* non-empty — they are
|
|
72
|
+
the point of the record. Cite code richly (files, functions, constants).
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# alkahest/adr — decision records
|
|
2
|
+
|
|
3
|
+
ADRs (`docs/decisions/NNN-kebab-title.md`) record the **why** of decisions: context,
|
|
4
|
+
alternatives, trade-offs. They are a separate axis from as-built docs — as-built documents
|
|
5
|
+
are overwritten to stay current; ADRs are **append-only**, frozen at decision time.
|
|
6
|
+
|
|
7
|
+
## When to write one
|
|
8
|
+
|
|
9
|
+
One-line test: **if the code diff alone cannot reconstruct the "why", it deserves an ADR.**
|
|
10
|
+
|
|
11
|
+
Typical cases: data-model or structural changes; policy decisions and their reversals;
|
|
12
|
+
adopting an external dependency or license; fixing an ownership boundary ("this module is
|
|
13
|
+
the single owner of that transform"); behavior changes that trade something away; and
|
|
14
|
+
decisions deliberately **not** taken (record the reason and the revisit trigger).
|
|
15
|
+
|
|
16
|
+
Skip when: plain bug fixes, refactors, dependency bumps — anything self-evident from the
|
|
17
|
+
code and the as-built docs.
|
|
18
|
+
|
|
19
|
+
## Bootstrap — ADR-001
|
|
20
|
+
|
|
21
|
+
On a repo's first documentation pass, write **ADR-001 as an architecture snapshot**: the
|
|
22
|
+
decisions already embedded in the current code (framework, storage, module boundaries),
|
|
23
|
+
each with the alternatives it implicitly rejected. This seeds the habit of communicating
|
|
24
|
+
through decision records.
|
|
25
|
+
|
|
26
|
+
## Numbering & lifecycle
|
|
27
|
+
|
|
28
|
+
- `NNN` is zero-padded, sequential, never reused or renumbered.
|
|
29
|
+
- Never rewrite an accepted ADR. When a decision changes, write a **new** ADR that names
|
|
30
|
+
the old one in `Supersedes:`, and flip the old one's Status to `Superseded by …`
|
|
31
|
+
(keep the body — "why we did it that way once, then backed out" is the value).
|
|
32
|
+
|
|
33
|
+
## Tags (frontmatter)
|
|
34
|
+
|
|
35
|
+
Every ADR opens with a `tags:` frontmatter block. Keep the vocabulary small and stable:
|
|
36
|
+
one **surface** tag (the area of the product it touches) plus at most two **arc** tags
|
|
37
|
+
(a storyline several ADRs share). On the hosted `adr` note map each tag renders as a hub
|
|
38
|
+
node — keep every tag attached to roughly 3–12 ADRs so the map stays legible, and prefer
|
|
39
|
+
reusing an existing tag over inventing a new one.
|
|
40
|
+
|
|
41
|
+
**The vocabulary lives in `docs/decisions/README.md`'s tag table, and the repo owns it.**
|
|
42
|
+
On the bootstrap pass, seed it: derive 3–7 surface tags from the codebase's *actual* areas
|
|
43
|
+
(the folders/verticals you just documented), record them in the table, and tag ADR-001 from
|
|
44
|
+
that set. Afterwards, every ADR picks from the table; a genuinely new tag means adding its
|
|
45
|
+
row in the same commit. Arc tags are not invented up front — they emerge when several ADRs
|
|
46
|
+
turn out to share a storyline.
|
|
47
|
+
|
|
48
|
+
## Template
|
|
49
|
+
|
|
50
|
+
```markdown
|
|
51
|
+
---
|
|
52
|
+
tags: [<one surface tag>, <0-2 arc tags>]
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
# ADR-NNN: <one-line title>
|
|
56
|
+
|
|
57
|
+
* **Status**: Accepted (YYYY-MM-DD)
|
|
58
|
+
* **Date**: YYYY-MM-DD
|
|
59
|
+
* **Supersedes**: none | ADR-NNN (partial/full)
|
|
60
|
+
* **Related**: ADRs, as-built docs
|
|
61
|
+
|
|
62
|
+
***
|
|
63
|
+
|
|
64
|
+
## 1. Context
|
|
65
|
+
## 2. Decision
|
|
66
|
+
## 3. Trade-offs
|
|
67
|
+
## 4. Considered alternatives
|
|
68
|
+
## 5. Known limitations
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Keep *Trade-offs*, *Considered alternatives*, and *Known limitations* non-empty — they are
|
|
72
|
+
the point of the record. Cite code richly (files, functions, constants).
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# as-built-docs — writing instructions
|
|
2
|
+
|
|
3
|
+
You are maintaining this repository's **as-built documentation**: documents that record how
|
|
4
|
+
the system **is actually built**. Never plans, PRDs, or aspirations — present tense, code as
|
|
5
|
+
the source of truth.
|
|
6
|
+
|
|
7
|
+
## The four layers
|
|
8
|
+
|
|
9
|
+
Documents live under `docs/` in four folders, split by scope and viewpoint:
|
|
10
|
+
|
|
11
|
+
| Layer | Scope | Viewpoint | Answers |
|
|
12
|
+
|---|---|---|---|
|
|
13
|
+
| `system/` | whole app | architecture / data flow | "How is this app put together overall?" |
|
|
14
|
+
| `components/` | one UI area | what the user sees | "What is on this screen area, and what does each control do?" |
|
|
15
|
+
| `features/` | one behavior | time / user action | "When and under what conditions does this behavior run?" |
|
|
16
|
+
| `modules/` | one code layer | developer view | "What does this layer provide, and how is it separated from the rest?" |
|
|
17
|
+
|
|
18
|
+
Placement rule of thumb: what the user *sees* → `components/`; what *happens over time* →
|
|
19
|
+
`features/`; *code structure* → `modules/`; the picture that crosses all three → `system/`.
|
|
20
|
+
When a topic straddles two layers, pick one as the **main** document and leave a short
|
|
21
|
+
summary + link in the other.
|
|
22
|
+
|
|
23
|
+
## Bootstrap — when the repo has no docs yet
|
|
24
|
+
|
|
25
|
+
Do NOT try to document everything in one session. The first pass is deliberately small so
|
|
26
|
+
the user sees a map fast:
|
|
27
|
+
|
|
28
|
+
1. `docs/system/<app>.md` — one system map: layers, data flow, key dependencies, honest
|
|
29
|
+
Known Limitations.
|
|
30
|
+
2. Two or three `docs/modules/*.md` for the load-bearing modules only.
|
|
31
|
+
3. One decision record (see the `adr` skill): **ADR-001, an architecture snapshot** — the
|
|
32
|
+
decisions already embedded in the current code.
|
|
33
|
+
4. Add each document to the index in `docs/README.md`, then **mirror to the note maps and
|
|
34
|
+
hand the user the map link** (the mirroring rule lives in this repo's CLAUDE.md).
|
|
35
|
+
|
|
36
|
+
Grow the rest incrementally: each later work session adds or updates only the documents its
|
|
37
|
+
code changes touch.
|
|
38
|
+
|
|
39
|
+
## Tone and rules
|
|
40
|
+
|
|
41
|
+
- **As-built, present tense** — "this is how it is built." Cite real file paths, function
|
|
42
|
+
names, and constants so readers can jump straight to code.
|
|
43
|
+
- **Decision history is a separate axis** — why / alternatives / trade-offs belong in ADRs
|
|
44
|
+
(`docs/decisions/`, see the `adr` skill), not in these documents.
|
|
45
|
+
- **Known Limitations, honestly** — the most valuable section of a post-hoc document.
|
|
46
|
+
Remove limitations you fixed; add the ones you introduced.
|
|
47
|
+
- **Overwrite freely** — these documents always describe the present. (ADRs are the
|
|
48
|
+
append-only record; never blend the two.)
|
|
49
|
+
|
|
50
|
+
## After every code change (checklist)
|
|
51
|
+
|
|
52
|
+
- [ ] Does the affected document still describe current behavior?
|
|
53
|
+
- [ ] Are its code citations (paths, names, constants) still valid?
|
|
54
|
+
- [ ] Known Limitations updated — fixed ones removed, new ones added?
|
|
55
|
+
- [ ] Cross-references from documents in other layers updated?
|
|
56
|
+
- [ ] `docs/README.md` index still accurate (add a row when adding a document)?
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<!-- alkahest as-built preset — installed by `alkahest docs init`. Owned by this repo: edit freely. -->
|
|
2
|
+
## Documentation — as-built docs + ADR
|
|
3
|
+
|
|
4
|
+
This repo keeps **as-built documentation** under `docs/` (four layers: system / components /
|
|
5
|
+
features / modules — see docs/README.md) and **ADRs** under `docs/decisions/`. The writing
|
|
6
|
+
instructions live in the account skills `as-built-docs` and `adr` — read them via the
|
|
7
|
+
alkahest MCP `skills` tool before writing docs.
|
|
8
|
+
|
|
9
|
+
1. **After finishing any code change, update the affected docs in the same session.**
|
|
10
|
+
The layer mapping and the update checklist are in the `as-built-docs` skill. Write an
|
|
11
|
+
ADR only for decisions whose "why" a code diff cannot reconstruct (criteria and the
|
|
12
|
+
template are in the `adr` skill).
|
|
13
|
+
2. **First documentation pass (repo has no docs yet)?** Follow the bootstrap protocol in
|
|
14
|
+
the `as-built-docs` skill: one system map + 2–3 core modules + ADR-001 (architecture
|
|
15
|
+
snapshot) — small first, then mirror and hand the user the note-map link. Grow the rest
|
|
16
|
+
incrementally with later work.
|
|
17
|
+
3. **After changing `docs/`, mirror it to the hosted note maps** by running
|
|
18
|
+
`node scripts/sync-docs-maps.mjs` (background recommended — one POST per document).
|
|
19
|
+
The script stages the docs (title from the first H1, H1 line stripped, intra-set
|
|
20
|
+
relative links → `[[wikilinks]]`, the original repo path injected as `source_path:`
|
|
21
|
+
frontmatter) and uploads with `alkahest notes import --map <adr|as-built>`. The import
|
|
22
|
+
is idempotent by source_path first, title second — re-runs and retitles update notes in
|
|
23
|
+
place. The script is a reference implementation and belongs to this repo: adapt it to
|
|
24
|
+
local conventions freely.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!-- alkahest as-built preset — installed by `alkahest preset install as-built`. Owned by this repo: edit freely; `alkahest preset update` merges later preset changes into your edits. -->
|
|
2
|
+
## Documentation — as-built docs + ADR
|
|
3
|
+
|
|
4
|
+
This repo keeps **as-built documentation** under `docs/` (four layers: system / components /
|
|
5
|
+
features / modules — see docs/README.md) and **ADRs** under `docs/decisions/`. The writing
|
|
6
|
+
instructions live in the account skills `alkahest/as-built-docs` and `alkahest/adr` — read them via the
|
|
7
|
+
alkahest MCP `skills` tool before writing docs.
|
|
8
|
+
|
|
9
|
+
1. **After finishing any code change, update the affected docs in the same session.**
|
|
10
|
+
The layer mapping and the update checklist are in the `alkahest/as-built-docs` skill. Write an
|
|
11
|
+
ADR only for decisions whose "why" a code diff cannot reconstruct (criteria and the
|
|
12
|
+
template are in the `alkahest/adr` skill).
|
|
13
|
+
2. **First documentation pass (repo has no docs yet)?** Follow the bootstrap protocol in
|
|
14
|
+
the `alkahest/as-built-docs` skill: one system map + 2–3 core modules + ADR-001 (architecture
|
|
15
|
+
snapshot) — small first, then mirror and hand the user the note-map link. Grow the rest
|
|
16
|
+
incrementally with later work.
|
|
17
|
+
3. **After changing `docs/`, mirror it to the hosted note maps** by running
|
|
18
|
+
`node scripts/sync-docs-maps.mjs` (background recommended — one POST per document).
|
|
19
|
+
The script stages the docs (title from the first H1, H1 line stripped, intra-set
|
|
20
|
+
relative links → `[[wikilinks]]`, the original repo path injected as `source_path:`
|
|
21
|
+
frontmatter) and uploads with `alkahest notes import --map <adr|as-built>`. The import
|
|
22
|
+
is idempotent by source_path first, title second — re-runs and retitles update notes in
|
|
23
|
+
place. The script is a reference implementation and belongs to this repo: adapt it to
|
|
24
|
+
local conventions freely.
|
|
25
|
+
<!-- /alkahest as-built preset -->
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# adr — decision records
|
|
2
|
+
|
|
3
|
+
ADRs (`docs/decisions/NNN-kebab-title.md`) record the **why** of decisions: context,
|
|
4
|
+
alternatives, trade-offs. They are a separate axis from as-built docs — as-built documents
|
|
5
|
+
are overwritten to stay current; ADRs are **append-only**, frozen at decision time.
|
|
6
|
+
|
|
7
|
+
## When to write one
|
|
8
|
+
|
|
9
|
+
One-line test: **if the code diff alone cannot reconstruct the "why", it deserves an ADR.**
|
|
10
|
+
|
|
11
|
+
Typical cases: data-model or structural changes; policy decisions and their reversals;
|
|
12
|
+
adopting an external dependency or license; fixing an ownership boundary ("this module is
|
|
13
|
+
the single owner of that transform"); behavior changes that trade something away; and
|
|
14
|
+
decisions deliberately **not** taken (record the reason and the revisit trigger).
|
|
15
|
+
|
|
16
|
+
Skip when: plain bug fixes, refactors, dependency bumps — anything self-evident from the
|
|
17
|
+
code and the as-built docs.
|
|
18
|
+
|
|
19
|
+
## Bootstrap — ADR-001
|
|
20
|
+
|
|
21
|
+
On a repo's first documentation pass, write **ADR-001 as an architecture snapshot**: the
|
|
22
|
+
decisions already embedded in the current code (framework, storage, module boundaries),
|
|
23
|
+
each with the alternatives it implicitly rejected. This seeds the habit of communicating
|
|
24
|
+
through decision records.
|
|
25
|
+
|
|
26
|
+
## Numbering & lifecycle
|
|
27
|
+
|
|
28
|
+
- `NNN` is zero-padded, sequential, never reused or renumbered.
|
|
29
|
+
- Never rewrite an accepted ADR. When a decision changes, write a **new** ADR that names
|
|
30
|
+
the old one in `Supersedes:`, and flip the old one's Status to `Superseded by …`
|
|
31
|
+
(keep the body — "why we did it that way once, then backed out" is the value).
|
|
32
|
+
|
|
33
|
+
## Tags (frontmatter)
|
|
34
|
+
|
|
35
|
+
Every ADR opens with a `tags:` frontmatter block. Keep the vocabulary small and stable:
|
|
36
|
+
one **surface** tag (the area of the product it touches) plus at most two **arc** tags
|
|
37
|
+
(a storyline several ADRs share). On the hosted `adr` note map each tag renders as a hub
|
|
38
|
+
node — keep every tag attached to roughly 3–12 ADRs so the map stays legible, and prefer
|
|
39
|
+
reusing an existing tag over inventing a new one.
|
|
40
|
+
|
|
41
|
+
## Template
|
|
42
|
+
|
|
43
|
+
```markdown
|
|
44
|
+
---
|
|
45
|
+
tags: [<one surface tag>, <0-2 arc tags>]
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
# ADR-NNN: <one-line title>
|
|
49
|
+
|
|
50
|
+
* **Status**: Accepted (YYYY-MM-DD)
|
|
51
|
+
* **Date**: YYYY-MM-DD
|
|
52
|
+
* **Supersedes**: none | ADR-NNN (partial/full)
|
|
53
|
+
* **Related**: ADRs, as-built docs
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
## 1. Context
|
|
58
|
+
## 2. Decision
|
|
59
|
+
## 3. Trade-offs
|
|
60
|
+
## 4. Considered alternatives
|
|
61
|
+
## 5. Known limitations
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Keep *Trade-offs*, *Considered alternatives*, and *Known limitations* non-empty — they are
|
|
65
|
+
the point of the record. Cite code richly (files, functions, constants).
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<!-- alkahest as-built preset — installed by `alkahest docs init`. Owned by this repo: edit freely. -->
|
|
2
|
+
## Documentation — as-built docs + ADR
|
|
3
|
+
|
|
4
|
+
This repo keeps **as-built documentation** under `docs/` (four layers: system / components /
|
|
5
|
+
features / modules — see docs/README.md) and **ADRs** under `docs/decisions/`. The writing
|
|
6
|
+
instructions live in the account skills `alkahest/as-built-docs` and `alkahest/adr` — read them via the
|
|
7
|
+
alkahest MCP `skills` tool before writing docs.
|
|
8
|
+
|
|
9
|
+
1. **After finishing any code change, update the affected docs in the same session.**
|
|
10
|
+
The layer mapping and the update checklist are in the `alkahest/as-built-docs` skill. Write an
|
|
11
|
+
ADR only for decisions whose "why" a code diff cannot reconstruct (criteria and the
|
|
12
|
+
template are in the `alkahest/adr` skill).
|
|
13
|
+
2. **First documentation pass (repo has no docs yet)?** Follow the bootstrap protocol in
|
|
14
|
+
the `alkahest/as-built-docs` skill: one system map + 2–3 core modules + ADR-001 (architecture
|
|
15
|
+
snapshot) — small first, then mirror and hand the user the note-map link. Grow the rest
|
|
16
|
+
incrementally with later work.
|
|
17
|
+
3. **After changing `docs/`, mirror it to the hosted note maps** by running
|
|
18
|
+
`node scripts/sync-docs-maps.mjs` (background recommended — one POST per document).
|
|
19
|
+
The script stages the docs (title from the first H1, H1 line stripped, intra-set
|
|
20
|
+
relative links → `[[wikilinks]]`, the original repo path injected as `source_path:`
|
|
21
|
+
frontmatter) and uploads with `alkahest notes import --map <adr|as-built>`. The import
|
|
22
|
+
is idempotent by source_path first, title second — re-runs and retitles update notes in
|
|
23
|
+
place. The script is a reference implementation and belongs to this repo: adapt it to
|
|
24
|
+
local conventions freely.
|