@taylorwong/ichartjs 2.0.5 → 2.0.7

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 (46) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +11 -4
  3. package/docs/agent/README.md +3 -1
  4. package/docs/agent/coding-agent-integration.md +6 -2
  5. package/docs/agent/development/iteration-11.md +44 -0
  6. package/docs/agent/development/iteration-12.md +101 -0
  7. package/docs/agent/development/roadmap.md +29 -3
  8. package/docs/agent/development-guide.md +1 -1
  9. package/docs/agent/diagram-scenario.md +39 -11
  10. package/docs/agent/editing-contract.md +5 -0
  11. package/docs/agent/frontend-integration.md +1 -1
  12. package/docs/agent/runtime-contract.md +11 -1
  13. package/docs/agent/theme-guide.md +63 -0
  14. package/docs/agent/usage-scenarios.md +40 -1
  15. package/docs/agent/zh-CN/README.md +1 -1
  16. package/docs/agent/zh-CN/coding-agent-integration.md +6 -2
  17. package/docs/agent/zh-CN/diagram-scenario.md +32 -3
  18. package/docs/agent/zh-CN/editing-contract.md +2 -0
  19. package/docs/agent/zh-CN/frontend-integration.md +1 -1
  20. package/docs/agent/zh-CN/iteration-12.md +98 -0
  21. package/docs/agent/zh-CN/runtime-contract.md +3 -1
  22. package/docs/agent/zh-CN/theme-guide.md +63 -0
  23. package/docs/agent/zh-CN/usage-scenarios.md +40 -1
  24. package/docs/manifests/capabilities.json +37 -2
  25. package/docs/manifests/commands.json +10 -9
  26. package/docs/manifests/schemas.json +5 -2
  27. package/package.json +1 -1
  28. package/skills/ichartjs/SKILL.md +11 -2
  29. package/src/capabilities.mjs +65 -8
  30. package/src/charts.mjs +127 -44
  31. package/src/command.mjs +4 -3
  32. package/src/diagram-interaction.mjs +55 -11
  33. package/src/diagram.mjs +149 -36
  34. package/src/edit-controller.mjs +6 -3
  35. package/src/edit.mjs +17 -7
  36. package/src/index.mjs +68 -17
  37. package/src/layout.mjs +39 -0
  38. package/src/preferences-ui.mjs +135 -0
  39. package/src/preferences.mjs +194 -0
  40. package/src/project.mjs +64 -24
  41. package/src/renderer.mjs +2 -2
  42. package/src/scene.mjs +32 -1
  43. package/src/schema.mjs +7 -2
  44. package/src/spec.mjs +10 -4
  45. package/src/theme.mjs +1 -1
  46. package/types/index.d.ts +39 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.7 - 2026-09-20
4
+
5
+ - Added Architecture and Mindmap chart types with shared diagram contracts, layers, boundaries, parent-child validation, deterministic tree/radial layouts, and Agent-readable schemas and capabilities.
6
+ - Added renderer-parity edge selection and editing, persistent manual waypoints, obstacle-aware routing, and true cubic-Bezier Mindmap edges while keeping navigation and editing disabled by default.
7
+ - Improved chart layout reflow, diagram connection routing, label spacing, legend and branding controls, and compact chart preference behavior.
8
+ - Fixed chart settings placement so scrolling preserves the selected side without viewport snapping and closes the menu directly after its anchor leaves the viewport.
9
+
10
+ ## 2.0.6 - 2026-09-18
11
+
12
+ - Added compact per-chart visual settings with explicit default font sizing, capability-aware visibility toggles, bilingual labels, and theme-aware hamburger icon contrast.
13
+ - Added shared page-level preferences with localStorage persistence and Agent JSON patch support through the Preferences API and Playground settings page.
14
+ - Synchronized Runtime, Playground, package metadata, release-pinned installation guidance, and roadmap status for the `v2.0.6` release.
15
+
3
16
  ## 2.0.5 - 2026-09-18
4
17
 
5
18
  - Hardened JSON, SVG, PNG, and JPEG export contracts with deterministic type errors, JSON output representations, and an explicit optional Node `canvas` path through `exportAsync()`.
package/README.md CHANGED
@@ -31,6 +31,7 @@ getCapabilities
31
31
  | Coding Agent integration | [`docs/agent/coding-agent-integration.md`](docs/agent/coding-agent-integration.md) |
32
32
  | Frontend integration | [`docs/agent/frontend-integration.md`](docs/agent/frontend-integration.md) |
33
33
  | Visual style and themes | [`docs/agent/theme-guide.md`](docs/agent/theme-guide.md) |
34
+ | Chart and page preferences | [`docs/agent/theme-guide.md`](docs/agent/theme-guide.md#chart-and-page-preferences) |
34
35
  | Official Agent Skill for Codex and WorkBuddy | [`skills/ichartjs/SKILL.md`](skills/ichartjs/SKILL.md) |
35
36
 
36
37
  ### Install
@@ -39,7 +40,7 @@ getCapabilities
39
40
  npm install @taylorwong/ichartjs@^2
40
41
  ```
41
42
 
42
- As a fallback for environments without npm access, install directly from GitHub: `npm install github:wanghetommy/ichartjs#v2.0.5`.
43
+ As a fallback for environments without npm access, install directly from GitHub: `npm install github:wanghetommy/ichartjs#v2.0.7`.
43
44
 
44
45
  ### Optional Agent Skill
45
46
 
@@ -49,13 +50,19 @@ The runtime API remains the source of truth; the Skill only teaches and orchestr
49
50
  https://github.com/wanghetommy/ichartjs/tree/master/skills/ichartjs
50
51
  ```
51
52
 
52
- From a repository checkout, install it into Codex with:
53
+ Install the latest Skill with the standard Agent Skills CLI:
53
54
 
54
55
  ```bash
55
- cp -R skills/ichartjs "${CODEX_HOME:-$HOME/.codex}/skills/"
56
+ npx skills add wanghetommy/ichartjs --skill ichartjs
56
57
  ```
57
58
 
58
- WorkBuddy users can import or register the same `skills/ichartjs` folder through the host's Skill interface. Package consumers can copy it from `node_modules/@taylorwong/ichartjs/skills/ichartjs` into their Agent host's Skill directory. After installation, invoke it as `$ichartjs` when the host supports named Skill invocation, or select the `ichartjs` Skill in the host UI.
59
+ For a non-interactive global Codex installation:
60
+
61
+ ```bash
62
+ npx skills add wanghetommy/ichartjs --skill ichartjs --agent codex --global --yes
63
+ ```
64
+
65
+ For a release-pinned installation, use `npx skills add https://github.com/wanghetommy/ichartjs/tree/v2.0.7/skills/ichartjs --agent codex --global --yes`. WorkBuddy users can import the same tagged `skills/ichartjs` URL through the host's Skill interface; do not assume a `--agent workbuddy` adapter unless the installed CLI declares it. Package consumers can still copy `node_modules/@taylorwong/ichartjs/skills/ichartjs` as a manual fallback. After installation, invoke `$ichartjs` when named Skill invocation is supported, or select `ichartjs` in the host UI.
59
66
 
60
67
  ### Agent workflow
61
68
 
@@ -17,7 +17,7 @@ This is the user-facing Agent entry point for iChart.js 2.0. Read this file firs
17
17
  - [Visual Style and Themes](theme-guide.md): automatic matching, presets, palettes, switching, and contrast checks.
18
18
  - [Data Charting](charting-scenario.md): generic data analysis charts.
19
19
  - [Project Management](project-scenario.md): Gantt, Timeline, Milestone, and Burndown.
20
- - [Interactive Diagrams](diagram-scenario.md): Flow, Swimlane, Groups, Ports, and editing.
20
+ - [Interactive Diagrams](diagram-scenario.md): Flow, Swimlane, Architecture, Mindmap, Groups, Ports, and editing.
21
21
  - [Runtime Contract](runtime-contract.md): shared Spec, renderer, interaction, and export rules.
22
22
  - [Editing Contract](editing-contract.md): schemas, commands, preview, commit, and undo/redo.
23
23
  - Machine-readable capability manifests are in `docs/manifests/` and should be loaded on demand.
@@ -56,6 +56,8 @@ For a visual overview of all supported chart types, open `playground/project-gal
56
56
  - Prefer `canvas` when rendering many marks or targeting lower-power devices.
57
57
  - Use `gantt`, `timeline`, `milestone`, or `burndown` for project delivery views.
58
58
  - Use `flow` or `swimlane` for process, ownership, and responsibility views.
59
+ - Use `architecture` for business, data, and technical system structures with declared layers and boundaries.
60
+ - Use `mindmap` for hierarchical ideas, with stable `parentId` references and tree or radial layout.
59
61
  - Do not generate `map` or `3d` Specs unless `getCapabilities()` declares them.
60
62
 
61
63
  ## Error handling
@@ -27,12 +27,16 @@ npm install
27
27
  npm run playground
28
28
  ```
29
29
 
30
- The same official Skill can be imported by Codex, WorkBuddy, and other Agent Skills-compatible hosts from `skills/ichartjs`. Install it into Codex from a repository checkout with:
30
+ Install the official Skill with the standard Agent Skills CLI:
31
31
 
32
32
  ```bash
33
- cp -R skills/ichartjs "${CODEX_HOME:-$HOME/.codex}/skills/"
33
+ npx skills add wanghetommy/ichartjs --skill ichartjs
34
34
  ```
35
35
 
36
+ For global non-interactive Codex setup, append `--agent codex --global --yes`. To pin the released workflow, install `https://github.com/wanghetommy/ichartjs/tree/v2.0.7/skills/ichartjs`. WorkBuddy can import that tagged directory through its Skill interface; only use a host-specific `--agent` value when the installed CLI declares it.
37
+
38
+ Verify discovery with `npx skills add wanghetommy/ichartjs --list`; the result should include `ichartjs`.
39
+
36
40
  ## Agent Request Pattern
37
41
 
38
42
  A useful request is explicit about data, intent, output, and acceptance:
@@ -0,0 +1,44 @@
1
+ # Iteration 11 — Chart Preferences and Agent Adjustments
2
+
3
+ Iteration 11A–11D adds a small, allowlisted preference layer for visual configuration. It does not add chart types or change data encoding behavior. The same contract powers per-chart settings, page-wide defaults, browser persistence, and Agent conversational adjustments.
4
+
5
+ ## 11A — Preferences Contract
6
+
7
+ - Add `createPreferencesStore()`, `normalizePreferences()`, `mergePreferences()`, and `validatePreferences()`.
8
+ - Keep the public fields limited to theme mode/preset/palette, typography scale, density, legend/labels/grid visibility, branding, and motion.
9
+ - Resolve precedence as defaults → global page preferences → chart preferences → temporary Agent patch.
10
+ - Keep preference state separate from business data and provide structured change events with `source`, `scope`, and persistence status.
11
+ - Fall back to memory in Node/SSR and support browser `localStorage` or a host storage adapter explicitly.
12
+
13
+ ## 11B — Per-Chart Settings
14
+
15
+ - Add `Chart#getPreferences()`, `Chart#setPreferences()`, and `Chart#resetPreferences()`.
16
+ - Add the optional `mountChartSettings()` browser UI with an accessible settings button in the chart container's top-right corner.
17
+ - Limit the per-chart menu to high-frequency theme, palette, font-scale, and capability-supported visibility controls; keep advanced and global controls on a dedicated page outside the chart popover.
18
+ - Keep the settings DOM outside SVG/Canvas so it is not included in PNG/SVG exports.
19
+ - Apply changes without recreating the Chart instance and preserve explicit chart colors/background/padding overrides.
20
+
21
+ ## 11C — Global Page Configuration
22
+
23
+ - Allow one `PreferencesStore` to be shared by all charts on a page.
24
+ - Support global and chart scopes with chart-specific inheritance and reset behavior.
25
+ - Persist only the versioned preference document, never business rows or credentials.
26
+ - Expose the effective preferences in `chart.getState()` and the capabilities manifest.
27
+
28
+ ## 11D — Agent and Playground Integration
29
+
30
+ - Let an Agent apply a validated visual patch with `chart.setPreferences(patch, { source: 'agent' })`.
31
+ - Keep Agent updates and UI updates on the same `preferenceschange` event path.
32
+ - Add `preferences-lab.html` and settings controls to the Complete Gallery for browser acceptance.
33
+ - Document conversational examples such as “use dashboard style, status colors, larger labels, and hide the grid.”
34
+
35
+ ## Acceptance
36
+
37
+ - `npm run agent:check` passes.
38
+ - Preferences work in headless memory mode and browser `localStorage` mode.
39
+ - Global updates reach all charts sharing a store; chart updates remain isolated.
40
+ - Invalid preference patches return structured validation details and do not mutate state.
41
+ - Preview pages:
42
+ - `http://localhost:3000/playground/preferences-lab.html`
43
+ - `http://localhost:3000/playground/project-gallery.html`
44
+ - No new chart type, data transform, or export format is introduced.
@@ -0,0 +1,101 @@
1
+ # Iteration 12 — Structured Diagrams: Architecture and Mindmap
2
+
3
+ Release status: Iteration 12A–12G is included in `v2.0.7`.
4
+
5
+ Iteration 12 extends the existing Flow/Swimlane diagram runtime with two structured-diagram modes. Architecture diagrams and mindmaps share the same JSON-safe nodes, edges, layout, interaction, export, and Agent contracts; they are not separate renderer implementations.
6
+
7
+ ## 12A — Shared Structured Diagram Model
8
+
9
+ - Reuse stable node IDs, edges, groups, ports, positions, sizes, routing, selection, keyboard navigation, history, Canvas/SVG rendering, and JSON/SVG/PNG export.
10
+ - Normalize `diagram.mode` as `process`, `architecture`, or `mindmap`.
11
+ - Derive mindmap parent-child edges from `node.parentId` while preserving explicit edges.
12
+ - Validate missing parents, self-parenting, duplicate IDs, layer references, and mindmap cycles.
13
+ - Keep `validateDiagram()` as the Agent-facing validation entry point.
14
+
15
+ ## 12B — Architecture Diagram Mode
16
+
17
+ - Add `type: 'architecture'` for business, data, and technical architecture views.
18
+ - Support `layers` for stable vertical or horizontal architectural strata.
19
+ - Support `boundaries` with `nodeIds`, labels, padding, and color for bounded contexts, domains, systems, or platform boundaries.
20
+ - Keep regular edges for dependencies, realizes, persists, publishes, and other declared relationships; the runtime does not infer business semantics.
21
+ - Preserve manual positions when supplied and use deterministic layered placement otherwise.
22
+
23
+ ## 12C — Mindmap Mode
24
+
25
+ - Add `type: 'mindmap'` with `parentId` as the compact Agent-friendly hierarchy contract.
26
+ - Support deterministic `tree` and `radial` layouts through the existing diagram layout modes.
27
+ - Render root and branch emphasis without introducing a new renderer or a separate editing model.
28
+ - Keep explicit IDs and parent references so Agents can update one branch without replacing the whole mindmap.
29
+
30
+ ## 12D — Agent Contract and Schemas
31
+
32
+ - Expose `architecture` and `mindmap` in `getCapabilities()`, `planChart()`, chart profiles, TypeScript declarations, and manifests.
33
+ - Add `architecture-node`, `architecture-edge`, and `mindmap-node` business schemas.
34
+ - Return assumptions and structured validation diagnostics instead of silently guessing layer, boundary, or parent semantics.
35
+ - Keep architecture and mindmap in the `diagram` family and recommend them only for `architecture`, `hierarchy`, `brainstorm`, and related intents.
36
+
37
+ ## 12E — Playground and Documentation
38
+
39
+ - Add Architecture and Mindmap examples to `playground/project-gallery.html`.
40
+ - Document the distinction: architecture is a domain/system structure; a mindmap is a hierarchy of ideas. Both are structured diagrams, but a mindmap is not an architecture diagram by default.
41
+ - Use `npm run playground` and preview `http://localhost:3000/playground/project-gallery.html`, then search `Architecture` or `Mindmap`.
42
+
43
+ ## 12F — Renderer-Parity Edge Editing
44
+
45
+ Direct edge editing must remain a renderer-independent Diagram capability. SVG may be used to validate the interaction first, but Canvas and SVG must expose the same public operations, editing semantics, persisted data, keyboard behavior, and final acceptance status. The feature is not complete while either renderer is read-only or has reduced editing behavior.
46
+
47
+ The default runtime state must be static and safe, with no unexpected viewport or structural changes. Zoom, pan, brush selection, node dragging, edge dragging, port connection, and structural commands are disabled by default and must be explicitly enabled by the host. Agent-driven edits continue to use the validated preview/commit contract and do not implicitly enable pointer editing in the UI.
48
+
49
+ ### Phase 1 — Edge Hit Testing and Selection
50
+
51
+ - Add geometry-aware edge hit testing with a forgiving interaction tolerance instead of relying on rectangular scene bounds.
52
+ - Make diagram edges selectable in Flow, Swimlane, Architecture, and Mindmap without changing chart-series line behavior.
53
+ - Support selected, hover, focus, delete, Escape, and keyboard traversal states consistently in Canvas and SVG.
54
+ - Keep hit testing in the shared Scene Graph; SVG transparent strokes may optimize DOM interaction but must not become the source of truth.
55
+ - Expose explicit edge-selection and edge-editing support through `getCapabilities()`.
56
+ - Keep navigation and editing disabled in default chart specs; Gallery and read-only embeds must not enable them implicitly.
57
+
58
+ ### Phase 2 — Waypoint and Segment Handles
59
+
60
+ - Show bend-point and segment-midpoint handles only after an edge is selected in editing mode.
61
+ - Dragging a bend point updates one waypoint; dragging an orthogonal segment midpoint moves only that horizontal or vertical segment.
62
+ - Use enlarged invisible hit regions and minimum target sizes so thin lines remain usable without visually thickening them.
63
+ - Reuse preview, confirmation, commit, undo, redo, and audit behavior from the shared edit controller.
64
+ - Validate the interaction in SVG first if useful, but do not publish renderer-specific public behavior.
65
+
66
+ ### Phase 3 — Persistent Manual Routing
67
+
68
+ - Add JSON-safe `waypoints` to the edge contract and preserve stable edge IDs.
69
+ - Apply the same waypoint model to Canvas rendering, SVG rendering, JSON export, SVG/PNG export, copy/paste, duplicate, and Agent edits.
70
+ - Define routing precedence as explicit waypoints first, automatic obstacle-aware routing otherwise.
71
+ - When connected nodes move, preserve valid manual segments, repair invalid endpoint segments, and fall back to deterministic automatic routing when the manual path becomes unusable.
72
+ - Support Agent updates through validated `updateEdge` operations rather than renderer-specific commands.
73
+
74
+ ### 12F Acceptance
75
+
76
+ - Canvas and SVG pass the same edge hit-testing, selection, handle dragging, persistence, undo/redo, keyboard, and export tests.
77
+ - Flow, Swimlane, Architecture, and Mindmap use the same edge-editing contract and interaction implementation.
78
+ - Thin edges remain easy to select without changing their visible stroke width.
79
+ - Manual waypoints survive rerender, renderer switching, serialization, export, and chart recreation.
80
+ - Node movement never leaves an edge passing through a node; invalid manual routes are repaired or deterministically rerouted.
81
+ - Until all parity criteria pass, capabilities report segment dragging as unavailable rather than advertising SVG-only support.
82
+ - Default charts remain static: zoom, pan, brush, node drag, edge drag, port connection, and structural editing only activate through explicit host configuration.
83
+
84
+ ## 12G — Mindmap Curved Edges
85
+
86
+ - Mindmap parent-child edges default to `routing: 'curved'`; Flow, Swimlane, and Architecture keep orthogonal defaults.
87
+ - `curved` renders one cubic Bezier segment in both Canvas and SVG instead of a four-point polyline.
88
+ - `diagram.curveTension` and per-edge `curveTension` accept values from `0.2` to `0.8`, with `0.4` as the default.
89
+ - Labels use the Bezier midpoint and arrowheads use the end tangent. Shared Scene Graph hit testing samples the curve so Canvas and SVG selection remain equivalent.
90
+ - Curves that intersect another node fall back deterministically to obstacle-aware orthogonal routing.
91
+ - Explicit `waypoints` retain precedence and render as manual polylines. Bezier control-point editing is intentionally excluded; moving nodes recalculates the curve.
92
+
93
+ ## Acceptance
94
+
95
+ - `npm run agent:check` passes with 18 public chart types and 10 business schemas.
96
+ - Architecture validates and renders layers, boundaries, nodes, and dependency edges in both SVG and Canvas.
97
+ - Mindmap validates parent references and cycles, derives stable parent-child edges, and renders tree and radial layouts deterministically.
98
+ - Existing Flow and Swimlane tests and previews remain unchanged and pass.
99
+ - Existing export, accessibility, selection, keyboard, and preference behavior remains available through the shared diagram runtime.
100
+ - Iteration 12F is accepted only when Canvas and SVG expose equivalent edge-editing behavior.
101
+ - Iteration 12G is accepted only when Canvas, browser SVG, and headless SVG all emit true cubic Bezier paths and preserve static-by-default interaction behavior.
@@ -1,6 +1,6 @@
1
1
  # iChart.js 2.0 Roadmap
2
2
 
3
- > Roadmap baseline: 2026-09-14. Current release status: `v2.0.4` is published and `v2.0.5` is prepared as the Iteration 10A export-contract and usage-guidance patch release. Geographic charts and 3D rendering remain out of scope until explicitly reintroduced.
3
+ > Roadmap baseline: 2026-09-14. Current release status: `v2.0.7` includes the completed Iteration 12 structured-diagram work and follow-up chart/menu fixes. Geographic charts and 3D rendering remain out of scope until explicitly reintroduced.
4
4
 
5
5
  ## Current Status
6
6
 
@@ -12,7 +12,9 @@
12
12
  - Iteration 7 local runtime and browser acceptance are complete for foundational composition, Heatmap, and Radar; physical-device checks remain host integration evidence.
13
13
  - Iteration 8A–8D is complete and accepted in automated tests, Chromium, Firefox 144, WebKit 26, native Safari 26.6.2, and a 390 px touch viewport. Physical iOS/Android and representative release-host measurements remain post-release host/device follow-up. No new public chart type was introduced.
14
14
  - Iteration 9A–9D implemented the lightweight visual style system, adaptive theme planning, runtime switching, renderer integration, and bilingual Agent guidance without adding a chart type; these capabilities remain in the `2.0.x` line.
15
- - Iteration 10A Export Contract Hardening is implemented on `develop`: export representations and type errors are deterministic, optional Node raster export uses `exportAsync()`, Canvas/SVG paint semantics are aligned, and the playground server has safer port/path handling. No chart behavior or public chart type was added.
15
+ - Iteration 10A Export Contract Hardening was implemented and released in `v2.0.5`: export representations and type errors are deterministic, optional Node raster export uses `exportAsync()`, Canvas/SVG paint semantics are aligned, and the playground server has safer port/path handling. No chart behavior or public chart type was added.
16
+ - Iteration 11 visual preference controls are included in the `v2.0.6` release: compact per-chart settings, capability-aware visibility controls, theme-aware icon contrast, explicit font-size defaults, shared page preferences, and Agent-adjustable global settings.
17
+ - Iteration 12A–12G is included in `v2.0.7`: shared structured-diagram contracts, Architecture layers/boundaries, Mindmap parent-child tree/radial layouts with true cubic-Bezier edges, Agent schemas/capabilities, renderer-parity edge hit testing and selection, waypoint/segment handles, persistent manual routing, and Gallery/documentation coverage. Navigation and editing remain disabled by default and require explicit host activation.
16
18
  - The original `2.0.0` readiness record is historical and superseded by the published `2.0.x` releases. Current release checks are defined by `docs/agent/development/release-sop.md`.
17
19
 
18
20
  ## Iteration 4 — Agent Data Contract and Business Editing
@@ -248,6 +250,29 @@ The following remain deferred beyond this roadmap baseline:
248
250
 
249
251
  They should only be scheduled after the core runtime, diagram model, and project analytics contracts are stable.
250
252
 
253
+ ## Iteration 11 — Chart Preferences and Agent Adjustments
254
+
255
+ ### Goal
256
+
257
+ Allow users and Agents to adjust a chart's visual presentation after creation through one small, auditable contract. The detailed 11A–11D plan is in `docs/agent/development/iteration-11.md`.
258
+
259
+ ### Tasks
260
+
261
+ 1. Add allowlisted preferences for theme, typography scale, density, components, branding, and motion.
262
+ 2. Support chart-scoped and page-global inheritance through an explicit Preferences Store.
263
+ 3. Persist only versioned preference state through browser `localStorage` or a host adapter.
264
+ 4. Add an optional accessible settings button outside the SVG/Canvas export surface.
265
+ 5. Let Agents apply natural-language intent as a validated preference patch with source and scope metadata.
266
+ 6. Add Playground and bilingual guidance for UI and Agent adjustment workflows.
267
+
268
+ ### Verification
269
+
270
+ - Global changes reach all charts sharing a store; chart overrides remain isolated.
271
+ - UI, Agent, and host code use the same `preferenceschange` event path.
272
+ - Invalid patches do not mutate preferences or business data.
273
+ - Settings UI is excluded from SVG, PNG, and JSON chart exports.
274
+ - `npm run agent:check`, `git diff --check`, and `http://localhost:3000/playground/preferences-lab.html` acceptance pass.
275
+
251
276
  ## Recommended Execution Order
252
277
 
253
278
  1. Finish Iteration 3 browser acceptance.
@@ -257,4 +282,5 @@ They should only be scheduled after the core runtime, diagram model, and project
257
282
  5. Execute Iteration 7 foundations before considering additional specialized chart types.
258
283
  6. Execute Iteration 8 to complete existing chart behavior, Agent adaptation, and the 2.0 release gates.
259
284
  7. Execute Iteration 9 to standardize adaptive visual styling without expanding chart count.
260
- 8. Re-evaluate geographic and 3D scope only after usage data confirms demand.
285
+ 8. Execute Iteration 11 to add post-creation chart and page preferences without expanding chart count.
286
+ 9. Re-evaluate geographic and 3D scope only after usage data confirms demand.
@@ -8,7 +8,7 @@ Unified workflow for Coding Agents developing iChart.js 2.0.
8
8
  | --- | --- | --- |
9
9
  | Generic metrics and data charts | `charting-scenario.md` | `src/charts.mjs` |
10
10
  | Schedules, milestones, and progress | `project-scenario.md` | `src/project.mjs` |
11
- | Processes, swimlanes, and Diagram editing | `diagram-scenario.md` | `src/diagram.mjs`, `src/diagram-interaction.mjs` |
11
+ | Processes, swimlanes, architecture, mindmaps, and Diagram editing | `diagram-scenario.md` | `src/diagram.mjs`, `src/diagram-interaction.mjs` |
12
12
 
13
13
  ## Standard Change Flow
14
14
 
@@ -6,22 +6,36 @@ Agent usage and development guide for process modeling, responsibility mapping,
6
6
 
7
7
  - `flow`: a process graph made of nodes and edges.
8
8
  - `swimlane`: a process graph organized by responsibility lanes.
9
+ - `architecture`: a layered business, data, or technical architecture graph with optional boundaries.
10
+ - `mindmap`: a parent-child hierarchy of ideas rendered as a tree or radial diagram.
11
+
12
+ Architecture and mindmap are both structured diagrams, but they are not interchangeable: architecture describes declared domain or system relationships, while a mindmap describes an idea hierarchy.
9
13
 
10
14
  ## Data Model
11
15
 
12
16
  ```js
13
17
  {
14
- type: 'flow',
18
+ type: 'architecture',
19
+ layers: [{ id: 'business', label: 'Business' }, { id: 'technology', label: 'Technology' }],
20
+ boundaries: [{ id: 'platform', label: 'Platform', nodeIds: ['api'] }],
15
21
  nodes: [{
16
- id: 'review',
17
- label: 'Review',
18
- position: { x: 240, y: 100 },
19
- size: { width: 140, height: 44 },
20
- ports: [{ id: 'in', side: 'left', offset: 0.5 }],
21
- groupId: 'delivery'
22
+ id: 'api', label: 'Order API', layerId: 'technology', position: { x: 240, y: 100 }
22
23
  }],
23
- edges: [{ from: 'start', to: 'review', toPort: 'in' }],
24
- groups: [{ id: 'delivery', label: 'Delivery' }]
24
+ edges: [{ id: 'orders-api', from: 'orders', to: 'api', relation: 'realizes', waypoints: [{ x: 220, y: 80 }, { x: 220, y: 160 }] }]
25
+ }
26
+ ```
27
+
28
+ For a mindmap, prefer the compact parent contract:
29
+
30
+ ```js
31
+ {
32
+ type: 'mindmap',
33
+ nodes: [
34
+ { id: 'root', label: 'Release plan' },
35
+ { id: 'scope', label: 'Scope', parentId: 'root' },
36
+ { id: 'risk', label: 'Risks', parentId: 'root' }
37
+ ],
38
+ diagram: { mode: 'mindmap', layout: 'tree', routing: 'curved', curveTension: 0.4 }
25
39
  }
26
40
  ```
27
41
 
@@ -31,12 +45,25 @@ Supported:
31
45
 
32
46
  - Nodes, edges, lanes, groups, and ports.
33
47
  - `manual`, `layered`, `tree`, and `radial` layouts.
34
- - `straight`, `orthogonal`, and `curved` routing declarations, with lightweight obstacle-aware orthogonal routing.
48
+ - Architecture layers and boundaries, plus mindmap parent-child derivation.
49
+ - `straight`, `orthogonal`, and true cubic-Bezier `curved` routing, with adjustable `curveTension` and obstacle-aware orthogonal fallback.
35
50
  - Node dragging, multi-selection, alignment, and grid snapping.
36
51
  - Keyboard movement, copy/paste, duplicate, group collapse/expand, undo/redo, and a shared Canvas/SVG Scene.
37
52
  - Port-aware drag-to-connect interaction and typed edge creation.
53
+ - Geometry-aware edge selection, waypoint handles, orthogonal segment handles, persistent manual routing, and edge deletion.
38
54
  - Group collapse/expand with collapsed group summary rendering.
39
55
 
56
+ Navigation and editing are opt-in. The default chart is static: zoom, pan, brush, node drag, edge drag, port connection, and structural editing are disabled until the host enables them.
57
+
58
+ ```js
59
+ interaction: { zoom: true, pan: true, drag: true, edgeDrag: true, portConnect: true },
60
+ editing: { enabled: true, allowDelete: true, allowStructuralChanges: true }
61
+ ```
62
+
63
+ Canvas and SVG use the same Scene Graph hit testing, `waypoints` contract, commands, history, and interaction behavior.
64
+
65
+ Mindmap defaults to curved parent-child edges. Set `diagram.curveTension` from `0.2` to `0.8`, override `routing` or `curveTension` on one explicit edge, or use `waypoints` when a persistent manual polyline is required. Bezier control points are not directly editable.
66
+
40
67
  Current limitations:
41
68
 
42
69
  - Groups are flat; nested groups are not supported.
@@ -50,7 +77,7 @@ Current limitations:
50
77
  1. Assign stable IDs to nodes and edges.
51
78
  2. Use `validateDiagram(spec)` to check endpoints, ports, groups, lanes, and layout options.
52
79
  3. Create the chart with `createChart(spec)`.
53
- 4. Use typed commands such as `moveNodes`, `alignNodes`, `snapNodes`, `addEdge`, `toggleGroupCollapse`, `duplicateSelection`, and `pasteSelection` for edits.
80
+ 4. Use typed commands such as `moveNodes`, `alignNodes`, `snapNodes`, `addEdge`, `updateEdge`, `removeEdge`, `toggleGroupCollapse`, `duplicateSelection`, and `pasteSelection` for edits.
54
81
  5. Follow the preview/confirm/commit flow for all business-data changes.
55
82
 
56
83
  ## Implementation Map
@@ -80,3 +107,4 @@ Current limitations:
80
107
  - Copy/paste preserves internal edges and produces deterministic new IDs.
81
108
  - Group collapse hides member nodes and keeps group-level state visible.
82
109
  - Groups, ports, and invalid references produce structured validation results.
110
+ - Canvas and SVG produce equivalent edge selection, handle dragging, persisted waypoints, keyboard behavior, and exports.
@@ -40,6 +40,8 @@ Core APIs:
40
40
  - Command validation does not mutate the input command or source data.
41
41
  - Host confirmation is required by default; `confirmed: true` is not an authorization system.
42
42
  - External persistence, permissions, and authentication belong to the host application.
43
+ - Pointer navigation and editing are disabled by default. `editing.enabled` authorizes edit transactions; `interaction.drag`, `interaction.edgeDrag`, and `interaction.portConnect` separately expose direct-manipulation UI.
44
+ - Diagram edge routes use JSON-safe `waypoints` and update through `updateEdge`; edge deletion uses `removeEdge` and requires structural-edit permission.
43
45
 
44
46
  ## Supported Models
45
47
 
@@ -50,6 +52,9 @@ Core APIs:
50
52
  - `flow-node`
51
53
  - `flow-edge`
52
54
  - `swimlane`
55
+ - `architecture-node`
56
+ - `architecture-edge`
57
+ - `mindmap-node`
53
58
 
54
59
  ## History and Revision
55
60
 
@@ -10,7 +10,7 @@ This is the production component path. For one-off files or Agent-led repository
10
10
  npm install @taylorwong/ichartjs@^2
11
11
  ```
12
12
 
13
- For environments without npm registry access, install from GitHub as a fallback: `npm install github:wanghetommy/ichartjs#v2.0.5`.
13
+ For environments without npm registry access, install from GitHub as a fallback: `npm install github:wanghetommy/ichartjs#v2.0.7`.
14
14
 
15
15
  Use the package through a bundler or another environment that resolves npm ESM imports:
16
16
 
@@ -10,6 +10,8 @@ getCapabilities → inspectData → planChart → create Spec → validateSpec
10
10
 
11
11
  Agents should use `getCapabilities()` first instead of hard-coding undeclared types or operations.
12
12
 
13
+ For post-creation visual settings, use `getPreferenceCapabilities(chartType, { locale }) → chart.getPreferences() → validatePreferences(patch) → chart.setPreferences(patch, { source: 'agent' }) → chart.getState().preferences`. This keeps Agent changes on the same allowlisted contract as the built-in settings menu.
14
+
13
15
  Iteration 8 adds per-chart profiles through `getChartCapability(type)`. Each profile declares required data roles, supported interactions, renderers, feature status, exports, and practical limits. Unsupported behavior must be handled from this profile or from validation diagnostics rather than guessed.
14
16
 
15
17
  `planChart(data, { intent, renderer })` returns a versioned planning result with a primary chart, alternatives, confidence, reasons, required fields, suggested encodings, assumptions, warnings, unsupported requests, safe next actions, and the selected capability profile. Planning never invents business meaning, units, dates, or missing fields.
@@ -19,7 +21,7 @@ Iteration 8 adds per-chart profiles through `getChartCapability(type)`. Each pro
19
21
  - Specs must be JSON-serializable.
20
22
  - Call `validateSpec()` before rendering.
21
23
  - Chart layout and data semantics are renderer-independent.
22
- - `flow` and `swimlane` use `nodes/edges/lanes`; generic charts use `data.values`.
24
+ - `flow` and `swimlane` use `nodes/edges/lanes`; `architecture` uses `nodes/edges/layers/boundaries`; `mindmap` uses `nodes` with `parentId` and optional `edges`; generic charts use `data.values`.
23
25
 
24
26
  ## Renderer
25
27
 
@@ -93,10 +95,18 @@ validateSpec(spec)
93
95
  createChart(spec)
94
96
  getCapabilities()
95
97
  getChartCapability(type)
98
+ getPreferenceCapabilities(type, options)
99
+ validatePreferences(patch, options)
96
100
  chart.describe()
97
101
  chart.explain()
98
102
  chart.getState()
103
+ chart.getPreferences()
104
+ chart.setPreferences(patch, options)
105
+ chart.resetPreferences(options)
99
106
  chart.getSelectedData()
107
+ chart.selectEdges(edgeIds, options)
108
+ chart.getSelectedEdgeIds()
109
+ chart.deleteSelectedEdges(options)
100
110
  chart.export(options)
101
111
  chart.exportAsync(options)
102
112
  chart.toDataURL(type)
@@ -57,3 +57,66 @@ Built-in modes expose text, muted text, axis, grid, focus, selection, missing-va
57
57
 
58
58
  Preview and acceptance: `http://localhost:3000/playground/theme-gallery.html`.
59
59
 
60
+ ## Chart and Page Preferences
61
+
62
+ Use preferences for visual adjustments that a user or Agent may change after the chart has been created. Keep business data, encodings, and chart selection outside this surface.
63
+
64
+ ```js
65
+ import { createChart, createPreferencesStore, mountChartSettings } from '@taylorwong/ichartjs';
66
+
67
+ const pagePreferences = createPreferencesStore({
68
+ storage: 'localStorage',
69
+ storageKey: 'my-app:chart-preferences'
70
+ });
71
+ const chart = createChart({
72
+ chartId: 'revenue',
73
+ container: '#revenue',
74
+ type: 'line',
75
+ data: { values: rows },
76
+ preferences: pagePreferences
77
+ });
78
+ const settings = mountChartSettings(chart, {
79
+ locale: 'en',
80
+ placement: 'auto',
81
+ preferredPlacements: ['right', 'top', 'bottom']
82
+ });
83
+
84
+ // The same operation can come from an Agent conversation.
85
+ chart.setPreferences({
86
+ theme: { preset: 'dashboard', palette: 'status' },
87
+ typography: { scale: 1.15 },
88
+ components: { grid: false }
89
+ }, { source: 'agent' });
90
+
91
+ // Call this when the host permanently removes the chart.
92
+ settings.destroy();
93
+ ```
94
+
95
+ The quick-settings panel is portaled outside the clipped chart surface. Automatic placement prefers the button's right side, then the top, then the bottom, and finally constrains the panel inside the browser viewport. On scroll it preserves the selected placement and follows the anchor without viewport snapping; it closes directly when the chart or anchor leaves the viewport. Resize and content changes may recompute placement.
96
+
97
+ ### Agent Discovery and Validation
98
+
99
+ Agents should discover the allowlisted surface instead of hard-coding menu options. `getPreferenceCapabilities(chartType, { locale })` returns every preference field with its type, default value, options, scopes, chart applicability, and `menu.visible` status. Use the same contract for conversational changes and custom settings pages.
100
+
101
+ ```js
102
+ import { getPreferenceCapabilities, validatePreferences } from '@taylorwong/ichartjs';
103
+
104
+ const capabilities = getPreferenceCapabilities(chart.getSpec().type, { locale: 'en' });
105
+ const menuFields = capabilities.fields.filter(field => field.menu.visible);
106
+ const current = chart.getPreferences();
107
+ const patch = {
108
+ theme: { preset: 'dashboard', palette: 'status' },
109
+ typography: { scale: 1.15 },
110
+ components: { grid: false }
111
+ };
112
+ const checked = validatePreferences(patch, { partial: true });
113
+ if (!checked.valid) throw new Error(JSON.stringify(checked.errors));
114
+ chart.setPreferences(checked.value, { scope: 'chart', source: 'agent' });
115
+ const applied = chart.getState().preferences;
116
+ ```
117
+
118
+ The quick menu fields are `theme.mode`, `theme.palette`, `typography.scale`, and capability-supported `components.legend`, `components.labels`, and `components.grid`. The full allowlist additionally includes `theme.preset`, `density`, `branding.enabled`, and `motion`. Unknown locales fall back to English.
119
+
120
+ The optional per-chart menu uses a compact hamburger icon and intentionally exposes only high-frequency controls: theme mode, palette, font scale, and supported legend/label/grid visibility. Capability checks hide controls that do not apply to the current chart. Changes apply immediately and the UI supports `en`, `zh-CN`, and automatic document-language detection.
121
+
122
+ Keep low-frequency and page-wide controls in a dedicated settings surface outside the chart popover. Share one store across the page, and call `store.setGlobal()` or `chart.setPreferences(patch, { scope: 'global' })`. The full surface may expose preset, density, branding, and other allowlisted preferences without overloading every chart. The store uses memory in Node/SSR unless `localStorage` or a host adapter is explicitly selected. Preview the quick menu in `http://localhost:3000/playground/project-gallery.html` and the full page at `http://localhost:3000/playground/preferences-lab.html`.
@@ -35,6 +35,22 @@ The Skill is not a second renderer or service. A Skill-enabled Agent still needs
35
35
 
36
36
  JSON is the machine-readable source of truth. SVG and PNG/JPEG are presentation artifacts. Code is the integration artifact. An interactive page is the product artifact.
37
37
 
38
+ ## Visual Preferences: UI and Agent
39
+
40
+ For post-creation visual adjustments, share a `createPreferencesStore()` with the page's charts. Use `storage: 'localStorage'` only in a browser when the host wants preferences to survive refreshes. `mountChartSettings(chart)` adds an optional accessible quick-settings button outside the export surface; keep the full page-level settings surface as a separate host route.
41
+
42
+ The host or Agent can use the same patch contract:
43
+
44
+ ```js
45
+ chart.setPreferences({
46
+ theme: { preset: 'dashboard', palette: 'status' },
47
+ typography: { scale: 1.15 },
48
+ components: { grid: false }
49
+ }, { source: 'agent' });
50
+ ```
51
+
52
+ Keep the quick menu limited to theme, palette, font scale, and capability-supported visibility toggles. Use `scope: 'global'` for a page-wide update, the default chart scope for a single chart, and `chart.getState().preferences` for an auditable effective result. Preview both layers at `http://localhost:3000/playground/project-gallery.html` and `http://localhost:3000/playground/preferences-lab.html`.
53
+
38
54
  ## Scenario 1: Integrate into a Web Project
39
55
 
40
56
  Install the runtime in the host application:
@@ -90,7 +106,28 @@ For a consumer project, return that project's own development URL.
90
106
 
91
107
  ## Scenario 3: Use the Official Skill
92
108
 
93
- Install or select `skills/ichartjs` in Codex, WorkBuddy, or another Agent Skills-compatible host. Then ask:
109
+ Install the latest Skill with the standard Agent Skills CLI:
110
+
111
+ ```bash
112
+ npx skills add wanghetommy/ichartjs --skill ichartjs
113
+ ```
114
+
115
+ Install globally for Codex without prompts:
116
+
117
+ ```bash
118
+ npx skills add wanghetommy/ichartjs --skill ichartjs --agent codex --global --yes
119
+ ```
120
+
121
+ For reproducible installation, pin the released Skill directory:
122
+
123
+ ```bash
124
+ npx skills add https://github.com/wanghetommy/ichartjs/tree/v2.0.7/skills/ichartjs \
125
+ --agent codex --global --yes
126
+ ```
127
+
128
+ WorkBuddy users can import the same tagged GitHub directory through the host's Skill interface. Do not assume that `--agent workbuddy` exists unless the installed Skills CLI lists that adapter. A manual copy from `node_modules/@taylorwong/ichartjs/skills/ichartjs` remains a fallback for hosts with custom Skill directories.
129
+
130
+ After installation or selection, ask:
94
131
 
95
132
  ```text
96
133
  Use the iChart.js Skill. Read this dataset, create a project Burndown,
@@ -122,6 +159,8 @@ Use the project and diagram contracts when the data has project semantics rather
122
159
  - `gantt`, `timeline`, `milestone`, and `burndown` for delivery schedules;
123
160
  - project analytics for capacity, velocity, release forecast, risk, and issue aging;
124
161
  - `flow` and `swimlane` for process, ownership, responsibility, groups, ports, and controlled editing.
162
+ - `architecture` for business, data, or technical architecture with explicit layers, boundaries, and relationships.
163
+ - `mindmap` for idea hierarchies where `parentId` is the source of truth and a tree or radial layout is preferred.
125
164
 
126
165
  Preserve stable record, node, edge, lane, group, and port IDs. For business edits, return a preview before commit and include the audit result.
127
166
 
@@ -11,7 +11,7 @@
11
11
  - [视觉样式与主题](theme-guide.md)
12
12
  - [数据分析图表](charting-scenario.md)
13
13
  - [项目管理图表](project-scenario.md)
14
- - [交互式 Diagram](diagram-scenario.md)
14
+ - [交互式 Diagram](diagram-scenario.md):Flow、Swimlane、Architecture、Mindmap 与编辑。
15
15
  - [Runtime 契约](runtime-contract.md)
16
16
  - [编辑契约](editing-contract.md)
17
17
  - 机器可读能力清单位于 `docs/manifests/`,供 Agent 按需读取。
@@ -16,12 +16,16 @@ npm install @taylorwong/ichartjs@^2
16
16
 
17
17
  npm Registry 中无作用域的 `ichartjs` 是安全占位包,并非本项目。正式包名是 `@taylorwong/ichartjs`,优先从 npm 安装。
18
18
 
19
- Codex、WorkBuddy 和其他兼容 Agent Skills 的宿主可共同使用 `skills/ichartjs`。从仓库检出目录安装到 Codex:
19
+ 使用标准 Agent Skills CLI 安装官方 Skill:
20
20
 
21
21
  ```bash
22
- cp -R skills/ichartjs "${CODEX_HOME:-$HOME/.codex}/skills/"
22
+ npx skills add wanghetommy/ichartjs --skill ichartjs
23
23
  ```
24
24
 
25
+ Codex 全局无交互安装可追加 `--agent codex --global --yes`。需要固定发布版本时,安装 `https://github.com/wanghetommy/ichartjs/tree/v2.0.7/skills/ichartjs`。WorkBuddy 可通过自身 Skill 界面导入该带 Tag 的目录;只有当前 CLI 明确声明对应适配器时才使用宿主专用 `--agent` 参数。
26
+
27
+ 使用 `npx skills add wanghetommy/ichartjs --list` 验证发现结果,其中应包含 `ichartjs`。
28
+
25
29
  推荐请求:
26
30
 
27
31
  ```text