@theholocron/cli 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/dist/cli.mjs CHANGED
@@ -29,7 +29,7 @@ import { findRootSync, isWorkspaceRoot, walkFilesSync } from "@theholocron/fs-ut
29
29
  import { access, copyFile, mkdir, open, readFile, readdir, realpath, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
30
30
  import { createServer } from "node:http";
31
31
  import { stringifyJson } from "@theholocron/json-utils";
32
- import { evaluateDocsPresence, isAddedDocComment, isFeat, packageOf, parseSkipDocs } from "@theholocron/astromech/repo-validation";
32
+ import { ADR_DIR, SPEC_DIRS, checkSpecs, evaluateDocsPresence, isAddedDocComment, isFeat, packageOf, parseSkipDocs } from "@theholocron/astromech/repo-validation";
33
33
  import { lintCommitMsgFile } from "@theholocron/astromech/lint";
34
34
  import { createGitHubClient } from "@theholocron/github-client";
35
35
  // src/env/env.ts
@@ -13931,6 +13931,80 @@ async function runProbe(input) {
13931
13931
  rows
13932
13932
  };
13933
13933
  }
13934
+ // src/commands/probe/specs/real-specs-io.ts
13935
+ /** The `specs check` probe's inputs from the real filesystem under `repoRoot`. */
13936
+ function realSpecsIo(repoRoot) {
13937
+ /* v8 ignore start -- reads the real filesystem; the probe is tested with an injected io */
13938
+ return {
13939
+ list: (dir) => {
13940
+ try {
13941
+ return readdirSync(join(repoRoot, dir));
13942
+ } catch {
13943
+ return [];
13944
+ }
13945
+ },
13946
+ read: (path) => {
13947
+ try {
13948
+ return readFileSync(join(repoRoot, path), "utf8");
13949
+ } catch {
13950
+ return;
13951
+ }
13952
+ },
13953
+ repoPath: (arg) => relative(repoRoot, resolve(arg)).split("\\").join("/")
13954
+ };
13955
+ /* v8 ignore stop */
13956
+ }
13957
+ // src/commands/probe/specs/specs-probe.ts
13958
+ /** The group of probes that check the repo's written decisions and designs. */
13959
+ const SPECS_PROVIDER = "specs";
13960
+ /** The files to read: the ones named, or every file in the ADR and spec folders. A named file that is gone is dropped. */
13961
+ function filesToRead(args, io) {
13962
+ return (args.length > 0 ? args.map((arg) => io.repoPath(arg)) : [ADR_DIR, ...SPEC_DIRS].flatMap((dir) => io.list(dir).sort().map((name) => `${dir}/${name}`))).flatMap((path) => {
13963
+ const text = io.read(path);
13964
+ return text === void 0 ? [] : [{
13965
+ path,
13966
+ text
13967
+ }];
13968
+ });
13969
+ }
13970
+ /**
13971
+ * `specs check [files...]`: validates the frontmatter of the ADRs (`docs/wiki/decisions/*.md`, other than the template and
13972
+ * the README) and specs (`.notes/*.spec.md` and `docs/wiki/specifications/*.spec.md`). Without files it reads every ADR
13973
+ * and spec; with files it checks the ones among them that are an ADR or a spec, and ignores the rest. An error fails
13974
+ * the run (a bad or missing `id`, `title`, `status` or `date`, an unknown status, no frontmatter); a warning is
13975
+ * reported and never fails it (an accepted ADR with no discussion link, a spec with no issue). This is the `adrs` job of
13976
+ * `platform.repoValidation`; the rules are `checkSpecs` in `@theholocron/astromech/repo-validation`, which Sentinel runs on
13977
+ * a pull request's files too.
13978
+ */
13979
+ function specsCheckProbe(io) {
13980
+ return {
13981
+ summary: "Fail for each ADR or spec with bad frontmatter; warn on a missing discussion link or issue (CI runs this).",
13982
+ writes: false,
13983
+ async run(ctx) {
13984
+ ctx.say({
13985
+ status: "heading",
13986
+ label: "ADRs and specs"
13987
+ });
13988
+ const { fileCount, findings } = checkSpecs(filesToRead(ctx.args ?? [], io));
13989
+ for (const f of findings) ctx.say({
13990
+ status: f.severity === "error" ? "fail" : "info",
13991
+ label: `${f.file}:${f.line}`,
13992
+ detail: `${f.reason} [${f.rule}]`
13993
+ });
13994
+ const errors = findings.filter((f) => f.severity === "error").length;
13995
+ const counts = `${fileCount} file(s) checked, ${errors} error(s), ${findings.length - errors} warning(s)`;
13996
+ ctx.say({
13997
+ status: errors === 0 ? "ok" : "info",
13998
+ label: "frontmatter",
13999
+ detail: counts
14000
+ });
14001
+ }
14002
+ };
14003
+ }
14004
+ /** The `specs` probes: the ADR and spec frontmatter check, over `io`. */
14005
+ function specsProbes(io) {
14006
+ return { check: specsCheckProbe(io) };
14007
+ }
13934
14008
  // src/commands/probe/probe.ts
13935
14009
  /**
13936
14010
  * `holocron probe [<provider> [<probe>]]`. With nothing, lists what can be probed; with a provider, lists its probes;
@@ -13952,6 +14026,7 @@ async function runProbeCommand(input) {
13952
14026
  groups.set(DEPS_PROVIDER, depsProbes(input.context.repoRoot, print));
13953
14027
  groups.set(GENERATED_PROVIDER, generatedProbes(input.loaded, input.context.repoRoot));
13954
14028
  groups.set("ci", ciProbes(input.context.org));
14029
+ groups.set(SPECS_PROVIDER, specsProbes(realSpecsIo(input.context.repoRoot)));
13955
14030
  if (!input.provider) {
13956
14031
  if (input.pick) await input.pick(groups);
13957
14032
  else for (const line of listProbes(groups)) print(line);
@@ -14476,7 +14551,7 @@ cp .agents/skills/adr/assets/template.md docs/wiki/decisions/000N-short-title.md
14476
14551
  \`\`\`
14477
14552
 
14478
14553
  \`madr\` has no CLI — creation is manual. Frontmatter is validated in CI
14479
- via \`scripts/validate-adrs.mjs\` (runs as part of the Lint workflow).
14554
+ via \`holocron probe specs check\` (the \`adrs\` job of \`platform.repoValidation\`).
14480
14555
 
14481
14556
  ## Status values
14482
14557