@theholocron/astromech 5.0.0-alpha.284 → 5.0.0-alpha.285
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/README.md +8 -3
- package/dist/index.mjs +1 -4
- package/dist/repo-validation/index.d.mts +84 -1
- package/dist/repo-validation/index.mjs +168 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ documents, not a naming convention repos need to follow.
|
|
|
74
74
|
| `platform.notifyCheck` | _(none — manual workflow)_ | posts a labelled test message to every notification channel; fails per channel that does not work |
|
|
75
75
|
| `platform.repoSync` | `holocron repo sync` | keeps generated files current |
|
|
76
76
|
| `platform.commitStandards` | commitlint | no local equivalent — enforced by the `commit-msg` hook locally, over the PR's commit range in CI |
|
|
77
|
-
| `platform.repoValidation` | `
|
|
77
|
+
| `platform.repoValidation` | `holocron probe specs check`, `holocron probe docs presence` | a job-bearing task — spec/ADR frontmatter and docs-presence, not linters |
|
|
78
78
|
| `knowledge.wiki` | Fern | publishes `docs/wiki/*.md` — not a sync, a publish; carries `preview` |
|
|
79
79
|
| `knowledge.docs` | Astro build | the docs site itself; carries `preview` (defaults on) |
|
|
80
80
|
| `knowledge.components` | Storybook build | a browsable component catalog — "Storybook" is the tool, not the intent; carries `preview` (defaults on) |
|
|
@@ -253,11 +253,16 @@ writes (`createEditorconfig`, `createAlexrc`, `createPrePush`, …) and
|
|
|
253
253
|
|
|
254
254
|
The rules of the `platform.repoValidation` checks, once, as pure functions over plain data (changed files, commit
|
|
255
255
|
subjects, the PR description, a manifest) that return findings. They do no git, no filesystem and no network, so the two
|
|
256
|
-
interfaces that run them only supply the data: the CLI (`holocron probe docs presence
|
|
257
|
-
`holocron run platform.repoValidation`) from git, and [Sentinel](https://docs.theholocron.dev/holocron/sentinel/) from the
|
|
256
|
+
interfaces that run them only supply the data: the CLI (`holocron probe docs presence` and `holocron probe specs check`, the two jobs of
|
|
257
|
+
`holocron run platform.repoValidation`) from git and the filesystem, and [Sentinel](https://docs.theholocron.dev/holocron/sentinel/) from the
|
|
258
258
|
webhook and the GitHub API (#929).
|
|
259
259
|
|
|
260
260
|
- Docs presence: `isFeat(subjects)`, `packageOf(file, readPackage)`, `pageNames(dir)`, `hasDocsSignal(dir, changedFiles, addedCommentLines)`,
|
|
261
261
|
`isAddedDocComment(line)`, `parseSkipDocs(text)` (the `[skip docs] <reason>` marker) and
|
|
262
262
|
`evaluateDocsPresence({ packages, changedFiles, addedCommentLines, skip })`, which sorts a feature's packages into
|
|
263
263
|
those to warn about and those a marker excused.
|
|
264
|
+
- ADRs and specs: `checkSpecs(files)` takes `{ path, text }` pairs and returns `{ fileCount, findings }`, skipping a path that
|
|
265
|
+
is neither an ADR nor a spec; underneath it are `classifySpecPath(path)`, `parseFrontmatter(text)`,
|
|
266
|
+
`validateAdr(path, text)`, `validateSpec(path, text)` and `isValidIsoDate(value)`, and the folders and status sets
|
|
267
|
+
(`ADR_DIR`, `SPEC_DIRS`, `ADR_STATUSES`, `SPEC_STATUSES`). A `SpecFinding` is an `error` (fails the check) or a
|
|
268
|
+
`warning` (never does), with the file, the field's line and the rule.
|
package/dist/index.mjs
CHANGED
|
@@ -1192,10 +1192,7 @@ const TASKS = {
|
|
|
1192
1192
|
retiredJobs: ["registry"],
|
|
1193
1193
|
jobs: {
|
|
1194
1194
|
adrs: {
|
|
1195
|
-
local: {
|
|
1196
|
-
tool: "node",
|
|
1197
|
-
args: ["scripts/validate-adrs.mjs"]
|
|
1198
|
-
},
|
|
1195
|
+
local: { command: "probe specs check" },
|
|
1199
1196
|
checkContext: "platform.repoValidation / Validate ADRs and specs"
|
|
1200
1197
|
},
|
|
1201
1198
|
docsPresence: {
|
|
@@ -55,4 +55,87 @@ export declare function pageNames(dir: string): string[];
|
|
|
55
55
|
* text has no marker.
|
|
56
56
|
*/
|
|
57
57
|
export declare function parseSkipDocs(text: string): SkipDocs | null;
|
|
58
|
-
|
|
58
|
+
/** One frontmatter field: its trimmed value and the 1-indexed line it sits on in the file. */
|
|
59
|
+
interface SpecField {
|
|
60
|
+
/** The text after the colon, trimmed; empty for a key that only opens a nested block (`discussion:`). */
|
|
61
|
+
value: string;
|
|
62
|
+
/** 1-indexed, counting the opening `---` as line 1. */
|
|
63
|
+
line: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A file's frontmatter by key. One level of nesting is keyed `parent.child` (`discussion.github`), and the parent
|
|
67
|
+
* key is there too.
|
|
68
|
+
*/
|
|
69
|
+
type SpecFrontmatter = Map<string, SpecField>;
|
|
70
|
+
/** The kind of file the ADR and spec check reads: an architecture decision record or a design spec. */
|
|
71
|
+
type SpecKind = "adr" | "spec";
|
|
72
|
+
/** One problem the ADR and spec check found in a file. */
|
|
73
|
+
interface SpecFinding {
|
|
74
|
+
/** The file's repo-relative path, as it was given to the check. */
|
|
75
|
+
file: string;
|
|
76
|
+
/** 1-indexed: the offending field's own line, or the first line when the field (or the whole frontmatter) is missing. */
|
|
77
|
+
line: number;
|
|
78
|
+
/** The frontmatter field at fault (`id`, `status`, ...), or `frontmatter` when there is none at all. */
|
|
79
|
+
rule: string;
|
|
80
|
+
/** What is wrong, as a sentence. */
|
|
81
|
+
reason: string;
|
|
82
|
+
/** An `error` fails the check; a `warning` is reported and never fails it. */
|
|
83
|
+
severity: "error" | "warning";
|
|
84
|
+
}
|
|
85
|
+
/** A file to check: its repo-relative path and its text. */
|
|
86
|
+
interface SpecFile {
|
|
87
|
+
/** Repo-relative, with `/` separators. */
|
|
88
|
+
path: string;
|
|
89
|
+
/** The file's whole text. */
|
|
90
|
+
text: string;
|
|
91
|
+
}
|
|
92
|
+
/** What the ADR and spec check found across the files it was given. */
|
|
93
|
+
interface SpecsResult {
|
|
94
|
+
/** How many of the files were an ADR or a spec (the rest were not the check's business and were skipped). */
|
|
95
|
+
fileCount: number;
|
|
96
|
+
/** Every problem found, in file order. */
|
|
97
|
+
findings: SpecFinding[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The ADR and spec check over the files it is given: each one that is an ADR or a spec (see `classifySpecPath`) goes to
|
|
101
|
+
* its rules, and every other file is skipped. Whoever calls it decides which files to read (the whole tree, a PR's
|
|
102
|
+
* changed files) and supplies their text; nothing here touches the filesystem or the network.
|
|
103
|
+
*/
|
|
104
|
+
export declare function checkSpecs(files: readonly SpecFile[]): SpecsResult;
|
|
105
|
+
/**
|
|
106
|
+
* What a repo-relative path is to the ADR and spec check: an `adr` (a `.md` file directly in the ADR folder, other
|
|
107
|
+
* than the template and the README), a `spec` (a `*.spec.md` file directly in `.notes` or the wiki's specifications
|
|
108
|
+
* folder), or `undefined` for anything else, which the check leaves alone. Subfolders are not searched.
|
|
109
|
+
*/
|
|
110
|
+
export declare function classifySpecPath(path: string): SpecKind | undefined;
|
|
111
|
+
/** Whether `value` is a `YYYY-MM-DD` date that exists as far as `Date.parse` can tell. */
|
|
112
|
+
export declare function isValidIsoDate(value: string): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Reads a leading `---` block of `key: value` lines, with the line each one is on, plus one level of nesting keyed
|
|
115
|
+
* `parent.child` (the ADR template's `discussion:` / ` github:`). Any other line is skipped. Returns `null` when the
|
|
116
|
+
* text does not open with such a block.
|
|
117
|
+
*/
|
|
118
|
+
export declare function parseFrontmatter(content: string): SpecFrontmatter | null;
|
|
119
|
+
/** Where ADRs live, relative to the repo root. */
|
|
120
|
+
export declare const ADR_DIR = "docs/wiki/decisions";
|
|
121
|
+
/** Where specs live, relative to the repo root: in-progress ones in `.notes`, settled ones under the wiki. */
|
|
122
|
+
export declare const SPEC_DIRS: readonly string[];
|
|
123
|
+
/** The statuses an ADR may have. */
|
|
124
|
+
export declare const ADR_STATUSES: readonly string[];
|
|
125
|
+
/** The statuses a spec may have. */
|
|
126
|
+
export declare const SPEC_STATUSES: readonly string[];
|
|
127
|
+
/** The files in the ADR folder that are not ADRs. */
|
|
128
|
+
export declare const ADR_EXEMPT: readonly string[];
|
|
129
|
+
/**
|
|
130
|
+
* The findings for one ADR's text. Errors: no frontmatter; a missing `id`, or one that is not `ADR-<the filename's
|
|
131
|
+
* four-digit prefix>`; a missing or empty `title`; a missing or unknown `status`; a missing or malformed `date`. A
|
|
132
|
+
* warning: an `accepted` ADR whose `discussion.github` is not set.
|
|
133
|
+
*/
|
|
134
|
+
export declare function validateAdr(file: string, content: string): SpecFinding[];
|
|
135
|
+
/**
|
|
136
|
+
* The findings for one spec's text. Errors: no frontmatter; a missing or unknown `status`. A warning: a missing
|
|
137
|
+
* `issue` (every spec has a companion GitHub issue), except on an `archived` or `superseded` spec, many of which
|
|
138
|
+
* predate the issue-first process.
|
|
139
|
+
*/
|
|
140
|
+
export declare function validateSpec(file: string, content: string): SpecFinding[];
|
|
141
|
+
export type { DocsPresenceResult, SkipDocs, SpecField, SpecFile, SpecFinding, SpecFrontmatter, SpecKind, SpecsResult };
|
|
@@ -94,4 +94,171 @@ function parseSkipDocs(text) {
|
|
|
94
94
|
reason: match[2].trim()
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
// src/repo-validation/specs/spec-locations/spec-locations.ts
|
|
98
|
+
/** Where ADRs live, relative to the repo root. */
|
|
99
|
+
const ADR_DIR = "docs/wiki/decisions";
|
|
100
|
+
/** Where specs live, relative to the repo root: in-progress ones in `.notes`, settled ones under the wiki. */
|
|
101
|
+
const SPEC_DIRS = [".notes", "docs/wiki/specifications"];
|
|
102
|
+
/** The statuses an ADR may have. */
|
|
103
|
+
const ADR_STATUSES = [
|
|
104
|
+
"proposed",
|
|
105
|
+
"accepted",
|
|
106
|
+
"rejected",
|
|
107
|
+
"deprecated",
|
|
108
|
+
"superseded"
|
|
109
|
+
];
|
|
110
|
+
/** The statuses a spec may have. */
|
|
111
|
+
const SPEC_STATUSES = [
|
|
112
|
+
"draft",
|
|
113
|
+
"proposed",
|
|
114
|
+
"accepted",
|
|
115
|
+
"archived",
|
|
116
|
+
"superseded"
|
|
117
|
+
];
|
|
118
|
+
/** The files in the ADR folder that are not ADRs. */
|
|
119
|
+
const ADR_EXEMPT = ["template.md", "README.md"];
|
|
120
|
+
// src/repo-validation/specs/classify-spec-path/classify-spec-path.ts
|
|
121
|
+
/**
|
|
122
|
+
* What a repo-relative path is to the ADR and spec check: an `adr` (a `.md` file directly in the ADR folder, other
|
|
123
|
+
* than the template and the README), a `spec` (a `*.spec.md` file directly in `.notes` or the wiki's specifications
|
|
124
|
+
* folder), or `undefined` for anything else, which the check leaves alone. Subfolders are not searched.
|
|
125
|
+
*/
|
|
126
|
+
function classifySpecPath(path) {
|
|
127
|
+
const slash = path.lastIndexOf("/");
|
|
128
|
+
const dir = path.slice(0, slash);
|
|
129
|
+
const name = path.slice(slash + 1);
|
|
130
|
+
if (dir === "docs/wiki/decisions") return name.endsWith(".md") && !ADR_EXEMPT.includes(name) ? "adr" : void 0;
|
|
131
|
+
if (SPEC_DIRS.includes(dir)) return name.endsWith(".spec.md") ? "spec" : void 0;
|
|
132
|
+
}
|
|
133
|
+
// src/repo-validation/specs/is-valid-iso-date/is-valid-iso-date.ts
|
|
134
|
+
/** Whether `value` is a `YYYY-MM-DD` date that exists as far as `Date.parse` can tell. */
|
|
135
|
+
function isValidIsoDate(value) {
|
|
136
|
+
return /^\d{4}-\d{2}-\d{2}$/.test(value) && !Number.isNaN(Date.parse(value));
|
|
137
|
+
}
|
|
138
|
+
// src/repo-validation/specs/parse-frontmatter/parse-frontmatter.ts
|
|
139
|
+
/**
|
|
140
|
+
* Reads a leading `---` block of `key: value` lines, with the line each one is on, plus one level of nesting keyed
|
|
141
|
+
* `parent.child` (the ADR template's `discussion:` / ` github:`). Any other line is skipped. Returns `null` when the
|
|
142
|
+
* text does not open with such a block.
|
|
143
|
+
*/
|
|
144
|
+
function parseFrontmatter(content) {
|
|
145
|
+
const match = /^---\n([\s\S]*?)\n---/.exec(content);
|
|
146
|
+
if (!match) return null;
|
|
147
|
+
const fields = /* @__PURE__ */ new Map();
|
|
148
|
+
let parent;
|
|
149
|
+
match[1].split("\n").forEach((text, i) => {
|
|
150
|
+
const line = i + 2;
|
|
151
|
+
const kv = /^(\w[\w-]*):\s*(.*)/.exec(text);
|
|
152
|
+
if (kv) {
|
|
153
|
+
fields.set(kv[1], {
|
|
154
|
+
value: kv[2].trim(),
|
|
155
|
+
line
|
|
156
|
+
});
|
|
157
|
+
parent = kv[1];
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const nested = /^\s+(\w[\w-]*):\s*(.*)/.exec(text);
|
|
161
|
+
if (nested && parent) fields.set(`${parent}.${nested[1]}`, {
|
|
162
|
+
value: nested[2].trim(),
|
|
163
|
+
line
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
return fields;
|
|
167
|
+
}
|
|
168
|
+
// src/repo-validation/specs/validate-adr/validate-adr.ts
|
|
169
|
+
/**
|
|
170
|
+
* The findings for one ADR's text. Errors: no frontmatter; a missing `id`, or one that is not `ADR-<the filename's
|
|
171
|
+
* four-digit prefix>`; a missing or empty `title`; a missing or unknown `status`; a missing or malformed `date`. A
|
|
172
|
+
* warning: an `accepted` ADR whose `discussion.github` is not set.
|
|
173
|
+
*/
|
|
174
|
+
function validateAdr(file, content) {
|
|
175
|
+
const findings = [];
|
|
176
|
+
const add = (rule, reason, line = 1, severity = "error") => {
|
|
177
|
+
findings.push({
|
|
178
|
+
file,
|
|
179
|
+
line,
|
|
180
|
+
rule,
|
|
181
|
+
reason,
|
|
182
|
+
severity
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
const fm = parseFrontmatter(content);
|
|
186
|
+
if (!fm) {
|
|
187
|
+
add("frontmatter", "no frontmatter found");
|
|
188
|
+
return findings;
|
|
189
|
+
}
|
|
190
|
+
const id = fm.get("id");
|
|
191
|
+
const sequence = /^(\d{4})-/.exec(file.slice(file.lastIndexOf("/") + 1))?.[1];
|
|
192
|
+
if (!id?.value) add("id", "missing `id` field", id?.line);
|
|
193
|
+
else if (sequence && id.value !== `ADR-${sequence}`) add("id", `id "${id.value}" does not match filename sequence (expected ADR-${sequence})`, id.line);
|
|
194
|
+
const title = fm.get("title");
|
|
195
|
+
if (!title?.value || title.value === "\"\"" || title.value === "''") add("title", "missing or empty `title` field", title?.line);
|
|
196
|
+
const status = fm.get("status");
|
|
197
|
+
if (!status?.value) add("status", "missing `status` field", status?.line);
|
|
198
|
+
else if (!ADR_STATUSES.includes(status.value)) add("status", `invalid status "${status.value}" — must be one of: ${ADR_STATUSES.join(", ")}`, status.line);
|
|
199
|
+
const date = fm.get("date");
|
|
200
|
+
if (!date?.value) add("date", "missing `date` field", date?.line);
|
|
201
|
+
else if (!isValidIsoDate(date.value)) add("date", `invalid date "${date.value}" — must be YYYY-MM-DD`, date.line);
|
|
202
|
+
if (status?.value === "accepted" && !fm.get("discussion.github")?.value && !fm.get("discussion")?.value) add("discussion", "status is accepted but `discussion.github` is not set", status.line, "warning");
|
|
203
|
+
return findings;
|
|
204
|
+
}
|
|
205
|
+
// src/repo-validation/specs/validate-spec/validate-spec.ts
|
|
206
|
+
/**
|
|
207
|
+
* The findings for one spec's text. Errors: no frontmatter; a missing or unknown `status`. A warning: a missing
|
|
208
|
+
* `issue` (every spec has a companion GitHub issue), except on an `archived` or `superseded` spec, many of which
|
|
209
|
+
* predate the issue-first process.
|
|
210
|
+
*/
|
|
211
|
+
function validateSpec(file, content) {
|
|
212
|
+
const fm = parseFrontmatter(content);
|
|
213
|
+
if (!fm) return [{
|
|
214
|
+
file,
|
|
215
|
+
line: 1,
|
|
216
|
+
rule: "frontmatter",
|
|
217
|
+
reason: "no frontmatter found",
|
|
218
|
+
severity: "error"
|
|
219
|
+
}];
|
|
220
|
+
const findings = [];
|
|
221
|
+
const status = fm.get("status");
|
|
222
|
+
if (!status?.value) findings.push({
|
|
223
|
+
file,
|
|
224
|
+
line: status?.line ?? 1,
|
|
225
|
+
rule: "status",
|
|
226
|
+
reason: "missing `status` field",
|
|
227
|
+
severity: "error"
|
|
228
|
+
});
|
|
229
|
+
else if (!SPEC_STATUSES.includes(status.value)) findings.push({
|
|
230
|
+
file,
|
|
231
|
+
line: status.line,
|
|
232
|
+
rule: "status",
|
|
233
|
+
reason: `invalid status "${status.value}" — must be one of: ${SPEC_STATUSES.join(", ")}`,
|
|
234
|
+
severity: "error"
|
|
235
|
+
});
|
|
236
|
+
if (!fm.get("issue")?.value && status?.value !== "archived" && status?.value !== "superseded") findings.push({
|
|
237
|
+
file,
|
|
238
|
+
line: 1,
|
|
239
|
+
rule: "issue",
|
|
240
|
+
reason: "missing `issue` field — every spec must have a companion GitHub issue",
|
|
241
|
+
severity: "warning"
|
|
242
|
+
});
|
|
243
|
+
return findings;
|
|
244
|
+
}
|
|
245
|
+
// src/repo-validation/specs/check-specs/check-specs.ts
|
|
246
|
+
/**
|
|
247
|
+
* The ADR and spec check over the files it is given: each one that is an ADR or a spec (see `classifySpecPath`) goes to
|
|
248
|
+
* its rules, and every other file is skipped. Whoever calls it decides which files to read (the whole tree, a PR's
|
|
249
|
+
* changed files) and supplies their text; nothing here touches the filesystem or the network.
|
|
250
|
+
*/
|
|
251
|
+
function checkSpecs(files) {
|
|
252
|
+
const result = {
|
|
253
|
+
fileCount: 0,
|
|
254
|
+
findings: []
|
|
255
|
+
};
|
|
256
|
+
for (const { path, text } of files) {
|
|
257
|
+
const kind = classifySpecPath(path);
|
|
258
|
+
if (!kind) continue;
|
|
259
|
+
result.fileCount++;
|
|
260
|
+
result.findings.push(...kind === "adr" ? validateAdr(path, text) : validateSpec(path, text));
|
|
261
|
+
}
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
export { ADR_DIR, ADR_EXEMPT, ADR_STATUSES, SPEC_DIRS, SPEC_STATUSES, checkSpecs, classifySpecPath, evaluateDocsPresence, hasDocsSignal, isAddedDocComment, isFeat, isValidIsoDate, packageOf, pageNames, parseFrontmatter, parseSkipDocs, validateAdr, validateSpec };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/astromech",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.285",
|
|
4
4
|
"description": "The Holocron task runner — one task manifest drives `holocron run`, `holocron run ci`, the CI workflows, package.json scripts, linters, and required checks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ci",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"@commitlint/lint": "^21.2.3",
|
|
56
56
|
"@commitlint/load": "^21.2.3",
|
|
57
57
|
"@commitlint/types": "^21.2.3",
|
|
58
|
+
"@theholocron/datapad": "5.0.0-alpha.285",
|
|
58
59
|
"@theholocron/fs-utils": "^1.16.1-alpha.3",
|
|
59
|
-
"@theholocron/datapad": "5.0.0-alpha.284",
|
|
60
60
|
"@theholocron/json-utils": "^1.16.1-alpha.3",
|
|
61
61
|
"@theholocron/pkg-utils": "^1.16.1-alpha.3"
|
|
62
62
|
},
|
|
@@ -74,14 +74,14 @@
|
|
|
74
74
|
"tsdown": "^0.23.3",
|
|
75
75
|
"typescript": "^5.9.3",
|
|
76
76
|
"vitest": "^5.0.5",
|
|
77
|
-
"@theholocron/ci": "1.0.0",
|
|
78
77
|
"@theholocron/commitlint-config": "^8.9.0-alpha.5",
|
|
79
|
-
"@theholocron/eslint-config": "^8.9.0-alpha.5",
|
|
80
78
|
"@theholocron/rollup-plugin-transform-template": "^8.9.0-alpha.5",
|
|
79
|
+
"@theholocron/ci": "1.0.0",
|
|
81
80
|
"@theholocron/semantic-release-config": "^8.9.0-alpha.5",
|
|
81
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.5",
|
|
82
82
|
"@theholocron/tsconfig": "^8.9.0-alpha.5",
|
|
83
83
|
"@theholocron/vitest-config": "^8.9.0-alpha.5",
|
|
84
|
-
"@theholocron/
|
|
84
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.5"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"@semantic-release/commit-analyzer": "^13",
|