repo-cortex 0.0.0-stage → 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,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alan B Smith
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,122 @@
1
- # Temporary Holding Version
1
+ # repo-cortex
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A **cortex** is a small `cortex/` folder of plain Markdown in a repository that holds the why behind the project: decisions and their reasons, open questions, why each milestone exists, and where things stand now. A fresh agent session or a new teammate reads it on demand, when planning or asking why, and starts work without being re-briefed.
4
+
5
+ repo-cortex helps you build one. It's for repository maintainers, for new maintainers and contributors, and for any agent that reads skills.
6
+
7
+ **Status:** early. What's on npm is a bootstrap build, `0.1.0-bootstrap.0`, not the 0.1.0 release. The release is part of the [Publish package prep milestone](https://github.com/alanbsmith/repo-cortex/milestone/2).
8
+
9
+ ## Why a cortex
10
+
11
+ The code and the tracker say what and when. They rarely say why. The cortex is where the why goes, and it's kept honest by a few rules:
12
+
13
+ - **Reasons, never statuses.** Statuses live in the tracker. The cortex reads them live and never copies them, so it can't go stale that way.
14
+ - **One home per question.** The cortex's README maps each question a planning session asks to the one place that answers it.
15
+ - **Decisions are never edited.** A change of mind is a new decision that supersedes the old one, so the history of why stays trustworthy.
16
+ - **Never invent a reason.** If nobody knows why, the decision says so.
17
+
18
+ ## What's in the package
19
+
20
+ - **The `repo-cortex` CLI** does what's the same in every repo: scaffold, check, start a decision, list summaries.
21
+ - **The `build-cortex` skill** does what's different in every repo: it surveys the repo, interviews the owner, writes the decisions and the map of where things live, wires the cortex into CLAUDE.md or AGENTS.md and CI, and tests it with a cold read.
22
+
23
+ ## Quick start
24
+
25
+ With the npm build, you need Node.js 24 or later. Run its commands from the root of the repo you want a cortex in.
26
+
27
+ ### With an agent
28
+
29
+ With Claude Code, install the skill into your repo:
30
+
31
+ ```bash
32
+ npx repo-cortex skill
33
+ ```
34
+
35
+ The skill goes into `.claude/skills/`. Use `--global` to install it into `~/.claude/skills/` instead. For another agent that reads skills, copy the installed `build-cortex` folder to where it looks for them.
36
+
37
+ The installed skill calls `npx repo-cortex@0.1`, not bare `npx repo-cortex`, with the range of the version that installed it, so a later release with different commands can't break it. The commands in the files `init` writes and in the `snippet` paragraph are pinned the same way. To update an installed skill, run `npx repo-cortex@latest skill --force`. A prerelease pins its exact version.
38
+
39
+ Then start a session in your repo and ask:
40
+
41
+ > Build a cortex for this repo.
42
+
43
+ ### By hand
44
+
45
+ ```bash
46
+ npx repo-cortex init --public --milestones
47
+ npx repo-cortex snippet
48
+ npx repo-cortex decision "Use pnpm over npm" --status accepted --decided-by owner
49
+ npx repo-cortex check
50
+ ```
51
+
52
+ 1. `init` scaffolds `cortex/` with `TODO(cortex)` markers. Use `--private` for a private repo, and leave out `--milestones` if you don't work in milestones.
53
+ 2. `snippet` prints the paragraph to add to your CLAUDE.md or AGENTS.md.
54
+ 3. `decision` starts a decision. Replace the example title with a choice you made.
55
+ 4. `check` warns about each marker until you fill it in. Run it again until it's clean, then add it to CI.
56
+
57
+ ### From a clone
58
+
59
+ To run the latest source instead of the npm build, you need Node.js 26 and pnpm ([CONTRIBUTING.md](CONTRIBUTING.md#setup) has the details). Clone repo-cortex next to your repo, then run the same commands as `pnpm cortex <command>`, with `-C` pointing at your repo. Start in the folder that holds your repo:
60
+
61
+ ```bash
62
+ git clone https://github.com/alanbsmith/repo-cortex
63
+ cd repo-cortex
64
+ pnpm install
65
+ pnpm cortex init -C ../your-repo --public --milestones
66
+ pnpm cortex check -C ../your-repo
67
+ ```
68
+
69
+ ## What a cortex looks like
70
+
71
+ ```text
72
+ cortex/
73
+ README.md start here: where everything lives, live-status commands, the rules
74
+ now.md the current focus and why it's the focus
75
+ open-questions.md undecided and deferred questions, each with what would reopen it
76
+ glossary.md the project's own jargon
77
+ decisions/
78
+ 0001-keep-a-cortex.md
79
+ 0002-....md one choice each: Decision, Why, Weighed, Consequences
80
+ milestones/ optional: why each active milestone exists, and its log
81
+ related-projects.md optional: neighbors, and what's private
82
+ ```
83
+
84
+ Every file starts with front matter: a one-line `summary:` so a session can choose a file without opening it, and an `updated:` date. Decisions add `status:` (`proposed`, `accepted`, `superseded`, `rejected`), `date:`, `decided-by:` and, where they apply, `supersedes:` and `superseded-by:`.
85
+
86
+ ## Commands
87
+
88
+ Run each as `npx repo-cortex <command>`. `npx repo-cortex --help` lists every option.
89
+
90
+ | Command | Does |
91
+ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
92
+ | `init` | Scaffold a cortex from the templates. Never overwrites without `--force`. |
93
+ | `check` | Check front matter, links, paths, the index, decisions and staleness. Exits 1 on errors; `--strict` on warnings too, except the ones marked `(info)`. |
94
+ | `decision "<title>"` | Start a decision with the next number. With `--supersedes <n> --status accepted` it also marks the old one superseded. |
95
+ | `list` | Print every file's summary and each decision's status. `--decisions`, `--status <s>`, `--json`. |
96
+ | `snippet` | Print the paragraph to add to CLAUDE.md or AGENTS.md. |
97
+ | `skill` | Install the `build-cortex` skill into `.claude/skills/` (or `~/.claude/skills/` with `--global`). |
98
+
99
+ Every command takes `--dir <folder>` (default: `$CORTEX_DIR`, else `cortex`) and `-C <repo>`.
100
+
101
+ ### What `check` checks
102
+
103
+ Errors: missing `README.md`, `now.md`, `open-questions.md` or `decisions/`; missing or malformed front matter, including a date that isn't a real date; a link, anchor or backticked repo path in a living file that goes nowhere; a file the README doesn't link; a decision's bad file name, duplicate number, unknown status, or supersession that doesn't point both ways.
104
+
105
+ Warnings: a decision's text changed since `main`; a decision on `main` that was deleted or renamed; a `proposed` decision already on `main`; a new decision with no `decided-by:`; a decision without a numbered title, **Decision:** or **Why:**; an `updated:` date in the future; `now.md` more than 21 days older than the last commit; an open question with no "Reopen when"; a milestone file missing Why / Why now / Done when / Log, unless it sets `layout: free`; a leftover `TODO(cortex)`.
106
+
107
+ Some warnings are marked `(info)`, and `--strict` never fails on them, because the rules forbid the fix or the change may be fine: a stale link or path in a decision (its text never changes), a small edit to a merged decision (a typo fix is allowed), shape warnings on a merged decision, and a missing `origin/main` to compare with (in CI, check out with `fetch-depth: 0`).
108
+
109
+ Exit codes: 0 ok, 1 the check failed, 2 a usage error, 70 a bug in repo-cortex.
110
+
111
+ It checks shape and freshness, not truth. A repo with its own docs drift check should add the cortex to it for repo-specific checks such as commands and flags.
112
+
113
+ ## Project links
114
+
115
+ - **Vision:** [what we're building and why](https://github.com/alanbsmith/repo-cortex/discussions/26), a pinned discussion. Check a plan or a pull request against it.
116
+ - **Contributing:** [CONTRIBUTING.md](CONTRIBUTING.md) says how to set up, change and submit work, and how the project is run.
117
+ - **Reasons:** [cortex/](cortex/README.md) is this project's own cortex.
118
+ - **Security:** please report a vulnerability privately, not in a public issue. [SECURITY.md](SECURITY.md) says how.
119
+
120
+ ## License
121
+
122
+ [MIT](LICENSE)
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ // In a checkout (src/ exists) this runs the TypeScript sources, which Node runs by stripping types, so a
3
+ // stale dist/ is never used while developing. The published package ships dist/ and not src/, so an
4
+ // installed repo-cortex runs the compiled CLI.
5
+ import { existsSync } from "node:fs";
6
+
7
+ const sources = new URL("../src/cli.ts", import.meta.url);
8
+ const { main, UsageError } = await import(
9
+ existsSync(sources)
10
+ ? sources.href
11
+ : new URL("../dist/cli.js", import.meta.url).href
12
+ );
13
+
14
+ try {
15
+ process.exitCode = main(process.argv.slice(2));
16
+ } catch (err) {
17
+ if (err instanceof UsageError) {
18
+ // The person's mistake: the message says what to do.
19
+ console.error(`repo-cortex: ${err.message}`);
20
+ process.exitCode = 2;
21
+ } else {
22
+ // A bug: show the stack so it can be reported.
23
+ console.error("repo-cortex: unexpected error. Please report it.");
24
+ console.error(err);
25
+ process.exitCode = 70;
26
+ }
27
+ }