the-grimoire-cli 0.3.2 → 0.4.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.
Files changed (95) hide show
  1. package/.agents/AGENTS.md +112 -112
  2. package/.agents/NAVIGATOR.md +188 -168
  3. package/.agents/VERSION +4 -4
  4. package/.agents/agents/INDEX.md +7 -7
  5. package/.agents/agents/verifier.md +50 -50
  6. package/.agents/commands/INDEX.md +11 -11
  7. package/.agents/commands/checkpoint.md +15 -15
  8. package/.agents/commands/grimoire.md +14 -14
  9. package/.agents/commands/onboard.md +56 -56
  10. package/.agents/commands/present.md +23 -23
  11. package/.agents/commands/verify.md +20 -20
  12. package/.agents/grimoire.manifest +18 -18
  13. package/.agents/rules/00-always.md +42 -42
  14. package/.agents/rules/05-code-quality.md +28 -28
  15. package/.agents/rules/10-working-process.md +31 -31
  16. package/.agents/rules/15-skills.md +27 -27
  17. package/.agents/rules/20-modes.md +41 -41
  18. package/.agents/rules/25-surgical-changes.md +29 -29
  19. package/.agents/rules/30-verification.md +36 -36
  20. package/.agents/rules/35-context-economy.md +41 -41
  21. package/.agents/rules/40-handoff.md +25 -25
  22. package/.agents/rules/45-presentation.md +35 -35
  23. package/.agents/rules/50-security.md +30 -30
  24. package/.agents/rules/60-commit-style.md +14 -14
  25. package/.agents/rules/INDEX.md +18 -18
  26. package/.agents/skills/INDEX.md +8 -8
  27. package/.agents/skills/README.md +1 -1
  28. package/.agents/skills/catalog.md +106 -106
  29. package/.agents/skills/find-skills/SKILL.md +142 -142
  30. package/.agents/stack/README.md +69 -66
  31. package/.agents/stack/desktop.md +36 -36
  32. package/.agents/stack/library.md +1 -1
  33. package/.agents/stack/web-app.md +32 -32
  34. package/.agents/standards/INDEX.md +23 -23
  35. package/.agents/standards/accessibility.md +50 -50
  36. package/.agents/standards/architecture.md +39 -39
  37. package/.agents/standards/attribution.md +39 -39
  38. package/.agents/standards/clean-code.md +121 -121
  39. package/.agents/standards/codex.md +69 -69
  40. package/.agents/standards/error-codes.md +41 -41
  41. package/.agents/standards/general.md +46 -46
  42. package/.agents/standards/guardrail-tests.md +40 -40
  43. package/.agents/standards/knowledge-management.md +35 -35
  44. package/.agents/standards/launch-security-checklist.md +45 -45
  45. package/.agents/standards/observability.md +35 -35
  46. package/.agents/standards/release-versioning.md +53 -53
  47. package/.agents/standards/requirements.md +75 -75
  48. package/.agents/standards/security-scanners.md +42 -42
  49. package/.agents/standards/testing-strategy.md +61 -61
  50. package/.agents/standards/typescript.md +19 -19
  51. package/.agents/standards/writing.md +58 -58
  52. package/.agents/tooling.json +19 -19
  53. package/LICENSE +1 -1
  54. package/README.md +139 -139
  55. package/bin/grimoire.mjs +630 -598
  56. package/package.json +32 -32
  57. package/templates/CLAUDE.md +7 -7
  58. package/templates/ci/ci.yml +49 -49
  59. package/templates/ci/sast.yml +44 -44
  60. package/templates/codex/INDEX.md +18 -18
  61. package/templates/codex/README.md +28 -28
  62. package/templates/codex/decisions/0000-template.md +36 -36
  63. package/templates/codex/decisions/INDEX.md +11 -11
  64. package/templates/codex/decisions/README.md +25 -25
  65. package/templates/codex/domain/INDEX.md +14 -14
  66. package/templates/codex/domain/README.md +10 -10
  67. package/templates/codex/evidence/0000-extraction-template.md +36 -36
  68. package/templates/codex/evidence/INDEX.md +11 -11
  69. package/templates/codex/evidence/README.md +15 -15
  70. package/templates/codex/reference/INDEX.md +11 -11
  71. package/templates/codex/reference/README.md +15 -15
  72. package/templates/codex/reference/confirmed-values.md +18 -18
  73. package/templates/codex/requirements/INDEX.md +11 -11
  74. package/templates/codex/requirements/README.md +22 -22
  75. package/templates/codex/requirements/addons/0000-template.md +35 -35
  76. package/templates/codex/requirements/base.md +36 -36
  77. package/templates/codex/requirements/changes/0000-template.md +39 -39
  78. package/templates/codex/resources/INDEX.md +11 -11
  79. package/templates/codex/resources/README.md +17 -17
  80. package/templates/codex/resources/manifest.md +11 -11
  81. package/templates/codex/runbooks/INDEX.md +9 -9
  82. package/templates/codex/runbooks/README.md +8 -8
  83. package/templates/codex/runbooks/incident-runbook-template.md +58 -58
  84. package/templates/gitignore-snippet.txt +10 -12
  85. package/templates/journal/backlog/README.md +18 -18
  86. package/templates/journal/memory/MEMORY.md +15 -15
  87. package/templates/journal/session/archive/.gitkeep +1 -1
  88. package/templates/journal/session/artifacts/.gitkeep +1 -1
  89. package/templates/journal/session/current.md +12 -12
  90. package/templates/lint/README.md +25 -25
  91. package/templates/lint/eslint.config.mjs +33 -33
  92. package/templates/lint/tsconfig.base.json +11 -11
  93. package/templates/local/AGENTS.local.md +33 -33
  94. package/templates/local/README.md +55 -55
  95. package/templates/tests/guardrail.invariants.test.ts +59 -59
package/.agents/AGENTS.md CHANGED
@@ -1,112 +1,112 @@
1
- # AGENTS.md — master contract (tool-agnostic)
2
-
3
- This is the **canonical entry** for every agent working in this repo. Claude Code reaches it via
4
- `CLAUDE.md` (`@.agents/AGENTS.md`). Read in the order below — do **not** "read everything" up front.
5
-
6
- Keep this file lean (`rules/35-context-economy.md`): tone, hardest rules, the map, pointers — detail
7
- lives in the files it links.
8
-
9
- ## Tone
10
-
11
- The person you work with is a **Product Builder** — address them directly ("you"), not as a passive
12
- third party. Talk straight: factual and data-driven, no hype, no flattery, no telling them what they
13
- want to hear. State trade-offs, risks, and disagreements plainly, with the evidence behind them —
14
- being right matters more than being agreeable. Stay calm and professional, never emotional or
15
- defensive. They may not know a given technical detail; explain it when it matters, plainly and
16
- without condescension. Be terse and technical, and match the surrounding code and the user's
17
- register. Project-specific tone or any communication mode lives in `local/AGENTS.local.md`.
18
-
19
- ## Load order
20
-
21
- 1. **This file** — hardest rules + the map (below).
22
- 2. **`rules/`** — always-on working process. Read `00-always.md` every session.
23
- 3. **`codex/INDEX.md`** — the project's knowledge base (domain, requirements, decisions, evidence,
24
- resources, reference, runbooks). Read-on-demand, but **read-first for any domain/feature work**.
25
- 4. **`standards/`** — when writing code, load `general.md` + the per-language file.
26
- 5. **`stack/`** — when scaffolding or configuring, load the active profile.
27
- 6. **`codex/decisions/`** — when a decision's *why* matters.
28
- 7. **`local/`** — per-project customization. Read `local/AGENTS.local.md`, then the matching
29
- `local/<area>/` (rules/standards/stack/skills/commands/reference) for any base area you touch;
30
- **loads last and wins**.
31
-
32
- ## The map
33
-
34
- | Need | Go to |
35
- |---|---|
36
- | System structure / what grimoire creates / CLI behavior / layout & lifecycles | `NAVIGATOR.md` |
37
- | Project knowledge / domain / evidence / resources / requirements / decisions | `codex/` (start at `codex/INDEX.md`) |
38
- | Working process, modes, handoff routing | `rules/` |
39
- | Coding standards, naming, error codes | `standards/` |
40
- | Requirements (base / addon / change request) | `standards/requirements.md` + `codex/requirements/` |
41
- | Test strategy, release/versioning, accessibility | `standards/testing-strategy.md` · `standards/release-versioning.md` · `standards/accessibility.md` |
42
- | Framework / lint / test / CI **starter templates** (copy manually — not auto-seeded) | `stack/` + `templates/ci/` · `templates/lint/` · `templates/tests/` |
43
- | Independent verification (the verifier) | `rules/30-verification.md` + `agents/verifier.md` |
44
- | What am I doing right now? | `journal/session/current.md` (NOW) |
45
- | What do we already know? | `journal/memory/` + `journal/memory/MEMORY.md` (KNOWLEDGE) |
46
- | What work is pending? | `journal/backlog/` (QUEUE) |
47
- | Project-specific overrides | `local/` |
48
- | Project domain reference (big contracts, IPC tables, confirmed values) | `local/reference/` |
49
- | Keeping entry files lean | `rules/35-context-economy.md` |
50
- | Presenting to a human (HTML) | `rules/45-presentation.md` + `commands/present.md` |
51
-
52
- Inside any managed folder **or `local/` folder**, read its generated `INDEX.md` (one line per file)
53
- **before** opening files — that is the per-folder resource map (regenerate with `grimoire index`; CI
54
- runs `--check`). `grimoire doctor` health-checks the whole wiring (exits non-zero on error, for CI).
55
-
56
- ### Hot keywords (jump straight to the file)
57
-
58
- | Keyword | File |
59
- |---|---|
60
- | error code / error catalog | `standards/error-codes.md` |
61
- | verify command / done | active `stack/<profile>.md` + `rules/30-verification.md` |
62
- | security / auth / secrets | `rules/50-security.md` |
63
- | code quality / clean code | `standards/clean-code.md` + `rules/05-code-quality.md` |
64
- | over-engineering / laziness / minimal code / the ladder / `ponytail:` marker | `standards/clean-code.md` (ladder + guardrail) · ADR `docs/adr/0007-adopt-ponytail-laziness-ladder.md` |
65
- | launch / privacy gate | `standards/launch-security-checklist.md` + `standards/security-scanners.md` |
66
- | requirement / spec / REQ-id / change request | `standards/requirements.md` + `codex/requirements/` |
67
- | test strategy / how to test / coverage | `standards/testing-strategy.md` |
68
- | release / changelog / version / rollback | `standards/release-versioning.md` |
69
- | accessibility / a11y / WCAG | `standards/accessibility.md` |
70
- | incident / runbook / on-call / outage | `codex/runbooks/` |
71
- | CI / pipeline / workflow | `templates/ci/ci.yml` + `templates/ci/sast.yml` |
72
- | commit format | `rules/60-commit-style.md` |
73
- | HOTFIX | `rules/20-modes.md` |
74
- | codex / knowledge base / provenance | `standards/codex.md` + `codex/INDEX.md` |
75
- | domain / glossary / context | `codex/domain/` |
76
- | evidence / investigation / decompile / reverse-engineer / provenance | `codex/evidence/` + `standards/codex.md` |
77
- | decision / ADR / "why" | `codex/decisions/` |
78
- | which skill / capability | `skills/catalog.md` |
79
- | writing / editing a contract doc | `standards/writing.md` |
80
- | credit / attribution / license / external source / adopt a tool | `standards/attribution.md` |
81
- | knowledge retrieval / search the codebase / code graph | `graphify` (ADR `docs/adr/0006-delegate-retrieval-to-external-tooling.md`) |
82
- | structure / architecture / navigator / what does grimoire create / layout / lifecycle | `NAVIGATOR.md` |
83
-
84
- ## Source priority (when sources conflict)
85
-
86
- Trust in this order: **live code + committed docs/specs** (current) > **this base template**
87
- (`rules/ standards/ stack/`) > **`journal/memory/` cards** (may be stale — verify before acting on one).
88
- A memory never overrides what the code currently says; treat it as a lead, not as truth.
89
-
90
- ## Hardest rules (full text in `rules/00-always.md`)
91
-
92
- - **Verify before done.** Code you wrote is not done until the verifier returns `pass` on fresh
93
- context. The author cannot mark their own work done.
94
- - **Doc-sync same turn.** Behavior change and its doc/memory update ship in the same turn.
95
- - **Security first.** No hardcoded roles/secrets; validate + authorize on the server; fail closed.
96
- - **Effort is not a constraint.** Do not scope-cut to save effort. Spawn parallel subagents instead.
97
-
98
- ## Customization & precedence
99
-
100
- Base (this template) loads first; `local/` loads last and **wins**.
101
-
102
- **In a consuming project, never edit the managed base** — `.agents/AGENTS.md`, `rules/`,
103
- `standards/`, `stack/`, `agents/`, `skills/`, `commands/`, `tooling.json`. `grimoire sync`
104
- overwrites all of them, so edits there are lost. Put **every** customization under root `local/`
105
- (it is never synced): **override** a base behavior by restating it in `local/` (it wins), or **add**
106
- a project-only rule/skill/command/standard under the matching `local/<area>/`. Protocol:
107
- `local/README.md`.
108
-
109
- **Project domain docs** that don't fit the lean `AGENTS.md` (a big runtime contract, confirmed-value
110
- tables, an IPC catalog) live in `local/reference/` — `grimoire index` generates its `INDEX.md` too.
111
- Run `grimoire doctor` to verify the wiring (imports, skill frontmatter, INDEX drift, placeholders);
112
- it exits non-zero on error, for CI.
1
+ # AGENTS.md — master contract (tool-agnostic)
2
+
3
+ This is the **canonical entry** for every agent working in this repo. Claude Code reaches it via
4
+ `CLAUDE.md` (`@.agents/AGENTS.md`). Read in the order below — do **not** "read everything" up front.
5
+
6
+ Keep this file lean (`rules/35-context-economy.md`): tone, hardest rules, the map, pointers — detail
7
+ lives in the files it links.
8
+
9
+ ## Tone
10
+
11
+ The person you work with is a **Product Builder** — address them directly ("you"), not as a passive
12
+ third party. Talk straight: factual and data-driven, no hype, no flattery, no telling them what they
13
+ want to hear. State trade-offs, risks, and disagreements plainly, with the evidence behind them —
14
+ being right matters more than being agreeable. Stay calm and professional, never emotional or
15
+ defensive. They may not know a given technical detail; explain it when it matters, plainly and
16
+ without condescension. Be terse and technical, and match the surrounding code and the user's
17
+ register. Project-specific tone or any communication mode lives in `local/AGENTS.local.md`.
18
+
19
+ ## Load order
20
+
21
+ 1. **This file** — hardest rules + the map (below).
22
+ 2. **`rules/`** — always-on working process. Read `00-always.md` every session.
23
+ 3. **`codex/INDEX.md`** — the project's knowledge base (domain, requirements, decisions, evidence,
24
+ resources, reference, runbooks). Read-on-demand, but **read-first for any domain/feature work**.
25
+ 4. **`standards/`** — when writing code, load `general.md` + the per-language file.
26
+ 5. **`stack/`** — when scaffolding or configuring, load the active profile.
27
+ 6. **`codex/decisions/`** — when a decision's *why* matters.
28
+ 7. **`local/`** — per-project customization. Read `local/AGENTS.local.md`, then the matching
29
+ `local/<area>/` (rules/standards/stack/skills/commands/reference) for any base area you touch;
30
+ **loads last and wins**.
31
+
32
+ ## The map
33
+
34
+ | Need | Go to |
35
+ |---|---|
36
+ | System structure / what grimoire creates / CLI behavior / layout & lifecycles | `NAVIGATOR.md` |
37
+ | Project knowledge / domain / evidence / resources / requirements / decisions | `codex/` (start at `codex/INDEX.md`) |
38
+ | Working process, modes, handoff routing | `rules/` |
39
+ | Coding standards, naming, error codes | `standards/` |
40
+ | Requirements (base / addon / change request) | `standards/requirements.md` + `codex/requirements/` |
41
+ | Test strategy, release/versioning, accessibility | `standards/testing-strategy.md` · `standards/release-versioning.md` · `standards/accessibility.md` |
42
+ | Framework / lint / test / CI **starter templates** (copy manually — not auto-seeded) | `stack/` + `templates/ci/` · `templates/lint/` · `templates/tests/` |
43
+ | Independent verification (the verifier) | `rules/30-verification.md` + `agents/verifier.md` |
44
+ | What am I doing right now? | `journal/session/current.md` (NOW) |
45
+ | What do we already know? | `journal/memory/` + `journal/memory/MEMORY.md` (KNOWLEDGE) |
46
+ | What work is pending? | `journal/backlog/` (QUEUE) |
47
+ | Project-specific overrides | `local/` |
48
+ | Project domain reference (big contracts, IPC tables, confirmed values) | `local/reference/` |
49
+ | Keeping entry files lean | `rules/35-context-economy.md` |
50
+ | Presenting to a human (HTML) | `rules/45-presentation.md` + `commands/present.md` |
51
+
52
+ Inside any managed folder **or `local/` folder**, read its generated `INDEX.md` (one line per file)
53
+ **before** opening files — that is the per-folder resource map (regenerate with `grimoire index`; CI
54
+ runs `--check`). `grimoire doctor` health-checks the whole wiring (exits non-zero on error, for CI).
55
+
56
+ ### Hot keywords (jump straight to the file)
57
+
58
+ | Keyword | File |
59
+ |---|---|
60
+ | error code / error catalog | `standards/error-codes.md` |
61
+ | verify command / done | active `stack/<profile>.md` + `rules/30-verification.md` |
62
+ | security / auth / secrets | `rules/50-security.md` |
63
+ | code quality / clean code | `standards/clean-code.md` + `rules/05-code-quality.md` |
64
+ | over-engineering / laziness / minimal code / the ladder / `ponytail:` marker | `standards/clean-code.md` (ladder + guardrail) · ADR `docs/adr/0007-adopt-ponytail-laziness-ladder.md` |
65
+ | launch / privacy gate | `standards/launch-security-checklist.md` + `standards/security-scanners.md` |
66
+ | requirement / spec / REQ-id / change request | `standards/requirements.md` + `codex/requirements/` |
67
+ | test strategy / how to test / coverage | `standards/testing-strategy.md` |
68
+ | release / changelog / version / rollback | `standards/release-versioning.md` |
69
+ | accessibility / a11y / WCAG | `standards/accessibility.md` |
70
+ | incident / runbook / on-call / outage | `codex/runbooks/` |
71
+ | CI / pipeline / workflow | `templates/ci/ci.yml` + `templates/ci/sast.yml` |
72
+ | commit format | `rules/60-commit-style.md` |
73
+ | HOTFIX | `rules/20-modes.md` |
74
+ | codex / knowledge base / provenance | `standards/codex.md` + `codex/INDEX.md` |
75
+ | domain / glossary / context | `codex/domain/` |
76
+ | evidence / investigation / decompile / reverse-engineer / provenance | `codex/evidence/` + `standards/codex.md` |
77
+ | decision / ADR / "why" | `codex/decisions/` |
78
+ | which skill / capability | `skills/catalog.md` |
79
+ | writing / editing a contract doc | `standards/writing.md` |
80
+ | credit / attribution / license / external source / adopt a tool | `standards/attribution.md` |
81
+ | knowledge retrieval / search the codebase / code graph | `graphify` (ADR `docs/adr/0006-delegate-retrieval-to-external-tooling.md`) |
82
+ | structure / architecture / navigator / what does grimoire create / layout / lifecycle | `NAVIGATOR.md` |
83
+
84
+ ## Source priority (when sources conflict)
85
+
86
+ Trust in this order: **live code + committed docs/specs** (current) > **this base template**
87
+ (`rules/ standards/ stack/`) > **`journal/memory/` cards** (may be stale — verify before acting on one).
88
+ A memory never overrides what the code currently says; treat it as a lead, not as truth.
89
+
90
+ ## Hardest rules (full text in `rules/00-always.md`)
91
+
92
+ - **Verify before done.** Code you wrote is not done until the verifier returns `pass` on fresh
93
+ context. The author cannot mark their own work done.
94
+ - **Doc-sync same turn.** Behavior change and its doc/memory update ship in the same turn.
95
+ - **Security first.** No hardcoded roles/secrets; validate + authorize on the server; fail closed.
96
+ - **Effort is not a constraint.** Do not scope-cut to save effort. Spawn parallel subagents instead.
97
+
98
+ ## Customization & precedence
99
+
100
+ Base (this template) loads first; `local/` loads last and **wins**.
101
+
102
+ **In a consuming project, never edit the managed base** — `.agents/AGENTS.md`, `rules/`,
103
+ `standards/`, `stack/`, `agents/`, `skills/`, `commands/`, `tooling.json`. `grimoire sync`
104
+ overwrites all of them, so edits there are lost. Put **every** customization under root `local/`
105
+ (it is never synced): **override** a base behavior by restating it in `local/` (it wins), or **add**
106
+ a project-only rule/skill/command/standard under the matching `local/<area>/`. Protocol:
107
+ `local/README.md`.
108
+
109
+ **Project domain docs** that don't fit the lean `AGENTS.md` (a big runtime contract, confirmed-value
110
+ tables, an IPC catalog) live in `local/reference/` — `grimoire index` generates its `INDEX.md` too.
111
+ Run `grimoire doctor` to verify the wiring (imports, skill frontmatter, INDEX drift, placeholders);
112
+ it exits non-zero on error, for CI.
@@ -1,168 +1,188 @@
1
- # NAVIGATOR — Grimoire structure & components
2
-
3
- Canonical reference for **what Grimoire is, what it creates, and what each part does**. Read this to
4
- get a consistent mental model before touching the CLI, the contract, or the layout. It ships inside the
5
- contract (`.agents/NAVIGATOR.md`) so every project shares the same map; it complements `README.md`
6
- (quickstart) and `.agents/AGENTS.md` (the working contract an agent loads each session).
7
-
8
- Grimoire is a single, version-controlled **AI-agent operating system** you pull into any repo. One
9
- command (`grimoire init`) gives a project a complete contract — rules, standards, subagents, skills,
10
- commands, stack presets, a verification protocol — plus the root folders an agent writes into. Later,
11
- `grimoire sync` propagates template updates to old projects **without clobbering** their own data.
12
-
13
- The CLI (`grimoire`, source `bin/grimoire.mjs` in the template repo) is **zero dependencies**,
14
- Node ≥18, ESM. The Grimoire repo itself *is* the template and dogfoods this layout
15
- (`TEMPLATE_ROOT` = repo root, so its own `.agents/` is the template source).
16
-
17
- ## The one mental model: three lifecycles
18
-
19
- Everything Grimoire manages falls into exactly one of three buckets. This split is the whole design.
20
-
21
- | Lifecycle | Who owns it | `grimoire sync` | Where it lives |
22
- |---|---|---|---|
23
- | **Contract** (read-only) | the base template | **overwrites wholesale** (delete + copy) | `.agents/` |
24
- | **Project-owned state/knowledge** | the project / the agent | **never touches** | `codex/`, `journal/`, `local/` (repo root) |
25
- | **Seed sources** | the base template | shipped, copied into new projects | `templates/` |
26
-
27
- Rule of thumb: **`.agents/` is 100% read-only.** Nothing an agent or project writes lives under it.
28
- Anything written goes to a root folder (`codex/`, `journal/`, `local/`). To customize base behavior,
29
- never edit `.agents/` in a consuming project — restate it in `local/` (loads last, wins).
30
-
31
- ## Top-level layout (what a Grimoire project contains)
32
-
33
- ```
34
- <repo>/
35
- ├─ CLAUDE.md # thin pointer: imports @.agents/AGENTS.md + @local/AGENTS.local.md
36
- ├─ .agents/ # CONTRACT — read-only, wholesale-synced
37
- │ ├─ AGENTS.md # canonical entry: tone, hardest rules, the map, load order
38
- │ ├─ rules/ # always-on working process (numbered 00–60)
39
- │ ├─ standards/ # coding standards (general + per-language) + writing/codex
40
- │ ├─ stack/ # tech-stack presets (web-app / desktop / library)
41
- │ ├─ agents/ # subagents (e.g. the independent verifier)
42
- │ ├─ skills/ # reusable workflows (incl. vendored find-skills)
43
- │ ├─ commands/ # slash commands (verify, checkpoint, onboard, present, grimoire)
44
- │ ├─ tooling.json # declared plugins / skills / MCP servers
45
- │ ├─ grimoire.manifest # documents the contract surface (no longer used for carve-outs)
46
- │ └─ VERSION # template version + source sha (stamped by init/sync)
47
- ├─ codex/ # KNOWLEDGE — project-owned, seeded once, never synced
48
- │ ├─ INDEX.md domain/ requirements/ decisions/ evidence/ resources/ reference/ runbooks/
49
- ├─ journal/ # AGENT STATE — project-owned, never synced
50
- │ ├─ memory/ (+ MEMORY.md) # KNOWLEDGE: durable facts (tracked)
51
- │ ├─ backlog/ # QUEUE: pending work items (tracked)
52
- │ └─ session/ # NOW: per-run state (gitignored)
53
- └─ local/ # OVERRIDE CONFIG — project-owned, never synced, loads LAST and wins
54
- ├─ AGENTS.local.md # profile (stack, testing policy), project facts, override declarations
55
- ├─ README.md rules/ standards/ stack/ skills/ commands/ reference/
56
- └─ tooling.json # project-only plugins / MCP (merged additively by bootstrap)
57
- ```
58
-
59
- ### The contract — `.agents/` (read-only)
60
-
61
- | Path | Holds |
62
- |---|---|
63
- | `AGENTS.md` | entry contract + load-order + the map + hot-keywords |
64
- | `rules/` | always-on process: 00-always, verification, modes, handoff, context-economy, commit-style, … |
65
- | `standards/` | coding standards (general + per-language), writing, codex, knowledge-management |
66
- | `stack/` | per-profile defaults (framework / lint / test / verify command) |
67
- | `agents/` | subagent definitions — notably `verifier` (independent done-check) |
68
- | `skills/` | re-runnable workflows; `find-skills` is vendored + mirrored to `.claude/skills/` |
69
- | `commands/` | slash commands |
70
- | `tooling.json` | source of truth for required plugins / skills / MCP |
71
- | `grimoire.manifest` | lists the managed paths — documentation only (sync is wholesale) |
72
-
73
- ### Project-owned roots (never synced)
74
-
75
- - **`codex/`** — the project's knowledge base; read-first for any domain/feature work (start at
76
- `codex/INDEX.md`). Holds `domain/`, `requirements/`, `decisions/` (ADRs), `evidence/`, `resources/`,
77
- `reference/`, `runbooks/`. Seeded once from `templates/codex/`.
78
- - **`journal/`** — the agent's working state, the "3 homes":
79
- - `journal/session/` = **NOW** (current run; gitignored),
80
- - `journal/memory/` = **KNOWLEDGE** (durable facts + `MEMORY.md` index; tracked),
81
- - `journal/backlog/` = **QUEUE** (pending work; tracked).
82
- - **`local/`** — the project's customization layer. Loads **last and wins**. Override a base rule by
83
- restating it here; add project-only rules/skills/commands/standards under the matching `local/<area>/`.
84
-
85
- ## What each CLI command creates / does
86
-
87
- `grimoire <command> [--dir <path>]` (default dir = cwd).
88
-
89
- ### `init` — scaffold a project
90
- 1. **Auto-migrate** an old-layout project first (`migrateLegacyLayout`, see below).
91
- 2. **Wholesale-copy** the template `.agents/` into the project (`copyAgentsWholesale`).
92
- 3. Stamp `VERSION` (template version + git sha).
93
- 4. Write `CLAUDE.md` pointer (if absent).
94
- 5. Ensure `.gitignore` has the session/backup ignore snippet.
95
- 6. **Seed root folders** (only if absent / per-file gap-fill, never overwriting):
96
- `seedCodex` → `codex/`; `seedRoot("journal")` → `journal/`; `seedRoot("local")` → `local/`.
97
- 7. Mirror discoverable skills into `.claude/skills/` (`find-skills` + every `local/skills/<x>`).
98
- 8. Generate per-folder `INDEX.md` (after all mutations).
99
- 9. Run `bootstrap` in dry-run (prints the plugin/MCP plan; writes nothing).
100
-
101
- ### `sync` — pull template updates into an existing project
102
- 1. Fail if no `.agents/` (must `init` first).
103
- 2. **Auto-migrate** an old layout (once, with backup).
104
- 3. **Wholesale-replace** `.agents/` from the template (delete + copy) — your contract is refreshed.
105
- 4. Re-stamp `VERSION`; re-seed `codex/`/`journal/`/`local/` (gap-fill only, never clobbers your files);
106
- re-mirror skills; regenerate `INDEX.md`.
107
- **`codex/`, `journal/`, `local/` are never overwritten** — only missing files are filled in.
108
-
109
- ### `bootstrap` — wire plugins / MCP / skills
110
- Reads base `tooling.json` ∪ `local/tooling.json` (base wins on key conflict; local adds new keys).
111
- - Dry-run (default): prints missing plugins, MCP servers to ensure, and skill install hints.
112
- - `--apply`: enables missing plugins in `~/.claude/settings.json` (backs it up first, only **adds**,
113
- never disables), and merges MCP servers into `.mcp.json` (never clobbers an existing server). Flags
114
- unresolved `${ENV}` placeholders.
115
-
116
- ### `index` — regenerate per-folder `INDEX.md`
117
- One-line-per-file table built from each file's frontmatter `description:` or its H1 + first sentence.
118
- Two groups: the contract (`.agents/<folder>`) and the override layer (`local/<folder>`).
119
- `index --check` is the CI drift gate: fails if any `INDEX.md` is stale, or a `tooling.json` MCP isn't
120
- documented in `skills/catalog.md`. Newline-agnostic (tolerates CRLF checkouts).
121
-
122
- ### `doctor` — health-check the wiring (CI-friendly, exits non-zero on error)
123
- Checks: `CLAUDE.md` imports `@.agents/AGENTS.md` (error) and `@local/AGENTS.local.md` (warn); mirrored
124
- skills have `name:`+`description:`; INDEX/catalog drift; `local/AGENTS.local.md` stack-profile +
125
- testing-policy filled; entry files ≤300 lines; `codex/INDEX.md` scaffolded; `local/tooling.json` valid.
126
-
127
- ## Seed-source map (`templates/` → project root)
128
-
129
- `init`/`sync` seed project-owned roots from `templates/`. Source and destination are separate so this
130
- repo's own live state never doubles as the seed.
131
-
132
- | Seed source | Seeds into | How |
133
- |---|---|---|
134
- | `templates/codex/` | `codex/` | `seedCodex` — dir-level **seed-once** (skips if `codex/` exists) |
135
- | `templates/journal/` | `journal/` | `seedRoot` — **per-file gap-fill** (fills missing files only) |
136
- | `templates/local/` | `local/` | `seedRoot` — **per-file gap-fill** |
137
- | `templates/CLAUDE.md` | `CLAUDE.md` | copied once (if absent) |
138
- | `templates/gitignore-snippet.txt` | `.gitignore` | appended once (`journal/session/`, `.agents.bak-*/`) |
139
-
140
- ## Migration (old layout → new)
141
-
142
- Older projects kept agent state under `.agents/{memory,backlog,session,local}`. On the next
143
- `init`/`sync`, `migrateLegacyLayout` runs once: it backs up the whole `.agents/` to
144
- `.agents.bak-<stamp>/`, then **moves** each legacy dir to its root home —
145
- `.agents/memory→journal/memory`, `…/backlog→journal/backlog`, `…/session→journal/session`,
146
- `…/local→local/` — **only if the destination is absent** (a conflict leaves the legacy copy in the
147
- backup, never overwriting a newer root copy). Idempotent: a no-op once the legacy dirs are gone.
148
-
149
- ## How an agent reads a Grimoire project (load order)
150
-
151
- 1. `CLAUDE.md` imports `@.agents/AGENTS.md` (contract) + `@local/AGENTS.local.md` (overrides).
152
- 2. `.agents/AGENTS.md` hardest rules + the map; **read first, don't read everything**.
153
- 3. `.agents/rules/00-always.md` — every session.
154
- 4. `codex/INDEX.md` read-first for any domain/feature work.
155
- 5. `standards/` + `stack/` — when writing/scaffolding code.
156
- 6. `local/` loads **last and wins**.
157
-
158
- Inside any folder, read its generated `INDEX.md` before opening files (two-level progressive
159
- disclosure: mapINDEX file), keeping context lean.
160
-
161
- ## Invariants (don't break these)
162
-
163
- - **Zero runtime dependencies** in `bin/grimoire.mjs` (Node stdlib only).
164
- - **`.agents/` is read-only** and wholesale-replaced by `sync` never store project data there.
165
- - **`codex/`, `journal/`, `local/` are never synced** safe homes for project-owned content.
166
- - **`local/` wins** on any conflict (loads last).
167
- - Behavior change ships with its doc/INDEX update in the **same change** (doc-sync).
168
- - Code an agent wrote is not done until the independent **verifier** returns `pass`.
1
+ # NAVIGATOR — Grimoire structure & components
2
+
3
+ Canonical reference for **what Grimoire is, what it creates, and what each part does**. Read this to
4
+ get a consistent mental model before touching the CLI, the contract, or the layout. It ships inside the
5
+ contract (`.agents/NAVIGATOR.md`) so every project shares the same map; it complements `README.md`
6
+ (quickstart) and `.agents/AGENTS.md` (the working contract an agent loads each session).
7
+
8
+ Grimoire is a single, version-controlled **AI-agent operating system** you pull into any repo. One
9
+ command (`grimoire init`) gives a project a complete contract — rules, standards, subagents, skills,
10
+ commands, stack presets, a verification protocol — plus the root folders an agent writes into. Later,
11
+ `grimoire sync` propagates template updates to old projects **without clobbering** their own data.
12
+
13
+ The CLI (`grimoire`, source `bin/grimoire.mjs` in the template repo) is **zero dependencies**,
14
+ Node ≥18, ESM. The Grimoire repo itself *is* the template and dogfoods this layout
15
+ (`TEMPLATE_ROOT` = repo root, so its own `.agents/` is the template source).
16
+
17
+ ## The one mental model: three lifecycles
18
+
19
+ Everything Grimoire manages falls into exactly one of three buckets. This split is the whole design.
20
+
21
+ | Lifecycle | Who owns it | `grimoire sync` | Where it lives |
22
+ |---|---|---|---|
23
+ | **Contract** (read-only) | the base template | **overwrites wholesale** (delete + copy) | `.agents/` |
24
+ | **Project-owned state/knowledge** | the project / the agent | **never touches** | `codex/`, `journal/`, `local/` (repo root) |
25
+ | **Seed sources** | the base template | shipped, copied into new projects | `templates/` |
26
+
27
+ Rule of thumb: **`.agents/` is 100% read-only.** Nothing an agent or project writes lives under it.
28
+ Anything written goes to a root folder (`codex/`, `journal/`, `local/`). To customize base behavior,
29
+ never edit `.agents/` in a consuming project — restate it in `local/` (loads last, wins).
30
+
31
+ ## Top-level layout (what a Grimoire project contains)
32
+
33
+ ```
34
+ <repo>/
35
+ ├─ CLAUDE.md # thin pointer: imports @.agents/AGENTS.md + @local/AGENTS.local.md
36
+ ├─ .agents/ # CONTRACT — read-only, wholesale-synced
37
+ │ ├─ AGENTS.md # canonical entry: tone, hardest rules, the map, load order
38
+ │ ├─ rules/ # always-on working process (numbered 00–60)
39
+ │ ├─ standards/ # coding standards (general + per-language) + writing/codex
40
+ │ ├─ stack/ # tech-stack presets (web-app / desktop / library)
41
+ │ ├─ agents/ # subagents (e.g. the independent verifier)
42
+ │ ├─ skills/ # reusable workflows (incl. vendored find-skills)
43
+ │ ├─ commands/ # slash commands (verify, checkpoint, onboard, present, grimoire)
44
+ │ ├─ tooling.json # declared plugins / skills / MCP servers
45
+ │ ├─ grimoire.manifest # documents the contract surface (no longer used for carve-outs)
46
+ │ └─ VERSION # template version + source sha (stamped by init/sync)
47
+ ├─ codex/ # KNOWLEDGE — project-owned, seeded once, never synced
48
+ │ ├─ INDEX.md domain/ requirements/ decisions/ evidence/ resources/ reference/ runbooks/
49
+ ├─ journal/ # AGENT STATE — project-owned, never synced
50
+ │ ├─ memory/ (+ MEMORY.md) # KNOWLEDGE: durable facts (tracked)
51
+ │ ├─ backlog/ # QUEUE: pending work items (tracked)
52
+ │ └─ session/ # NOW: per-run state (gitignored)
53
+ └─ local/ # OVERRIDE CONFIG — project-owned, never synced, loads LAST and wins
54
+ ├─ AGENTS.local.md # profile (stack, testing policy), project facts, override declarations
55
+ ├─ README.md rules/ standards/ stack/ skills/ commands/ reference/
56
+ └─ tooling.json # project-only plugins / MCP (merged additively by bootstrap)
57
+ ```
58
+
59
+ ### The contract — `.agents/` (read-only)
60
+
61
+ | Path | Holds |
62
+ |---|---|
63
+ | `AGENTS.md` | entry contract + load-order + the map + hot-keywords |
64
+ | `rules/` | always-on process: 00-always, verification, modes, handoff, context-economy, commit-style, … |
65
+ | `standards/` | coding standards (general + per-language), writing, codex, knowledge-management |
66
+ | `stack/` | per-profile defaults (framework / lint / test / verify command) |
67
+ | `agents/` | subagent definitions — notably `verifier` (independent done-check) |
68
+ | `skills/` | re-runnable workflows; `find-skills` is vendored + mirrored to `.claude/skills/` |
69
+ | `commands/` | slash commands |
70
+ | `tooling.json` | source of truth for required plugins / skills / MCP |
71
+ | `grimoire.manifest` | lists the managed paths — documentation only (sync is wholesale) |
72
+
73
+ ### Project-owned roots (never synced)
74
+
75
+ - **`codex/`** — the project's knowledge base; read-first for any domain/feature work (start at
76
+ `codex/INDEX.md`). Holds `domain/`, `requirements/`, `decisions/` (ADRs), `evidence/`, `resources/`,
77
+ `reference/`, `runbooks/`. Seeded once from `templates/codex/`.
78
+ - **`journal/`** — the agent's working state, the "3 homes":
79
+ - `journal/session/` = **NOW** (current run; gitignored),
80
+ - `journal/memory/` = **KNOWLEDGE** (durable facts + `MEMORY.md` index; tracked),
81
+ - `journal/backlog/` = **QUEUE** (pending work; tracked).
82
+ - **`local/`** — the project's customization layer. Loads **last and wins**. Override a base rule by
83
+ restating it here; add project-only rules/skills/commands/standards under the matching `local/<area>/`.
84
+
85
+ ## What each CLI command creates / does
86
+
87
+ `grimoire <command> [--dir <path>]` (default dir = cwd).
88
+
89
+ ### `init` — scaffold a project
90
+ 1. **Auto-migrate** an old-layout project first (`migrateLegacyLayout`, see below).
91
+ 2. **Wholesale-copy** the template `.agents/` into the project (`copyAgentsWholesale`).
92
+ 3. Stamp `VERSION` (template version + git sha).
93
+ 4. Write `CLAUDE.md` pointer (if absent).
94
+ 5. Ensure `.gitignore` has the session/backup ignore snippet.
95
+ 6. **Seed root folders** (only if absent / per-file gap-fill, never overwriting):
96
+ `seedCodex` → `codex/`; `seedRoot("journal")` → `journal/`; `seedRoot("local")` → `local/`.
97
+ 7. Mirror discoverable skills into `.claude/skills/` (`find-skills` + every `local/skills/<x>`).
98
+ 8. Generate per-folder `INDEX.md` (after all mutations).
99
+ 9. Run `bootstrap` in dry-run (prints the plugin/MCP plan; writes nothing).
100
+
101
+ ### `sync` — pull template updates into an existing project
102
+ 1. Fail if no `.agents/` (must `init` first).
103
+ 2. **Auto-migrate** an old layout (once, with backup).
104
+ 3. **Wholesale-replace** `.agents/` from the template (delete + copy) — your contract is refreshed.
105
+ 4. Re-stamp `VERSION`; re-seed `codex/`/`journal/`/`local/` (gap-fill only, never clobbers your files);
106
+ re-mirror skills; regenerate `INDEX.md`.
107
+ **`codex/`, `journal/`, `local/` are never overwritten** — only missing files are filled in.
108
+
109
+ ### `bootstrap` — wire plugins / MCP / skills
110
+ Reads base `tooling.json` ∪ `local/tooling.json` (base wins on key conflict; local adds new keys).
111
+ - Dry-run (default): prints missing plugins, MCP servers to ensure, and skill install hints.
112
+ - `--apply`: enables missing plugins in `~/.claude/settings.json` (backs it up first, only **adds**,
113
+ never disables), and merges MCP servers into `.mcp.json` (never clobbers an existing server). Flags
114
+ unresolved `${ENV}` placeholders.
115
+
116
+ ### `index` — regenerate per-folder `INDEX.md`
117
+ One-line-per-file table built from each file's frontmatter `description:` or its H1 + first sentence.
118
+ Two groups: the contract (`.agents/<folder>`) and the override layer (`local/<folder>`).
119
+ `index --check` is the CI drift gate: fails if any `INDEX.md` is stale, or a `tooling.json` MCP isn't
120
+ documented in `skills/catalog.md`. Newline-agnostic (tolerates CRLF checkouts).
121
+
122
+ ### `doctor` — health-check the wiring (CI-friendly, exits non-zero on error)
123
+ Checks: `CLAUDE.md` imports `@.agents/AGENTS.md` (error) and `@local/AGENTS.local.md` (warn); mirrored
124
+ skills have `name:`+`description:`; INDEX/catalog drift; `local/AGENTS.local.md` stack-profile +
125
+ testing-policy filled; entry files ≤300 lines; `codex/INDEX.md` scaffolded; `local/tooling.json` valid.
126
+
127
+ ## Seed-source map (`templates/` → project root)
128
+
129
+ `init`/`sync` seed project-owned roots from `templates/`. Source and destination are separate so this
130
+ repo's own live state never doubles as the seed.
131
+
132
+ | Seed source | Seeds into | How |
133
+ |---|---|---|
134
+ | `templates/codex/` | `codex/` | `seedCodex` — dir-level **seed-once** (skips if `codex/` exists) |
135
+ | `templates/journal/` | `journal/` | `seedRoot` — **per-file gap-fill** (fills missing files only) |
136
+ | `templates/local/` | `local/` | `seedRoot` — **per-file gap-fill** |
137
+ | `templates/CLAUDE.md` | `CLAUDE.md` | copied once (if absent) |
138
+ | `templates/gitignore-snippet.txt` | `.gitignore` | appended once (`journal/session/`, `.agents.bak-*/`) |
139
+
140
+ ## Migration (old layout → new)
141
+
142
+ Older projects kept agent state under `.agents/{memory,backlog,session,local}`. On the next
143
+ `init`/`sync`, `migrateLegacyLayout` runs once: it backs up the whole `.agents/` to
144
+ `.agents.bak-<stamp>/`, then **moves** each legacy dir to its root home —
145
+ `.agents/memory→journal/memory`, `…/backlog→journal/backlog`, `…/session→journal/session`,
146
+ `…/local→local/` — **only if the destination is absent** (a conflict leaves the legacy copy in the
147
+ backup, never overwriting a newer root copy). Idempotent: a no-op once the legacy dirs are gone.
148
+
149
+ The same `sync` also **repairs the wiring** the move would otherwise break: it rewrites a `CLAUDE.md`
150
+ still importing `@.agents/local/…` to `@local/…`, and refreshes `.gitignore` (drops the stale
151
+ `.agents/session/` line, adds `journal/session/`, `.agents.bak-*/`, and `graphify-out/`). `doctor`
152
+ warns if a stale `@.agents/local/` import survives.
153
+
154
+ ### Adopting an existing repo's `docs/` into `codex/`
155
+
156
+ Moving a project's hand-kept `docs/` tree into `codex/` is **manual and project-owned** (the CLI never
157
+ touches `docs/` or `codex/`). Place by *kind*, not by old folder: ADRs → `codex/decisions/`, specs →
158
+ `codex/requirements/`, contracts/lookups/IPC tables `codex/reference/`, "what the system is"
159
+ `codex/domain/`, runbooks`codex/runbooks/`, investigations/postmortems/release evidence
160
+ `codex/evidence/`. Drop low-value process exhaust (it stays recoverable in git history).
161
+
162
+ **Before calling it done, grep the codebase for runtime reads of the moved paths.** Code that does
163
+ `readFileSync(join(cwd, "docs", …))` test oracles, `db:seed` scripts, fixture loaders — breaks
164
+ silently when the file moves. Two consequences: (1) update that path in the code; (2) if the moved
165
+ files are *loaded by code* (seed CSVs, test fixtures), they are runtime assets, not knowledge — keep
166
+ them where the loader expects, or treat `codex/` as their home and point the loader there. **Never let
167
+ PII (staff/patient rosters) land in `codex/` if `codex/` is fed to retrieval/wiki tooling.**
168
+
169
+ ## How an agent reads a Grimoire project (load order)
170
+
171
+ 1. `CLAUDE.md` → imports `@.agents/AGENTS.md` (contract) + `@local/AGENTS.local.md` (overrides).
172
+ 2. `.agents/AGENTS.md` — hardest rules + the map; **read first, don't read everything**.
173
+ 3. `.agents/rules/00-always.md` — every session.
174
+ 4. `codex/INDEX.md` — read-first for any domain/feature work.
175
+ 5. `standards/` + `stack/` — when writing/scaffolding code.
176
+ 6. `local/` — loads **last and wins**.
177
+
178
+ Inside any folder, read its generated `INDEX.md` before opening files (two-level progressive
179
+ disclosure: map → INDEX → file), keeping context lean.
180
+
181
+ ## Invariants (don't break these)
182
+
183
+ - **Zero runtime dependencies** in `bin/grimoire.mjs` (Node stdlib only).
184
+ - **`.agents/` is read-only** and wholesale-replaced by `sync` — never store project data there.
185
+ - **`codex/`, `journal/`, `local/` are never synced** — safe homes for project-owned content.
186
+ - **`local/` wins** on any conflict (loads last).
187
+ - Behavior change ships with its doc/INDEX update in the **same change** (doc-sync).
188
+ - Code an agent wrote is not done until the independent **verifier** returns `pass`.
package/.agents/VERSION CHANGED
@@ -1,4 +1,4 @@
1
- grimoire v0.3.2
2
- source: this repository IS the template (canonical source of truth)
3
- note: informational only — package.json `version` is the single source of truth;
4
- `grimoire init` / `grimoire sync` regenerate this from it and stamp the build sha.
1
+ grimoire v0.4.0
2
+ source: this repository IS the template (canonical source of truth)
3
+ note: informational only — package.json `version` is the single source of truth;
4
+ `grimoire init` / `grimoire sync` regenerate this from it and stamp the build sha.
@@ -1,7 +1,7 @@
1
- # agents — index
2
-
3
- <!-- GENERATED by `grimoire index`; do not edit by hand. Re-run after adding/renaming files here. -->
4
-
5
- | File | What it covers |
6
- |---|---|
7
- | `verifier.md` | Independent verification reviewer. |
1
+ # agents — index
2
+
3
+ <!-- GENERATED by `grimoire index`; do not edit by hand. Re-run after adding/renaming files here. -->
4
+
5
+ | File | What it covers |
6
+ |---|---|
7
+ | `verifier.md` | Independent verification reviewer. |