codealmanac 0.1.1 → 0.1.2
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/codealmanac.js +983 -391
- package/dist/codealmanac.js.map +1 -1
- package/guides/mini.md +187 -0
- package/guides/reference.md +599 -0
- package/package.json +2 -1
- package/prompts/bootstrap.md +55 -10
package/guides/mini.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# codealmanac — a wiki for this codebase, maintained for you
|
|
2
|
+
|
|
3
|
+
This repo has a `.almanac/` directory. It's a **living wiki** written for AI agents, documenting the things the code can't say: **why** it's shaped this way, **what was tried and failed**, **what must not be violated**, **how things flow end-to-end**, and **known gotchas** discovered through real debugging.
|
|
4
|
+
|
|
5
|
+
You are the primary reader. When the user asks you to do something, **check the wiki before you touch related code** — it will often answer the question the user didn't think to ask ("we tried that in March, here's why it broke").
|
|
6
|
+
|
|
7
|
+
You don't write the wiki during normal work. A separate agent ("capture") runs automatically at session end via a Claude Code hook, reads the session transcript, and writes or updates pages. Your job during the session is: **read, use, occasionally fix obvious errors.**
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## The mental model in 60 seconds
|
|
12
|
+
|
|
13
|
+
- **Pages** are markdown files in `.almanac/pages/` with YAML frontmatter. One page per stable concept: a technology we depend on (`supabase`), a multi-file flow (`checkout-flow`), a decision (`jwt-vs-sessions`), a gotcha (`stripe-webhook-deadlock`).
|
|
14
|
+
- **Topics** organize pages. They form a **DAG** — each page has multiple topics, each topic can have multiple parents. Topics live in `.almanac/topics.yaml`.
|
|
15
|
+
- **Links** use one syntax: `[[...]]`. The classifier looks at content:
|
|
16
|
+
- `[[checkout-flow]]` → page slug (no slash)
|
|
17
|
+
- `[[src/checkout/handler.ts]]` → file reference (has slash)
|
|
18
|
+
- `[[src/checkout/]]` → folder reference (trailing slash)
|
|
19
|
+
- `[[openalmanac:supabase]]` → cross-wiki reference (colon prefix)
|
|
20
|
+
- **Frontmatter carries `topics:` and `files:`.** The `files:` list is load-bearing: it's how `almanac search --mentions src/foo.ts` finds pages about `src/foo.ts` even when the path isn't in the prose.
|
|
21
|
+
- **The wiki evolves.** When facts change, existing pages get edited in place — git history is the archive. Fundamental reversals use a separate "archive" mechanism; you rarely need to worry about it.
|
|
22
|
+
|
|
23
|
+
Read `.almanac/README.md` at the start of any session where the wiki is likely to be relevant. It carries this repo's **notability bar** (what deserves a page here) and topic taxonomy.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## When to reach for it
|
|
28
|
+
|
|
29
|
+
**At the start of a task that touches real subsystems**, before you do anything else:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
almanac search --mentions src/checkout/handler.ts
|
|
33
|
+
almanac search --mentions src/checkout/
|
|
34
|
+
almanac search "checkout timeout"
|
|
35
|
+
almanac search --topic checkout
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The output is page slugs. Pick 1-3 that look relevant, `almanac show <slug>`, follow `[[wikilinks]]` the way you'd follow imports. Do this *before* grepping the codebase for unfamiliar behavior — the wiki tells you *why*, the code tells you *what*.
|
|
39
|
+
|
|
40
|
+
**Skip the wiki when**: the task is a pure typo fix, styling tweak, scoped refactor inside one file you already understand, or anything where the user's request is literally "read this file and tell me X."
|
|
41
|
+
|
|
42
|
+
**Trust the code over the wiki when they disagree.** Code is truth. If the wiki is wrong, fix the wiki — but don't propagate the wiki's error into code.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## The five commands you'll actually use
|
|
47
|
+
|
|
48
|
+
### 1. `almanac search` — the starting point
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
almanac search "<query>" # FTS
|
|
52
|
+
almanac search --mentions src/path/to/file.ts # pages referencing this file
|
|
53
|
+
almanac search --mentions src/path/to/folder/ # pages referencing anything in this folder
|
|
54
|
+
almanac search --topic auth # active pages in a topic
|
|
55
|
+
almanac search --topic auth --topic decisions # intersection
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Useful when you need them:
|
|
59
|
+
- `--since 2w` / `--stale 30d` — freshness filters
|
|
60
|
+
- `--orphan` — pages with no topics (usually a bug to fix)
|
|
61
|
+
- `--include-archive` — include historical pages when active wiki feels sparse
|
|
62
|
+
- `--limit N`, `--json` — output control
|
|
63
|
+
|
|
64
|
+
Returns slugs, one per line. Pipe-friendly. Filters AND-intersect.
|
|
65
|
+
|
|
66
|
+
### 2. `almanac show <slug>` — read a page
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
almanac show checkout-flow # metadata header + body (default)
|
|
70
|
+
almanac show checkout-flow --raw # body only
|
|
71
|
+
almanac show checkout-flow --meta # metadata only
|
|
72
|
+
almanac show checkout-flow --lead # first paragraph (cheap preview)
|
|
73
|
+
almanac show checkout-flow --backlinks # pages linking TO this one
|
|
74
|
+
almanac show checkout-flow --links # pages this links out to
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`--lead` to triage long result lists. `--backlinks` before editing a load-bearing page — you want to know who depends on its current shape.
|
|
78
|
+
|
|
79
|
+
### 3. `almanac topics` — understand structure
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
almanac topics # list all with page counts
|
|
83
|
+
almanac topics show auth # description, parents, children, pages
|
|
84
|
+
almanac topics show auth --descendants # walks the DAG subtree
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`--descendants` is the right call for "everything tagged auth or under it" — subtopics like `jwt`, `sessions`, `oauth` get walked automatically.
|
|
88
|
+
|
|
89
|
+
### 4. Read the file directly
|
|
90
|
+
|
|
91
|
+
`.almanac/pages/<slug>.md` is just markdown. The Read tool works fine. The CLI is faster when you want composed metadata; Read is fine for scanning prose or editing.
|
|
92
|
+
|
|
93
|
+
### 5. `almanac health` — when something feels off
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
almanac health # 8-category graph integrity report
|
|
97
|
+
almanac health --topic auth # scope
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Run when cleaning up the wiki, when the user reports broken links, or after you deleted/moved code and want to know which pages now reference dead files.
|
|
101
|
+
|
|
102
|
+
Categories: `orphans`, `stale` (90+ days), `dead-refs`, `broken-links`, `broken-xwiki`, `empty-topics`, `empty-pages`, `slug-collisions`.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Decisions you'll face
|
|
107
|
+
|
|
108
|
+
### "Search the wiki or just grep?"
|
|
109
|
+
Search when the task is named: subsystem (checkout, auth, search), external service (Stripe, Supabase), cross-cutting concern (caching, sessions). Grep for mechanical tasks.
|
|
110
|
+
|
|
111
|
+
### "The wiki says X. The code does Y. Which is right?"
|
|
112
|
+
The code. Then fix the wiki — small fixes edit the page directly. Substantial changes: mention clearly in your response so capture has context to update at session end.
|
|
113
|
+
|
|
114
|
+
### "Should I create a new page mid-session?"
|
|
115
|
+
Usually no. Capture writes pages from the session transcript with full context. Exceptions: user explicitly asks, or you're doing deliberate wiki maintenance.
|
|
116
|
+
|
|
117
|
+
When you do write: read `.almanac/README.md` for the notability bar, use `[[...]]` syntax, include `files:` frontmatter, keep every sentence factual, no speculation.
|
|
118
|
+
|
|
119
|
+
### "New topic or existing?"
|
|
120
|
+
Almost always existing. Skim `almanac topics` before creating. New topic is justified when multiple pages share a concept no current topic captures.
|
|
121
|
+
|
|
122
|
+
### "Can I just `almanac tag`?"
|
|
123
|
+
Yes — safe, idempotent, preserves body bytes. Use `almanac tag` / `untag` rather than hand-editing frontmatter.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## A concrete example
|
|
128
|
+
|
|
129
|
+
User: *"fix the checkout timeout bug."*
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# 1. Find relevant pages
|
|
133
|
+
$ almanac search --mentions src/checkout/
|
|
134
|
+
checkout-flow
|
|
135
|
+
inventory-lock-gotcha
|
|
136
|
+
stripe-async-migration
|
|
137
|
+
|
|
138
|
+
# 2. Triage with --lead
|
|
139
|
+
$ almanac show checkout-flow --lead
|
|
140
|
+
$ almanac show inventory-lock-gotcha --lead
|
|
141
|
+
|
|
142
|
+
# 3. Read the most relevant
|
|
143
|
+
$ almanac show inventory-lock-gotcha
|
|
144
|
+
# ...points to [[stripe-deadlock]], show that too
|
|
145
|
+
|
|
146
|
+
# 4. Before editing, check backlinks
|
|
147
|
+
$ almanac show checkout-flow --backlinks
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
You now know: there was a deadlock between webhooks and the inventory lock, the team moved to async Stripe in April, two other pages link to `checkout-flow` so your edits matter beyond this file.
|
|
151
|
+
|
|
152
|
+
You don't write anything. At session end the capture agent reads the transcript, sees your discovery, writes or updates pages. Next session, a different agent running a related task sees it surface in `--mentions`.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## What runs automatically (don't invoke these)
|
|
157
|
+
|
|
158
|
+
- **`almanac capture`** — runs in the background after every Claude Code session via the `SessionEnd` hook.
|
|
159
|
+
- **`almanac reindex`** — runs implicitly before every query when pages changed.
|
|
160
|
+
- **`almanac bootstrap`** — one-shot scaffolding. You almost certainly don't run this.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Cross-wiki references
|
|
165
|
+
|
|
166
|
+
If the user has multiple repos with `.almanac/`, they're globally registered. Pages can reference other wikis with `[[wiki-name:slug]]`. `--wiki <name>` or `--all` span registered wikis. You rarely need this mid-session.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Writing conventions (if you do write)
|
|
171
|
+
|
|
172
|
+
- **Every sentence contains a specific fact.** If the sentence could describe any codebase, cut it.
|
|
173
|
+
- **Neutral tone.** "is", not "serves as". No promotional language, no "plays a pivotal role", no interpretive "-ing" clauses.
|
|
174
|
+
- **No speculation.** If you don't know why, don't guess in prose.
|
|
175
|
+
- **Prose first.** Bullets for genuine lists. Tables for structured comparison only.
|
|
176
|
+
- **Reference code with `[[...]]`.** Inline mentions are fine but only `[[...]]` gets indexed.
|
|
177
|
+
- **List files in frontmatter.** Pages about specific code need `files: [...]` to surface in `--mentions` queries.
|
|
178
|
+
|
|
179
|
+
The reviewer subagent (run by capture at session end) enforces these. Stricter with yourself = less rework.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## When in doubt
|
|
184
|
+
|
|
185
|
+
- `.almanac/README.md` — repo-specific conventions + notability bar
|
|
186
|
+
- `@~/.claude/codealmanac-reference.md` — full command reference with every flag
|
|
187
|
+
- `almanac --help`, `almanac <command> --help` — built-in
|