adr-kit 0.13.0 → 0.14.1

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 (94) hide show
  1. package/README.md +62 -211
  2. package/README.zh.md +58 -174
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +41 -25
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/archive.d.ts +2 -0
  7. package/dist/commands/archive.d.ts.map +1 -0
  8. package/dist/commands/archive.js +62 -0
  9. package/dist/commands/archive.js.map +1 -0
  10. package/dist/commands/completion.d.ts.map +1 -1
  11. package/dist/commands/completion.js +5 -4
  12. package/dist/commands/completion.js.map +1 -1
  13. package/dist/commands/{accept.d.ts → implement.d.ts} +2 -2
  14. package/dist/commands/implement.d.ts.map +1 -0
  15. package/dist/commands/implement.js +42 -0
  16. package/dist/commands/implement.js.map +1 -0
  17. package/dist/commands/init.js +3 -3
  18. package/dist/commands/init.js.map +1 -1
  19. package/dist/commands/instructions.d.ts.map +1 -1
  20. package/dist/commands/instructions.js +24 -81
  21. package/dist/commands/instructions.js.map +1 -1
  22. package/dist/commands/list.d.ts.map +1 -1
  23. package/dist/commands/list.js +9 -14
  24. package/dist/commands/list.js.map +1 -1
  25. package/dist/commands/propose.d.ts.map +1 -1
  26. package/dist/commands/propose.js +9 -10
  27. package/dist/commands/propose.js.map +1 -1
  28. package/dist/commands/{decide.d.ts → record.d.ts} +2 -2
  29. package/dist/commands/record.d.ts.map +1 -0
  30. package/dist/commands/{decide.js → record.js} +6 -6
  31. package/dist/commands/{decide.js.map → record.js.map} +1 -1
  32. package/dist/commands/reject.d.ts +1 -1
  33. package/dist/commands/reject.d.ts.map +1 -1
  34. package/dist/commands/reject.js +24 -8
  35. package/dist/commands/reject.js.map +1 -1
  36. package/dist/commands/show.d.ts.map +1 -1
  37. package/dist/commands/show.js +2 -16
  38. package/dist/commands/show.js.map +1 -1
  39. package/dist/commands/status.d.ts.map +1 -1
  40. package/dist/commands/status.js +6 -17
  41. package/dist/commands/status.js.map +1 -1
  42. package/dist/commands/supersede.d.ts.map +1 -1
  43. package/dist/commands/supersede.js +44 -10
  44. package/dist/commands/supersede.js.map +1 -1
  45. package/dist/commands/validate.d.ts +1 -1
  46. package/dist/commands/validate.d.ts.map +1 -1
  47. package/dist/commands/validate.js +11 -3
  48. package/dist/commands/validate.js.map +1 -1
  49. package/dist/core/adr.d.ts +22 -20
  50. package/dist/core/adr.d.ts.map +1 -1
  51. package/dist/core/adr.js +31 -10
  52. package/dist/core/adr.js.map +1 -1
  53. package/dist/core/archive-seal.d.ts +48 -0
  54. package/dist/core/archive-seal.d.ts.map +1 -0
  55. package/dist/core/archive-seal.js +122 -0
  56. package/dist/core/archive-seal.js.map +1 -0
  57. package/dist/core/cli-options.d.ts +2 -2
  58. package/dist/core/cli-options.d.ts.map +1 -1
  59. package/dist/core/cli-options.js +8 -6
  60. package/dist/core/cli-options.js.map +1 -1
  61. package/dist/core/config.d.ts +1 -1
  62. package/dist/core/deliberation.d.ts.map +1 -1
  63. package/dist/core/deliberation.js +2 -3
  64. package/dist/core/deliberation.js.map +1 -1
  65. package/dist/core/git.d.ts +9 -0
  66. package/dist/core/git.d.ts.map +1 -1
  67. package/dist/core/git.js +31 -0
  68. package/dist/core/git.js.map +1 -1
  69. package/dist/core/graph-html.js +5 -5
  70. package/dist/core/graph-html.js.map +1 -1
  71. package/dist/core/graph.d.ts +2 -1
  72. package/dist/core/graph.d.ts.map +1 -1
  73. package/dist/core/graph.js +9 -4
  74. package/dist/core/graph.js.map +1 -1
  75. package/dist/core/repository.d.ts +3 -11
  76. package/dist/core/repository.d.ts.map +1 -1
  77. package/dist/core/repository.js +60 -141
  78. package/dist/core/repository.js.map +1 -1
  79. package/dist/core/templates.d.ts +6 -7
  80. package/dist/core/templates.d.ts.map +1 -1
  81. package/dist/core/templates.js +13 -14
  82. package/dist/core/templates.js.map +1 -1
  83. package/dist/core/tool-integrations.d.ts.map +1 -1
  84. package/dist/core/tool-integrations.js +77 -422
  85. package/dist/core/tool-integrations.js.map +1 -1
  86. package/dist/core/validate.d.ts +19 -6
  87. package/dist/core/validate.d.ts.map +1 -1
  88. package/dist/core/validate.js +295 -91
  89. package/dist/core/validate.js.map +1 -1
  90. package/package.json +1 -1
  91. package/dist/commands/accept.d.ts.map +0 -1
  92. package/dist/commands/accept.js +0 -42
  93. package/dist/commands/accept.js.map +0 -1
  94. package/dist/commands/decide.d.ts.map +0 -1
package/README.md CHANGED
@@ -17,18 +17,12 @@
17
17
  <img src="./assets/readme-banner.png" alt="ADR Kit" width="100%" />
18
18
  </p>
19
19
 
20
- ADR Kit turns architecture decisions into plain Markdown files with a
21
- machine-checkable lifecycle. Decisions are durable records
22
- (**accepted / superseded**); proposals are ephemeral drafts that either become
23
- a decision or vanish. It borrows the spec-driven spirit of
24
- [OpenSpec](https://github.com/Fission-AI/OpenSpec)
25
- and the decision-record discipline of agent-native codebases: every record
26
- must say what problem it solves, what it chose, and what it gave up.
27
-
28
- - fluid not rigid
29
- - plain Markdown
30
- - one decision, one file
31
- - built for agents and humans alike
20
+ ADR Kit stores architecture decisions as plain Markdown across four lifecycle directories. It is an independent, agent-friendly decision-record tool: proposals are unshipped, implemented records describe shipped choices, rejections keep the anti-patterns worth avoiding, and archives preserve frozen history.
21
+
22
+ - Plain Markdown and YAML front matter
23
+ - One choice per file, with explicit alternatives
24
+ - Stable ADR numbers assigned only when work ships
25
+ - Built for agents and humans
32
26
 
33
27
  ## Quick start
34
28
 
@@ -38,240 +32,97 @@ Requires Node.js 20.19 or later.
38
32
  npm install -g adr-kit
39
33
  cd your-project
40
34
  adrkit init
41
- adrkit decide "Use SQLite for session storage" --raised-by human --decided-by human
35
+ adrkit propose "Use SQLite for session storage"
36
+ # Fill the proposal; after the work ships:
37
+ adrkit implement "Use SQLite for session storage" --raised-by human --decided-by human
38
+ adrkit validate
42
39
  ```
43
40
 
44
- `adrkit init` creates an `adr/` directory:
41
+ For an architectural choice already shipped, use `adrkit record "<title>" --raised-by human --decided-by human` instead.
45
42
 
46
43
  ```text
47
44
  adr/
48
- ├── config.yaml # project context and per-status rules
49
- ├── README.md # repository conventions
50
- ├── .gitignore # keeps adr/.drafts/ out of git
51
- └── decisions/ # decisions, numbered N, immutable history
45
+ ├── config.yaml
46
+ ├── README.md
47
+ ├── proposed/ # dated, unnumbered, unshipped
48
+ ├── implemented/ # numbered, shipped, active guidance
49
+ ├── rejected/ # dated, unnumbered, anti-patterns to avoid
50
+ └── archived/ # numbered, frozen history
52
51
  ```
53
52
 
54
- `adrkit decide` is the default path: it records an already-made decision
55
- directly. Proposals are the exception, used only when a decision still needs
56
- review. They are ephemeral drafts in `adr/.drafts/`: `adrkit propose` creates
57
- one, `adrkit accept` promotes it to a numbered decision, and `adrkit reject`
58
- discards it without leaving a record. Rejection is recorded in a decision's
59
- `Alternatives considered`, never as a standalone record.
60
-
61
- Fill in the decision, then:
62
-
63
- ```bash
64
- adrkit validate
65
- adrkit list
66
- ```
53
+ An uncommitted proposal is a local working-tree draft; committing it shares it. There is no separate `.drafts/`. A choice settled by discussion remains proposed until shipped. `adrkit reject --reason` records a declined proposal's anti-pattern as a durable terminal: keep it, and remove it only when another record owns the warning it blocks. `adrkit supersede --by` archives a fully replaced implemented decision; `adrkit archive --reason` retires one whose current behavior has another authoritative owner. Never archive by age or quota. Partial replacement leaves still-relevant guidance active. Both moves seal the archived file in `adr/archived/MANIFEST.json`; `adrkit validate` checks the seal and `adrkit validate --base <git-ref>` proves the archive only grows.
67
54
 
68
55
  ## Tell your agent
69
56
 
70
- Paste this into any AI coding agent to record key decisions automatically:
71
-
72
- ```text
73
- Use github.com/luochang212/adr-kit in this repository to automatically record key decisions. Prefer `adrkit decide`; use `adrkit propose` only when a decision still needs review. Every record declares two flags: `--raised-by` (who put the decision on the table) and `--decided-by` (whose judgment settled it). Use `human` when a person determined it, `agent` when it came from your own judgment, even if a person let it through.
74
- ```
75
-
76
- To use decisions in later coding tasks, add the [reading rule](docs/workflow.md#read-decisions-before-coding)
77
- to the project's `AGENTS.md` (and `CLAUDE.md` for Claude Code teams). Start tasks
78
- with `adrkit list` and `adrkit show <N>` to read the existing decisions, then
79
- check them against current code and requirements. The init skill guides this
80
- setup; existing projects should run `adrkit update` and add the rule too.
81
- The CLI does not edit project instruction files automatically.
82
- Record only architectural choices that constrain future development and whose
83
- rationale is not apparent from code alone; routine fixes need no ADR. See
84
- [when to record](docs/workflow.md#when-to-record).
57
+ Add the [reading rule](docs/workflow.md#read-decisions-before-coding) to `AGENTS.md` or `CLAUDE.md`. At task start, run `adrkit list`: read the relevant `implemented/` records in full, check `proposed/` for intent and `rejected/` for the bad cases they warn against, and consult `archived/` only for cited history. Do not filter by title alone. The `adrkit-init` skill guides setup; `adrkit update` refreshes installed skills. Before creating a record, compare it with active records covering the same choice and resolve a full replacement with `adrkit supersede --by` in the same change; when shipping or reviewing, use the `adrkit-implement` and `adrkit-review` skills to keep realization facts aligned with shipped code.
85
58
 
86
59
  ## Commands
87
60
 
88
61
  ```text
89
62
  adrkit init [path] [--tools <list>] [--workflows <list>]
90
- Initialize an ADR Kit repository
91
- adrkit decide <title> --raised-by <human|agent> --decided-by <human|agent>
92
- Record an already-made decision (default path)
93
- adrkit propose <title> Create an ephemeral proposal draft (only when review is needed)
94
- adrkit accept <name> --raised-by <human|agent> --decided-by <human|agent>
95
- Promote a draft to a decision (assigns N)
96
- adrkit reject <name> [--reason <text>] Discard a draft (leaves no record)
97
- adrkit supersede <name> --by <name> Mark an accepted decision as superseded
98
- adrkit list List decisions and pending drafts
99
- adrkit show <name> Show a decision or draft
100
- adrkit status Show lifecycle counts and validity
101
- adrkit instructions Print the next step; flag pending drafts as ready or needing work
102
- adrkit validate [name] [--all] Validate one record or the repository
63
+ adrkit propose <title>
64
+ adrkit implement <name> --raised-by <human|agent> --decided-by <human|agent>
65
+ adrkit record <title> --raised-by <human|agent> --decided-by <human|agent>
66
+ adrkit reject <name> --reason <text>
67
+ adrkit archive <name> --reason <text>
68
+ adrkit supersede <old> --by <new>
69
+ adrkit list
70
+ adrkit show <name>
71
+ adrkit status
72
+ adrkit instructions
73
+ adrkit validate [name] [--all] [--base <git-ref>]
103
74
  adrkit update [--tools <list>] [--workflows <list>]
104
- Rewrite AI tool integrations
105
- adrkit config Print the current configuration
75
+ adrkit config
106
76
  adrkit graph [--mermaid|--dot|--text|--html] [--formal-only] [--tag <tag>] [--out <path>]
107
- Emit the decision relationship graph
108
- adrkit tree <name> [--mermaid|--text|--html] Render a record's deliberation tree
109
- adrkit completion <bash|zsh|fish> Print a shell completion script
110
- adrkit version Print the version
77
+ adrkit tree <name> [--mermaid|--text|--html]
78
+ adrkit completion <bash|zsh|fish>
79
+ adrkit version
111
80
  ```
112
81
 
113
- > [!IMPORTANT]
114
- > Integrations install into the open [`.agents/`](https://agents.md/) standard
115
- > by default: one set of skills and slash commands every mainstream agent
116
- > reads. Claude Code is the one holdout: it even [closed the AGENTS.md support
117
- > request](https://github.com/anthropics/claude-code/issues/6235), and Shopify's
118
- > CEO [publicly threatened to ban it over this](https://thenewstack.io/shopify-claude-code-agentsmd/).
119
- > If your team uses Claude Code, pass `--tools claude` to also install
120
- > `.claude/` copies; an exception we carry until Anthropic adopts the standard.
121
-
122
- > [!TIP]
123
- > Every integration ships all nine workflow skills by default. A small
124
- > repository that only records decisions can pass
125
- > `--workflows init,decide,validate` to install a lean subset; the choice is
126
- > recorded in `adr/config.yaml`, `adrkit update` keeps it, and
127
- > `--workflows all` restores the full set.
128
-
129
- `<name>` resolves by title, file name, or decision number (`1`).
130
-
131
- ## Docs
132
-
133
- | Document | Content |
134
- | --- | --- |
135
- | [CLI reference](https://github.com/luochang212/adr-kit/blob/main/docs/cli.md) | Command reference with arguments and output shapes |
136
- | [Record format](https://github.com/luochang212/adr-kit/blob/main/docs/record-format.md) | ADR file format and validation rules |
137
- | [Workflow](https://github.com/luochang212/adr-kit/blob/main/docs/workflow.md) | Lifecycle from proposal to decision |
138
- | [Agent skills](https://github.com/luochang212/adr-kit/blob/main/skills/README.md) | Agent skills that drive the `adrkit` CLI |
82
+ By default, integrations install into `.agents/`. Pass `--tools claude` for additional `.claude/` copies, or `--tools none` to install none. `--workflows` selects a subset such as `init,propose,implement,validate`.
139
83
 
140
84
  ## Record format
141
85
 
142
- Every record is YAML front matter followed by a Markdown body:
86
+ A shipped decision is `adr/implemented/N-slug.md`:
143
87
 
144
88
  ```markdown
145
89
  ---
146
- status: accepted
147
- date: 2026-08-19
90
+ status: implemented
91
+ date: 2026-09-25
148
92
  raised-by: human
149
93
  decided-by: human
150
- created: 2026-08-17
151
- commit: abc1234
152
- tags: [frontend]
94
+ created: 2026-09-24
95
+ tags: [storage]
153
96
  ---
154
97
 
155
98
  # ADR: 1 Use SQLite for session storage
156
99
 
157
100
  ## Problem
101
+
102
+ ...
103
+
104
+ ## Decision
105
+
106
+ ...
107
+
108
+ ## Alternatives considered
109
+
158
110
  ...
159
- ```
160
111
 
161
- The `date` field records when the current status was reached; the CLI
162
- stamps it at every lifecycle move, alongside the git `commit` the decision
163
- was recorded against. `created` is the birth date, stamped once and never
164
- re-stamped, so the time axis survives later lifecycle moves. Optional
165
- `tags` (kebab-case keywords) let `adrkit graph` group and filter decisions
166
- by theme. Decisions are immutable history; the current facts
167
- live in code, not in the record.
168
-
169
- `accepted` denotes a recorded decision, not proof of human review.
170
- `raised-by` and `decided-by` are each `human` or `agent`, declared when
171
- `decide` or `accept` runs: `raised-by` is who put the decision on the table,
172
- and `decided-by` is whose judgment settled it. For `decided-by`, `human`
173
- means a person determined the direction (they stated it, changed a proposal into
174
- what shipped, or you are recording one they made earlier), `agent` when it came
175
- from the agent's own judgment, including when a person only let it through. The
176
- CLI records the declarations without inferring or verifying them, so the fields
177
- do not establish who chose or authorized the decision; when who proposed and who
178
- approved matters, write it in the body. `supersede` preserves both original
179
- values. See the
180
- [record format reference](docs/record-format.md) for limitations. Identity
181
- stays in git.
182
-
183
- - **Decisions** (`adr/decisions/N-slug.md`) are `accepted` or `superseded`
184
- and require `Problem`, `Decision`, `Alternatives considered`, and
185
- `Consequences`; proposal-era headings are rejected by `validate`.
186
- - **Drafts** (`adr/.drafts/YYYY-MM-DD-slug.md`) are ephemeral proposals with
187
- `status: proposed`, require `Problem`, `Proposal`, `Alternatives
188
- considered`, `Acceptance criteria`, and `Risks`, and are never checked by
189
- `validate`: `adrkit accept` validates a draft right before promoting it.
190
- A required section counts as written only when it has text outside HTML
191
- comments, so an unfilled `<!--` placeholder never passes.
192
- - **Rejected** ideas are not standalone records: a decision's
193
- `Alternatives considered` documents what was considered and why it lost.
194
- - **Superseded** decisions stay in `adr/decisions/` as history, with the
195
- replacing decision in the front matter: `status: superseded` plus
196
- `superseded-by: N`.
197
- `adrkit supersede <old> --by <new>` performs the rewrite; `validate`
198
- checks that the complete replacement chain exists, has no cycles, and
199
- ends at an accepted decision. Historical links are preserved.
200
-
201
- `adrkit accept` performs the mechanical rewrite a lifecycle move always
202
- owed: `## Proposal` becomes `## Decision`, and `Acceptance criteria` plus
203
- `Risks` are folded into `## Consequences`.
204
-
205
- A decision may also carry an optional `## Deliberation` appendix: the design
206
- tree behind the choice, stored as a nested Markdown list whose nodes may be
207
- tagged `[settled]`, `[rejected]`, or `[open]`. A follow-up question is
208
- nested under the node that raised it, so related questions run deeper and
209
- unrelated ones stay flat. Render it with `adrkit tree <name>` (text by default,
210
- `--mermaid` for a graph, `--html` for an offline interactive card tree). The
211
- `adrkit-grill` workflow produces that tree and records every decision the
212
- session settles. The whole set renders as an interactive offline decision map with
213
- `adrkit graph --html`, which marks the decisions that carry a tree. Ask your
214
- agent to visualize a recorded decision or the whole set with `adrkit-visualize`;
215
- it uses the built-in renderer, opens the result in your default browser, and
216
- returns an HTML file link. Ask for a file only to skip opening the browser. If
217
- opening is unavailable or fails, the agent explains and keeps the link. HTML is
218
- not a default grilling deliverable.
219
- Run `adrkit update` to refresh installed skills.
220
-
221
- ```sh
222
- adrkit tree 7 --html > "adr-7.html"
112
+ ## Consequences
113
+
114
+ ...
223
115
  ```
224
116
 
225
- ## Compatibility with other tools
226
-
227
- ADR Kit owns one directory, `adr/`, and reads and validates only its own
228
- files, so it can share a repository with any tool that does not collide
229
- with that layout. Its agent skills are namespaced per tool (`adrkit-*`),
230
- and `adrkit update` only rewrites its own integrations.
231
-
232
- | Tool | Role | Relationship |
233
- |---|---|---|
234
- | [OpenSpec](https://github.com/Fission-AI/OpenSpec) | Forward-looking: specifies what to build | Complementary: specs vs records |
235
- | [Changesets](https://changesets.dev) | Release tooling: versions and changelog | Orthogonal: cite the ADR number in the changeset body |
236
-
237
- When a change makes an architectural decision that should outlive the
238
- change, record it as an ADR.
239
-
240
- ## Sources of Inspiration
241
-
242
- ADR Kit stands on two projects, in two different roles:
243
-
244
- - **[OpenSpec](https://github.com/Fission-AI/OpenSpec)** shaped *how* the
245
- tool is built: an agent-first CLI whose instructions are installed as
246
- agent skills, a deterministic `validate`, and a "fluid not rigid" workflow.
247
- Like OpenSpec, ADR Kit
248
- *steers* agents: session-visible skills rather than imposing hard phase
249
- gates or mandating that every change be recorded.
250
- - **[deepseek-harness](https://github.com/deepseek-ai/deepseek-harness)**
251
- gave ADR Kit *what a record is*. Its **Agent Notes**: plain Markdown
252
- with a `Status:` line, lifecycle folders
253
- (`proposed` → `implemented` → `rejected`, plus a frozen archive), and a
254
- `Problem` / `Proposal`·`Decision` / `Alternatives considered` /
255
- `Consequences` skeleton: that is the direct ancestor of the ADR Kit record
256
- format.
257
-
258
- Adapted, not copied. Accepted records carry a `N` number, `supersede`
259
- retires a decision in place, and `accept` mechanically rewrites a proposal
260
- into a decision. Records are immutable once accepted: a decision record is
261
- history, and current facts live in code, not in the record.
262
-
263
- ## Philosophy
264
-
265
- - **The record is the source of truth.** Code comments rot, docs drift; an
266
- ADR that says what was decided and what was given up stays useful.
267
- - **Alternatives are mandatory.** A decision recorded without what it beat
268
- invites re-litigation.
269
- - **Lifecycle is mechanical, not editorial.** Promoting a draft and retiring
270
- an accepted decision are commands (`accept`, `supersede`), and `validate`
271
- enforces the resulting shape.
272
- - **Agents are first-class users.** The record is the interface: plain
273
- Markdown with YAML front matter an agent reads directly, at predictable
274
- paths, with `validate` as the machine check.
117
+ Proposals use dated filenames and `Problem`, `Proposal`, `Alternatives considered`, `Acceptance criteria`, and `Risks`. The CLI stamps `date` on lifecycle moves; `created` preserves the birth date. `raised-by` and `decided-by` declare who introduced and settled a shipped choice, not who ran the command or authorized deployment. The CLI cannot verify shipping or provenance. `tags` remain the thematic classification; no class directory is needed. `adrkit validate` checks all four folders; fresh templates intentionally fail until filled.
118
+
119
+ An implemented record may refresh factual paths, symbols, or defaults, but not rewrite the choice or rationale into another decision. A changed choice needs a new record and relationship. Full supersession stamps `superseded-by: N` and moves the old record to `archived/`. Archived records keep their numbers and are historical, not current authority. The graph includes numbered history; `## Deliberation` optionally preserves the design tree.
120
+
121
+ See [record format](docs/record-format.md), [workflow](docs/workflow.md), and [CLI reference](docs/cli.md).
122
+
123
+ ## Sources of inspiration
124
+
125
+ [DeepSeek Harness Agent Notes](https://github.com/deepseek-ai/deepseek-harness) inspired the lifecycle directories and the distinction between proposed, implemented, rejected, and archived. ADR Kit keeps its own provenance fields, numbered decisions, validation, deliberation tree, and graph. OpenSpec is not part of ADR Kit's runtime or governance model.
275
126
 
276
127
  ## Development
277
128
 
@@ -284,4 +135,4 @@ npm run build
284
135
 
285
136
  ## License
286
137
 
287
- [MIT](https://github.com/luochang212/adr-kit/blob/main/LICENSE)
138
+ MIT.
package/README.zh.md CHANGED
@@ -17,228 +17,112 @@
17
17
  <img src="./assets/readme-banner.png" alt="ADR Kit" width="100%" />
18
18
  </p>
19
19
 
20
- ADR Kit 把架构决策变成纯 Markdown 文件,并带有机检的生命周期。决策是持久记录
21
- (**accepted / superseded**);提案是临时草稿,要么变成决策、要么消失。它借鉴了
22
- [OpenSpec](https://github.com/Fission-AI/OpenSpec) 的 spec-driven 思路,以及
23
- agent 原生代码库的决策记录纪律:每条记录都必须说明它解决什么问题、选择了什么、
24
- 放弃了什么。
20
+ ADR Kit 用纯 Markdown 记录架构决策,并以四个目录表示完整生命周期:`proposed/` 是未交付提案,`implemented/` 是已交付且仍有指导意义的决策,`rejected/` 保存待避免的反例(正式否决),`archived/` 保存最低价值的冻结历史。它是独立的、面向人与 agent 的决策记录工具。
25
21
 
26
- - 灵活而不僵化
27
- - 纯 Markdown
28
- - 一个决策一个文件
29
- - 同时服务人类和 agent
22
+ - 纯 Markdown 与 YAML front matter
23
+ - 一个选择一个文件,含明确的备选
24
+ - 仅在工作交付时分配稳定 ADR 编号
25
+ - 面向 agent 与人类
30
26
 
31
27
  ## 快速开始
32
28
 
33
- 需要 Node.js 20.19 或更高版本。
29
+ 需要 Node.js 20.19 或更新版本。
34
30
 
35
31
  ```bash
36
32
  npm install -g adr-kit
37
33
  cd your-project
38
34
  adrkit init
39
- adrkit decide "使用 SQLite 存储会话" --raised-by human --decided-by human
35
+ adrkit propose "使用 SQLite 存储会话"
36
+ # 填写提案,实际交付后:
37
+ adrkit implement "使用 SQLite 存储会话" --raised-by human --decided-by human
38
+ adrkit validate
40
39
  ```
41
40
 
42
- `adrkit init` 会创建 `adr/` 目录:
41
+ 已交付但尚未记录的选择可直接用 `adrkit record "<标题>" --raised-by human --decided-by human`。
43
42
 
44
43
  ```text
45
44
  adr/
46
- ├── config.yaml # 项目上下文与分状态规则
47
- ├── README.md # 仓库约定
48
- ├── .gitignore # 让 adr/.drafts/ 不进 git
49
- └── decisions/ # 决策,按 N 编号,不可变历史
50
- ```
51
-
52
- `adrkit decide` 是默认路径,直接记录已成定局的决策。需要评审时,提案是
53
- `adr/.drafts/` 里的临时草稿:`adrkit propose` 创建一条,`adrkit accept` 把它
54
- 提升为编号决策,`adrkit reject` 直接丢弃、不留下任何记录。拒绝记录在决策的
55
- `Alternatives considered` 里,从不是独立记录。
56
-
57
- 填写决策内容后:
58
-
59
- ```bash
60
- adrkit validate
61
- adrkit list
45
+ ├── config.yaml
46
+ ├── README.md
47
+ ├── proposed/ # 按日期命名,未编号,尚未交付
48
+ ├── implemented/ # 已编号、已交付,当前指导
49
+ ├── rejected/ # 按日期命名,待避免的反例
50
+ └── archived/ # 保留编号,冻结历史
62
51
  ```
63
52
 
64
- ## 接入你的 Agent
65
-
66
- 把下面这行贴给任意 AI 编码 Agent,它就会自动把关键决策记录成 ADR:
53
+ 未提交的提案只是本地工作树草稿;Git 提交后成为共享提案,不另设 `.drafts/`。讨论已定方向但尚未交付时仍在 `proposed/`。正式否决用 `adrkit reject --reason` 记为稳定的反例终态:保留它,只有当另一条记录接管了它挡住的错误时才移除(否决记录无编号、不入封存)。完整替代用 `adrkit supersede --by` 并自动归档旧记录;当现状已有其他权威来源、原决策不再指导未来时,可用 `adrkit archive --reason` 归档。不要按年龄或配额归档;部分替代仍保留有效的现行记录。两次转移都会把归档文件封存进 `adr/archived/MANIFEST.json`;`adrkit validate` 检查封存,`adrkit validate --base <git-ref>` 证明归档只增不改。
67
54
 
68
- ```text
69
- 在本仓库用 github.com/luochang212/adr-kit 自动记录关键决策。优先用 `adrkit decide`,仅当决策还需评审时才用 `adrkit propose`。每条记录都要声明两个值:`raised-by`(谁把决策提上台面)与 `decided-by`(谁的判断定下它);方向由人决定用 `human`,由你自己的判断得出用 `agent`,即使人只是放行。
70
- ```
55
+ ## 告诉 Agent
71
56
 
72
- 让后续编码任务也用上决策:在项目 `AGENTS.md`(Claude Code 团队也包括
73
- `CLAUDE.md`)加入[查阅规则](docs/zh/workflow.md#编码前查阅决策)。任务开始时用
74
- `adrkit list`、`adrkit show <N>` 读完现有决策,结合代码和新需求判断是否仍适用。
75
- 初始化技能会引导补入规则;已有项目运行 `adrkit update` 后也需补入。
76
- CLI 不会自动修改项目指令文件。只有持续约束后续开发、且理由难以从代码直接
77
- 看出的架构选择才值得记录;普通修复无需 ADR,详见[记录门槛](docs/zh/workflow.md#何时值得记录)。
57
+ 将[任务开始阅读规则](docs/zh/workflow.md#任务开始前阅读决策)加入 `AGENTS.md` 或 `CLAUDE.md`。任务开始时先运行 `adrkit list`:四个目录是一份上下文预算——完整阅读相关的 `implemented/`;检查 `proposed/` 的意图与 `rejected/` 的反例;`archived/` 仅在任务明确引用历史时读。不能只看标题判断相关性。`adrkit-init` 指导配置,`adrkit update` 刷新已安装技能。创建记录前,先与涉及同一选择的现行记录比较,完整替代在同一次变更中用 `adrkit supersede --by` 解析;交付或审查时用 `adrkit-implement` 和 `adrkit-review` 技能保持实现事实与已交付代码一致。
78
58
 
79
59
  ## 命令
80
60
 
81
61
  ```text
82
62
  adrkit init [path] [--tools <list>] [--workflows <list>]
83
- 初始化 ADR Kit 仓库
84
- adrkit decide <title> --raised-by <human|agent> --decided-by <human|agent>
85
- 直接记录已做的决策(默认路径)
86
- adrkit propose <title> 仅当决策还需评审时,创建临时提案草稿
87
- adrkit accept <name> --raised-by <human|agent> --decided-by <human|agent>
88
- 把草稿提升为决策(分配 N 编号)
89
- adrkit reject <name> [--reason <text>] 丢弃草稿(不留记录)
90
- adrkit supersede <name> --by <name> 标记已接受决策被新决策取代
91
- adrkit list 列出决策与待决草稿
92
- adrkit show <name> 查看决策或草稿
93
- adrkit status 查看生命周期计数与校验状态
94
- adrkit instructions 查看下一步;标注待决草稿已就绪或需修改
95
- adrkit validate [name] [--all] 校验单条记录或整个仓库
63
+ adrkit propose <title>
64
+ adrkit implement <name> --raised-by <human|agent> --decided-by <human|agent>
65
+ adrkit record <title> --raised-by <human|agent> --decided-by <human|agent>
66
+ adrkit reject <name> --reason <text>
67
+ adrkit archive <name> --reason <text>
68
+ adrkit supersede <old> --by <new>
69
+ adrkit list
70
+ adrkit show <name>
71
+ adrkit status
72
+ adrkit instructions
73
+ adrkit validate [name] [--all] [--base <git-ref>]
96
74
  adrkit update [--tools <list>] [--workflows <list>]
97
- 重写 AI 工具集成文件
98
- adrkit config 查看当前配置
75
+ adrkit config
99
76
  adrkit graph [--mermaid|--dot|--text|--html] [--formal-only] [--tag <tag>] [--out <path>]
100
- 输出决策关系图
101
- adrkit tree <name> [--mermaid|--text|--html] 渲染记录的 deliberation 树
102
- adrkit completion <bash|zsh|fish> 打印 shell 补全脚本
103
- adrkit version 查看版本
77
+ adrkit tree <name> [--mermaid|--text|--html]
78
+ adrkit completion <bash|zsh|fish>
79
+ adrkit version
104
80
  ```
105
81
 
106
- > [!IMPORTANT]
107
- > 集成默认写入开放的 [`.agents/`](https://agents.md/) 标准:一套技能和斜杠
108
- > 命令,所有主流 Agent 通用。Claude Code 是唯一的例外:它不仅[关闭了
109
- > AGENTS.md 支持请求](https://github.com/anthropics/claude-code/issues/6235),
110
- > 还让 [Shopify CEO 公开放话要因此禁用它](https://thenewstack.io/shopify-claude-code-agentsmd/)。
111
- > 如果你的团队用 Claude Code,加 `--tools claude` 会同时安装 `.claude/`
112
- > 副本;这个例外我们一直背到 Anthropic 采纳标准为止。
113
-
114
- > [!TIP]
115
- > 集成默认安装全部九个工作流技能。只记录决策的小仓库可传
116
- > `--workflows init,decide,validate` 装精简子集;选择会写入
117
- > `adr/config.yaml`,`adrkit update` 会保持,`--workflows all` 恢复全套。
118
-
119
- `<name>` 支持按标题、文件名或决策编号(`1`)查找。
120
-
121
- ## 文档
122
-
123
- | 文档 | 内容 |
124
- | --- | --- |
125
- | [CLI 参考](https://github.com/luochang212/adr-kit/blob/main/docs/zh/cli.md) | 命令参考:参数与输出形态 |
126
- | [记录格式](https://github.com/luochang212/adr-kit/blob/main/docs/zh/record-format.md) | ADR 文件格式与校验规则 |
127
- | [工作流](https://github.com/luochang212/adr-kit/blob/main/docs/zh/workflow.md) | 从提案到决策的生命周期 |
128
- | [Agent 技能](https://github.com/luochang212/adr-kit/blob/main/skills/README.md) | 驱动 `adrkit` CLI 的 agent 技能 |
82
+ 默认把集成安装到 `.agents/`;`--tools claude` 另装 `.claude/`,`--tools none` 不安装。可用 `--workflows init,propose,implement,validate` 选子集。
129
83
 
130
84
  ## 记录格式
131
85
 
132
- 每条记录都是 YAML front matter 加 Markdown 正文:
86
+ 已交付决策在 `adr/implemented/N-slug.md`:
133
87
 
134
88
  ```markdown
135
89
  ---
136
- status: accepted
137
- date: 2026-08-19
90
+ status: implemented
91
+ date: 2026-09-25
138
92
  raised-by: human
139
93
  decided-by: human
140
- created: 2026-08-17
141
- commit: abc1234
142
- tags: [frontend]
94
+ created: 2026-09-24
95
+ tags: [storage]
143
96
  ---
144
97
 
145
98
  # ADR: 1 使用 SQLite 存储会话
146
99
 
147
100
  ## Problem
101
+
148
102
  ...
149
- ```
150
103
 
151
- `date` 字段记录当前状态达成的日期;CLI 在每次生命周期迁移时自动盖章,
152
- 同时盖上该决策对应的 git `commit`。`created` 是创建日期,创建时盖一次、
153
- 永不重盖,让时间轴在后续生命周期迁移后依然成立。可选的 `tags`(kebab-case
154
- 关键词)让 `adrkit graph` 按主题分组和过滤决策。决策是不可变历史;当前
155
- 事实以代码为准,不在记录里。
156
-
157
- `accepted` 表示正式记录的决定,不代表人已审阅批准。`raised-by` 与 `decided-by`
158
- 取值都是 `human` 或 `agent`,在 `decide` 或 `accept` 时声明:`raised-by` 是
159
- 谁把决策提上台面,`decided-by` 是谁的判断定下了它。`decided-by` 取 `human`
160
- 表示方向由人决定(人说出的、人把 agent 的提案改成最终落地方案的、或人此前定过
161
- 而现在只是补记的),取 `agent` 表示由 AI 自主判断得出,包括人只是放行的情况。
162
- CLI 既不推断也不校验,只记录声明,所以它不能证明是谁自主拍板或授权;谁改写、
163
- 谁批准写进正文。`supersede` 保留两个原值。局限见
164
- [记录格式参考](docs/zh/record-format.md)。身份留在 git 里。
165
-
166
- - **决策**(`adr/decisions/N-slug.md`)是 `accepted` 或 `superseded`,
167
- 需要 `Problem`、`Decision`、`Alternatives considered`、`Consequences`;
168
- `validate` 会拒绝提案时代的标题出现在已接受决策中。
169
- - **草稿**(`adr/.drafts/YYYY-MM-DD-slug.md`)是 `status: proposed` 的临时
170
- 提案,需要 `Problem`、`Proposal`、`Alternatives considered`、
171
- `Acceptance criteria`、`Risks`,`validate` 不检查它们:`adrkit accept`
172
- 在提升前才校验草稿。必需 section 只有在 HTML 注释之外有文字时才算写了
173
- 内容,未填写的 `<!--` 占位不算通过。
174
- - **被否决**的想法不是独立记录:决策的 `Alternatives considered` 记录了
175
- 考虑过什么、为什么落选。
176
- - **Superseded** 决策保留在 `adr/decisions/` 作为历史,front matter 指向
177
- 取代它的决策:`status: superseded` 加 `superseded-by: N`。
178
- `adrkit supersede <旧> --by <新>` 完成改写;
179
- `validate` 沿完整替代链检查引用均存在、没有循环,且最终到达 accepted 决策;
180
- 保留各次替代的历史链接。
181
-
182
- `adrkit accept` 会自动完成生命周期迁移所要求的改写:`## Proposal` 改为
183
- `## Decision`,`Acceptance criteria` 与 `Risks` 合并进 `## Consequences`。
184
-
185
- 决策还可以携带可选的 `## Deliberation` 附录:记录选择背后的 design tree,
186
- 用嵌套 Markdown 列表存储,节点可标注 `[settled]`、`[rejected]`、`[open]`。
187
- 后续问题嵌在提出它的节点之下,因此相关问题更深、无关问题平铺。用 `adrkit tree
188
- <name>` 渲染(默认文本,加 `--mermaid` 输出图形,加 `--html` 输出离线交互卡片树)。这
189
- 棵树通常来自 `adrkit-grill` 工作流,它记录会话定下的每个决策。
190
- 需要时让 AI 用 `adrkit-visualize` 可视化指定决策或整套决策。它会调用内置渲染器,主动用默认浏览器打开,
191
- 并提供 HTML 文件链接。明确要求“只生成文件”或“不要打开”时不打开浏览器;
192
- 无法打开时会说明原因并保留链接。HTML 不是 grilling 的默认交付。
193
- 整套决策可用 `adrkit graph --html` 渲染为可交互的离线决策地图,并标出带 deliberation 树的决策。
194
- 用 `adrkit update` 更新已安装的技能。
195
-
196
- ```sh
197
- adrkit tree 7 --html > "adr-7.html"
198
- ```
104
+ ## Decision
105
+
106
+ ...
199
107
 
200
- ## 工具兼容性
108
+ ## Alternatives considered
109
+
110
+ ...
111
+
112
+ ## Consequences
113
+
114
+ ...
115
+ ```
201
116
 
202
- ADR Kit 只拥有 `adr/` 这一个目录,并且只读取和校验自己的文件,因此可以
203
- 与任何不占用该布局的工具共处于一个仓库。它的 agent skills 按工具命名空间
204
- 隔离(`adrkit-*`),`adrkit update` 只重写自己的集成文件。
117
+ 提案按日期命名,使用 `Problem`、`Proposal`、`Alternatives considered`、`Acceptance criteria`、`Risks`。`date` 在每次生命周期转移时由 CLI 写入;`created` 保留创建日期。`raised-by` 与 `decided-by` 分别声明谁提出、谁定下已交付选择,不表示谁运行命令或批准部署。CLI 不能验证交付或来源。`tags` 提供主题分类,不额外引入类别目录。`adrkit validate` 检查全部四个目录;新模板未填完时按预期失败。
205
118
 
206
- | 工具 | 角色 | 与 ADR Kit 的关系 |
207
- |---|---|---|
208
- | [OpenSpec](https://github.com/Fission-AI/OpenSpec) | 前瞻:规定要构建什么 | 互补:规格与记录各司其职 |
209
- | [Changesets](https://changesets.dev) | 发布:版本号与 changelog | 正交:changeset 正文引用 ADR 编号 |
119
+ implemented 记录可以更新路径、符号、默认值等已交付事实,但不可悄悄重写选择或理由。选择改变应新建记录并建立关系。完整替代写入 `superseded-by: N`,旧记录移入 `archived/`;归档记录保持编号,只作历史参考。图谱包含编号历史,可选 `## Deliberation` 附录保留思辨树。
210
120
 
211
- 当某个变更做出了应比变更本身更长命的架构决策时,把它记成一条 ADR。
121
+ 详见[记录格式](docs/zh/record-format.md)、[工作流](docs/zh/workflow.md)与[CLI 参考](docs/zh/cli.md)。
212
122
 
213
123
  ## 灵感来源
214
124
 
215
- ADR Kit 站在两个项目之上,两者角色不同:
216
-
217
- - **[OpenSpec](https://github.com/Fission-AI/OpenSpec)** 决定了这个工具*怎么建*:
218
- agent 优先的 CLI、指令以 agent skills 安装、确定性的 `validate`,
219
- 以及"灵活而不僵化"的工作流。和 OpenSpec 一样,
220
- ADR Kit 靠*引导* agent(会话开始可见的 skills),而不是硬性阶段门禁,
221
- 也不强制每次变更都记录。
222
- - **[deepseek-harness](https://github.com/deepseek-ai/deepseek-harness)**
223
- 决定了 ADR Kit 里*记录是什么*。它的 **Agent Notes**:带 `Status:` 行的
224
- 纯 Markdown、生命周期文件夹(`proposed` → `implemented` → `rejected`,
225
- 外加冻结归档)、以及 `Problem` / `Proposal`·`Decision` /
226
- `Alternatives considered` / `Consequences` 骨架,是 ADR Kit 记录格式的
227
- 直接祖先。
228
-
229
- 是改编,不是照抄。已接受记录带 `N` 编号,`supersede` 原地退役一条决策,
230
- `accept` 机械地把提案改写成决策。记录一旦接受就不可变:决策记录是历史,
231
- 当前事实以代码为准,不在记录里。
232
-
233
- ## 理念
234
-
235
- - **记录是事实来源。** 代码注释会腐化,文档会漂移;一条写明了决定与代价的
236
- ADR 会持续有用。
237
- - **备选方案是强制项。** 没有记录被否决方案的决策,是在邀请未来的重复争论。
238
- - **生命周期是机械操作,不是编辑操作。** 提升草稿、退役已接受决策都是命令
239
- (`accept`、`supersede`),`validate` 强制检查结果形态。
240
- - **Agent 是一等用户。** 记录本身就是接口:纯 Markdown 加 YAML front matter,
241
- agent 直接读,路径可预测,`validate` 充当机器检查。
125
+ [DeepSeek Harness Agent Notes](https://github.com/deepseek-ai/deepseek-harness) 启发了生命周期目录及 proposed、implemented、rejected、archived 的语义。ADR Kit 保留自身的来源声明、稳定编号、校验、思辨树和关系图。OpenSpec 不是运行时或治理依赖。
242
126
 
243
127
  ## 开发
244
128
 
@@ -251,4 +135,4 @@ npm run build
251
135
 
252
136
  ## 许可证
253
137
 
254
- [MIT](https://github.com/luochang212/adr-kit/blob/main/LICENSE)
138
+ MIT。
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAyEA,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAiMzC"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AA6EA,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAuMzC"}