@rezti/dsh-rez-suite 0.1.49 → 0.1.51

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 (142) hide show
  1. package/CHANGELOG.md +13 -2
  2. package/README.md +3 -3
  3. package/README.zh.md +2 -2
  4. package/cordis.patch.yml +1 -1
  5. package/lib/client.d.ts +31 -3
  6. package/lib/client.js +343 -7
  7. package/lib/index.js +244 -15
  8. package/lib/style.css +7 -0
  9. package/package.json +12 -11
  10. package/src/boss/mount.ts +4 -3
  11. package/src/boss/register.ts +1 -1
  12. package/src/boss/seed.ts +34 -0
  13. package/src/changelog.ts +48 -0
  14. package/src/channel-board.ts +55 -0
  15. package/src/client/locales.ts +62 -6
  16. package/src/client/panel/BoardTab.tsx +136 -0
  17. package/src/client/panel/ConfigTab.tsx +2 -2
  18. package/src/client/panel/StatusTab.tsx +31 -0
  19. package/src/client/panel/panel.module.css +7 -0
  20. package/src/client/settings-card.tsx +4 -1
  21. package/src/index.ts +3 -2
  22. package/src/protocol.ts +14 -0
  23. package/src/routes.ts +7 -1
  24. package/src/tools.ts +49 -6
  25. package/src/wecom-cli.ts +125 -0
  26. package/templates/boss/ops/AGENTS.md +2 -0
  27. package/templates/shared/wecom-cli.SOURCE.md +9 -0
  28. package/templates/shared/wecom-office/SKILL.md +32 -0
  29. package/templates/shared/wecomcli-calendar/SKILL.md +303 -0
  30. package/templates/shared/wecomcli-calendar/references/calendar-agenda.md +224 -0
  31. package/templates/shared/wecomcli-calendar/references/calendar-cancel.md +108 -0
  32. package/templates/shared/wecomcli-calendar/references/calendar-create.md +238 -0
  33. package/templates/shared/wecomcli-calendar/references/calendar-freebusy.md +207 -0
  34. package/templates/shared/wecomcli-calendar/references/calendar-meeting-room.md +170 -0
  35. package/templates/shared/wecomcli-calendar/references/calendar-search.md +206 -0
  36. package/templates/shared/wecomcli-calendar/references/calendar-update.md +272 -0
  37. package/templates/shared/wecomcli-contact/SKILL.md +58 -0
  38. package/templates/shared/wecomcli-disk/SKILL.md +389 -0
  39. package/templates/shared/wecomcli-doc/SKILL.md +137 -0
  40. package/templates/shared/wecomcli-doc/references/doc-contents-append.md +20 -0
  41. package/templates/shared/wecomcli-doc/references/doc-contents-overwrite.md +27 -0
  42. package/templates/shared/wecomcli-doc/references/doc-create.md +161 -0
  43. package/templates/shared/wecomcli-doc/scripts/build_docx.py +1375 -0
  44. package/templates/shared/wecomcli-doc-manage/SKILL.md +132 -0
  45. package/templates/shared/wecomcli-doc-manage/references/doc-members-update.md +24 -0
  46. package/templates/shared/wecomcli-doc-manage/references/doc-names-update.md +20 -0
  47. package/templates/shared/wecomcli-doc-manage/references/doc-rules-update.md +22 -0
  48. package/templates/shared/wecomcli-email/SKILL.md +218 -0
  49. package/templates/shared/wecomcli-email/references/forward-mail.md +131 -0
  50. package/templates/shared/wecomcli-email/references/get-mail.md +166 -0
  51. package/templates/shared/wecomcli-email/references/reply-mail.md +138 -0
  52. package/templates/shared/wecomcli-email/references/search-mail.md +111 -0
  53. package/templates/shared/wecomcli-email/references/security.md +53 -0
  54. package/templates/shared/wecomcli-email/references/send-mail.md +186 -0
  55. package/templates/shared/wecomcli-email/references/send-schedule.md +83 -0
  56. package/templates/shared/wecomcli-media/SKILL.md +98 -0
  57. package/templates/shared/wecomcli-meeting/SKILL.md +373 -0
  58. package/templates/shared/wecomcli-meeting/references/meeting-cancel.md +113 -0
  59. package/templates/shared/wecomcli-meeting/references/meeting-create.md +167 -0
  60. package/templates/shared/wecomcli-meeting/references/meeting-list.md +226 -0
  61. package/templates/shared/wecomcli-meeting/references/meeting-original-get.md +98 -0
  62. package/templates/shared/wecomcli-meeting/references/meeting-search.md +173 -0
  63. package/templates/shared/wecomcli-meeting/references/meeting-update.md +217 -0
  64. package/templates/shared/wecomcli-message/SKILL.md +200 -0
  65. package/templates/shared/wecomcli-shared/SKILL.md +73 -0
  66. package/templates/shared/wecomcli-sheet/SKILL.md +172 -0
  67. package/templates/shared/wecomcli-sheet/references/sheet-contents-update.md +47 -0
  68. package/templates/shared/wecomcli-sheet/references/sheet-ranges-get.md +45 -0
  69. package/templates/shared/wecomcli-sheet/references/sheet-rows-append.md +45 -0
  70. package/templates/shared/wecomcli-sheet/references/sheet-subsheets-add.md +26 -0
  71. package/templates/shared/wecomcli-sheet/references/sheet-subsheets-delete.md +20 -0
  72. package/templates/shared/wecomcli-smartpage/SKILL.md +170 -0
  73. package/templates/shared/wecomcli-smartpage/references/data-driven-pages.md +50 -0
  74. package/templates/shared/wecomcli-smartpage/references/formula/arraylist.md +369 -0
  75. package/templates/shared/wecomcli-smartpage/references/formula/datetime.md +283 -0
  76. package/templates/shared/wecomcli-smartpage/references/formula/logic.md +247 -0
  77. package/templates/shared/wecomcli-smartpage/references/formula/math.md +362 -0
  78. package/templates/shared/wecomcli-smartpage/references/formula/operators.md +246 -0
  79. package/templates/shared/wecomcli-smartpage/references/formula/pageblock.md +76 -0
  80. package/templates/shared/wecomcli-smartpage/references/formula/templates.md +410 -0
  81. package/templates/shared/wecomcli-smartpage/references/formula/text.md +377 -0
  82. package/templates/shared/wecomcli-smartpage/references/formula/user.md +22 -0
  83. package/templates/shared/wecomcli-smartpage/references/formula-reference.md +192 -0
  84. package/templates/shared/wecomcli-smartpage/references/mdx-syntax.md +739 -0
  85. package/templates/shared/wecomcli-smartpage/references/smartpage-edit.md +506 -0
  86. package/templates/shared/wecomcli-smartsheet/SKILL.md +154 -0
  87. package/templates/shared/wecomcli-smartsheet/assets/templates/README.md +53 -0
  88. package/templates/shared/wecomcli-smartsheet/assets/templates/ai_efficiency.md +709 -0
  89. package/templates/shared/wecomcli-smartsheet/assets/templates/connect_to_app.md +380 -0
  90. package/templates/shared/wecomcli-smartsheet/assets/templates/financial_accounting.md +369 -0
  91. package/templates/shared/wecomcli-smartsheet/assets/templates/hr_and_administration.md +475 -0
  92. package/templates/shared/wecomcli-smartsheet/assets/templates/ledger_records.md +156 -0
  93. package/templates/shared/wecomcli-smartsheet/assets/templates/manufacturing.md +395 -0
  94. package/templates/shared/wecomcli-smartsheet/assets/templates/marketing.md +186 -0
  95. package/templates/shared/wecomcli-smartsheet/assets/templates/office_essentials.md +299 -0
  96. package/templates/shared/wecomcli-smartsheet/assets/templates/personal_efficiency.md +70 -0
  97. package/templates/shared/wecomcli-smartsheet/assets/templates/procurement_logistics.md +325 -0
  98. package/templates/shared/wecomcli-smartsheet/assets/templates/project_management.md +564 -0
  99. package/templates/shared/wecomcli-smartsheet/assets/templates/rd_process_customer.md +222 -0
  100. package/templates/shared/wecomcli-smartsheet/assets/templates/rd_process_ops.md +105 -0
  101. package/templates/shared/wecomcli-smartsheet/assets/templates/rd_process_project.md +109 -0
  102. package/templates/shared/wecomcli-smartsheet/assets/templates/rd_process_research.md +92 -0
  103. package/templates/shared/wecomcli-smartsheet/assets/templates/sales_and_operations.md +446 -0
  104. package/templates/shared/wecomcli-smartsheet/assets/templates/store_management.md +431 -0
  105. package/templates/shared/wecomcli-smartsheet/assets/templates/team_tasks.md +274 -0
  106. package/templates/shared/wecomcli-smartsheet/assets/templates/wechat_customer.md +384 -0
  107. package/templates/shared/wecomcli-smartsheet/assets/templates/work_report.md +100 -0
  108. package/templates/shared/wecomcli-smartsheet/references/common.md +143 -0
  109. package/templates/shared/wecomcli-smartsheet/references/smart-sheet-chart-types.md +95 -0
  110. package/templates/shared/wecomcli-smartsheet/references/smart-sheet-edit.md +589 -0
  111. package/templates/shared/wecomcli-smartsheet/references/smart-sheet-field-types.md +438 -0
  112. package/templates/shared/wecomcli-smartsheet/references/smart-sheet-formula.md +845 -0
  113. package/templates/shared/wecomcli-smartsheet/references/smart-sheet-read.md +391 -0
  114. package/templates/shared/wecomcli-smartsheet/references/smart-sheet-record-values.md +201 -0
  115. package/templates/shared/wecomcli-smartsheet/references/smart-sheet-view-types.md +356 -0
  116. package/templates/shared/wecomcli-smartsheet/references/smart-sheet-webhook-examples.md +176 -0
  117. package/templates/shared/wecomcli-smartsheet/references/smart-sheet-webhook.md +169 -0
  118. package/templates/shared/wecomcli-todo/SKILL.md +76 -0
  119. package/templates/shared/wecomcli-todo/references/todo-create.md +137 -0
  120. package/templates/shared/wecomcli-todo/references/todo-delete.md +63 -0
  121. package/templates/shared/wecomcli-todo/references/todo-finish.md +72 -0
  122. package/templates/shared/wecomcli-todo/references/todo-get.md +66 -0
  123. package/templates/shared/wecomcli-todo/references/todo-list.md +133 -0
  124. package/templates/shared/wecomcli-todo/references/todo-update.md +112 -0
  125. package/templates/staff/design/AGENTS.md +2 -1
  126. package/templates/staff/ecommerce/.agents/skills/ops-ecommerce/SKILL.md +6 -0
  127. package/templates/staff/ecommerce/AGENTS.md +49 -0
  128. package/templates/staff/ecommerce/BOOTSTRAP.md +23 -0
  129. package/templates/staff/ecommerce/IDENTITY.md +8 -0
  130. package/templates/staff/ecommerce/MEMORY.md +9 -0
  131. package/templates/staff/ecommerce/PRIORITIES.md +3 -0
  132. package/templates/staff/ecommerce/SOUL.md +5 -0
  133. package/templates/staff/ecommerce/USER.md +8 -0
  134. package/templates/staff/hr/.agents/skills/staff-onboard-keys/SKILL.md +3 -3
  135. package/templates/staff/publish/.agents/skills/ops-publish/SKILL.md +6 -0
  136. package/templates/staff/publish/AGENTS.md +59 -0
  137. package/templates/staff/publish/BOOTSTRAP.md +23 -0
  138. package/templates/staff/publish/IDENTITY.md +8 -0
  139. package/templates/staff/publish/MEMORY.md +9 -0
  140. package/templates/staff/publish/PRIORITIES.md +3 -0
  141. package/templates/staff/publish/SOUL.md +6 -0
  142. package/templates/staff/publish/USER.md +8 -0
@@ -0,0 +1,589 @@
1
+ # 智能表格操作参考
2
+
3
+ 企业微信智能表格的读取与编辑操作,支持读取表格信息与数据、修改表结构(子表/字段)、修改记录、修改视图、修改图表、修改样式。
4
+
5
+ > **对应 doc_type 值**:`smartsheet`(智能表格)
6
+ >
7
+ > **适用 docid 前缀**:`s3_`
8
+
9
+ > `docid` 参数名全小写无下划线,其他行为约束见 `SKILL.md`。
10
+ >
11
+ > **警惕数据破坏行为**:
12
+ > 1. 批量删除记录、清空字段、删除子表等不可逆操作,执行前必须确保用户给出了**明确、具体的保留策略**(如"删除 2026 年 3 月之前的所有记录"、"只保留状态为已完成的行")。若用户描述模棱两可(如"删除全部"、"删掉就好了"、"清一下"),**必须先向用户确认**具体的删除范围与保留条件,不得直接执行
13
+ > 2. 删除最后一个子表/字段/视图固定流程时,由于智能表格至少需要保留一个子表、一个字段、一个视图,所以执行删除操作前必须先用 `wecom-cli smartsheet sheets list`、`wecom-cli smartsheet fields list` 或 `wecom-cli smartsheet records query` 确认对应资源的数量;若只剩 1 个,先用简洁自然语言向用户明确确认是否继续。如果用户明确要求删除/重建/重置/数据不要了,禁止先试探删除,禁止改成清空数据,禁止追问方案。必须先新增一个最小占位资源(子表/字段/视图),再删除目标资源。
14
+
15
+ ---
16
+
17
+ ## 场景导航
18
+
19
+ 根据操作意图,快速定位到对应的接口:
20
+
21
+ | 用户场景/意图 | 对应命令 | 说明 |
22
+ | --- | --- | --- |
23
+ | 从零新建智能表格并初始化子表字段 | `wecom-cli smartsheet create` | 写操作,接口详见 `references/common.md` |
24
+ | 导入本地/已上传文件为智能表格 | `wecom-cli smartsheet import` | 写操作,接口详见 `references/common.md` |
25
+ | 查看智能表格子表列表 | `wecom-cli smartsheet sheets list` | 读操作,接口说明见 `references/smart-sheet-read.md` |
26
+ | 读取指定子表的行记录数据、按条件筛选数据 | `wecom-cli smartsheet records query` | 读操作,接口说明见 `references/smart-sheet-read.md` |
27
+ | 查询字段列表 | `wecom-cli smartsheet fields list` | 读操作,接口说明见 `references/smart-sheet-read.md` |
28
+ | 查询视图列表 | `wecom-cli smartsheet views list` | 读操作,接口说明见 `references/smart-sheet-read.md` |
29
+ | 查询图表列表 | `wecom-cli smartsheet charts list` | 读操作,接口说明见 `references/smart-sheet-read.md` |
30
+ | 新建/修改/删除子表 | `wecom-cli smartsheet sheets add` / `wecom-cli smartsheet sheets update` / `wecom-cli smartsheet sheets delete` | 写操作,支持新增/修改/删除子表 |
31
+ | 新建/修改/删除字段 | `wecom-cli smartsheet fields add` / `wecom-cli smartsheet fields update` / `wecom-cli smartsheet fields delete` | 写操作,字段操作独立命令 |
32
+ | 新建/修改/删除行记录 | `wecom-cli smartsheet records add` / `wecom-cli smartsheet records update` / `wecom-cli smartsheet records delete` | 写操作,支持新增/修改/删除行记录 |
33
+ | 新增/修改记录返回 `851003` / `no authority` | Webhook 兜底写入 | 停止重试 CLI,完整阅读 `references/smart-sheet-webhook.md` 后按其流程处理 |
34
+ | 新建/修改/删除视图 | `wecom-cli smartsheet views add` / `wecom-cli smartsheet views update` / `wecom-cli smartsheet views delete` | 写操作,支持新增/修改/删除视图 |
35
+ | 新建/修改/删除图表 | `wecom-cli smartsheet charts add` / `wecom-cli smartsheet charts update` / `wecom-cli smartsheet charts delete` | 写操作,支持新增/修改/删除仪表盘图表 |
36
+ ---
37
+
38
+ ## 编辑强制规范
39
+
40
+ 1. **写前必读**——执行新增/修改记录前,先 `wecom-cli smartsheet records query` 读取 3-5 条现有记录,对齐用词习惯(如是否采用"动词+名词"结构)和单选/多选字段的已有选项。
41
+ 2. **新建字段/子表后必须调整列宽**——新增字段完成后,必须立即按 `references/smart-sheet-view-types.md` 中「新建字段时的列宽判断规则」确定各字段列宽,并调用 `wecom-cli smartsheet views update` 写入。
42
+ 3. **优先推荐公式字段**——用户要求新增字段且字段值可由表内其他字段计算/推导得出时:用户未指定类型则直接用 `formula`;用户已指定其他类型则说明公式字段优势并询问意见,不得擅自改变。
43
+ 4. **参考文档 vs 目标文档**——用户表达"参考/模仿/按照…格式"时,该文档是结构模板而非写入目标:① 读取参考文档字段结构 → ② 新建智能表格 → ③ 向新表写入数据。
44
+ 5. **更新记录必须一次完成**——`wecom-cli smartsheet records update` 对单次更新的记录无数量限制,任何记录更新操作必须一次完成,**严禁**拆分请求。
45
+
46
+ ---
47
+
48
+ ## 接口说明
49
+
50
+ ### 一、子表操作(smartsheet sheets add / update / delete)
51
+
52
+ > **命令说明**:
53
+ > - `wecom-cli smartsheet sheets add`:新增子表
54
+ > - `wecom-cli smartsheet sheets update`:修改子表名称
55
+ > - `wecom-cli smartsheet sheets delete`:删除子表
56
+
57
+ #### **前置必读**:创建时初始化字段(推荐)
58
+
59
+ > ✅ **创建智能表格时,优先使用 `wecom-cli smartsheet create` 一次性初始化子表字段,不要再拆成"先建表、再补字段"两步。**
60
+
61
+ 根据 `wecom-cli smartsheet create` 接口说明(详见 `references/common.md` ),支持在创建阶段同时传入 `sheet_title` 与 `fields`,可直接完成默认子表及字段初始化。
62
+
63
+ **推荐流程(新建场景):**
64
+
65
+ 1. 调用 `wecom-cli smartsheet create` 创建智能表格,并同时传入 `sheet_title` + `fields`
66
+ 2. 从返回值获取 `docid` 和所有字段的 `field_title`
67
+ 3. 按 `references/smart-sheet-view-types.md` 中「新建字段时的列宽判断规则」和「列宽调整接口调用方式」完成列宽写入
68
+ 4. 后续如需调整,再调用 `wecom-cli smartsheet sheets update` 做增量修改
69
+
70
+ **示例(创建时直接初始化字段):**
71
+
72
+ ```bash
73
+ wecom-cli smartsheet create --json '{"name": "任务跟踪表", "sheet_title": "任务列表", "fields": [{"field_title": "任务名称", "field_type": "text"}, {"field_title": "优先级", "field_type": "single_select", "property_single_select": {"is_quick_add": true, "options": [{"text": "高", "style": 18}, {"text": "中", "style": 20}, {"text": "低", "style": 16}]}}, {"field_title": "负责人", "field_type": "user", "property_user": {"is_multiple": false, "is_notified": true}}]}'
74
+ ```
75
+
76
+ **兜底流程(仅当历史表已创建且未按创建阶段初始化时使用):**
77
+
78
+ 1. 调用 `wecom-cli smartsheet sheets list` 获取当前子表列表,再调用 `wecom-cli smartsheet fields list` 获取字段列表(含 `field_title`)
79
+ 2. 用 `wecom-cli smartsheet fields update` 重命名可复用字段(仅在类型兼容时)
80
+ 3. 用 `wecom-cli smartsheet fields delete` 删除多余字段(注意至少保留一个文本类型字段)
81
+ 4. 用 `wecom-cli smartsheet fields add` 补充缺失字段
82
+ 5. 按 `references/smart-sheet-view-types.md` 中「新建字段时的列宽判断规则」和「列宽调整接口调用方式」对所有新增字段完成列宽写入
83
+
84
+ 根据文档 ID,新建、更新、删除工作表及字段(支持批处理)。
85
+
86
+
87
+ ```bash
88
+ wecom-cli smartsheet sheets add --json '{...}'
89
+ wecom-cli smartsheet sheets update --json '{...}'
90
+ wecom-cli smartsheet sheets delete --json '{...}'
91
+ ```
92
+
93
+ **请求参数 (JSON 格式传入):**
94
+
95
+ | 参数 | 类型 | 必填 | 说明 |
96
+ | --- | --- | --- | --- |
97
+ | `docid` | string | 是 | 文档 ID |
98
+ | `sheet_title` | string | 是 | 子表名称。`add` 时该字段表示新增子表的名称;`update`/`delete` 时用于定位子表 |
99
+ | `new_sheet_title` | string | 否 | 新子表名称。`update` 修改子表名称时传此字段 |
100
+ | `fields` | Field[] | 否 | 仅 `sheets add` 新增子表时可传,用于同时初始化列 |
101
+ | `sheet_type` | string | 否 | 子表类型,仅 `sheets add` 新增子表时使用,不传则默认为 `smartsheet`,可选值:`smartsheet`、`dashboard` |
102
+
103
+ **情形分类总览:**
104
+
105
+ 根据命令和参数组合,共分为以下场景:
106
+
107
+ | 场景 | 命令 | sheet_title | new_sheet_title | sheet_type | fields |
108
+ | --- | --- | --- | --- | --- | --- |
109
+ | 新增子表 | `sheets add` | **必传** | 不传 | 可选(默认 `smartsheet`) | 可选(仅用于初始化列) |
110
+ | 修改子表名称 | `sheets update` | **必传** | **必传** | — | **不传**(字段操作用 `fields` 命令) |
111
+ | 删除子表 | `sheets delete` | **必传** | 不传 | — | **不传** |
112
+
113
+ > 完整字段类型枚举(20+ 种)及 `property_xxx` 属性定义见 `references/smart-sheet-field-types.md`。
114
+ > **字段操作(新增/修改/删除字段)统一使用 `wecom-cli smartsheet fields` 命令,不通过 `sheets` 命令操作字段(`sheets add` 初始化列除外)。**
115
+
116
+ #### 场景 1:新增子表
117
+
118
+ 创建新的子表或仪表盘。
119
+
120
+ > **执行前必须检查重名**:
121
+ > - 子表名称在同一智能表格内不可重复。先调用 `wecom-cli smartsheet sheets list` 获取现有子表列表,确认不存在同名子表。
122
+ > - 同一子表中的字段名称不可重复。执行前必须先确认初始化字段中不包含同名字段。
123
+
124
+ > 智能表格在全新创建时默认可能会创建几条空记录,请先清理掉。
125
+
126
+ **参数要求:**
127
+
128
+ - `sheet_title`:**必传**,子表标题
129
+ - `sheet_type`:可选,默认 `smartsheet`(普通数据表),可选 `dashboard`(仪表盘)
130
+ - `fields`:可选。若传入,则会在**创建子表的同时初始化列**。`sheets add` 新增子表时传 `fields`,效果与「场景2:新增字段」相同,每个 Field 需传 `field_title` + `field_type` + 对应的 `property`(详见 `references/smart-sheet-field-types.md` )
131
+
132
+ **示例 1 — 新增普通子表:**
133
+
134
+ ```bash
135
+ wecom-cli smartsheet sheets add --json '{"docid": "s3_xxx", "sheet_title": "需求池"}'
136
+ ```
137
+
138
+ **示例 2 — 新增仪表盘:**
139
+
140
+ ```bash
141
+ wecom-cli smartsheet sheets add --json '{"docid": "s3_xxx", "sheet_title": "数据看板", "sheet_type": "dashboard"}'
142
+ ```
143
+
144
+ **示例 3 — 新增子表并同时初始化字段:**
145
+
146
+ ```bash
147
+ wecom-cli smartsheet sheets add --json '{"docid": "s3_AcDeFg", "sheet_title": "任务跟踪", "fields": [{"field_title": "任务名称", "field_type": "text"}, {"field_title": "优先级", "field_type": "single_select", "property_single_select": {"is_quick_add": true, "options": [{"text": "高", "style": 18}, {"text": "中", "style": 20}, {"text": "低", "style": 16}]}}, {"field_title": "负责人", "field_type": "user", "property_user": {"is_multiple": false, "is_notified": true}}]}'
148
+ ```
149
+
150
+ > ✅ **提示**:新增子表时支持**一步到位**传入 `fields`,无需先建子表再单独调用新增字段。
151
+
152
+ **创建子表后,必须立即调整列宽(强制):**
153
+
154
+ - 若创建时传入了 `fields`:从返回值取得各字段的 `field_title`,按 `references/smart-sheet-view-types.md` 中「新建字段时的列宽判断规则」和「列宽调整接口调用方式」完成列宽写入
155
+ - 若创建时未传入 `fields`:调用 `wecom-cli smartsheet fields list` 取得字段列表和 `field_title`,再按上述规则完成列宽写入
156
+
157
+ #### 场景 2:修改子表名称
158
+
159
+ 修改已有子表的名称,可同时修改列。
160
+
161
+ **参数要求:**
162
+
163
+ - `sheet_title`:**必传**,定位目标子表;修改子表名称时传当前名称,新名称用 `new_sheet_title` 传入
164
+ - `new_sheet_title`:**必传**,新的子表名称
165
+ - `fields`:可选,可同时修改列定义
166
+
167
+ **示例:**
168
+
169
+ ```bash
170
+ wecom-cli smartsheet sheets update --json '{"docid": "s3_xxx", "sheet_title": "需求池", "new_sheet_title": "需求管理"}'
171
+ ```
172
+
173
+ #### 场景 3:删除子表
174
+
175
+ 删除整个子表。
176
+
177
+ **参数要求:**
178
+
179
+ - `sheet_title`:**必传**,要删除的子表名称
180
+
181
+ > 👆 若只剩最后一个子表,须遵循上方**删除最后一个子表/字段/视图固定流程**。
182
+
183
+ **示例:**
184
+
185
+ ```bash
186
+ wecom-cli smartsheet sheets delete --json '{"docid": "s3_xxx", "sheet_title": "需求池"}'
187
+ ```
188
+
189
+ ---
190
+
191
+ ### 二、字段操作(smartsheet fields add / update / delete)
192
+
193
+ > - `wecom-cli smartsheet fields add`:新增字段
194
+ > - `wecom-cli smartsheet fields update`:修改字段
195
+ > - `wecom-cli smartsheet fields delete`:删除字段
196
+
197
+ > 新增字段(`add`)或修改字段名称(`update`)之前必须调用 `wecom-cli smartsheet fields list` 检查是否存在同名字段,字段名称在同一子表内不可重复
198
+
199
+ ```bash
200
+ wecom-cli smartsheet fields add --json '{"docid": "<docid>", "sheet_title": "<子表名称>", "fields": [...]}'
201
+ wecom-cli smartsheet fields update --json '{"docid": "<docid>", "sheet_title": "<子表名称>", "fields": [...]}'
202
+ wecom-cli smartsheet fields delete --json '{"docid": "<docid>", "sheet_title": "<子表名称>", "fields": [{"field_title": "<字段名>"}]}'
203
+ ```
204
+
205
+ **请求参数 (JSON 格式传入):**
206
+
207
+ | 参数 | 类型 | 必填 | 说明 |
208
+ | --- | --- | --- | --- |
209
+ | `docid` | string | 是 | 文档 ID |
210
+ | `sheet_title` | string | 是 | 目标子表名称 |
211
+ | `fields` | Field[] | 是 | 字段列表,结构与 `sheets update` 中的 `fields` 完全相同 |
212
+
213
+ **Field 字段填写规则:**
214
+
215
+ | 操作命令 | Field 需传字段 | 说明 |
216
+ | --- | --- | --- |
217
+ | `fields add` | `field_title` + `field_type` + `property_xxx` | 新增字段时必须指定标题、类型,以及对应类型的属性 |
218
+ | `fields update` | `field_title` + `field_type`(必传) + 可选 `new_field_title` / `property_xxx` | 修改字段时必须指定字段名称和字段类型 |
219
+ | `fields delete` | `field_title` | 删除字段时需指定字段名称 |
220
+
221
+ > 完整字段类型枚举及 `property_xxx` 属性定义见 `references/smart-sheet-field-types.md`。
222
+
223
+ **新增字段后,必须立即调整列宽(强制):**
224
+
225
+ 从返回值取得所有新建字段的 `field_title`,按 `references/smart-sheet-view-types.md` 中「新建字段时的列宽判断规则」和「列宽调整接口调用方式」完成列宽写入。
226
+
227
+ ---
228
+
229
+ ### 三、记录操作(smartsheet records add / update / delete)
230
+
231
+ 根据文档 ID 和工作表 ID,新建、更新、删除记录(支持批处理)。
232
+
233
+ > - `wecom-cli smartsheet records add`:新增记录
234
+ > - `wecom-cli smartsheet records update`:修改记录
235
+ > - `wecom-cli smartsheet records delete`:删除记录
236
+
237
+ > `wwgroup`(群)不支持 API 写入。写前必读机制见本文件「编辑强制规范」。
238
+
239
+ ```bash
240
+ wecom-cli smartsheet records add --json '{"docid": "<docid>", "sheet_title": "<子表名称>", "records": [{"values": {"<字段名称>": "<字段值>"}}]}'
241
+ wecom-cli smartsheet records update --json '{"docid": "<docid>", "sheet_title": "<子表名称>", "records": [{"record_id": "<记录ID>", "values": {"<字段名称>": "<字段值>"}}]}'
242
+ wecom-cli smartsheet records delete --json '{"docid": "<docid>", "sheet_title": "<子表名称>", "records": [{"record_id": "<记录ID>"}]}'
243
+ ```
244
+
245
+ **请求参数 (JSON 格式传入):**
246
+
247
+ | 参数 | 类型 | 必填 | 说明 |
248
+ | --- | --- | --- | --- |
249
+ | `docid` | string | 是 | 文档 ID |
250
+ | `sheet_title` | string | 是 | 子表名称,用于定位目标子表 |
251
+ | `records` | array | 是 | 行记录列表;单次请求长度为 1~2000,不允许传空;总量超过 2000 时按每批最多 2000 条拆分请求 |
252
+ | `records[].record_id` | string | 否 | 行记录 ID(修改或删除时必填) |
253
+ | `records[].values` | object | 否 | 字段值,key 为字段名称(`field_title`),value 格式取决于字段类型,详见 `references/smart-sheet-record-values.md` |
254
+
255
+ > - `records add`:records 只传 `values`
256
+ > - `records update`:records 传 `record_id` + `values`
257
+ > - `records delete`:records 只需传 `record_id`
258
+ > - 单次请求的 `records` 数组最多 2000 条。待处理记录总量不限;超过 2000 条时必须拆成多次请求,每批最多 2000 条,直至全部完成
259
+
260
+ #### Record 值格式示例
261
+
262
+ | 字段类型 | 值格式 | 示例 |
263
+ | --- | --- | --- |
264
+ | 文本 | 字符串 | `{"品牌": "金士顿"}` |
265
+ | 数字 | 直接数字 | `{"价格": 399}` |
266
+ | 日期 | 标准日期格式字符串 | `{"日期": "YYYY-MM-DD HH:mm:ss"}` |
267
+ | 单选/多选 | `[{"id": "选项ID", "text": "选项文本"}]` | `{"状态": [{"id": "opt_xxx", "text": "进行中"}]}` |
268
+ | 人员 | `[{"userId": "userid", "userName": "姓名"}]`(写入支持仅传其一) | `{"负责人": [{"userName": "张三"}]}` |
269
+
270
+ **属性枚举值**:必须严格使用 `references/smart-sheet-field-types.md` 中定义的常量。
271
+
272
+ **字段键名**:必须使用 field_title(字段名称,如 `品牌`),不能使用 field_id(如 `f04Gwj`)。
273
+
274
+ **请求示例:**
275
+
276
+ **新增行(使用 `sheet_title` 定位子表,`field_title` 作为 values 的 key):**
277
+
278
+ ```json
279
+ {
280
+ "docid": "DOCID",
281
+ "sheet_title": "任务列表",
282
+ "records": [
283
+ {
284
+ "values": {
285
+ "任务名称": "新任务A",
286
+ "预算": 100,
287
+ "状态": [{ "id": "opt_1", "text": "进行中", "style": 3 }]
288
+ }
289
+ }
290
+ ]
291
+ }
292
+ ```
293
+
294
+ **更新行:**
295
+
296
+ ```json
297
+ {
298
+ "docid": "DOCID",
299
+ "sheet_title": "任务列表",
300
+ "records": [
301
+ {
302
+ "record_id": "re9IqD",
303
+ "values": {
304
+ "任务名称": "更新后的任务名",
305
+ "状态": [{ "id": "opt_2", "text": "已完成", "style": 4 }]
306
+ }
307
+ }
308
+ ]
309
+ }
310
+ ```
311
+
312
+ **删除行:**
313
+
314
+ ```json
315
+ {
316
+ "docid": "DOCID",
317
+ "sheet_title": "任务列表",
318
+ "records": [{ "record_id": "re9IqD" }, { "record_id": "rpS0P9" }]
319
+ }
320
+ ```
321
+ > 提示:**values** 中的 key 必须是**字段名称**,可通过 `wecom-cli smartsheet fields list` 获取。各字段类型的 value 格式详见 `references/smart-sheet-record-values.md`。
322
+
323
+ **返回值:**
324
+
325
+ | 字段 | 类型 | 说明 |
326
+ | --- | --- | --- |
327
+ | `errcode` | int | `0` 表示执行成功 |
328
+ | `records` | array | 写入的行记录列表,每项包含 `record_id` 和 `values` |
329
+
330
+ #### `851003 no authority` 的 Webhook 兜底
331
+
332
+ `wecom-cli smartsheet records add` 或 `wecom-cli smartsheet records update` 返回 `errcode: 851003`,或 `errmsg` 包含 `no authority` 时,通常表示企业可见范围超过 10 人,CLI 写入接口受到规模限制。此时:
333
+
334
+ 1. 停止重试 CLI 写入;
335
+ 2. 完整阅读 `references/smart-sheet-webhook.md`;
336
+ 3. 临时向用户索取目标子表的 Webhook 完整 URL 和「接收外部数据」页面的 schema 示例 JSON;
337
+ 4. 使用 Webhook 专用字段格式构造并发送请求;
338
+ 5. 写入完成后仍按 `references/smart-sheet-read.md` 读取目标数据进行验证。
339
+
340
+ 仅新增和更新记录使用该兜底。删除记录、结构操作、参数错误、字段错误、文档不存在等场景不应切换 Webhook。Webhook 更新还受额外限制:只能更新此前通过 Webhook 写入的记录,不能更新人工创建或通过普通接口创建的记录。
341
+
342
+ ### 四、视图操作(smartsheet views add / update / delete)
343
+
344
+ 根据文档 ID 和工作表 ID,新建、更新、删除视图,以及调整列宽。
345
+
346
+ > - `wecom-cli smartsheet views add`:新增视图
347
+ > - `wecom-cli smartsheet views update`:修改视图
348
+ > - `wecom-cli smartsheet views delete`:删除视图
349
+
350
+ > **新建视图前必须查重**:
351
+ > 1. 先调用 `wecom-cli smartsheet views list --json '{"docid":"<docid>","sheet_title":"<子表名称>","limit":100}'` 获取现有视图。
352
+ > 2. 如果同名视图已存在,优先用简洁自然语言询问用户是否修改该视图;如果用户不同意,则请用户提供新名称,或者询问是否在原名称后追加数字,不得自行决定。
353
+
354
+ ```bash
355
+ wecom-cli smartsheet views add --json '{"docid": "<docid>", "sheet_title": "<子表名称>", "views": [...]}'
356
+ wecom-cli smartsheet views update --json '{"docid": "<docid>", "sheet_title": "<子表名称>", "views": [...]}'
357
+ wecom-cli smartsheet views delete --json '{"docid": "<docid>", "sheet_title": "<子表名称>", "views": [...]}'
358
+ ```
359
+
360
+ > 📖 **完整参数结构(ViewParam、ViewType 枚举、ViewProperty、甘特/日历视图属性、过滤/排序/分组/填色/列宽等)均定义在 `references/smart-sheet-view-types.md`,使用前必须查阅,禁止凭猜测填写。**
361
+
362
+ **顶层参数:**
363
+
364
+ **请求参数 (JSON 格式传入):**
365
+
366
+ | 参数 | 类型 | 必填 | 说明 |
367
+ | --- | --- | --- | --- |
368
+ | `docid` | string | 是 | 文档 ID |
369
+ | `sheet_title` | string | 是 | 子表名称,用于定位目标子表 |
370
+ | `views` | ViewParam[] | 否 | 视图信息列表,结构见 `references/smart-sheet-view-types.md` |
371
+
372
+ **返回值:**
373
+
374
+ | 字段 | 类型 | 说明 |
375
+ | --- | --- | --- |
376
+ | `errcode` | int | `0` 表示执行成功 |
377
+ | `views` | array | 写入的视图信息列表,每项包含 `view_id`、`view_title`、`view_type`、`property` |
378
+
379
+ ---
380
+
381
+ ### 五、图表操作(smartsheet charts add / update / delete)
382
+
383
+ 根据文档 ID 和工作表 ID,新建、更新、删除图表。
384
+
385
+ > 无论是新建、更新一个图表还是多个图表,在请求体里传入一个charts数组,传入一个或多个图表。
386
+ > 更新图表时,必须把原有的属性参数,一并传入(后台不支持Partial属性合并)。
387
+ > 图表都有自己的布局位置(layout,由x,y坐标和宽高决定)。在修改图表时,必须确保 layout 不与现有的任意一个图表重叠。
388
+
389
+ ```bash
390
+ wecom-cli smartsheet charts add --json '{"docid": "<docid>", "sheet_title": "<仪表盘名称>", "charts": [{"id": "<图表ID>", "type": "<图表类型>", "datasource": "<数据表名称>", "layout": {"xy": [0, 0], "width_height": [3, 4]}}]}'
391
+ wecom-cli smartsheet charts update --json '{"docid": "<docid>", "sheet_title": "<子表名称>", "charts": [{"id": "<图表ID>", ...}]}'
392
+ wecom-cli smartsheet charts delete --json '{"docid": "<docid>", "sheet_title": "<子表名称>", "charts": [{"id": "<图表ID>"}]}'
393
+ ```
394
+
395
+ **请求参数 (JSON 格式传入):**
396
+
397
+ | 参数 | 类型 | 必填 | 说明 |
398
+ | --- | --- | --- | --- |
399
+ | `docid` | string | 是 | 文档 ID |
400
+ | `sheet_title` | string | 是 | 子表名称(仪表盘名称),用于定位目标子表 |
401
+ | `charts` | Chart[] | 是 | 图表结构列表,【**必须**】查阅 `references/smart-sheet-chart-types.md` 中的 Chart 结构定义,【**禁止**】凭猜测填写图表参数 |
402
+
403
+ > 完整图表类型定义见 `references/smart-sheet-chart-types.md`,使用前必须查阅。
404
+
405
+ > **combo 图(组合图/双轴图)的特殊约束**:
406
+ > - `combo` 图的 `series` 必须 **≥ 2 项**,**不能为空数组**(combo 的语义是"柱+线"等多系列组合,单系列或零系列不成立);
407
+
408
+ #### 图表创建前的字段校验
409
+ 在创建图表时,如果用户指定的字段无法满足需求,应该:
410
+ 1. 先校验用户指定的字段类型是否支持该图表类型
411
+ 2. 如果不支持,直接告知用户无法执行,说明原因
412
+ 3. 提供替代方案并等待用户确认后再执行
413
+
414
+ **请求示例:**
415
+
416
+ **新增图表:**
417
+
418
+ ```json
419
+ {
420
+ "docid": "DOCID",
421
+ "sheet_title": "数据看板",
422
+ "charts": [
423
+ {
424
+ "title": "月度销售趋势",
425
+ "type": "line",
426
+ "datasource": "任务列表",
427
+ "category": {
428
+ "field_title": "月份"
429
+ },
430
+ "series": [
431
+ {
432
+ "field_title": "销售额",
433
+ "aggregation": "sum"
434
+ },
435
+ {
436
+ "field_title": "利润",
437
+ "aggregation": "avg"
438
+ }
439
+ ],
440
+ "layout": {
441
+ "width_height": [3, 4],
442
+ "xy": [0, 0]
443
+ }
444
+ }
445
+ ]
446
+ }
447
+ ```
448
+
449
+ **更新图表:**
450
+
451
+ ```json
452
+ {
453
+ "docid": "DOCID",
454
+ "sheet_title": "数据看板",
455
+ "charts": [
456
+ {
457
+ "id": "cht_001",
458
+ "title": "年度销售趋势",
459
+ "type": "bar",
460
+ "datasource": "任务列表",
461
+ "category": {
462
+ "field_title": "季度",
463
+ "sub_field_title": "区域"
464
+ },
465
+ "series": [
466
+ {
467
+ "field_title": "销售额",
468
+ "aggregation": "sum"
469
+ }
470
+ ],
471
+ "layout": {
472
+ "width_height": [6, 4],
473
+ "xy": [0, 0]
474
+ }
475
+ }
476
+ ]
477
+ }
478
+ ```
479
+
480
+ **删除图表:**
481
+
482
+ ```json
483
+ {
484
+ "docid": "DOCID",
485
+ "sheet_title": "数据看板",
486
+ "charts": [
487
+ {
488
+ "id": "cht_001"
489
+ }
490
+ ]
491
+ }
492
+ ```
493
+
494
+ **返回值:**
495
+
496
+ | 字段 | 类型 | 说明 |
497
+ | --- | --- | --- |
498
+ | `errcode` | int | `0` 表示执行成功 |
499
+ | `charts` | array | 写入的图表信息列表,每项包含 `id`、`title`、`type`、`datasource` 等 |
500
+
501
+ ---
502
+
503
+ ## 典型工作流与示范
504
+
505
+ 以下示例展示常见的智能表格操作流程,供参考。
506
+
507
+ > **读取类操作的通用流程**:若用户未提供 `docid`,先通过 `wecomcli-doc-manage` 技能的搜索文档接口获取;再调用 `wecom-cli smartsheet sheets list` 获取子表列表,如需字段详情或未返回 `fields`,必须针对具体子表调用 `wecom-cli smartsheet fields list`。
508
+
509
+ ### 示例一:向智能表格新增记录
510
+
511
+ **用户意图**:「在智能表格 s3_xxx 的"需求池"子表中新增一条记录,标题为"登录优化",优先级为"高"」
512
+
513
+ **执行步骤**:
514
+
515
+ 1. 先调用 `wecom-cli smartsheet sheets list` 获取子表列表,确认"需求池"子表存在;
516
+ 2. 调用 `wecom-cli smartsheet fields list` 查询"需求池"的字段详情,确认"标题"字段(类型为文本)和"优先级"字段(类型为单选)存在,并取得单选选项 ID;
517
+ 3. 调用 `wecom-cli smartsheet records add` 新增记录:
518
+ ```
519
+ {"docid": "s3_xxx", "sheet_title": "需求池", "records": [{"values": {"标题": "登录优化", "优先级": [{"id": "opt_xxx", "text": "高"}]}}]}
520
+ ```
521
+ 4. 新增成功后告知用户。
522
+
523
+ 若第 3 步返回 `851003` / `no authority`,不要重复调用 `records add`;改为完整阅读 `references/smart-sheet-webhook.md`,向用户临时索取 Webhook 完整 URL 与 schema 示例 JSON 后走 Webhook 兜底写入。
524
+
525
+ ---
526
+
527
+ ### 示例二:修改表结构
528
+
529
+ **用户意图**:「把智能表格 s3_xxx 中"需求池"这个子表删除」
530
+
531
+ **执行步骤**:
532
+
533
+ 1. 先调用 `wecom-cli smartsheet sheets list` 确认"需求池"子表存在:
534
+ ```
535
+ {"docid": "s3_xxx"}
536
+ ```
537
+ 2. 调用 `wecom-cli smartsheet sheets delete` 执行删除子表(不传 `fields`):
538
+ ```
539
+ {"docid": "s3_xxx", "sheet_title": "需求池"}
540
+ ```
541
+ 3. 删除成功后告知用户。
542
+
543
+ ---
544
+
545
+ ## 注意事项
546
+
547
+ > 以下为编辑接口的补充说明;通用安全和交互约束见 `SKILL.md`。
548
+
549
+ - **创建时一次性初始化字段**:新建智能表格时,优先使用 `wecom-cli smartsheet create` 并同时传入 `sheet_title` + `fields`,避免拆分为"创建后再补字段"
550
+ - **默认字段处理仅作兜底**:仅当历史表已创建且字段不符合需求时,再通过 `wecom-cli smartsheet sheets list` + `wecom-cli smartsheet fields list` + `wecom-cli smartsheet fields update/delete/add` 执行重命名/删除/新增
551
+ - **至少保留一个文本字段**:删除接口要求至少保留一个文本类型字段
552
+ - **字段操作统一用 `fields` 命令**:新增/修改/删除字段一律使用 `wecom-cli smartsheet fields add/update/delete`,不通过 `sheets` 命令操作字段(`sheets add` 初始化列除外)
553
+ - **新增子表可同时创建字段**:`sheets add` 时可传入 `fields` 一步到位
554
+ - **字段添加顺序**:系统按添加顺序排列,建议按业务逻辑顺序依次添加
555
+ - **添加/更新字段必须带属性**:日期、超链接、人员、单选、多选、数字等类型须带 `property_xxx`,仅纯文本无需
556
+ - **人员字段值格式**:`[{"userId": "<userid>"}]` 或者 `[{"userName": "<姓名>"}]`
557
+ - **日期字段值格式**:标准日期字符串 `"YYYY-MM-DD HH:mm:ss"`,非时间戳
558
+ - **单表限制**:单个子表最多 20000 条记录、150 个字段
559
+ - **附件文档默认仅作参考**:用户表达"参考/按上传表头格式"等意图时,默认新建智能表格写入,上传文档仅作结构参考;在未明确写回授权前禁止对上传文档执行写操作
560
+
561
+ ---
562
+
563
+ ## 参数补全
564
+
565
+ 当用户提供的信息不足以完成操作时(如缺少必填参数),**必须用简洁自然语言追问缺失或有歧义的信息;有候选项时在文字中列出,禁止自行猜测默认值。**
566
+
567
+ ### 何时触发?
568
+
569
+ 当用户发起智能表格操作的意图,但以下任一必填信息缺失时,触发参数补全:
570
+
571
+ | 缺失信息 | 对应接口/字段 | 示例用户表述 |
572
+ | --- | --- | --- |
573
+ | 目标智能表格 | `docid`(所有接口) | "帮我看看智能表格的数据"(没说哪个智能表格)/ "参考xxx附件,转为智能表格"(没说是在原有表格上修改还是新建表格) |
574
+ | 子表 | `sheet_title`(records add/update/delete/query、views add/update/delete、charts add/update/delete) | "帮我加条记录"(没说加到哪个子表) |
575
+ | 操作类型 | 命令动词(sheets/records/views/charts 的 add/update/delete) | "帮我改一下表格"(没说是新增、修改还是删除) |
576
+ | 子表名称 | `sheet_title`(sheets add) | "帮我新建一个子表"(没说叫什么名字) |
577
+ | 字段定义 | `fields`(sheets add 初始化列时) | "帮我加几个字段"(没说加什么字段、什么类型) |
578
+ | 记录内容 | `records[].values`(records add) | "帮我往表里加条数据"(没说加什么内容) |
579
+
580
+ ### 正确做法
581
+
582
+ 1. 分析用户已提供的信息,确定哪些必填参数缺失
583
+ 2. **仅对缺失的参数进行提问**(用户已明确的参数不要重复问)
584
+ 3. 收到用户回答后,组装完整的入参;四要素唯一确定时直接执行,只有业务规则要求确认的场景再用自然语言明确确认
585
+
586
+ ### 禁止事项
587
+
588
+ - ❌ 参数缺失时自行猜测默认值(如随意假设目标智能表格、子表、字段类型或记录内容)
589
+ - ❌ 用户已明确的参数还重复提问