@delurio/cli 0.3.0 → 0.4.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  While the version is 0.x, a release that can judge the same graphs differently (a new check, a stricter schema) bumps the minor; a fix that judges nothing differently bumps the patch.
4
4
 
5
+ ## 0.4.0 (2026-11-01)
6
+
7
+ - An exit (`type: final`) may be named in snake_case, optionally followed by its cause: `signed_out`, `invalid_token.dpop_bound` (SPEC.md §1, Text). The `schema` rule accepts these names on exits only; every other state stays camelCase. `flow.mmd` writes such an id as `invalid_token__dpop_bound`, since Mermaid ids take no dot.
8
+
5
9
  ## 0.3.0 (2026-10-25)
6
10
 
7
11
  - The modules a tool on top of delurio needs are importable, with their types: `@delurio/cli/graph`, `/model`, `/story`, `/wireframe`, `/kit`, `/edges`, `/html`, `/nav` and `/expr`. While the version is 0.x their API may change in any minor release; pin an exact version.
package/SPEC.md CHANGED
@@ -42,7 +42,7 @@ A flow with no screen (an HTTP endpoint, a webhook, an MCP tool, a CI job) has n
42
42
 
43
43
  ### Text
44
44
 
45
- The graph is written in one language, given by the project. Titles, `say` sentences, descriptions and assertion sentences are in that language. Every word a user of the product sees lives in a catalog, one file per locale; the graph refers to it by key. Identifiers (states, events, guards, effects, nodes, catalog keys) are English camelCase; events are UPPER_SNAKE.
45
+ The graph is written in one language, given by the project. Titles, `say` sentences, descriptions and assertion sentences are in that language. Every word a user of the product sees lives in a catalog, one file per locale; the graph refers to it by key. Identifiers (states, events, guards, effects, nodes, catalog keys) are English camelCase; events are UPPER_SNAKE. An exit (a final state) may instead be named after what the outside world is told, in snake_case, followed by its cause when several exits tell the same thing: `signed_out`, `invalid_token.dpop_bound`, `invalid_token.expired`. A protocol's errors are snake_case, so its exits read as its errors do.
46
46
 
47
47
  ## 2. Flow (`kind: flow`)
48
48
 
@@ -91,7 +91,7 @@ An effect changes the context when a transition is taken: `set` gives variables
91
91
  | `invoke` | the step runs something: `{ action: <domain action> }`, `{ flow: <flow id> }` (another flow runs and this one waits for its outcome), or `{ external: <name> }` |
92
92
  | `on` | event → transition (below) |
93
93
  | `always` | an ordered list of transitions taken at once, with no event. The first whose guard holds is taken; the list must cover every context (the checker fails otherwise) |
94
- | `type: final` | an exit; it has no transitions |
94
+ | `type: final` | an exit; it has no transitions. Its id may be `<snake_case>` or `<error>.<cause>` (§1, Text) |
95
95
  | `redirect`, `code`, `carries` | on an exit of a web protocol flow: `redirect: success \| error \| never`, the error `code`s, and what a success carries back |
96
96
  | `leavesPage: true` | on an exit: the person left (closed the page, went elsewhere) |
97
97
  | `response` | on a step with no screen: what the outside world sees, as data: `status`, `code`, `redirect`, `headers`, `body`, or the fields of a tool's answer. The page shows it beside the step, and a replay over HTTP will read it |
package/dist/mermaid.js CHANGED
@@ -1,19 +1,37 @@
1
1
  import { collectEdges, exitLine, kindOf } from './edges.js';
2
2
  import { titleOf } from './graph.js';
3
3
  const clean = (s) => s.replace(/"/g, "'").replace(/:/g, ' -');
4
+ // Mermaid's ids, which take no dot: an exit named `<error>.<cause>` is written `<error>__<cause>`
5
+ function mermaidIds(names) {
6
+ const ids = new Map();
7
+ const taken = new Set(names.filter((n) => !n.includes('.')));
8
+ for (const n of names) {
9
+ if (!n.includes('.')) {
10
+ ids.set(n, n);
11
+ continue;
12
+ }
13
+ let id = n.replace(/\./g, '__');
14
+ for (let i = 2; taken.has(id); i++)
15
+ id = `${n.replace(/\./g, '__')}_${i}`;
16
+ taken.add(id);
17
+ ids.set(n, id);
18
+ }
19
+ return (name) => ids.get(name) ?? name;
20
+ }
4
21
  // Mermaid stateDiagram-v2 text, for PRs and READMEs. The full page is html.ts.
5
22
  export function renderMermaid(g, ex) {
6
23
  const lines = ['---', `title: ${clean(g.flow.title ?? g.flow.id)}`, '---', 'stateDiagram-v2', ' direction TB'];
7
24
  const names = Object.keys(g.flow.states);
25
+ const id = mermaidIds(names);
8
26
  for (const name of names) {
9
27
  const st = g.flow.states[name];
10
28
  const detail = st.type === 'final' && st.leavesPage !== true ? ` (${exitLine(st)})` : '';
11
- lines.push(` state "${clean(titleOf(g.flow, name))}${clean(detail)}" as ${name}`);
29
+ lines.push(` state "${clean(titleOf(g.flow, name))}${clean(detail)}" as ${id(name)}`);
12
30
  }
13
- lines.push(` [*] --> ${g.flow.initial}`);
31
+ lines.push(` [*] --> ${id(g.flow.initial)}`);
14
32
  for (const e of collectEdges(g, ex)) {
15
33
  const label = e.labels.map(clean).join(', ');
16
- lines.push(` ${e.from} --> ${e.to}${label === '' ? '' : `: ${label}`}${e.unused ? ' (never taken)' : ''}`);
34
+ lines.push(` ${id(e.from)} --> ${id(e.to)}${label === '' ? '' : `: ${label}`}${e.unused ? ' (never taken)' : ''}`);
17
35
  }
18
36
  lines.push(' classDef server fill:#eeeeec,stroke:#6b6560,stroke-dasharray:4 3');
19
37
  lines.push(' classDef screen fill:#ffffff,stroke:#1c1917,stroke-width:2px');
@@ -22,7 +40,7 @@ export function renderMermaid(g, ex) {
22
40
  for (const kind of ['server', 'screen', 'subflow', 'exit']) {
23
41
  const members = names.filter((n) => kindOf(g, n) === kind);
24
42
  if (members.length > 0)
25
- lines.push(` class ${members.join(',')} ${kind}`);
43
+ lines.push(` class ${members.map(id).join(',')} ${kind}`);
26
44
  }
27
45
  return lines.join('\n') + '\n';
28
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delurio/cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.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",
@@ -52,7 +52,20 @@
52
52
  "type": "object",
53
53
  "description": "The states of the flow, by id. Nested, parallel and history states are not part of v0.",
54
54
  "minProperties": 1,
55
- "propertyNames": { "$ref": "#/$defs/identifier" },
55
+ "propertyNames": { "$ref": "#/$defs/stateName" },
56
+ "patternProperties": {
57
+ "[_.]": {
58
+ "type": "object",
59
+ "allOf": [
60
+ { "$ref": "#/$defs/state" },
61
+ {
62
+ "$comment": "a state named in snake_case, or `<error>.<cause>`, is an exit (type: final); every other state is camelCase",
63
+ "if": true,
64
+ "then": { "properties": { "type": { "const": "final" } }, "required": ["type"] }
65
+ }
66
+ ]
67
+ }
68
+ },
56
69
  "additionalProperties": { "$ref": "#/$defs/state" }
57
70
  },
58
71
  "assertions": {
@@ -80,10 +93,15 @@
80
93
  "description": "An identifier of the graph: English camelCase (SPEC.md §1, Text).",
81
94
  "pattern": "^[a-z][A-Za-z0-9]*$"
82
95
  },
96
+ "stateName": {
97
+ "type": "string",
98
+ "description": "The id of a state: English camelCase, or for an exit (type: final) what the outside world is told, in snake_case, optionally followed by its cause: `signed_out`, `invalid_token.dpop_bound` (SPEC.md §1, Text).",
99
+ "pattern": "^([a-z][A-Za-z0-9]*|[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)?)$"
100
+ },
83
101
  "stateRef": {
84
102
  "type": "string",
85
103
  "description": "The id of a state of this flow.",
86
- "pattern": "^[a-z][A-Za-z0-9]*$"
104
+ "pattern": "^([a-z][A-Za-z0-9]*|[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)?)$"
87
105
  },
88
106
  "eventName": {
89
107
  "type": "string",
@@ -93,7 +93,7 @@
93
93
  "stateRef": {
94
94
  "type": "string",
95
95
  "description": "The id of a state of the flow.",
96
- "pattern": "^[a-z][A-Za-z0-9]*$"
96
+ "pattern": "^([a-z][A-Za-z0-9]*|[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)?)$"
97
97
  },
98
98
  "nodeRef": {
99
99
  "type": "string",