@delurio/cli 0.10.0 → 0.11.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 (86) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/NOTICE +7 -0
  3. package/README.md +14 -13
  4. package/js/changes.d.ts +17 -0
  5. package/js/cli.js +6 -0
  6. package/{dist → js}/edges.d.ts +2 -2
  7. package/js/edges.js +40 -0
  8. package/js/expr.js +25 -0
  9. package/js/graph.js +59 -0
  10. package/{dist → js}/html.d.ts +6 -6
  11. package/js/html.js +13 -0
  12. package/js/internal.js +408 -0
  13. package/js/kit.js +54 -0
  14. package/{dist → js}/model.d.ts +2 -2
  15. package/js/model.js +136 -0
  16. package/js/native.cjs +46 -0
  17. package/js/native.d.cts +322 -0
  18. package/{dist → js}/nav.d.ts +1 -1
  19. package/js/nav.js +70 -0
  20. package/js/needs.js +30 -0
  21. package/{dist → js}/spine.d.ts +3 -3
  22. package/js/spine.js +22 -0
  23. package/{dist → js}/starts.d.ts +1 -3
  24. package/{dist → js}/story.d.ts +2 -2
  25. package/js/story.js +22 -0
  26. package/{dist → js}/wireframe.d.ts +2 -2
  27. package/js/wireframe.js +29 -0
  28. package/js/yaml.d.ts +20 -0
  29. package/js/yaml.js +40 -0
  30. package/package.json +40 -24
  31. package/dist/anchors.d.ts +0 -29
  32. package/dist/anchors.js +0 -160
  33. package/dist/changes.d.ts +0 -25
  34. package/dist/changes.js +0 -101
  35. package/dist/check.d.ts +0 -23
  36. package/dist/check.js +0 -649
  37. package/dist/cli.d.ts +0 -2
  38. package/dist/cli.js +0 -194
  39. package/dist/compare.d.ts +0 -34
  40. package/dist/compare.js +0 -143
  41. package/dist/diff-flow.d.ts +0 -33
  42. package/dist/diff-flow.js +0 -547
  43. package/dist/diff-nav.d.ts +0 -20
  44. package/dist/diff-nav.js +0 -401
  45. package/dist/diff.d.ts +0 -25
  46. package/dist/diff.js +0 -331
  47. package/dist/domain-names.d.ts +0 -18
  48. package/dist/domain-names.js +0 -124
  49. package/dist/domain.d.ts +0 -25
  50. package/dist/domain.js +0 -110
  51. package/dist/edges.js +0 -120
  52. package/dist/expr.js +0 -157
  53. package/dist/graph.js +0 -236
  54. package/dist/html.js +0 -311
  55. package/dist/index-page.d.ts +0 -12
  56. package/dist/index-page.js +0 -50
  57. package/dist/invokes.d.ts +0 -10
  58. package/dist/invokes.js +0 -67
  59. package/dist/kit.js +0 -711
  60. package/dist/mermaid.d.ts +0 -3
  61. package/dist/mermaid.js +0 -50
  62. package/dist/model.js +0 -608
  63. package/dist/nav-page.d.ts +0 -15
  64. package/dist/nav-page.js +0 -283
  65. package/dist/nav.js +0 -578
  66. package/dist/needs.js +0 -335
  67. package/dist/pan.d.ts +0 -2
  68. package/dist/pan.js +0 -252
  69. package/dist/schemas.d.ts +0 -15
  70. package/dist/schemas.js +0 -316
  71. package/dist/spine.js +0 -156
  72. package/dist/starts.js +0 -88
  73. package/dist/story.js +0 -109
  74. package/dist/tutorial-check.d.ts +0 -9
  75. package/dist/tutorial-check.js +0 -297
  76. package/dist/ui-check.d.ts +0 -8
  77. package/dist/ui-check.js +0 -142
  78. package/dist/watch.d.ts +0 -5
  79. package/dist/watch.js +0 -114
  80. package/dist/wireframe.js +0 -276
  81. package/dist/yaml.d.ts +0 -19
  82. package/dist/yaml.js +0 -134
  83. /package/{dist → js}/expr.d.ts +0 -0
  84. /package/{dist → js}/graph.d.ts +0 -0
  85. /package/{dist → js}/kit.d.ts +0 -0
  86. /package/{dist → js}/needs.d.ts +0 -0
package/package.json CHANGED
@@ -1,44 +1,60 @@
1
1
  {
2
2
  "name": "@delurio/cli",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "The open checker and page of delurio-graph/0: check every graph in a project's own CI, offline, with GNU error lines and SARIF.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
- "bin": { "delurio": "dist/cli.js" },
7
+ "bin": { "delurio": "js/cli.js" },
8
8
  "exports": {
9
- "./graph": { "types": "./dist/graph.d.ts", "default": "./dist/graph.js" },
10
- "./model": { "types": "./dist/model.d.ts", "default": "./dist/model.js" },
11
- "./story": { "types": "./dist/story.d.ts", "default": "./dist/story.js" },
12
- "./wireframe": { "types": "./dist/wireframe.d.ts", "default": "./dist/wireframe.js" },
13
- "./kit": { "types": "./dist/kit.d.ts", "default": "./dist/kit.js" },
14
- "./edges": { "types": "./dist/edges.d.ts", "default": "./dist/edges.js" },
15
- "./html": { "types": "./dist/html.d.ts", "default": "./dist/html.js" },
16
- "./nav": { "types": "./dist/nav.d.ts", "default": "./dist/nav.js" },
17
- "./expr": { "types": "./dist/expr.d.ts", "default": "./dist/expr.js" },
18
- "./spine": { "types": "./dist/spine.d.ts", "default": "./dist/spine.js" },
19
- "./yaml": { "types": "./dist/yaml.d.ts", "default": "./dist/yaml.js" },
20
- "./needs": { "types": "./dist/needs.d.ts", "default": "./dist/needs.js" },
9
+ "./graph": { "types": "./js/graph.d.ts", "default": "./js/graph.js" },
10
+ "./model": { "types": "./js/model.d.ts", "default": "./js/model.js" },
11
+ "./story": { "types": "./js/story.d.ts", "default": "./js/story.js" },
12
+ "./wireframe": { "types": "./js/wireframe.d.ts", "default": "./js/wireframe.js" },
13
+ "./kit": { "types": "./js/kit.d.ts", "default": "./js/kit.js" },
14
+ "./edges": { "types": "./js/edges.d.ts", "default": "./js/edges.js" },
15
+ "./html": { "types": "./js/html.d.ts", "default": "./js/html.js" },
16
+ "./nav": { "types": "./js/nav.d.ts", "default": "./js/nav.js" },
17
+ "./expr": { "types": "./js/expr.d.ts", "default": "./js/expr.js" },
18
+ "./spine": { "types": "./js/spine.d.ts", "default": "./js/spine.js" },
19
+ "./yaml": { "types": "./js/yaml.d.ts", "default": "./js/yaml.js" },
20
+ "./needs": { "types": "./js/needs.d.ts", "default": "./js/needs.js" },
21
21
  "./package.json": "./package.json"
22
22
  },
23
- "files": ["dist", "schemas", "SPEC.md", "NOTICE", "CHANGELOG.md"],
23
+ "files": ["js", "schemas", "SPEC.md", "NOTICE", "CHANGELOG.md"],
24
24
  "engines": { "node": ">=26" },
25
25
  "repository": { "type": "git", "url": "git+https://github.com/delurio-labs/delurio.git" },
26
26
  "homepage": "https://delur.io",
27
27
  "bugs": "https://github.com/delurio-labs/delurio/issues",
28
28
  "keywords": ["statechart", "graph", "spec", "checker", "sarif", "ci"],
29
+ "napi": {
30
+ "binaryName": "delurio",
31
+ "packageName": "@delurio/cli",
32
+ "targets": [
33
+ "x86_64-unknown-linux-gnu",
34
+ "x86_64-unknown-linux-musl",
35
+ "aarch64-unknown-linux-gnu",
36
+ "aarch64-unknown-linux-musl",
37
+ "aarch64-apple-darwin",
38
+ "x86_64-pc-windows-msvc"
39
+ ]
40
+ },
29
41
  "scripts": {
30
- "check": "tsc --noEmit",
31
- "build": "tsc -p tsconfig.build.json",
32
- "test": "node src/cli.ts check examples --strict"
42
+ "build": "napi build --platform --release --manifest-path crates/delurio-node/Cargo.toml --package-json-path package.json --output-dir . --no-js --dts js/native.d.cts",
43
+ "build:debug": "napi build --platform --manifest-path crates/delurio-node/Cargo.toml --package-json-path package.json --output-dir . --no-js --dts js/native.d.cts",
44
+ "test": "node --test tests/node/"
33
45
  },
34
46
  "dependencies": {
35
- "ajv": "8.20.0",
36
- "ajv-formats": "3.0.1",
37
- "elkjs": "0.12.1",
38
- "yaml": "2.9.1"
47
+ "elkjs": "0.12.1"
48
+ },
49
+ "optionalDependencies": {
50
+ "@delurio/cli-linux-x64-gnu": "0.11.0",
51
+ "@delurio/cli-linux-x64-musl": "0.11.0",
52
+ "@delurio/cli-linux-arm64-gnu": "0.11.0",
53
+ "@delurio/cli-linux-arm64-musl": "0.11.0",
54
+ "@delurio/cli-darwin-arm64": "0.11.0",
55
+ "@delurio/cli-win32-x64-msvc": "0.11.0"
39
56
  },
40
57
  "devDependencies": {
41
- "@types/node": "26.6.6",
42
- "typescript": "7.0.2"
58
+ "@napi-rs/cli": "3.10.12"
43
59
  }
44
60
  }
package/dist/anchors.d.ts DELETED
@@ -1,29 +0,0 @@
1
- export type AnchorRule = 'source-unresolved' | 'citation-unresolved';
2
- export interface AnchorProblem {
3
- rule: AnchorRule;
4
- file: string;
5
- line: number;
6
- column: number;
7
- message: string;
8
- graph: string;
9
- element: string;
10
- }
11
- export interface AnchorsCheck {
12
- problems: AnchorProblem[];
13
- anchors: number;
14
- citations: number;
15
- }
16
- export declare class AppFiles {
17
- private readonly kinds;
18
- private readonly lines;
19
- readonly root: string;
20
- constructor(root: string);
21
- abs(path: string): string;
22
- kind(path: string): 'file' | 'folder' | null;
23
- lineCount(path: string): number;
24
- unresolved(value: string): {
25
- subject: string;
26
- reason: string;
27
- } | null;
28
- }
29
- export declare function checkAnchors(files: string[], app: string | null): AnchorsCheck;
package/dist/anchors.js DELETED
@@ -1,160 +0,0 @@
1
- // Source anchors held to the code they name (SPEC.md §9). Every `source:` that a graph file's schema gives as an anchor
2
- // names a file of the application's repository, from its root, and, with a line, a line within that file: one that
3
- // does not is an error (`source-unresolved`), as a need's evidence is (SPEC.md §13). A `path:line` written in a graph's
4
- // words (a description, a `say`, a note) is no anchor, but it cites the code all the same, so it is held to the code
5
- // too, as a warning (`citation-unresolved`): words are not parsed, so only a token that reads as a path from the
6
- // repository's root, a folder of the root first and a file with an extension last, is looked at. Under --no-app neither
7
- // is looked for, and only counted.
8
- import { existsSync, readFileSync, statSync } from 'node:fs';
9
- import { basename, dirname, isAbsolute, join } from 'node:path';
10
- import { anchorsIn, schemaKindOf } from './schemas.js';
11
- import { keyAt, readYaml } from './yaml.js';
12
- const FORMAT = 'delurio-graph/0';
13
- // the kinds whose files carry anchors; a need's evidence is held by its own rule, and a catalog holds the product's
14
- // words, which cite nothing
15
- const ANCHORED = new Set(['flow', 'ui', 'nav', 'domain']);
16
- const WORDED = new Set(['flow', 'ui', 'nav', 'domain', 'needs']);
17
- // what is data rather than words: sample values of the screens, records of an entity, the anchors themselves and a nav
18
- // graph's source; and in a needs file a need's evidence, which its own rule holds (a nav page's evidence is words)
19
- const NOT_WORDS = new Set(['samples', 'examples', 'source']);
20
- const NOT_NEEDS_WORDS = new Set([...NOT_WORDS, 'evidence']);
21
- const lineCount = (body) => body.split('\n').length - (body.endsWith('\n') ? 1 : 0);
22
- const pointer = (path) => path.map((s) => `/${s.replace(/~/g, '~0').replace(/\//g, '~1')}`).join('');
23
- // the files of the application, each looked up once per run: whether it is there and is a file, and its lines
24
- export class AppFiles {
25
- kinds = new Map();
26
- lines = new Map();
27
- root;
28
- constructor(root) {
29
- this.root = root;
30
- }
31
- abs(path) {
32
- return isAbsolute(path) ? path : join(this.root, path);
33
- }
34
- kind(path) {
35
- const abs = this.abs(path);
36
- if (!this.kinds.has(abs))
37
- this.kinds.set(abs, existsSync(abs) ? (statSync(abs).isFile() ? 'file' : 'folder') : null);
38
- return this.kinds.get(abs) ?? null;
39
- }
40
- lineCount(path) {
41
- const abs = this.abs(path);
42
- if (!this.lines.has(abs))
43
- this.lines.set(abs, lineCount(readFileSync(abs, 'utf8')));
44
- return this.lines.get(abs) ?? 0;
45
- }
46
- // why `<path>[:<line>]` names nothing under the root, or null when it names a file and a line within it: what is
47
- // wrong (the path, or the path and its line) and what is wrong with it
48
- unresolved(value) {
49
- const m = /^(.*?)(?::(\d+))?$/.exec(value);
50
- const kind = this.kind(m[1]);
51
- if (kind === null)
52
- return { subject: m[1], reason: 'does not exist' };
53
- if (kind === 'folder')
54
- return { subject: m[1], reason: 'is a folder: an anchor names a file' };
55
- if (m[2] === undefined)
56
- return null;
57
- const line = Number(m[2]);
58
- const n = this.lineCount(m[1]);
59
- if (line < 1)
60
- return { subject: value, reason: `names line ${line}: a file's lines count from 1` };
61
- return line > n ? { subject: value, reason: `is past the file's end: it has ${n} ${n === 1 ? 'line' : 'lines'}` } : null;
62
- }
63
- }
64
- // a token of words that reads as `<path>:<line>`: a folder, then a file with an extension, then the line, and a range's
65
- // last line after a dash; not inside an address, a longer path or a word
66
- const CITATION = /(?<![\p{L}\p{N}_.\/:@~+\-])((?:[\p{L}\p{N}_@.][\p{L}\p{N}_@.()[\]+\-]*\/)+[\p{L}\p{N}_@()[\]+\-.]*?\.[A-Za-z][A-Za-z0-9]*):(\d+)(?:-(\d+))?(?!\d)/gu;
67
- // the folder given as source.app by a nav graph, or by the nav.yaml beside a generated one, to say where an anchor
68
- // would have been had it been written from there
69
- function navApp(file, doc) {
70
- const own = doc.source?.app;
71
- if (typeof own === 'string')
72
- return own;
73
- const beside = join(dirname(file), 'nav.yaml');
74
- if (basename(file) === 'nav.yaml' || !existsSync(beside))
75
- return null;
76
- try {
77
- const app = (readYaml(readFileSync(beside, 'utf8'))?.source)?.app;
78
- return typeof app === 'string' ? app : null;
79
- }
80
- catch {
81
- return null;
82
- }
83
- }
84
- // every anchor and every citation in words of the graph files given, against the application's files under `app`;
85
- // with `app` null (--no-app), each is counted and none is looked for
86
- export function checkAnchors(files, app) {
87
- const out = { problems: [], anchors: 0, citations: 0 };
88
- const code = app === null ? null : new AppFiles(app);
89
- for (const file of files) {
90
- const kind = schemaKindOf(file);
91
- if (kind === null || !WORDED.has(kind))
92
- continue;
93
- let text;
94
- let doc;
95
- try {
96
- text = readFileSync(file, 'utf8');
97
- doc = readYaml(text);
98
- }
99
- catch {
100
- continue; // the schema rule, or the graph's load, says why
101
- }
102
- if (doc === null || typeof doc !== 'object' || Array.isArray(doc))
103
- continue;
104
- const own = doc;
105
- if (typeof own.schema === 'string' && own.schema !== FORMAT)
106
- continue;
107
- const graph = typeof own.id === 'string' ? own.id : basename(dirname(file));
108
- const name = basename(file);
109
- const problem = (rule, path, message, element) => {
110
- out.problems.push({ rule, file, ...keyAt(text, path), message, graph, element });
111
- };
112
- if (ANCHORED.has(kind)) {
113
- const navFrom = kind === 'nav' ? navApp(file, own) : null;
114
- for (const { path, value } of anchorsIn(kind, doc)) {
115
- if (!/^[^\s:]+(:[0-9]+)?$/.test(value))
116
- continue; // the schema rule says why
117
- out.anchors++;
118
- const why = code?.unresolved(value) ?? null;
119
- if (why === null)
120
- continue;
121
- const where = path.slice(0, -1).join('.') || 'the graph';
122
- const from = navFrom === null || code === null ? null : join(navFrom, value);
123
- const there = from !== null && code?.unresolved(from) === null ? `; ${from} is there: an anchor is written from the repository's root, not from source.app` : '';
124
- problem('source-unresolved', path, `${where}: source ${why.subject} ${why.reason}${there} (SPEC.md §9)`, `${name}#${pointer(path)}`);
125
- }
126
- }
127
- const skip = kind === 'needs' ? NOT_NEEDS_WORDS : NOT_WORDS;
128
- const words = (value, path) => {
129
- if (typeof value === 'string') {
130
- for (const m of value.matchAll(CITATION)) {
131
- const first = m[1].split('/')[0];
132
- if (first === '.' || first === '..')
133
- continue;
134
- if (code !== null && code.kind(first) !== 'folder')
135
- continue; // not a path from the repository's root
136
- out.citations++;
137
- if (code === null)
138
- continue;
139
- const line = Math.max(Number(m[2]), Number(m[3] ?? 0));
140
- const why = code.unresolved(`${m[1]}:${line}`);
141
- if (why === null)
142
- continue;
143
- const cited = m[0];
144
- const said = why.subject === m[1] ? `and ${why.subject} ${why.reason}` : `which ${why.reason}`;
145
- problem('citation-unresolved', path, `${path.join('.')} cites ${cited}, ${said} (SPEC.md §9)`, `${name}#${pointer(path)}/${cited}`);
146
- }
147
- return;
148
- }
149
- if (Array.isArray(value))
150
- value.forEach((x, i) => words(x, [...path, String(i)]));
151
- else if (value !== null && typeof value === 'object') {
152
- for (const [k, x] of Object.entries(value))
153
- if (!skip.has(k))
154
- words(x, [...path, k]);
155
- }
156
- };
157
- words(doc, []);
158
- }
159
- return out;
160
- }
package/dist/changes.d.ts DELETED
@@ -1,25 +0,0 @@
1
- import type { Graph } from './graph.ts';
2
- export interface DomainAction {
3
- route?: string;
4
- serverFn?: string;
5
- result?: {
6
- returns?: string;
7
- };
8
- sideEffects?: unknown[];
9
- }
10
- export interface Domain {
11
- id?: string;
12
- actions?: Record<string, DomainAction | null>;
13
- policies?: Array<{
14
- do?: string[];
15
- write?: string[];
16
- }>;
17
- }
18
- export interface ChangesCheck {
19
- writes: string[];
20
- key: string | null;
21
- missing: string | null;
22
- problems: string[];
23
- }
24
- export declare function flowDomain(g: Graph, seen?: Map<string, Domain | null>): Domain | null;
25
- export declare function checkChanges(g: Graph, domainOf?: () => Domain | null): ChangesCheck | null;
package/dist/changes.js DELETED
@@ -1,101 +0,0 @@
1
- // `changes:` in ui.yaml (SPEC.md §4): a flow whose steps write something tells its users, in its own note, what it
2
- // changes and what follows, or says why it has none yet (`missing`, a gap; decided on 16 Nov 2026, d-1116-11). An action writes when its route or its server function is not a GET, when a policy lets
3
- // someone `write` with it, or when it is a step inside the service (neither a route nor a server function) that returns
4
- // an entity; all three are read from the flow's domain, looked up by id among the graphs beside this one, all its files
5
- // read as one (SPEC.md §5). A GET that a policy lists is held to what it does: it writes only when one of its
6
- // `sideEffects` is more than an audit record of the call (`audit:<event>`), as a policy names reads and writes together
7
- // (SPEC.md §4, decided on 16 Nov 2026, d-1116-12). A flow with no screens, or whose domain is not found, is not checked.
8
- import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
9
- import { basename, dirname, join } from 'node:path';
10
- import { inReadingOrder, isDomainText, mayBeDomain, mergeDomain } from './domain.js';
11
- const SKIP = new Set(['viz', 'video', 'node_modules', '.git']);
12
- // the root to search: the nearest folder called `graphs` above the graph, else the graph's parent
13
- function rootOf(dir) {
14
- for (let d = dir, i = 0; i < 5; i++, d = dirname(d))
15
- if (basename(d) === 'graphs')
16
- return d;
17
- return dirname(dir);
18
- }
19
- function domainUnder(root, id, depth = 4) {
20
- const names = readdirSync(root);
21
- const parts = inReadingOrder(names.filter((name) => mayBeDomain(name) && statSync(join(root, name)).isFile()))
22
- .map((name) => ({ file: join(root, name), text: readFileSync(join(root, name), 'utf8') }))
23
- .filter((p) => isDomainText(p.text));
24
- if (parts.length > 0) {
25
- const merged = mergeDomain(parts);
26
- if (merged.id === id)
27
- return merged.doc;
28
- }
29
- if (depth === 0)
30
- return null;
31
- for (const name of names) {
32
- if (SKIP.has(name))
33
- continue;
34
- const sub = join(root, name);
35
- if (!statSync(sub).isDirectory())
36
- continue;
37
- const found = domainUnder(sub, id, depth - 1);
38
- if (found !== null)
39
- return found;
40
- }
41
- return null;
42
- }
43
- // the domain the flow names, looked up by id among the graphs beside it; null when it names none or it is not found.
44
- // `seen` keeps what a run has found, so that the flows that name one domain look it up once
45
- export function flowDomain(g, seen) {
46
- if (g.flow.domain === undefined)
47
- return null;
48
- const root = rootOf(g.dir);
49
- const key = `${root}\0${g.flow.domain}`;
50
- if (seen?.has(key) === true)
51
- return structuredClone(seen.get(key));
52
- const found = domainUnder(root, g.flow.domain);
53
- seen?.set(key, found);
54
- return seen === undefined ? found : structuredClone(found);
55
- }
56
- // the HTTP method of an action's route or server function; undefined for a step inside the service
57
- const methodOf = (a) => (a?.route ?? a?.serverFn)?.trim().split(/\s+/)[0]?.toUpperCase();
58
- // a side effect that records the call and changes nothing the flow's users are told of: `audit:<event>` (SPEC.md §5)
59
- const isAudit = (s) => typeof s === 'string' && s.trimStart().startsWith('audit:');
60
- // a GET that a writing policy lists writes only when it does more than record that it was called: a policy names its
61
- // actor's reads and writes together, and a GET reads (SPEC.md §4)
62
- const writesThroughPolicy = (a) => methodOf(a) !== 'GET' || (Array.isArray(a?.sideEffects) && a.sideEffects.some((s) => !isAudit(s)));
63
- // `domainOf` finds the flow's domain, called at most once: a caller that reads the domain for another rule as well
64
- // hands over the one it found
65
- export function checkChanges(g, domainOf = () => flowDomain(g)) {
66
- if (g.ui.absent === true)
67
- return null;
68
- const domain = domainOf();
69
- if (domain === null)
70
- return null;
71
- const writing = new Set();
72
- for (const [name, a] of Object.entries(domain.actions ?? {})) {
73
- const method = methodOf(a);
74
- if ((method !== undefined && method !== 'GET') || (method === undefined && a?.result?.returns !== undefined))
75
- writing.add(name);
76
- }
77
- for (const p of domain.policies ?? [])
78
- if ((p.write ?? []).length > 0)
79
- for (const name of p.do ?? [])
80
- if (writesThroughPolicy(domain.actions?.[name]))
81
- writing.add(name);
82
- const invoked = Object.values(g.flow.states).map((s) => s.invoke?.action);
83
- const writes = [...new Set(invoked.filter((a) => a !== undefined && writing.has(a)))].sort();
84
- const key = g.ui.changes?.key ?? null;
85
- const said = g.ui.changes?.missing;
86
- // the note a writing flow says it has no message for yet; a flow that writes nothing is missing none
87
- const missing = writes.length > 0 && key === null && typeof said === 'string' && said.trim() !== '' ? said.trim() : null;
88
- const problems = [];
89
- if (writes.length > 0 && key === null && missing === null)
90
- problems.push(`its steps write (${writes.join(', ')}), but ui.yaml has no changes note (SPEC.md §4)`);
91
- if (key !== null) {
92
- for (const locale of g.ui.locales ?? [basename(g.ui.catalog, '.json')]) {
93
- const file = join(g.dir, dirname(g.ui.catalog), `${locale}.json`);
94
- const catalog = existsSync(file) ? JSON.parse(readFileSync(file, 'utf8')) : null;
95
- const note = catalog?.[key];
96
- if (typeof note !== 'string' || note.trim() === '')
97
- problems.push(`the changes note ${key} is not in the ${locale} catalog`);
98
- }
99
- }
100
- return { writes, key, missing, problems };
101
- }
package/dist/check.d.ts DELETED
@@ -1,23 +0,0 @@
1
- export declare const CHECK_USAGE: string;
2
- type Level = 'error' | 'warning' | 'note';
3
- interface Place {
4
- file: string;
5
- line: number;
6
- column: number;
7
- }
8
- interface Note extends Place {
9
- message: string;
10
- }
11
- export interface CheckResult extends Place {
12
- rule: string;
13
- level: Level;
14
- message: string;
15
- graph: string;
16
- element: string;
17
- notes: Note[];
18
- baselineState?: 'new' | 'unchanged';
19
- }
20
- export declare const count: (n: number, word: string) => string;
21
- export declare function graphDirs(root: string, out?: string[]): string[];
22
- export declare function checkMain(args: string[]): number;
23
- export {};