doctrina-cli 0.13.0 → 0.14.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 (66) hide show
  1. package/README.md +1 -1
  2. package/package.json +3 -2
  3. package/src/commands/adapter.js +205 -0
  4. package/src/commands/analyze.js +66 -19
  5. package/src/commands/change.js +100 -42
  6. package/src/commands/clarify.js +8 -1
  7. package/src/commands/close.js +57 -2
  8. package/src/commands/completion.js +6 -0
  9. package/src/commands/constitution.js +8 -1
  10. package/src/commands/context.js +359 -53
  11. package/src/commands/contract.js +17 -24
  12. package/src/commands/coverage.js +16 -4
  13. package/src/commands/decision.js +172 -40
  14. package/src/commands/doctor.js +38 -7
  15. package/src/commands/handoff.js +8 -1
  16. package/src/commands/hooks.js +6 -0
  17. package/src/commands/index-rebuild.js +8 -1
  18. package/src/commands/init.js +139 -6
  19. package/src/commands/intake.js +11 -2
  20. package/src/commands/intent.js +8 -1
  21. package/src/commands/metrics.js +80 -7
  22. package/src/commands/next.js +14 -2
  23. package/src/commands/prime.js +8 -1
  24. package/src/commands/report.js +8 -1
  25. package/src/commands/review.js +8 -1
  26. package/src/commands/search.js +8 -1
  27. package/src/commands/show.js +8 -1
  28. package/src/commands/skill.js +16 -6
  29. package/src/commands/spec.js +13 -6
  30. package/src/commands/status.js +14 -2
  31. package/src/commands/templates.js +193 -59
  32. package/src/commands/trace.js +15 -3
  33. package/src/commands/upgrade.js +8 -1
  34. package/src/commands/validate.js +58 -2
  35. package/src/commands/verify.js +12 -2
  36. package/src/commands/watch.js +8 -1
  37. package/src/commands/why.js +10 -24
  38. package/src/commands/work.js +8 -1
  39. package/src/index.js +60 -6
  40. package/src/lib/adapters.js +140 -0
  41. package/src/lib/adr-guard.js +1 -0
  42. package/src/lib/args.js +10 -0
  43. package/src/lib/clarity.js +1 -0
  44. package/src/lib/colors.js +1 -0
  45. package/src/lib/commands.js +239 -26
  46. package/src/lib/criteria.js +1 -0
  47. package/src/lib/dates.js +1 -0
  48. package/src/lib/diff.js +1 -0
  49. package/src/lib/doc-model.js +287 -0
  50. package/src/lib/docs-impact.js +167 -0
  51. package/src/lib/ears.js +1 -0
  52. package/src/lib/exit-codes.js +103 -0
  53. package/src/lib/flag-catalog.js +106 -0
  54. package/src/lib/fs-ops.js +1 -0
  55. package/src/lib/gates.js +123 -0
  56. package/src/lib/git.js +97 -0
  57. package/src/lib/index-json.js +14 -6
  58. package/src/lib/json-out.js +83 -0
  59. package/src/lib/prompt.js +18 -1
  60. package/src/lib/scan.js +81 -33
  61. package/src/lib/spec-ops.js +94 -9
  62. package/src/lib/suggest.js +1 -0
  63. package/src/lib/templates.js +89 -0
  64. package/src/lib/usage.js +89 -0
  65. package/src/lib/version.js +1 -0
  66. package/templates/AGENTS.md.template +59 -53
@@ -33,19 +33,42 @@ prompt and approves; do not make them run the CLI or hand-author artifacts.
33
33
  <!-- doctrina:surface:begin — CLI-owned block, generated from the installed command catalog. Refreshed by `doctrina upgrade --write`; edits inside are overwritten. -->
34
34
  ## Doctrina command surface (generated — reach for these, don't hand-author)
35
35
 
36
- Every operation of the installed CLI, grouped by workflow. The CLI
37
- scaffolds from canonical templates and keeps `index.json` in sync, so
38
- prefer it over writing artifacts by hand. Details: `doctrina --help`.
39
-
40
- - **Start:** `doctrina init` · `doctrina intake` · `doctrina work "<prompt>" (--capability · --chore · --from-diff · --quiet)`
41
- - **Author:** `doctrina spec new|list|set` · `doctrina change new|apply|archive|check|tick|diff|abandon` · `doctrina contract new|list|check` · `doctrina decision new|accept|land|supersede|list` · `doctrina skill new|list|sync|suggest` · `doctrina intent add|list`
42
- - **Read / orient:** `doctrina prime (session start)` · `doctrina context [<cap>] --concat` · `doctrina show` · `doctrina search` · `doctrina status` · `doctrina next` · `doctrina why` · `doctrina handoff (before compaction/handover)` · `doctrina constitution`
43
- - **Gates:** `doctrina analyze` · `doctrina clarify --all (--lang pt|en)` · `doctrina validate (--fix)` · `doctrina coverage --strict` · `doctrina trace --strict` · `doctrina review` · `doctrina verify` · `doctrina close <id...>` · `doctrina doctor`
44
- - **Maintain:** `doctrina templates list|check|update` · `doctrina hooks install` · `doctrina index rebuild` · `doctrina watch` · `doctrina metrics` · `doctrina report` · `doctrina completion` · `doctrina upgrade --write`
45
-
46
- Session bookends: `doctrina prime` to orient at session start;
47
- `doctrina handoff` before compaction or handover. Continuous:
48
- `doctrina watch`. Capture lessons: `doctrina skill suggest`.
36
+ Every command, with the moment you reach for it. The CLI scaffolds from
37
+ canonical templates and keeps `index.json` in sync — prefer it over
38
+ hand-authoring. Flags and detail: `doctrina <command> --help`.
39
+ **Bootstrap**
40
+ - `doctrina init` — scaffold AGENTS.md and .doctrina/. *When:* starting a project that has no AGENTS.md yet.
41
+ - `doctrina intake` — store the intent and print the bootstrap playbook. *When:* you have a full project description and no specs yet.
42
+ - `doctrina adapter list|add|remove` — install/remove agent adapters (additive). *When:* adding or removing an agent's pointer files.
43
+ **Orient**
44
+ - `doctrina prime (session start)` — gates, standing rules, and open work in one read. *When:* at the START of every session.
45
+ - `doctrina context [<cap>] --for "<task>" --concat` — the read pack, assembled to fit a token budget. *When:* before working on any task, to load the right files.
46
+ - `doctrina show` — point-read a single artifact by reference. *When:* you need one requirement, criterion, or ADR, not a file.
47
+ - `doctrina search` — search the artifact tree, grouped by category. *When:* you do not know which artifact mentions a term.
48
+ - `doctrina status` — index, coverage, trace, and artifact counts. *When:* you need the health of the tree at a glance.
49
+ - `doctrina next` — the recommended next workflow action. *When:* you finished something and do not know what follows.
50
+ - `doctrina why` — provenance: intent, proof, ADRs, and history. *When:* you need to justify or trace a capability's existence.
51
+ - `doctrina handoff (before compaction/handover)` — a resume note: open work, task state, next command. *When:* BEFORE compaction or handing over to another session.
52
+ - `doctrina constitution` — accepted ADRs and product non-goals. *When:* you need the standing rules before deciding something.
53
+ **Change**
54
+ - `doctrina work "<prompt>" (--capability · --chore · --from-diff · --quiet)` — scaffold a change and print the playbook to execute. *When:* any request arrives that changes behaviour.
55
+ - `doctrina spec new|list|set` — create, list, and edit capability specs. *When:* a capability needs creating or its headers advancing.
56
+ - `doctrina change new|apply|archive|check|tick|diff|abandon` — new / apply / archive / check / tick / diff / abandon. *When:* driving a change through its lifecycle by hand.
57
+ - `doctrina contract new|list|check` — own and verify the integration surface. *When:* the change touches ports, env vars, or public endpoints.
58
+ - `doctrina decision new|accept|land|supersede|list|scope` — record, accept, land, scope, and supersede ADRs. *When:* the change decides something a later session must not relitigate.
59
+ - `doctrina skill new|list|sync|suggest` — capture on-demand procedural memory. *When:* a lesson is worth not relearning.
60
+ - `doctrina intent add|list` — append and list product intent anchors. *When:* new product intent appears after the intake.
61
+ **Gate**
62
+ - `doctrina analyze` — structural pre-flight on a change folder. *When:* before applying a change.
63
+ - `doctrina clarify --all (--lang pt|en)` — smell-test Markdown for ambiguity. *When:* before applying, or before opening a PR.
64
+ - `doctrina validate (--fix)` — schema, structure, EARS, and index drift. *When:* after any artifact edit, and before considering work done.
65
+ - `doctrina coverage --strict` — acceptance criteria against cited evidence. *When:* before claiming a capability is proven.
66
+ - `doctrina trace --strict` — intent provenance across the tree. *When:* checking that product intent still maps to capabilities.
67
+ - `doctrina review` — conformance of your changes vs specs/ADRs/contracts. *When:* before handing work back, to self-review it.
68
+ - `doctrina verify` — the project's declared typecheck/test/build checks. *When:* the real build gate must run.
69
+ - `doctrina close <id...>` — the whole closing sequence in one attested pass. *When:* a change is implemented and ready to finish.
70
+ - `doctrina doctor` — aggregate diagnostic with per-finding remedies. *When:* something looks wrong and you do not know which gate to ask.
71
+ **Maintain** (triggers: `doctrina <command> --help`) — `doctrina templates list|check|update` · `doctrina hooks install` · `doctrina index rebuild` · `doctrina watch` · `doctrina metrics` · `doctrina report` · `doctrina completion` · `doctrina upgrade --write`
49
72
  <!-- doctrina:surface:end -->
50
73
 
51
74
  ## Stack and tooling
@@ -78,55 +101,38 @@ Session bookends: `doctrina prime` to orient at session start;
78
101
  - Archived changes in `.doctrina/changes/archive/` are out of the default
79
102
  read path; consult only when explicitly debugging history.
80
103
 
81
- ## Artifact invariants (verbatim — `doctrina validate` enforces these)
82
-
83
- Scaffold artifacts with the CLI (`doctrina decision new`, `doctrina work`),
84
- which writes from the canonical templates. Do NOT hand-author these files
85
- from memory. If you must write one by hand, match these exactly:
86
-
87
- - **Metadata headers come in two forms — do not mix them up:**
88
- - ADRs, change proposals, and the intake use **list items**:
89
- `- **Status:** accepted`, `- **Date:** 2026-06-13`.
90
- - Specs use **bare bold** (no leading `- `):
91
- `**Status:** active`, `**Version:** 0.1.0`.
92
- Match the template for the artifact you are writing.
93
- - **ADR filename** must be `NNNN-slug.md` — four digits, e.g.
94
- `0001-jwt-algorithm.md`. `ADR-001-...md` or `1-...md` is invisible to
95
- `doctrina decision accept`, the index, and the orphan check.
96
- - **Change folder** at `.doctrina/changes/<id>/` must contain a file named
97
- exactly `proposal.md` (not `change.md`, not `README.md`). `tasks.md` and
98
- `design.md` are optional siblings.
99
- - **Spec** lives at `.doctrina/specs/<capability>/spec.md` and its
100
- `**Version:**` header must equal the `version` recorded for it in
101
- `.doctrina/index.json`.
102
- - **Every artifact on disk** must be registered in `.doctrina/index.json`,
103
- and every path in `index.json` must exist on disk. Update the index in
104
- the same change that adds or moves a file.
105
-
106
- Always finish by running `doctrina validate` and resolving every `error:`
107
- before considering work done.
104
+ ## Artifact invariants (`doctrina validate` enforces these)
105
+
106
+ Scaffold with the CLI; do not hand-author from memory. If you must:
107
+
108
+ - **Headers:** ADRs / proposals / intake use list items
109
+ (`- **Status:** accepted`); specs use bare bold (`**Status:** active`).
110
+ - **ADR filename:** `NNNN-slug.md`, four digits. Other shapes are invisible
111
+ to `decision accept`, the index, and the orphan check.
112
+ - **Change folder:** `.doctrina/changes/<id>/proposal.md`, that exact name.
113
+ - **Spec:** `.doctrina/specs/<cap>/spec.md`; its `**Version:**` must equal
114
+ the version recorded in `index.json`.
115
+ - **Every artifact** is registered in `index.json`, and every indexed path
116
+ exists. Update the index in the same change.
117
+
118
+ Finish by running `doctrina validate` and resolving every `error:`.
108
119
 
109
120
  ## How to read context efficiently
110
121
 
111
122
  `doctrina context [<capability>] --concat` assembles the read pack in one
112
- call, in order: this `AGENTS.md` → `.doctrina/product.md` → the capability
113
- spec → open `.doctrina/changes/<id>/` → `.doctrina/decisions/` filtered to
114
- `Status: accepted`. Run it for ANY task, not only `doctrina work`; it skips
115
- `changes/archive/` (history — read only when debugging it).
123
+ call: this `AGENTS.md` → `product.md` → the capability spec → open changes →
124
+ accepted ADRs. Run it for ANY task. It skips `changes/archive/` (history).
116
125
 
117
- On demand only: if the task matches a skill in `.doctrina/skills/`, read its
118
- `description:` / `when:` frontmatter; load the full body when the trigger fires.
126
+ Skills are on demand: read the `description:` / `when:` frontmatter in
127
+ `.doctrina/skills/`; load a body only when its trigger fires.
119
128
 
120
- Keep this file under 150 lines. Density beats prose. Use exact commands.
129
+ Keep this file under 150 lines. Density beats prose.
121
130
 
122
131
  ## Definition of done
123
132
 
124
- A change is done when:
125
- - All tasks in the change's `tasks.md` are checked.
126
- - Deltas have been merged into affected spec files.
127
- - The change folder has been moved to `.doctrina/changes/archive/`.
128
- - Any architectural decisions are recorded as ADRs with `Status: accepted`.
129
- - `.doctrina/index.json` has been updated.
133
+ `doctrina close <id>` is the definition: tasks checked, deltas merged into
134
+ specs, gates green, ADRs recorded and accepted, change archived, index
135
+ updated. If close refuses, the change is not done.
130
136
 
131
137
  ## What never goes in this file
132
138