doctrina-cli 0.15.0 → 0.16.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 (85) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/commands/adapter.js +24 -1
  4. package/src/commands/analyze.js +8 -199
  5. package/src/commands/change.js +143 -217
  6. package/src/commands/ci.js +182 -0
  7. package/src/commands/clarify.js +58 -21
  8. package/src/commands/close.js +291 -42
  9. package/src/commands/constitution.js +14 -91
  10. package/src/commands/context.js +278 -107
  11. package/src/commands/contract.js +95 -75
  12. package/src/commands/coverage.js +58 -273
  13. package/src/commands/decision.js +54 -7
  14. package/src/commands/doctor.js +292 -129
  15. package/src/commands/handoff.js +10 -57
  16. package/src/commands/hooks.js +11 -2
  17. package/src/commands/index-rebuild.js +9 -48
  18. package/src/commands/init.js +70 -13
  19. package/src/commands/intake.js +30 -92
  20. package/src/commands/metrics.js +53 -84
  21. package/src/commands/next.js +105 -147
  22. package/src/commands/prime.js +24 -91
  23. package/src/commands/report.js +50 -108
  24. package/src/commands/review.js +68 -36
  25. package/src/commands/search.js +18 -4
  26. package/src/commands/show.js +24 -9
  27. package/src/commands/skill.js +16 -25
  28. package/src/commands/spec.js +26 -5
  29. package/src/commands/status.js +51 -172
  30. package/src/commands/templates.js +31 -138
  31. package/src/commands/trace.js +36 -71
  32. package/src/commands/triage.js +7 -75
  33. package/src/commands/validate.js +14 -871
  34. package/src/commands/verify.js +121 -160
  35. package/src/commands/why.js +2 -2
  36. package/src/commands/work.js +234 -263
  37. package/src/index.js +106 -7
  38. package/src/lib/actions.js +484 -0
  39. package/src/lib/adapters.js +0 -11
  40. package/src/lib/adr-guard.js +19 -0
  41. package/src/lib/agent-changelog.js +133 -0
  42. package/src/lib/analysis.js +264 -0
  43. package/src/lib/change-ops.js +131 -0
  44. package/src/lib/commands.js +109 -6
  45. package/src/lib/config.js +206 -0
  46. package/src/lib/constitution-model.js +102 -0
  47. package/src/lib/coverage-model.js +392 -0
  48. package/src/lib/criteria.js +23 -0
  49. package/src/lib/doc-model.js +326 -0
  50. package/src/lib/docs-impact.js +196 -27
  51. package/src/lib/flag-catalog.js +0 -16
  52. package/src/lib/fs-ops.js +58 -1
  53. package/src/lib/gates.js +210 -24
  54. package/src/lib/git.js +132 -0
  55. package/src/lib/index-json.js +2 -19
  56. package/src/lib/intake-model.js +86 -0
  57. package/src/lib/json-out.js +100 -2
  58. package/src/lib/ledger.js +192 -0
  59. package/src/lib/lexicon.js +191 -0
  60. package/src/lib/metrics-model.js +159 -0
  61. package/src/lib/names.js +42 -0
  62. package/src/lib/playbook.js +97 -0
  63. package/src/lib/project.js +57 -0
  64. package/src/lib/reproducibility.js +137 -0
  65. package/src/lib/runtime.js +238 -11
  66. package/src/lib/scan.js +204 -13
  67. package/src/lib/signoff.js +147 -0
  68. package/src/lib/snapshot.js +209 -0
  69. package/src/lib/spec-ops.js +50 -5
  70. package/src/lib/templates-model.js +262 -0
  71. package/src/lib/trace-model.js +95 -0
  72. package/src/lib/triage-model.js +121 -0
  73. package/src/lib/usage.js +6 -4
  74. package/src/lib/validation-model.js +1299 -0
  75. package/src/lib/version.js +22 -0
  76. package/src/lib/views.js +410 -0
  77. package/src/lib/work-model.js +77 -0
  78. package/templates/AGENTS.md.template +20 -26
  79. package/templates/README.md +35 -0
  80. package/templates/change/proposal.md.template +1 -0
  81. package/templates/contract.md.template +7 -0
  82. package/templates/hooks/pre-commit.sample +6 -2
  83. package/templates/playbooks/bootstrap.md.template +43 -0
  84. package/templates/playbooks/chore.md.template +19 -0
  85. package/templates/playbooks/work.md.template +76 -0
@@ -3,6 +3,7 @@
3
3
  - **Status:** proposed
4
4
  - **Date:** {{DATE}}
5
5
  - **Owner:**
6
+ - **Lane:**
6
7
  - **Affects specs:**
7
8
 
8
9
  ## Why
@@ -56,6 +56,13 @@ program, because no `env:` line ever exports it.
56
56
  vars and secrets are CI-injected, and CI injects the EMPTY
57
57
  STRING for one that is unset — not "absent". That is why a
58
58
  `getenv(NAME, default)` default silently never applies.
59
+
60
+ Exporting under a name that is not the source's is routine
61
+ (npm reads its credential from NODE_AUTH_TOKEN whatever your
62
+ secret is called). Declare it as `<origin>:<source>` — e.g.
63
+ `secrets:NPM_TOKEN` — and RT02 stays silent while the two
64
+ agree, and speaks the moment either side moves. A bare origin
65
+ keeps warning on any rename, which is the right default.
59
66
  Workflow repo-relative path to the workflow/pipeline file.
60
67
  Job/Step the job (or step) whose env: block must export it.
61
68
  Consumer the file that reads it.
@@ -13,9 +13,13 @@
13
13
  # EARS, ledger/index disagreement, and so on.
14
14
  #
15
15
  # To gate without auto-repairing (CI-style, fail on any drift), replace the
16
- # line below with a bare `doctrina validate`.
16
+ # line below with a bare `$DOCTRINA validate`.
17
17
 
18
- doctrina validate --fix || exit 1
18
+ # The CLI that installed this hook, pinned by path (the hook is local to
19
+ # the clone). Set DOCTRINA in the environment to run another one.
20
+ DOCTRINA="${DOCTRINA:-{{DOCTRINA_BIN}}}"
21
+
22
+ $DOCTRINA validate --fix || exit 1
19
23
 
20
24
  # Re-stage the index if --fix rewrote it, so the repaired index lands in this
21
25
  # commit rather than as a leftover unstaged change. Harmless when unchanged.
@@ -0,0 +1,43 @@
1
+ [[b]]Bootstrap playbook[[/b]][[g]] — agent-executed (ADR 0005); the CLI does no interpretation.[[/g]]
2
+
3
+ Execute in order, in a single linear pass:
4
+
5
+ 1. Read [[c]].doctrina/intake.md[[/c]] (raw intent) and [[c]].doctrina/product.md[[/c]].
6
+
7
+ 2. Fill every product.md section from the intake: Vision, Problem,
8
+ Target users, Scope (in/out), Non-goals, Success criteria, and the
9
+ Delivery order — name the ONE end-to-end walking skeleton to build
10
+ and verify before fanning out (depth before breadth).
11
+ One fact, one home — product.md holds vision, never requirements.
12
+
13
+ 3. Derive the capability list: kebab-case, one per area of behaviour
14
+ (e.g. auth, billing, reports). For each capability:
15
+ [[c]]doctrina spec new <capability>[[/c]]
16
+ then replace the template placeholders in
17
+ .doctrina/specs/<capability>/spec.md with EARS requirements derived
18
+ from the intake (Ubiquitous / Event-driven / State-driven /
19
+ Unwanted-behavior / Optional). Keep the two axes honest — leave
20
+ Implementation: planned for what is not built yet; keep aspiration
21
+ under ## Maturity → Future, not in EARS; write concrete Acceptance
22
+ criteria, each [unverified] until a cited test proves it.
23
+
24
+ 4. If the project spans services/front-ends, own the seams between
25
+ them (port map, env, API/WS/event shapes) as a contract:
26
+ [[c]]doctrina contract new <name>[[/c]] → fill it → [[c]]doctrina contract check[[/c]]
27
+
28
+ 5. Record any architectural decision the intake forces (cite Evidence):
29
+ [[c]]doctrina decision new "<title>"[[/c]] → edit → [[c]]doctrina decision accept <num>[[/c]]
30
+
31
+ 6. Quality gates — fix everything they report before moving on:
32
+ [[c]]doctrina clarify --all[[/c]]
33
+ [[c]]doctrina validate[[/c]]
34
+ [[c]]doctrina coverage[[/c]] (and [[c]]doctrina verify --init[[/c]] to declare the build gate)
35
+ If something in the intake is genuinely ambiguous, ask the user
36
+ before assuming.
37
+
38
+ 7. Mark the intake consumed: in .doctrina/intake.md flip
39
+ "- **Status:** pending" to "- **Status:** converted".
40
+
41
+ 8. [[c]]doctrina next[[/c]] — follow the recommendation. Implementation then
42
+ flows through [[c]]doctrina work "<brief prompt>"[[/c]], one change at a time.
43
+ {{MISSING_SPECS_WARNING}}
@@ -0,0 +1,19 @@
1
+ [[b]]Chore playbook — change {{CHANGE_ID}}[[/b]][[g]] — agent-executed (ADR 0005); no spec deltas.[[/g]]
2
+
3
+ Prompt: "{{PROMPT}}"
4
+
5
+ Execute in order, in a single linear pass:
6
+
7
+ 1. Replace the placeholder tasks in .doctrina/changes/{{CHANGE_ID}}/tasks.md
8
+ with small, checkable steps; implement them, checking each box.
9
+ [[g]] (Do it before implementing — analyze/close refuse leftover scaffold[[/g]]
10
+ [[g]] placeholders, and `change tick` will not tick an empty box.)[[/g]]
11
+ 2. Prove it (archive refuses unchecked boxes):
12
+ [[c]]doctrina verify[[/c]] — the project's typecheck/test/build gate
13
+ [[c]]doctrina verify --clean[[/c]] — clean-checkout reproducibility lint
14
+ Then check the proposal's ## Verification boxes and every task.
15
+ 3. This is a chore: no spec changes. If you find yourself needing a
16
+ spec delta, it is not a chore — reopen with [[c]]doctrina work "<prompt>"[[/c]].
17
+ 4. [[c]]doctrina change apply {{CHANGE_ID}}[[/c]] (zero deltas → flips to applied).
18
+ 5. [[c]]doctrina change archive {{CHANGE_ID}}[[/c]], then [[c]]doctrina validate[[/c]].
19
+ [[g]] If this fix taught a lesson worth not relearning, capture it: [[/g]][[c]]doctrina skill new <slug>[[/c]][[g]].[[/g]]
@@ -0,0 +1,76 @@
1
+ [[b]]{{TITLE}} — change {{CHANGE_ID}}[[/b]][[g]] — agent-executed (ADR 0005).[[/g]]
2
+
3
+ Prompt: "{{PROMPT}}"
4
+ {{FROM_DIFF_NOTE}}
5
+ {{THIN_WARNING}}
6
+ {{CAPABILITY_BLOCK}}
7
+ {{DIFF_MATCHES}}
8
+
9
+ Execute in order, in a single linear pass:
10
+
11
+ 1. Read the context pack and confirm (or correct) the capability:
12
+ [[c]]doctrina context {{CAPABILITY}} --concat[[/c]]
13
+
14
+ 2. If the capability has no spec yet:
15
+ [[c]]doctrina spec new <capability>[[/c]]
16
+ [[g]] Trace it to product intent: tag the product.md success-criteria bullet[[/g]]
17
+ [[g]] it serves with an anchor ("- [SC1] ...") and set the spec's[[/g]]
18
+ [[g]] "**Realizes:** SC1" header (or "n/a — <why>"). `doctrina validate` warns[[/g]]
19
+ [[g]] on an active spec with no Realizes; `doctrina trace` reports the link.[[/g]]
20
+
21
+ {{STEP3_INTRO}}
22
+ [[g]] # Spec Delta — capability: <capability>[[/g]]
23
+ [[g]] **Operation:** ADDED | MODIFIED | REMOVED[[/g]]
24
+ [[g]] **Target spec on apply:** `.doctrina/specs/<capability>/spec.md`[[/g]]
25
+ [[g]] ---[[/g]]
26
+ [[g]] <EARS body. Keep the two axes honest (Status vs Implementation),[[/g]]
27
+ [[g]] keep aspiration under ## Maturity → Future, and cite the proof per[[/g]]
28
+ [[g]] criterion: "1. [unverified] <signal> — verified by `path/to/test`">[[/g]]
29
+ [[g]] New capability? `spec new` then an ADDED delta with the FULL body — apply[[/g]]
30
+ [[g]] replaces the untouched scaffold. Bookkeeping edits? MODIFIED with an ops[[/g]]
31
+ [[g]] block, applied mechanically (all ops or none):[[/g]]
32
+ [[g]] ```ops[[/g]]
33
+ [[g]] set-header Implementation: verified — `src/x.js`[[/g]]
34
+ [[g]] bump-version minor[[/g]]
35
+ [[g]] set-criterion 1: verified[[/g]]
36
+ [[g]] append-criterion [unverified] new signal — verified by `test/y.test.js`[[/g]]
37
+ [[g]] append-requirement event: When <trigger>, the system shall <action>.[[/g]]
38
+ [[g]] replace-requirement ubiquitous 2: The system shall <action>.[[/g]]
39
+ [[g]] ```[[/g]]
40
+ [[g]] append-* ops number/position at APPLY time, so concurrent changes[[/g]]
41
+ [[g]] appending to the same spec never collide. Only free-prose rewrites[[/g]]
42
+ [[g]] (Purpose, Maturity, ...) stay a by-hand merge.[[/g]]
43
+ {{FROM_DIFF_DELTA_NOTE}}
44
+
45
+ 4. Replace the placeholder tasks in .doctrina/changes/{{CHANGE_ID}}/tasks.md
46
+ with small, checkable implementation tasks (a few hours each, max),
47
+ and record the change's What/Scope in its proposal.md. Do this BEFORE
48
+ implementing — analyze and close refuse a change whose scaffold
49
+ placeholders were never replaced, and `change tick` will not tick them.
50
+
51
+ 5. Implement task by task, checking each box as it lands. Advance the
52
+ spec's Implementation: planned → partial → implemented as code lands.
53
+ If the prompt is genuinely ambiguous, ask the user before assuming.
54
+
55
+ 6. ADR checkpoint — does this change decide something structural
56
+ (an architecture, a boundary, a trade-off a future session must
57
+ not relitigate)? If yes: [[c]]doctrina decision new "<title>"[[/c]] now,
58
+ before closing — the definition of done requires it recorded.
59
+ [[g]] (close re-checks this: it warns when the change touches capabilities[[/g]]
60
+ [[g]] cited by an accepted ADR — amend via decision supersede, not silence.)[[/g]]
61
+ Touching an integration surface (ports, env vars, public endpoints)?
62
+ Own it in a contract: [[c]]doctrina contract new <id>[[/c]] · [[c]]doctrina contract check[[/c]].
63
+
64
+ 7. Close in one attested pass (preferred — runs every gate and stops
65
+ at the first failure with the exact rerun command):
66
+ [[c]]doctrina close {{CHANGE_ID}}[[/c]]
67
+ [[g]] It self-reviews on the way through: the close runs `doctrina review`[[/g]]
68
+ [[g]] before the apply, where its findings can still change what gets[[/g]]
69
+ [[g]] written. Advisory — it reports and the close continues.[[/g]]
70
+ [[g]] (equivalent, step by step: [[/g]][[g]]analyze → change apply → verify → coverage → trace → change archive → validate)[[/g]]
71
+ Before it: check the proposal's ## Verification boxes and every task,
72
+ closing steps included, and bump Implementation to verified.
73
+
74
+ 8. [[c]]doctrina next[[/c]] for the follow-up.
75
+ [[g]] If this change taught a reusable lesson (a fix you'd hate to relearn,[[/g]]
76
+ [[g]] a recurring convention), capture it: [[/g]][[c]]doctrina skill new <slug>[[/c]][[g]].[[/g]]