@sdd-method/maintain-cli 0.13.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/catalogue/aggregate.js +50 -13
  3. package/dist/lib/catalogue/build.js +72 -23
  4. package/dist/lib/catalogue/builders/adr-governs.js +1 -1
  5. package/dist/lib/catalogue/builders/adrs.js +2 -2
  6. package/dist/lib/catalogue/builders/c4-containers.js +6 -2
  7. package/dist/lib/catalogue/builders/contract-revisions.js +45 -7
  8. package/dist/lib/catalogue/builders/contracts.js +4 -11
  9. package/dist/lib/catalogue/builders/data-model.js +1 -1
  10. package/dist/lib/catalogue/builders/entities-manifest.js +10 -4
  11. package/dist/lib/catalogue/builders/entity-archetype.js +121 -0
  12. package/dist/lib/catalogue/builders/entity-merge.js +90 -0
  13. package/dist/lib/catalogue/builders/features.js +1 -1
  14. package/dist/lib/catalogue/builders/glossary-xref.js +11 -5
  15. package/dist/lib/catalogue/builders/journey-requirement.js +5 -5
  16. package/dist/lib/catalogue/builders/quality-scores.js +1 -1
  17. package/dist/lib/catalogue/builders/requirements.js +1 -1
  18. package/dist/lib/catalogue/builders/service-contract-consumes.js +2 -2
  19. package/dist/lib/catalogue/builders/service-entity-tables.js +1 -1
  20. package/dist/lib/catalogue/canonical-schema.yaml +50 -30
  21. package/dist/lib/catalogue/contract-id.js +49 -12
  22. package/dist/lib/catalogue/manifest-loader.js +1 -1
  23. package/dist/lib/catalogue/retired-catalogues.js +1 -1
  24. package/dist/lib/catalogue/rubric-coverage-map.yaml +7 -3
  25. package/dist/lib/catalogue/schema-compat.js +1 -1
  26. package/dist/lib/catalogue/staleness-verdicts.js +3 -3
  27. package/dist/lib/structure/catalogue.js +31 -10
  28. package/dist/lib/structure/compose.js +1 -1
  29. package/dist/lib/structure/effects.js +1 -1
  30. package/dist/lib/structure/intended.js +194 -0
  31. package/dist/lib/structure/model.js +1 -1
  32. package/dist/lib/structure/render.js +1 -1
  33. package/dist/lib/structure/view.js +8 -3
  34. package/dist/lib/validate/agreement-evidence.js +2 -2
  35. package/dist/lib/validate/behaviour-store.js +49 -12
  36. package/dist/lib/validate/dispatch.js +2 -2
  37. package/dist/lib/validate/journey-impact.js +7 -7
  38. package/dist/lib/validate/structural-model.js +48 -35
  39. package/dist/maintain-program.js +7 -1
  40. package/dist/maintain-version.json +2 -2
  41. package/dist/verbs/structure.js +95 -0
  42. package/dist/verify-version.json +2 -2
  43. package/package.json +2 -2
@@ -7,7 +7,8 @@
7
7
  // (M-ADR 0218 §4.2–4.3): the method payload, lock, CI block and briefing (`sync`,
8
8
  // `generate-briefing`), the derived model (`catalogue build | aggregate | graph | diff`), an
9
9
  // output the caller names (`pack build`, `render screen`), and a code repository's briefing
10
- // (`context pull`). Plus the whole verify surface, because the personas nest.
10
+ // (`context pull`), and the structural model's generated views (`structure render`, with `structure show` beside
11
+ // them). Plus the whole verify surface, because the personas nest.
11
12
  //
12
13
  // ⚠ As with sdd-verify, the boundary is ABSENCE, not a menu: the package ships only the import
13
14
  // closure of maintain-bin.js, so authoring verbs (init, scaffold, plan, conformance,
@@ -23,6 +24,7 @@ import { registerContext } from "./verbs/context.js";
23
24
  import { registerGenerateBriefing } from "./verbs/generate-briefing.js";
24
25
  import { registerPackBuild } from "./verbs/pack-build.js";
25
26
  import { registerRender } from "./verbs/render.js";
27
+ import { registerStructure } from "./verbs/structure.js";
26
28
  import { registerSync } from "./verbs/sync.js";
27
29
  const SPEC_URL = "docs/method/cli/sdd-cli-specification.md (in the method distribution)";
28
30
  /** The verbs maintain adds to verify, as `<verb>` or `<verb> <subcommand>`. Asserted by test. */
@@ -37,6 +39,8 @@ export const MAINTAIN_ONLY_SURFACE = [
37
39
  "catalogue diff",
38
40
  "pack build",
39
41
  "render screen",
42
+ "structure show",
43
+ "structure render",
40
44
  ];
41
45
  /** The full surface: verify's, plus maintain's own. */
42
46
  export const MAINTAIN_SURFACE = [...VERIFY_SURFACE, ...MAINTAIN_ONLY_SURFACE];
@@ -79,6 +83,8 @@ export function buildMaintainProgram() {
79
83
  registerGenerateBriefing(program);
80
84
  registerContext(program);
81
85
  registerRender(program);
86
+ // The structural model's generated views are derived (M-ADR 0230 §4.3); show is the read beside them.
87
+ registerStructure(program);
82
88
  const catalogue = program.commands.find((c) => c.name() === "catalogue");
83
89
  catalogue.description("Build, aggregate, validate and query per-SDD catalogues (M-ADR 0134) — the derived model");
84
90
  registerCatalogueBuild(catalogue);
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "0.13.1",
3
- "built_against_sdd_cli": "4.0.1"
2
+ "version": "0.15.0",
3
+ "built_against_sdd_cli": "5.1.0"
4
4
  }
@@ -0,0 +1,95 @@
1
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import { dirname, join } from "node:path";
3
+ import { stringify } from "yaml";
4
+ import { elementKey, loadModel, STRUCTURE_DIR } from "../lib/structure/model.js";
5
+ import { describeState, renderViews, viewState } from "../lib/structure/render.js";
6
+ import { revisionOf, viewOf } from "../lib/structure/view.js";
7
+ // `structure show <catalogue>/<id>`: one element of the structural model and its revision, the value a change's
8
+ // `base:` records for it (M-ADR 0230 §4.4). Read only.
9
+ export async function runStructureShow(sddPath, ref, write) {
10
+ const slash = ref.indexOf("/");
11
+ if (slash <= 0 || slash === ref.length - 1) {
12
+ write(`[FAIL] structure show: name an element as <catalogue>/<id>, not ${JSON.stringify(ref)}\n`);
13
+ return 2;
14
+ }
15
+ const catalogue = ref.slice(0, slash);
16
+ const id = ref.slice(slash + 1);
17
+ const problems = [];
18
+ const files = await loadModel(sddPath, problems);
19
+ if (files === null) {
20
+ write(`[FAIL] structure show: no structural model (${STRUCTURE_DIR}/) in ${sddPath}\n`);
21
+ return 1;
22
+ }
23
+ const e = viewOf(files, problems).get(catalogue)?.get(id);
24
+ if (!e) {
25
+ write(`[FAIL] structure show: the model holds no ${elementKey(catalogue, id)}\n`);
26
+ for (const p of problems)
27
+ write(` ${p}\n`);
28
+ return 1;
29
+ }
30
+ write(`# ${elementKey(catalogue, id)} in ${e.file} (partition ${e.partition})\n`);
31
+ write(`revision: ${revisionOf(e)}\n`);
32
+ write(stringify({ id: e.id, ...e.columns }));
33
+ return 0;
34
+ }
35
+ // `structure render [--check]`: write the generated views of the current view (M-ADR 0230 §4.3), or, with
36
+ // --check, write nothing and report each view that is missing, stale or edited by hand (exit 1 if any is).
37
+ export async function runStructureRender(sddPath, options, write) {
38
+ const problems = [];
39
+ const files = await loadModel(sddPath, problems);
40
+ if (files === null) {
41
+ write(`[FAIL] structure render: no structural model (${STRUCTURE_DIR}/) in ${sddPath}\n`);
42
+ return 1;
43
+ }
44
+ const view = viewOf(files, problems);
45
+ if (problems.length > 0) {
46
+ write(`[FAIL] structure render: the model does not load cleanly; run \`sdd-cli validate --validator structural-model\`\n`);
47
+ for (const p of problems)
48
+ write(` ${p}\n`);
49
+ return 1;
50
+ }
51
+ let off = 0;
52
+ for (const [path, rendered] of renderViews(view)) {
53
+ const abs = join(sddPath, path);
54
+ const text = await readFile(abs, "utf8").catch(() => null);
55
+ const state = viewState(rendered, text);
56
+ if (options.check) {
57
+ if (state !== "current") {
58
+ off++;
59
+ write(`[WARN] ${describeState(path, state)}\n`);
60
+ }
61
+ continue;
62
+ }
63
+ if (state === "hand-edited")
64
+ write(`[WARN] ${describeState(path, state)}; the edit is overwritten\n`);
65
+ if (state !== "current") {
66
+ await mkdir(dirname(abs), { recursive: true });
67
+ await writeFile(abs, rendered, "utf8");
68
+ }
69
+ write(`${state === "current" ? "unchanged" : "wrote"} ${path}\n`);
70
+ }
71
+ if (options.check)
72
+ write(off === 0 ? "[PASS] structure render --check: every view is current\n" : `[FAIL] structure render --check: ${off} view(s) not current\n`);
73
+ return options.check && off > 0 ? 1 : 0;
74
+ }
75
+ // Read the model and write its generated views: maintain's and sdd-cli's (M-ADR 0230 §4.3, at its acceptance).
76
+ // Extraction is the author's (migrate-structure.ts), registered apart so this module's closure carries no extractor.
77
+ export function registerStructure(program) {
78
+ const structure = program.command("structure").description("Read the structural model, and write its generated views (M-ADR 0230)");
79
+ structure
80
+ .command("show <element>")
81
+ .description("Print one element of the structural model, <catalogue>/<id>, with its revision")
82
+ .option("--sdd-path <path>", "the SDD (default: the current directory)", ".")
83
+ .action(async (element, opts) => {
84
+ process.exitCode = await runStructureShow(opts.sddPath, element, (s) => process.stdout.write(s));
85
+ });
86
+ structure
87
+ .command("render")
88
+ .description("Write the generated views of the structural model under docs/structure/; --check reports instead")
89
+ .option("--sdd-path <path>", "the SDD (default: the current directory)", ".")
90
+ .option("--check", "write nothing; report each view that is missing, stale or edited by hand", false)
91
+ .action(async (opts) => {
92
+ process.exitCode = await runStructureRender(opts.sddPath, { check: opts.check }, (s) => process.stdout.write(s));
93
+ });
94
+ }
95
+ //# sourceMappingURL=structure.js.map
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "4.0.1",
3
- "built_against_sdd_cli": "4.0.1"
2
+ "version": "5.1.0",
3
+ "built_against_sdd_cli": "5.1.0"
4
4
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sdd-method/maintain-cli",
3
- "version": "0.13.1",
4
- "sddCliVersion": "4.0.1",
3
+ "version": "0.15.0",
4
+ "sddCliVersion": "5.1.0",
5
5
  "description": "Bring an SDD repository current and rebuild its derived model — sync, briefing, catalogue build and aggregate, pack build, context pull — plus every read-only verify verb. Ships only the code those verbs reach; it cannot author specification content. Authoring is in @sdd-method/sdd-cli.",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",