codealmanac 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rohan Sheth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,195 @@
1
+ # codealmanac
2
+
3
+ codealmanac maintains a `.almanac/` folder in your repo that AI coding agents populate with decisions, gotchas, flows, and invariants — the context the code itself can't tell you. Pages are atomic markdown files, interlinked by `[[wikilinks]]`, indexed in SQLite, and written by a writer/reviewer agent pair that runs at session end.
4
+
5
+ The primary consumer is the AI coding agent. The secondary consumer is humans.
6
+
7
+ ## Why
8
+
9
+ Claude Code, Cursor, and Copilot can read the code and tell you what it does. They can't tell you why it's shaped that way, what approaches were tried and rejected, what invariants must not be violated, or how a flow spans four files in three services. That knowledge lives in Slack threads, PR descriptions, and people's heads. It dies when threads scroll, people leave, or an agent starts a fresh session.
10
+
11
+ A single `CLAUDE.md` at the repo root doesn't scale past a few hundred lines, has no graph structure, and gets stale the moment anyone commits without editing it. codealmanac replaces that one flat file with a wiki of atomic pages that agents are prompted to keep current as a side-effect of coding.
12
+
13
+ ## How it works
14
+
15
+ Each repo gets a committed `.almanac/pages/` directory of markdown files. A SessionEnd hook fires when a Claude Code session ends and runs `almanac capture` in the background. A writer agent reads the session transcript and existing pages, drafts changes, and invokes a reviewer subagent that critiques against the wider graph. The writer applies the final versions. New and updated pages show up in your next `git status`; you review them like any other commit.
16
+
17
+ The CLI never reads or writes page content except in `capture` and `bootstrap`. Every other command (`search`, `show`, `info`, `topics`, `tag`, `health`) operates on a SQLite index that rebuilds silently whenever pages are newer than the index.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ npm install -g codealmanac
23
+ # or for one-off use:
24
+ npx codealmanac --help
25
+ ```
26
+
27
+ Installs two binaries pointing at the same entry: `codealmanac` (canonical) and `almanac` (alias). Requires Node 20 or 22.
28
+
29
+ `bootstrap` and `capture` invoke Claude via the bundled Claude Agent SDK. The query commands (`search`, `show`, `info`, `health`, `topics`) need no credentials at all.
30
+
31
+ ## Authentication
32
+
33
+ Pick one — `bootstrap` and `capture` accept either:
34
+
35
+ ```bash
36
+ # Option A — your Claude subscription (Pro/Max). Preferred if you already
37
+ # use Claude Code; no separate bill, no copy-pasted keys.
38
+ claude auth login --claudeai
39
+
40
+ # Option B — a pay-per-token API key from https://console.anthropic.com.
41
+ export ANTHROPIC_API_KEY=sk-ant-...
42
+
43
+ # Either way, verify with:
44
+ claude auth status
45
+ ```
46
+
47
+ codealmanac itself never sees your credentials — auth is handled by the bundled Claude Agent SDK CLI, which reads the same `~/.claude/credentials/` store Claude Code uses.
48
+
49
+ ## Quickstart
50
+
51
+ ```bash
52
+ cd your-repo
53
+
54
+ almanac init
55
+ # scaffolds .almanac/pages/ and .almanac/README.md, registers the wiki
56
+ # in ~/.almanac/registry.json, adds .almanac/index.db to .gitignore
57
+
58
+ almanac bootstrap
59
+ # spawns an agent that reads package.json, docker-compose.yml, the
60
+ # top-level layout, and writes stub entity pages + a topic DAG
61
+
62
+ almanac search "auth"
63
+ # full-text search across pages; prints slugs one per line
64
+
65
+ almanac hook install
66
+ # adds the SessionEnd entry to ~/.claude/settings.json so capture
67
+ # runs at the end of every Claude Code session
68
+
69
+ # from here on, just code as usual — capture runs itself
70
+ ```
71
+
72
+ ## Command reference
73
+
74
+ | Command | What it does |
75
+ |---------|--------------|
76
+ | `almanac init` | Scaffold `.almanac/` and register the wiki globally |
77
+ | `almanac list` | List every registered wiki (`--drop <name>` to remove) |
78
+ | `almanac bootstrap` | Agent reads the repo and seeds stub entity pages + topic DAG |
79
+ | `almanac search [query]` | FTS, `--topic`, `--mentions <path>`, `--since`, `--stale`, `--orphan` |
80
+ | `almanac show <slug>` | Print a page's markdown to stdout |
81
+ | `almanac path <slug>` | Resolve a slug to its absolute file path |
82
+ | `almanac info <slug>` | Topics, file refs, wikilinks, lineage for a page |
83
+ | `almanac topics` | List, create, link, rename, delete topics in the DAG |
84
+ | `almanac tag <page> <topic>...` | Add topics to a page |
85
+ | `almanac untag <page> <topic>` | Remove a topic |
86
+ | `almanac health` | Orphans, stale pages, dead refs, broken links, slug collisions |
87
+ | `almanac capture [transcript]` | Writer + reviewer on a Claude Code session transcript |
88
+ | `almanac hook install\|uninstall\|status` | Manage the SessionEnd hook in `~/.claude/settings.json` |
89
+ | `almanac reindex` | Force rebuild of `.almanac/index.db` |
90
+
91
+ Every command that returns pages prints slugs one per line; pass `--json` for structured output; pipe slugs into commands that accept `--stdin`. Run `almanac <command> --help` for the full flag surface.
92
+
93
+ ## Concepts
94
+
95
+ ### Page shapes (suggestions, not rules)
96
+
97
+ The wiki tends to organize around four kinds of pages, but nothing in the system enforces them:
98
+
99
+ - **Entity pages** — stable named things (Supabase, Stripe, a custom auth system). These are the anchors other pages link to.
100
+ - **Decision pages** — why X over Y, with context and consequences.
101
+ - **Flow pages** — how a multi-file process works end-to-end.
102
+ - **Gotcha pages** — specific failures or constraints, usually anchored to an entity.
103
+
104
+ A page that doesn't fit any of these is fine. Pick the shape that serves the knowledge.
105
+
106
+ ### Topics as a DAG
107
+
108
+ One organizational axis: topics. Topics form a directed acyclic graph — a topic can have multiple parents, and a page can belong to multiple topics. No page type system.
109
+
110
+ ```
111
+ decisions stack flows
112
+ └─ database
113
+ └─ supabase ← a page tagged [stack, database]
114
+ ```
115
+
116
+ `almanac topics show database --descendants` walks the subgraph and returns every page in `database` or `supabase`. Cycles are prevented by a `CHECK` constraint and a depth cap.
117
+
118
+ ### The unified `[[...]]` link syntax
119
+
120
+ One link form, disambiguated by content:
121
+
122
+ ```markdown
123
+ See [[checkout-flow]] for the full sequence. ← page slug (no slash)
124
+ The handler [[src/checkout/handler.ts]] does X. ← file (has slash)
125
+ This spans [[src/checkout/]] generally. ← folder (trailing slash)
126
+ See [[openalmanac:supabase]] for cross-wiki context. ← cross-wiki (colon prefix)
127
+ ```
128
+
129
+ The indexer classifies each link by those rules and writes it to `wikilinks`, `file_refs`, or `cross_wiki_links`. `almanac search --mentions src/checkout/handler.ts` returns every page referencing that file or any folder containing it.
130
+
131
+ ### Archive vs edit
132
+
133
+ Most changes are edits — the page is updated in place to reflect current truth, with git history as the archive. When a page's central decision is reversed (not just refined), the old page is marked `archived_at` and `superseded_by`, a new page is created with `supersedes`, and both live side by side. Archived pages are excluded from `almanac search` by default and exempt from dead-ref health checks.
134
+
135
+ ### The notability bar
136
+
137
+ Every repo's `.almanac/README.md` contains a notability bar: the threshold for what deserves a page. The default is "non-obvious knowledge that will help a future agent" — decisions that took research, gotchas discovered through failure, cross-cutting flows, constraints not visible in code. The writer consults the bar before writing; the reviewer enforces it. Edit the bar to match your repo's taste.
138
+
139
+ ## How capture works
140
+
141
+ A page looks like this:
142
+
143
+ ```markdown
144
+ ---
145
+ title: Supabase
146
+ topics: [stack, database]
147
+ files:
148
+ - src/lib/supabase.ts
149
+ - backend/src/models/
150
+ ---
151
+
152
+ # Supabase
153
+
154
+ PostgreSQL hosted on Supabase. Connection pooling via Supavisor.
155
+
156
+ ## Gotchas
157
+ - Supavisor has a 30s idle timeout — long transactions get killed ([[supavisor-timeout]]).
158
+ - UUIDs as primary keys, not `serial` ([[uuid-decision]]).
159
+ ```
160
+
161
+ When a Claude Code session ends, the SessionEnd hook backgrounds `almanac capture <transcript>`. The writer agent reads the transcript, runs `almanac search` and `almanac show` against the existing wiki, drafts changes to pages under `.almanac/pages/`, and invokes the reviewer subagent. The reviewer reads across the graph, flags duplicates, missing wikilinks, missing topics, inference dressed as fact, and cohesion problems, then returns a text critique. The writer decides what to incorporate and writes the final versions. Capture writes nothing if nothing in the session meets the notability bar — silence is a valid outcome.
162
+
163
+ No proposal files, no `--apply` step, no state machine between writer and reviewer. The changes land in `git status` and you commit them like anything else.
164
+
165
+ ## Multi-wiki
166
+
167
+ Each repo has its own sovereign `.almanac/`. The global registry at `~/.almanac/registry.json` tracks every wiki on the machine.
168
+
169
+ ```bash
170
+ almanac list # all registered wikis
171
+ almanac search --wiki openalmanac "RLS" # specific wiki
172
+ almanac search --all "RLS" # every registered wiki
173
+ ```
174
+
175
+ Cross-wiki references use a colon prefix: `[[openalmanac:supabase]]`. The segment before `:` resolves via the registry; unreachable wikis are silently skipped rather than erroring. Cloning a repo with a committed `.almanac/` auto-registers it on the first `almanac` command.
176
+
177
+ ## Writing conventions
178
+
179
+ Pages are neutral-tone encyclopedia-style prose — every sentence contains a specific fact, no significance inflation, no hedging, no formulaic conclusions. Prose first, bullets for genuine lists, tables only for structured comparison. The conventions are described in each repo's `.almanac/README.md` (generated by `init` and refined by `bootstrap`); the reviewer loads them at runtime and enforces them on every proposal.
180
+
181
+ ## Status
182
+
183
+ `v0.1.0`, pre-release. Node 20.x or 22.x. Release process is documented in [RELEASE.md](./RELEASE.md). Breaking changes are possible before 1.0; they will be called out in release notes.
184
+
185
+ ## Philosophy
186
+
187
+ Intelligence lives in the prompt, not in the pipeline. Whenever a task calls for judgment — deciding what from a session is worth capturing, evaluating a proposal against the graph, picking between editing and archiving — codealmanac hands a concrete-but-open prompt to an agent. It does not wrap agents in propose/review/apply state machines, intermediate proposal files, or `--dry-run` rehearsal flags. The CLI finds and organizes; the agents do the thinking. If a future change can be expressed as a longer prompt or as more pipeline code, the prompt almost always wins.
188
+
189
+ ## Related
190
+
191
+ codealmanac is part of the [OpenAlmanac](https://www.openalmanac.org) family. OpenAlmanac is a knowledge base for curious people; codealmanac is knowledge for codebases. Same writing standards, different reader.
192
+
193
+ ## License
194
+
195
+ MIT. Copyright (c) 2026 Rohan Sheth. See [LICENSE](./LICENSE).