codeassembly-agent-logic 0.4.0 → 0.6.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.
@@ -1,4 +1,64 @@
1
1
  [
2
+ {
3
+ "version": "0.6.0",
4
+ "date": "2026-11-19",
5
+ "sections": [
6
+ {
7
+ "title": "🎉 Features",
8
+ "audience": "all",
9
+ "items": [
10
+ {
11
+ "description": "Adds `PromptPane` and `PromptKey` to `codeassembly-agent-logic/react`, which show the whole prompt with a key and mark ambient, unused, unconverted, and comment text, leaving the text that the chart uses unmarked. (#2297)",
12
+ "hash": "69ca2afee97618c49a07c257bcf70684b58f8567",
13
+ "entry": 1
14
+ },
15
+ {
16
+ "description": "Adds the custom properties `--agent-logic-passage-background`, `--agent-logic-text-subtlest`, and `--agent-logic-unconverted` to `codeassembly-agent-logic/react/styles.css` for theming the pane, and adds `--agent-logic-font-prose`, which replaces the serif face that was hard-coded for a flow's preamble. (#2297)",
17
+ "hash": "69ca2afee97618c49a07c257bcf70684b58f8567",
18
+ "entry": 2
19
+ }
20
+ ]
21
+ }
22
+ ]
23
+ },
24
+ {
25
+ "version": "0.5.0",
26
+ "date": "2026-11-19",
27
+ "sections": [
28
+ {
29
+ "title": "🎉 Features",
30
+ "audience": "all",
31
+ "items": [
32
+ {
33
+ "description": "Adds six seed colour properties to `codeassembly-agent-logic/react/styles.css` (`--agent-logic-surface`, `--agent-logic-text`, `--agent-logic-accent`, `--agent-logic-global`, `--agent-logic-waiting`, and `--agent-logic-warning`), from which each component property, such as `--agent-logic-border` or `--agent-logic-selected`, derives its default, and keeps each component property available to override one part. (#2296)",
34
+ "hash": "b499d2faed00b6a46a7a43b50da20299723d6694",
35
+ "entry": 1
36
+ },
37
+ {
38
+ "description": "Changes the default palette and tints the canvas ground with the accent seed, with dots coloured from the text and accent seeds, while React Flow's `--xy-background-color` and `--xy-background-pattern-color` still replace the ground and the dots. (#2296)",
39
+ "hash": "b499d2faed00b6a46a7a43b50da20299723d6694",
40
+ "entry": 2
41
+ },
42
+ {
43
+ "description": "Adds a dotted underline in the global colour to an ambient instruction on the canvas, the same mark that the prompt pane gives ambient text. (#2296)",
44
+ "hash": "b499d2faed00b6a46a7a43b50da20299723d6694",
45
+ "entry": 3
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "title": "🐛 Bug fixes",
51
+ "audience": "all",
52
+ "items": [
53
+ {
54
+ "description": "Fixes the issue that a consumer's layered reset, such as Tailwind's preflight, removed the padding that React Flow gives the canvas attribution, by setting that padding in the package's `styles.css` outside any cascade layer. (#2295)",
55
+ "hash": "34aa04421ed93d04a7eae0092f62fe30ed20ddae",
56
+ "entry": 1
57
+ }
58
+ ]
59
+ }
60
+ ]
61
+ },
2
62
  {
3
63
  "version": "0.4.0",
4
64
  "date": "2026-11-18",
package/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 0.6.0 — 2026-11-19
6
+
7
+ ### 🎉 Features
8
+
9
+ - Adds `PromptPane` and `PromptKey` to `codeassembly-agent-logic/react`, which show the whole prompt with a key and mark ambient, unused, unconverted, and comment text, leaving the text that the chart uses unmarked. (#2297)
10
+ - Adds the custom properties `--agent-logic-passage-background`, `--agent-logic-text-subtlest`, and `--agent-logic-unconverted` to `codeassembly-agent-logic/react/styles.css` for theming the pane, and adds `--agent-logic-font-prose`, which replaces the serif face that was hard-coded for a flow's preamble. (#2297)
11
+
12
+ ## 0.5.0 — 2026-11-19
13
+
14
+ ### 🎉 Features
15
+
16
+ - Adds six seed colour properties to `codeassembly-agent-logic/react/styles.css` (`--agent-logic-surface`, `--agent-logic-text`, `--agent-logic-accent`, `--agent-logic-global`, `--agent-logic-waiting`, and `--agent-logic-warning`), from which each component property, such as `--agent-logic-border` or `--agent-logic-selected`, derives its default, and keeps each component property available to override one part. (#2296)
17
+ - Changes the default palette and tints the canvas ground with the accent seed, with dots coloured from the text and accent seeds, while React Flow's `--xy-background-color` and `--xy-background-pattern-color` still replace the ground and the dots. (#2296)
18
+ - Adds a dotted underline in the global colour to an ambient instruction on the canvas, the same mark that the prompt pane gives ambient text. (#2296)
19
+
20
+ ### 🐛 Bug fixes
21
+
22
+ - Fixes the issue that a consumer's layered reset, such as Tailwind's preflight, removed the padding that React Flow gives the canvas attribution, by setting that padding in the package's `styles.css` outside any cascade layer. (#2295)
23
+
5
24
  ## 0.4.0 — 2026-11-18
6
25
 
7
26
  ### 🎉 Features
package/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  <!-- section:release-notes -->
2
- ## Release notes — v0.4.0 (2026-11-18)
2
+ ## Release notes — v0.6.0 (2026-11-19)
3
3
 
4
4
  ### 🎉 Features
5
5
 
6
- - Adds the experimental `codeassembly-agent-logic/job` entry, whose `createConversionJob` returns a job that `runJob` of `@williamthorsen/toolbelt.llm` runs in a page or a hosted function to convert a prompt with the instructions, the `check_coverage` and `submit_draft` tools, and the caps that `convertWithAgent` uses. (#2290)
6
+ - Adds `PromptPane` and `PromptKey` to `codeassembly-agent-logic/react`, which show the whole prompt with a key and mark ambient, unused, unconverted, and comment text, leaving the text that the chart uses unmarked. (#2297)
7
+ - Adds the custom properties `--agent-logic-passage-background`, `--agent-logic-text-subtlest`, and `--agent-logic-unconverted` to `codeassembly-agent-logic/react/styles.css` for theming the pane, and adds `--agent-logic-font-prose`, which replaces the serif face that was hard-coded for a flow's preamble. (#2297)
7
8
  <!-- /section:release-notes -->
8
9
 
9
10
  <!-- readme-type: library -->
@@ -34,8 +35,8 @@ if (result.ok) {
34
35
  | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
35
36
  | `codeassembly-agent-logic` | The config schema and its validation, the converter and coverage check, the chart description, its ELK graph (`buildElkGraph`), its layout, source marking, and the bundled examples. |
36
37
  | `codeassembly-agent-logic/agent` | `convertWithAgent`, which converts a prompt by directing an ACP agent through the conversion. |
37
- | `codeassembly-agent-logic/react` | `StatechartCanvas`, the key's entries as data (`CANVAS_KEY_ENTRIES` and the mark glyphs), and the hooks of a page that presents a chart. |
38
- | `codeassembly-agent-logic/react/styles.css` | The canvas stylesheet. |
38
+ | `codeassembly-agent-logic/react` | `StatechartCanvas`, the key's entries as data (`CANVAS_KEY_ENTRIES` and the mark glyphs), `PromptPane` and its `PromptKey`, and the hooks of a page that presents a chart. |
39
+ | `codeassembly-agent-logic/react/styles.css` | The stylesheet of the canvas and the prompt pane. |
39
40
  | `codeassembly-agent-logic/server` | `createConversionHandler`, which serves conversions on an ACP agent, and its stores. |
40
41
  | `codeassembly-agent-logic/client` | `createConversionClient`, the browser client of the routes that `createConversionHandler` serves. |
41
42
  | `codeassembly-agent-logic/job` | `createConversionJob`, which converts a prompt as a job of `@williamthorsen/toolbelt.llm`, in a page or a function. |
@@ -114,26 +115,42 @@ if (started.ok) {
114
115
 
115
116
  ## What the app supplies
116
117
 
117
- The package draws the chart; the page around it is the app's. The app renders the load controls, the inspector, the source pane, and the terminal in its own design system, and it renders the canvas's key: `StatechartCanvas` passes the marks that the chart draws to its `renderKey` prop, and `CANVAS_KEY_ENTRIES` gives each mark's name, gloss, and drawing. The app also supplies the URL of the conversions resource to `./client`'s `createConversionClient`.
118
+ The package draws the chart and the prompt; the page around them is the app's. The app renders the load controls, the inspector, and the terminal in its own design system, and it renders the canvas's key: `StatechartCanvas` passes the marks that the chart draws to its `renderKey` prop, and `CANVAS_KEY_ENTRIES` gives each mark's name, gloss, and drawing.
119
+
120
+ `PromptPane` shows the whole prompt with its key, marking the text that the chart does not use and leaving used text unmarked. The app supplies its segments, from `buildPromptSegments`, the selected element, the passages to show, and the handler that receives a clicked passage's path. A line that the app draws from the canvas to the selected passage finds the pane's text by `data-prompt-text` and the passage by `data-passage-for`, whose value is the element's path; `PromptPane`'s doc comment lists its other attributes. `PromptKey` renders the key alone, for an app that places it outside the pane. The app also supplies the URL of the conversions resource to `./client`'s `createConversionClient`.
118
121
 
119
122
  ## Styling and theming
120
123
 
121
- Import `codeassembly-agent-logic/react/styles.css` once, through a bundler: It imports React Flow's base styles from this package's own dependency. It declares a default for each custom property on `:root` at zero specificity, so an app overrides any of them on `:root` or on an ancestor of the canvas, for example to map them to its design tokens:
124
+ Import `codeassembly-agent-logic/react/styles.css` once, through a bundler: It imports React Flow's base styles from this package's own dependency. Its defaults form a finished light theme, which applies under any `color-scheme`.
125
+
126
+ The colours come in two tiers of custom properties. The seeds are a few base colours, and every other colour derives from them, so an app sets the seeds alone to retheme the canvas and its key, for example to map them to its design tokens or to make a dark theme:
122
127
 
123
128
  ```css
124
129
  :root {
130
+ --agent-logic-surface: var(--ds-surface);
125
131
  --agent-logic-text: var(--ds-text);
126
- --agent-logic-selected: var(--ds-border-selected);
132
+ --agent-logic-accent: var(--ds-border-selected);
127
133
  }
128
134
  ```
129
135
 
130
- The properties, whose defaults [`styles.css`](src/react/styles.css) declares:
136
+ Set the properties on `:root`, or on an ancestor of the canvas, the pane, and any key that the app renders outside them. The seeds, whose defaults [`styles.css`](src/react/styles.css) declares:
137
+
138
+ - `--agent-logic-surface`: the background of a state and of a label
139
+ - `--agent-logic-text`: the text
140
+ - `--agent-logic-accent`: selection and focus
141
+ - `--agent-logic-global`, `--agent-logic-waiting`, `--agent-logic-warning`: the marks for an any-time transition and ambient text, a state that waits for the user, and an unreachable state
142
+
143
+ The component properties, which an app sets to override one part; `styles.css` states each derivation:
144
+
145
+ - `--agent-logic-ambient-background`, `--agent-logic-compound-background`, `--agent-logic-hover-background`: backgrounds, from `text` (and `surface` for a compound state)
146
+ - `--agent-logic-node-background`, `--agent-logic-tooltip-text`: from `surface`
147
+ - `--agent-logic-selected-background`, `--agent-logic-passage-background`: from `accent` and `surface`; the second fills the pane's selected and shown passages
148
+ - `--agent-logic-text-subtle`, `--agent-logic-text-subtlest`, `--agent-logic-border`, `--agent-logic-border-strong`: from `text` and `surface`; the pane sets unused text in the first and comments in the second
149
+ - `--agent-logic-unconverted`: the wavy line under unconverted text, from `warning` and `text`
150
+ - `--agent-logic-tooltip-background`: from `text`
151
+ - `--agent-logic-focus-ring`, `--agent-logic-selected`: from `accent`
131
152
 
132
- - `--agent-logic-ambient-background`, `--agent-logic-compound-background`, `--agent-logic-hover-background`, `--agent-logic-node-background`, `--agent-logic-selected-background`, `--agent-logic-surface`, `--agent-logic-tooltip-background`: backgrounds
133
- - `--agent-logic-text`, `--agent-logic-text-subtle`, `--agent-logic-tooltip-text`: text
134
- - `--agent-logic-border`, `--agent-logic-border-strong`, `--agent-logic-focus-ring`, `--agent-logic-selected`: borders and outlines
135
- - `--agent-logic-global`, `--agent-logic-waiting`, `--agent-logic-warning`: the marks for an any-time transition, a state that waits for the user, and an unreachable state
136
- - `--agent-logic-font-code`: the code font
153
+ The canvas's ground and its dots also derive from the seeds; React Flow's `--xy-background-color` and `--xy-background-pattern-color` replace them. `--agent-logic-font-code` sets the code font, and `--agent-logic-font-prose` the face in which the pane and a flow's preamble quote the prompt.
137
154
 
138
155
  ## The bin
139
156
 
@@ -1,4 +1,4 @@
1
- /** `./react` entry: the statechart canvas, the data of its key, and the hooks of a page that presents a chart. */
1
+ /** `./react` entry: the statechart canvas, the data of its key, the prompt pane, and the hooks of a chart's page. */
2
2
  export * from './canvas/canvas-key-entries.js';
3
3
  export * from './canvas/list-chart-marks.js';
4
4
  export * from './canvas/marks.js';
@@ -15,3 +15,5 @@ export * from './hooks/useEscapeToClear.js';
15
15
  export * from './hooks/useSelection.js';
16
16
  export * from './hooks/useShowAmbient.js';
17
17
  export * from './hooks/useUnknownExample.js';
18
+ export * from './source/PromptKey.js';
19
+ export * from './source/PromptPane.js';
@@ -14,3 +14,5 @@ export * from "./hooks/useEscapeToClear.js";
14
14
  export * from "./hooks/useSelection.js";
15
15
  export * from "./hooks/useShowAmbient.js";
16
16
  export * from "./hooks/useUnknownExample.js";
17
+ export * from "./source/PromptKey.js";
18
+ export * from "./source/PromptPane.js";
@@ -0,0 +1,3 @@
1
+ import type { ReactElement } from 'react';
2
+ /** The key of the prompt pane's marks, each name drawn with the mark that it names. */
3
+ export declare function PromptKey(): ReactElement;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export function PromptKey() {
3
+ return (_jsx("ul", { "aria-label": "Prompt marks", className: "prompt-key", children: KEY_ENTRIES.map(({ coverage, label }) => (_jsx("li", { className: "prompt-key__entry", children: _jsx("span", { className: `prompt-key__sample prompt-key__sample--${coverage}`, children: label }) }, coverage))) }));
4
+ }
5
+ const KEY_ENTRIES = [
6
+ { coverage: 'ambient', label: 'Ambient' },
7
+ { coverage: 'unused', label: 'Not used' },
8
+ { coverage: 'unconverted', label: 'Not converted' },
9
+ { coverage: 'comment', label: 'Comment' },
10
+ ];
@@ -0,0 +1,19 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { ElementDescription } from '../../layout/describe-config.js';
3
+ import type { Span } from '../../schema/agent-logic-schema.js';
4
+ import { type PromptSegment } from '../../source/prompt-segments.js';
5
+ export interface PromptPaneProps {
6
+ segments: PromptSegment[];
7
+ selected: ElementDescription | undefined;
8
+ /** The passages to mark, the earliest of which is brought into view; the segments must be cut at their bounds. */
9
+ shownPassages?: Span[] | undefined;
10
+ /** Receives the path of the element whose passage was clicked. */
11
+ onSelect: (path: string) => void;
12
+ }
13
+ /**
14
+ * The whole prompt with its key, marking the text that the chart does not use, with the selected element's or the
15
+ * shown passages highlighted. Its text region has `data-prompt-text`, and each passage `data-coverage`; a selected
16
+ * passage has `data-selected`, the first of them `data-passage-for` with the element's path, a shown passage
17
+ * `data-shown`, the earliest of them `data-shown-passage`, and a passage that selects an element `data-select-path`.
18
+ */
19
+ export declare function PromptPane({ segments, selected, shownPassages, onSelect }: PromptPaneProps): ReactElement;
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef } from 'react';
3
+ import { listElementWords } from "../../source/prompt-segments.js";
4
+ import { PromptKey } from "./PromptKey.js";
5
+ export function PromptPane({ segments, selected, shownPassages = [], onSelect }) {
6
+ const headingId = useId();
7
+ const textRef = useRef(null);
8
+ const selectedPath = selected?.path;
9
+ const sharedWords = selected === undefined ? new Set() : listElementWords(selected);
10
+ const firstSelectedStart = segments.find(({ paths }) => selectedPath !== undefined && paths.includes(selectedPath))?.start;
11
+ const firstShownStart = Math.min(...shownPassages.map(({ start }) => start));
12
+ const shownKey = shownPassages.map(({ start, end }) => `${start}-${end}`).join(',');
13
+ useEffect(() => {
14
+ const container = textRef.current;
15
+ const passage = container?.querySelector('[data-passage-for], [data-shown-passage]');
16
+ const firstLine = passage?.getClientRects()[0];
17
+ if (container === null || firstLine === undefined)
18
+ return;
19
+ const bounds = container.getBoundingClientRect();
20
+ if (firstLine.top >= bounds.top && firstLine.bottom <= bounds.bottom)
21
+ return;
22
+ container.scrollTop += firstLine.top - bounds.top - container.clientHeight * 0.3;
23
+ }, [selectedPath, shownKey]);
24
+ function handleClick(event) {
25
+ if (!(event.target instanceof Element))
26
+ return;
27
+ const path = event.target.closest('[data-select-path]')?.dataset['selectPath'];
28
+ if (path !== undefined)
29
+ onSelect(path);
30
+ }
31
+ return (_jsxs("section", { "aria-labelledby": headingId, className: "prompt-pane", children: [_jsxs("div", { className: "prompt-pane__header", children: [_jsx("h2", { id: headingId, className: "prompt-pane__heading", children: "Prompt" }), _jsx(PromptKey, {})] }), _jsx("div", { ref: textRef, onClick: handleClick, "data-prompt-text": "", className: "prompt-pane__text", children: segments.map((segment) => {
32
+ const isShown = shownPassages.some(({ start, end }) => segment.start >= start && segment.end <= end);
33
+ const isSelected = selectedPath !== undefined && segment.paths.includes(selectedPath);
34
+ const selectPath = segment.coverage === 'used'
35
+ ? segment.paths[0]
36
+ : segment.coverage === 'ambient'
37
+ ? segment.paths.find((path) => AMBIENT_PATH.test(path))
38
+ : undefined;
39
+ return (_jsx("span", { className: classifyPassage(segment, isSelected || isShown), "data-coverage": segment.coverage, "data-selected": isSelected ? '' : undefined, "data-shown": isShown ? '' : undefined, "data-select-path": selectPath, "data-passage-for": isSelected && segment.start === firstSelectedStart ? selectedPath : undefined, "data-shown-passage": isShown && segment.start === firstShownStart ? '' : undefined, children: isSelected ? boldSharedWords(segment.text, sharedWords) : segment.text }, segment.start));
40
+ }) })] }));
41
+ }
42
+ const AMBIENT_PATH = /(?:^|\.)meta\.ambient\[\d+\]$/;
43
+ const WORD = /[A-Za-z0-9]/;
44
+ function boldSharedWords(text, words) {
45
+ return text
46
+ .split(/([A-Za-z0-9]+)/)
47
+ .map((part, index) => (words.has(part.toLowerCase()) ? _jsx("b", { children: part }, index) : part));
48
+ }
49
+ function classifyPassage({ coverage, text }, isHighlighted) {
50
+ const isMarked = coverage !== 'unused' || WORD.test(text);
51
+ const classes = isMarked ? `prompt-pane__passage prompt-pane__passage--${coverage}` : 'prompt-pane__passage';
52
+ return isHighlighted ? `${classes} prompt-pane__passage--highlighted` : classes;
53
+ }
@@ -1,29 +1,80 @@
1
1
  /*
2
- * Styles for the statechart canvas and the marks of its key. Colours and the code font are custom properties, each with
3
- * a default here; a consumer overrides any of them on :root or on an ancestor of the canvas.
2
+ * Styles for the statechart canvas, the prompt pane, and the marks of their keys. The colours come in two tiers of
3
+ * custom properties: the seeds, declared on :root, and the component properties, each of which derives its default from
4
+ * the seeds. A consumer sets either tier on :root or on an ancestor of the components that it renders.
4
5
  */
5
6
 
6
7
  @import '@xyflow/react/style.css';
7
8
 
8
9
  :where(:root) {
9
- --agent-logic-ambient-background: #091e420f;
10
- --agent-logic-border: #0b120e24;
11
- --agent-logic-border-strong: #758195;
12
- --agent-logic-compound-background: #f7f8f9;
13
- --agent-logic-focus-ring: #2684ff;
10
+ --agent-logic-accent: #2346c4;
14
11
  --agent-logic-font-code: ui-monospace, monospace;
15
- --agent-logic-global: #8270db;
16
- --agent-logic-hover-background: #091e420f;
17
- --agent-logic-node-background: #fff;
18
- --agent-logic-selected: #0c66e4;
19
- --agent-logic-selected-background: #e9f2ff;
20
- --agent-logic-surface: #fff;
21
- --agent-logic-text: #172b4d;
22
- --agent-logic-text-subtle: #44546f;
23
- --agent-logic-tooltip-background: #44546f;
24
- --agent-logic-tooltip-text: #fff;
25
- --agent-logic-waiting: #1d7afc;
26
- --agent-logic-warning: #e06c00;
12
+ --agent-logic-font-prose: 'Iowan Old Style', Charter, 'Source Serif 4', Georgia, ui-serif, serif;
13
+ --agent-logic-global: #b0307f;
14
+ --agent-logic-surface: #ffffff;
15
+ --agent-logic-text: #1c1f24;
16
+ --agent-logic-waiting: #0e9f3c;
17
+ --agent-logic-warning: #c9520a;
18
+ }
19
+
20
+ /*
21
+ * Each component property resolves here, on the elements that read it, rather than on :root, so that seeds set on any
22
+ * ancestor of the canvas, the pane, or a key entry reach the derivation. Every rule below reads the private property.
23
+ */
24
+ :where(
25
+ .statechart-canvas,
26
+ .arrowhead-defs,
27
+ .canvas-key__swatch,
28
+ .canvas-key__word,
29
+ .mark-glyph,
30
+ .prompt-pane,
31
+ .prompt-key
32
+ ) {
33
+ --_agent-logic-ambient-background: var(
34
+ --agent-logic-ambient-background,
35
+ color-mix(in srgb, var(--agent-logic-text) 7%, transparent)
36
+ );
37
+ --_agent-logic-border: var(
38
+ --agent-logic-border,
39
+ color-mix(in srgb, var(--agent-logic-text) 58%, var(--agent-logic-surface))
40
+ );
41
+ --_agent-logic-border-strong: var(
42
+ --agent-logic-border-strong,
43
+ color-mix(in srgb, var(--agent-logic-text) 63%, var(--agent-logic-surface))
44
+ );
45
+ --_agent-logic-compound-background: var(
46
+ --agent-logic-compound-background,
47
+ color-mix(in srgb, var(--agent-logic-text) 5%, var(--agent-logic-surface))
48
+ );
49
+ --_agent-logic-focus-ring: var(--agent-logic-focus-ring, var(--agent-logic-accent));
50
+ --_agent-logic-hover-background: var(
51
+ --agent-logic-hover-background,
52
+ color-mix(in srgb, var(--agent-logic-text) 12.5%, transparent)
53
+ );
54
+ --_agent-logic-node-background: var(--agent-logic-node-background, var(--agent-logic-surface));
55
+ --_agent-logic-passage-background: var(
56
+ --agent-logic-passage-background,
57
+ color-mix(in srgb, var(--agent-logic-accent) 22%, var(--agent-logic-surface))
58
+ );
59
+ --_agent-logic-selected: var(--agent-logic-selected, var(--agent-logic-accent));
60
+ --_agent-logic-selected-background: var(
61
+ --agent-logic-selected-background,
62
+ color-mix(in srgb, var(--agent-logic-accent) 13%, var(--agent-logic-surface))
63
+ );
64
+ --_agent-logic-text-subtle: var(
65
+ --agent-logic-text-subtle,
66
+ color-mix(in srgb, var(--agent-logic-text) 78%, var(--agent-logic-surface))
67
+ );
68
+ --_agent-logic-text-subtlest: var(
69
+ --agent-logic-text-subtlest,
70
+ color-mix(in srgb, var(--agent-logic-text) 72%, var(--agent-logic-surface))
71
+ );
72
+ --_agent-logic-tooltip-background: var(--agent-logic-tooltip-background, var(--agent-logic-text));
73
+ --_agent-logic-tooltip-text: var(--agent-logic-tooltip-text, var(--agent-logic-surface));
74
+ --_agent-logic-unconverted: var(
75
+ --agent-logic-unconverted,
76
+ color-mix(in srgb, var(--agent-logic-warning) 70%, var(--agent-logic-text))
77
+ );
27
78
  }
28
79
 
29
80
  .statechart-canvas {
@@ -42,9 +93,23 @@
42
93
  block-size: auto;
43
94
  }
44
95
 
45
- /* Keep the library's attribution at the page's 12px text floor. */
96
+ /*
97
+ * Keep the library's attribution at the page's 12px text floor, padded for that size. The library's own padding is in
98
+ * its cascade layer, which a consumer's layered reset, such as Tailwind's preflight, can override.
99
+ */
46
100
  .statechart-canvas .react-flow__attribution {
47
101
  font-size: 12px;
102
+ padding: 3px 6px;
103
+ }
104
+
105
+ /* Tint the ground under the cards. A consumer's `--xy-background-color` or `--xy-background-pattern-color` wins. */
106
+ .statechart-canvas .react-flow {
107
+ --xy-background-color-default: color-mix(in srgb, var(--agent-logic-accent) 9%, var(--agent-logic-surface));
108
+ --xy-background-pattern-dots-color-default: color-mix(
109
+ in srgb,
110
+ color-mix(in srgb, var(--agent-logic-text), var(--agent-logic-accent)) 40%,
111
+ var(--xy-background-color, var(--xy-background-color-default))
112
+ );
48
113
  }
49
114
 
50
115
  /* -- Interaction states, shared by every node and edge -- */
@@ -55,7 +120,7 @@
55
120
  }
56
121
 
57
122
  .statechart-canvas .react-flow__node:focus-visible {
58
- outline: 2px solid var(--agent-logic-focus-ring);
123
+ outline: 2px solid var(--_agent-logic-focus-ring);
59
124
  outline-offset: 2px;
60
125
  }
61
126
 
@@ -80,29 +145,29 @@
80
145
  max-inline-size: none;
81
146
  padding: 0;
82
147
  overflow: hidden;
83
- background-color: var(--agent-logic-border-strong);
148
+ background-color: var(--_agent-logic-border-strong);
84
149
  color: transparent;
85
150
  font-size: 0;
86
151
  transform: none;
87
152
  }
88
153
 
89
154
  .statechart-canvas .state-node__flow-name--hidden:hover {
90
- background-color: var(--agent-logic-selected);
155
+ background-color: var(--_agent-logic-selected);
91
156
  }
92
157
 
93
158
  /* A final state's outline is its mark, so pointing at or selecting it adds only the ring. */
94
159
  .statechart-canvas .react-flow__node:hover > .state-node:not(.state-node--final),
95
160
  .statechart-canvas .react-flow__node.selected > .state-node:not(.state-node--final) {
96
- border-color: var(--agent-logic-border-strong);
161
+ border-color: var(--_agent-logic-border-strong);
97
162
  }
98
163
 
99
164
  .statechart-canvas .react-flow__node.selected > .state-node {
100
- box-shadow: 0 0 0 1px var(--agent-logic-selected);
165
+ box-shadow: 0 0 0 1px var(--_agent-logic-selected);
101
166
  }
102
167
 
103
168
  .statechart-canvas .react-flow__edge:hover .transition-edge__path,
104
169
  .statechart-canvas .react-flow__edge.selected .transition-edge__path {
105
- stroke: var(--agent-logic-selected);
170
+ stroke: var(--_agent-logic-selected);
106
171
  stroke-width: 2.5;
107
172
  marker-end: url('#arrowhead-selected');
108
173
  }
@@ -110,7 +175,7 @@
110
175
  .statechart-canvas .react-flow__edge:focus-visible .transition-edge__label,
111
176
  .statechart-canvas .react-flow__edge.selected .transition-edge__label {
112
177
  /* Inset, because the label's foreignObject clips anything outside it. */
113
- outline: 2px solid var(--agent-logic-focus-ring);
178
+ outline: 2px solid var(--_agent-logic-focus-ring);
114
179
  outline-offset: -2px;
115
180
  }
116
181
 
@@ -120,7 +185,7 @@
120
185
 
121
186
  /* The lower levels of detail hide the label, so the route shows focus too. */
122
187
  .statechart-canvas .react-flow__edge:focus-visible .transition-edge__path {
123
- stroke: var(--agent-logic-focus-ring);
188
+ stroke: var(--_agent-logic-focus-ring);
124
189
  stroke-width: 3;
125
190
  marker-end: url('#arrowhead-selected');
126
191
  }
@@ -148,8 +213,9 @@
148
213
  }
149
214
 
150
215
  .statechart-canvas__flow--shapes .state-node__ambient {
151
- background: var(--agent-logic-ambient-background);
216
+ background: var(--_agent-logic-ambient-background);
152
217
  color: transparent;
218
+ text-decoration: none;
153
219
  }
154
220
 
155
221
  /* -- States -- */
@@ -158,9 +224,9 @@
158
224
  block-size: 100%;
159
225
  box-sizing: border-box;
160
226
  padding: 8px 12px;
161
- border: 1px solid var(--agent-logic-border);
227
+ border: 1px solid var(--_agent-logic-border);
162
228
  border-radius: 8px;
163
- background: var(--agent-logic-node-background);
229
+ background: var(--_agent-logic-node-background);
164
230
  color: var(--agent-logic-text);
165
231
  font-size: 14px;
166
232
  line-height: 18px;
@@ -168,7 +234,7 @@
168
234
  }
169
235
 
170
236
  .state-node--compound {
171
- background: var(--agent-logic-compound-background);
237
+ background: var(--_agent-logic-compound-background);
172
238
  }
173
239
 
174
240
  /* A thicker border takes its width from the padding, so the content keeps its place. */
@@ -179,7 +245,7 @@
179
245
 
180
246
  .state-node--inferred {
181
247
  padding: 7px 11px;
182
- border: 2px dashed var(--agent-logic-text-subtle);
248
+ border: 2px dashed var(--_agent-logic-text-subtle);
183
249
  }
184
250
 
185
251
  /* An inferred final state keeps its dash and takes the final outline's colour. */
@@ -243,17 +309,17 @@
243
309
  }
244
310
 
245
311
  .mark-glyph__cutout {
246
- fill: var(--agent-logic-node-background);
312
+ fill: var(--_agent-logic-node-background);
247
313
  }
248
314
 
249
315
  .state-node__inferred {
250
- color: var(--agent-logic-text-subtle);
316
+ color: var(--_agent-logic-text-subtle);
251
317
  font-size: 12px;
252
318
  font-style: italic;
253
319
  }
254
320
 
255
321
  .state-node__gate {
256
- color: var(--agent-logic-text-subtle);
322
+ color: var(--_agent-logic-text-subtle);
257
323
  font-size: 12px;
258
324
  }
259
325
 
@@ -273,7 +339,7 @@
273
339
  }
274
340
 
275
341
  .state-node__preamble-heading {
276
- color: var(--agent-logic-text-subtle);
342
+ color: var(--_agent-logic-text-subtle);
277
343
  font-size: 12px;
278
344
  line-height: 16px;
279
345
  }
@@ -311,26 +377,29 @@
311
377
  background: none;
312
378
  color: var(--agent-logic-text);
313
379
  cursor: pointer;
314
- /* The serif face in which an app's prompt pane quotes the prompt. */
315
- font-family: 'Iowan Old Style', Charter, 'Source Serif 4', Georgia, ui-serif, serif;
380
+ /* The prompt pane's face, in which the preamble quotes the prompt. */
381
+ font-family: var(--agent-logic-font-prose);
316
382
  font-size: 14px;
317
383
  line-height: 20px;
318
384
  text-align: start;
385
+ /* The prompt pane's mark for ambient text, beside the global colour. */
386
+ text-decoration: underline dotted 2px var(--agent-logic-global);
387
+ text-underline-offset: 3px;
319
388
  }
320
389
 
321
390
  .state-node__ambient:hover {
322
- background: var(--agent-logic-hover-background);
391
+ background: var(--_agent-logic-hover-background);
323
392
  }
324
393
 
325
394
  .state-node__ambient:focus-visible {
326
- outline: 2px solid var(--agent-logic-focus-ring);
395
+ outline: 2px solid var(--_agent-logic-focus-ring);
327
396
  outline-offset: 1px;
328
397
  }
329
398
 
330
399
  .state-node__ambient--selected,
331
400
  .state-node__ambient--selected:hover {
332
- background: var(--agent-logic-selected-background);
333
- box-shadow: inset 2px 0 0 var(--agent-logic-selected);
401
+ background: var(--_agent-logic-selected-background);
402
+ box-shadow: inset 2px 0 0 var(--_agent-logic-selected);
334
403
  }
335
404
 
336
405
  .state-node__title {
@@ -344,7 +413,7 @@
344
413
  }
345
414
 
346
415
  .state-node__actions-heading {
347
- color: var(--agent-logic-text-subtle);
416
+ color: var(--_agent-logic-text-subtle);
348
417
  font-size: 12px;
349
418
  }
350
419
 
@@ -369,7 +438,7 @@
369
438
  }
370
439
 
371
440
  .state-node__more {
372
- color: var(--agent-logic-text-subtle);
441
+ color: var(--_agent-logic-text-subtle);
373
442
  font-size: 12px;
374
443
  }
375
444
 
@@ -394,8 +463,8 @@
394
463
  max-inline-size: 240px;
395
464
  padding: 2px 6px;
396
465
  border-radius: 3px;
397
- background: var(--agent-logic-tooltip-background);
398
- color: var(--agent-logic-tooltip-text);
466
+ background: var(--_agent-logic-tooltip-background);
467
+ color: var(--_agent-logic-tooltip-text);
399
468
  font-size: 12px;
400
469
  line-height: 16px;
401
470
  overflow-wrap: anywhere;
@@ -411,12 +480,12 @@
411
480
  }
412
481
 
413
482
  .transition-edge__word {
414
- color: var(--agent-logic-text-subtle);
483
+ color: var(--_agent-logic-text-subtle);
415
484
  font-style: italic;
416
485
  }
417
486
 
418
487
  .transition-edge__path {
419
- stroke: var(--agent-logic-border-strong);
488
+ stroke: var(--_agent-logic-border-strong);
420
489
  stroke-width: 1.5;
421
490
  marker-end: url('#arrowhead-ordinary');
422
491
  }
@@ -434,7 +503,7 @@
434
503
  }
435
504
 
436
505
  .arrowhead--arrowhead-ordinary {
437
- fill: var(--agent-logic-border-strong);
506
+ fill: var(--_agent-logic-border-strong);
438
507
  }
439
508
 
440
509
  .arrowhead--arrowhead-global {
@@ -442,7 +511,7 @@
442
511
  }
443
512
 
444
513
  .arrowhead--arrowhead-selected {
445
- fill: var(--agent-logic-selected);
514
+ fill: var(--_agent-logic-selected);
446
515
  }
447
516
 
448
517
  .transition-edge__path--inferred {
@@ -473,10 +542,124 @@
473
542
 
474
543
  .canvas-key__swatch--inferred {
475
544
  block-size: 12px;
476
- border: 2px dashed var(--agent-logic-text-subtle);
545
+ border: 2px dashed var(--_agent-logic-text-subtle);
477
546
  border-radius: 2px;
478
547
  }
479
548
 
480
549
  .canvas-key__word {
481
- color: var(--agent-logic-text-subtle);
550
+ color: var(--_agent-logic-text-subtle);
551
+ }
552
+
553
+ /* -- Prompt pane: the prompt, with marks on the exceptions to used text -- */
554
+
555
+ .prompt-pane {
556
+ display: grid;
557
+ grid-template-rows: auto minmax(0, 1fr);
558
+ block-size: 100%;
559
+ min-block-size: 0;
560
+ background: var(--agent-logic-surface);
561
+ color: var(--agent-logic-text);
562
+ }
563
+
564
+ .prompt-pane__header {
565
+ display: flex;
566
+ flex-wrap: wrap;
567
+ gap: 4px 12px;
568
+ align-items: baseline;
569
+ padding: 12px 20px 4px;
570
+ }
571
+
572
+ .prompt-pane__heading {
573
+ margin: 0;
574
+ font-size: 12px;
575
+ font-weight: 600;
576
+ line-height: 16px;
577
+ }
578
+
579
+ .prompt-pane__text {
580
+ overflow: auto;
581
+ padding: 4px 20px 40px;
582
+ font-family: var(--agent-logic-font-prose);
583
+ font-size: 16px;
584
+ line-height: 26px;
585
+ white-space: pre-wrap;
586
+ }
587
+
588
+ /* Used text is unmarked, so that the marks set apart the exceptions; pointing at a passage shows that it selects. */
589
+ .prompt-pane__passage--used,
590
+ .prompt-pane__passage--ambient {
591
+ cursor: pointer;
592
+ }
593
+
594
+ .prompt-pane__passage--used:hover {
595
+ background: var(--_agent-logic-hover-background);
596
+ text-decoration: underline solid 1px var(--_agent-logic-border-strong);
597
+ text-underline-offset: 0.25em;
598
+ }
599
+
600
+ .prompt-pane__passage--ambient:hover {
601
+ background: var(--_agent-logic-hover-background);
602
+ }
603
+
604
+ /* Each mark pairs its colour with a line style or italic, and its key sample shares the rule. */
605
+ .prompt-pane__passage--ambient,
606
+ .prompt-key__sample--ambient {
607
+ text-decoration: underline dotted 2px var(--agent-logic-global);
608
+ text-underline-offset: 0.2em;
609
+ }
610
+
611
+ .prompt-pane__passage--unused,
612
+ .prompt-key__sample--unused {
613
+ color: var(--_agent-logic-text-subtle);
614
+ text-decoration: underline dashed 1px var(--_agent-logic-border);
615
+ text-underline-offset: 0.25em;
616
+ }
617
+
618
+ .prompt-pane__passage--unconverted,
619
+ .prompt-key__sample--unconverted {
620
+ text-decoration: underline wavy 1.5px var(--_agent-logic-unconverted);
621
+ text-underline-offset: 0.3em;
622
+ }
623
+
624
+ .prompt-pane__passage--comment,
625
+ .prompt-key__sample--comment {
626
+ color: var(--_agent-logic-text-subtlest);
627
+ font-style: italic;
628
+ }
629
+
630
+ /* A selected or shown passage reads as the active text: a fill without a line of its own, over any hover. */
631
+ .prompt-pane__passage--highlighted,
632
+ .prompt-pane__passage--highlighted:hover {
633
+ background: var(--_agent-logic-passage-background);
634
+ color: var(--agent-logic-text);
635
+ }
636
+
637
+ /* An unconverted passage keeps its line, which tells the reader why the passage is shown. */
638
+ .prompt-pane__passage--highlighted:not(.prompt-pane__passage--unconverted),
639
+ .prompt-pane__passage--highlighted:not(.prompt-pane__passage--unconverted):hover {
640
+ text-decoration: none;
641
+ }
642
+
643
+ .prompt-pane__passage--highlighted.prompt-pane__passage--comment {
644
+ color: var(--_agent-logic-text-subtle);
645
+ }
646
+
647
+ .prompt-key {
648
+ display: flex;
649
+ flex-wrap: wrap;
650
+ gap: 4px 12px;
651
+ margin: 0;
652
+ margin-inline-start: auto;
653
+ padding: 0;
654
+ font-size: 12px;
655
+ line-height: 16px;
656
+ list-style: none;
657
+ }
658
+
659
+ .prompt-key__entry {
660
+ margin: 0;
661
+ }
662
+
663
+ .prompt-key__sample {
664
+ font-family: var(--agent-logic-font-prose);
482
665
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeassembly-agent-logic",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Model of an agent prompt's states and transitions, with React and server entries for the apps that present it",
5
5
  "keywords": [
6
6
  "agents",
@@ -64,8 +64,8 @@
64
64
  ".meta/changelog.json"
65
65
  ],
66
66
  "dependencies": {
67
- "@williamthorsen/toolbelt.errors": "0.11.3",
68
- "@xyflow/react": "13.0.1",
67
+ "@williamthorsen/toolbelt.errors": "0.11.4",
68
+ "@xyflow/react": "13.0.2",
69
69
  "elkjs": "0.12.1",
70
70
  "zod": "4.6.7"
71
71
  },
@@ -80,9 +80,9 @@
80
80
  "@types/react": "19.3.0",
81
81
  "@types/react-dom": "19.3.0",
82
82
  "@vitejs/plugin-react": "6.3.0",
83
- "@williamthorsen/nmr": "2.2.3",
84
- "@williamthorsen/toolbelt.acp": "0.3.2",
85
- "@williamthorsen/toolbelt.llm": "0.2.0",
83
+ "@williamthorsen/nmr": "2.3.0",
84
+ "@williamthorsen/toolbelt.acp": "0.3.3",
85
+ "@williamthorsen/toolbelt.llm": "0.2.1",
86
86
  "eslint": "10.15.0",
87
87
  "eslint-plugin-jest-dom": "5.10.2",
88
88
  "eslint-plugin-react": "7.37.5",
@@ -92,7 +92,7 @@
92
92
  "react": "19.3.1",
93
93
  "react-dom": "19.3.1",
94
94
  "vite": "8.3.8",
95
- "vitest": "5.1.0",
95
+ "vitest": "5.1.1",
96
96
  "xstate": "5.33.4"
97
97
  },
98
98
  "peerDependencies": {