@taylorwong/ichartjs 2.0.1

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 (80) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/LICENSE +201 -0
  3. package/README.md +194 -0
  4. package/agent-recipes/diagrams/agent-orchestration.json +18 -0
  5. package/agent-recipes/diagrams/approval-process.json +16 -0
  6. package/agent-recipes/diagrams/responsibility-mapping.json +13 -0
  7. package/agent-recipes/diagrams/workflow.json +19 -0
  8. package/agent-recipes/foundational-analysis.json +18 -0
  9. package/agent-recipes/project-management.json +47 -0
  10. package/agent-recipes/trend-line.json +21 -0
  11. package/docs/agent/README.md +62 -0
  12. package/docs/agent/charting-scenario.md +82 -0
  13. package/docs/agent/coding-agent-integration.md +88 -0
  14. package/docs/agent/development/2.0-release-readiness.md +65 -0
  15. package/docs/agent/development/iteration-2.md +9 -0
  16. package/docs/agent/development/iteration-3.md +142 -0
  17. package/docs/agent/development/iteration-4.md +261 -0
  18. package/docs/agent/development/iteration-5.md +43 -0
  19. package/docs/agent/development/iteration-6.md +130 -0
  20. package/docs/agent/development/iteration-7.md +117 -0
  21. package/docs/agent/development/iteration-8-acceptance.md +68 -0
  22. package/docs/agent/development/iteration-8.md +116 -0
  23. package/docs/agent/development/iteration-9.md +44 -0
  24. package/docs/agent/development/playground-plan.md +143 -0
  25. package/docs/agent/development/prompt-contract.md +22 -0
  26. package/docs/agent/development/rc-1-acceptance.md +43 -0
  27. package/docs/agent/development/roadmap.md +259 -0
  28. package/docs/agent/development-guide.md +60 -0
  29. package/docs/agent/diagram-scenario.md +82 -0
  30. package/docs/agent/editing-contract.md +71 -0
  31. package/docs/agent/frontend-integration.md +66 -0
  32. package/docs/agent/project-scenario.md +89 -0
  33. package/docs/agent/quickstart.md +205 -0
  34. package/docs/agent/runtime-contract.md +132 -0
  35. package/docs/agent/theme-guide.md +59 -0
  36. package/docs/agent/zh-CN/README.md +26 -0
  37. package/docs/agent/zh-CN/charting-scenario.md +62 -0
  38. package/docs/agent/zh-CN/coding-agent-integration.md +36 -0
  39. package/docs/agent/zh-CN/development-guide.md +31 -0
  40. package/docs/agent/zh-CN/diagram-scenario.md +37 -0
  41. package/docs/agent/zh-CN/editing-contract.md +27 -0
  42. package/docs/agent/zh-CN/frontend-integration.md +31 -0
  43. package/docs/agent/zh-CN/project-scenario.md +40 -0
  44. package/docs/agent/zh-CN/quickstart.md +84 -0
  45. package/docs/agent/zh-CN/runtime-contract.md +85 -0
  46. package/docs/agent/zh-CN/theme-guide.md +50 -0
  47. package/docs/manifests/capabilities.json +79 -0
  48. package/docs/manifests/commands.json +30 -0
  49. package/docs/manifests/schemas.json +13 -0
  50. package/examples/agent-workflow.mjs +94 -0
  51. package/package.json +55 -0
  52. package/skills/ichartjs/SKILL.md +72 -0
  53. package/skills/ichartjs/agents/openai.yaml +4 -0
  54. package/skills/ichartjs/references/agent-contract.md +39 -0
  55. package/skills/ichartjs/references/chart-selection.md +22 -0
  56. package/src/capabilities.mjs +190 -0
  57. package/src/charts.mjs +234 -0
  58. package/src/command.mjs +93 -0
  59. package/src/data.mjs +75 -0
  60. package/src/diagram-interaction.mjs +195 -0
  61. package/src/diagram.mjs +135 -0
  62. package/src/edit-controller.mjs +192 -0
  63. package/src/edit.mjs +369 -0
  64. package/src/format.mjs +19 -0
  65. package/src/history.mjs +14 -0
  66. package/src/index.mjs +562 -0
  67. package/src/plugin.mjs +18 -0
  68. package/src/project-analytics.mjs +357 -0
  69. package/src/project-linking.mjs +72 -0
  70. package/src/project.mjs +370 -0
  71. package/src/recipes.mjs +18 -0
  72. package/src/renderer.mjs +77 -0
  73. package/src/scale.mjs +9 -0
  74. package/src/scene.mjs +18 -0
  75. package/src/schema.mjs +142 -0
  76. package/src/spec.mjs +127 -0
  77. package/src/theme.mjs +232 -0
  78. package/src/transforms.mjs +34 -0
  79. package/src/validation.mjs +106 -0
  80. package/types/index.d.ts +134 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,69 @@
1
+ # Changelog
2
+
3
+ ## 2.0.0 - 2026-09-16
4
+
5
+ - Added Iteration 9's lightweight visual style system with adaptive modes, semantic presets and palettes, live switching, contrast diagnostics, Agent recommendations, bilingual guidance, and Theme Gallery while retaining version `2.0.0`.
6
+ - Released the new Agent-first iChart.js 2.0 product line with one ESM/TypeScript runtime surface, 16 public chart types, project intelligence, controlled diagram editing, capability discovery, planning, validation, explanation, and stable lineage.
7
+ - Accepted 51 core tests, the executable Agent workflow, official Skill validation, strict TypeScript consumption, package installation, and Node.js 18/20/22 GitHub Actions.
8
+ - Accepted Chromium, Firefox 144, WebKit 26, and native Safari 26.6.2 across maintained Playground pages, plus 390 x 844 responsive/touch viewport checks.
9
+ - Accepted local 5,000-row Line and Heatmap, 1,000-task Gantt, 300-node Diagram, Canvas/SVG, and lifecycle samples.
10
+ - Deferred npm publication while retaining GitHub Tag installation. Physical iOS/Android verification remains a documented host/device follow-up and does not block the source release.
11
+
12
+ ## 2.0.0-rc.1 Iteration 8 - 2026-09-16
13
+
14
+ - Reorganized the root README around the Agent discovery, inspection, planning, validation, rendering, and self-check workflow.
15
+ - Added one publishable ESM entry plus manifest, recipe, TypeScript, example, and official Skill package surfaces.
16
+ - Added English and Chinese Agent quickstarts plus an executable end-to-end Agent workflow.
17
+ - Completed common presentation and geometry behavior across the existing 16 public chart types without adding a new type.
18
+ - Added per-chart capability profiles, deterministic Agent planning, richer data inspection, validation diagnostics, explanations, and stable lineage output.
19
+ - Added a unified Playground home, full Gallery, Agent Workbench, Interaction Lab, Accessibility Lab, Performance Lab, and a no-cache preview server.
20
+ - Expanded TypeScript declarations, manifests, bilingual Agent contracts, regression tests, and local browser acceptance evidence.
21
+ - Added Node.js 18/20/22 CI, contribution guidance, private vulnerability-reporting guidance, and an Apache 2.0 license file.
22
+ - Completed Chromium, Firefox 144, and WebKit 26 desktop/mobile-viewport regression plus local 5,000-row performance and lifecycle samples.
23
+ - Kept native Safari automation, physical iOS/Android, and representative release-host performance checks as explicit RC release gates.
24
+
25
+ ## 2.0.0-alpha.1 - 2026-09-14
26
+
27
+ - Added the initial 2.0 module tree under `src/`.
28
+ - Added JSON-friendly Chart Spec normalization and validation.
29
+ - Added data normalization and inspection.
30
+ - Added renderer-independent Scene Graph.
31
+ - Added Canvas and SVG renderers.
32
+ - Added line, area, bar, column, and pie charts.
33
+ - Added basic hover, click, tooltip, resize, and export APIs.
34
+ - Added Node-based core tests.
35
+
36
+ The legacy 1.x implementation remains unchanged.
37
+
38
+ ## 2.0.0-beta.1 - 2026-09-14
39
+
40
+ - Added chainable data transforms: filter, sortBy, groupBy, sum, average, topN, and percentage.
41
+ - Added selection state, selected data, element lookup, JSON patches, and zoom reset APIs.
42
+ - Added standalone Scale primitives for category, linear, and time mapping.
43
+ - Added multi-series line/column rendering with left and right y-axis mappings.
44
+ - Added temporal x-axis tick generation and adaptive date labels.
45
+ - Added touch pan, pinch zoom, pointer brush, wheel zoom, and keyboard focus navigation.
46
+ - Added Annotation, DataZoom, DataLabels, and Accessibility plugin exports.
47
+
48
+ ## Iteration 3 plan - 2026-09-14
49
+
50
+ - Planned project-management views: Gantt, timeline, milestone, and burndown.
51
+ - Planned process visualizations: flow chart and swimlane chart.
52
+ - Planned shared interval, dependency, graph layout, lane, interaction, accessibility, export, and Agent Recipe capabilities.
53
+ - Deferred geographic charts, 3D rendering, fishbone diagrams, organization charts, dependency networks, resource-load views, and Kanban boards.
54
+
55
+ ## Iteration 3 product hardening - 2026-09-14
56
+
57
+ - Added Gantt critical-path analysis with automatic critical tasks, dependency arrowheads, and critical-edge emphasis.
58
+ - Added Flow node dragging with persisted `node.position`, edge rerouting, `drag`, and `dragend` events.
59
+ - Added Burndown scope-change markers, total-scope series, completion velocity, and estimated finish date.
60
+ - Added project-specific tooltips for tasks, milestones, burndown points, nodes, and swimlanes.
61
+ - Added shared project viewport scaling, mobile single-finger drag, and two-finger pinch behavior.
62
+ - Added renderer-independent scene-structure checks for SVG and Canvas outputs.
63
+
64
+ ## Iteration 4 plan - 2026-09-14
65
+
66
+ - Planned a versioned Business Data Schema for Agent-readable fields, permissions, relationships, and business rules.
67
+ - Planned typed Edit Commands for task scheduling, progress, dependencies, milestones, Flow nodes, and Swimlane ownership.
68
+ - Planned deterministic preview diffs, confirmation policies, audit records, rollback, undo, redo, and stale-version protection.
69
+ - Planned TypeScript declarations, Recipe validation, headless preview/export, and an editing acceptance demo.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,194 @@
1
+ # iChart.js 2.0
2
+
3
+ iChart.js is an Agent-first, renderer-independent visualization runtime. An Agent can inspect data, choose an appropriate chart, generate and validate a JSON-friendly Spec, render it with SVG or Canvas, and explain the result through public APIs.
4
+
5
+ ## For AI Agents
6
+
7
+ Do not guess chart types or configuration fields from source code. Use the public planning contract:
8
+
9
+ ```text
10
+ getCapabilities
11
+ → inspectData
12
+ → planChart
13
+ → build Spec
14
+ → validateSpec
15
+ → createChart
16
+ → chart.explain + chart.getState
17
+ ```
18
+
19
+ ### Agent entry points
20
+
21
+ | Need | Entry point |
22
+ | --- | --- |
23
+ | Runtime and Agent planning APIs | `ichartjs` |
24
+ | Machine-readable capability manifest | `ichartjs/capabilities.json` |
25
+ | Intent and chart recipes | `ichartjs/recipes/*` |
26
+ | Agent quickstart | [`docs/agent/quickstart.md`](docs/agent/quickstart.md) |
27
+ | Chinese quickstart | [`docs/agent/zh-CN/quickstart.md`](docs/agent/zh-CN/quickstart.md) |
28
+ | Coding Agent integration | [`docs/agent/coding-agent-integration.md`](docs/agent/coding-agent-integration.md) |
29
+ | Frontend integration | [`docs/agent/frontend-integration.md`](docs/agent/frontend-integration.md) |
30
+ | Visual style and themes | [`docs/agent/theme-guide.md`](docs/agent/theme-guide.md) |
31
+ | Official Agent Skill for Codex and WorkBuddy | [`skills/ichartjs/SKILL.md`](skills/ichartjs/SKILL.md) |
32
+
33
+ ### Install
34
+
35
+ ```bash
36
+ npm install @taylorwong/ichartjs@^2
37
+ ```
38
+
39
+ As a fallback for environments without npm access, install directly from GitHub: `npm install github:wanghetommy/ichartjs#v2.0.1`.
40
+
41
+ ### Optional Agent Skill
42
+
43
+ The runtime API remains the source of truth; the Skill only teaches and orchestrates the workflow. Codex, WorkBuddy, and other Agent Skills-compatible hosts can import the same versioned Skill from:
44
+
45
+ ```text
46
+ https://github.com/wanghetommy/ichartjs/tree/master/skills/ichartjs
47
+ ```
48
+
49
+ From a repository checkout, install it into Codex with:
50
+
51
+ ```bash
52
+ cp -R skills/ichartjs "${CODEX_HOME:-$HOME/.codex}/skills/"
53
+ ```
54
+
55
+ 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/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.
56
+
57
+ ### Agent workflow
58
+
59
+ ```js
60
+ import {
61
+ createChart,
62
+ getCapabilities,
63
+ inspectData,
64
+ planChart,
65
+ validateSpec
66
+ } from '@taylorwong/ichartjs';
67
+
68
+ const rows = [
69
+ { id: 'jan', month: 'Jan', revenue: 120 },
70
+ { id: 'feb', month: 'Feb', revenue: 148 },
71
+ { id: 'mar', month: 'Mar', revenue: 136 }
72
+ ];
73
+
74
+ const capabilities = getCapabilities();
75
+ const inspection = inspectData(rows);
76
+ const plan = planChart(rows, { intent: 'trend', renderer: 'svg' });
77
+
78
+ const candidate = {
79
+ type: plan.primary,
80
+ renderer: 'svg',
81
+ data: { values: rows },
82
+ encoding: {
83
+ x: { field: plan.suggestedEncodings.dimension },
84
+ y: { field: plan.suggestedEncodings.measure }
85
+ },
86
+ accessibility: { enabled: true },
87
+ theme: {
88
+ mode: 'auto',
89
+ preset: plan.styleRecommendation.preset,
90
+ palette: plan.styleRecommendation.palette
91
+ }
92
+ };
93
+
94
+ const validation = validateSpec(candidate);
95
+ if (!validation.valid) throw new Error(JSON.stringify(validation.errors));
96
+
97
+ const chart = createChart(validation.spec);
98
+ const agentResult = {
99
+ contractVersion: capabilities.contractVersion,
100
+ inspection,
101
+ plan,
102
+ explanation: chart.explain(),
103
+ state: chart.getState()
104
+ };
105
+
106
+ chart.destroy();
107
+ ```
108
+
109
+ Run the complete executable workflow with:
110
+
111
+ ```bash
112
+ npm run example:agent
113
+ ```
114
+
115
+ Source: [`examples/agent-workflow.mjs`](examples/agent-workflow.mjs).
116
+
117
+ ### Agent rules
118
+
119
+ - Call `getCapabilities()` instead of inventing chart types or options.
120
+ - Treat `inspectData()` field roles and units as inferences, not business truth.
121
+ - Stop and report `plan.requiredFields` when required data is missing.
122
+ - Call `validateSpec()` before every render or edit.
123
+ - Preserve stable source record IDs for selection, linking, and explanation.
124
+ - Return assumptions, warnings, unsupported requests, and validation diagnostics to the user.
125
+ - Use `chart.explain()` and `chart.getState()` for self-checking.
126
+ - Never generate geographic or 3D Specs unless the capability contract adds them.
127
+
128
+ ### Integration boundary
129
+
130
+ iChart.js is a JavaScript UI component library. Coding Agents use the same ESM API as developers and may optionally load the Skill for workflow guidance. A daily-use assistant can use iChart.js only inside a host web application that runs JavaScript; integrating a non-coding assistant is the host application's responsibility. The core package does not add a CLI, MCP server, HTTP service, or Python runtime.
131
+
132
+ ## Preview and Acceptance
133
+
134
+ Start the cache-safe local server:
135
+
136
+ ```bash
137
+ npm run playground
138
+ ```
139
+
140
+ - Playground Home: `http://localhost:3000/playground/index.html`
141
+ - Agent Workbench: `http://localhost:3000/playground/agent-workbench.html`
142
+ - Complete Gallery: `http://localhost:3000/playground/project-gallery.html`
143
+ - Theme Gallery: `http://localhost:3000/playground/theme-gallery.html`
144
+ - Project Intelligence: `http://localhost:3000/playground/project-intelligence.html`
145
+ - Diagram Editor: `http://localhost:3000/playground/diagram-editor.html`
146
+
147
+ ## For Developers
148
+
149
+ Use the main package entry when the chart type and Spec are already known:
150
+
151
+ ```js
152
+ import { createChart } from '@taylorwong/ichartjs';
153
+
154
+ const chart = createChart({
155
+ container: '#chart',
156
+ type: 'line',
157
+ renderer: 'svg',
158
+ data: {
159
+ values: [
160
+ { id: 'jan', month: 'Jan', sales: 120 },
161
+ { id: 'feb', month: 'Feb', sales: 180 }
162
+ ]
163
+ },
164
+ encoding: {
165
+ x: { field: 'month', type: 'category' },
166
+ y: { field: 'sales', type: 'quantitative' }
167
+ },
168
+ title: { text: 'Monthly Sales' }
169
+ });
170
+ ```
171
+
172
+ The public package includes ESM exports, TypeScript declarations, Agent documentation, manifests, recipes, examples, and the official Skill. The runtime has no external production dependency.
173
+
174
+ ## Supported Surface
175
+
176
+ - Foundational charts: Line, Area, Bar, Column, Pie/Donut, Scatter, Funnel, Gauge, Heatmap, and Radar.
177
+ - Project views: Gantt, Timeline, Milestone, and Burndown.
178
+ - Diagrams: Flow and Swimlane with groups, ports, routing, and controlled editing.
179
+ - Renderers: SVG and Canvas.
180
+ - Agent contracts: capability discovery, data inspection, planning, validation, explanation, lineage, diagnostics, and safe editing.
181
+ - Branding signature: low-contrast `Powered by iChart.js` bottom-right watermark, consistent across live view and all export formats; controlled via `branding` on Spec/Theme.
182
+ - Exports: JSON (spec + runtime state, all environments), SVG (vector, zero-dependency headless), PNG/JPEG (raster, dual-engine, browser native + headless with optional `canvas` dependency), plus browser `downloadPNG/SVG/JSON` helpers.
183
+ - Deferred: geographic charts and 3D rendering.
184
+
185
+ ## Development
186
+
187
+ ```bash
188
+ npm run agent:check
189
+ npm run playground
190
+ ```
191
+
192
+ Start with [`docs/agent/quickstart.md`](docs/agent/quickstart.md). Detailed runtime, charting, project, diagram, and editing contracts live in [`docs/agent/`](docs/agent/).
193
+
194
+ Contribution requirements are in [`CONTRIBUTING.md`](CONTRIBUTING.md). Report vulnerabilities privately according to [`SECURITY.md`](SECURITY.md).
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "agent-orchestration-diagram",
3
+ "version": "2.0",
4
+ "intent": "agent-orchestration",
5
+ "spec": {
6
+ "type": "flow",
7
+ "renderer": "svg",
8
+ "diagram": { "layout": "layered", "routing": "orthogonal", "grid": 8 },
9
+ "groups": [{ "id": "workers", "label": "Worker Agents", "padding": 20 }],
10
+ "nodes": [
11
+ { "id": "router", "label": "Router" },
12
+ { "id": "research", "label": "Research", "groupId": "workers" },
13
+ { "id": "writer", "label": "Writer", "groupId": "workers" },
14
+ { "id": "review", "label": "Review" }
15
+ ],
16
+ "edges": [{ "from": "router", "to": "research" }, { "from": "research", "to": "writer" }, { "from": "writer", "to": "review" }]
17
+ }
18
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "approval-process-diagram",
3
+ "version": "2.0",
4
+ "intent": "approval-process",
5
+ "spec": {
6
+ "type": "flow",
7
+ "renderer": "svg",
8
+ "diagram": { "layout": "layered", "routing": "orthogonal", "grid": 8 },
9
+ "nodes": [
10
+ { "id": "request", "label": "Request", "ports": [{ "id": "out", "side": "right" }] },
11
+ { "id": "review", "label": "Review", "ports": [{ "id": "in", "side": "left" }, { "id": "out", "side": "right" }] },
12
+ { "id": "approved", "label": "Approved", "ports": [{ "id": "in", "side": "left" }] }
13
+ ],
14
+ "edges": [{ "id": "request-review", "from": "request", "to": "review", "fromPort": "out", "toPort": "in" }]
15
+ }
16
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "responsibility-mapping-diagram",
3
+ "version": "2.0",
4
+ "intent": "responsibility",
5
+ "spec": {
6
+ "type": "swimlane",
7
+ "renderer": "svg",
8
+ "diagram": { "layout": "layered", "routing": "orthogonal", "grid": 8 },
9
+ "lanes": [{ "id": "product", "label": "Product" }, { "id": "engineering", "label": "Engineering" }],
10
+ "nodes": [{ "id": "scope", "label": "Define Scope", "laneId": "product" }, { "id": "build", "label": "Build", "laneId": "engineering" }, { "id": "accept", "label": "Accept", "laneId": "product" }],
11
+ "edges": [{ "from": "scope", "to": "build" }, { "from": "build", "to": "accept" }]
12
+ }
13
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "workflow-diagram",
3
+ "version": "2.0",
4
+ "intent": "workflow",
5
+ "spec": {
6
+ "type": "flow",
7
+ "renderer": "svg",
8
+ "diagram": { "layout": "layered", "routing": "orthogonal", "grid": 8 },
9
+ "nodes": [],
10
+ "edges": []
11
+ },
12
+ "commands": [
13
+ { "type": "layout-edit", "operations": [{ "op": "moveNode", "nodeId": "review", "position": { "x": 320, "y": 120 } }] },
14
+ { "type": "layout-edit", "operations": [{ "op": "resizeNode", "nodeId": "review", "size": { "width": 180, "height": 56 } }] },
15
+ { "type": "layout-edit", "reason": "Align selected workflow nodes", "operations": [{ "op": "alignNodes", "nodeIds": ["review", "qa"], "alignment": "left" }] },
16
+ { "type": "layout-edit", "reason": "Snap selected workflow nodes to grid", "operations": [{ "op": "snapNodes", "nodeIds": ["review", "qa"] }] }
17
+ ,{ "type": "layout-edit", "reason": "Resize the delivery group member bounds", "operations": [{ "op": "resizeGroup", "groupId": "delivery", "size": { "width": 320, "height": 180 } }] }
18
+ ]
19
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "foundational-analysis-views",
3
+ "version": "2.0",
4
+ "intentMappings": {
5
+ "composition": "column",
6
+ "distribution": "column",
7
+ "matrix": "heatmap",
8
+ "multidimensional": "radar"
9
+ },
10
+ "examples": {
11
+ "stacked": { "type": "column", "stack": "stacked", "encoding": { "x": { "field": "period" }, "y": [{ "field": "product" }, { "field": "service" }] }, "data": [] },
12
+ "donut": { "type": "pie", "innerRadius": 0.55, "data": [{ "name": "Product", "value": 60 }, { "name": "Service", "value": 40 }] },
13
+ "combo": { "type": "column", "encoding": { "x": { "field": "period" }, "y": [{ "field": "sales", "mark": "column" }, { "field": "rate", "mark": "line", "axis": "right" }] }, "data": [] },
14
+ "histogram": { "type": "column", "transform": { "type": "bin", "field": "score", "thresholds": 8 }, "encoding": { "x": { "field": "name" }, "y": { "field": "value" } }, "data": [] },
15
+ "heatmap": { "type": "heatmap", "encoding": { "x": { "field": "day" }, "y": { "field": "period" }, "color": { "field": "value" } }, "data": [] },
16
+ "radar": { "type": "radar", "indicators": [{ "name": "Quality", "field": "quality", "min": 0, "max": 100 }, { "name": "Speed", "field": "speed", "min": 0, "max": 100 }, { "name": "Experience", "field": "experience", "min": 0, "max": 100 }], "data": [] }
17
+ }
18
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "project-management-views",
3
+ "version": "2.0",
4
+ "intentMappings": {
5
+ "schedule": "gantt",
6
+ "milestone": "milestone",
7
+ "progress": "burndown",
8
+ "variance": "gantt",
9
+ "capacity": "column",
10
+ "release": "burndown",
11
+ "risk": "scatter",
12
+ "aging": "bar",
13
+ "workflow": "flow",
14
+ "responsibility": "swimlane"
15
+ },
16
+ "examples": {
17
+ "gantt": {
18
+ "type": "gantt",
19
+ "renderer": "svg",
20
+ "project": {
21
+ "overlays": {
22
+ "criticalPath": true,
23
+ "slack": true,
24
+ "baseline": true,
25
+ "actual": true,
26
+ "variance": true
27
+ },
28
+ "calendar": {
29
+ "timezone": "UTC",
30
+ "workingWeekdays": [1, 2, 3, 4, 5],
31
+ "holidays": ["2026-09-10"]
32
+ }
33
+ },
34
+ "data": [
35
+ { "id": "design", "name": "Design", "start": "2026-09-01", "end": "2026-09-05", "baselineStart": "2026-09-01", "baselineEnd": "2026-09-04", "actualStart": "2026-09-01", "actualEnd": "2026-09-05", "owner": "Alex", "progress": 100, "status": "done" }
36
+ ]
37
+ },
38
+ "timeline": { "type": "timeline", "renderer": "svg", "data": [{ "date": "2026-09-01", "title": "Kickoff" }] },
39
+ "milestone": { "type": "milestone", "renderer": "svg", "data": [{ "date": "2026-09-19", "title": "Release", "baselineDate": "2026-09-17", "actualDate": "2026-09-19" }] },
40
+ "burndown": { "type": "burndown", "renderer": "svg", "data": [{ "date": "2026-09-01", "remaining": 40 }, { "date": "2026-09-19", "remaining": 0 }] },
41
+ "capacity": { "type": "column", "renderer": "svg", "data": [{ "name": "Alex", "value": 10, "capacity": 8, "overload": 2 }] },
42
+ "risk": { "type": "scatter", "renderer": "svg", "data": [{ "name": "Vendor delay", "x": 4, "y": 5, "value": 20, "recordId": "risk-1" }] },
43
+ "aging": { "type": "bar", "renderer": "svg", "data": [{ "name": "0-7", "value": 4 }, { "name": "8-14", "value": 2 }] },
44
+ "flow": { "type": "flow", "renderer": "svg", "nodes": [{ "id": "start", "label": "Start" }, { "id": "done", "label": "Done" }], "edges": [{ "from": "start", "to": "done" }] },
45
+ "swimlane": { "type": "swimlane", "renderer": "svg", "lanes": [{ "id": "agent", "label": "Agent" }], "nodes": [{ "id": "plan", "label": "Plan", "laneId": "agent" }], "edges": [] }
46
+ }
47
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "monthly-sales-trend",
3
+ "intent": "trend",
4
+ "inputData": [
5
+ { "month": "Jan", "sales": 120 },
6
+ { "month": "Feb", "sales": 180 },
7
+ { "month": "Mar", "sales": 145 }
8
+ ],
9
+ "spec": {
10
+ "version": "2.0",
11
+ "type": "line",
12
+ "renderer": "svg",
13
+ "data": { "values": [] },
14
+ "encoding": {
15
+ "x": { "field": "month", "type": "category" },
16
+ "y": { "field": "sales", "type": "quantitative" }
17
+ },
18
+ "interaction": { "tooltip": true, "hover": true, "click": true }
19
+ },
20
+ "expected": { "chartType": "line", "dimension": "month", "measure": "sales" }
21
+ }