@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.
- package/CHANGELOG.md +13 -0
- package/README.md +11 -4
- package/docs/agent/README.md +3 -1
- package/docs/agent/coding-agent-integration.md +6 -2
- package/docs/agent/development/iteration-11.md +44 -0
- package/docs/agent/development/iteration-12.md +101 -0
- package/docs/agent/development/roadmap.md +29 -3
- package/docs/agent/development-guide.md +1 -1
- package/docs/agent/diagram-scenario.md +39 -11
- package/docs/agent/editing-contract.md +5 -0
- package/docs/agent/frontend-integration.md +1 -1
- package/docs/agent/runtime-contract.md +11 -1
- package/docs/agent/theme-guide.md +63 -0
- package/docs/agent/usage-scenarios.md +40 -1
- package/docs/agent/zh-CN/README.md +1 -1
- package/docs/agent/zh-CN/coding-agent-integration.md +6 -2
- package/docs/agent/zh-CN/diagram-scenario.md +32 -3
- package/docs/agent/zh-CN/editing-contract.md +2 -0
- package/docs/agent/zh-CN/frontend-integration.md +1 -1
- package/docs/agent/zh-CN/iteration-12.md +98 -0
- package/docs/agent/zh-CN/runtime-contract.md +3 -1
- package/docs/agent/zh-CN/theme-guide.md +63 -0
- package/docs/agent/zh-CN/usage-scenarios.md +40 -1
- package/docs/manifests/capabilities.json +37 -2
- package/docs/manifests/commands.json +10 -9
- package/docs/manifests/schemas.json +5 -2
- package/package.json +1 -1
- package/skills/ichartjs/SKILL.md +11 -2
- package/src/capabilities.mjs +65 -8
- package/src/charts.mjs +127 -44
- package/src/command.mjs +4 -3
- package/src/diagram-interaction.mjs +55 -11
- package/src/diagram.mjs +149 -36
- package/src/edit-controller.mjs +6 -3
- package/src/edit.mjs +17 -7
- package/src/index.mjs +68 -17
- package/src/layout.mjs +39 -0
- package/src/preferences-ui.mjs +135 -0
- package/src/preferences.mjs +194 -0
- package/src/project.mjs +64 -24
- package/src/renderer.mjs +2 -2
- package/src/scene.mjs +32 -1
- package/src/schema.mjs +7 -2
- package/src/spec.mjs +10 -4
- package/src/theme.mjs +1 -1
- package/types/index.d.ts +39 -3
|
@@ -6,10 +6,39 @@
|
|
|
6
6
|
|
|
7
7
|
- `flow`:节点和边组成的流程图。
|
|
8
8
|
- `swimlane`:带责任泳道的流程图。
|
|
9
|
+
- `architecture`:带可选层和边界的业务、数据或技术架构图。
|
|
10
|
+
- `mindmap`:以树形或放射布局呈现想法层级的思维导图。
|
|
11
|
+
|
|
12
|
+
架构图和思维导图都属于结构化图,但不能混用:架构图表达明确的领域或系统关系,思维导图表达想法层级。
|
|
13
|
+
|
|
14
|
+
思维导图建议使用简洁的父子数据:
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
{
|
|
18
|
+
type: 'mindmap',
|
|
19
|
+
nodes: [
|
|
20
|
+
{ id: 'root', label: '发布计划' },
|
|
21
|
+
{ id: 'scope', label: '范围', parentId: 'root' },
|
|
22
|
+
{ id: 'risk', label: '风险', parentId: 'root' }
|
|
23
|
+
],
|
|
24
|
+
diagram: { mode: 'mindmap', layout: 'tree', routing: 'curved', curveTension: 0.4 }
|
|
25
|
+
}
|
|
26
|
+
```
|
|
9
27
|
|
|
10
28
|
## 当前能力
|
|
11
29
|
|
|
12
|
-
已支持节点、边、泳道、Group、Port
|
|
30
|
+
已支持节点、边、泳道、Group、Port、四种布局、三种路由、Mindmap 三次贝塞尔曲线、节点拖动、多选、对齐、网格吸附、键盘移动、Copy/Paste、Group 折叠展开、Port 键盘连线、边选择、折点/正交线段手柄、持久化 `waypoints`、边删除和 Undo/Redo。
|
|
31
|
+
|
|
32
|
+
导航和编辑能力默认关闭。普通图表保持静态,缩放、平移、框选、节点拖动、线段拖动、Port 连线和结构编辑必须由宿主显式开启:
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
interaction: { zoom: true, pan: true, drag: true, edgeDrag: true, portConnect: true },
|
|
36
|
+
editing: { enabled: true, allowDelete: true, allowStructuralChanges: true }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Canvas 与 SVG 共用 Scene Graph 命中、`waypoints`、命令、历史和交互行为,不提供渲染器专属编辑能力。
|
|
40
|
+
|
|
41
|
+
Mindmap 默认使用曲线父子连线。`diagram.curveTension` 支持 `0.2` 到 `0.8`;显式边可以覆盖 `routing` 或 `curveTension`。存在 `waypoints` 时优先使用人工折线,当前不支持直接拖动贝塞尔控制点。
|
|
13
42
|
|
|
14
43
|
当前限制:
|
|
15
44
|
|
|
@@ -22,7 +51,7 @@
|
|
|
22
51
|
1. 为节点和边分配稳定 ID。
|
|
23
52
|
2. 使用 `validateDiagram(spec)` 检查端点、Port、Group、Lane 和布局。
|
|
24
53
|
3. 使用 `createChart(spec)` 创建图表。
|
|
25
|
-
4. 使用 `moveNodes`、`alignNodes`、`snapNodes` 等命令编辑。
|
|
54
|
+
4. 使用 `moveNodes`、`alignNodes`、`snapNodes`、`updateEdge`、`removeEdge` 等命令编辑。
|
|
26
55
|
5. 编辑遵循 `editing-contract.md` 的 Preview/Confirm/Commit 流程。
|
|
27
56
|
|
|
28
57
|
## 开发位置与验收
|
|
@@ -34,4 +63,4 @@
|
|
|
34
63
|
- 专用 Demo:`playground/diagram-editor.html`
|
|
35
64
|
- 全量 Gallery:`playground/project-gallery.html`
|
|
36
65
|
|
|
37
|
-
节点移动后必须验证边、箭头和标签跟随;同时检查 Canvas 与 SVG
|
|
66
|
+
节点移动后必须验证边、箭头和标签跟随;同时检查 Canvas 与 SVG 的边命中、手柄拖动、waypoint 持久化、键盘和导出一致性。
|
|
@@ -23,5 +23,7 @@ const result = chart.applyEdit(command, { preview, confirmed: true, source: 'age
|
|
|
23
23
|
- 默认需要 Host 确认;确认不等同于授权。
|
|
24
24
|
- 成功提交产生 ChangeSet、审计信息、revision 和 Undo 历史。
|
|
25
25
|
- 外部持久化、权限和认证由 Host 应用负责。
|
|
26
|
+
- 指针导航和编辑默认关闭。`editing.enabled` 授权编辑事务;`interaction.drag`、`interaction.edgeDrag`、`interaction.portConnect` 分别控制直接操作 UI。
|
|
27
|
+
- Diagram 边通过 JSON-safe 的 `waypoints` 持久化;路径更新使用 `updateEdge`,删除使用 `removeEdge`,并要求结构编辑权限。
|
|
26
28
|
|
|
27
29
|
Schema、命令、Preview/Commit、事务和历史的实现分别位于 `src/schema.mjs`、`src/command.mjs`、`src/edit.mjs`、`src/edit-controller.mjs` 和 `src/history.mjs`。
|
|
@@ -6,7 +6,7 @@ iChart.js 应作为普通 JavaScript UI 组件运行在浏览器应用中。数
|
|
|
6
6
|
npm install @taylorwong/ichartjs@^2
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
无法访问 npm Registry 的环境请用 GitHub 源作为后备:`npm install github:wanghetommy/ichartjs#v2.0.
|
|
9
|
+
无法访问 npm Registry 的环境请用 GitHub 源作为后备:`npm install github:wanghetommy/ichartjs#v2.0.7`。
|
|
10
10
|
|
|
11
11
|
```js
|
|
12
12
|
import { createChart } from '@taylorwong/ichartjs';
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Iteration 12:结构化图——架构图与思维导图
|
|
2
|
+
|
|
3
|
+
Iteration 12 在 Flow/Swimlane 现有 Diagram Runtime 上增加两种结构化图模式。架构图和思维导图共用节点、边、布局、交互、导出和 Agent 契约,不新增第二套渲染器。
|
|
4
|
+
|
|
5
|
+
## 12A:共享结构化图模型
|
|
6
|
+
|
|
7
|
+
- 复用稳定节点 ID、边、Group、Port、位置、尺寸、路由、选择、键盘导航、历史、Canvas/SVG 渲染以及 JSON/SVG/PNG 导出。
|
|
8
|
+
- 将 `diagram.mode` 归一化为 `process`、`architecture` 或 `mindmap`。
|
|
9
|
+
- 思维导图可以从 `node.parentId` 推导父子边,同时保留显式边。
|
|
10
|
+
- 校验缺失父节点、自引用、重复 ID、无效层引用和思维导图循环。
|
|
11
|
+
- Agent 统一使用 `validateDiagram()` 作为校验入口。
|
|
12
|
+
|
|
13
|
+
## 12B:架构图模式
|
|
14
|
+
|
|
15
|
+
- 使用 `type: 'architecture'` 表达业务架构、数据架构和技术架构。
|
|
16
|
+
- 使用 `layers` 表达稳定的架构分层。
|
|
17
|
+
- 使用 `boundaries` 表达领域、系统、平台或上下文边界,并支持 `nodeIds`、标签、边距和颜色。
|
|
18
|
+
- 普通边表达依赖、实现、持久化、发布等关系;Runtime 不擅自推断业务语义。
|
|
19
|
+
- 有明确位置时保留手工布局,否则使用确定性的分层布局。
|
|
20
|
+
|
|
21
|
+
## 12C:思维导图模式
|
|
22
|
+
|
|
23
|
+
- 使用 `type: 'mindmap'` 和 `parentId` 表达简洁的 Agent 友好层级。
|
|
24
|
+
- 支持确定性的 `tree` 和 `radial` 布局。
|
|
25
|
+
- 使用现有 Diagram 模型表达根节点和分支强调,不新增独立编辑模型。
|
|
26
|
+
- 保留稳定 ID 和父引用,Agent 可以只更新一个分支。
|
|
27
|
+
|
|
28
|
+
## 12D:Agent 契约与 Schema
|
|
29
|
+
|
|
30
|
+
- 在 `getCapabilities()`、`planChart()`、图表能力、TypeScript 声明和 manifest 中暴露 `architecture`、`mindmap`。
|
|
31
|
+
- 增加 `architecture-node`、`architecture-edge`、`mindmap-node` Schema。
|
|
32
|
+
- 对层、边界和父节点语义返回 assumptions 与结构化诊断,不静默猜测。
|
|
33
|
+
- 两者都归入 `diagram` 家族,仅在 architecture、hierarchy、brainstorm 等意图下推荐。
|
|
34
|
+
|
|
35
|
+
## 12E:Playground 与文档
|
|
36
|
+
|
|
37
|
+
- 在 `playground/project-gallery.html` 增加 Architecture 和 Mindmap 示例。
|
|
38
|
+
- 要区分:架构图表达领域/系统结构,思维导图表达想法层级;思维导图不默认等同于架构图。
|
|
39
|
+
- 执行 `npm run playground`,打开 `http://localhost:3000/playground/project-gallery.html`,搜索 `Architecture` 或 `Mindmap`。
|
|
40
|
+
|
|
41
|
+
## 12F:Canvas/SVG 一致的线段编辑
|
|
42
|
+
|
|
43
|
+
线段直接编辑必须是与渲染器无关的 Diagram 能力。可以先用 SVG 验证交互体验,但 Canvas 与 SVG 必须提供相同的公共操作、编辑语义、持久化数据、键盘行为和最终验收状态。只要任一渲染器仍为只读或能力缩水,12F 就不算完成。
|
|
44
|
+
|
|
45
|
+
Runtime 默认状态必须静态、安全,不产生意外的视图或结构变化。缩放、平移、框选、节点拖动、线段拖动、端口连线和结构命令默认全部关闭,必须由宿主显式开启。Agent 编辑继续使用经过校验的预览/提交契约,不得隐式开启页面中的指针编辑能力。
|
|
46
|
+
|
|
47
|
+
### 第一阶段:边命中与选择
|
|
48
|
+
|
|
49
|
+
- 增加基于几何距离的边命中算法和宽容的交互容差,不再依赖 Scene Node 的矩形 `bounds`。
|
|
50
|
+
- Flow、Swimlane、Architecture、Mindmap 中的边都可选择,但不影响普通 Line 等数据图表的折线交互。
|
|
51
|
+
- Canvas 与 SVG 一致支持选中、Hover、焦点、删除、Escape 和键盘遍历状态。
|
|
52
|
+
- 命中检测放在共享 Scene Graph 中;SVG 可以使用透明粗描边优化 DOM 交互,但不能以 SVG DOM 作为唯一事实来源。
|
|
53
|
+
- 通过 `getCapabilities()` 明确暴露边选择和边编辑能力。
|
|
54
|
+
- 默认图表 Spec 必须关闭导航与编辑;Gallery 和只读嵌入页面不能隐式开启这些能力。
|
|
55
|
+
|
|
56
|
+
### 第二阶段:折点与线段手柄
|
|
57
|
+
|
|
58
|
+
- 仅在编辑模式选中边后显示折点手柄和线段中点手柄。
|
|
59
|
+
- 拖动折点只更新一个 waypoint;拖动正交线段中点只移动对应的水平或垂直线段。
|
|
60
|
+
- 使用不可见的扩大命中区域和最小触控尺寸,让细线易于操作,同时不改变可见线宽。
|
|
61
|
+
- 复用共享编辑控制器的预览、确认、提交、撤销、重做和审计能力。
|
|
62
|
+
- 可以先在 SVG 中验证交互,但不能发布渲染器特有的公共行为。
|
|
63
|
+
|
|
64
|
+
### 第三阶段:人工路由持久化
|
|
65
|
+
|
|
66
|
+
- 在边契约中增加 JSON-safe 的 `waypoints`,继续使用稳定 edge ID。
|
|
67
|
+
- Canvas、SVG、JSON 导出、SVG/PNG 导出、复制粘贴、复制和 Agent 编辑均使用同一 waypoint 模型。
|
|
68
|
+
- 路由优先级定义为:存在显式 waypoints 时优先使用,否则执行自动避障路由。
|
|
69
|
+
- 节点移动后尽量保留有效人工线段,修复无效的端点线段;人工路径不可用时回退到确定性的自动路由。
|
|
70
|
+
- Agent 通过经过校验的 `updateEdge` 操作更新路径,不增加渲染器专属命令。
|
|
71
|
+
|
|
72
|
+
### 12F 验收
|
|
73
|
+
|
|
74
|
+
- Canvas 与 SVG 通过同一套边命中、选择、手柄拖动、持久化、撤销/重做、键盘和导出测试。
|
|
75
|
+
- Flow、Swimlane、Architecture、Mindmap 共用同一套边编辑契约和交互实现。
|
|
76
|
+
- 细线在不改变可见宽度的情况下仍容易选择。
|
|
77
|
+
- 人工 waypoints 在重绘、切换渲染器、序列化、导出和重新创建图表后保持不变。
|
|
78
|
+
- 节点移动后边不能穿过节点;无效人工路径必须被修复或确定性地重新路由。
|
|
79
|
+
- 在双渲染器一致性全部通过前,Capabilities 应报告线段拖动不可用,而不是只声明 SVG 支持。
|
|
80
|
+
- 默认图表保持静态:缩放、平移、框选、节点拖动、线段拖动、端口连线和结构编辑只有在宿主显式配置后才启用。
|
|
81
|
+
|
|
82
|
+
## 12G:Mindmap 贝塞尔曲线
|
|
83
|
+
|
|
84
|
+
- Mindmap 父子连线默认使用 `routing: 'curved'`;Flow、Swimlane、Architecture 继续默认使用正交路由。
|
|
85
|
+
- `curved` 在 Canvas 与 SVG 中都渲染为一段真实三次贝塞尔曲线,不再是四点折线。
|
|
86
|
+
- `diagram.curveTension` 和单边 `curveTension` 支持 `0.2` 到 `0.8`,默认值为 `0.4`。
|
|
87
|
+
- 标签位于贝塞尔中点,箭头根据终点切线定向;共享 Scene Graph 通过曲线采样保持 Canvas/SVG 命中一致。
|
|
88
|
+
- 曲线穿过其他节点时,确定性回退到具备避障能力的正交路由。
|
|
89
|
+
- 显式 `waypoints` 优先并继续使用人工折线。暂不提供贝塞尔控制点拖动;节点移动后自动重新计算曲线。
|
|
90
|
+
|
|
91
|
+
## 验收
|
|
92
|
+
|
|
93
|
+
- `npm run agent:check` 通过,公开图表类型为 18 个,业务 Schema 为 10 个。
|
|
94
|
+
- Architecture 在 SVG 和 Canvas 下均能显示层、边界、节点和依赖边。
|
|
95
|
+
- Mindmap 能校验父引用与循环,生成稳定父子边,并确定性渲染 tree/radial 布局。
|
|
96
|
+
- 既有 Flow、Swimlane 测试和预览不回归。
|
|
97
|
+
- Iteration 12F 只有在 Canvas 与 SVG 具备一致的线段编辑能力后才通过验收。
|
|
98
|
+
- Iteration 12G 只有在 Canvas、浏览器 SVG 与 Headless SVG 都输出真实三次贝塞尔路径,并保持默认静态交互时才通过验收。
|
|
@@ -10,6 +10,8 @@ getCapabilities → inspectData → planChart → 创建 Spec → validateSpec
|
|
|
10
10
|
|
|
11
11
|
Agent 应优先使用 `getCapabilities()`,不要硬编码未声明的图表类型或操作。
|
|
12
12
|
|
|
13
|
+
图表创建后的视觉设置使用 `getPreferenceCapabilities(chartType, { locale }) → chart.getPreferences() → validatePreferences(patch) → chart.setPreferences(patch, { source: 'agent' }) → chart.getState().preferences`。这样 Agent 与内置设置菜单始终使用同一份白名单契约。
|
|
14
|
+
|
|
13
15
|
Iteration 8 通过 `getChartCapability(type)` 提供逐图表能力档案,包括必需数据角色、支持的交互、Renderer、功能状态、导出和建议限制。Agent 不应猜测未声明能力。
|
|
14
16
|
|
|
15
17
|
`planChart(data, { intent, renderer })` 返回版本化规划结果:主选图表、备选项、置信度、原因、缺失字段、建议编码、假设、警告、不支持请求和安全下一步。规划不会虚构业务含义、单位、日期或缺失字段。
|
|
@@ -80,6 +82,6 @@ iChart.js 导出采用**双底层单源架构**,所有产物共享 `buildScene
|
|
|
80
82
|
- `DOWNLOAD_HEADLESS`:`chart.download*()` 仅在浏览器有 DOM 时可用,无头用 `export`。
|
|
81
83
|
- `EXPORT_TYPE_UNSUPPORTED`:不支持的导出类型。
|
|
82
84
|
|
|
83
|
-
公共 API:`inspectData`、`normalizeData`、`planChart`、`recommend`、`validateSpec`、`createChart`、`getCapabilities`、`getChartCapability`、`chart.describe`、`chart.explain`、`chart.getState`、`chart.export`、`chart.exportAsync`、`chart.toDataURL`、`chart.toBlob`、`chart.download`、`chart.downloadPNG`、`chart.downloadSVG`、`chart.downloadJSON`。
|
|
85
|
+
公共 API:`inspectData`、`normalizeData`、`planChart`、`recommend`、`validateSpec`、`createChart`、`getCapabilities`、`getChartCapability`、`getPreferenceCapabilities`、`validatePreferences`、`chart.describe`、`chart.explain`、`chart.getState`、`chart.getPreferences`、`chart.setPreferences`、`chart.resetPreferences`、`chart.selectEdges`、`chart.getSelectedEdgeIds`、`chart.deleteSelectedEdges`、`chart.export`、`chart.exportAsync`、`chart.toDataURL`、`chart.toBlob`、`chart.download`、`chart.downloadPNG`、`chart.downloadSVG`、`chart.downloadJSON`。
|
|
84
86
|
|
|
85
87
|
实现位置:`src/index.mjs`、`src/spec.mjs`、`src/scene.mjs`、`src/renderer.mjs`、`src/plugin.mjs`、`src/scale.mjs`、`src/charts.mjs`、`src/capabilities.mjs`。
|
|
@@ -48,3 +48,66 @@ const resolved = chart.getTheme();
|
|
|
48
48
|
|
|
49
49
|
预览与验收:`http://localhost:3000/playground/theme-gallery.html`。
|
|
50
50
|
|
|
51
|
+
## 单图表与页面级偏好
|
|
52
|
+
|
|
53
|
+
偏好用于图表创建后的视觉调整,适合用户操作和 Agent 对话调整。业务数据、编码和图表类型不应放进这个配置面。
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import { createChart, createPreferencesStore, mountChartSettings } from '@taylorwong/ichartjs';
|
|
57
|
+
|
|
58
|
+
const pagePreferences = createPreferencesStore({
|
|
59
|
+
storage: 'localStorage',
|
|
60
|
+
storageKey: 'my-app:chart-preferences'
|
|
61
|
+
});
|
|
62
|
+
const chart = createChart({
|
|
63
|
+
chartId: 'revenue',
|
|
64
|
+
container: '#revenue',
|
|
65
|
+
type: 'line',
|
|
66
|
+
data: { values: rows },
|
|
67
|
+
preferences: pagePreferences
|
|
68
|
+
});
|
|
69
|
+
const settings = mountChartSettings(chart, {
|
|
70
|
+
locale: 'zh-CN',
|
|
71
|
+
placement: 'auto',
|
|
72
|
+
preferredPlacements: ['right', 'top', 'bottom']
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Agent 对话也使用同一套 API。
|
|
76
|
+
chart.setPreferences({
|
|
77
|
+
theme: { preset: 'dashboard', palette: 'status' },
|
|
78
|
+
typography: { scale: 1.15 },
|
|
79
|
+
components: { grid: false }
|
|
80
|
+
}, { source: 'agent' });
|
|
81
|
+
|
|
82
|
+
// 宿主永久移除图表时同步销毁快捷设置浮层。
|
|
83
|
+
settings.destroy();
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
快捷设置面板会通过 Portal 放到图表裁剪区域之外。自动定位优先使用按钮右侧,其次上侧、下侧;都无法完整容纳时限制在浏览器视口内。滚动时保持已经选定的方位并跟随按钮,不再被视口约束拉回;图表或菜单按钮离开视口时直接关闭。窗口缩放和内容变化时可以重新计算方位。
|
|
87
|
+
|
|
88
|
+
### Agent 配置发现与验证
|
|
89
|
+
|
|
90
|
+
Agent 不应硬编码菜单选项,应先调用 `getPreferenceCapabilities(chartType, { locale })`。该接口会返回每个偏好字段的类型、默认值、候选值、作用域、当前图表适用性和 `menu.visible` 状态;对话调整和宿主自定义设置页应使用同一份契约。
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
import { getPreferenceCapabilities, validatePreferences } from '@taylorwong/ichartjs';
|
|
94
|
+
|
|
95
|
+
const capabilities = getPreferenceCapabilities(chart.getSpec().type, { locale: 'zh-CN' });
|
|
96
|
+
const menuFields = capabilities.fields.filter(field => field.menu.visible);
|
|
97
|
+
const current = chart.getPreferences();
|
|
98
|
+
const patch = {
|
|
99
|
+
theme: { preset: 'dashboard', palette: 'status' },
|
|
100
|
+
typography: { scale: 1.15 },
|
|
101
|
+
components: { grid: false }
|
|
102
|
+
};
|
|
103
|
+
const checked = validatePreferences(patch, { partial: true });
|
|
104
|
+
if (!checked.valid) throw new Error(JSON.stringify(checked.errors));
|
|
105
|
+
chart.setPreferences(checked.value, { scope: 'chart', source: 'agent' });
|
|
106
|
+
const applied = chart.getState().preferences;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
快捷菜单字段为 `theme.mode`、`theme.palette`、`typography.scale`,以及当前图表支持的 `components.legend`、`components.labels`、`components.grid`。完整白名单另外包含 `theme.preset`、`density`、`branding.enabled` 和 `motion`。无法识别语言时默认返回英文。
|
|
110
|
+
|
|
111
|
+
单图表快捷菜单使用紧凑的汉堡图标,只保留高频操作:主题模式、配色、字号,以及当前图表真正支持的图例、数据标签和网格线。能力检测会自动隐藏无效设置;修改即时生效,并支持 `zh-CN`、`en` 和按文档语言自动识别。
|
|
112
|
+
|
|
113
|
+
低频选项和页面级配置应放在图表弹出菜单之外的独立设置页。页面内图表共享同一个 store,并使用 `store.setGlobal()` 或 `chart.setPreferences(patch, { scope: 'global' })` 更新全局。完整设置页可提供 preset、密度、署名等白名单能力,而不挤占每张图表。Node/SSR 默认使用内存,浏览器需要显式选择 `localStorage` 或宿主存储适配器。快捷菜单验收地址:`http://localhost:3000/playground/project-gallery.html`;完整页面设置验收地址:`http://localhost:3000/playground/preferences-lab.html`。
|
|
@@ -35,6 +35,22 @@ Skill 不是第二套渲染器,也不是服务端。使用 Skill 的 Agent 仍
|
|
|
35
35
|
|
|
36
36
|
JSON 是机器可读的事实来源;SVG 和 PNG/JPEG 是视觉交付物;代码是集成交付物;交互页面是产品交付物。
|
|
37
37
|
|
|
38
|
+
## 视觉偏好:界面与 Agent
|
|
39
|
+
|
|
40
|
+
图表创建后需要调整视觉样式时,可让页面图表共享 `createPreferencesStore()`。浏览器中只有在宿主希望刷新后保留配置时,才显式使用 `storage: 'localStorage'`。`mountChartSettings(chart)` 会在导出区域之外增加可访问的快捷设置按钮;完整的页面级设置中心应作为宿主的独立路由。
|
|
41
|
+
|
|
42
|
+
宿主交互和 Agent 对话使用同一个 patch 合约:
|
|
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
|
+
快捷菜单只保留主题、配色、字号和当前图表支持的显示开关。使用 `scope: 'global'` 修改页面全部图表;默认只修改当前图表;使用 `chart.getState().preferences` 获取可审计的最终配置。两层体验可在 `http://localhost:3000/playground/project-gallery.html` 和 `http://localhost:3000/playground/preferences-lab.html` 验收。
|
|
53
|
+
|
|
38
54
|
## 场景一:集成到 Web 项目
|
|
39
55
|
|
|
40
56
|
在宿主项目中安装 Runtime:
|
|
@@ -85,7 +101,28 @@ Agent 应返回:
|
|
|
85
101
|
|
|
86
102
|
## 场景三:作为官方 Skill 使用
|
|
87
103
|
|
|
88
|
-
|
|
104
|
+
使用标准 Agent Skills CLI 安装最新版:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npx skills add wanghetommy/ichartjs --skill ichartjs
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
无交互地全局安装到 Codex:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npx skills add wanghetommy/ichartjs --skill ichartjs --agent codex --global --yes
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
需要固定发布版本时,直接安装已发布的 Skill 目录:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npx skills add https://github.com/wanghetommy/ichartjs/tree/v2.0.7/skills/ichartjs \
|
|
120
|
+
--agent codex --global --yes
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
WorkBuddy 用户可以通过宿主的 Skill 界面导入同一个带 Tag 的 GitHub 目录。在当前 Skills CLI 没有明确声明适配器时,不要假设存在 `--agent workbuddy`。具有自定义 Skill 目录的宿主仍可从 `node_modules/@taylorwong/ichartjs/skills/ichartjs` 手动复制。
|
|
124
|
+
|
|
125
|
+
安装或选择 `ichartjs` 后可以这样提问:
|
|
89
126
|
|
|
90
127
|
```text
|
|
91
128
|
使用 iChart.js Skill。读取这份数据,生成项目 Burndown,校验 Spec,
|
|
@@ -113,6 +150,8 @@ Agent 可以创建一个 ESM 脚本或独立 HTML 页面,输出:
|
|
|
113
150
|
- `gantt`、`timeline`、`milestone`、`burndown`:项目进度和交付计划;
|
|
114
151
|
- 项目分析:capacity、velocity、release forecast、risk、issue aging;
|
|
115
152
|
- `flow`、`swimlane`:流程、责任、分组、Port 和受控编辑。
|
|
153
|
+
- `architecture`:业务、数据或技术架构,使用明确的层、边界和关系。
|
|
154
|
+
- `mindmap`:想法层级,以 `parentId` 为事实来源,支持树形或放射布局。
|
|
116
155
|
|
|
117
156
|
保留稳定的 record、node、edge、lane、group、port ID。业务编辑先返回 preview,确认后再 commit,并返回审计结果。
|
|
118
157
|
|
|
@@ -12,11 +12,29 @@
|
|
|
12
12
|
"scenarios": {
|
|
13
13
|
"charting": ["line", "area", "bar", "column", "pie", "scatter", "funnel", "gauge", "heatmap", "radar"],
|
|
14
14
|
"project": ["gantt", "timeline", "milestone", "burndown"],
|
|
15
|
-
"diagram": ["flow", "swimlane"]
|
|
15
|
+
"diagram": ["flow", "swimlane", "architecture", "mindmap"]
|
|
16
16
|
},
|
|
17
17
|
"projectIntelligence": ["variance", "capacity", "release", "risk", "aging"],
|
|
18
|
-
"chartModes": ["stacked", "percent-stacked", "donut", "mixed-line-column", "bin"],
|
|
18
|
+
"chartModes": ["stacked", "percent-stacked", "donut", "mixed-line-column", "bin", "architecture-layers", "architecture-boundaries", "mindmap-tree", "mindmap-radial", "mindmap-curved-edges"],
|
|
19
19
|
"renderers": ["canvas", "svg"],
|
|
20
|
+
"interactionDefaults": { "zoom": false, "pan": false, "brush": false, "drag": false, "edgeDrag": false, "portConnect": false, "editing": false },
|
|
21
|
+
"diagramEditing": {
|
|
22
|
+
"renderers": ["canvas", "svg"],
|
|
23
|
+
"edgeSelection": true,
|
|
24
|
+
"waypointDrag": true,
|
|
25
|
+
"segmentDrag": true,
|
|
26
|
+
"persistentWaypoints": true,
|
|
27
|
+
"enabledByDefault": false,
|
|
28
|
+
"activation": ["editing.enabled", "interaction.edgeDrag"]
|
|
29
|
+
},
|
|
30
|
+
"diagramCurves": {
|
|
31
|
+
"renderers": ["canvas", "svg"],
|
|
32
|
+
"type": "cubic-bezier",
|
|
33
|
+
"mindmapDefault": true,
|
|
34
|
+
"curveTension": { "minimum": 0.2, "maximum": 0.8, "default": 0.4 },
|
|
35
|
+
"obstacleFallback": "orthogonal",
|
|
36
|
+
"controlPointEditing": false
|
|
37
|
+
},
|
|
20
38
|
"excluded": ["map", "3d"],
|
|
21
39
|
"exports": ["png", "svg", "json"],
|
|
22
40
|
"headless": {
|
|
@@ -59,7 +77,24 @@
|
|
|
59
77
|
"projectIntelligenceDemo": "playground/project-intelligence.html",
|
|
60
78
|
"foundationalGallery": "playground/foundational-gallery.html",
|
|
61
79
|
"themeGallery": "playground/theme-gallery.html",
|
|
80
|
+
"preferencesLab": "playground/preferences-lab.html",
|
|
62
81
|
"themeGuide": "docs/agent/theme-guide.md",
|
|
82
|
+
"preferences": {
|
|
83
|
+
"version": "1.0",
|
|
84
|
+
"scopes": ["global", "chart"],
|
|
85
|
+
"persistence": ["memory", "localStorage", "adapter"],
|
|
86
|
+
"fields": ["theme.mode", "theme.preset", "theme.palette", "typography.scale", "density", "components.legend", "components.labels", "components.grid", "branding.enabled", "motion"],
|
|
87
|
+
"agentAdjustable": true,
|
|
88
|
+
"interactiveSettingsUI": true,
|
|
89
|
+
"precedence": ["defaults", "global", "chart", "temporary-agent-patch"],
|
|
90
|
+
"discovery": {
|
|
91
|
+
"capabilities": "getPreferenceCapabilities(chartType?, { locale? })",
|
|
92
|
+
"current": "chart.getPreferences()",
|
|
93
|
+
"validate": "validatePreferences(patch, { partial: true })",
|
|
94
|
+
"apply": "chart.setPreferences(patch, { scope, source: 'agent' })",
|
|
95
|
+
"verify": "chart.getState().preferences"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
63
98
|
"styleSystem": {
|
|
64
99
|
"modes": ["auto", "light", "dark", "contrast"],
|
|
65
100
|
"presets": ["auto", "analysis", "dashboard", "report", "presentation", "project", "diagram"],
|
|
@@ -2,27 +2,28 @@
|
|
|
2
2
|
"version": "1.0",
|
|
3
3
|
"source": "src/command.mjs#operationTypes",
|
|
4
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 },
|
|
5
|
+
"updateField": { "models": ["project-task", "timeline-event", "milestone", "burndown-sample", "flow-node", "flow-edge", "swimlane", "architecture-node", "architecture-edge", "mindmap-node"], "previewRequired": true, "undoable": true },
|
|
6
|
+
"updateRecord": { "models": ["project-task", "timeline-event", "milestone", "burndown-sample", "flow-node", "flow-edge", "swimlane", "architecture-node", "architecture-edge", "mindmap-node"], "previewRequired": true, "undoable": true },
|
|
7
7
|
"updateTask": { "models": ["project-task"], "previewRequired": true, "undoable": true },
|
|
8
8
|
"shiftTask": { "models": ["project-task"], "required": ["taskId", "days"], "previewRequired": true, "undoable": true },
|
|
9
9
|
"updateProgress": { "models": ["project-task"], "required": ["taskId", "progress"], "previewRequired": true, "undoable": true },
|
|
10
10
|
"addDependency": { "models": ["project-task"], "required": ["taskId", "dependencyId"], "previewRequired": true, "undoable": true },
|
|
11
11
|
"removeDependency": { "models": ["project-task"], "required": ["taskId", "dependencyId"], "previewRequired": true, "undoable": true },
|
|
12
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 },
|
|
13
|
+
"moveNode": { "models": ["flow-node", "architecture-node", "mindmap-node"], "required": ["nodeId", "position"], "previewRequired": true, "undoable": true },
|
|
14
|
+
"moveNodes": { "models": ["flow-node", "architecture-node", "mindmap-node"], "required": ["nodeIds", "delta"], "previewRequired": true, "undoable": true },
|
|
15
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 },
|
|
16
|
+
"resizeNode": { "models": ["flow-node", "architecture-node", "mindmap-node"], "required": ["nodeId", "size"], "previewRequired": true, "undoable": true },
|
|
17
|
+
"alignNodes": { "models": ["flow-node", "architecture-node", "mindmap-node"], "required": ["nodeIds", "alignment"], "previewRequired": true, "undoable": true },
|
|
18
|
+
"snapNodes": { "models": ["flow-node", "architecture-node", "mindmap-node"], "required": ["nodeIds"], "previewRequired": true, "undoable": true },
|
|
19
19
|
"moveGroup": { "models": ["flow-node"], "required": ["groupId", "delta"], "previewRequired": true, "undoable": true },
|
|
20
20
|
"resizeGroup": { "models": ["flow-node"], "required": ["groupId", "size"], "previewRequired": true, "undoable": true },
|
|
21
21
|
"assignNodesToGroup": { "models": ["flow-node"], "required": ["nodeIds", "groupId"], "previewRequired": true, "confirmationRequired": true, "undoable": true },
|
|
22
22
|
"duplicateGroup": { "models": ["flow-node", "flow-edge"], "required": ["groupId"], "previewRequired": true, "confirmationRequired": true, "undoable": true },
|
|
23
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
|
-
"
|
|
24
|
+
"updateEdge": { "models": ["flow-edge", "architecture-edge"], "required": ["edgeId", "changes"], "previewRequired": true, "undoable": true },
|
|
25
|
+
"removeEdge": { "models": ["flow-edge", "architecture-edge"], "required": ["edgeId"], "previewRequired": true, "confirmationRequired": true, "undoable": true },
|
|
26
|
+
"addEdge": { "models": ["flow-edge", "architecture-edge"], "required": ["from", "to"], "previewRequired": true, "confirmationRequired": true, "undoable": true },
|
|
26
27
|
"toggleGroupCollapse": { "models": ["flow-node"], "required": ["groupId"], "previewRequired": true, "confirmationRequired": true, "undoable": true },
|
|
27
28
|
"duplicateSelection": { "models": ["flow-node", "flow-edge"], "required": ["nodeIds"], "previewRequired": true, "confirmationRequired": true, "undoable": true },
|
|
28
29
|
"pasteSelection": { "models": ["flow-node", "flow-edge"], "required": ["nodes"], "previewRequired": true, "confirmationRequired": true, "undoable": true }
|
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
"milestone": { "key": "id", "required": ["id", "title", "date"], "editable": ["title", "date", "status"] },
|
|
8
8
|
"burndown-sample": { "key": "id", "required": ["id", "date", "remaining"], "editable": ["date", "remaining", "scopeChange"] },
|
|
9
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"] }
|
|
10
|
+
"flow-edge": { "key": "id", "required": ["id", "from", "to"], "editable": ["from", "to", "fromPort", "toPort", "label", "status", "routing", "curveTension", "waypoints"] },
|
|
11
|
+
"swimlane": { "key": "id", "required": ["id", "label"], "editable": ["label"] },
|
|
12
|
+
"architecture-node": { "key": "id", "required": ["id", "label"], "editable": ["label", "layerId", "boundaryId", "position", "size", "description", "status"] },
|
|
13
|
+
"architecture-edge": { "key": "id", "required": ["id", "from", "to"], "editable": ["from", "to", "label", "relation", "routing", "curveTension", "waypoints", "status"] },
|
|
14
|
+
"mindmap-node": { "key": "id", "required": ["id", "label"], "editable": ["label", "parentId", "position", "size", "branch", "description", "status"] }
|
|
12
15
|
}
|
|
13
16
|
}
|
package/package.json
CHANGED
package/skills/ichartjs/SKILL.md
CHANGED
|
@@ -7,7 +7,7 @@ description: Plan, validate, render, explain, and safely edit iChart.js visualiz
|
|
|
7
7
|
|
|
8
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
9
|
|
|
10
|
-
Read [
|
|
10
|
+
Read the [usage scenarios](https://github.com/wanghetommy/ichartjs/blob/master/docs/agent/usage-scenarios.md) when the request is ambiguous about whether the output should be a live project component, a Coding Agent change, a Skill-generated artifact, or a scheduled report.
|
|
11
11
|
|
|
12
12
|
## Source and Runtime Setup
|
|
13
13
|
|
|
@@ -15,6 +15,14 @@ Read [`docs/agent/usage-scenarios.md`](../../docs/agent/usage-scenarios.md) when
|
|
|
15
15
|
- Official Skill source: `https://github.com/wanghetommy/ichartjs/tree/master/skills/ichartjs`
|
|
16
16
|
- Supported Skill hosts include Codex, WorkBuddy, and other Agent Skills-compatible environments.
|
|
17
17
|
|
|
18
|
+
Recommended installation:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npx skills add wanghetommy/ichartjs --skill ichartjs
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Use `--agent codex --global --yes` for global non-interactive Codex installation. Use the tagged directory `https://github.com/wanghetommy/ichartjs/tree/v2.0.7/skills/ichartjs` when reproducibility matters. WorkBuddy can import the same directory through its Skill interface; do not assume a `--agent workbuddy` adapter unless the installed CLI declares it.
|
|
25
|
+
|
|
18
26
|
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:
|
|
19
27
|
|
|
20
28
|
```bash
|
|
@@ -36,6 +44,7 @@ Do not install the unscoped npm registry package named `ichartjs`; it is current
|
|
|
36
44
|
9. Self-check with `chart.explain()`, `chart.getState()`, and JSON export.
|
|
37
45
|
10. Provide an exact preview URL or artifact path and report assumptions, warnings, and deferred checks.
|
|
38
46
|
11. Prefer `theme: { mode: 'auto', preset, palette }`; preserve explicit user style choices and use `chart.setTheme()` for live switching.
|
|
47
|
+
12. For post-creation visual changes, call `getPreferenceCapabilities(chartType, { locale })`, validate the patch with `validatePreferences()`, apply it with `chart.setPreferences(..., { source: 'agent' })`, and verify `chart.getState().preferences`.
|
|
39
48
|
|
|
40
49
|
Use `@taylorwong/ichartjs` for package imports. Use `examples/agent-workflow.mjs` as the executable baseline when working in the repository.
|
|
41
50
|
|
|
@@ -54,7 +63,7 @@ Route by requested output:
|
|
|
54
63
|
- For Flow or Swimlane, preserve node, edge, lane, group, and port IDs; use diagram recipes and validated edit commands.
|
|
55
64
|
- For business edits, preview first, preserve the preview ID and revision, require confirmation when declared, then commit or reject atomically.
|
|
56
65
|
- For browser deliverables, start `npm run playground` and return the exact maintained Playground URL.
|
|
57
|
-
- Release workflow (npm publish + develop→master merge) is **AUTHOR ONLY**. Read the release SOP
|
|
66
|
+
- Release workflow (npm publish + develop→master merge) is **AUTHOR ONLY**. Read the [release SOP](https://github.com/wanghetommy/ichartjs/blob/master/docs/agent/development/release-sop.md). Never initiate any release step unless the author explicitly instructs.
|
|
58
67
|
|
|
59
68
|
## Guardrails
|
|
60
69
|
|