@delurio/cli 0.6.1 → 0.7.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,14 @@
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.7.0 (2026-11-12)
6
+
7
+ - An action may be a server function (SPEC.md §5): `serverFn: GET` or `serverFn: POST` in place of a route, for a call that the product's own pages make to its server through their framework, such as TanStack Start's `createServerFn` or React's server functions, at an address the framework gives it. It is not part of the product's HTTP API: it is no OpenAPI operation, its input is its `body`, and it has no `query` and no `operationId`. `GET` reads and changes nothing; `POST` may write. An address that the browser itself opens, such as a link in an e-mail or a sign-in callback, keeps its route even when a server function answers it. Before, such an action could only be written with a route, as an operation that others may call, or with none, as a step inside the service; the `schema` rule refused `serverFn`.
8
+ - New rule of `check`, which fails `--strict`: `server-fn-http`, a server function that also has a `route`, a `query` or an `operationId`. It is given at the `serverFn`, with a note at the other key, in whichever files of a split domain each is given. A method other than `GET` or `POST` is an error of the `schema` rule.
9
+ - The `changes` rule (SPEC.md §4) reads a server function's method as it reads a route's: a `POST` writes and a `GET` does not, even when it returns an entity. Graphs with no `serverFn` are judged as before.
10
+ - `page`: a flow's page lists what each of its steps calls, under "What each step calls": the action, and how it is called (an HTTP operation and its route, a server function and its method, or a step inside the service). It reads the flow's domain where the `changes` rule finds it; a flow whose domain is not found gets no list. The other parts of the examples' pages are unchanged.
11
+ - `examples/notes/restore`: a flow with a screen whose two actions are server functions, one `GET` and one `POST`, in the split notes domain.
12
+
5
13
  ## 0.6.1 (2026-11-11)
6
14
 
7
15
  - `page`: in the flow's diagram, every state's group carries `data-state`, and every edge and its label `data-from` and `data-to`. One edge is drawn per pair of states, so a transition is found by its two states. A tool on top of the CLI can now find a state or a transition in the drawing, to move to it or link to it. The pages of the examples differ from 0.6.0's only by these attributes. Nothing is judged differently.
package/README.md CHANGED
@@ -56,7 +56,7 @@ npx @delurio/cli check graphs --strict
56
56
  npx @delurio/cli page examples/qauth-authorize --out viz/qauth-authorize
57
57
  ```
58
58
 
59
- The page shows the flow in words: its main story, every way it ends, its guarantees and whether they hold, its screens as wireframes, and its diagram, which opens fitted to the window and moves like a design tool's canvas (drag to move, Ctrl or ⌘ + scroll or a pinch to zoom, Shift+1 to fit). `examples/qauth-authorize` is a small graph to try it on.
59
+ The page shows the flow in words: its main story, every way it ends, its guarantees and whether they hold, its screens as wireframes, what each step calls (an HTTP operation, a server function of the product's own pages, or a step inside the service), and its diagram, which opens fitted to the window and moves like a design tool's canvas (drag to move, Ctrl or ⌘ + scroll or a pinch to zoom, Shift+1 to fit). `examples/qauth-authorize` is a small graph to try it on.
60
60
 
61
61
  Given a folder of graphs instead, it writes the page of every graph under it, each at its own path, and `index.html` listing them all with what their check found:
62
62
 
package/SPEC.md CHANGED
@@ -235,7 +235,22 @@ A capture may carry more words of its own on a field (`owner`, `note`, `editable
235
235
 
236
236
  An action, a refusal and an invariant may carry `note`: the author's own words, which no tool reads. An invariant the code does not keep is still written, with `holds: false` and the `finding` that reports it: the finding's id in the graph's report, such as `MS-7`. A capture describes the code, so the invariant says what should hold and the finding says where it does not. Decided on 25 Oct 2026.
237
237
 
238
- **The API.** An action with a `route` (`METHOD /path`) is one OpenAPI 3.1 operation: its name is the `operationId`, `needs` its security requirement, `query` (a JSON Schema object) its query parameters, `body` its request body, `result` its response (`returns` an entity, a `redirect`, a `status`, or a JSON Schema), and each refusal one more response. When a refusal has a body, it is RFC 9457 problem details with the refusal code as its `type`. So a domain can be written out as an OpenAPI document, and an app that already publishes one names it at the top (`openapi: <file>`) and each action's operation by `operationId`, instead of copying them. An action with no route is a step inside the service. `needs`, `policies`, `sideEffects`, `refusals.<code>.redirect` and `invariants` are delurio's own: no standard says who may do what to which data, or what must always hold.
238
+ **The API.** An action with a `route` (`METHOD /path`) is one OpenAPI 3.1 operation: its name is the `operationId`, `needs` its security requirement, `query` (a JSON Schema object) its query parameters, `body` its request body, `result` its response (`returns` an entity, a `redirect`, a `status`, or a JSON Schema), and each refusal one more response. When a refusal has a body, it is RFC 9457 problem details with the refusal code as its `type`. So a domain can be written out as an OpenAPI document, and an app that already publishes one names it at the top (`openapi: <file>`) and each action's operation by `operationId`, instead of copying them. An action with `serverFn` is a server function (below), and an action with neither is a step inside the service. `needs`, `policies`, `sideEffects`, `refusals.<code>.redirect` and `invariants` are delurio's own: no standard says who may do what to which data, or what must always hold.
239
+
240
+ **Server functions.** Full-stack frameworks let a product's own pages call code on its server as if it were a function: TanStack Start's `createServerFn`, or React's server functions. The framework gives each one an address of its own and makes the call from the product's pages; it is not a public HTTP API, and nothing else is meant to call it. Such an action says so with `serverFn` and its HTTP method, `GET` or `POST`, in place of a route:
241
+
242
+ ```yaml
243
+ actions:
244
+ readNote: { serverFn: GET, needs: session, body: { type: object, required: [id] }, result: { returns: Note } }
245
+ restoreNote: { serverFn: POST, needs: session, body: { type: object, required: [id] }, result: { returns: Note } }
246
+ ```
247
+
248
+ - `GET` reads: it changes nothing, so the framework may call it ahead of time (a page's loader, a preload) or keep its answer. `POST` may write, and every server function that changes something is one.
249
+ - Its input is its `body`, whatever its method: a framework puts a `GET`'s input in the address under a name of its own, so a server function has no `query`. `needs`, `result`, `refusals` and `sideEffects` mean what they mean for a route. The function is reached over HTTP like any request, so what it `needs` is checked by the function itself, never only by the page that calls it.
250
+ - It is no OpenAPI operation: the OpenAPI document of a domain ([#8](https://github.com/delurio-labs/delurio/issues/8)) leaves it out, and it has no `operationId`.
251
+ - An action has a route or `serverFn`, never both. An address that the browser itself opens, such as a link in an e-mail, a sign-in callback, or a link that sends the browser on to another site, keeps its `route` even when a server function answers it: the address is what is called, and others may link to it, so it is part of the API.
252
+
253
+ `check` gives an error (`server-fn-http`) at the `serverFn` of an action that also has a `route`, a `query` or an `operationId`, in whichever of the domain's files each is given, with a note where the other key is; a method other than `GET` or `POST` is a `schema` error. Decided on 12 Nov 2026.
239
254
 
240
255
  This form was decided on 22 Oct 2026. Graphs captured before it may still give fields as `{ kind: text }`; they are converted when a tool first reads fields. The OpenAPI export and import are [#8](https://github.com/delurio-labs/delurio/issues/8).
241
256
 
@@ -247,7 +262,7 @@ This form was decided on 22 Oct 2026. Graphs captured before it may still give f
247
262
 
248
263
  A value given in two files is an error of `check` at the second one's line (`domain-twice`); so is a file whose id is not its directory's domain, and a domain whose files sit in two directories (`domain-place`). A split keeps a large domain one entity per file, and lets a part generated from the code ([#6](https://github.com/delurio-labs/delurio/issues/6)) and a part written by hand sit side by side; how a generator marks the files it owns is decided there. Decided on 1 Nov 2026.
249
264
 
250
- `check` validates every file of a domain against its schema and reads its files as one, the `changes` rule (§4) reads its actions, the revision diff compares it, and anchors lock its `source:` keys. Loading it with the flow and checking policies, secrets and `invoke` names is [#5](https://github.com/delurio-labs/delurio/issues/5); generating it from Drizzle and Zod is [#6](https://github.com/delurio-labs/delurio/issues/6); a registry that every API operation and route is covered by a graph is [#7](https://github.com/delurio-labs/delurio/issues/7).
265
+ `check` validates every file of a domain against its schema and reads its files as one, the `changes` rule (§4) reads its actions (one writes when its route or its server function is not a `GET`, when a policy lets someone `write` with it, or when it is a step inside the service that returns an entity), the revision diff compares it, anchors lock its `source:` keys, and the page of a flow that names it lists what each of its steps calls and how: an HTTP operation and its route, a server function and its method, or a step inside the service. Loading it with the flow and checking policies, secrets and `invoke` names is [#5](https://github.com/delurio-labs/delurio/issues/5); generating it from Drizzle and Zod is [#6](https://github.com/delurio-labs/delurio/issues/6); a registry that every API operation and route is covered by a graph is [#7](https://github.com/delurio-labs/delurio/issues/7).
251
266
 
252
267
  ## 6. Navigation (`kind: nav`)
253
268
 
@@ -303,7 +318,7 @@ A kit says how the components of `ui.yaml` look in one product: `tokens` and `da
303
318
  |---|---|
304
319
  | 0 | the graph loads and, under `--strict`, nothing is wrong |
305
320
  | 1 | the graph cannot be loaded: a YAML error, unsupported YAML (§1), an unknown state, an unknown name in an expression, a non-exhaustive `always`, an unsupported construct |
306
- | 2 | under `--strict`: an assertion is violated, a catalog key or a sample value is missing, a component has no renderer, the kit does not cover a component, the main story cannot be walked, a domain's files clash (§5), or a state of a captured flow names no code (§9) |
321
+ | 2 | under `--strict`: an assertion is violated, a catalog key or a sample value is missing, a component has no renderer, the kit does not cover a component, the main story cannot be walked, a domain's files clash or a server function has what only a route has (§5), or a state of a captured flow names no code (§9) |
307
322
 
308
323
  **As text.** A finding is one line in the GNU error format, which compilers, editors and most CI logs read:
309
324
 
@@ -356,7 +371,7 @@ Where a standard covers a part, delurio uses it rather than writing its own. Sur
356
371
  |---|---|---|
357
372
  | YAML 1.2 | every graph file | as it is |
358
373
  | JSON Schema 2020-12 | the fields of entities, bodies and results (§5); a schema of every kind of graph file, so that editors check and complete them (#1) | as it is, plus the keywords of §5 |
359
- | OpenAPI 3.1 | an action with a route is an operation (§5) | export and import: #13 |
374
+ | OpenAPI 3.1 | an action with a route is an operation (§5); a server function is not | export and import: #13 |
360
375
  | RFC 9457, problem details | the body of a refusal (§5) | as it is |
361
376
  | SCXML (W3C, 2015) | what a flow means (§2) | a subset; export: #14 |
362
377
  | WAI-ARIA 1.2, Accessible Name and Description Computation 1.2 | roles and names in `ui.yaml` (§4) | as they are |
package/dist/changes.d.ts CHANGED
@@ -1,7 +1,23 @@
1
1
  import type { Graph } from './graph.ts';
2
+ export interface DomainAction {
3
+ route?: string;
4
+ serverFn?: string;
5
+ result?: {
6
+ returns?: string;
7
+ };
8
+ }
9
+ export interface Domain {
10
+ id?: string;
11
+ actions?: Record<string, DomainAction | null>;
12
+ policies?: Array<{
13
+ do?: string[];
14
+ write?: string[];
15
+ }>;
16
+ }
2
17
  export interface ChangesCheck {
3
18
  writes: string[];
4
19
  key: string | null;
5
20
  problems: string[];
6
21
  }
22
+ export declare function flowDomain(g: Graph): Domain | null;
7
23
  export declare function checkChanges(g: Graph): ChangesCheck | null;
package/dist/changes.js CHANGED
@@ -1,8 +1,8 @@
1
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. An action writes when its route is not a GET, when a policy lets someone `write` with it, or
3
- // when it is a step inside the service (no route) that returns an entity; all three are read from the flow's domain,
4
- // looked up by id among the graphs beside this one, all its files read as one (SPEC.md §5). A flow with no screens, or
5
- // whose domain is not found, is not checked.
2
+ // changes and what follows. 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 flow with no screens, or whose domain is not found, is not checked.
6
6
  import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
7
7
  import { basename, dirname, join } from 'node:path';
8
8
  import { inReadingOrder, isDomainText, mayBeDomain, mergeDomain } from './domain.js';
@@ -38,15 +38,21 @@ function domainUnder(root, id, depth = 4) {
38
38
  }
39
39
  return null;
40
40
  }
41
+ // the domain the flow names, looked up by id among the graphs beside it; null when it names none or it is not found
42
+ export function flowDomain(g) {
43
+ return g.flow.domain === undefined ? null : domainUnder(rootOf(g.dir), g.flow.domain);
44
+ }
45
+ // the HTTP method of an action's route or server function; undefined for a step inside the service
46
+ const methodOf = (a) => (a?.route ?? a?.serverFn)?.trim().split(/\s+/)[0]?.toUpperCase();
41
47
  export function checkChanges(g) {
42
- if (g.ui.absent === true || g.flow.domain === undefined)
48
+ if (g.ui.absent === true)
43
49
  return null;
44
- const domain = domainUnder(rootOf(g.dir), g.flow.domain);
50
+ const domain = flowDomain(g);
45
51
  if (domain === null)
46
52
  return null;
47
53
  const writing = new Set();
48
54
  for (const [name, a] of Object.entries(domain.actions ?? {})) {
49
- const method = a?.route?.trim().split(/\s+/)[0]?.toUpperCase();
55
+ const method = methodOf(a);
50
56
  if ((method !== undefined && method !== 'GET') || (method === undefined && a?.result?.returns !== undefined))
51
57
  writing.add(name);
52
58
  }
package/dist/check.js CHANGED
@@ -29,6 +29,7 @@ const RULES = [
29
29
  { id: 'schema', text: "A graph file does not follow its kind's schema (SPEC.md)", level: 'error' },
30
30
  { id: 'domain-twice', text: 'A value of a domain is given in two of its files (SPEC.md §5)', level: 'error' },
31
31
  { id: 'domain-place', text: 'A domain file is not with the rest of its domain (SPEC.md §1)', level: 'error' },
32
+ { id: 'server-fn-http', text: 'A server function is given a route, a query or an operationId, which only an HTTP operation has (SPEC.md §5)', level: 'error' },
32
33
  { id: 'assertion-violated', text: 'A guarantee of the flow is broken by a reachable situation', level: 'error' },
33
34
  { id: 'main-story-unwalkable', text: 'The declared main story cannot be walked', level: 'error' },
34
35
  { id: 'catalog-key-missing', text: 'A catalog key the screens use is missing', level: 'error' },
@@ -165,8 +166,50 @@ function checkFlow(dir) {
165
166
  }
166
167
  return out;
167
168
  }
169
+ // what only an HTTP operation has (SPEC.md §5), and why a server function has none of it
170
+ const HTTP_ONLY = {
171
+ route: 'a route is an operation that others call over HTTP, and a server function is called only by the product\'s own pages: give one of them',
172
+ query: 'a server function\'s input is its body, whatever its method',
173
+ operationId: 'a server function is no operation of an OpenAPI document',
174
+ };
175
+ // a server function that is also given what only an HTTP operation has (SPEC.md §5), at its `serverFn` with a note at
176
+ // the other key; the two may come from two files of a split domain, so the domain is read as one first
177
+ function checkServerFunctions(parts, doc, id) {
178
+ const out = [];
179
+ const read = parts.map((p) => {
180
+ try {
181
+ return readYaml(p.text);
182
+ }
183
+ catch {
184
+ return null;
185
+ }
186
+ });
187
+ // the part that gives the action's key, and where in it
188
+ const given = (name, key) => {
189
+ const i = read.findIndex((d) => d?.actions?.[name]?.[key] !== undefined);
190
+ return i < 0 ? null : { file: parts[i].file, ...keyAt(parts[i].text, ['actions', name, key]) };
191
+ };
192
+ const actions = (doc.actions ?? {});
193
+ for (const [name, a] of Object.entries(actions)) {
194
+ if (a === null || typeof a !== 'object' || a.serverFn === undefined)
195
+ continue;
196
+ const at = given(name, 'serverFn');
197
+ if (at === null)
198
+ continue;
199
+ for (const [key, why] of Object.entries(HTTP_ONLY)) {
200
+ if (a[key] === undefined)
201
+ continue;
202
+ const other = given(name, key);
203
+ const said = key === 'route' ? `a route, ${String(a.route)}` : key === 'query' ? 'a query' : `an operationId, ${String(a.operationId)}`;
204
+ const notes = other === null ? [] : [{ file: rel(other.file), line: other.line, column: other.column, message: `its ${key} is given here` }];
205
+ out.push(result('server-fn-http', at.file, at, `the action ${name} is a server function (serverFn: ${String(a.serverFn)}) and has ${said}: ${why} (SPEC.md §5)`, id, `actions/${name}/${key}`, notes));
206
+ }
207
+ }
208
+ return out;
209
+ }
168
210
  // the domains under root, each the domain files of one directory read as one (SPEC.md §5): a value given in two of
169
- // them, a file whose id is not its directory's, and a domain whose files sit in two directories
211
+ // them, a file whose id is not its directory's, a domain whose files sit in two directories, and a server function
212
+ // given what only an HTTP operation has
170
213
  function checkDomains(files) {
171
214
  const byDir = new Map();
172
215
  for (const f of files)
@@ -175,11 +218,13 @@ function checkDomains(files) {
175
218
  const out = [];
176
219
  const dirsOf = new Map(); // a domain's id -> the directories that hold it
177
220
  for (const [dir, list] of byDir) {
178
- const merged = mergeDomain(inReadingOrder(list).map((file) => ({ file, text: readFileSync(file, 'utf8') })));
221
+ const parts = inReadingOrder(list).map((file) => ({ file, text: readFileSync(file, 'utf8') }));
222
+ const merged = mergeDomain(parts);
179
223
  for (const p of merged.problems) {
180
224
  const notes = p.first === undefined ? [] : [{ file: rel(p.first.file), line: p.first.line, column: p.first.column, message: 'given first here' }];
181
225
  out.push(result(p.rule, p.file, p, p.message, merged.id ?? rel(dir), p.element, notes));
182
226
  }
227
+ out.push(...checkServerFunctions(parts, merged.doc, merged.id ?? rel(dir)));
183
228
  if (merged.id !== null)
184
229
  dirsOf.set(merged.id, [...(dirsOf.get(merged.id) ?? []), dir]);
185
230
  }
package/dist/cli.js CHANGED
@@ -10,7 +10,7 @@ import { renderMermaid } from './mermaid.js';
10
10
  import { renderSpine } from './spine.js';
11
11
  import { renderScreens } from './wireframe.js';
12
12
  import { renderPage } from './html.js';
13
- import { checkChanges } from './changes.js';
13
+ import { checkChanges, flowDomain } from './changes.js';
14
14
  import { checkStarts } from './starts.js';
15
15
  import { mainStoryIndex, narrate, stepsByEvents, stepsTo } from './story.js';
16
16
  import { checkGoals, findings, loadNav, menuRows, viewOf } from './nav.js';
@@ -80,7 +80,7 @@ async function flowPage(dir, out, args) {
80
80
  for (const p of checkChanges(g)?.problems ?? [])
81
81
  warn(p);
82
82
  mkdirSync(out, { recursive: true });
83
- writeFileSync(join(out, 'index.html'), renderPage({ g, m: model, ex, assertions, finals, main, spineMain, spineFull, screens, kit, handOvers }));
83
+ writeFileSync(join(out, 'index.html'), renderPage({ g, m: model, ex, assertions, finals, main, spineMain, spineFull, screens, kit, handOvers, domain: flowDomain(g) }));
84
84
  writeFileSync(join(out, 'flow.mmd'), renderMermaid(g, ex));
85
85
  const violated = assertions.filter((a) => a.violation !== undefined);
86
86
  console.log(`${g.flow.id}: ${count(Object.keys(g.flow.states).length, 'state')}, ${count(ex.configs.length, 'configuration')} from ${count(ex.starts, 'start')}, ${assertions.length - violated.length}/${assertions.length} assertions hold`);
package/dist/html.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { AssertionResult, Exploration, FinalPath, Model } from './model.ts'
3
3
  import type { Story } from './story.ts';
4
4
  import type { Kit } from './kit.ts';
5
5
  import type { HandOver } from './starts.ts';
6
+ import type { Domain, DomainAction } from './changes.ts';
6
7
  export declare const CSS = "\n: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; }\n@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; } }\n* { box-sizing: border-box; }\nbody { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, \"Segoe UI\", sans-serif; }\nmain { max-width: 1000px; margin: 0 auto; padding: 28px 16px 80px; }\nh1 { 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; }\ncode, pre, .mono { font-family: ui-monospace, \"SF Mono\", Menlo, Consolas, monospace; font-size: 13px; }\n.muted { color: var(--muted); } .label { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }\n.eyebrow { margin: 0; color: var(--muted); } .lede { font-size: 18px; max-width: 46em; margin: 0; }\n.tag { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); border-radius: 99px; font-size: 12px; color: var(--muted); vertical-align: middle; }\n.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }\ntable { 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; }\ntd ol { margin: 0; padding-left: 20px; }\n.ok { color: var(--ok); font-weight: 600; } .bad { color: var(--bad); font-weight: 600; }\n.story { margin-top: 28px; padding: 18px 22px; border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 10px; background: var(--surface); }\n.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; }\n.views input { margin-right: 8px; accent-color: var(--accent); } .views label { display: inline-block; margin: 0 0 10px; cursor: pointer; }\n.views .panel-full { display: none; } .views input:checked ~ .panel-main { display: none; } .views input:checked ~ .panel-full { display: block; }\nsvg.spine { display: block; width: 100%; height: auto; padding: 8px; background: var(--surface); margin: 0 auto; }\n.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); }\n.spine .edge-main { stroke: var(--accent); stroke-width: 3.5; stroke-dasharray: none; }\n.spine .arrow { fill: var(--muted); } .spine .arrow-fail { fill: var(--bad); } .spine .arrow-main { fill: var(--accent); }\n.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); }\n.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; }\n.spine .node-subflow rect { stroke: var(--accent); } .spine .node-subflow rect.inner { fill: none; stroke-width: 1; }\n.spine .on-main rect { stroke-width: 3; } .spine .node-server.on-main rect { stroke: var(--accent); }\n.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; }\n.spine .node.by-human rect { fill: var(--surface); stroke: var(--ink); stroke-dasharray: none; }\n.spine .node.by-ai rect { fill: var(--ai-bg); stroke: var(--ai); stroke-dasharray: none; }\n.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; }\n.spine .node.by-ci rect { fill: var(--ci-bg); stroke: var(--ci); stroke-dasharray: none; }\n.spine .node.goal rect { fill: var(--ok-bg); stroke: var(--ok); stroke-width: 3.5; stroke-dasharray: none; }\n.spine .node.on-main rect { stroke-width: 3.5; }\n.spine .nmore { fill: var(--muted); font: 600 11px system-ui, sans-serif; }\n.legend .sw { display: inline-flex; align-items: center; gap: 6px; } .legend svg { flex: none; }\n.legend .sw-node rect { stroke-width: 1.6; }\n.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; }\n.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; }\n.legend .sw-screen rect { fill: var(--surface); stroke: var(--ink); } .legend .sw-subflow rect { fill: var(--surface); stroke: var(--accent); }\n.legend .sw-node.sw-fail rect { fill: var(--surface); stroke: var(--bad); stroke-width: 3; }\n.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; }\n.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; }\n.spine .node-unreachable rect { stroke: var(--bad); fill: none; }\n.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); }\n.spine a:focus-visible .node rect, .spine a:hover .node rect { stroke: var(--focus); stroke-width: 3; }\n.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 10px 0 0; font-size: 14px; color: var(--muted); }\n.screens { display: grid; gap: 18px; }\n.screen { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 14px 16px 16px; scroll-margin-top: 16px; }\n.screen:target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }\n.screen header { display: flex; align-items: center; gap: 10px; } .screen > p { margin: 4px 0 10px; }\n.wf { border: 1px dashed var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 10px; background: var(--bg); max-width: 560px; }\n.wf-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 2px; border-radius: 4px; }\n.wf-cond { outline: 1.5px dashed var(--muted); outline-offset: 2px; } .wf-focus { outline: 2.5px solid var(--focus); outline-offset: 2px; }\n.wf-h { margin: 0; font-size: 17px; } .wf-t { margin: 0; color: var(--muted); }\n.wf-row { display: flex; flex-wrap: wrap; gap: 10px; }\n.wf-btn, .wf-link { font: inherit; border-radius: 6px; padding: 6px 14px; border: 1px solid var(--ink); background: var(--surface); color: var(--ink); }\n.wf-confirm { background: var(--ink); color: var(--bg); } .wf-link { border: 0; background: none; color: var(--accent); text-decoration: underline; padding: 0; }\n.wf button:disabled { opacity: .45; }\n.wf-list { margin: 0; padding-left: 20px; display: grid; gap: 2px; }\n.wf-status { color: var(--muted); font-style: italic; } .wf-alert { border: 1.5px solid var(--bad); border-radius: 6px; padding: 6px 10px; }\n.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); }\n.wf-unmapped { border: 1.5px solid var(--bad); padding: 6px 10px; }\n.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; }\ndetails { margin-top: 12px; } summary { cursor: pointer; color: var(--muted); }\ndetails.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; }\ndl.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; }\nul.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: \"\u2713\"; position: absolute; left: 4px; color: var(--ok); font-weight: 700; } ul.checks li.fail::before { content: \"\u2717\"; color: var(--bad); }\nfooter { margin-top: 56px; color: var(--muted); font-size: 13px; }\n";
7
8
  export interface PageInput {
8
9
  g: Graph;
@@ -16,5 +17,7 @@ export interface PageInput {
16
17
  screens: string;
17
18
  kit?: Kit | null;
18
19
  handOvers?: HandOver[];
20
+ domain?: Domain | null;
19
21
  }
22
+ export declare function callLine(a: DomainAction | null | undefined): string;
20
23
  export declare function renderPage(p: PageInput): string;
package/dist/html.js CHANGED
@@ -76,6 +76,19 @@ dl.guards { margin: 10px 0 0; display: grid; grid-template-columns: max-content
76
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
77
  footer { margin-top: 56px; color: var(--muted); font-size: 13px; }
78
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
+ }
79
92
  function routingSection(g, ex) {
80
93
  const out = [];
81
94
  for (const [name, st] of Object.entries(g.flow.states)) {
@@ -223,6 +236,19 @@ export function renderPage(p) {
223
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>`);
224
237
  out.push('</tbody></table></div>');
225
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
+ }
226
252
  const routing = routingSection(g, ex);
227
253
  if (routing !== '') {
228
254
  out.push('<h2>How it decides what happens next</h2>');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delurio/cli",
3
- "version": "0.6.1",
3
+ "version": "0.7.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",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "actions": {
29
29
  "type": "object",
30
- "description": "The API and the steps inside the service, by action name. An action with a `route` is one OpenAPI 3.1 operation whose operationId is its name; one with no route is a step inside the service. An action may be named before it is written (an empty value).",
30
+ "description": "The API and the steps inside the service, by action name. An action with a `route` is one OpenAPI 3.1 operation whose operationId is its name; one with `serverFn` is a server function that only the product's own pages call; one with neither is a step inside the service. An action may be named before it is written (an empty value).",
31
31
  "additionalProperties": { "$ref": "#/$defs/action" }
32
32
  },
33
33
  "invariants": {
@@ -212,21 +212,25 @@
212
212
  },
213
213
  "action": {
214
214
  "type": ["object", "null"],
215
- "description": "An action. With a `route` it is one OpenAPI 3.1 operation: its name is the operationId, `needs` its security requirement, `query` its query parameters, `body` its request body, `result` its response, and each refusal one more response.",
215
+ "description": "An action. With a `route` it is one OpenAPI 3.1 operation: its name is the operationId, `needs` its security requirement, `query` its query parameters, `body` its request body, `result` its response, and each refusal one more response. With `serverFn` it is a server function, called only by the product's own pages: `body` is its input, and it is no OpenAPI operation. An action has a route or a server function, never both.",
216
216
  "additionalProperties": false,
217
217
  "properties": {
218
218
  "route": {
219
219
  "type": "string",
220
- "description": "`METHOD /path`: the HTTP method and the path of the operation. An action with no route is a step inside the service.",
220
+ "description": "`METHOD /path`: the HTTP method and the path of the operation, which others call over HTTP. An action with neither a route nor `serverFn` is a step inside the service.",
221
221
  "pattern": "^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS|TRACE) /\\S*$",
222
222
  "examples": ["POST /authorize/consent", "GET /w/{workspace}/projects"]
223
223
  },
224
- "operationId": { "type": "string", "description": "The operation in the app's own OpenAPI document (named at the top with `openapi:`), when it is not this action's name." },
224
+ "serverFn": {
225
+ "description": "The action is a server function: the product's own pages call it through their framework (such as TanStack Start's `createServerFn`), at an address the framework gives it, and nobody else calls it. Its method: `GET` reads and changes nothing, `POST` may write. It is no OpenAPI operation, so it has no `route`, no `query` and no `operationId`; its input is its `body`, whatever its method (SPEC.md §5).",
226
+ "enum": ["GET", "POST"]
227
+ },
228
+ "operationId": { "type": "string", "description": "The operation in the app's own OpenAPI document (named at the top with `openapi:`), when it is not this action's name. Only a route has one." },
225
229
  "summary": { "type": "string", "description": "OpenAPI: the operation in a few words." },
226
230
  "description": { "type": "string", "description": "OpenAPI: what the operation or the step does, in words." },
227
231
  "needs": { "type": "string", "description": "delurio: what the caller must hold (the operation's security requirement).", "examples": ["session"] },
228
- "query": { "$ref": "#/$defs/schema", "description": "The query parameters: a JSON Schema object." },
229
- "body": { "$ref": "#/$defs/schema", "description": "The request body: a JSON Schema." },
232
+ "query": { "$ref": "#/$defs/schema", "description": "The query parameters of a route: a JSON Schema object." },
233
+ "body": { "$ref": "#/$defs/schema", "description": "The request body of a route, or the input of a server function: a JSON Schema." },
230
234
  "result": { "$ref": "#/$defs/result" },
231
235
  "refusals": {
232
236
  "type": "object",