@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
@@ -0,0 +1,50 @@
1
+ # 视觉样式与主题指南
2
+
3
+ iChart.js 2.0 内置轻量、与 Renderer 无关的样式系统。Agent 应表达场景和数据语义,由 Runtime 解析颜色、字号、间距和标记样式,不应为每张图随意生成一套视觉配置。
4
+
5
+ ## 三层样式模型
6
+
7
+ - `mode`:`auto`、`light`、`dark`、`contrast`。
8
+ - `preset`:`auto`、`analysis`、`dashboard`、`report`、`presentation`、`project`、`diagram`。
9
+ - `palette`:`auto`、`categorical`、`sequential`、`diverging`、`status`。
10
+
11
+ 推荐默认使用 `auto`。系统根据图表家族、用户意图、数据语义和宿主明暗模式进行确定性匹配。解析结果可通过 `planStyle()`、`planChart().styleRecommendation`、`chart.getTheme()`、`chart.getState().style` 和 `chart.explain().style` 查看。
12
+
13
+ ## Agent 使用方式
14
+
15
+ ```js
16
+ const plan = planChart(rows, { intent: 'comparison', context: 'dashboard' });
17
+ const spec = {
18
+ type: plan.primary,
19
+ data: { values: rows },
20
+ theme: {
21
+ mode: 'auto',
22
+ preset: plan.styleRecommendation.preset,
23
+ palette: plan.styleRecommendation.palette
24
+ }
25
+ };
26
+ ```
27
+
28
+ 仅在用户明确要求明暗模式、展示场景或语义配色时提供显式值;用户选择始终高于自动匹配。
29
+
30
+ ## 实时切换
31
+
32
+ ```js
33
+ chart.setTheme({ mode: 'dark', preset: 'dashboard', palette: 'categorical' });
34
+ const resolved = chart.getTheme();
35
+ ```
36
+
37
+ 切换不会重建图表。`mode: 'auto'` 会跟随宿主的 `prefers-color-scheme`。Spec 中显式提供的 `colors`、`background` 和 `padding` 在切换时保持不变。
38
+
39
+ ## 配色原则
40
+
41
+ - `categorical`:不同系列或分组,同时比较建议不超过 6 色。
42
+ - `sequential`:有序数值强度,例如 Heatmap。
43
+ - `diverging`:存在有意义的中点,且数据向两侧变化。
44
+ - `status`:成功、警告、危险、信息等业务状态。
45
+ - 不只依赖颜色传达含义,应保留标签、形状、线型或文字状态。
46
+
47
+ 自定义 token 后调用 `validateThemeContrast()`;Agent 不应隐藏对比度警告。
48
+
49
+ 预览与验收:`http://localhost:3000/playground/theme-gallery.html`。
50
+
@@ -0,0 +1,79 @@
1
+ {
2
+ "version": "2.0",
3
+ "contractVersion": "1.0",
4
+ "source": "src/index.mjs#getCapabilities",
5
+ "perChartProfiles": "src/index.mjs#getChartCapability",
6
+ "agentPlanning": "src/index.mjs#planChart",
7
+ "agentExplanation": "Chart#explain",
8
+ "agentQuickstart": "docs/agent/quickstart.md",
9
+ "agentWorkflowExample": "examples/agent-workflow.mjs",
10
+ "officialSkill": "skills/ichartjs/SKILL.md",
11
+ "scenarios": {
12
+ "charting": ["line", "area", "bar", "column", "pie", "scatter", "funnel", "gauge", "heatmap", "radar"],
13
+ "project": ["gantt", "timeline", "milestone", "burndown"],
14
+ "diagram": ["flow", "swimlane"]
15
+ },
16
+ "projectIntelligence": ["variance", "capacity", "release", "risk", "aging"],
17
+ "chartModes": ["stacked", "percent-stacked", "donut", "mixed-line-column", "bin"],
18
+ "renderers": ["canvas", "svg"],
19
+ "excluded": ["map", "3d"],
20
+ "exports": ["png", "svg", "json"],
21
+ "headless": {
22
+ "preview": true,
23
+ "json": true,
24
+ "svg": true,
25
+ "png": "Node headless PNG requires the optional `canvas` npm package (createCanvas). Otherwise use chart.export({type:\"svg\"})."
26
+ },
27
+ "export": {
28
+ "types": ["png", "jpeg", "svg", "json"],
29
+ "mime": { "png": "image/png", "jpeg": "image/jpeg", "svg": "image/svg+xml", "json": "application/json" },
30
+ "browser": { "png": true, "jpeg": true, "svg": true, "json": true },
31
+ "headless": {
32
+ "png": "optional: install the `canvas` npm package for createCanvas",
33
+ "jpeg": "same as png",
34
+ "svg": true,
35
+ "json": true
36
+ },
37
+ "methods": {
38
+ "exportPNG": "chart.export({ type:\"png\" }) returns base64 data URL (browser); pass as:\"blob\" for a Blob. In Node headless either install the canvas package or fall back to SVG.",
39
+ "exportSVG": "chart.export({ type:\"svg\" }) returns the SVG string in both browser and headless; as:\"dataurl\" for embeds, as:\"blob\" for a Blob (browser).",
40
+ "exportJSON": "chart.export({ type:\"json\" }) returns pretty JSON; use as:\"object\" to get the parsed {version,spec,state}.",
41
+ "downloadPNG": "chart.downloadPNG() triggers a browser save-as dialog (filename derived from title + timestamp).",
42
+ "downloadSVG": "chart.downloadSVG() same semantics as downloadPNG but for SVG.",
43
+ "downloadJSON": "chart.downloadJSON() saves {version,spec,state} as a .json document.",
44
+ "toDataURL": "chart.toDataURL(\"image/png\"|\"image/svg+xml\") returns a data URL string.",
45
+ "toBlob": "chart.toBlob(\"image/png\"|\"image/svg+xml\") returns a Blob (browser-only)."
46
+ },
47
+ "options": { "as": ["string", "object", "dataurl", "blob"] },
48
+ "branding": "By default PNG/SVG exports include the Powered by iChart.js branding watermark. Pass branding: { enabled: false } or branding: false to remove it for white-label output."
49
+ },
50
+ "gallery": "playground/project-gallery.html",
51
+ "playgroundHome": "playground/index.html",
52
+ "agentWorkbench": "playground/agent-workbench.html",
53
+ "interactionLab": "playground/interaction-lab.html",
54
+ "accessibilityLab": "playground/accessibility-lab.html",
55
+ "performanceLab": "playground/performance-lab.html",
56
+ "businessEditingDemo": "playground/editing.html",
57
+ "diagramEditor": "playground/diagram-editor.html",
58
+ "projectIntelligenceDemo": "playground/project-intelligence.html",
59
+ "foundationalGallery": "playground/foundational-gallery.html",
60
+ "themeGallery": "playground/theme-gallery.html",
61
+ "themeGuide": "docs/agent/theme-guide.md",
62
+ "styleSystem": {
63
+ "modes": ["auto", "light", "dark", "contrast"],
64
+ "presets": ["auto", "analysis", "dashboard", "report", "presentation", "project", "diagram"],
65
+ "palettes": ["auto", "categorical", "sequential", "diverging", "status"]
66
+ },
67
+ "branding": {
68
+ "defaultEnabled": true,
69
+ "signature": "Powered by iChart.js",
70
+ "options": [
71
+ { "name": "enabled", "type": "boolean", "default": true }
72
+ ],
73
+ "notes": [
74
+ "Default signature rendered in the bottom-right corner inside the chart safe padding, 10px / font-weight 500, theme.muted color with ~0.42 opacity, decorative and non-interactive.",
75
+ "Agents MUST keep branding enabled by default; only disable when the user explicitly requests a white-label / no-brand output or already provides their own signature.",
76
+ "Short form `branding: false` and object form `branding: { enabled: false }` are both supported. Custom text, link, position, or font are intentionally NOT exposed in the current iteration."
77
+ ]
78
+ }
79
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "version": "1.0",
3
+ "source": "src/command.mjs#operationTypes",
4
+ "commands": {
5
+ "updateField": { "models": ["project-task", "timeline-event", "milestone", "burndown-sample", "flow-node", "flow-edge", "swimlane"], "previewRequired": true, "undoable": true },
6
+ "updateRecord": { "models": ["project-task", "timeline-event", "milestone", "burndown-sample", "flow-node", "flow-edge", "swimlane"], "previewRequired": true, "undoable": true },
7
+ "updateTask": { "models": ["project-task"], "previewRequired": true, "undoable": true },
8
+ "shiftTask": { "models": ["project-task"], "required": ["taskId", "days"], "previewRequired": true, "undoable": true },
9
+ "updateProgress": { "models": ["project-task"], "required": ["taskId", "progress"], "previewRequired": true, "undoable": true },
10
+ "addDependency": { "models": ["project-task"], "required": ["taskId", "dependencyId"], "previewRequired": true, "undoable": true },
11
+ "removeDependency": { "models": ["project-task"], "required": ["taskId", "dependencyId"], "previewRequired": true, "undoable": true },
12
+ "updateMilestone": { "models": ["milestone"], "required": ["recordId"], "previewRequired": true, "undoable": true },
13
+ "moveNode": { "models": ["flow-node"], "required": ["nodeId", "position"], "previewRequired": true, "undoable": true },
14
+ "moveNodes": { "models": ["flow-node"], "required": ["nodeIds", "delta"], "previewRequired": true, "undoable": true },
15
+ "moveNodeToLane": { "models": ["flow-node"], "required": ["nodeId", "laneId"], "previewRequired": true, "undoable": true },
16
+ "resizeNode": { "models": ["flow-node"], "required": ["nodeId", "size"], "previewRequired": true, "undoable": true },
17
+ "alignNodes": { "models": ["flow-node"], "required": ["nodeIds", "alignment"], "previewRequired": true, "undoable": true },
18
+ "snapNodes": { "models": ["flow-node"], "required": ["nodeIds"], "previewRequired": true, "undoable": true },
19
+ "moveGroup": { "models": ["flow-node"], "required": ["groupId", "delta"], "previewRequired": true, "undoable": true },
20
+ "resizeGroup": { "models": ["flow-node"], "required": ["groupId", "size"], "previewRequired": true, "undoable": true },
21
+ "assignNodesToGroup": { "models": ["flow-node"], "required": ["nodeIds", "groupId"], "previewRequired": true, "confirmationRequired": true, "undoable": true },
22
+ "duplicateGroup": { "models": ["flow-node", "flow-edge"], "required": ["groupId"], "previewRequired": true, "confirmationRequired": true, "undoable": true },
23
+ "deleteGroup": { "models": ["flow-node", "flow-edge"], "required": ["groupId", "policy"], "previewRequired": true, "confirmationRequired": true, "undoable": true },
24
+ "updateEdge": { "models": ["flow-edge"], "required": ["edgeId", "changes"], "previewRequired": true, "undoable": true },
25
+ "addEdge": { "models": ["flow-edge"], "required": ["from", "to"], "previewRequired": true, "confirmationRequired": true, "undoable": true },
26
+ "toggleGroupCollapse": { "models": ["flow-node"], "required": ["groupId"], "previewRequired": true, "confirmationRequired": true, "undoable": true },
27
+ "duplicateSelection": { "models": ["flow-node", "flow-edge"], "required": ["nodeIds"], "previewRequired": true, "confirmationRequired": true, "undoable": true },
28
+ "pasteSelection": { "models": ["flow-node", "flow-edge"], "required": ["nodes"], "previewRequired": true, "confirmationRequired": true, "undoable": true }
29
+ }
30
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "1.0",
3
+ "source": "src/schema.mjs#getBusinessSchema",
4
+ "models": {
5
+ "project-task": { "key": "id", "required": ["id", "name", "start", "end"], "editable": ["name", "start", "end", "progress", "status", "dependencies"] },
6
+ "timeline-event": { "key": "id", "required": ["id", "title", "date"], "editable": ["title", "date", "description", "status"] },
7
+ "milestone": { "key": "id", "required": ["id", "title", "date"], "editable": ["title", "date", "status"] },
8
+ "burndown-sample": { "key": "id", "required": ["id", "date", "remaining"], "editable": ["date", "remaining", "scopeChange"] },
9
+ "flow-node": { "key": "id", "required": ["id", "label"], "editable": ["label", "position", "size", "laneId", "description", "status"] },
10
+ "flow-edge": { "key": "id", "required": ["id", "from", "to"], "editable": ["from", "to", "label"] },
11
+ "swimlane": { "key": "id", "required": ["id", "label"], "editable": ["label"] }
12
+ }
13
+ }
@@ -0,0 +1,94 @@
1
+ import { pathToFileURL } from 'node:url';
2
+ import {
3
+ createChart,
4
+ getCapabilities,
5
+ getChartCapability,
6
+ inspectData,
7
+ planChart,
8
+ recommend,
9
+ validateSpec
10
+ } from '@taylorwong/ichartjs';
11
+ export const sampleRows = [
12
+ { id: 'jan', month: 'Jan', revenue: 120, cost: 82 },
13
+ { id: 'feb', month: 'Feb', revenue: 148, cost: 91 },
14
+ { id: 'mar', month: 'Mar', revenue: 136, cost: 88 },
15
+ { id: 'apr', month: 'Apr', revenue: 176, cost: 105 }
16
+ ];
17
+
18
+ function buildCandidate(rows, plan, renderer) {
19
+ const measureFields = [plan.suggestedEncodings.measure, plan.suggestedEncodings.secondaryMeasure].filter(Boolean);
20
+ return {
21
+ type: plan.primary,
22
+ renderer,
23
+ data: { values: rows },
24
+ title: { text: `Agent plan: ${plan.intent}`, subtitle: `confidence ${plan.confidence}` },
25
+ encoding: {
26
+ x: { field: plan.suggestedEncodings.dimension, type: 'category' },
27
+ y: measureFields.length === 1 ? { field: measureFields[0], type: 'quantitative' } : measureFields.map(field => ({ field, type: 'quantitative' }))
28
+ },
29
+ interaction: { tooltip: true, hover: true, keyboard: true },
30
+ accessibility: { enabled: true },
31
+ theme: {
32
+ mode: 'auto',
33
+ preset: plan.styleRecommendation.preset,
34
+ palette: plan.styleRecommendation.palette
35
+ }
36
+ };
37
+ }
38
+
39
+ export function runAgentWorkflow(rows, options = {}) {
40
+ const intent = options.intent || 'trend';
41
+ const renderer = options.renderer || 'svg';
42
+ const capabilities = getCapabilities();
43
+ const inspection = inspectData(rows);
44
+ const plan = planChart(rows, { intent, renderer, context: options.context || 'analysis' });
45
+
46
+ if (plan.requiredFields.length) {
47
+ return { ok: false, stage: 'planning', capabilitiesContract: capabilities.contractVersion, inspection, plan };
48
+ }
49
+
50
+ const candidate = buildCandidate(rows, plan, renderer);
51
+ const validation = validateSpec(candidate);
52
+ if (!validation.valid) {
53
+ return { ok: false, stage: 'validation', capabilitiesContract: capabilities.contractVersion, inspection, plan, candidate, validation };
54
+ }
55
+
56
+ const chart = createChart(validation.spec);
57
+ try {
58
+ const explanation = chart.explain();
59
+ const state = chart.getState();
60
+ return {
61
+ ok: true,
62
+ stage: 'complete',
63
+ capabilitiesContract: capabilities.contractVersion,
64
+ inspection,
65
+ plan,
66
+ capability: getChartCapability(plan.primary),
67
+ validation,
68
+ explanation,
69
+ state,
70
+ selfCheck: {
71
+ chartDeclared: capabilities.chartTypes.includes(plan.primary),
72
+ recordIdsPreserved: rows.every(row => explanation.lineage.recordIds.includes(row.id)),
73
+ warningsVisible: plan.warnings.every(warning => state.warnings.some(item => item.code === warning.code)),
74
+ styleExplained: explanation.style?.preset === plan.styleRecommendation.preset
75
+ },
76
+ export: JSON.parse(chart.export({ type: 'json' }))
77
+ };
78
+ } finally {
79
+ chart.destroy();
80
+ }
81
+ }
82
+
83
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
84
+ const result = runAgentWorkflow(sampleRows);
85
+ console.log(JSON.stringify({
86
+ ok: result.ok,
87
+ stage: result.stage,
88
+ chartType: result.plan.primary,
89
+ confidence: result.plan.confidence,
90
+ encodings: result.explanation?.encodings,
91
+ warnings: result.state?.warnings || result.plan.warnings,
92
+ selfCheck: result.selfCheck
93
+ }, null, 2));
94
+ }
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@taylorwong/ichartjs",
3
+ "version": "2.0.1",
4
+ "description": "Agent-first, renderer-independent charting and project visualization runtime",
5
+ "type": "module",
6
+ "main": "./src/index.mjs",
7
+ "module": "./src/index.mjs",
8
+ "browser": "./src/index.mjs",
9
+ "types": "./types/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./types/index.d.ts",
13
+ "import": "./src/index.mjs",
14
+ "default": "./src/index.mjs"
15
+ },
16
+ "./capabilities.json": "./docs/manifests/capabilities.json",
17
+ "./recipes/*": "./agent-recipes/*.json",
18
+ "./package.json": "./package.json"
19
+ },
20
+ "files": [
21
+ "src/",
22
+ "types/",
23
+ "docs/agent/",
24
+ "docs/manifests/",
25
+ "agent-recipes/",
26
+ "examples/",
27
+ "skills/ichartjs/",
28
+ "README.md",
29
+ "CHANGELOG.md"
30
+ ],
31
+ "sideEffects": false,
32
+ "publishConfig": {
33
+ "access": "public",
34
+ "registry": "https://registry.npmjs.org/"
35
+ },
36
+ "scripts": {
37
+ "test": "node --test tests/*.test.mjs",
38
+ "check": "for file in src/*.mjs; do node --check \"$file\" || exit 1; done",
39
+ "docs:check": "node scripts/check-agent-docs.mjs",
40
+ "example:agent": "node examples/agent-workflow.mjs",
41
+ "playground": "node scripts/serve-playground.mjs",
42
+ "agent:check": "npm run docs:check && npm run check && npm test",
43
+ "rc:check": "npm test && npm run check && git diff --check"
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/wanghetommy/ichartjs.git"
48
+ },
49
+ "homepage": "https://github.com/wanghetommy/ichartjs#readme",
50
+ "bugs": "https://github.com/wanghetommy/ichartjs/issues",
51
+ "keywords": ["chart", "visualization", "agent", "svg", "canvas", "gantt", "diagram"],
52
+ "engines": { "node": ">=18" },
53
+ "author": "taylorwong <wanghetommy@gmail.com>",
54
+ "license": "Apache-2.0"
55
+ }
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: ichartjs
3
+ description: Plan, validate, render, explain, and safely edit iChart.js visualizations from tabular, project, or diagram data. Use when Codex needs to choose a chart, create or repair an iChart.js Spec, build a browser preview, produce Gantt or project analytics, create Flow or Swimlane diagrams, or verify visualization accessibility, diagnostics, lineage, and runtime state.
4
+ ---
5
+
6
+ # iChart.js
7
+
8
+ Use the public Agent contract as the source of truth. Do not infer capabilities from renderer internals or duplicate chart-selection logic in generated code.
9
+
10
+ ## Source and Runtime Setup
11
+
12
+ - Official repository: `https://github.com/wanghetommy/ichartjs`
13
+ - Official Skill source: `https://github.com/wanghetommy/ichartjs/tree/master/skills/ichartjs`
14
+ - Supported Skill hosts include Codex, WorkBuddy, and other Agent Skills-compatible environments.
15
+
16
+ The Skill is a workflow adapter, not the chart runtime. If the current JavaScript or TypeScript project does not already depend on iChart.js, install the matching runtime from GitHub:
17
+
18
+ ```bash
19
+ npm install @taylorwong/ichartjs@^2
20
+ ```
21
+
22
+ Do not install the unscoped npm registry package named `ichartjs`; it is currently a security holding package and is not this project.
23
+
24
+ ## Workflow
25
+
26
+ 1. Locate the package or repository root. Read `docs/agent/quickstart.md` when available.
27
+ 2. Call `getCapabilities()` before selecting a chart or interaction.
28
+ 3. Call `inspectData()` and preserve stable record IDs.
29
+ 4. Call `planChart(data, { intent, renderer, context })` and inspect the complete result, including `styleRecommendation`.
30
+ 5. Stop when `requiredFields` is non-empty; request data or explain a supported alternative.
31
+ 6. Build a JSON-serializable Spec using `suggestedEncodings`, the selected capability, and an applicable recipe.
32
+ 7. Call `validateSpec()` before rendering. Repair only from structured diagnostics.
33
+ 8. Call `createChart()` only after validation succeeds.
34
+ 9. Self-check with `chart.explain()`, `chart.getState()`, and JSON export.
35
+ 10. Provide an exact preview URL or artifact path and report assumptions, warnings, and deferred checks.
36
+ 11. Prefer `theme: { mode: 'auto', preset, palette }`; preserve explicit user style choices and use `chart.setTheme()` for live switching.
37
+
38
+ Use `ichartjs` for package imports. Use `examples/agent-workflow.mjs` as the executable baseline when working in the repository.
39
+
40
+ ## Task Routing
41
+
42
+ - For standard data analysis, read `references/chart-selection.md` and use foundational recipes.
43
+ - For Gantt, Timeline, Milestone, Burndown, capacity, release, risk, or aging, use project capabilities and `agent-recipes/project-management.json`.
44
+ - For Flow or Swimlane, preserve node, edge, lane, group, and port IDs; use diagram recipes and validated edit commands.
45
+ - For business edits, preview first, preserve the preview ID and revision, require confirmation when declared, then commit or reject atomically.
46
+ - For browser deliverables, start `npm run playground` and return the exact maintained Playground URL.
47
+
48
+ ## Guardrails
49
+
50
+ - Never invent fields, units, dates, dependencies, calendar rules, domains, or forecast confidence.
51
+ - Never silently drop validation errors, warnings, assumptions, normalizations, or unsupported requests.
52
+ - Avoid Pie for high-cardinality categories; prefer Bar for comparison.
53
+ - Require explicit Radar domains when units differ.
54
+ - Distinguish missing Heatmap values from zero.
55
+ - Use categorical, sequential, diverging, or status palettes by data semantics; do not invent arbitrary color sets or rely on color alone.
56
+ - Surface theme contrast diagnostics and high-cardinality color warnings.
57
+ - Do not generate Map or 3D Specs unless capabilities explicitly add them.
58
+ - Prefer SVG for accessibility, DOM interaction, and diagram editing; prefer Canvas for larger mark counts when supported.
59
+ - Destroy replaced charts and verify lifecycle cleanup.
60
+
61
+ ## Deliverable
62
+
63
+ Return:
64
+
65
+ - the selected chart and reasons;
66
+ - the validated Spec or structured repair request;
67
+ - assumptions, warnings, and unsupported requests;
68
+ - explanation lineage and runtime self-check;
69
+ - changed files when coding;
70
+ - the exact preview URL and acceptance actions.
71
+
72
+ Read `references/agent-contract.md` for the required API sequence and response checklist. Read `references/chart-selection.md` only when selecting or challenging a chart type.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "iChart.js Agent Charting"
3
+ short_description: "Plan, validate, render, and explain iChart.js charts"
4
+ default_prompt: "Use $ichartjs to inspect this dataset, choose a chart, validate the Spec, and provide a preview path."
@@ -0,0 +1,39 @@
1
+ # Agent Contract
2
+
3
+ ## Required sequence
4
+
5
+ ```text
6
+ getCapabilities → inspectData → planChart → build Spec → validateSpec → createChart → explain/getState/export → destroy
7
+ ```
8
+
9
+ ## Public APIs
10
+
11
+ - `getCapabilities()`: global and per-chart discoverability.
12
+ - `getChartCapability(type)`: required roles, interactions, renderers, features, exports, and limits.
13
+ - `inspectData(input)`: field roles, identifiers, cardinality, missingness, temporal coverage, and warnings.
14
+ - `planChart(input, options)`: primary type, alternatives, confidence, reasons, required fields, suggested encodings, assumptions, warnings, unsupported requests, and next actions.
15
+ - `validateSpec(spec)`: errors, warnings, normalizations, and normalized Spec.
16
+ - `createChart(spec)`: headless or mounted chart lifecycle.
17
+ - `chart.explain()`: semantics, encodings, interactions, lineage, warnings, and accessibility summary.
18
+ - `chart.getState()`: renderer, dimensions, warnings, assumptions, selection, view, project analytics, and linked state.
19
+ - `chart.export({ type: 'json' })`: JSON-safe Spec and state.
20
+
21
+ ## Stop conditions
22
+
23
+ Do not render when:
24
+
25
+ - `plan.requiredFields` is non-empty;
26
+ - `validateSpec().valid` is false;
27
+ - the requested chart, renderer, interaction, or export is not declared;
28
+ - required project dates, diagram endpoints, ports, lanes, or business schema rules are invalid.
29
+
30
+ ## Self-check
31
+
32
+ Verify that:
33
+
34
+ - the chosen type exists in `getCapabilities().chartTypes`;
35
+ - validation passed without ignored errors;
36
+ - explanation lineage preserves stable source IDs;
37
+ - warnings and assumptions are visible in the response;
38
+ - the preview uses a maintained URL;
39
+ - replaced charts are destroyed.
@@ -0,0 +1,22 @@
1
+ # Chart Selection
2
+
3
+ | Intent | Preferred type | Important guardrail |
4
+ | --- | --- | --- |
5
+ | Trend or time series | Line | Require an ordered or temporal dimension. |
6
+ | Cumulative trend | Area | Use stacking only for meaningful additive measures. |
7
+ | Category comparison or ranking | Bar | Prefer for long labels and negative values. |
8
+ | Compact comparison or histogram | Column | Use the bin transform for histogram workflows. |
9
+ | Part-to-whole | Pie with optional `innerRadius` | Keep category count low and require a positive total. |
10
+ | Relationship | Scatter | Require two quantitative measures. |
11
+ | Conversion stages | Funnel | Preserve stage order. |
12
+ | Single bounded KPI | Gauge | Declare the domain. |
13
+ | Matrix | Heatmap | Distinguish missing cells from zero. |
14
+ | Multidimensional profile | Radar | Require at least three explicit indicator domains. |
15
+ | Schedule and dependency analysis | Gantt | Require stable IDs, dates, and explicit calendar assumptions. |
16
+ | Events | Timeline | Require valid dates and labels. |
17
+ | Delivery checkpoints | Milestone | Keep baseline and actual dates distinct. |
18
+ | Remaining work | Burndown | Surface scope changes and forecast assumptions. |
19
+ | Process | Flow | Preserve node and edge IDs; validate endpoints and ports. |
20
+ | Responsibility | Swimlane | Require valid lane membership. |
21
+
22
+ Always prefer `planChart()` over this table when runtime capability output is available. Treat alternatives as tradeoffs, not automatic fallbacks.