adr-kit 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +57 -45
- package/README.zh.md +53 -41
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +10 -11
- package/dist/cli.js.map +1 -1
- package/dist/commands/accept.d.ts.map +1 -1
- package/dist/commands/accept.js +12 -14
- package/dist/commands/accept.js.map +1 -1
- package/dist/commands/decide.d.ts.map +1 -1
- package/dist/commands/decide.js +3 -2
- package/dist/commands/decide.js.map +1 -1
- package/dist/commands/init.js +2 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/instructions.d.ts.map +1 -1
- package/dist/commands/instructions.js +24 -25
- package/dist/commands/instructions.js.map +1 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +14 -14
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/propose.d.ts.map +1 -1
- package/dist/commands/propose.js +12 -5
- package/dist/commands/propose.js.map +1 -1
- package/dist/commands/reject.d.ts +1 -1
- package/dist/commands/reject.d.ts.map +1 -1
- package/dist/commands/reject.js +8 -19
- package/dist/commands/reject.js.map +1 -1
- package/dist/commands/show.d.ts.map +1 -1
- package/dist/commands/show.js +16 -2
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +15 -14
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/supersede.d.ts.map +1 -1
- package/dist/commands/supersede.js +14 -5
- package/dist/commands/supersede.js.map +1 -1
- package/dist/core/adr.d.ts +24 -9
- package/dist/core/adr.d.ts.map +1 -1
- package/dist/core/adr.js +97 -65
- package/dist/core/adr.js.map +1 -1
- package/dist/core/git.d.ts +9 -0
- package/dist/core/git.d.ts.map +1 -0
- package/dist/core/git.js +22 -0
- package/dist/core/git.js.map +1 -0
- package/dist/core/repository.d.ts +11 -0
- package/dist/core/repository.d.ts.map +1 -1
- package/dist/core/repository.js +95 -18
- package/dist/core/repository.js.map +1 -1
- package/dist/core/templates.d.ts +18 -10
- package/dist/core/templates.d.ts.map +1 -1
- package/dist/core/templates.js +65 -41
- package/dist/core/templates.js.map +1 -1
- package/dist/core/tool-integrations.d.ts.map +1 -1
- package/dist/core/tool-integrations.js +38 -30
- package/dist/core/tool-integrations.js.map +1 -1
- package/dist/core/validate.d.ts +7 -1
- package/dist/core/validate.d.ts.map +1 -1
- package/dist/core/validate.js +109 -97
- package/dist/core/validate.js.map +1 -1
- package/package.json +3 -2
package/dist/core/adr.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { basename } from 'node:path';
|
|
3
|
+
import { parse } from 'yaml';
|
|
4
|
+
/** Canonical front matter field order; only fields that exist are written. */
|
|
5
|
+
export const FRONT_MATTER_ORDER = ['status', 'date', 'commit', 'reason', 'superseded-by'];
|
|
3
6
|
/** Sections that only make sense during the proposal era and must not appear in an accepted decision. */
|
|
4
7
|
export const PROPOSAL_ERA_HEADINGS = ['Proposal', 'Acceptance criteria', 'Risks', 'Plan', 'Migration plan'];
|
|
5
8
|
/** A `YYYY-MM-DD` date value. Shared by the parser (format) and validate (calendar validity). */
|
|
6
9
|
export const DATE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
7
10
|
/**
|
|
8
11
|
* Today's date as `YYYY-MM-DD` in local time. The single source of the date:
|
|
9
|
-
* it feeds the `
|
|
12
|
+
* it feeds the `date` front matter field that every record carries and the
|
|
10
13
|
* `YYYY-MM-DD-` prefix of proposal file names, so the two always agree.
|
|
11
14
|
*/
|
|
12
15
|
export function todayStamp() {
|
|
@@ -24,27 +27,6 @@ export class AdrFormatError extends Error {
|
|
|
24
27
|
this.name = 'AdrFormatError';
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
|
-
export function statusForFolder(folder) {
|
|
28
|
-
switch (folder) {
|
|
29
|
-
case 'decisions':
|
|
30
|
-
return 'accepted';
|
|
31
|
-
case 'proposed':
|
|
32
|
-
return 'proposed';
|
|
33
|
-
case 'rejected':
|
|
34
|
-
return 'rejected';
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export function folderForStatus(status) {
|
|
38
|
-
switch (status) {
|
|
39
|
-
case 'accepted':
|
|
40
|
-
case 'superseded':
|
|
41
|
-
return 'decisions';
|
|
42
|
-
case 'proposed':
|
|
43
|
-
return 'proposed';
|
|
44
|
-
case 'rejected':
|
|
45
|
-
return 'rejected';
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
30
|
export function section(record, heading) {
|
|
49
31
|
return record.sections.find((candidate) => candidate.heading === heading)?.body;
|
|
50
32
|
}
|
|
@@ -57,72 +39,116 @@ export function hasMeaningfulBody(body) {
|
|
|
57
39
|
/**
|
|
58
40
|
* Parse a single ADR markdown file into its structured parts.
|
|
59
41
|
*
|
|
60
|
-
* The format is
|
|
42
|
+
* The format is YAML front matter followed by a Markdown body:
|
|
43
|
+
*
|
|
44
|
+
* ---
|
|
45
|
+
* status: proposed | accepted | rejected | superseded
|
|
46
|
+
* date: YYYY-MM-DD
|
|
47
|
+
* reason: <why> (rejected only)
|
|
48
|
+
* superseded-by: <N> (superseded only)
|
|
49
|
+
* ---
|
|
61
50
|
*
|
|
62
51
|
* # ADR: <title or "N Title">
|
|
63
|
-
*
|
|
64
|
-
* Date: YYYY-MM-DD
|
|
65
|
-
* <blank line>
|
|
52
|
+
*
|
|
66
53
|
* ## Problem
|
|
67
54
|
* ...
|
|
68
55
|
*
|
|
69
|
-
* The `
|
|
56
|
+
* The `date` field records the date the current status was reached and is
|
|
70
57
|
* stamped by the CLI at every lifecycle move (propose, decide, accept,
|
|
71
58
|
* reject, supersede).
|
|
72
59
|
*/
|
|
73
60
|
export function parseAdrFile(filePath) {
|
|
74
61
|
const text = readFileSync(filePath, 'utf8');
|
|
75
62
|
const lines = text.split(/\r?\n/);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
63
|
+
if (lines[0] !== '---') {
|
|
64
|
+
throw new AdrFormatError('file must start with a YAML front matter block ("---")', filePath);
|
|
65
|
+
}
|
|
66
|
+
const closing = lines.indexOf('---', 1);
|
|
67
|
+
if (closing === -1) {
|
|
68
|
+
throw new AdrFormatError('front matter block is not closed ("---" missing)', filePath);
|
|
69
|
+
}
|
|
70
|
+
let frontMatter;
|
|
71
|
+
try {
|
|
72
|
+
frontMatter = parse(lines.slice(1, closing).join('\n'));
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
76
|
+
throw new AdrFormatError(`front matter is not valid YAML: ${detail}`, filePath);
|
|
77
|
+
}
|
|
78
|
+
if (typeof frontMatter !== 'object' || frontMatter === null || Array.isArray(frontMatter)) {
|
|
79
|
+
throw new AdrFormatError('front matter must be a YAML mapping', filePath);
|
|
80
|
+
}
|
|
81
|
+
const fields = frontMatter;
|
|
82
|
+
const extras = Object.keys(fields).filter((key) => !FRONT_MATTER_ORDER.includes(key));
|
|
83
|
+
const statusText = fields['status'];
|
|
84
|
+
if (statusText === undefined) {
|
|
85
|
+
throw new AdrFormatError('front matter must include "status"', filePath);
|
|
86
|
+
}
|
|
87
|
+
if (statusText !== 'proposed' &&
|
|
88
|
+
statusText !== 'accepted' &&
|
|
89
|
+
statusText !== 'rejected' &&
|
|
90
|
+
statusText !== 'superseded') {
|
|
91
|
+
throw new AdrFormatError('status must be "proposed", "accepted", "rejected", or "superseded"', filePath);
|
|
92
|
+
}
|
|
93
|
+
const status = statusText;
|
|
94
|
+
const dateText = fields['date'];
|
|
95
|
+
if (dateText === undefined) {
|
|
96
|
+
throw new AdrFormatError('front matter must include "date"', filePath);
|
|
97
|
+
}
|
|
98
|
+
if (typeof dateText !== 'string' || !DATE_PATTERN.test(dateText)) {
|
|
99
|
+
throw new AdrFormatError('date must be a "YYYY-MM-DD" string', filePath);
|
|
100
|
+
}
|
|
101
|
+
const date = dateText;
|
|
102
|
+
let commit;
|
|
103
|
+
const commitField = fields['commit'];
|
|
104
|
+
if (commitField !== undefined) {
|
|
105
|
+
if (typeof commitField !== 'string' || commitField.trim().length === 0) {
|
|
106
|
+
throw new AdrFormatError('commit must be a non-empty string', filePath);
|
|
107
|
+
}
|
|
108
|
+
commit = commitField.trim();
|
|
87
109
|
}
|
|
88
|
-
const statusText = statusLine.slice('Status: '.length).trim();
|
|
89
|
-
let status;
|
|
90
110
|
let rejectionReason;
|
|
91
|
-
|
|
92
|
-
if (
|
|
93
|
-
|
|
111
|
+
const reason = fields['reason'];
|
|
112
|
+
if (status === 'rejected') {
|
|
113
|
+
if (typeof reason !== 'string' || reason.trim().length === 0) {
|
|
114
|
+
throw new AdrFormatError('rejected status requires a non-empty "reason"', filePath);
|
|
115
|
+
}
|
|
116
|
+
rejectionReason = reason;
|
|
94
117
|
}
|
|
95
|
-
else if (
|
|
96
|
-
status
|
|
118
|
+
else if (reason !== undefined) {
|
|
119
|
+
throw new AdrFormatError('"reason" is only allowed when status is "rejected"', filePath);
|
|
97
120
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (
|
|
102
|
-
|
|
121
|
+
let supersededBy;
|
|
122
|
+
const supersededByField = fields['superseded-by'];
|
|
123
|
+
if (status === 'superseded') {
|
|
124
|
+
if (typeof supersededByField !== 'number' ||
|
|
125
|
+
!Number.isInteger(supersededByField) ||
|
|
126
|
+
supersededByField < 1) {
|
|
127
|
+
throw new AdrFormatError('superseded status requires a positive integer "superseded-by"', filePath);
|
|
103
128
|
}
|
|
129
|
+
supersededBy = supersededByField;
|
|
104
130
|
}
|
|
105
|
-
else if (
|
|
106
|
-
|
|
107
|
-
supersededBy = Number(statusText.slice('superseded by '.length));
|
|
131
|
+
else if (supersededByField !== undefined) {
|
|
132
|
+
throw new AdrFormatError('"superseded-by" is only allowed when status is "superseded"', filePath);
|
|
108
133
|
}
|
|
109
|
-
|
|
110
|
-
|
|
134
|
+
const body = lines.slice(closing + 1);
|
|
135
|
+
if ((body[0] ?? '') !== '') {
|
|
136
|
+
throw new AdrFormatError('front matter must be followed by a blank line', filePath);
|
|
111
137
|
}
|
|
112
|
-
const
|
|
113
|
-
if (!
|
|
114
|
-
throw new AdrFormatError('line
|
|
138
|
+
const titleLine = body[1] ?? '';
|
|
139
|
+
if (!titleLine.startsWith('# ADR: ')) {
|
|
140
|
+
throw new AdrFormatError('title line must be "# ADR: <title>"', filePath);
|
|
115
141
|
}
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
throw new AdrFormatError('
|
|
142
|
+
const title = titleLine.slice('# ADR: '.length).trim();
|
|
143
|
+
if (title.length === 0) {
|
|
144
|
+
throw new AdrFormatError('ADR title must not be empty', filePath);
|
|
119
145
|
}
|
|
120
|
-
if ((
|
|
121
|
-
throw new AdrFormatError('
|
|
146
|
+
if ((body[2] ?? '') !== '') {
|
|
147
|
+
throw new AdrFormatError('the title must be followed by a blank line', filePath);
|
|
122
148
|
}
|
|
123
149
|
const sections = [];
|
|
124
150
|
let current = null;
|
|
125
|
-
for (const line of
|
|
151
|
+
for (const line of body.slice(3)) {
|
|
126
152
|
if (line.startsWith('## ')) {
|
|
127
153
|
if (current !== null)
|
|
128
154
|
sections.push(current);
|
|
@@ -139,8 +165,10 @@ export function parseAdrFile(filePath) {
|
|
|
139
165
|
if (current !== null)
|
|
140
166
|
sections.push(current);
|
|
141
167
|
const numberMatch = title.match(/^([1-9]\d*)\s+(.+)$/);
|
|
168
|
+
// The parser does not know which folder the file lives in; listRecords and
|
|
169
|
+
// listDrafts set `folder` after scanning. 'decisions' is a neutral placeholder.
|
|
142
170
|
const parsed = {
|
|
143
|
-
folder: '
|
|
171
|
+
folder: 'decisions',
|
|
144
172
|
path: filePath,
|
|
145
173
|
fileName: basename(filePath),
|
|
146
174
|
title,
|
|
@@ -148,10 +176,14 @@ export function parseAdrFile(filePath) {
|
|
|
148
176
|
date,
|
|
149
177
|
sections,
|
|
150
178
|
};
|
|
179
|
+
if (commit !== undefined)
|
|
180
|
+
parsed.commit = commit;
|
|
151
181
|
if (rejectionReason !== undefined)
|
|
152
182
|
parsed.rejectionReason = rejectionReason;
|
|
153
183
|
if (supersededBy !== undefined)
|
|
154
184
|
parsed.supersededBy = supersededBy;
|
|
185
|
+
if (extras.length > 0)
|
|
186
|
+
parsed.frontMatterExtras = extras;
|
|
155
187
|
if (numberMatch !== null) {
|
|
156
188
|
parsed.number = Number(numberMatch[1]);
|
|
157
189
|
}
|
package/dist/core/adr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adr.js","sourceRoot":"","sources":["../../src/core/adr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"adr.js","sourceRoot":"","sources":["../../src/core/adr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAW7B,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,CAAU,CAAC;AAEnG,yGAAyG;AACzG,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,UAAU,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAE5G,iGAAiG;AACjG,MAAM,CAAC,MAAM,YAAY,GAAG,2BAA2B,CAAC;AAExD;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,GAAG,GAAG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AC;IAE7C,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACvD,2EAA2E;IAC3E,gFAAgF;IAChF,MAAM,MAAM,GAAc;QACxB,MAAM,EAAE,WAAW;QACnB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC;QAC5B,KAAK;QACL,MAAM;QACN,IAAI;QACJ,QAAQ;KACT,CAAC;IACF,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IACjD,IAAI,eAAe,KAAK,SAAS;QAAE,MAAM,CAAC,eAAe,GAAG,eAAe,CAAC;IAC5E,IAAI,YAAY,KAAK,SAAS;QAAE,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;IACnE,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,iBAAiB,GAAG,MAAM,CAAC;IACzD,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;QACzB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The short HEAD commit hash of the repository containing `cwd`, or undefined
|
|
3
|
+
* when git is unavailable, `cwd` is not inside a git repository, or the repo
|
|
4
|
+
* has no commits yet. Silent by design: the commit stamp is an enhancement
|
|
5
|
+
* (it anchors a decision to the code state it was recorded against), never a
|
|
6
|
+
* failure. Callers stamp `commit` into the front matter only when defined.
|
|
7
|
+
*/
|
|
8
|
+
export declare function gitHead(cwd: string): string | undefined;
|
|
9
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/core/git.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAWvD"}
|
package/dist/core/git.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
/**
|
|
3
|
+
* The short HEAD commit hash of the repository containing `cwd`, or undefined
|
|
4
|
+
* when git is unavailable, `cwd` is not inside a git repository, or the repo
|
|
5
|
+
* has no commits yet. Silent by design: the commit stamp is an enhancement
|
|
6
|
+
* (it anchors a decision to the code state it was recorded against), never a
|
|
7
|
+
* failure. Callers stamp `commit` into the front matter only when defined.
|
|
8
|
+
*/
|
|
9
|
+
export function gitHead(cwd) {
|
|
10
|
+
try {
|
|
11
|
+
const hash = execFileSync('git', ['rev-parse', '--short', 'HEAD'], {
|
|
12
|
+
cwd,
|
|
13
|
+
encoding: 'utf8',
|
|
14
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
15
|
+
}).trim();
|
|
16
|
+
return hash.length > 0 ? hash : undefined;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/core/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE;YACjE,GAAG;YACH,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;SACpC,CAAC,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { type AdrFolder, type AdrRecord } from './adr.js';
|
|
2
|
+
/** Durable records live in one folder; status is carried in the front matter. */
|
|
2
3
|
export declare const FOLDERS: AdrFolder[];
|
|
4
|
+
/**
|
|
5
|
+
* Ephemeral proposal drafts. Created lazily on the first `adrkit propose`,
|
|
6
|
+
* gitignored (init writes `adr/.gitignore`), never validated by `adrkit
|
|
7
|
+
* validate` and never durable until `accept` promotes one into decisions/.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DRAFTS_DIR = ".drafts";
|
|
3
10
|
export interface InitResult {
|
|
4
11
|
root: string;
|
|
5
12
|
created: string[];
|
|
@@ -12,6 +19,10 @@ export declare function resolveRecord(root: string, query: string): AdrRecord;
|
|
|
12
19
|
export declare function nextDecisionNumber(root: string): number;
|
|
13
20
|
export declare function writeRecord(root: string, folder: AdrFolder, fileName: string, content: string): string;
|
|
14
21
|
export declare function removeRecord(record: AdrRecord): void;
|
|
22
|
+
/** Path to the ephemeral drafts folder (`adr/.drafts/`). */
|
|
23
|
+
export declare function draftsPath(root: string): string;
|
|
24
|
+
export declare function listDrafts(root: string): AdrRecord[];
|
|
25
|
+
export declare function resolveDraft(root: string, query: string): AdrRecord;
|
|
15
26
|
export declare function readRecord(record: AdrRecord): string;
|
|
16
27
|
export declare function displayName(record: AdrRecord): string;
|
|
17
28
|
export declare function relativePath(record: AdrRecord): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../src/core/repository.ts"],"names":[],"mappings":"AAUA,OAAO,EAAgB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAExE,eAAO,MAAM,OAAO,EAAE,SAAS,
|
|
1
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MAAM,GAAG,SAAS,CAYnE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAEpD;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAMrD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAEtD"}
|
package/dist/core/repository.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync, } from 'node:fs';
|
|
2
|
-
import { basename, join, relative, resolve } from 'node:path';
|
|
2
|
+
import { basename, dirname, join, relative, resolve } from 'node:path';
|
|
3
3
|
import { ADR_DIR, CONFIG_FILE, configPath } from './config.js';
|
|
4
4
|
import { parseAdrFile } from './adr.js';
|
|
5
|
-
|
|
5
|
+
/** Durable records live in one folder; status is carried in the front matter. */
|
|
6
|
+
export const FOLDERS = ['decisions'];
|
|
7
|
+
/**
|
|
8
|
+
* Ephemeral proposal drafts. Created lazily on the first `adrkit propose`,
|
|
9
|
+
* gitignored (init writes `adr/.gitignore`), never validated by `adrkit
|
|
10
|
+
* validate` and never durable until `accept` promotes one into decisions/.
|
|
11
|
+
*/
|
|
12
|
+
export const DRAFTS_DIR = '.drafts';
|
|
6
13
|
function initConfig(tools) {
|
|
7
14
|
// tools 始终作为顶层键输出:全注释的 YAML 文档会被解析为空,
|
|
8
15
|
// readConfig 的 isMap 检查会报 "top-level value must be a mapping"。
|
|
@@ -28,32 +35,40 @@ ${toolsYaml}
|
|
|
28
35
|
const INIT_README = `# Architecture Decision Records
|
|
29
36
|
|
|
30
37
|
This directory is an ADR Kit repository. Each record is plain Markdown with a
|
|
31
|
-
machine-checkable header
|
|
38
|
+
machine-checkable header. Decisions are durable; proposals are ephemeral drafts.
|
|
32
39
|
|
|
33
40
|
## Folders
|
|
34
41
|
|
|
35
42
|
| Folder | Meaning |
|
|
36
43
|
| --- | --- |
|
|
37
|
-
| \`decisions/\` |
|
|
38
|
-
|
|
|
39
|
-
|
|
44
|
+
| \`decisions/\` | Decisions, numbered sequentially, immutable history (accepted or superseded) |
|
|
45
|
+
| \`.drafts/\` | Proposal drafts, gitignored and ephemeral - promote one with \`adrkit accept\` or discard it with \`adrkit reject\` |
|
|
46
|
+
|
|
47
|
+
Rejection is recorded in a decision's \`Alternatives considered\` section, never
|
|
48
|
+
as a standalone record.
|
|
40
49
|
|
|
41
50
|
## Record format
|
|
42
51
|
|
|
43
|
-
Every record starts with
|
|
52
|
+
Every record starts with a YAML front matter block:
|
|
44
53
|
|
|
45
54
|
\`\`\`markdown
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
---
|
|
56
|
+
status: accepted | superseded
|
|
57
|
+
date: YYYY-MM-DD
|
|
58
|
+
commit: abc1234
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
# ADR: N <title>
|
|
49
62
|
\`\`\`
|
|
50
63
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
\`
|
|
64
|
+
Decisions use \`# ADR: N <title>\` and require \`Problem\`, \`Decision\`,
|
|
65
|
+
\`Alternatives considered\`, and \`Consequences\`. Superseded decisions add
|
|
66
|
+
\`superseded-by: N\`. The \`date\` field records when the current status was
|
|
67
|
+
reached; the CLI stamps it at every lifecycle move, alongside the git \`commit\`
|
|
68
|
+
the decision was recorded against. Drafts (\`adr/.drafts/\`, \`status:
|
|
69
|
+
proposed\`) require \`Problem\`, \`Proposal\`, \`Alternatives considered\`,
|
|
70
|
+
\`Acceptance criteria\`, and \`Risks\`; \`adrkit accept\` promotes one into a
|
|
71
|
+
decision, and \`adrkit reject\` discards it without leaving a record.
|
|
57
72
|
|
|
58
73
|
Run \`adrkit validate\` to check every record.
|
|
59
74
|
`;
|
|
@@ -75,6 +90,12 @@ export function initRepository(targetDir, tools = []) {
|
|
|
75
90
|
const config = configPath(root);
|
|
76
91
|
writeFileSync(config, initConfig(tools));
|
|
77
92
|
created.push(`${ADR_DIR}/${CONFIG_FILE}`);
|
|
93
|
+
// Drafts are ephemeral and must never be committed; the guard ships with init
|
|
94
|
+
// so a draft can never leak into git, even before the first propose creates
|
|
95
|
+
// the directory.
|
|
96
|
+
const gitignore = join(adrRoot, '.gitignore');
|
|
97
|
+
writeFileSync(gitignore, `${DRAFTS_DIR}\n`);
|
|
98
|
+
created.push(`${ADR_DIR}/.gitignore`);
|
|
78
99
|
const readme = join(adrRoot, 'README.md');
|
|
79
100
|
writeFileSync(readme, INIT_README);
|
|
80
101
|
created.push(`${ADR_DIR}/README.md`);
|
|
@@ -83,8 +104,16 @@ export function initRepository(targetDir, tools = []) {
|
|
|
83
104
|
export function adrRoot(root) {
|
|
84
105
|
return join(root, ADR_DIR);
|
|
85
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Physical directory name for a folder value. The drafts folder is named
|
|
109
|
+
* `.drafts` (dot-prefixed, gitignored) while the value carried on AdrRecord is
|
|
110
|
+
* the bare `drafts`.
|
|
111
|
+
*/
|
|
112
|
+
function folderDirName(folder) {
|
|
113
|
+
return folder === 'drafts' ? DRAFTS_DIR : folder;
|
|
114
|
+
}
|
|
86
115
|
export function folderPath(root, folder) {
|
|
87
|
-
return join(adrRoot(root), folder);
|
|
116
|
+
return join(adrRoot(root), folderDirName(folder));
|
|
88
117
|
}
|
|
89
118
|
export function listRecords(root) {
|
|
90
119
|
const records = [];
|
|
@@ -204,12 +233,60 @@ export function nextDecisionNumber(root) {
|
|
|
204
233
|
}
|
|
205
234
|
export function writeRecord(root, folder, fileName, content) {
|
|
206
235
|
const path = join(folderPath(root, folder), fileName);
|
|
236
|
+
// mkdir-on-write: a target folder may not exist yet (e.g. .drafts/ before the
|
|
237
|
+
// first propose, or a decisions/ that was removed). Creating it on demand
|
|
238
|
+
// keeps every lifecycle command correct without eager directory ceremony.
|
|
239
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
207
240
|
writeFileSync(path, content);
|
|
208
241
|
return path;
|
|
209
242
|
}
|
|
210
243
|
export function removeRecord(record) {
|
|
211
244
|
rmSync(record.path);
|
|
212
245
|
}
|
|
246
|
+
/** Path to the ephemeral drafts folder (`adr/.drafts/`). */
|
|
247
|
+
export function draftsPath(root) {
|
|
248
|
+
return join(adrRoot(root), DRAFTS_DIR);
|
|
249
|
+
}
|
|
250
|
+
export function listDrafts(root) {
|
|
251
|
+
const dir = draftsPath(root);
|
|
252
|
+
if (!existsSync(dir))
|
|
253
|
+
return [];
|
|
254
|
+
const drafts = [];
|
|
255
|
+
for (const entry of readdirSync(dir)) {
|
|
256
|
+
if (!entry.endsWith('.md'))
|
|
257
|
+
continue;
|
|
258
|
+
const path = join(dir, entry);
|
|
259
|
+
try {
|
|
260
|
+
const draft = parseAdrFile(path);
|
|
261
|
+
draft.folder = 'drafts';
|
|
262
|
+
drafts.push(draft);
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
266
|
+
throw new Error(`failed to parse ${relative(root, path)}: ${message}`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
drafts.sort((a, b) => a.fileName.localeCompare(b.fileName));
|
|
270
|
+
return drafts;
|
|
271
|
+
}
|
|
272
|
+
function draftMatchesQuery(draft, needle) {
|
|
273
|
+
if (fileNameMatchesQuery(draft.fileName, needle))
|
|
274
|
+
return true;
|
|
275
|
+
return draft.title === needle || `# ADR: ${draft.title}` === needle;
|
|
276
|
+
}
|
|
277
|
+
export function resolveDraft(root, query) {
|
|
278
|
+
const needle = query.trim();
|
|
279
|
+
const drafts = listDrafts(root);
|
|
280
|
+
const candidates = drafts.filter((draft) => draftMatchesQuery(draft, needle));
|
|
281
|
+
if (candidates.length === 0) {
|
|
282
|
+
throw new Error(`no draft proposal matches "${query}"`);
|
|
283
|
+
}
|
|
284
|
+
if (candidates.length > 1) {
|
|
285
|
+
const paths = candidates.map((draft) => relative(root, draft.path)).join(', ');
|
|
286
|
+
throw new Error(`"${query}" is ambiguous; matches: ${paths}`);
|
|
287
|
+
}
|
|
288
|
+
return candidates[0];
|
|
289
|
+
}
|
|
213
290
|
export function readRecord(record) {
|
|
214
291
|
return readFileSync(record.path, 'utf8');
|
|
215
292
|
}
|
|
@@ -221,6 +298,6 @@ export function displayName(record) {
|
|
|
221
298
|
return record.title;
|
|
222
299
|
}
|
|
223
300
|
export function relativePath(record) {
|
|
224
|
-
return join(ADR_DIR, record.folder, basename(record.path));
|
|
301
|
+
return join(ADR_DIR, folderDirName(record.folder), basename(record.path));
|
|
225
302
|
}
|
|
226
303
|
//# sourceMappingURL=repository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../src/core/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../src/core/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAkC,MAAM,UAAU,CAAC;AAExE,iFAAiF;AACjF,MAAM,CAAC,MAAM,OAAO,GAAgB,CAAC,WAAW,CAAC,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC;AAOpC,SAAS,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4BAA4B,KAAK,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,UAAU,CAAC,CAAC,CAAE,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAiB;IAC1C,OAAO,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAiB;IAC3C,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACrE,MAAM,kBAAkB,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAC/D,OAAO,IAAI,MAAM,CAAC,MAAM,KAAK,kBAAkB,EAAE,CAAC;IACpD,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAiB;IAC5C,OAAO,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5E,CAAC"}
|
package/dist/core/templates.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { type AdrRecord } from './adr.js';
|
|
2
|
+
/**
|
|
3
|
+
* Render a YAML front matter block. Fields are written in the canonical
|
|
4
|
+
* order (status, date, commit, reason, superseded-by); only the fields
|
|
5
|
+
* present in `fields` are emitted.
|
|
6
|
+
*/
|
|
7
|
+
export declare function frontMatter(fields: Record<string, string | number>): string;
|
|
2
8
|
export declare function proposalTemplate(title: string, context?: string): string;
|
|
3
|
-
export declare function decisionTemplate(number: number, title: string, context?: string): string;
|
|
4
|
-
export declare function rejectedTemplate(title: string, reason: string): string;
|
|
9
|
+
export declare function decisionTemplate(number: number, title: string, context?: string, commit?: string): string;
|
|
5
10
|
/**
|
|
6
|
-
* Convert a proposal into an accepted decision using the same mechanical
|
|
11
|
+
* Convert a draft proposal into an accepted decision using the same mechanical
|
|
7
12
|
* rewrite the format requires: Proposal becomes Decision, and the
|
|
8
|
-
* acceptance criteria and risks are folded into Consequences.
|
|
13
|
+
* acceptance criteria and risks are folded into Consequences. `commit` anchors
|
|
14
|
+
* the decision to the code state it was recorded against.
|
|
9
15
|
*/
|
|
10
|
-
export declare function proposalToDecision(proposal: AdrRecord, number: number): string;
|
|
16
|
+
export declare function proposalToDecision(proposal: AdrRecord, number: number, commit?: string): string;
|
|
11
17
|
/**
|
|
12
18
|
* Proposal sections that have no place in an accepted decision and would be
|
|
13
19
|
* silently discarded by `proposalToDecision`. Only proposal-era leftovers
|
|
@@ -17,10 +23,12 @@ export declare function proposalToDecision(proposal: AdrRecord, number: number):
|
|
|
17
23
|
*/
|
|
18
24
|
export declare function droppedSections(proposal: AdrRecord): string[];
|
|
19
25
|
/**
|
|
20
|
-
* Rewrite a record's
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
26
|
+
* Rewrite a record's front matter for a lifecycle move: parse the existing
|
|
27
|
+
* block, merge `patch` over it, and re-emit the fields in canonical order.
|
|
28
|
+
* Every non-creating move (accept, reject, supersede) must stamp the date so
|
|
29
|
+
* the front matter always reflects the current status; the Markdown body is
|
|
30
|
+
* left untouched. Unknown keys are preserved after the canonical ones so a
|
|
31
|
+
* mechanical rewrite never loses data silently (validate flags them).
|
|
24
32
|
*/
|
|
25
|
-
export declare function stampLifecycleMove(content: string,
|
|
33
|
+
export declare function stampLifecycleMove(content: string, patch: Record<string, string | number>): string;
|
|
26
34
|
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/core/templates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/core/templates.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,UAAU,CAAC;AAoClB;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAO3E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAyBxE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAuBzG;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAqD/F;AAMD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,SAAS,GAAG,MAAM,EAAE,CAI7D;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAyBlG"}
|