dsh-vscode-mode 0.29.2 → 0.31.0

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/README.md +120 -11
  2. package/lib/client.js +178 -51
  3. package/lib/client.js.map +1 -1
  4. package/lib/index.js +4860 -1576
  5. package/lib/index.js.map +1 -1
  6. package/package.json +1 -1
  7. package/skills/dsh-vscodemode-html-plan/LICENSE +202 -0
  8. package/skills/dsh-vscodemode-html-plan/SKILL.md +147 -0
  9. package/skills/dsh-vscodemode-html-plan/examples/scheduled-send.html +298 -0
  10. package/skills/dsh-vscodemode-html-plan/references/blocks.md +227 -0
  11. package/skills/dsh-vscodemode-html-plan/references/subagent-brief.md +17 -0
  12. package/skills/dsh-vscodemode-html-plan/references/upstream-SKILL.md +174 -0
  13. package/skills/dsh-vscodemode-html-plan/runtime/htmlplan.css +564 -0
  14. package/skills/dsh-vscodemode-html-plan/runtime/htmlplan.js +1299 -0
  15. package/skills/dsh-vscodemode-html-plan/runtime/pack.mjs +300 -0
  16. package/src/ai/llmTask.ts +178 -0
  17. package/src/ai/llmTypes.ts +6 -0
  18. package/src/ai/svnCommitMsg.ts +107 -0
  19. package/src/ai/svnTriage.ts +34 -85
  20. package/src/client/aiCommit.ts +57 -0
  21. package/src/client/compatSummary.ts +15 -0
  22. package/src/client/editorFlush.ts +55 -0
  23. package/src/client/featurePrefs.ts +63 -0
  24. package/src/client/htmlPlan/HtmlPlanPanel.ts +261 -0
  25. package/src/client/htmlPlan/planActions.ts +347 -0
  26. package/src/client/htmlPlan/planPage.ts +333 -0
  27. package/src/client/htmlPreview.ts +218 -0
  28. package/src/client/index.ts +43 -0
  29. package/src/client/monaco/loader.ts +71 -9
  30. package/src/client/monaco/templateLanguages.ts +300 -0
  31. package/src/client/officialSidebar.ts +16 -4
  32. package/src/client/openPathRouter.ts +7 -0
  33. package/src/client/planState.ts +8 -2
  34. package/src/client/refCopy.ts +70 -0
  35. package/src/client/refIntake.ts +215 -0
  36. package/src/client/sidebar/menuItems.ts +11 -0
  37. package/src/client/sidebar/panels/FileExplorer.ts +11 -0
  38. package/src/client/sidebar/panels/SearchPanel.ts +214 -4
  39. package/src/client/sidebar/panels/SvnPanel.ts +17 -0
  40. package/src/client/sidebar/types.ts +2 -0
  41. package/src/client/styles/editor.css +112 -0
  42. package/src/client/svnActions.ts +7 -0
  43. package/src/client/svnCommit.ts +109 -0
  44. package/src/client/svnNotice.ts +1 -1
  45. package/src/client/svnStatus.ts +5 -2
  46. package/src/client/ui/DiffLauncher.ts +3 -1
  47. package/src/client/ui/EditorView.ts +221 -14
  48. package/src/client/ui/McpSettings.ts +108 -1
  49. package/src/client/ui/SvnAiPlanDialog.ts +24 -4
  50. package/src/client/ui/SvnCommitDialog.ts +458 -0
  51. package/src/client/ui/commandCatalog.ts +11 -0
  52. package/src/client/ui/svnCommitModel.ts +204 -0
  53. package/src/client/univer/UniverCacheSettings.ts +75 -0
  54. package/src/client/univer/UniverHost.ts +177 -0
  55. package/src/client/univer/api.ts +30 -0
  56. package/src/client/univer/routing.ts +32 -0
  57. package/src/client/univer/store.ts +111 -0
  58. package/src/fileOpenSettings.ts +118 -6
  59. package/src/htmlPlanCommand.ts +176 -0
  60. package/src/index.ts +4 -0
  61. package/src/paths.ts +5 -0
  62. package/src/refPointer.ts +193 -0
  63. package/src/rpc.ts +51 -0
  64. package/src/search/replacePlan.ts +144 -0
  65. package/src/search/replaceRun.ts +289 -0
  66. package/src/shared/keybindings.ts +11 -0
  67. package/src/shared/refSyntax.ts +106 -0
  68. package/src/shared/rpc.ts +28 -4
  69. package/src/shared/snippets.ts +17 -0
  70. package/src/shared/svn.ts +191 -10
  71. package/src/shared/svnActions.ts +16 -0
  72. package/src/shared/univer.ts +90 -0
  73. package/src/svn.ts +205 -47
  74. package/src/svnCommit.ts +348 -0
  75. package/src/svnCore.ts +254 -0
  76. package/src/svnToolJson.ts +73 -0
  77. package/src/svnTools.ts +566 -0
  78. package/src/univerBridge.ts +83 -0
  79. package/src/univerCache.ts +205 -0
  80. package/src/univerRpc.ts +144 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-vscode-mode",
3
- "version": "0.29.2",
3
+ "version": "0.31.0",
4
4
  "description": "DSH 上的类 VSCode 编码体验:Monaco 编辑器(文件页签/QuickOpen/状态栏,可驻 DSH 0.1.5+ 官方右侧 Sidebar 与对话同屏)+ 命令栏(Ctrl+Shift+P)与可扩展指令系统 + VS Code 兼容代码片段(.code-snippets 全局/项目,IntelliSense 展开)+ Agent 编辑差异审查(整文件差异/采纳/拒绝/归档/回滚)+ SVN 集成(侧栏变更面板/日志弹窗/并排差异)+ 语言服务器(LSP)智能(跳转定义/引用/hover/大纲 + VSIX 扩展市场安装),状态持久化到工作区旁车,界面状态(页签/光标/侧栏/编辑 Tab/导航历史)镜像到 DSH home 跨重启恢复",
5
5
  "icon": "assets/icon.svg",
6
6
  "keywords": [
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,147 @@
1
+ ---
2
+ name: dsh-vscodemode-html-plan
3
+ description: 把实施计划写成一份单文件交互式 HTML 计划页(主张树:为什么 › 能做什么 › 怎么做 › 在哪;每条主张配一个图示;需要用户拍板的决策挂在它影响的主张上),并接入 DSH 计划模式的状态、审批与退出流程。
4
+ whenToUse: 用户输入 /html-plan;或 plan 模式下要求给出可逐项作答的 HTML 计划/方案/设计稿/RFC;或计划里有 2~5 个必须用户拍板的岔口时。
5
+ ---
6
+
7
+ # html-plan(DSH 版)
8
+
9
+ 本技能包含上游 anthropics/claude-plugins-community 的 html-plan 运行时与规则(MIT,作者 Thariq Shihipar),
10
+ 按 DSH 计划模式改写:页面在 dsh-vscode-mode 的计划页签中渲染,审批与退出仍走官方计划模式。
11
+
12
+ ## 0. 快捷入口
13
+
14
+ - 用户输入 `/html-plan <任务>`:宿主命令会进入计划模式,并把「用本技能产出 HTML 计划页」的指令作为用户消息发出。
15
+ - 只输入 `/html-plan`:同样进入计划模式,但指令要求先问清要规划的任务。
16
+ - 用户已 `/plan`:按本技能正常产出即可,插件在 `exit_plan_mode` 时渲染 HTML 计划页。
17
+
18
+ ## 1. 何时用
19
+
20
+ - 当前处于 plan 模式(/plan),或用户明确要求「先出计划/方案/设计稿/RFC」。
21
+ - 计划里存在必须用户拍板的岔口(2~5 个):范围、取舍、默认值。
22
+
23
+ ## 2. 产出约定(DSH 特有,必读)
24
+
25
+ 1. 位置:plans/<slug>/plan.html。slug 用 kebab-case,例如 plans/html-plan/plan.html。
26
+ 2. 复制运行时:把本技能目录的 runtime/htmlplan.css、runtime/htmlplan.js、runtime/pack.mjs
27
+ 复制到 plans/<slug>/runtime/。
28
+ 3. 页面引用(相对路径):
29
+ <link rel="stylesheet" href="runtime/htmlplan.css">
30
+ <script src="runtime/htmlplan.js" defer></script>
31
+ 4. 打包:node plans/<slug>/runtime/pack.mjs plans/<slug>/plan.html --root <工作区绝对路径>。
32
+ 产物为 plans/<slug>/plan.packed.html(单文件、可离线)。按 pack 报告逐条修错误与警告。
33
+ 5. 清理:打包成功后删除 plans/<slug>/runtime/ 与未打包的 plan.html,只留 packed 单文件,避免仓库噪声。
34
+ 6. 提交审批:调用 exit_plan_mode。plan 正文第一行必须是「# 计划:<标题>」,并且**必须包含一行**:
35
+
36
+ HTML 计划页:plans/<slug>/plan.packed.html
37
+
38
+ 插件据这一行在计划页签渲染 HTML;缺少该行则回落 Markdown 计划预览。
39
+ 7. 正文同时写 3~6 行摘要与决策清单:官方审批卡片只显示标题与两行纯文本摘要,
40
+ 正文是官方「查看全文」与历史卡片的内容来源。
41
+
42
+ ## 3. 主张树(沿用上游)
43
+
44
+ 每一层回答一个问题,问题决定配什么图示。
45
+
46
+ | 层级 | 回答 | 主张 | 图示 |
47
+ |---|---|---|---|
48
+ | h1 | 这是什么? | 3~7 个词的标题 | 无 |
49
+ | details.thread | 为什么? | — | 用户自己的话(封闭引用) |
50
+ | 1 | 用户现在能做什么/看到什么? | 一个行为 | doc-mock;有生命周期用 doc-machine |
51
+ | 2 | 它怎么工作? | 一个入口、规则或记录 | doc-calls、doc-schema 或短 doc-code |
52
+ | 3 | 在哪? | file:line | doc-code |
53
+
54
+ HTML 骨架(可复制后改写):
55
+
56
+ ```html
57
+ <!doctype html>
58
+ <html lang="zh-CN">
59
+ <meta charset="utf-8">
60
+ <title>计划标题</title>
61
+ <link rel="stylesheet" href="runtime/htmlplan.css">
62
+ <script src="runtime/htmlplan.js" defer></script>
63
+ <body>
64
+ <header>
65
+ <h1>计划标题(3~7 词)</h1>
66
+ <doc-changes new="5" changed="4"></doc-changes>
67
+ <details class="thread"><summary>为什么</summary>…doc-quote…</details>
68
+ </header>
69
+ <main>
70
+ <doc-plan>
71
+ <doc-claim>
72
+ <p>用户现在能选择发送时间。</p>
73
+ <doc-mock frame="none" w="440">…</doc-mock>
74
+ <doc-claim>
75
+ <p>「稍后发送」只保存时间,不发送。</p>
76
+ <doc-calls …>…</doc-calls>
77
+ <doc-claim at="src/routes.ts:18">
78
+ <p><b>routes.ts:18</b> · createScheduled()</p>
79
+ <doc-code …>…</doc-code>
80
+ </doc-claim>
81
+ </doc-claim>
82
+ <doc-claim>
83
+ <p>每个用户最多保留 50 条待发消息。</p>
84
+ <doc-code …>…</doc-code>
85
+ <doc-ask id="limit">…</doc-ask>
86
+ </doc-claim>
87
+ </doc-claim>
88
+ <doc-claim aux="shared"><p>共用:一张新表。</p><doc-schema lang="sql" …>…</doc-schema></doc-claim>
89
+ <doc-claim aux="scope"><p>不改:普通发送、草稿、邮件服务商。</p><ul>…</ul></doc-claim>
90
+ </doc-plan>
91
+ </main>
92
+ </body></html>
93
+ ```
94
+
95
+ 规则(pack.mjs 检查 2、3、5、6、7、11;其余自查):
96
+
97
+ 1. 顶层按行为拆,不按文件、层或工作顺序拆。
98
+ 2. 1/2 层每条主张都必须是可真可假的句子(约 12 词内);3 层只写位置 file:line · symbol。
99
+ 3. 一条主张只配一个图示;第二个图示就是第二条主张。
100
+ 4. 收起状态就是摘要:只读 1 层主张,必须讲清整个改动。不要 TL;DR、不要章节、不要步骤清单。
101
+ 5. 每层最多 5 个孩子,最多 3 层。
102
+ 6. 决策挂在它改变的那条主张上(图示之后、子主张之前),默认勾选你会选的;
103
+ 如果某个选项会删掉一条主张,写明「主张 4 移除」。只问会改变实现的岔口,2~5 个。
104
+ 7. 结尾必须有 aux="shared"(共用记录,可省略)与 aux="scope"(明确不改什么)。
105
+ 8. 真实优先:已存在的代码给真实路径与行号,用 src="path" lines="a-b";
106
+ 尚不存在的代码在标题里标注「草图」。引用用户原话,不改写。
107
+ 9. Schema 用项目自身语言(TypeScript/SQL/protobuf),不要自造表格或符号。
108
+ 10. 状态机会改变用户所见时,每个状态都要画屏幕,摆在网格上。
109
+ 11. 页面以标题开头:h1 命名「改动 + 位置」,3~7 词,不是句子,上面不放任何标签行。
110
+
111
+ ## 4. 写作
112
+
113
+ 图示才是计划,文字只负责命名。
114
+
115
+ - 中文正文:短句;一句一个主题;主动语态;术语全文一致;「必须」表示规则,「可以」表示可能;
116
+ 不用「应该/也许」;不用缩略语与玩笑。
117
+ - 英文正文:沿用上游 ASD-STE100 简化技术英语规则;不确定的词用最常见短词。
118
+ - 标题一句话说明「注意什么」;pin 是短语;选项说明(small)不超过 12 词。
119
+ - 主张与图示之间不写解释段落;需要解释就换一个更好的图示。
120
+
121
+ ## 5. 决策与答复
122
+
123
+ - 页面底部按钮「N 个待回答」跳到下一个未展开的决策;每个决策有编号(如「决策 2 / 4」)。
124
+ - 用户点 Respond 后出现一份 markdown 答复;点「回复」直接发送给 agent(等同把答复发回对话)。
125
+ - 发送失败时插件会恢复按钮并提示原因;此时可用 Copy response 或计划页签顶部「填入对话输入框」。
126
+ - 有待审批卡片时,「回复」= 先「同意执行」再发送答复(agent 从下一步开始执行);要改计划请先点页签「继续规划」,再回复反馈。
127
+
128
+ ## 6. DSH 计划页签与状态
129
+
130
+ - 计划页签显示状态:计划中 / 待审批 / 已批准(已退出计划模式)/ 继续规划 / 已退出计划模式。
131
+ -「同意执行」「继续规划」等价于官方审批卡片的同名操作,走官方问答通道;
132
+ 「退出计划模式」等价于 composer 计划徽标的 /plan off;官方审批卡片仍是权威通道。
133
+ - 任一官方客户端服务缺失时按钮降级为提示,不会伪造批准。
134
+
135
+ ## 7. 委派写页(可选)
136
+
137
+ - 默认自己写。满足任一条件时,先按 Agent 协作规则征求同意再委派:预计页 >12 KB、主张/图示 ≥4、上下文紧张。
138
+ - 用户写 `/html-plan --delegate` 视为本任务已授权;`--no-delegate` 明确不委派。
139
+ - 用 subagent_fork(cwd = 工作区),父级先定稿主张树,再交固定摘要(模板见 references/subagent-brief.md)。
140
+ - 子级只写页并 pack,返回 packed 路径、lint 结果、主张/决策计数;父级只验 lint、计数与三处抽查,不读全文。
141
+ - 子级失败(不能写文件 / 缺 pack / lint 错)时父级自己写,不中断计划。
142
+
143
+ ## 8. 上游资产与许可
144
+
145
+ runtime/、references/blocks.md、examples/scheduled-send.html 来自上游 html-plan
146
+ (仓库 anthropics/claude-plugins-community,MIT,作者 Thariq Shihipar),未修改。
147
+ 本目录 LICENSE 保留上游许可原文;改写部分(本 SKILL.md 的 DSH 约定)同样以 MIT 提供。
@@ -0,0 +1,298 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <meta charset="utf-8">
4
+ <title>Scheduled Send Plan</title>
5
+ <link rel="stylesheet" href="../runtime/htmlplan.css">
6
+ <script src="../runtime/htmlplan.js" defer></script>
7
+ <style data-mock-shared>
8
+ .ui { font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #1c1b19; background: #fff; border: 1px solid #ddd8cc; border-radius: 10px; overflow: hidden; }
9
+ .ui .hd { padding: 9px 14px; border-bottom: 1px solid #eee9dd; font-weight: 650; display: flex; gap: 8px; align-items: baseline; } .ui .hd small { color: #8a8578; font-weight: 400; }
10
+ .ui .ln { padding: 7px 14px; border-bottom: 1px solid #f3efe6; color: #5f5a4f; } .ui .ln b { color: #1c1b19; font-weight: 600; }
11
+ .ui .body { padding: 12px 14px; color: #5f5a4f; min-height: 46px; }
12
+ .ui .ft { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-top: 1px solid #eee9dd; background: #faf8f3; }
13
+ .ui .btn { font-weight: 600; font-size: 13px; padding: 7px 12px; border-radius: 7px; border: 1px solid #ddd8cc; background: #fff; } .ui .btn.pri { background: #1c1b19; color: #fff; border-color: #1c1b19; }
14
+ .ui .menu { margin: 0 14px 12px auto; width: 230px; border: 1px solid #ddd8cc; border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.12); background: #fff; } .ui .menu div { padding: 7px 12px; } .ui .menu div + div { border-top: 1px solid #f3efe6; } .ui .menu .on { background: #f6ede9; }
15
+ .ui .row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 9px 14px; border-bottom: 1px solid #f3efe6; } .ui .row small { color: #8a8578; } .ui .row .t { color: #b4541f; font-weight: 600; font-size: 13px; } .ui .row .acts { grid-column: 1 / -1; color: #8a8578; font-size: 12.5px; }
16
+ .ui .ok { color: #1f7a52; font-weight: 650; } .ui .bad { color: #b42318; font-weight: 650; } .ui .dim { color: #8a8578; }
17
+ </style>
18
+ <body>
19
+
20
+ <header>
21
+ <h1>Scheduling Sent Messages in PostBox</h1>
22
+ <doc-changes new="5" changed="4"></doc-changes>
23
+ <details class="thread"><summary>Why · 2 requests</summary>
24
+ <doc-quote via="prompt" from="the user">add send later to the composer. I need to be able to cancel it, and it must never go out early</doc-quote>
25
+ <doc-quote via="doc" from="support notes">people write replies at night and do not want them to arrive at night</doc-quote>
26
+ </details>
27
+ </header>
28
+
29
+ <main>
30
+ <doc-plan>
31
+
32
+ <!-- ═════ 1 ═════ -->
33
+ <doc-claim>
34
+ <p>The user can pick a time in the composer.</p>
35
+ <doc-mock frame="none" w="440"><template>
36
+ <div class="ui">
37
+ <div class="ln">To <b>dana@example.com</b></div>
38
+ <div class="ln">Subject <b>Notes from today</b></div>
39
+ <div class="body">Here is what we agreed…</div>
40
+ <div class="menu" data-ref="menu"><div>Tomorrow morning <span class="dim">· 8:00</span></div><div class="on">Monday morning <span class="dim">· 8:00</span></div><div>Pick a date and time…</div></div>
41
+ <div class="ft"><span class="btn pri">Send</span><span class="btn" data-ref="later">Send later ▾</span></div>
42
+ </div></template>
43
+ <doc-pin ref="later" title="New button">Send is unchanged.</doc-pin>
44
+ </doc-mock>
45
+
46
+ <doc-claim>
47
+ <p>“Send later” saves the message with a time. It does not send.</p>
48
+ <doc-calls title="Scheduling" caption="Tap the second call to open its code.">
49
+ <script type="text/plain">
50
+ ~ <Composer/> @ web/src/composer/Composer.tsx:41
51
+ + <**SendLaterMenu**/> @ web/src/composer/SendLaterMenu.tsx:12
52
+ + POST /api/scheduled @ web/src/api/scheduled.ts:9
53
+ + **createScheduled**(req) @ server/src/scheduled/routes.ts:18
54
+ + **assertUnderLimit**(userId) @ server/src/scheduled/limits.ts:6
55
+ + **buildScheduled**(body, session) @ server/src/scheduled/build.ts:10
56
+ + insert into scheduled_messages @ server/src/scheduled/store.ts:22
57
+ </script>
58
+ </doc-calls>
59
+ <doc-claim at="server/src/scheduled/routes.ts:18">
60
+ <p><b>routes.ts:18</b> · createScheduled()</p>
61
+ <doc-code title="routes.ts · sketch" lang="ts">
62
+ <script type="text/plain">
63
+ export async function createScheduled(req: Request) {
64
+ const session = requireSession(req)
65
+ await assertUnderLimit(session.userId) // throws at 50
66
+ const row = buildScheduled(await req.json(), session)
67
+ await store.insert(row)
68
+ return json({ id: row.id, sendAt: row.sendAt }, 201)
69
+ }
70
+ </script>
71
+ </doc-code>
72
+ </doc-claim>
73
+ </doc-claim>
74
+
75
+ <doc-claim>
76
+ <p>The server sets the owner and the status. The client cannot.</p>
77
+ <doc-code title="build.ts · sketch" lang="ts" hl="4-5">
78
+ <script type="text/plain">
79
+ export function buildScheduled(body: Body, session: Session): Scheduled {
80
+ return {
81
+ id: randomUUID(),
82
+ userId: session.userId,
83
+ status: 'scheduled',
84
+ sendAt: toUtc(body.sendAt, session.timeZone),
85
+ message: pick(body, ['to', 'subject', 'html']),
86
+ attempts: 0,
87
+ }
88
+ }
89
+ </script>
90
+ <doc-pin line="5" title="From the session, never from the body"></doc-pin>
91
+ </doc-code>
92
+ </doc-claim>
93
+
94
+ <doc-claim>
95
+ <p>A user can hold 50 scheduled messages at most.</p>
96
+ <doc-code title="limits.ts · sketch" lang="ts">
97
+ <script type="text/plain">
98
+ export async function assertUnderLimit(userId: string) {
99
+ if (await store.countScheduled(userId) >= 50) throw new LimitError(50)
100
+ }
101
+ </script>
102
+ </doc-code>
103
+ <doc-ask id="limit">
104
+ <p>How many scheduled messages per user?</p>
105
+ <div class="opts-row">
106
+ <label><input type="radio" name="limit" value="50" checked> 50</label>
107
+ <label><input type="radio" name="limit" value="500"> 500</label>
108
+ <label><input type="radio" name="limit" value="none"> No limit</label>
109
+ </div>
110
+ </doc-ask>
111
+ </doc-claim>
112
+ </doc-claim>
113
+
114
+ <!-- ═════ 2 ═════ -->
115
+ <doc-claim>
116
+ <p>The user sees and changes scheduled messages in one list.</p>
117
+ <doc-mock frame="none" w="440"><template>
118
+ <div class="ui">
119
+ <div class="hd">Scheduled <small>2</small></div>
120
+ <div class="row"><b>Notes from today</b><span class="t">Mon 8:00</span><small>to dana@example.com</small><span></span><span class="acts" data-ref="acts">Edit · Send now · Cancel</span></div>
121
+ <div class="row"><b>Invoice for March</b><span class="t">Apr 1, 9:30</span><small>to billing@example.com</small></div>
122
+ </div></template>
123
+ <doc-pin ref="acts" anchor="r" offset="14,0" title="Three actions">See 2.2.</doc-pin>
124
+ </doc-mock>
125
+
126
+ <doc-claim>
127
+ <p>A new folder lists them, soonest first.</p>
128
+ <doc-calls title="The list" caption="One query. It reads only this user's rows.">
129
+ <script type="text/plain">
130
+ ~ <Sidebar/> @ web/src/nav/Sidebar.tsx:30
131
+ + <**ScheduledFolder**/> @ web/src/scheduled/ScheduledFolder.tsx:14
132
+ + GET /api/scheduled @ web/src/api/scheduled.ts:21
133
+ + **listScheduled**(req) @ server/src/scheduled/routes.ts:34
134
+ + select … where user_id = $1 order by send_at @ server/src/scheduled/store.ts:40
135
+ </script>
136
+ </doc-calls>
137
+ </doc-claim>
138
+
139
+ <doc-claim>
140
+ <p>Three actions work on a message until it starts to send.</p>
141
+ <doc-calls title="Actions" caption="Each one checks the status first.">
142
+ <script type="text/plain">
143
+ + <**ScheduledRow**/> @ web/src/scheduled/ScheduledRow.tsx:9
144
+ + Edit → PATCH /api/scheduled/:id @ server/src/scheduled/routes.ts:48
145
+ + Send now → **sendNow**(id) @ server/src/scheduled/routes.ts:66
146
+ + Cancel → **cancelScheduled**(id) @ server/src/scheduled/routes.ts:80
147
+ </script>
148
+ </doc-calls>
149
+ </doc-claim>
150
+ </doc-claim>
151
+
152
+ <!-- ═════ 3 ═════ -->
153
+ <doc-claim>
154
+ <p>A message is sent only at its time. A failed send is kept.</p>
155
+ <doc-machine name="msg" caption="Dashed green is proposed.">
156
+ <script type="text/plain">
157
+ machine msg initial scheduled
158
+ state scheduled # Saved. Waiting for its time.
159
+ state sending # The worker holds it.
160
+ state sent final # Moved to Sent.
161
+ state failed # Kept, with the error.
162
+ state cancelled final # Back in Drafts.
163
+
164
+ | scheduled | sending | sent |
165
+ | cancelled | failed | . |
166
+
167
+ scheduled -due-> sending : at send_at
168
+ sending -ok-> sent : 250
169
+ sending -fail-> failed : error
170
+ scheduled -cancel-> cancelled : Cancel
171
+ failed -cancel-> cancelled : Cancel
172
+ + failed -retry-> sending : retry ×3
173
+ </script>
174
+ <div data-state="scheduled"><doc-mock frame="none" w="400"><template><div class="ui"><div class="row"><b>Notes from today</b><span class="t">Mon 8:00</span><small>to dana@example.com</small><span></span><span class="acts">Edit · Send now · Cancel</span></div></div></template></doc-mock></div>
175
+ <div data-state="sending"><doc-mock frame="none" w="400"><template><div class="ui"><div class="row"><b>Notes from today</b><span class="dim">Sending…</span><small>to dana@example.com</small></div></div></template></doc-mock></div>
176
+ <div data-state="sent"><doc-mock frame="none" w="400"><template><div class="ui"><div class="hd">Sent</div><div class="row"><b>Notes from today</b><span class="ok">Mon 8:00</span><small>to dana@example.com</small></div></div></template></doc-mock></div>
177
+ <div data-state="failed"><doc-mock frame="none" w="400"><template><div class="ui"><div class="row"><b>Notes from today</b><span class="bad">Not sent</span><small>The mail server refused it.</small><span></span><span class="acts">Try again · Cancel</span></div></div></template></doc-mock></div>
178
+ <div data-state="cancelled"><doc-mock frame="none" w="400"><template><div class="ui"><div class="hd">Drafts</div><div class="row"><b>Notes from today</b><span class="dim">draft</span><small>to dana@example.com</small></div></div></template></doc-mock></div>
179
+ </doc-machine>
180
+
181
+ <doc-claim>
182
+ <p>A worker claims due messages once a minute.</p>
183
+ <doc-calls title="The worker" caption="The existing send function is called, not changed.">
184
+ <script type="text/plain">
185
+ + **runScheduledSends**() @ server/src/scheduled/worker.ts:12
186
+ + **claimDue**(now, 100) @ server/src/scheduled/store.ts:58
187
+ + sendMessage(message) @ server/src/mail/send.ts:20
188
+ + if ok → markSent(id) @ server/src/scheduled/store.ts:74
189
+ + else markFailed(id, error) @ server/src/scheduled/store.ts:82
190
+ </script>
191
+ </doc-calls>
192
+ <doc-claim at="server/src/scheduled/store.ts:58">
193
+ <p><b>store.ts:58</b> · claimDue()</p>
194
+ <doc-code title="store.ts · sketch" lang="sql">
195
+ <script type="text/plain">
196
+ UPDATE scheduled_messages SET status = 'sending'
197
+ WHERE id IN (
198
+ SELECT id FROM scheduled_messages
199
+ WHERE status = 'scheduled' AND send_at <= $1
200
+ ORDER BY send_at LIMIT $2
201
+ FOR UPDATE SKIP LOCKED
202
+ )
203
+ RETURNING *;
204
+ </script>
205
+ <doc-pin line="6" title="Two workers never claim the same row"></doc-pin>
206
+ </doc-code>
207
+ </doc-claim>
208
+ </doc-claim>
209
+
210
+ <doc-claim>
211
+ <p>Cancel wins if it lands before the worker's claim.</p>
212
+ <doc-code title="store.ts · sketch" lang="sql">
213
+ <script type="text/plain">
214
+ UPDATE scheduled_messages SET status = 'cancelled'
215
+ WHERE id = $1 AND user_id = $2 AND status IN ('scheduled', 'failed')
216
+ RETURNING id; -- no row back: too late, tell the user
217
+ </script>
218
+ </doc-code>
219
+ </doc-claim>
220
+
221
+ <doc-claim>
222
+ <p>A failed send is tried again, then left for the user.</p>
223
+ <doc-calls title="Retry" caption="The same worker picks it up.">
224
+ <script type="text/plain">
225
+ ~ runScheduledSends() @ server/src/scheduled/worker.ts:12
226
+ ? claimRetries(now) @ server/src/scheduled/store.ts:96 -- attempts < 3, 5 minutes apart
227
+ </script>
228
+ </doc-calls>
229
+ <doc-ask id="retry">
230
+ <p>Should a failed send retry on its own?</p>
231
+ <label><input type="radio" name="retry" value="3" checked> Yes, 3 times, 5 minutes apart</label>
232
+ <label><input type="radio" name="retry" value="no"> No <small>the user presses “Try again”</small></label>
233
+ </doc-ask>
234
+ </doc-claim>
235
+ </doc-claim>
236
+
237
+ <!-- ═════ 4 ═════ -->
238
+ <doc-claim>
239
+ <p>The user is told when a scheduled message fails.</p>
240
+ <doc-mock frame="none" w="400"><template>
241
+ <div class="ui"><div class="row"><span><span class="bad">Not sent</span> · Notes from today</span><span class="dim">8:16</span><small>We tried 3 times. It is in Scheduled.</small></div></div></template>
242
+ </doc-mock>
243
+ <doc-ask id="notify">
244
+ <p>How is the user told?</p>
245
+ <label><input type="radio" name="notify" value="app" checked> In the app only</label>
246
+ <label><input type="radio" name="notify" value="both"> In the app and by email <small>adds one template</small></label>
247
+ <label><input type="radio" name="notify" value="none"> Not at all <small>claim 4 goes</small></label>
248
+ </doc-ask>
249
+ <doc-claim>
250
+ <p>The last failed try adds one notification.</p>
251
+ <doc-calls title="Notify" caption="Uses the notifications that exist today.">
252
+ <script type="text/plain">
253
+ ~ markFailed(id, error) @ server/src/scheduled/store.ts:82
254
+ + if (attempts >= 3) notify(userId, …) @ server/src/notify/notify.ts:15
255
+ </script>
256
+ </doc-calls>
257
+ </doc-claim>
258
+ </doc-claim>
259
+
260
+ <!-- ═════ shared · not changing ═════ -->
261
+ <doc-claim aux="shared">
262
+ <p>Shared: one new table.</p>
263
+ <doc-schema id="table" lang="sql" title="migrations/0042_scheduled_messages.sql" caption="Times are stored in UTC.">
264
+ <script type="text/plain">
265
+ CREATE TABLE scheduled_messages (
266
+ id uuid PRIMARY KEY,
267
+ user_id uuid NOT NULL REFERENCES users(id),
268
+ status text NOT NULL CHECK (status IN
269
+ ('scheduled','sending','sent','failed','cancelled')),
270
+ send_at timestamptz NOT NULL,
271
+ message jsonb NOT NULL, -- to, subject, html
272
+ attempts int NOT NULL DEFAULT 0,
273
+ last_error text,
274
+ created_at timestamptz NOT NULL DEFAULT now()
275
+ );
276
+ CREATE INDEX scheduled_due ON scheduled_messages (status, send_at);
277
+ </script>
278
+ </doc-schema>
279
+ <doc-ask id="keep">
280
+ <p>How long do sent and cancelled rows stay?</p>
281
+ <label><input type="radio" name="keep" value="30" checked> 30 days, then deleted</label>
282
+ <label><input type="radio" name="keep" value="forever"> Forever</label>
283
+ </doc-ask>
284
+ </doc-claim>
285
+
286
+ <doc-claim aux="scope">
287
+ <p>Not changing: normal send, drafts, the mail provider.</p>
288
+ <ul>
289
+ <li><code>sendMessage()</code> is called as it is.</li>
290
+ <li>Drafts keep their own table.</li>
291
+ <li>No recurring sends. One message, one time.</li>
292
+ </ul>
293
+ </doc-claim>
294
+
295
+ </doc-plan>
296
+ </main>
297
+ </body>
298
+ </html>