@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/dist/html.js DELETED
@@ -1,311 +0,0 @@
1
- import { alternatives, humanize, titleOf } from './graph.js';
2
- import { identifiers, parseExpr } from './expr.js';
3
- import { collectEdges, exitLine, kindOf, pressLabel, responseLine } from './edges.js';
4
- import { narrate, stepsTo } from './story.js';
5
- import { kitCss } from './kit.js';
6
- import { PAN_CSS, PAN_SCRIPT } from './pan.js';
7
- const esc = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
8
- const code = (s) => `<code>${esc(s)}</code>`;
9
- export const CSS = `
10
- :root { --bg:#fafaf9; --surface:#ffffff; --ink:#1c1917; --muted:#6b6560; --line:#d6d3d1; --accent:#1d4ed8; --accent-bg:#eef3ff; --ok:#15803d; --bad:#b91c1c; --server:#eeeeec; --focus:#1d4ed8; --ai:#7e22ce; --ai-bg:#f5edff; --agent:#c2410c; --agent-bg:#fff1e8; --ci:#0f766e; --ci-bg:#e6f6f3; --ok-bg:#eaf7ee; }
11
- @media (prefers-color-scheme: dark) { :root { --bg:#161513; --surface:#1f1d1b; --ink:#f2efec; --muted:#a8a29e; --line:#44403c; --accent:#8fb0ff; --accent-bg:#1c2438; --ok:#5fcf85; --bad:#f08080; --server:#2a2826; --focus:#8fb0ff; --ai:#c99bff; --ai-bg:#2a2135; --agent:#ff9a66; --agent-bg:#33241b; --ci:#5fd4c4; --ci-bg:#1a2e2b; --ok-bg:#16291d; } }
12
- * { box-sizing: border-box; }
13
- body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; }
14
- main { max-width: 1000px; margin: 0 auto; padding: 28px 16px 80px; }
15
- h1 { font-size: 30px; line-height: 1.2; margin: 6px 0 8px; } h2 { font-size: 21px; margin: 44px 0 12px; } h3 { font-size: 16px; margin: 0; }
16
- code, pre, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
17
- .muted { color: var(--muted); } .label { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
18
- .eyebrow { margin: 0; color: var(--muted); } .lede { font-size: 18px; max-width: 46em; margin: 0; }
19
- .tag { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); border-radius: 99px; font-size: 12px; color: var(--muted); vertical-align: middle; }
20
- .scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
21
- table { border-collapse: collapse; width: 100%; } th, td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--line); } th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); } tr:last-child td { border-bottom: 0; }
22
- td ol { margin: 0; padding-left: 20px; }
23
- .ok { color: var(--ok); font-weight: 600; } .bad { color: var(--bad); font-weight: 600; }
24
- .story { margin-top: 28px; padding: 18px 22px; border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 10px; background: var(--surface); }
25
- .story h2 { margin: 0 0 6px; } .story .given { margin: 0 0 8px; } .story ol { margin: 0; padding-left: 26px; } .story li { margin: 5px 0; padding-left: 4px; } .story .result { margin: 10px 0 0; font-weight: 600; }
26
- .views input { margin-right: 8px; accent-color: var(--accent); } .views label { display: inline-block; margin: 0 0 10px; cursor: pointer; }
27
- .views .panel-full { display: none; } .views input:checked ~ .panel-main { display: none; } .views input:checked ~ .panel-full { display: block; }
28
- svg.spine { display: block; width: 100%; height: auto; padding: 8px; background: var(--surface); margin: 0 auto; }
29
- .spine .edge { fill: none; stroke-width: 1.5; } .spine .edge-user { stroke: var(--muted); } .spine .edge-system { stroke: var(--muted); } .spine .edge-route { stroke: var(--muted); stroke-dasharray: 2 4; } .spine .edge-fail { stroke: var(--bad); stroke-dasharray: 7 4; } .spine .edge-unused { stroke: var(--line); }
30
- .spine .edge-main { stroke: var(--accent); stroke-width: 3.5; stroke-dasharray: none; }
31
- .spine .arrow { fill: var(--muted); } .spine .arrow-fail { fill: var(--bad); } .spine .arrow-main { fill: var(--accent); }
32
- .spine .elabel rect { fill: var(--surface); stroke: var(--line); } .spine .elabel text { fill: var(--ink); font: 13px system-ui, sans-serif; } .spine .elabel-fail text { fill: var(--bad); } .spine .elabel-main rect { stroke: var(--accent); }
33
- .spine .node rect { fill: var(--surface); stroke: var(--ink); stroke-width: 1.6; } .spine .node-server rect { fill: var(--server); stroke: var(--muted); stroke-dasharray: 5 3; }
34
- .spine .node-subflow rect { stroke: var(--accent); } .spine .node-subflow rect.inner { fill: none; stroke-width: 1; }
35
- .spine .on-main rect { stroke-width: 3; } .spine .node-server.on-main rect { stroke: var(--accent); }
36
- .spine .exit-never rect { stroke: var(--bad); stroke-width: 3; } .spine .exit-error rect { stroke-dasharray: 6 3; } .spine .exit-left rect { stroke-dasharray: 2 3; stroke: var(--muted); } .spine .exit-success rect { stroke: var(--ok); stroke-width: 3; }
37
- .spine .node.by-human rect { fill: var(--surface); stroke: var(--ink); stroke-dasharray: none; }
38
- .spine .node.by-ai rect { fill: var(--ai-bg); stroke: var(--ai); stroke-dasharray: none; }
39
- .spine .node.by-agent rect { fill: var(--agent-bg); stroke: var(--agent); stroke-dasharray: none; } .spine .node.by-agent rect.inner { fill: none; stroke-width: 1; }
40
- .spine .node.by-ci rect { fill: var(--ci-bg); stroke: var(--ci); stroke-dasharray: none; }
41
- .spine .node.goal rect { fill: var(--ok-bg); stroke: var(--ok); stroke-width: 3.5; stroke-dasharray: none; }
42
- .spine .node.on-main rect { stroke-width: 3.5; }
43
- .spine .nmore { fill: var(--muted); font: 600 11px system-ui, sans-serif; }
44
- .legend .sw { display: inline-flex; align-items: center; gap: 6px; } .legend svg { flex: none; }
45
- .legend .sw-node rect { stroke-width: 1.6; }
46
- .legend .sw-human rect { fill: var(--surface); stroke: var(--ink); } .legend .sw-ai rect { fill: var(--ai-bg); stroke: var(--ai); } .legend .sw-agent rect { fill: var(--agent-bg); stroke: var(--agent); } .legend .sw-agent rect.inner { fill: none; stroke-width: 1; }
47
- .legend .sw-ci rect { fill: var(--ci-bg); stroke: var(--ci); } .legend .sw-goal rect { fill: var(--ok-bg); stroke: var(--ok); stroke-width: 3; } .legend .sw-server rect { fill: var(--server); stroke: var(--muted); stroke-dasharray: 4 2; }
48
- .legend .sw-screen rect { fill: var(--surface); stroke: var(--ink); } .legend .sw-subflow rect { fill: var(--surface); stroke: var(--accent); }
49
- .legend .sw-node.sw-fail rect { fill: var(--surface); stroke: var(--bad); stroke-width: 3; }
50
- .legend .sw-line path { fill: none; stroke-width: 3; } .legend .sw-main path { stroke: var(--accent); stroke-width: 3.5; } .legend .sw-fail path { stroke: var(--bad); stroke-dasharray: 6 3; } .legend .sw-route path { stroke: var(--muted); stroke-dasharray: 2 3; }
51
- .covers { display: grid; gap: 10px; } .covers .cv { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 10px 14px; } .covers ul { margin: 4px 0 0; padding-left: 20px; }
52
- .spine .node-unreachable rect { stroke: var(--bad); fill: none; }
53
- .spine .nname { fill: var(--ink); font: 600 14.5px system-ui, sans-serif; } .spine .nline { fill: var(--muted); font: 11.5px ui-monospace, Menlo, Consolas, monospace; } .spine .start { fill: var(--ink); }
54
- .spine a:focus-visible .node rect, .spine a:hover .node rect { stroke: var(--focus); stroke-width: 3; }
55
- .legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 10px 0 0; font-size: 14px; color: var(--muted); }
56
- .screens { display: grid; gap: 18px; }
57
- .screen { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 14px 16px 16px; scroll-margin-top: 16px; }
58
- .screen:target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }
59
- .screen header { display: flex; align-items: center; gap: 10px; } .screen > p { margin: 4px 0 10px; }
60
- .wf { border: 1px dashed var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 10px; background: var(--bg); max-width: 560px; }
61
- .wf-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 2px; border-radius: 4px; }
62
- .wf-cond { outline: 1.5px dashed var(--muted); outline-offset: 2px; } .wf-focus { outline: 2.5px solid var(--focus); outline-offset: 2px; }
63
- .wf-h { margin: 0; font-size: 17px; } .wf-t { margin: 0; color: var(--muted); }
64
- .wf-row { display: flex; flex-wrap: wrap; gap: 10px; }
65
- .wf-btn, .wf-link { font: inherit; border-radius: 6px; padding: 6px 14px; border: 1px solid var(--ink); background: var(--surface); color: var(--ink); }
66
- .wf-confirm { background: var(--ink); color: var(--bg); } .wf-link { border: 0; background: none; color: var(--accent); text-decoration: underline; padding: 0; }
67
- .wf button:disabled { opacity: .45; }
68
- .wf-list { margin: 0; padding-left: 20px; display: grid; gap: 2px; }
69
- .wf-status { color: var(--muted); font-style: italic; } .wf-alert { border: 1.5px solid var(--bad); border-radius: 6px; padding: 6px 10px; }
70
- .wf-check { display: flex; gap: 8px; align-items: center; } .wf-field { display: grid; gap: 4px; } .wf-input { font: inherit; border: 1px solid var(--muted); border-radius: 6px; padding: 6px 10px; background: var(--surface); color: var(--ink); }
71
- .wf-unmapped { border: 1.5px solid var(--bad); padding: 6px 10px; }
72
- .chip { font: 11px ui-monospace, Menlo, Consolas, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; white-space: nowrap; }
73
- details { margin-top: 12px; } summary { cursor: pointer; color: var(--muted); }
74
- details.ax-wrap { margin-top: 10px; } pre.ax { margin: 8px 0 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); line-height: 1.55; }
75
- dl.guards { margin: 10px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; } dl.guards dt { font-weight: 600; } dl.guards dd { margin: 0; }
76
- ul.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; } ul.checks li { padding-left: 26px; position: relative; } ul.checks li::before { content: "✓"; position: absolute; left: 4px; color: var(--ok); font-weight: 700; } ul.checks li.fail::before { content: "✗"; color: var(--bad); }
77
- footer { margin-top: 56px; color: var(--muted); font-size: 13px; }
78
- `;
79
- // how an action of the domain is called (SPEC.md §5): an HTTP operation others call, a server function only the
80
- // product's own pages call, or a step inside the service
81
- export function callLine(a) {
82
- if (a === undefined)
83
- return 'not in its domain';
84
- if (a === null)
85
- return 'named, not written yet';
86
- if (a.route !== undefined)
87
- return `an HTTP operation, ${a.route}`;
88
- if (a.serverFn !== undefined)
89
- return `a server function, ${a.serverFn}, called only by the product's own pages`;
90
- return 'a step inside the service';
91
- }
92
- function routingSection(g, ex) {
93
- const out = [];
94
- for (const [name, st] of Object.entries(g.flow.states)) {
95
- if (st.always === undefined)
96
- continue;
97
- const counts = ex.branchCounts.get(name) ?? [];
98
- const total = ex.atState.get(name) ?? 0;
99
- const rules = st.always;
100
- out.push(`<h3 style="margin:18px 0 8px">${esc(titleOf(g.flow, name))}</h3>`);
101
- out.push('<div class="scroll"><table><thead><tr><th>#</th><th>If</th><th>Then</th></tr></thead><tbody>');
102
- rules.forEach((a, i) => {
103
- const cond = a.say ?? (a.guard === undefined ? 'nothing above applies' : a.guard);
104
- out.push(`<tr><td>${i + 1}</td><td>${esc(cond)}</td><td>${esc(titleOf(g.flow, a.target))}</td></tr>`);
105
- });
106
- out.push('</tbody></table></div>');
107
- out.push('<p class="muted" style="margin:8px 0 0">The first matching rule wins.</p>');
108
- out.push('<details><summary>Exact conditions</summary><div class="scroll" style="margin-top:8px"><table><thead><tr><th>#</th><th>Condition</th><th>Goes to</th><th>Situations</th></tr></thead><tbody>');
109
- rules.forEach((a, i) => {
110
- out.push(`<tr><td>${i + 1}</td><td>${a.guard === undefined ? '<span class="muted">otherwise</span>' : code(a.guard)}</td><td>${code(a.target)}</td><td class="mono">${counts[i] ?? 0} of ${total}</td></tr>`);
111
- });
112
- out.push('</tbody></table></div>');
113
- const used = new Set();
114
- for (const a of rules)
115
- if (a.guard !== undefined)
116
- identifiers(parseExpr(a.guard)).forEach((n) => used.add(n));
117
- const named = Object.entries(g.flow.guards).filter(([n]) => used.has(n));
118
- if (named.length > 0) {
119
- out.push('<dl class="guards">');
120
- for (const [n, expr] of named)
121
- out.push(`<dt>${code(n)}</dt><dd>${code(expr)}</dd>`);
122
- out.push('</dl>');
123
- }
124
- out.push('</details>');
125
- }
126
- return out.join('\n');
127
- }
128
- function transitionsTable(g, ex) {
129
- const rows = [];
130
- for (const [name, st] of Object.entries(g.flow.states)) {
131
- const add = (event, guard, target, effect, taken) => {
132
- rows.push(`<tr><td>${code(name)}</td><td>${code(event)}</td><td>${guard === undefined ? '' : code(guard)}</td><td>${code(target)}</td><td>${(effect ?? []).map(code).join(' ')}</td><td class="${taken ? '' : 'bad'}">${taken ? 'yes' : 'never'}</td></tr>`);
133
- };
134
- (st.always ?? []).forEach((a, i) => add(`rule ${i + 1}`, a.guard, a.target, a.effect, ex.taken.has(`${name}|always|${i}`)));
135
- for (const [event, spec] of Object.entries(st.on ?? {})) {
136
- alternatives(spec).forEach((a, i) => add(event, a.guard, a.target, a.effect, ex.taken.has(`${name}|${event}|${i}`)));
137
- }
138
- }
139
- return `<div class="scroll" style="margin-top:8px"><table><thead><tr><th>From</th><th>Event</th><th>Guard</th><th>To</th><th>Effects</th><th>Taken</th></tr></thead><tbody>${rows.join('\n')}</tbody></table></div>`;
140
- }
141
- function legend(g, ex, hasMain) {
142
- const states = Object.entries(g.flow.states);
143
- const edges = collectEdges(g, ex);
144
- const node = (cls, rx, inner = false) => `<svg width="34" height="20" viewBox="0 0 34 20" aria-hidden="true" class="sw-node sw-${cls}"><rect x="1.5" y="1.5" width="31" height="17" rx="${rx}"/>${inner ? '<rect class="inner" x="4.5" y="4.5" width="25" height="11" rx="2"/>' : ''}</svg>`;
145
- const line = (cls) => `<svg width="34" height="20" viewBox="0 0 34 20" aria-hidden="true" class="sw-line sw-${cls}"><path d="M2 10 L32 10"/></svg>`;
146
- const items = [];
147
- const add = (sw, text) => {
148
- items.push(`<span class="sw">${sw}<span>${esc(text)}</span></span>`);
149
- };
150
- if (hasMain)
151
- add(line('main'), 'blue line: the main story');
152
- if (edges.some((e) => e.kind === 'fail'))
153
- add(line('fail'), 'red dashed line: a failure path (shown with “Show failure paths”)');
154
- if (edges.some((e) => e.kind === 'route'))
155
- add(line('route'), 'dotted line: decided by a rule, nobody acts');
156
- const by = new Set(states.map(([, s]) => s.by).filter((b) => b !== undefined));
157
- if (by.has('human'))
158
- add(node('human', 4), 'a person does it (editor, review, approval)');
159
- if (by.has('ai'))
160
- add(node('ai', 9), 'AI does it');
161
- if (by.has('agent'))
162
- add(node('agent', 4, true), 'an agent does it, on the real app or for a user');
163
- if (by.has('ci'))
164
- add(node('ci', 0), 'CI does it, automatically');
165
- if (states.some(([, s]) => s.goal === true))
166
- add(node('goal', 4), 'green: the goal the flow keeps returning to');
167
- const kinds = new Set(states.filter(([, s]) => s.by === undefined && s.goal !== true).map(([n]) => kindOf(g, n)));
168
- if (kinds.has('server'))
169
- add(node('server', 4), 'dashed grey box: the server decides, nothing is shown');
170
- if (kinds.has('screen'))
171
- add(node('screen', 4), 'solid box: the user sees a screen (click it)');
172
- if (kinds.has('subflow'))
173
- add(node('subflow', 4, true), 'double border: another flow');
174
- if (states.some(([, s]) => s.type === 'final' && s.redirect === 'success'))
175
- add(node('goal', 9), 'green exit: success');
176
- if (states.some(([, s]) => s.type === 'final' && s.redirect === 'never'))
177
- add(node('fail', 9), 'red exit: no redirect');
178
- if (states.some(([, s]) => (s.includes ?? []).length > 0))
179
- add('<b class="muted">+n</b>', 'the step covers n more things (listed below)');
180
- return `<p class="legend">${items.join('')}</p>`;
181
- }
182
- export function renderPage(p) {
183
- const { g, m, ex, assertions, finals, main } = p;
184
- const kit = p.kit ?? null;
185
- const holds = assertions.filter((a) => a.violation === undefined).length;
186
- const heading = g.flow.title ?? humanize(g.flow.id);
187
- const out = [];
188
- out.push('<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">');
189
- out.push(`<title>${esc(heading)}</title><style>${CSS}${PAN_CSS}${kit === null ? '' : kitCss(kit, 'page')}</style></head><body><main>`);
190
- out.push(`<p class="eyebrow">${g.flow.status === undefined ? '' : `<span class="tag">${esc(g.flow.status)}</span> `}<span class="mono">${esc(g.flow.id)}</span></p>`);
191
- out.push(`<h1>${esc(heading)}</h1>`);
192
- if (g.flow.summary !== undefined)
193
- out.push(`<p class="lede">${esc(g.flow.summary.trim())}</p>`);
194
- const sc = g.flow.scope;
195
- if (sc !== undefined) {
196
- out.push('<div class="story" style="border-left-color:var(--muted)"><p class="label">What this view shows</p>');
197
- if (sc.shows !== undefined)
198
- out.push(`<p style="margin:0">${esc(sc.shows)}.</p>`);
199
- if (sc.world === 'open')
200
- out.push('<p class="muted" style="margin:6px 0 0">Open world: what is not drawn here is not ruled out. Only the guarantees below are binding.</p>');
201
- if ((sc.outOfView ?? []).length > 0)
202
- out.push(`<p style="margin:8px 0 0"><b>Left out of this view:</b></p><ul style="margin:4px 0 0">${(sc.outOfView ?? []).map((o) => `<li>${esc(o)}</li>`).join('')}</ul>`);
203
- out.push('</div>');
204
- }
205
- if (main !== null) {
206
- out.push('<section class="story"><h2>The main story</h2>');
207
- out.push(`<p class="given"><b>When:</b> ${esc(main.given)}.</p><ol>`);
208
- for (const s of main.steps)
209
- out.push(`<li>${esc(s)}</li>`);
210
- out.push(`</ol><p class="result">Result: ${esc(main.result)}.</p></section>`);
211
- }
212
- out.push('<h2>The flow</h2>');
213
- out.push('<div class="views pz-host"><input type="checkbox" id="show-all"><label for="show-all">Show failure paths and “the user closes the page”</label>');
214
- out.push(`<div class="scroll panel-main pz">${p.spineMain}</div><div class="scroll panel-full pz">${p.spineFull}</div></div>`);
215
- out.push(legend(g, ex, main !== null));
216
- const covers = Object.entries(g.flow.states).filter(([, s]) => (s.includes ?? []).length > 0);
217
- if (covers.length > 0) {
218
- out.push('<h2>What each step covers</h2><div class="covers">');
219
- for (const [n, s] of covers)
220
- out.push(`<div class="cv"><b>${esc(titleOf(g.flow, n))}</b><ul>${(s.includes ?? []).map((i) => `<li>${esc(i)}</li>`).join('')}</ul></div>`);
221
- out.push('</div>');
222
- }
223
- if (p.screens.trim() !== '') {
224
- out.push('<h2>What the user sees</h2>');
225
- if (kit === null)
226
- out.push('<p class="muted" style="margin-top:-4px">Wireframes are generated from the UI graph with fixed components, so they show structure, wording and state, not the final look.</p>');
227
- else
228
- out.push(`<p class="muted" style="margin-top:-4px">Screens are drawn from the UI graph with the components of ${esc(kit.title)} (kit <span class="mono">${esc(kit.id)}</span>): the look is the kit's, the wording and state are the graph's. A component the kit does not cover is drawn with the fixed one.</p>`);
229
- out.push(`<div class="screens">${p.screens}</div>`);
230
- }
231
- const answers = Object.entries(g.flow.states).filter(([, st]) => st.response !== undefined);
232
- if (answers.length > 0) {
233
- out.push('<h2>What each step answers</h2>');
234
- out.push('<div class="scroll"><table><thead><tr><th>Step</th><th>The outside world sees</th></tr></thead><tbody>');
235
- for (const [name, st] of answers)
236
- out.push(`<tr><td>${esc(titleOf(g.flow, name))}<br><span class="mono muted">${esc(name)}</span></td><td>${esc(responseLine(st.response ?? {}))}</td></tr>`);
237
- out.push('</tbody></table></div>');
238
- }
239
- const actions = p.domain?.actions ?? null;
240
- const calls = Object.entries(g.flow.states).filter(([, st]) => st.invoke?.action !== undefined);
241
- if (actions !== null && calls.length > 0) {
242
- out.push('<h2>What each step calls</h2>');
243
- out.push(`<p class="muted" style="margin-top:-4px">The actions of its domain, <span class="mono">${esc(g.flow.domain ?? '')}</span>, and how each is called.</p>`);
244
- out.push('<div class="scroll"><table><thead><tr><th>Step</th><th>Action</th><th>How it is called</th></tr></thead><tbody>');
245
- for (const [name, st] of calls) {
246
- const action = st.invoke?.action ?? '';
247
- const a = Object.hasOwn(actions, action) ? actions[action] : undefined;
248
- out.push(`<tr><td>${esc(titleOf(g.flow, name))}<br><span class="mono muted">${esc(name)}</span></td><td>${code(action)}</td><td>${esc(callLine(a))}</td></tr>`);
249
- }
250
- out.push('</tbody></table></div>');
251
- }
252
- const routing = routingSection(g, ex);
253
- if (routing !== '') {
254
- out.push('<h2>How it decides what happens next</h2>');
255
- out.push(routing);
256
- }
257
- if (finals.length === 0)
258
- out.push('<h2>Every way it can end</h2><p class="muted">It never ends: every path returns to a state the flow keeps.</p>');
259
- else {
260
- out.push('<h2>Every way it can end</h2>');
261
- out.push('<div class="scroll"><table><thead><tr><th>It ends with</th><th>When</th><th>What happens</th></tr></thead><tbody>');
262
- for (const f of finals) {
263
- const story = narrate(g, m, stepsTo(m, ex, f.index));
264
- out.push(`<tr><td><b>${esc(story.result)}</b><br><span class="muted">${esc(exitLine(g.flow.states[f.state]))}</span></td><td>${esc(story.given)}</td><td><ol>${story.steps.map((s) => `<li>${esc(s)}</li>`).join('')}</ol></td></tr>`);
265
- }
266
- out.push('</tbody></table></div>');
267
- out.push('<p class="muted" style="margin:8px 0 0">Each row is also a generated test: set the starting situation, send the events, expect the ending.</p>');
268
- }
269
- const hands = p.handOvers ?? [];
270
- if (hands.length > 0) {
271
- out.push('<h2>The flows it starts</h2>');
272
- out.push('<p class="muted" style="margin-top:-4px">This flow starts them and does not wait. Each begins with what this flow knows at that moment.</p>');
273
- out.push('<div class="scroll"><table><thead><tr><th>From</th><th>It starts</th><th>Which begins with</th><th>Checked</th></tr></thead><tbody>');
274
- for (const h of hands) {
275
- const way = h.event === null ? 'a rule' : (pressLabel(g, h.from, h.event) ?? humanize(h.event).toLowerCase());
276
- const given = Object.entries(h.given).map(([k, v]) => `${code(k)} = ${code(String(v))}`).join('<br>') || '<span class="muted">its own beginning</span>';
277
- const checked = !h.found ? '<span class="muted">not written yet</span>' : h.problems.length === 0 ? 'fits' : `<span class="bad">${h.problems.map(esc).join('<br>')}</span>`;
278
- out.push(`<tr><td>${esc(titleOf(g.flow, h.from))}<br><span class="muted">${esc(way)}</span></td><td class="mono">${esc(h.flow)}</td><td>${given}</td><td>${checked}</td></tr>`);
279
- }
280
- out.push('</tbody></table></div>');
281
- }
282
- out.push('<h2>What is guaranteed</h2>');
283
- out.push(`<p>These hold in all ${ex.configs.length} situations the model can reach, from ${ex.starts} different starting situations${holds === assertions.length ? '' : ` — <span class="bad">${assertions.length - holds} do not</span>`}.</p>`);
284
- out.push('<ul class="checks">');
285
- for (const a of assertions) {
286
- const v = a.violation;
287
- const text = esc(a.say ?? humanize(a.id));
288
- out.push(v === undefined
289
- ? `<li>${text}</li>`
290
- : `<li class="fail"><b>${text}</b> <span class="bad">— violated</span> in <code>${esc(v.state)}</code> after <span class="mono">${esc(v.events.join(' > ') || '(start)')}</span></li>`);
291
- }
292
- out.push('</ul>');
293
- out.push('<details><summary>Exact rules</summary><div class="scroll" style="margin-top:8px"><table><thead><tr><th>Id</th><th>Never</th></tr></thead><tbody>');
294
- for (const a of assertions)
295
- out.push(`<tr><td>${code(a.id)}</td><td>${code(a.never)}</td></tr>`);
296
- out.push('</tbody></table></div></details>');
297
- if (g.flow.decisions !== undefined) {
298
- out.push('<h2>Still to decide</h2>');
299
- out.push('<div class="scroll"><table><thead><tr><th>Id</th><th>Question</th><th>Recommendation</th><th>Affects</th></tr></thead><tbody>');
300
- for (const [id, d] of Object.entries(g.flow.decisions)) {
301
- out.push(`<tr><td>${esc(id)}</td><td>${esc(d.question)}</td><td>${esc(d.recommend)}</td><td>${d.affects.map((s) => esc(titleOf(g.flow, s))).join(', ')}</td></tr>`);
302
- }
303
- out.push('</tbody></table></div>');
304
- }
305
- out.push('<h2>Reference</h2>');
306
- out.push(`<details><summary>All transitions (${Object.values(g.flow.states).reduce((n, s) => n + (s.always?.length ?? 0) + Object.values(s.on ?? {}).reduce((k, spec) => k + alternatives(spec).length, 0), 0)})</summary>${transitionsTable(g, ex)}</details>`);
307
- const from = g.ui.absent === true ? 'flow.yaml (it has no screens)' : `flow.yaml, ui.yaml${kit === null ? ' and the catalog' : `, the catalog and the kit ${esc(kit.id)}`}`;
308
- out.push(`<footer>delurio graph-viz · generated from ${from} · no AI, no network: the same input gives the same bytes.</footer>`);
309
- out.push(`</main>${PAN_SCRIPT}</body></html>`);
310
- return out.join('\n') + '\n';
311
- }
@@ -1,12 +0,0 @@
1
- export interface IndexEntry {
2
- path: string;
3
- kind: 'flow' | 'nav';
4
- id: string | null;
5
- title: string;
6
- status: string | null;
7
- holds: number;
8
- total: number;
9
- warnings: string[];
10
- error: string | null;
11
- }
12
- export declare function renderIndexPage(root: string, entries: IndexEntry[]): string;
@@ -1,50 +0,0 @@
1
- // The index of `page` on a folder of graphs: one row per graph, grouped by the folder it sits in, with what its check
2
- // found and a link to its page.
3
- import { CSS } from './html.js';
4
- import { count } from './check.js';
5
- const esc = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
6
- const INDEX_CSS = `
7
- .groups h2 { font-size: 18px; margin: 32px 0 10px; } .groups table { table-layout: fixed; } .groups col.check { width: 9em; }
8
- .groups a { color: var(--accent); } .groups td { overflow-wrap: anywhere; }
9
- .meta { margin-top: 2px; } .meta .tag { margin-left: 6px; } .warn { margin-top: 6px; color: var(--muted); font-size: 14px; } .warn ul { margin: 4px 0 0; padding-left: 18px; }
10
- `;
11
- function stateCell(e) {
12
- if (e.error !== null)
13
- return `<span class="bad">cannot be loaded</span>`;
14
- if (e.kind === 'nav')
15
- return `<span class="${e.total === 0 ? 'ok' : 'bad'}">${esc(count(e.total, 'problem'))}</span>`;
16
- if (e.total === 0)
17
- return '<span class="muted">no guarantees</span>';
18
- return e.holds === e.total ? `<span class="ok">${e.holds}/${e.total} hold</span>` : `<span class="bad">${e.total - e.holds} of ${e.total} broken</span>`;
19
- }
20
- // root: the indexed folder's name, which also heads the graphs that sit right in it
21
- export function renderIndexPage(root, entries) {
22
- const out = [];
23
- const failing = entries.filter((e) => e.error !== null || (e.kind === 'flow' ? e.holds < e.total : e.total > 0));
24
- const flows = entries.filter((e) => e.kind === 'flow').length;
25
- const navs = entries.length - flows;
26
- out.push('<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">');
27
- out.push(`<title>All graphs</title><style>${CSS}${INDEX_CSS}</style></head><body><main>`);
28
- out.push(`<p class="eyebrow"><span class="mono">${esc(root)}/</span> · delurio-graph/0</p><h1>All graphs</h1>`);
29
- const kinds = [flows > 0 ? count(flows, 'flow') : '', navs > 0 ? count(navs, 'navigation graph') : ''].filter((s) => s !== '').join(' and ');
30
- out.push(`<p class="lede">${esc(kinds)}. ${failing.length === 0 ? 'Every guarantee holds and nothing blocks anyone.' : `${esc(count(failing.length, 'graph'))} need${failing.length === 1 ? 's' : ''} a look: marked in red below.`}</p>`);
31
- const groups = new Map();
32
- for (const e of entries) {
33
- const slash = e.path.lastIndexOf('/');
34
- const folder = slash < 0 ? root : e.path.slice(0, slash);
35
- groups.set(folder, [...(groups.get(folder) ?? []), e]);
36
- }
37
- out.push('<div class="groups">');
38
- for (const [folder, rows] of groups) {
39
- out.push(`<h2>${esc(folder)}</h2><div class="scroll"><table><colgroup><col><col class="check"></colgroup><thead><tr><th>Graph</th><th>Check</th></tr></thead><tbody>`);
40
- for (const e of rows) {
41
- const name = e.error !== null ? esc(e.title) : `<a href="${esc(e.path)}/index.html">${esc(e.title)}</a>`;
42
- const meta = e.id === null ? '' : `<div class="meta"><span class="mono muted">${esc(e.id)}</span>${e.status === null ? '' : `<span class="tag">${esc(e.status)}</span>`}</div>`;
43
- const warn = e.error !== null ? `<div class="warn">${esc(e.error)}</div>` : e.warnings.length === 0 ? '' : `<div class="warn">${esc(count(e.warnings.length, 'warning'))}<ul>${e.warnings.map((w) => `<li>${esc(w)}</li>`).join('')}</ul></div>`;
44
- out.push(`<tr><td>${name}${meta}${warn}</td><td class="state">${stateCell(e)}</td></tr>`);
45
- }
46
- out.push('</tbody></table></div>');
47
- }
48
- out.push('</div></main></body></html>');
49
- return out.join('\n');
50
- }
package/dist/invokes.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { Domain } from './changes.ts';
2
- import type { Graph } from './graph.ts';
3
- export interface InvokeProblem {
4
- rule: 'invoke-unknown' | 'refusal-unknown';
5
- path: string[];
6
- message: string;
7
- element: string;
8
- }
9
- export declare const TRANSPORT_CODES: readonly string[];
10
- export declare function checkInvokes(g: Graph, domainOf?: () => Domain | null): InvokeProblem[];
package/dist/invokes.js DELETED
@@ -1,67 +0,0 @@
1
- // What a flow invokes, held to its domain (SPEC.md §2, §5): `invoke: { action }` names an action of the domain the flow
2
- // names, and for a state that invokes an action, `failures.<state>.from` does too and each class under it lists
3
- // refusals of that action. A state that invokes an `external` or a `flow` is not held to the domain. The domain is looked
4
- // up by id among the graphs beside the flow, all its files read as one, as the `changes` rule finds it. A class may also
5
- // list a transport code, a failure that is no answer of the action's own (SPEC.md §5). Each finding is an error, which
6
- // fails --strict (decided on 16 Nov 2026, d-1116-10).
7
- import { flowDomain } from './changes.js';
8
- // the key that names a class's action in `failures.<state>`; every other key is a class
9
- const FROM = 'from';
10
- // the codes a failure class may list though its action has no such refusal (SPEC.md §5): no answer came back, none came
11
- // in time, or the server failed with a status the action does not list
12
- export const TRANSPORT_CODES = ['network', 'timeout', '5xx'];
13
- // `domainOf` finds the flow's domain, as for checkChanges
14
- export function checkInvokes(g, domainOf = () => flowDomain(g)) {
15
- const invoked = Object.entries(g.flow.states).filter(([, st]) => typeof st.invoke?.action === 'string');
16
- if (g.flow.domain === undefined || invoked.length === 0)
17
- return [];
18
- const failures = (g.flow.failures ?? {});
19
- const domain = domainOf();
20
- if (domain === null) {
21
- return [
22
- {
23
- rule: 'invoke-unknown',
24
- path: ['domain'],
25
- element: 'domain',
26
- message: `the flow names the domain ${g.flow.domain}, which no domain beside it is (under the nearest folder called graphs), so what its steps invoke is not checked (SPEC.md §5)`,
27
- },
28
- ];
29
- }
30
- const actions = domain.actions ?? {};
31
- const has = (name) => Object.hasOwn(actions, name);
32
- const out = [];
33
- for (const [state, st] of invoked) {
34
- const action = st.invoke?.action;
35
- if (has(action))
36
- continue;
37
- out.push({ rule: 'invoke-unknown', path: ['states', state, 'invoke', 'action'], element: `states/${state}/invoke`, message: `state ${state} invokes ${action}, which is not an action of the domain ${g.flow.domain} (SPEC.md §5)` });
38
- }
39
- for (const [state, classes] of Object.entries(failures)) {
40
- const action = g.flow.states[state]?.invoke?.action;
41
- if (classes === null || typeof classes !== 'object' || typeof action !== 'string')
42
- continue;
43
- const named = typeof classes[FROM] === 'string' ? classes[FROM] : action;
44
- if (!has(named)) {
45
- // an action the state's own invoke names is reported there
46
- if (named !== action)
47
- out.push({ rule: 'invoke-unknown', path: ['failures', state, FROM], element: `failures/${state}/from`, message: `failures.${state} comes from ${named}, which is not an action of the domain ${g.flow.domain} (SPEC.md §2, §5)` });
48
- continue;
49
- }
50
- const refusals = actions[named]?.refusals ?? {};
51
- for (const [cls, codes] of Object.entries(classes)) {
52
- if (cls === FROM || !Array.isArray(codes))
53
- continue;
54
- codes.forEach((code, i) => {
55
- if (typeof code !== 'string' || Object.hasOwn(refusals, code) || TRANSPORT_CODES.includes(code))
56
- return;
57
- out.push({
58
- rule: 'refusal-unknown',
59
- path: ['failures', state, cls, String(i)],
60
- element: `failures/${state}/${cls}/${code}`,
61
- message: `FAIL.${cls} of ${state} stands for ${code}, which is not a refusal of ${named} in the domain ${g.flow.domain}, nor network, timeout or 5xx (SPEC.md §2, §5)`,
62
- });
63
- });
64
- }
65
- }
66
- return out;
67
- }