@delurio/cli 0.9.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 +24 -0
  2. package/NOTICE +7 -0
  3. package/README.md +16 -15
  4. package/SPEC.md +37 -11
  5. package/js/changes.d.ts +17 -0
  6. package/js/cli.js +6 -0
  7. package/{dist → js}/edges.d.ts +2 -2
  8. package/js/edges.js +40 -0
  9. package/js/expr.js +25 -0
  10. package/js/graph.js +59 -0
  11. package/{dist → js}/html.d.ts +6 -6
  12. package/js/html.js +13 -0
  13. package/js/internal.js +408 -0
  14. package/js/kit.js +54 -0
  15. package/{dist → js}/model.d.ts +2 -2
  16. package/js/model.js +136 -0
  17. package/js/native.cjs +46 -0
  18. package/js/native.d.cts +322 -0
  19. package/{dist → js}/nav.d.ts +1 -1
  20. package/js/nav.js +70 -0
  21. package/{dist → js}/needs.d.ts +3 -2
  22. package/js/needs.js +30 -0
  23. package/{dist → js}/spine.d.ts +3 -3
  24. package/js/spine.js +22 -0
  25. package/{dist → js}/starts.d.ts +1 -3
  26. package/{dist → js}/story.d.ts +2 -2
  27. package/js/story.js +22 -0
  28. package/{dist → js}/wireframe.d.ts +4 -2
  29. package/js/wireframe.js +29 -0
  30. package/js/yaml.d.ts +20 -0
  31. package/js/yaml.js +40 -0
  32. package/package.json +41 -25
  33. package/schemas/domain.schema.json +3 -0
  34. package/dist/changes.d.ts +0 -25
  35. package/dist/changes.js +0 -101
  36. package/dist/check.d.ts +0 -23
  37. package/dist/check.js +0 -574
  38. package/dist/cli.d.ts +0 -2
  39. package/dist/cli.js +0 -194
  40. package/dist/compare.d.ts +0 -34
  41. package/dist/compare.js +0 -143
  42. package/dist/diff-flow.d.ts +0 -33
  43. package/dist/diff-flow.js +0 -547
  44. package/dist/diff-nav.d.ts +0 -20
  45. package/dist/diff-nav.js +0 -401
  46. package/dist/diff.d.ts +0 -25
  47. package/dist/diff.js +0 -331
  48. package/dist/domain-names.d.ts +0 -18
  49. package/dist/domain-names.js +0 -124
  50. package/dist/domain.d.ts +0 -25
  51. package/dist/domain.js +0 -110
  52. package/dist/edges.js +0 -120
  53. package/dist/expr.js +0 -157
  54. package/dist/graph.js +0 -236
  55. package/dist/html.js +0 -311
  56. package/dist/index-page.d.ts +0 -12
  57. package/dist/index-page.js +0 -50
  58. package/dist/invokes.d.ts +0 -10
  59. package/dist/invokes.js +0 -67
  60. package/dist/kit.js +0 -710
  61. package/dist/mermaid.d.ts +0 -3
  62. package/dist/mermaid.js +0 -50
  63. package/dist/model.js +0 -608
  64. package/dist/nav-page.d.ts +0 -15
  65. package/dist/nav-page.js +0 -283
  66. package/dist/nav.js +0 -578
  67. package/dist/needs.js +0 -311
  68. package/dist/pan.d.ts +0 -2
  69. package/dist/pan.js +0 -252
  70. package/dist/schemas.d.ts +0 -10
  71. package/dist/schemas.js +0 -266
  72. package/dist/spine.js +0 -156
  73. package/dist/starts.js +0 -88
  74. package/dist/story.js +0 -109
  75. package/dist/tutorial-check.d.ts +0 -9
  76. package/dist/tutorial-check.js +0 -297
  77. package/dist/ui-check.d.ts +0 -8
  78. package/dist/ui-check.js +0 -136
  79. package/dist/watch.d.ts +0 -5
  80. package/dist/watch.js +0 -114
  81. package/dist/wireframe.js +0 -273
  82. package/dist/yaml.d.ts +0 -19
  83. package/dist/yaml.js +0 -134
  84. /package/{dist → js}/expr.d.ts +0 -0
  85. /package/{dist → js}/graph.d.ts +0 -0
  86. /package/{dist → js}/kit.d.ts +0 -0
package/package.json CHANGED
@@ -1,44 +1,60 @@
1
1
  {
2
2
  "name": "@delurio/cli",
3
- "version": "0.9.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"],
24
- "engines": { "node": ">=22.18" },
23
+ "files": ["js", "schemas", "SPEC.md", "NOTICE", "CHANGELOG.md"],
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.0",
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": "22.20.5",
42
- "typescript": "7.0.2"
58
+ "@napi-rs/cli": "3.10.12"
43
59
  }
44
60
  }
@@ -86,6 +86,8 @@
86
86
  "items": { "type": "object" },
87
87
  "examples": [[{ "userId": "0199f9a0-11aa-7b22-8c33-4d44e55f6601", "clientId": "0199f9b2-3c4d-7e5f-8a6b-7c8d9e0f1a2b", "scopes": ["openid"] }]]
88
88
  },
89
+ "note": { "type": "string", "description": "The author's own words about the entity, which no tool reads (SPEC.md §5)." },
90
+ "planned": { "type": "string", "minLength": 1, "description": "The entity is written before its code: no code makes it true yet. Why, or where that is tracked: words, an issue. It names no code (`source`) while it says so (SPEC.md §5).", "examples": ["the second phase builds it (#12)"] },
89
91
  "source": { "$ref": "#/$defs/sourceAnchor" }
90
92
  }
91
93
  },
@@ -244,6 +246,7 @@
244
246
  "examples": [["audit:consent.decided"]]
245
247
  },
246
248
  "note": { "type": "string", "description": "The author's own words about the action, which no tool reads (SPEC.md §5)." },
249
+ "planned": { "type": "string", "minLength": 1, "description": "The action is written before its code: no code makes it true yet. Why, or where that is tracked: words, an issue. It names no code (`source`) while it says so (SPEC.md §5).", "examples": ["the second phase builds it (#12)"] },
247
250
  "source": { "$ref": "#/$defs/sourceAnchor" }
248
251
  }
249
252
  },
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 {};