@delurio/cli 0.2.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,15 @@
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
+
9
+ ## 0.3.0 (2026-10-25)
10
+
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.
12
+ - SPEC.md §7: a video's AI disclosure is its first card, which says that the whole video is made with AI, in place of a label people see throughout.
13
+
5
14
  ## 0.2.0 (2026-10-25)
6
15
 
7
16
  - JSON Schemas (2020-12) for `flow`, `ui`, `nav` (and `nav.extracted.yaml`), `domain` and `catalog` files, shipped in `schemas/`, for editors: completion, hover help from SPEC.md, and errors such as a typo in a key or a title cut short by a comma inside `{ }`.
package/README.md CHANGED
@@ -100,6 +100,20 @@ npx @delurio/cli diff examples/qauth-authorize --base origin/main
100
100
 
101
101
  This prints Markdown for a pull request. It covers what the flow does differently (found by running both revisions) and what changed in the graph.
102
102
 
103
+ ## As a library
104
+
105
+ A tool built on the format can use the same loader and checker the CLI uses:
106
+
107
+ ```ts
108
+ import { load } from '@delurio/cli/graph';
109
+ import { explore, Model } from '@delurio/cli/model';
110
+
111
+ const g = load('graphs/billing/billing.payment');
112
+ const configurations = explore(new Model(g.flow)).configs.length;
113
+ ```
114
+
115
+ The entry points are `graph`, `model`, `story`, `wireframe`, `kit`, `edges`, `html`, `nav` and `expr`, each with its types. While the version is 0.x their API may change in any minor release: pin an exact version.
116
+
103
117
  ## Licence
104
118
 
105
119
  Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE). The name "delurio" is not licensed with the code.
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 |
@@ -273,7 +273,7 @@ A **binding** ties a flow to a running app for replay and recording: `apps` (bas
273
273
 
274
274
  A **tutorial** is written against a flow: `title`, `audience`, `locale`, `appName`, `voice`, the `scenario` (the starting context), and `steps`. A step is `intro`, `chapter`, `show <state>`, `cut <state>` (jump, through a scenario the binding names), `reveal`/`focus` (nodes), `press <node>`, `after`, `card { title, body }`, `end`, and `say`. Every step is replayed on the flow, so a tutorial that no longer matches the graph stops at that step. `{word}` in `say` is a sample value or a node's visible text.
275
275
 
276
- A video is an MP4 file. Its captions are WebVTT (`tutorial.vtt`, what an HTML `<track>` plays, with `tutorial.srt` beside it), and its chapters a WebVTT chapters track (`chapters.vtt`). Every video delurio makes is marked as AI-made in three ways, none of which can be turned off: the label people see, an imperceptible watermark in the sound and the picture, and signed, time-stamped provenance metadata (C2PA is the candidate). The watermark and the metadata are the machine-readable marking that Art. 50(2) of the EU AI Act asks of a system that generates synthetic audio and video, and the Commission's Code of Practice of 10 June 2026 describes. The label is there because every voice is made from real people's recordings and may resemble one of them, which Art. 50(4) treats as a deep fake to disclose; a catalogue voice is no different from a cloned one in that, and delurio cannot tell which listener would recognise which voice (Taha, 24 Oct 2026: "Klon olmayan sesler de gerçek insan sesinden"). The video tool does none of the three yet; that is an open issue.
276
+ A video is an MP4 file. Its captions are WebVTT (`tutorial.vtt`, what an HTML `<track>` plays, with `tutorial.srt` beside it), and its chapters a WebVTT chapters track (`chapters.vtt`). Every video delurio makes is marked as AI-made in three ways, none of which can be turned off: a first card that says the whole video is made with AI, an imperceptible watermark in the sound and the picture, and signed, time-stamped provenance metadata (C2PA is the candidate). The watermark and the metadata are the machine-readable marking that Art. 50(2) of the EU AI Act asks of a system that generates synthetic audio and video, and the Commission's Code of Practice of 10 June 2026 describes. The disclosure is there because every voice is made from real people's recordings and may resemble one of them, which Art. 50(4) treats as a deep fake to disclose; a catalogue voice is no different from a cloned one in that, and delurio cannot tell which listener would recognise which voice (Taha, 24 Oct 2026: "Klon olmayan sesler de gerçek insan sesinden"). It opens the video, since Art. 50(5) asks for it at the latest at the first exposure, and nothing is burnt into the picture after it (Taha, 25 Oct 2026: "en başta 'videonun tamamı' diye belirtip yazsak yetmez mi"); a clip cut from the middle loses the card but keeps the watermark and the metadata. A lawyer is to confirm this reading. The video tool does not add the watermark or the metadata yet; that is an open issue.
277
277
 
278
278
  ## 8. Kit (`kind: kit`)
279
279
 
@@ -0,0 +1,7 @@
1
+ import type { Graph } from './graph.ts';
2
+ export interface ChangesCheck {
3
+ writes: string[];
4
+ key: string | null;
5
+ problems: string[];
6
+ }
7
+ export declare function checkChanges(g: Graph): ChangesCheck | null;
@@ -0,0 +1,23 @@
1
+ export declare const CHECK_USAGE: string;
2
+ type Level = 'error' | 'warning';
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 {};
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,34 @@
1
+ export type Op = 'added' | 'removed' | 'changed' | 'moved';
2
+ export interface Change {
3
+ area: string;
4
+ key: string;
5
+ op: Op;
6
+ field?: string;
7
+ before?: unknown;
8
+ after?: unknown;
9
+ say: string | null;
10
+ }
11
+ export interface Shift {
12
+ topic: string;
13
+ key: string;
14
+ persona?: string;
15
+ before: unknown;
16
+ after: unknown;
17
+ say: string;
18
+ detail: string[];
19
+ worse: boolean;
20
+ }
21
+ export declare function canon(v: unknown): string;
22
+ export declare const same: (a: unknown, b: unknown) => boolean;
23
+ export declare function union(before: object | undefined, after: object | undefined): string[];
24
+ export declare const quote: (s: string) => string;
25
+ export declare const joinWords: (xs: string[]) => string;
26
+ export declare function matchOrdered<T>(before: T[], after: T[], keys: Array<(x: T) => string | null>): Array<[number, number]>;
27
+ export declare function moved(pairs: Array<[number, number]>): Array<[number, number]>;
28
+ export declare function deepDiff(area: string, key: string, before: unknown, after: unknown, out: Change[], path?: string[]): void;
29
+ export declare function fieldChanges(area: string, key: string, before: Record<string, unknown>, after: Record<string, unknown>, fields: string[], say: (field: string, b: unknown, a: unknown) => string | null): Change[];
30
+ export declare function otherKeys(key: string, before: Record<string, unknown>, after: Record<string, unknown>, known: string[], out: Change[]): void;
31
+ export declare function listChanges(before: string[] | undefined, after: string[] | undefined): {
32
+ added: string[];
33
+ removed: string[];
34
+ };
@@ -0,0 +1,33 @@
1
+ import type { Graph } from './graph.ts';
2
+ import { Model } from './model.ts';
3
+ import type { Exploration } from './model.ts';
4
+ import type { PathStep } from './story.ts';
5
+ import type { Change, Shift } from './compare.ts';
6
+ export interface FlowSide {
7
+ g: Graph;
8
+ domain: {
9
+ file: string;
10
+ doc: unknown;
11
+ } | null;
12
+ }
13
+ export interface FlowStructure {
14
+ changes: Change[];
15
+ ways: Array<[string, string]>;
16
+ added: string[];
17
+ }
18
+ export declare function flowStructure(b: FlowSide, a: FlowSide): FlowStructure;
19
+ interface Run {
20
+ g: Graph;
21
+ m: Model;
22
+ ex: Exploration;
23
+ violations: Map<string, number>;
24
+ exits: Map<string, number>;
25
+ moves: number;
26
+ main: PathStep[] | null;
27
+ mainBroken: boolean;
28
+ reached: Set<string>;
29
+ }
30
+ export declare function runSide(g: Graph, side: string): Run;
31
+ export declare function flowBehaviour(rb: Run, ra: Run, s: FlowStructure): Shift[];
32
+ export declare function flowSameBehaviour(r: Run): string;
33
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { Finding, Goalcheck, NavGraph, PersonaView } from './nav.ts';
2
+ import type { Change, Shift } from './compare.ts';
3
+ export interface NavSide {
4
+ g: NavGraph;
5
+ warnings: string[];
6
+ }
7
+ export interface NavStructure {
8
+ changes: Change[];
9
+ entries: Array<[number, number]>;
10
+ }
11
+ export declare function navStructure(b: NavSide, a: NavSide): NavStructure;
12
+ export interface NavRun {
13
+ g: NavGraph;
14
+ views: PersonaView[];
15
+ goals: Goalcheck[];
16
+ found: Finding[];
17
+ }
18
+ export declare function runNav(g: NavGraph, side: string): NavRun;
19
+ export declare function navBehaviour(rb: NavRun, ra: NavRun, s: NavStructure): Shift[];
20
+ export declare function navSameBehaviour(r: NavRun): string;
package/dist/diff.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import type { Change, Shift } from './compare.ts';
2
+ export declare const DIFF_USAGE: string;
3
+ interface Source {
4
+ where: string;
5
+ rev: string | null;
6
+ read: (file: string) => string;
7
+ exists: (file: string) => boolean;
8
+ texts: Map<string, string>;
9
+ }
10
+ export interface Report {
11
+ kind: 'flow' | 'nav';
12
+ title: string;
13
+ before: Source;
14
+ after: Source;
15
+ structure: Change[];
16
+ behaviour: Shift[];
17
+ same: string;
18
+ }
19
+ export declare function renderMarkdown(r: Report): string;
20
+ export declare function renderJson(r: Report): string;
21
+ export declare function compare(before: Source, after: Source, locale?: string): Report;
22
+ export declare function diffMain(args: string[]): Promise<number>;
23
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { Graph, State } from './graph.ts';
2
+ import type { Exploration } from './model.ts';
3
+ export type EdgeKind = 'user' | 'system' | 'route' | 'fail';
4
+ export interface VizEdge {
5
+ from: string;
6
+ to: string;
7
+ labels: string[];
8
+ kind: EdgeKind;
9
+ leave: boolean;
10
+ unused: boolean;
11
+ }
12
+ export type NodeKind = 'server' | 'screen' | 'subflow' | 'exit';
13
+ export declare const BY: Record<string, string>;
14
+ export declare function kindOf(g: Graph, name: string): NodeKind;
15
+ export declare function exitLine(st: State): string;
16
+ export declare function responseLine(r: Record<string, unknown>): string;
17
+ export declare function nodeLine(g: Graph, name: string): string;
18
+ export declare function plain(g: Graph, key: string): string;
19
+ export declare function pressLabel(g: Graph, state: string, event: string): string | null;
20
+ export declare function wrap(text: string, max: number): string[];
21
+ export declare function collectEdges(g: Graph, ex: Exploration): VizEdge[];
package/dist/expr.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ export type Value = string | number | boolean | null | Value[];
2
+ export type Expr = {
3
+ k: 'lit';
4
+ v: Value;
5
+ } | {
6
+ k: 'id';
7
+ name: string;
8
+ } | {
9
+ k: 'list';
10
+ items: Expr[];
11
+ } | {
12
+ k: 'not';
13
+ e: Expr;
14
+ } | {
15
+ k: 'and' | 'or';
16
+ l: Expr;
17
+ r: Expr;
18
+ } | {
19
+ k: 'cmp';
20
+ op: '==' | '!=' | 'in' | 'not in';
21
+ l: Expr;
22
+ r: Expr;
23
+ };
24
+ export declare function parseExpr(src: string): Expr;
25
+ export declare function evaluate(e: Expr, lookup: (name: string) => Value): Value;
26
+ export declare function identifiers(e: Expr, out?: Set<string>): Set<string>;
@@ -0,0 +1,121 @@
1
+ export type Scalar = string | number | boolean;
2
+ export interface Transition {
3
+ target: string;
4
+ guard?: string;
5
+ effect?: string[];
6
+ say?: string;
7
+ starts?: Starts;
8
+ }
9
+ export interface Starts {
10
+ flow: string;
11
+ given?: Record<string, string | number | boolean>;
12
+ }
13
+ export type TransitionSpec = string | Transition | Array<string | Transition>;
14
+ export interface State {
15
+ title?: string;
16
+ description?: string;
17
+ type?: string;
18
+ invoke?: {
19
+ action?: string;
20
+ flow?: string;
21
+ external?: string;
22
+ };
23
+ on?: Record<string, TransitionSpec>;
24
+ always?: Transition[];
25
+ redirect?: string;
26
+ code?: string;
27
+ carries?: string[];
28
+ leavesPage?: boolean;
29
+ by?: 'human' | 'ai' | 'agent' | 'ci';
30
+ goal?: boolean;
31
+ includes?: string[];
32
+ response?: Record<string, unknown>;
33
+ states?: unknown;
34
+ }
35
+ export interface ContextVar {
36
+ values: Scalar[];
37
+ initial: 'any' | Scalar;
38
+ say?: Record<string, string>;
39
+ }
40
+ export interface Effect {
41
+ set?: Record<string, Scalar>;
42
+ havoc?: string[];
43
+ }
44
+ export interface Decision {
45
+ question: string;
46
+ recommend: string;
47
+ affects: string[];
48
+ }
49
+ export interface Flow {
50
+ id: string;
51
+ title?: string;
52
+ status?: string;
53
+ summary?: string;
54
+ decisions?: Record<string, Decision>;
55
+ context: Record<string, ContextVar>;
56
+ guards: Record<string, string>;
57
+ effects: Record<string, Effect>;
58
+ initial: string;
59
+ states: Record<string, State>;
60
+ assertions?: Array<{
61
+ id: string;
62
+ never: string;
63
+ say?: string;
64
+ }>;
65
+ main?: string[] | {
66
+ given?: Record<string, Scalar>;
67
+ events: string[];
68
+ };
69
+ scope?: {
70
+ shows?: string;
71
+ world?: 'open' | 'closed';
72
+ outOfView?: string[];
73
+ };
74
+ domain?: string;
75
+ }
76
+ export interface Label {
77
+ key?: string;
78
+ params?: Record<string, string>;
79
+ labelledBy?: string;
80
+ literal?: string;
81
+ oneOf?: string[];
82
+ }
83
+ export interface UiNode {
84
+ type: string;
85
+ component?: string;
86
+ role?: string;
87
+ intent?: string;
88
+ name?: Label;
89
+ text?: Label;
90
+ in?: string[];
91
+ unless?: string[];
92
+ when?: string;
93
+ disabledIn?: string[];
94
+ emits?: string;
95
+ initialFocus?: string;
96
+ frame?: string;
97
+ }
98
+ export interface Ui {
99
+ absent?: boolean;
100
+ id: string;
101
+ catalog: string;
102
+ kit?: string;
103
+ samples: Record<string, string>;
104
+ nodes: Record<string, UiNode>;
105
+ locales?: string[];
106
+ changes?: {
107
+ key: string;
108
+ };
109
+ }
110
+ export interface Graph {
111
+ dir: string;
112
+ flow: Flow;
113
+ ui: Ui;
114
+ catalog: Record<string, string>;
115
+ }
116
+ export declare class GraphError extends Error {
117
+ }
118
+ export declare function humanize(id: string): string;
119
+ export declare function titleOf(flow: Flow, state: string): string;
120
+ export declare function alternatives(spec: TransitionSpec): Transition[];
121
+ export declare function load(dir: string, read?: (file: string) => string, exists?: (file: string) => boolean): Graph;
package/dist/html.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import type { Graph } from './graph.ts';
2
+ import type { AssertionResult, Exploration, FinalPath, Model } from './model.ts';
3
+ import type { Story } from './story.ts';
4
+ import type { Kit } from './kit.ts';
5
+ import type { HandOver } from './starts.ts';
6
+ 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
+ export interface PageInput {
8
+ g: Graph;
9
+ m: Model;
10
+ ex: Exploration;
11
+ assertions: AssertionResult[];
12
+ finals: FinalPath[];
13
+ main: Story | null;
14
+ spineMain: string;
15
+ spineFull: string;
16
+ screens: string;
17
+ kit?: Kit | null;
18
+ handOvers?: HandOver[];
19
+ }
20
+ export declare function renderPage(p: PageInput): string;
@@ -0,0 +1,12 @@
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;
package/dist/kit.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ export declare class KitError extends Error {
2
+ }
3
+ declare const SLOTS: readonly ['text', 'name', 'id', 'intent', 'children'];
4
+ declare const FLAGS: readonly ['disabled', 'named', 'conditional'];
5
+ type Slot = (typeof SLOTS)[number];
6
+ type Flag = (typeof FLAGS)[number];
7
+ type Part = {
8
+ lit: string;
9
+ } | {
10
+ slot: Slot;
11
+ ctx: 'text' | 'dq' | 'sq';
12
+ } | {
13
+ flag: Flag;
14
+ negate: boolean;
15
+ parts: Part[];
16
+ };
17
+ export interface Template {
18
+ source: string;
19
+ parts: Part[];
20
+ }
21
+ export interface KitComponent {
22
+ template: Template;
23
+ roles: Record<string, Template>;
24
+ intents?: Record<string, string>;
25
+ }
26
+ export interface Kit {
27
+ id: string;
28
+ title: string;
29
+ file: string;
30
+ components: Record<string, KitComponent>;
31
+ light: Array<[string, string]>;
32
+ dark: Array<[string, string]>;
33
+ css: string;
34
+ zoom: number;
35
+ }
36
+ export interface Fill {
37
+ id: string;
38
+ text: string;
39
+ name: string;
40
+ intent: string | undefined;
41
+ role: string | undefined;
42
+ children?: string;
43
+ disabled: boolean;
44
+ named: boolean;
45
+ conditional: boolean;
46
+ }
47
+ export declare function drawWith(kit: Kit, component: string, f: Fill, warn: (m: string) => void): string | null;
48
+ export declare function mark(html: string, id: string, chips: string): string;
49
+ export declare function loadKit(path: string): Kit;
50
+ export declare function resolveKit(graphDir: string, uiKit: string | undefined, flagValue: string | undefined): Kit | null;
51
+ export declare function kitCss(kit: Kit, target: 'page' | 'stage'): string;
52
+ export declare function kitStageScript(kit: Kit): string;
53
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Graph } from './graph.ts';
2
+ import type { Exploration } from './model.ts';
3
+ export declare function renderMermaid(g: Graph, ex: Exploration): string;
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
  }
@@ -0,0 +1,56 @@
1
+ import type { Flow, Scalar } from './graph.ts';
2
+ import type { Value } from './expr.ts';
3
+ export declare class ModelError extends Error {
4
+ }
5
+ export interface Step {
6
+ event: string | null;
7
+ target: string;
8
+ ctx: Scalar[];
9
+ taken: string;
10
+ }
11
+ export interface Config {
12
+ state: string;
13
+ ctx: Scalar[];
14
+ parent: number;
15
+ event: string | null;
16
+ }
17
+ export declare class Model {
18
+ readonly flow: Flow;
19
+ readonly vars: string[];
20
+ readonly domains: Scalar[][];
21
+ constructor(flow: Flow);
22
+ private lookup;
23
+ test(expr: string, state: string, ctx: Scalar[]): boolean;
24
+ value(expr: string, state: string, ctx: Scalar[]): Value;
25
+ private apply;
26
+ steps(state: string, ctx: Scalar[]): Step[];
27
+ initials(): Scalar[][];
28
+ scenario(ctx: Scalar[]): Record<string, Scalar>;
29
+ }
30
+ export interface Exploration {
31
+ configs: Config[];
32
+ starts: number;
33
+ taken: Set<string>;
34
+ atState: Map<string, number>;
35
+ branchCounts: Map<string, number[]>;
36
+ }
37
+ export declare function explore(m: Model, from?: Scalar[][], keep?: (at: Config, s: Step) => boolean): Exploration;
38
+ export interface PathResult {
39
+ events: string[];
40
+ start: Record<string, Scalar>;
41
+ }
42
+ export declare function pathTo(m: Model, ex: Exploration, index: number): PathResult;
43
+ export interface AssertionResult {
44
+ id: string;
45
+ never: string;
46
+ say?: string;
47
+ violation?: PathResult & {
48
+ state: string;
49
+ };
50
+ }
51
+ export declare function checkAssertions(m: Model, ex: Exploration): AssertionResult[];
52
+ export interface FinalPath extends PathResult {
53
+ state: string;
54
+ index: number;
55
+ }
56
+ export declare function finalPaths(m: Model, ex: Exploration): FinalPath[];
@@ -0,0 +1,15 @@
1
+ import type { Finding, Goalcheck, MenuRow, NavGraph, PersonaView, RepoCheck } from './nav.ts';
2
+ export interface NavPageInput {
3
+ g: NavGraph;
4
+ views: PersonaView[];
5
+ rows: MenuRow[];
6
+ goals: Goalcheck[];
7
+ found: Finding[];
8
+ repo: {
9
+ checks: RepoCheck[];
10
+ head: string | null;
11
+ } | null;
12
+ warnings: string[];
13
+ }
14
+ export declare function renderNavPage(p: NavPageInput): string;
15
+ export declare function renderNavMermaid(g: NavGraph): string;
package/dist/nav.d.ts ADDED
@@ -0,0 +1,153 @@
1
+ import type { Value } from './expr.ts';
2
+ export type PageKind = 'screen' | 'placeholder' | 'missing' | 'redirect' | 'external';
3
+ export type FrameId = string;
4
+ export type How = 'auto' | 'menu' | 'picker' | 'user' | 'link' | 'button';
5
+ export interface FrameSpec {
6
+ title: string;
7
+ menu?: string;
8
+ shows?: {
9
+ fact: string;
10
+ };
11
+ }
12
+ interface FactSpec {
13
+ values?: Value[];
14
+ of?: string[];
15
+ say?: string;
16
+ }
17
+ interface EntrySpec {
18
+ id?: string;
19
+ from: string | string[];
20
+ to: string;
21
+ how: string;
22
+ label?: string;
23
+ when?: string;
24
+ clicks?: number;
25
+ data?: boolean;
26
+ back?: boolean;
27
+ }
28
+ export interface ExtractCfg {
29
+ adapter?: string;
30
+ names?: Record<string, string>;
31
+ titles?: Record<string, string>;
32
+ locales?: string[];
33
+ }
34
+ export interface Page {
35
+ id: string;
36
+ route: string;
37
+ title: string;
38
+ titleKey: string | null;
39
+ kind: PageKind;
40
+ frame: FrameId;
41
+ source: string | null;
42
+ opensFor: string | null;
43
+ pageCodes: string | null;
44
+ evidence: string | null;
45
+ refusal: string | null;
46
+ }
47
+ export interface Entry {
48
+ id: string;
49
+ spec: number;
50
+ from: string;
51
+ ofFrame: FrameId | null;
52
+ to: string;
53
+ how: How;
54
+ label: string;
55
+ labelKey: string | null;
56
+ when: string | null;
57
+ clicks: number;
58
+ data: boolean;
59
+ back: boolean;
60
+ order: number;
61
+ }
62
+ export interface Persona {
63
+ id: string;
64
+ title: string;
65
+ say: string;
66
+ facts: Record<string, Value>;
67
+ }
68
+ export interface Goal {
69
+ id: string;
70
+ say: string;
71
+ page: string;
72
+ for: string[];
73
+ within: number;
74
+ }
75
+ export interface NavGraph {
76
+ dir: string;
77
+ adapter: string | null;
78
+ frames: Record<string, FrameSpec>;
79
+ menuFrames: string[];
80
+ id: string;
81
+ title: string;
82
+ status: string;
83
+ summary: string;
84
+ locale: string;
85
+ source: Record<string, string>;
86
+ facts: Record<string, FactSpec>;
87
+ guards: Record<string, string>;
88
+ pages: Record<string, Page>;
89
+ entries: Entry[];
90
+ specs: EntrySpec[];
91
+ personas: Persona[];
92
+ goals: Goal[];
93
+ notModeled: string[];
94
+ catalog: Record<string, string>;
95
+ }
96
+ export declare const frameLevel: (e: Entry) => boolean;
97
+ export declare function loadNav(dir: string, locale?: string, read?: (file: string) => string): {
98
+ g: NavGraph;
99
+ warnings: string[];
100
+ };
101
+ export declare function holds(g: NavGraph, p: Persona, expr: string | null): boolean;
102
+ export declare const refusedFor: (g: NavGraph, p: Persona, page: string) => boolean;
103
+ export interface Reach {
104
+ page: string;
105
+ clicks: number;
106
+ via: Entry | null;
107
+ prev: string | null;
108
+ usesData: boolean;
109
+ }
110
+ export declare function walk(g: NavGraph, p: Persona): Map<string, Reach>;
111
+ export declare function pathTo(reach: Map<string, Reach>, page: string): Entry[];
112
+ export type Standing = 'ok' | 'placeholder' | 'missing' | 'refused' | 'unreachable';
113
+ export interface PersonaView {
114
+ persona: Persona;
115
+ reach: Map<string, Reach>;
116
+ standing: Record<string, Standing>;
117
+ landing: string | null;
118
+ }
119
+ export declare function viewOf(g: NavGraph, p: Persona): PersonaView;
120
+ export declare const frameReached: (g: NavGraph, v: PersonaView, frame: FrameId) => boolean;
121
+ export interface MenuCell {
122
+ shown: boolean;
123
+ standing: Standing | null;
124
+ }
125
+ export interface MenuRow {
126
+ spec: number;
127
+ frame: FrameId;
128
+ entry: Entry;
129
+ cells: MenuCell[];
130
+ frameKnown: boolean[];
131
+ }
132
+ export declare function menuRows(g: NavGraph, views: PersonaView[]): MenuRow[];
133
+ export interface Finding {
134
+ level: 'problem' | 'note';
135
+ code: string;
136
+ say: string;
137
+ detail: string[];
138
+ }
139
+ export interface Goalcheck {
140
+ goal: Goal;
141
+ persona: Persona;
142
+ outcome: 'ok' | 'too many clicks' | 'not built' | 'does not exist' | 'refused' | 'cannot reach';
143
+ clicks: number | null;
144
+ }
145
+ export declare function checkGoals(g: NavGraph, views: PersonaView[]): Goalcheck[];
146
+ export declare function findings(g: NavGraph, views: PersonaView[], goals: Goalcheck[]): Finding[];
147
+ export interface RepoCheck {
148
+ ok: boolean;
149
+ what: string;
150
+ detail: string;
151
+ }
152
+ export declare function guardCodes(g: NavGraph, src: string, depth?: number): Set<string>;
153
+ export {};
@@ -0,0 +1,10 @@
1
+ export type SchemaKind = 'flow' | 'ui' | 'domain' | 'nav' | 'catalog';
2
+ export interface SchemaFinding {
3
+ line: number;
4
+ column: number;
5
+ message: string;
6
+ graph: string | null;
7
+ element: string;
8
+ }
9
+ export declare function schemaKindOf(file: string): SchemaKind | null;
10
+ export declare function validateFile(file: string): SchemaFinding[];
@@ -0,0 +1,5 @@
1
+ import type { Graph } from './graph.ts';
2
+ import type { Exploration } from './model.ts';
3
+ import type { PathStep } from './story.ts';
4
+ export type View = 'main' | 'full';
5
+ export declare function renderSpine(g: Graph, ex: Exploration, view: View, story: PathStep[] | null): Promise<string>;
@@ -0,0 +1,11 @@
1
+ import type { Graph } from './graph.ts';
2
+ import type { Exploration, Model } from './model.ts';
3
+ export interface HandOver {
4
+ from: string;
5
+ event: string | null;
6
+ flow: string;
7
+ given: Record<string, string | number | boolean>;
8
+ found: boolean;
9
+ problems: string[];
10
+ }
11
+ export declare function checkStarts(g: Graph, m: Model, ex: Exploration): HandOver[];
@@ -0,0 +1,17 @@
1
+ import type { Graph, Scalar } from './graph.ts';
2
+ import type { Exploration, Model } from './model.ts';
3
+ export interface PathStep {
4
+ state: string;
5
+ ctx: Scalar[];
6
+ event: string | null;
7
+ taken: string | null;
8
+ }
9
+ export interface Story {
10
+ given: string;
11
+ steps: string[];
12
+ result: string;
13
+ }
14
+ export declare function stepsTo(m: Model, ex: Exploration, index: number): PathStep[];
15
+ export declare function stepsByEvents(m: Model, main: NonNullable<Graph['flow']['main']>): PathStep[] | null;
16
+ export declare function mainStoryIndex(g: Graph, ex: Exploration): number | null;
17
+ export declare function narrate(g: Graph, m: Model, steps: PathStep[]): Story;
@@ -0,0 +1,5 @@
1
+ export interface Rendered {
2
+ ok: boolean;
3
+ message: string;
4
+ }
5
+ export declare function watchPages(root: string, out: string, render: () => Promise<Rendered>, port: number | null): Promise<never>;
@@ -0,0 +1,19 @@
1
+ import type { Graph } from './graph.ts';
2
+ import type { Kit } from './kit.ts';
3
+ type Warn = (message: string) => void;
4
+ export declare function renderScreens(g: Graph, warn: Warn, kit?: Kit | null): string;
5
+ export declare function renderStageScreen(g: Graph, state: string, reveal: string[], warn: Warn, kit?: Kit | null): string;
6
+ export interface Expectation {
7
+ state: string;
8
+ id: string;
9
+ index: number;
10
+ role: string;
11
+ name: string | undefined;
12
+ disabled: boolean;
13
+ }
14
+ export declare function renderCheckScreens(g: Graph, kit: Kit | null, warn: Warn): {
15
+ html: string;
16
+ expected: Expectation[];
17
+ };
18
+ export declare function nodeTexts(g: Graph, id: string, warn: Warn): string[];
19
+ export {};
package/package.json CHANGED
@@ -1,10 +1,22 @@
1
1
  {
2
2
  "name": "@delurio/cli",
3
- "version": "0.2.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",
7
7
  "bin": { "delurio": "dist/cli.js" },
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
+ "./package.json": "./package.json"
19
+ },
8
20
  "files": ["dist", "schemas", "SPEC.md", "NOTICE", "CHANGELOG.md"],
9
21
  "engines": { "node": ">=22.18" },
10
22
  "repository": { "type": "git", "url": "git+https://github.com/delurio-labs/delurio.git" },
@@ -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",