rtistree 0.5.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/CONTRIBUTING.md +47 -0
  3. package/README.md +38 -22
  4. package/SECURITY.md +20 -0
  5. package/THIRD_PARTY_NOTICES.md +1 -1
  6. package/dist/art-direction.js +1 -1
  7. package/dist/cli.js +55 -32
  8. package/dist/cli.js.map +1 -1
  9. package/dist/commands.d.ts +12 -0
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/mcp.js +18 -2
  14. package/dist/mcp.js.map +1 -1
  15. package/dist/print-scene.d.ts +6 -0
  16. package/dist/program.js +3 -1
  17. package/dist/program.js.map +1 -1
  18. package/dist/project-config.js +2 -1
  19. package/dist/project-config.js.map +1 -1
  20. package/dist/render.js +21 -1
  21. package/dist/render.js.map +1 -1
  22. package/dist/schema.d.ts +46 -0
  23. package/dist/schema.js +107 -0
  24. package/dist/schema.js.map +1 -1
  25. package/dist/sprites.d.ts +31 -0
  26. package/dist/sprites.js +142 -0
  27. package/dist/sprites.js.map +1 -0
  28. package/dist/starter.d.ts +7 -0
  29. package/dist/starter.js +38 -0
  30. package/dist/starter.js.map +1 -0
  31. package/dist/studio-reference.js +1 -1
  32. package/dist/studio-reference.js.map +1 -1
  33. package/docs/agent-art-workflow.md +12 -2
  34. package/docs/agent-setup.md +12 -7
  35. package/docs/atelier.md +15 -4
  36. package/docs/cli-reference.md +89 -26
  37. package/docs/core-concepts.md +95 -0
  38. package/docs/decisions/004-print-production-and-projects.md +1 -1
  39. package/docs/decisions/005-programmable-digital-art.md +1 -1
  40. package/docs/engine-overview.md +121 -165
  41. package/docs/evolution.md +12 -9
  42. package/docs/getting-started.md +84 -53
  43. package/docs/next-milestone.md +9 -9
  44. package/docs/production.md +22 -16
  45. package/docs/releasing.md +99 -43
  46. package/docs/scene-format.md +45 -8
  47. package/docs/sprites.md +166 -0
  48. package/docs/studio.md +27 -12
  49. package/examples/hello/README.md +24 -8
  50. package/examples/hello/render.mjs +2 -1
  51. package/package.json +10 -5
  52. package/schemas/authoring.schema.json +359 -229
  53. package/schemas/command.schema.json +462 -332
  54. package/schemas/patch.schema.json +462 -332
  55. package/schemas/scene.schema.json +347 -217
  56. package/schemas/sprites.schema.json +41 -0
@@ -12,4 +12,4 @@ Workers provide cancellation and V8 heap limits; helper allocations and output d
12
12
 
13
13
  Dense region editing uses existing promoted raster regions, extended with explicit `replace` and `over` semantics. Exact-size PNGs carry dense data instead of JSON pixel arrays. Transactions check stale scene hashes and edit locality. Attached patches follow object transforms. The trial found a near-zero pressure gradient failure; a minimum subpixel dab radius fixes it. Region testing also corrected final print-region copy bounds to use the transformed frame.
14
14
 
15
- The artistic evaluation is kept separate from mechanical verification. The wheel trial reproduces its pixels without external image inputs, but still reads as a synthetic illustration. Successful software tests and deterministic replay are not evidence of human-level artistic skill or photographic realism. See [the studio guide](../studio.md) and [trial](../../examples/manual-wheel-trial/README.md).
15
+ The artistic evaluation is kept separate from mechanical verification. The wheel trial reproduces its pixels without external image inputs, but still reads as a synthetic illustration. Successful software tests and deterministic replay are not evidence of human-level artistic skill or photographic realism. See [the studio guide](../studio.md) and [trial](https://github.com/Coly010/rtistree/blob/main/examples/manual-wheel-trial/README.md).
@@ -1,174 +1,130 @@
1
- # Rtistree
2
-
3
- A deterministic raster graphics engine that agents can inspect, edit, verify, and replay. A persistent scene is the source of truth; PNG, JPEG, TIFF, PDF and SVG are outputs.
4
-
5
- Version 0.4 adds a programmable digital-art studio: seeded raster programs, pressure brushes, texture fields, warps, displacement, height-field lighting and dense regional edits. Programs bake to pinned assets with portable, replayable recipes; normal rendering never executes code. See the [studio guide](studio.md), [decision](decisions/005-programmable-digital-art.md) and [wheel trial made without image generation](../examples/manual-wheel-trial/README.md).
6
-
7
- TypeScript provides the scene schema, transactions, CLI, and MCP tool server. The next-stage implementation includes attached painting, adaptive patches, incremental layer rendering, visual critique and source rebasing. **Native CPU Skia** performs rendering through `@napi-rs/canvas`. No browser, WebGL, GPU, model API key, or external service is required.
8
-
9
- ![Poster rendered by Rtistree](previews/poster.png)
10
-
11
- ## Print production and new projects
12
-
13
- Version 0.3 adds physical documents, ICC-managed CMYK exports, embedded PDF fonts/vector geometry, project creation, source crops/perspective, mask algebra, tonal adjustments, clone/heal, path booleans and richer typography. See the [production guide](production.md), [recorded decisions](decisions/004-print-production-and-projects.md) and [masked generated-asset print trial](../examples/print-trial/README.md).
14
-
15
- ```sh
16
- graphics project new artwork --size A3 --orientation landscape --ppi 300 --bleed 3mm
17
- graphics render artwork --preset screen
18
- # Configure the printer/paper ICC profile in rtistree.yaml before CMYK export.
19
- graphics preflight artwork --preset print
20
- graphics export artwork --preset print --format pdf
21
- ```
22
-
23
- Print PDFs encode exact trim/bleed dimensions and are reopened for validation. PDF/X certification, spot colours and overprint are not claimed. The engine remains an 8-bit sRGB working renderer with explicit colour-managed output.
24
-
25
- ## Run it
26
-
27
- Requires Node.js 22 or newer. Dependencies and bundled fonts are pinned in `package-lock.json`.
28
-
29
- ```sh
30
- npm ci
31
- npm run build
32
- npm test
33
- npm run demo
34
- ```
35
-
36
- The demo renders a poster, measures an underlit region, applies a local correction, and checks replay, undo, redo, and a self-contained export. It writes before/after images and evidence into `examples/poster/renders/`, plus a landscape into `examples/landscape/renders/`. Every demo run uses a fresh working project and leaves the example's authoring files untouched.
37
-
38
- The recorded poster benchmark changes **4,704 pixels inside a 56 × 84 region, zero pixels outside**, improves rule verification from fail to pass, and reproduces identical PNG bytes after reopen, undo/redo, and export. This establishes mechanical correctness, not a general measure of artistic quality. See [recorded evidence](previews/benchmark.json).
39
-
40
- Use the executable after building:
41
-
42
- ```sh
43
- node dist/cli.js render examples/poster/scene.yaml -o /tmp/poster.png
44
- node dist/cli.js inspect examples/poster/scene.yaml
45
- node dist/cli.js inspect-region examples/poster/scene.yaml 755 610 56 84
46
- node dist/cli.js apply examples/poster/scene.yaml examples/poster/refine.json
47
- node dist/cli.js verify examples/poster/scene.yaml
48
- node dist/cli.js render examples/poster/scene.yaml -o /tmp/refined.png
49
- node dist/cli.js undo examples/poster/scene.yaml
50
- node dist/cli.js redo examples/poster/scene.yaml
51
- node dist/cli.js export examples/poster/scene.yaml -o /tmp/rtistree-export/scene.json
52
- ```
53
-
54
- `npm run graphics -- …` runs the same CLI from source. Installing the package exposes the `graphics` executable. `graphics --help` lists commands. JSON goes to stdout; errors go to stderr. Verification failures exit with code 2, other failures with code 1.
55
-
56
- ## Compose a project from files
57
-
58
- A manifest can reference as many independently authored fragments as needed:
59
-
60
- ```yaml
61
- version: 1
62
- canvas:
63
- width: 1024
64
- height: 1024
65
- background: '#102c31'
66
- include:
67
- - layers/background.yaml
68
- - layers/product.yaml
69
- - layers/typography.yaml
70
- ```
71
-
72
- Each fragment contains `layers`, optional `assets`, and optional nested `include` paths. Paths resolve relative to the declaring file and must stay inside the project. Layer and asset IDs share a project namespace. Included layers compose in declaration order, followed by local layers; sibling `z` values determine paint order. Groups preserve hierarchy.
73
-
74
- The [poster example](../examples/poster/scene.yaml) uses this format. [Scene format documentation](scene-format.md) describes coordinates, layout, operations, and validation.
1
+ # Engine overview
2
+
3
+ Rtistree is a local TypeScript/Node.js graphics engine with a CLI, SDK and stdio MCP
4
+ server. Native CPU Skia renders the scene; Sharp and PDFKit handle artwork exports.
5
+ The renderer needs no browser, GPU, model API key or external service. An agent host
6
+ supplies its own model, image inspection and visual judgment.
7
+
8
+ Start with [getting started](getting-started.md) for an installed npm package.
9
+ The commands in the development section below require a repository checkout.
10
+
11
+ ## Scene and authoring model
12
+
13
+ JSON/YAML source scenes can include fragments and parameterized components. The loader
14
+ expands them into one validated layer tree. Layers support groups, paths, text,
15
+ local image assets, procedural fills, layouts, transforms, masks and adjustments.
16
+ Raster operations, sparse palette tiles and promoted regions add focused pixel edits.
17
+ See [scene format](scene-format.md) and [editing workflows](evolution.md).
18
+
19
+ Pixel-art scenes can opt into explicit integer, palette and nearest-neighbour
20
+ guardrails. Sprite manifests describe frame rectangles, pivots, durations, tags and
21
+ animation ordering; the sprite exporter packs them into a deterministic atlas without
22
+ making Rtistree responsible for a game engine's runtime. See [pixel art, sprites and
23
+ spritesheets](sprites.md).
24
+
25
+ Layer IDs are unique throughout the tree. Assets, fonts and components each have their
26
+ own ID map; they do not share the layer-ID namespace. Relative include and asset paths
27
+ resolve from the declaring source file and must remain inside the root scene directory.
28
+
29
+ For painting, trusted JavaScript programs use Canvas, seeded brushes, fields and pixels.
30
+ Programs bake to ordinary image assets and pin source, parameters and inputs in recipes.
31
+ [Explicit pipelines](atelier.md) rebuild changed dependencies with caching. Rendering and
32
+ opening a scene do not execute those programs. The VM is not a security sandbox.
33
+
34
+ Physical document dimensions and print sampling resolution are separate from design pixels.
35
+ [Print production](production.md) covers PNG/JPEG/TIFF/PDF/SVG exports, profiles,
36
+ physical page boxes, preflight and soft proofs. The working renderer is 8-bit sRGB;
37
+ PDF/X certification, spot colours and overprint are not implemented.
38
+
39
+ ## Editing and persistence
40
+
41
+ `Project.open(path)` accepts a scene file, `rtistree.yaml` or a configured project directory.
42
+ `project.scene()` returns the current resolved state. `project.render()` returns PNG bytes,
43
+ pixels and evidence; `project.inspect()` and `project.inspectLayer(id)` return structure.
44
+ `project.apply({reason, expected_hash, commands})` validates and commits a typed transaction.
45
+ The SDK exports `Project`, `SkiaRenderer`, schemas, command helpers, render/verification
46
+ functions, `runProgram`, `buildPipeline`, `exportSpriteSheet`, `production` and the
47
+ art-direction guide.
48
+
49
+ Authoring files remain the baseline. Mutations append to
50
+ `history/<scene-filename>.operations.jsonl`; journal records include state snapshots,
51
+ commands, hashes, timestamps and measured locality. Failed transactions leave the working
52
+ scene unchanged. Scoped raster edits compare the final composite before and after and
53
+ reject pixels changed outside the allowed area. Structural edits have no general locality promise.
54
+
55
+ Undo and redo append records. After manual source changes, `rebase` merges disjoint edits
56
+ against the retained baseline and reports conflicts without committing. `compact` compresses
57
+ journal records while retaining undo/redo; replay still reads the full history. Remove a stale
58
+ lock only after confirming its recorded writer is no longer active.
59
+
60
+ Portable export creates a new baseline with referenced assets, custom fonts, recipes and
61
+ configured print profiles. It preserves the current artwork and inline pipeline graph,
62
+ but does not copy edit history, critiques or production-session reviews and candidates.
75
63
 
76
64
  ## Agent interface
77
65
 
78
- Art-direction guidance ships with the engine. MCP clients receive concise rules
79
- at connection time and can read the full versioned guide through `studioHelp` or
80
- the `rtistree://guides/art-direction` resource. CLI agents use `graphics art-guide`
81
- without opening a project. SDK hosts can include `rtistreeAgentInstructions` in
82
- their agent context and expose `artDirectionGuide`.
83
-
84
- The guide includes representative-sample workflows, connected figure construction,
85
- shared prop perspective, ground-contact animation checks, lessons from failed
86
- asset trials and a starter production plan using existing review gates. Technical,
87
- functional and visual acceptance are separate. This makes the knowledge available
88
- to new agents; it does not guarantee that every client presents it or every model
89
- follows it. See [the agent workflow](agent-art-workflow.md).
90
-
91
- Start the MCP server with a scene:
92
-
93
- ```sh
94
- node dist/cli.js serve /absolute/path/to/scene.yaml
95
- ```
96
-
97
- Configure an MCP client to launch `node`, with the absolute path to `dist/cli.js`, `serve`, and the absolute scene path as arguments. Transport is stdio; the server writes only protocol messages to stdout.
98
-
99
- Tools: `inspectScene`, `inspectLayer`, `inspectRegion`, `render`, `renderRegion`, `apply`, `undo`, `redo`, `verify`, `history`, `recordCritique`, `readCritique`, `rebase`, `compactHistory`, `exportArtwork`, `preflight`, `softProof`, `studioHelp`, `runProgram`, `replayProgram`, `readRasterRegion`, `writeRasterRegion`. Image tools return PNG image content so a vision-capable agent can inspect the result. `apply` advertises a typed command schema and requires an explanation. Supply the scene hash returned by inspection to reject stale edits.
100
-
101
- ```json
102
- {
103
- "reason": "Brighten the underlit detail without changing the surrounding composition",
104
- "expected_hash": "sha256:…",
105
- "commands": [
106
- {
107
- "type": "applyRasterOperation",
108
- "target": "cover",
109
- "operation": {
110
- "type": "brightness",
111
- "bounds": [755, 610, 56, 84],
112
- "amount": 0.06
113
- }
114
- }
115
- ]
116
- }
117
- ```
118
-
119
- The SDK also exposes `Project`, `SkiaRenderer`, `parseScene`, layout and verification functions, and `runIterations(project, editingAgent, options)`. The injected agent receives the scene, PNG, and verifier report and returns a patch or `null`. Iteration budgets, stale-state checks, stall thresholds, and cancellation bound the loop. An optional typed `critic` callback adds visual feedback; `requireCritique: true` requires a current critique before passing, and unresolved medium/high findings prevent success. Model choice and vision critique stay outside the renderer; there is no built-in LLM or diffusion service.
120
-
121
- ## Persistence and reproducibility
122
-
123
- Authoring fragments remain intact. Successful mutations append a transaction to `history/<scene-filename>.operations.jsonl`. Each record stores its commands, reason, full resolved state, previous-record hash, input/output scene hashes, asset hashes, and measured locality. Reads replay this journal over the original scene. Undo/redo append records rather than deleting history. Full state snapshots favor correctness and recovery over storage efficiency in this MVP.
124
-
125
- A failed batch leaves the scene unchanged. A project lock prevents concurrent writers; an expected scene hash handles stale agents. Incomplete or altered journal records are rejected. If a writer crashes, inspect the PID in the `.lock` file before removing the stale lock. After manual source edits, run `graphics rebase scene.yaml` to merge nonconflicting changes into the working state. Conflicts report exact paths without committing. `graphics compact scene.yaml` compresses history while retaining every undo/redo state. New histories retain their source baseline; legacy histories require restoring/exporting the original source before rebasing. Changed raster asset bytes are also rejected after history exists.
126
-
127
- Exports copy raster assets and custom fonts into content-addressed files and pin their hashes. Every PNG has a `.evidence.json` sidecar recording renderer/backend/runtime versions, scene hash, asset hashes, bundled font hashes, dimensions, quality, and PNG hash. Byte identity is tested on the same pinned runtime and platform. Cross-platform Skia byte identity is **not** promised.
128
-
129
- ## Implemented scope
130
-
131
- - JSON/YAML scenes and recursive multi-file composition; strict validation and JSON Schema generation.
132
- - Groups, semantic roles, shapes and SVG-style paths, text wrapping, local PNG/JPEG/WebP assets, gradients, seeded noise, transforms, row/column layouts, anchors, percentages, opacity, and nine blend modes.
133
- - Rectangle, ellipse, polygon and semantic-alpha masks; feathering, layer blur, and adjustment layers.
134
- - Scoped fill, paint/erase strokes, blur, brightness, contrast, saturation, hue shifts, noise, colour replacement, direct pixels, and palette tiles. Binary rasters remain external assets.
135
- - Exact region crops, structural/color inspection, append-only transactions, undo/redo, self-contained export, CLI, and MCP.
136
- - Text overflow, declared contrast, safe-area, overlap, copy/role and region-luma rules, issue heatmaps, measured edit locality, and bounded agent iterations.
137
-
138
- The remaining extensions are automatic quadtree subdivision, a general dirty-tile compositor, advanced SVG import, mesh warp/smudge, general segmentation, provider-specific model integrations, learned asset generation, and animation. Draft still downsamples after rendering. Safe pointwise region scenes use smaller viewport surfaces; antialias-sensitive scenes fall back to a full composite and exact crop.
139
-
140
- ## Next-stage examples and agent trials
141
-
142
- See [the new API and workflows](evolution.md) and [ADR 003](decisions/003-editing-refinement-and-agent-validation.md). New features include mutable effects/operations, object-relative paint, promoted patches at 1–4× resolution, layer caching, rendered contrast/visibility rules, hash-bound visual critiques, component instances, custom fonts, source rebasing and compressed history.
143
-
144
- Three interactive trials are recorded in [agent-trials/results.json](../examples/agent-trials/results.json), with before/after images, briefs, complete audit snapshots and portable final scenes. Corrections were selected after inspecting the images. The visual scores are same-agent judgments; these are not independent quality evaluations, and token usage was unavailable. All three final scenes passed their configured checks and reproduced after export. The pear trial preserved every checked nonfruit pixel.
145
-
146
- ```sh
147
- node dist/cli.js render examples/agent-trials/reading-club/final/scene.json -o /tmp/reading-club.png
148
- node dist/cli.js render examples/agent-trials/pear/final/scene.json -o /tmp/pear.png
149
- npm run performance
150
- ```
151
-
152
- The performance probe records cache counters and local timings in `docs/previews/performance.json`. Its 16-layer edit reuses 15 surfaces and rasterizes one, while matching an uncached render exactly.
153
-
154
- See [architecture decisions](decisions/001-runtime-and-renderer.md), [multi-file persistence decision](decisions/002-composable-scenes-and-history.md), and the original [architecture proposal](../agentic-raster-graphics-architecture.md).
155
-
156
- ## Development
66
+ The [agent setup guide](agent-setup.md) explains CLI, MCP and SDK integration.
67
+ MCP tools are:
68
+
69
+ - Inspection and images: `inspectScene`, `inspectLayer`, `inspectRegion`, `render`, `renderRegion`.
70
+ - Editing and history: `apply`, `undo`, `redo`, `history`, `rebase`, `compactHistory`.
71
+ - Verification and review: `verify`, `recordCritique`, `readCritique`.
72
+ - Painting: `studioHelp`, `runProgram`, `replayProgram`, `readRasterRegion`, `writeRasterRegion`.
73
+ - Staged work: `buildPipeline`, `production`.
74
+ - Artwork export: `exportArtwork`, `exportSprites`, `preflight`, `softProof`.
75
+
76
+ MCP rendering/crop tools return PNG image content. Production capture and comparison return
77
+ artifact paths in JSON; the host needs a way to open those images. The MCP server operates
78
+ on the project passed to `serve`; project creation, SVG import, portable scene export and
79
+ interactive benchmarks are available through the CLI/SDK, not separate MCP tools.
80
+
81
+ The exported `runIterations(project, editingAgent, options)` supports bounded edit loops.
82
+ The injected agent receives the scene, PNG and verifier report and returns a patch or `null`.
83
+ An optional `critic` callback supplies visual feedback. `requireCritique: true` requires a
84
+ current critique before passing, and unresolved medium/high findings prevent success.
85
+ There is no built-in model client or automatic visual critic.
86
+
87
+ ## Evidence and limits
88
+
89
+ The [art-direction guide](agent-art-workflow.md) separates technical correctness, functional
90
+ behaviour and observed visual quality. Production gates enforce declared criteria and hashes;
91
+ they cannot authenticate reviewers, judge taste or prove that images were inspected.
92
+
93
+ PNG writes through the CLI/artifact helper include an evidence sidecar. SDK `render()` returns
94
+ evidence in memory; use `writeRender()` to write both files. Same-runtime/platform replay,
95
+ undo and portable export are tested. Cross-platform or cross-version byte identity is not promised.
96
+
97
+ A bounded layer cache reuses unchanged surfaces. Simple pointwise region scenes use a smaller
98
+ viewport; antialias-sensitive cases use a full render and exact crop. `cache: false` and
99
+ `regionMode: 'full'` request reference paths. Draft downsamples after rendering. A general
100
+ dirty-tile compositor, automatic quadtree refinement, a native animation timeline, mesh warp,
101
+ smudge and general segmentation remain unimplemented. Sprite manifests and atlas export
102
+ package authored frames but do not provide inverse kinematics, retargeting or automatic
103
+ visual approval. Procedural programs can still author individual animation frames, as the
104
+ [asset trial](https://github.com/Coly010/rtistree/tree/main/examples/warden-asset-trial) demonstrates.
105
+
106
+ The [poster benchmark](previews/benchmark.json) records 4,704 changed pixels inside a
107
+ 56 × 84 region and zero outside, with successful replay/undo/export checks. It is recorded
108
+ mechanical evidence, not a visual-quality benchmark. The [performance probe](previews/performance.json)
109
+ records local timings and cache reuse; it is not a portable speed guarantee.
110
+
111
+ ## Repository development
157
112
 
158
113
  ```sh
114
+ git clone https://github.com/Coly010/rtistree.git
115
+ cd rtistree
116
+ npm ci
159
117
  npm run check
160
- npm run format:check
161
- npm run schema
118
+ npm run demo
119
+ npm run docs:check
120
+ npm run package:check
162
121
  ```
163
122
 
164
- Subsystems are separate modules in `src/`: schema, loader, layout, assets, paint, renderer, commands, project transactions, verification, workflow, CLI and MCP. The `Renderer` interface makes backend replacement independent of scene authoring or agent logic. The original proposal's package boundaries are module boundaries until independent packaging has a concrete benefit.
165
-
166
- Bundled fonts are Inter and DM Serif Display from Fontsource, under their bundled SIL Open Font Licenses. They cover Latin text; custom project fonts can supply broader script coverage. Arbitrary system-font fallback remains disabled. Example artwork and book-cover raster are built from this engine's own primitives; regenerate the cover with `node --import tsx scripts/create-fixtures.ts`.
167
-
168
- ## Staged 2D art production
169
-
170
- Dependency-aware painting pipelines, immutable candidate comparisons, hash-bound visual reviews and gated production stages are available through the CLI, SDK and MCP. Seeded oil/filbert/scumble/ink brushes complement native Canvas paths and raw pixels. See [the atelier workflow](atelier.md) and the hand-authored dragon trial in `examples/dragon-oil-trial`. No image-generation or 3D dependency is used.
171
-
172
- Read [Art direction for agents](agent-art-workflow.md) before making art. The foundation-first protocol, named 2D construction guides, explicit blocking issues and parent-linked revisions are also discoverable through `graphics studio-help`. The [grayscale dragon study](../examples/dragon-foundation/README.md) demonstrates the process and records its unresolved artistic failures.
123
+ `npm run rtistree -- ...` runs the CLI from source. `npm run schema` regenerates the
124
+ schemas. `npm run performance` reruns the cache/timing probe. The demo uses a temporary
125
+ working project and writes preview images/evidence without editing the example source scenes.
173
126
 
174
- The [dragon head lighting experiment](../examples/dragon-head-study/README.md) uses the existing 2D tools for an original head, reflected green fire and two local revisions. It remains below the supplied artistic quality reference; code-only reproduction is verified separately from that verdict.
127
+ The [architecture decisions](decisions/001-runtime-and-renderer.md) retain historical
128
+ context. The [original proposal](https://github.com/Coly010/rtistree/blob/main/agentic-raster-graphics-architecture.md)
129
+ is not an API reference. See [contributing](https://github.com/Coly010/rtistree/blob/main/CONTRIBUTING.md)
130
+ for development setup and [releasing](releasing.md) for maintainer release instructions.
package/docs/evolution.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Editing and agent workflows
2
2
 
3
- ## Complete edits
3
+ ## Core edit commands
4
4
 
5
5
  `apply` is still a transaction containing `reason`, optional `expected_hash` and `commands`. The generated [command schema](../schemas/command.schema.json) is authoritative.
6
+ The table covers core edits; [print production and editing](production.md) lists the
7
+ additional document, path, crop, text and adjustment commands.
6
8
 
7
9
  | Area | Commands |
8
10
  | ---------------- | -------------------------------------------------------------------------------------------------------------------------- |
@@ -110,7 +112,7 @@ For visual critique, render and inspect the PNG, then submit:
110
112
  }
111
113
  ```
112
114
 
113
- `graphics critique scene.yaml critique.json` or the MCP `recordCritique` tool stores it. Stale scene/PNG hashes are rejected. `readCritique` returns only the current critique. A callback of type `VisualCritic` can perform this review in `runIterations`; use `requireCritique: true` to require it for success. Visual and rule scores inform stall detection; unresolved medium/high visual findings prevent a pass. The adapter is provider-neutral and requires the caller to supply the actual vision-capable reviewer. No synthetic review is substituted when one is absent.
115
+ `rtistree critique scene.yaml critique.json` or the MCP `recordCritique` tool stores it. Stale scene/PNG hashes are rejected. `readCritique` returns only the current critique. A callback of type `VisualCritic` can perform this review in `runIterations`; use `requireCritique: true` to require it for success. Visual and rule scores inform stall detection; unresolved medium/high visual findings prevent a pass. The adapter is provider-neutral and requires the caller to supply the actual vision-capable reviewer. No synthetic review is substituted when one is absent.
114
116
 
115
117
  ## Components and fonts
116
118
 
@@ -142,7 +144,7 @@ Components can live in included fragments. Instance children become `new-badge-p
142
144
  fonts:
143
145
  brand-display:
144
146
  source: fonts/BrandDisplay.otf
145
- hash: sha256:...
147
+ # Optional hash: sha256: followed by the font file’s 64 hex digest characters
146
148
  ```
147
149
 
148
150
  Choose `style.font: brand-display`. Fonts are registered under content-based aliases; changing a font file without updating its expected hash fails. History checks custom-font provenance, and exports copy font files. A custom file supplies one face; register a separate ID for another weight. Bundled names are reserved.
@@ -154,13 +156,13 @@ Layout supports `aspect_ratio`, positive `grow` weights and `layout.justify: sta
154
156
  After changing a source fragment or a component definition:
155
157
 
156
158
  ```sh
157
- graphics rebase scene.yaml
159
+ npx rtistree rebase scene.yaml
158
160
  ```
159
161
 
160
162
  This merges disjoint source and agent changes using the retained authoring baseline. Conflicts report paths such as `/layers/headline/style/colour` and leave history untouched. Resolve the conflicting source fields and retry, or export the working scene into a new project. Rebase is audited and undoable. Histories created before baseline retention require their original source to be restored and exported first.
161
163
 
162
164
  ```sh
163
- graphics compact scene.yaml
165
+ npx rtistree compact scene.yaml
164
166
  ```
165
167
 
166
168
  Compaction compresses full records into an immutable gzip archive with a content-hashed pointer, then starts an empty active log. Every undo/redo state remains accessible. It reduces storage; replay still reads all records. Missing/tampered archives fail closed. Do not delete archives referenced by the pointer.
@@ -170,10 +172,11 @@ Compaction compresses full records into an immutable gzip archive with a content
170
172
  `BenchmarkSession` requires visual review before each checkpoint. Briefs describe the objective and optional allowed region; the driver does not contain a solution or choose an edit.
171
173
 
172
174
  ```sh
173
- graphics benchmark scene.yaml brief.json before
175
+ # Render and record a current critique before the first checkpoint.
176
+ npx rtistree benchmark scene.yaml brief.json before
174
177
  # Inspect, critique, apply edits, then inspect and critique again.
175
- graphics benchmark scene.yaml brief.json after
176
- graphics benchmark scene.yaml brief.json finish
178
+ npx rtistree benchmark scene.yaml brief.json after
179
+ npx rtistree benchmark scene.yaml brief.json finish
177
180
  ```
178
181
 
179
- The report records actual edit/command counts, rule results, visual scores, locality, uncached equality and self-contained export equality. Token counts are nullable rather than guessed. The [recorded trials](../examples/agent-trials/results.json) were performed interactively by the assistant in this task, with self-authored briefs and same-agent visual critique. They establish a usable end-to-end workflow; broader held-out evaluation and independent human review remain future evidence to collect.
182
+ The report records actual edit/command counts, rule results, visual scores, locality, uncached equality and self-contained export equality. Token counts are nullable rather than guessed. The [recorded trials](https://github.com/Coly010/rtistree/blob/main/examples/agent-trials/results.json) were performed interactively by the assistant in this task, with self-authored briefs and same-agent visual critique. They establish a usable end-to-end workflow; broader held-out evaluation and independent human review remain future evidence to collect.
@@ -1,57 +1,52 @@
1
1
  # Make your first image
2
2
 
3
- Rtistree runs locally on Node.js 22 or newer. It needs no GPU or model API key.
4
- Start in an empty directory:
3
+ New to Rtistree? Read [Core concepts: an agent is the interface](core-concepts.md)
4
+ for how you, your agent and the engine work together.
5
+
6
+ Create a small artwork, render it, change one part, and undo that change.
7
+ You need **Node.js 22 or newer** and npm. No GPU or model API key is required.
8
+
9
+ ## Create your project
5
10
 
6
11
  ```sh
7
- mkdir my-art
12
+ npx rtistree@latest init my-art
8
13
  cd my-art
9
- npm init -y
10
- npm install https://github.com/Coly010/rtistree/releases/download/v0.5.0/rtistree-0.5.0.tgz
14
+ npm install
15
+ npm run render
11
16
  ```
12
17
 
13
- This installs the checked release tarball from GitHub. npm registry publication is pending;
14
- the installed package and `graphics` executable are the same.
18
+ If npm asks to install Rtistree for the first command, accept. `init` creates a new
19
+ `my-art` directory with a starter scene and a package.json that pins the Rtistree version.
20
+ It refuses existing paths, so choose a different name if `my-art` already exists.
15
21
 
16
- ## Render a scene
22
+ Open **hello.png** in the new directory. You should see a green disc and the text
23
+ “Hello, Rtistree.” on a dark background. Rendering also writes `hello.png.evidence.json`.
17
24
 
18
- Save this as `scene.json`:
25
+ The commands below run from inside `my-art` and use the locally installed package.
26
+ The executable is `rtistree`; older installations used `graphics`, which remains an alias.
19
27
 
20
- ```json
21
- {
22
- "version": 1,
23
- "canvas": { "width": 640, "height": 400, "background": "#14251f" },
24
- "layers": [
25
- {
26
- "id": "disc",
27
- "type": "vector",
28
- "bounds": [360, 60, 200, 200],
29
- "shape": { "type": "ellipse", "fill": "#95b85c" }
30
- },
31
- {
32
- "id": "title",
33
- "type": "text",
34
- "bounds": [48, 275, 544, 80],
35
- "content": "Hello, Rtistree.",
36
- "style": { "font": "inter", "size": 44, "weight": "bold", "colour": "#edf3e8" }
37
- }
38
- ]
39
- }
40
- ```
28
+ ## Understand the starter
29
+
30
+ | File | Purpose |
31
+ | -------------- | ------------------------------------------------------- |
32
+ | `scene.json` | Canvas settings and disc/title layers with editable IDs |
33
+ | `refine.json` | A sample patch that brightens only the disc |
34
+ | `render.mjs` | The same rendering workflow through the JavaScript SDK |
35
+ | `package.json` | Pinned dependency and the `npm run render` script |
41
36
 
42
- Or copy the same scene from `node_modules/rtistree/examples/hello/scene.json`.
37
+ `npm run render` runs `rtistree render scene.json -o hello.png`.
38
+ To inspect the scene's layers and bounds:
43
39
 
44
40
  ```sh
45
- npx graphics render scene.json -o hello.png
46
- npx graphics inspect scene.json
41
+ npx rtistree inspect scene.json
47
42
  ```
48
43
 
49
- Open `hello.png`: a green disc and a title on a dark background. An adjacent evidence JSON
50
- records the scene hash, dimensions, fonts and renderer/runtime information.
44
+ The starter is deliberately small so you can see what each edit does. Once comfortable,
45
+ use the [scene format](scene-format.md) to add shapes, text, images and masks.
51
46
 
52
- ## Change one part
47
+ ## Make a focused edit
53
48
 
54
- Save this as `refine.json`:
49
+ The supplied `refine.json` applies a brightness operation to the disc:
55
50
 
56
51
  ```json
57
52
  {
@@ -66,29 +61,60 @@ Save this as `refine.json`:
66
61
  }
67
62
  ```
68
63
 
64
+ Apply it and save a second image:
65
+
69
66
  ```sh
70
- npx graphics apply scene.json refine.json
71
- npx graphics render scene.json -o brighter.png
72
- npx graphics undo scene.json
73
- npx graphics render scene.json -o restored.png
67
+ npx rtistree apply scene.json refine.json
68
+ npx rtistree render scene.json -o brighter.png
74
69
  ```
75
70
 
76
- The disc becomes brighter. Undo restores the first image. Changes are journaled beside
77
- the scene; the original authoring file remains intact. On the same runtime and platform,
78
- `restored.png` should have the same bytes as `hello.png`.
71
+ Compare **hello.png** and **brighter.png**. Only the disc becomes brighter; the title and
72
+ background stay the same. The reason and edit are recorded in `history/`. The authoring
73
+ JSON remains intact; the rendered state includes the journaled edits.
79
74
 
80
- ## Export a portable project
75
+ ## Undo and export
81
76
 
82
77
  ```sh
83
- npx graphics export scene.json -o portable/scene.json
84
- npx graphics render portable/scene.json -o portable.png
78
+ npx rtistree undo scene.json
79
+ npx rtistree render scene.json -o restored.png
85
80
  ```
86
81
 
87
- The export includes referenced assets and fonts. Keep the exported directory together.
82
+ **restored.png** should match **hello.png** byte for byte on the same runtime and platform.
83
+ Use `npx rtistree redo scene.json` if you want to restore the edit again.
84
+
85
+ Export the current state as a portable project:
86
+
87
+ ```sh
88
+ npx rtistree export scene.json -o portable/scene.json
89
+ npx rtistree render portable/scene.json -o portable.png
90
+ ```
91
+
92
+ The export includes the current resolved scene, referenced assets, fonts and any baked
93
+ program recipes. It starts a new baseline: edit history, critiques and production-session
94
+ reviews are not copied. Keep the exported directory together.
95
+
96
+ ## Use an agent
97
+
98
+ Read the built-in art-direction guidance, then follow [agent setup](agent-setup.md)
99
+ to connect an MCP client or your own agent host:
100
+
101
+ ```sh
102
+ npx rtistree art-guide
103
+ ```
104
+
105
+ A useful first task is: “Inspect this scene, render it, and change the disc while preserving
106
+ the title and background.” For art creation, ask the agent to inspect silhouettes, values
107
+ and intended display size. Technical verification does not establish artistic quality.
88
108
 
89
109
  ## Use the SDK
90
110
 
91
- Save this as `render.mjs` beside `scene.json`:
111
+ The starter includes `render.mjs`. Run it with:
112
+
113
+ ```sh
114
+ npm run render:sdk
115
+ ```
116
+
117
+ Its core is:
92
118
 
93
119
  ```js
94
120
  import { Project } from 'rtistree';
@@ -99,9 +125,14 @@ const result = await project.render();
99
125
  await writeFile('sdk-output.png', result.png);
100
126
  ```
101
127
 
102
- Run `node render.mjs`. The SDK and CLI use the same engine.
128
+ The SDK and CLI use the same engine. For an existing Node project, install with
129
+ `npm install rtistree` and import from `rtistree` directly.
103
130
 
104
- ## Next steps
131
+ ## Where next?
105
132
 
106
- Read [agent setup](agent-setup.md) to connect an MCP client, or the [scene format](scene-format.md)
107
- to add layers, text, assets and masks. For generated painting programs, use the [studio guide](studio.md).
133
+ - [CLI reference](cli-reference.md) inspect, edit, render and export commands.
134
+ - [Scene format](scene-format.md) — layers, coordinates, assets and effects.
135
+ - [Pixel art, sprites and spritesheets](sprites.md) — indexed tiles, frame metadata,
136
+ deterministic atlases and animation review.
137
+ - [Studio](studio.md) — trusted JavaScript painting programs and replayable recipes.
138
+ - [Staged production](atelier.md) — compare candidates and record visual review.
@@ -1,25 +1,25 @@
1
- # Proposed next milestone: print documents and coherent projects
1
+ # Historical proposal: print documents and coherent projects
2
2
 
3
3
  Status: delivered as the v0.3 milestone. This document retains the original proposal; see [the production guide](production.md) and [ADR 004](decisions/004-print-production-and-projects.md) for the implemented scope, selected backends and explicit limits.
4
4
 
5
5
  ## Recommended order
6
6
 
7
- 1. Introduce a project manifest, physical document model, and `graphics project new` together.
7
+ 1. Introduce a project manifest, physical document model, and `rtistree project new` together.
8
8
  2. Add JPEG, TIFF and physically sized PDF exports, with colour management and output validation.
9
9
  3. Preserve text and vector geometry in PDF; add practical compositing, selection and path tools.
10
10
  4. Run a more demanding generated-asset integration trial, including subject extraction or seamless extension, and print the result through the new export pipeline.
11
11
 
12
- The first generated-asset fitting trial is already recorded in [the example](../examples/generated-asset-trial/README.md). It uses one built-in image-generation call followed by deterministic Rtistree composition. It establishes asset ingestion, aspect-preserving placement, editable surrounding content and exact preservation of the placed photograph. It does not establish seamless photographic outpainting, segmentation or print readiness.
12
+ The first generated-asset fitting trial is already recorded in [the example](https://github.com/Coly010/rtistree/blob/main/examples/generated-asset-trial/README.md). It uses one built-in image-generation call followed by deterministic Rtistree composition. It establishes asset ingestion, aspect-preserving placement, editable surrounding content and exact preservation of the placed photograph. It does not establish seamless photographic outpainting, segmentation or print readiness.
13
13
 
14
14
  ## Project creation
15
15
 
16
- Proposed syntax (not current commands):
16
+ Syntax proposed at the time (now implemented; use the current production guide):
17
17
 
18
18
  ```sh
19
- graphics project new alpine --size A3 --orientation landscape --ppi 300 --bleed 3mm --output-dir output
20
- graphics render alpine --preset screen
21
- graphics export alpine --preset print
22
- graphics preflight alpine --preset print
19
+ rtistree project new alpine --size A3 --orientation landscape --ppi 300 --bleed 3mm --output-dir output
20
+ rtistree render alpine --preset screen
21
+ rtistree export alpine --preset print
22
+ rtistree preflight alpine --preset print
23
23
  ```
24
24
 
25
25
  Create a project manifest describing the scene entry point, output directory and export presets; a scene referencing layer fragments; `assets/`, `fonts/`, `profiles/`, `layers/`, `history/`, and the designated output directory. Include a useful starter scene, schema references, a short project README, and ignore rules for generated artifacts. Relative paths resolve consistently from the project root. Creating a project must not overwrite an existing one. Existing scene-file commands remain usable.
@@ -32,7 +32,7 @@ Keep physical trim dimensions authoritative, independently of pixel dimensions.
32
32
 
33
33
  Record the PDF MediaBox, TrimBox and BleedBox correctly; actually render artwork into the bleed. Offer crop marks as an explicit option outside trim. Report effective ppi of placed source images and whether the requested output resamples them. The file can encode exact size, but downstream printer/viewer scaling remains outside the engine's control.
34
34
 
35
- The current schema caps canvas dimensions at 4,096 pixels and the renderer holds full-canvas layer surfaces. A3 at 300 ppi is about 4,961 by 3,508 pixels before bleed. Print therefore needs a bounded-memory strategy and expanded dimension support, not merely a new encoder or a higher schema limit. Tiled rendering must retain context for filters and match reference crops.
35
+ At the time of this proposal, the schema capped canvas dimensions at 4,096 pixels and the renderer held full-canvas layer surfaces. A3 at 300 ppi is about 4,961 by 3,508 pixels before bleed. Print therefore needs a bounded-memory strategy and expanded dimension support, not merely a new encoder or a higher schema limit. Tiled rendering must retain context for filters and match reference crops.
36
36
 
37
37
  ## Colour and formats
38
38