@oxmumu3/dsh-project-companion 0.24.1 → 0.25.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 (191) hide show
  1. package/README.md +2 -2
  2. package/docs/context-sources.md +1 -1
  3. package/docs/install.md +4 -4
  4. package/docs/quickstart.md +1 -1
  5. package/docs/roadmap.md +10 -2
  6. package/docs/verification.md +11 -0
  7. package/package.json +1 -3
  8. package/src/context-contracts.js +4 -4
  9. package/src/dida-rest.js +33 -2
  10. package/src/installation.js +5 -2
  11. package/test/action-surface.test.mjs +0 -69
  12. package/test/analysis-brief.test.mjs +0 -131
  13. package/test/attention-decision-service.test.mjs +0 -51
  14. package/test/attention-decision.test.mjs +0 -59
  15. package/test/build-release.test.mjs +0 -56
  16. package/test/bundled-wechat-storage.test.mjs +0 -44
  17. package/test/bundled-wechat.test.mjs +0 -122
  18. package/test/calendar-window.test.mjs +0 -25
  19. package/test/ci-sandbox.test.mjs +0 -55
  20. package/test/client-conversation.test.mjs +0 -98
  21. package/test/client-goal-board-native.test.mjs +0 -91
  22. package/test/client-goal-board-ui.test.mjs +0 -61
  23. package/test/client-goal-board.test.mjs +0 -128
  24. package/test/client-overlay-integration.test.mjs +0 -18
  25. package/test/client-overlay-session.test.mjs +0 -61
  26. package/test/client-overlay.test.mjs +0 -113
  27. package/test/compatibility-contract.test.mjs +0 -14
  28. package/test/context-account-auth.test.mjs +0 -373
  29. package/test/context-authorization.test.mjs +0 -11
  30. package/test/context-client.test.mjs +0 -438
  31. package/test/context-contracts.test.mjs +0 -231
  32. package/test/context-credential-writer.test.mjs +0 -36
  33. package/test/context-five-source-grant.test.mjs +0 -22
  34. package/test/context-google-auth.test.mjs +0 -252
  35. package/test/context-host.test.mjs +0 -290
  36. package/test/context-loop-host.test.mjs +0 -266
  37. package/test/context-loop.test.mjs +0 -219
  38. package/test/context-projection-diagnostics.test.mjs +0 -18
  39. package/test/context-provider.test.mjs +0 -18
  40. package/test/context-route-auth-check.test.mjs +0 -42
  41. package/test/context-route-binding-race.test.mjs +0 -91
  42. package/test/context-route-read-check.test.mjs +0 -64
  43. package/test/context-service.test.mjs +0 -111
  44. package/test/context-summary-probe.test.mjs +0 -92
  45. package/test/context-transport.test.mjs +0 -369
  46. package/test/contract-guidance.test.mjs +0 -77
  47. package/test/coordination-job-id.test.mjs +0 -89
  48. package/test/desktop-conversation.test.mjs +0 -80
  49. package/test/dida-named-project.test.mjs +0 -56
  50. package/test/dida-rest-integration.test.mjs +0 -37
  51. package/test/dida-rest.test.mjs +0 -139
  52. package/test/doctor.test.mjs +0 -136
  53. package/test/dot-appearance.test.mjs +0 -254
  54. package/test/egress-guard.test.mjs +0 -129
  55. package/test/embedded-wechat-auth.test.mjs +0 -63
  56. package/test/embedded-wechat-pairing.test.mjs +0 -202
  57. package/test/family-barrier-timeout.manual.mjs +0 -73
  58. package/test/family-context-adapter.test.mjs +0 -27
  59. package/test/family-context-intent.test.mjs +0 -66
  60. package/test/family-cross-host.test.mjs +0 -233
  61. package/test/family-flomo-refresh-cross-layer.test.mjs +0 -56
  62. package/test/family-intent.test.mjs +0 -32
  63. package/test/family-native-coordination.test.mjs +0 -26
  64. package/test/family-news-cross-host.test.mjs +0 -42
  65. package/test/family-news-intent.test.mjs +0 -29
  66. package/test/family-owner-delegation.test.mjs +0 -140
  67. package/test/family-owner-native-cross-host.test.mjs +0 -53
  68. package/test/family-owner-renewal-host.test.mjs +0 -67
  69. package/test/family-owner-renewal.test.mjs +0 -86
  70. package/test/family-personal-review-cross-host.test.mjs +0 -148
  71. package/test/family-personal-review.test.mjs +0 -73
  72. package/test/family-plan.test.mjs +0 -17
  73. package/test/family-project-admission.test.mjs +0 -7
  74. package/test/family-read-adapter.test.mjs +0 -33
  75. package/test/family-readme-full-cross-host.test.mjs +0 -52
  76. package/test/family-reminder-cross-host.test.mjs +0 -23
  77. package/test/family-reminder.test.mjs +0 -11
  78. package/test/family-renewal-brief-followup-cross-host.test.mjs +0 -161
  79. package/test/family-send-barrier-conversation-cross-host.test.mjs +0 -74
  80. package/test/family-send-barrier-cross-host.test.mjs +0 -75
  81. package/test/family-service-delivery.test.mjs +0 -36
  82. package/test/family-workbench-route.test.mjs +0 -18
  83. package/test/flomo-oauth-integration.test.mjs +0 -31
  84. package/test/followup-lifecycle.test.mjs +0 -87
  85. package/test/generation-failure.test.mjs +0 -45
  86. package/test/goal-board-collect.test.mjs +0 -12
  87. package/test/goal-board-host.test.mjs +0 -17
  88. package/test/goal-board-model-diagnostics.test.mjs +0 -23
  89. package/test/goal-board-model.test.mjs +0 -36
  90. package/test/goal-board-route.test.mjs +0 -6
  91. package/test/goal-board-service.test.mjs +0 -117
  92. package/test/goal-board-store.test.mjs +0 -32
  93. package/test/goal-board-sweep.test.mjs +0 -94
  94. package/test/goal-board-unsupported.test.mjs +0 -67
  95. package/test/google-calendar-auth.test.mjs +0 -43
  96. package/test/google-calendar-integration.test.mjs +0 -28
  97. package/test/google-calendar-rest.test.mjs +0 -112
  98. package/test/google-connection-check.test.mjs +0 -37
  99. package/test/google-secure-auth.test.mjs +0 -30
  100. package/test/google-suite-auth.test.mjs +0 -82
  101. package/test/google-suite-diagnostics.test.mjs +0 -70
  102. package/test/google-suite-integration.test.mjs +0 -45
  103. package/test/google-suite-network.test.mjs +0 -60
  104. package/test/google-suite-response.test.mjs +0 -83
  105. package/test/google-suite-rest.test.mjs +0 -146
  106. package/test/google-token-vault.test.mjs +0 -221
  107. package/test/google-vault-cold-integration.test.mjs +0 -32
  108. package/test/guidance.test.mjs +0 -56
  109. package/test/host-tool-call.test.mjs +0 -46
  110. package/test/host.test.mjs +0 -1108
  111. package/test/install.test.mjs +0 -271
  112. package/test/native-draft.test.mjs +0 -14
  113. package/test/natural-output-issue.test.mjs +0 -108
  114. package/test/news-editorial-quality.test.mjs +0 -48
  115. package/test/news-feed-service-regression.test.mjs +0 -21
  116. package/test/news-feeds.test.mjs +0 -287
  117. package/test/news-identity.test.mjs +0 -24
  118. package/test/news-model.test.mjs +0 -341
  119. package/test/news-preview-diagnostic-regression.test.mjs +0 -72
  120. package/test/news-render.test.mjs +0 -42
  121. package/test/news-service.test.mjs +0 -469
  122. package/test/news-topics.test.mjs +0 -28
  123. package/test/oauth-diagnostic-cross-layer.test.mjs +0 -22
  124. package/test/oauth-diagnostic.test.mjs +0 -28
  125. package/test/oauth-network.test.mjs +0 -32
  126. package/test/official-channels.test.mjs +0 -35
  127. package/test/onboarding-outcome.test.mjs +0 -154
  128. package/test/onboarding-retry.test.mjs +0 -81
  129. package/test/onboarding-ui.test.mjs +0 -227
  130. package/test/onboarding.test.mjs +0 -152
  131. package/test/personal-preview-regression.test.mjs +0 -65
  132. package/test/personal-preview-snooze-regression.test.mjs +0 -22
  133. package/test/personal-review-attention-receipt-host.test.mjs +0 -64
  134. package/test/personal-review-attention-receipt.test.mjs +0 -107
  135. package/test/personal-review-attention-wiring-regression.test.mjs +0 -115
  136. package/test/personal-review-attention.test.mjs +0 -55
  137. package/test/personal-review-audit.test.mjs +0 -192
  138. package/test/personal-review-availability-diagnostic.test.mjs +0 -118
  139. package/test/personal-review-availability-host.test.mjs +0 -47
  140. package/test/personal-review-collect.test.mjs +0 -76
  141. package/test/personal-review-collector-audit.test.mjs +0 -117
  142. package/test/personal-review-continuation.test.mjs +0 -77
  143. package/test/personal-review-control.test.mjs +0 -20
  144. package/test/personal-review-current-context.test.mjs +0 -81
  145. package/test/personal-review-deadline-selection.test.mjs +0 -14
  146. package/test/personal-review-delivery-failure-regression.test.mjs +0 -47
  147. package/test/personal-review-diagnostics-regression.test.mjs +0 -90
  148. package/test/personal-review-focus.test.mjs +0 -112
  149. package/test/personal-review-goals.test.mjs +0 -94
  150. package/test/personal-review-grant-calendar-regression.test.mjs +0 -33
  151. package/test/personal-review-model.test.mjs +0 -83
  152. package/test/personal-review-recovery.test.mjs +0 -96
  153. package/test/personal-review-render.test.mjs +0 -14
  154. package/test/personal-review-repair.test.mjs +0 -34
  155. package/test/personal-review-semantics-regression.test.mjs +0 -128
  156. package/test/personal-review-source-diagnostics.test.mjs +0 -85
  157. package/test/personal-review-source-reconcile.test.mjs +0 -126
  158. package/test/personal-review-source-tasks.test.mjs +0 -81
  159. package/test/personal-review-sources.test.mjs +0 -46
  160. package/test/personal-review.test.mjs +0 -228
  161. package/test/presentation.test.mjs +0 -65
  162. package/test/proactive-scheduler-boundary.test.mjs +0 -58
  163. package/test/proactive-vendor-provenance.test.mjs +0 -20
  164. package/test/project-catalog-intent.test.mjs +0 -14
  165. package/test/project-catalog-route.test.mjs +0 -44
  166. package/test/project-catalog-service.test.mjs +0 -27
  167. package/test/project-catalog.test.mjs +0 -46
  168. package/test/project-followup-loop.test.mjs +0 -553
  169. package/test/project-followup.test.mjs +0 -555
  170. package/test/project-memory-edit.test.mjs +0 -186
  171. package/test/project-memory.test.mjs +0 -382
  172. package/test/project-update-model.test.mjs +0 -584
  173. package/test/project-updates.test.mjs +0 -23
  174. package/test/review-handoff-coordination.test.mjs +0 -36
  175. package/test/review-runtime-health.test.mjs +0 -23
  176. package/test/review-workbench-projection.test.mjs +0 -173
  177. package/test/routing-corpus.mjs +0 -45
  178. package/test/routing-surface.test.mjs +0 -17
  179. package/test/service.test.mjs +0 -554
  180. package/test/sources.test.mjs +0 -32
  181. package/test/task-results.test.mjs +0 -412
  182. package/test/wechat-recovery.test.mjs +0 -181
  183. package/test/wechat-route.test.mjs +0 -83
  184. package/test/welcome-guard.test.mjs +0 -213
  185. package/test/workbench-actions.test.mjs +0 -244
  186. package/test/workbench-loop-plan.test.mjs +0 -43
  187. package/test/workbench-native-lifecycle.test.mjs +0 -91
  188. package/test/workbench-scope.test.mjs +0 -45
  189. package/test/workbench-ui.test.mjs +0 -726
  190. package/test/workbench.test.mjs +0 -325
  191. package/test/workspace-access.test.mjs +0 -22
package/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
  <img alt="macOS" src="https://img.shields.io/badge/macOS-%E6%A1%8C%E9%9D%A2%E7%89%88%E4%B8%8E%E7%BD%91%E9%A1%B5%E7%89%88-111?style=flat-square">
16
16
  </p>
17
17
 
18
- <p align="center"><sub>界面预览为设计稿,数据全部为示例;实机截图会随后替换。</sub></p>
18
+ <p align="center"><sub>界面预览为设计稿,数据为示例。产品站与实机截图见 <a href="https://dot.finvo.ai/">dot.finvo.ai</a>。</sub></p>
19
19
 
20
20
  作者:牛村木木山 · MIT · 社区开源项目,非 DeepSeek 官方产品。
21
21
 
@@ -42,7 +42,7 @@
42
42
  dsh plugin --profile web add @oxmumu3/dsh-project-companion
43
43
  ```
44
44
 
45
- 桌面版只走插件页面安装;装完若宿主提示,再完整退出并重开。要求官方 Harness `0.2.x`、Node.js 22.13+。离线安装包在 [Releases](https://github.com/oxmumu3/dsh-project-companion/releases)。
45
+ 桌面版只走插件页面安装;装完若宿主提示,再完整退出并重开。要求官方 Harness `0.2.x`、Node.js 22.13+。0.24 起不再随版本附带离线安装包,桌面版和网页版都走上面这条插件安装路径。
46
46
 
47
47
  <p align="center">
48
48
  <img src="docs/assets/preview/first-use-mobile.png" alt="第一次打开:先说一件事" width="300">
@@ -137,4 +137,4 @@ Google 普通连接与滴答普通 OAuth 走固定官方只读 REST;flomo、
137
137
 
138
138
  ### 滴答普通登录的读取范围
139
139
 
140
- 普通 OAuth 使用官方 Open API,保留 `tasks:read`。清单只取首批(最多10项),指定单个清单后读取其中任务(最多展示10条,响应上限1MiB),或者指定清单和任务读取一条。暂不支持跨全账号关键词搜索,不自动翻页或扫描其他清单。手填旧 token 的高级 MCP 路径保留;普通 OAuth 失败不会改用它。
140
+ 普通 OAuth 使用官方 Open API,保留 `tasks:read`。清单只取首批(最多10项),指定单个清单后读取其中任务(最多展示10条,响应上限1MiB),或者指定清单和任务读取一条。另支持账户级只读搜索:按标题、正文或备注跨清单搜索,单次最多返回 50 条并标记截断;内部最多枚举 1000 个清单、每个清单最多 1000 条任务、3 并发,超出直接失败而不是静默截断。不自动翻页。手填旧 token 的高级 MCP 路径保留;普通 OAuth 失败不会改用它。
package/docs/install.md CHANGED
@@ -1,4 +1,4 @@
1
- # 安装 DSH Dot 0.24.0
1
+ # 安装 DSH Dot 0.25.0
2
2
 
3
3
  ## 在创造模式中安装/更新
4
4
 
@@ -8,7 +8,7 @@
8
8
  请安装或更新并启用 DSH Dot。先检查现有插件,避免重复添加和降级。从 npm 官方源实时查询 @oxmumu3/dsh-project-companion 的 latest,按查到的精确版本安装或更新,不直接采用本机缓存的旧 latest。保留已有微信绑定、账号授权、资料范围、设置和其他插件,不自动读取或新建计划。核对实际版本、启用状态,再打开 DSH Dot。
9
9
  ```
10
10
 
11
- 新用户也可在「插件 → 添加插件」填写 `@oxmumu3/dsh-project-companion`(或精确版本 `@oxmumu3/dsh-project-companion@0.24.0`),安装后启用。它是一个标准插件包,已内置独立微信组件。已有未带 namespace 的历史安装应沿原包名更新;不要将两个名称当成同一个插件重复添加。
11
+ 新用户也可在「插件 → 添加插件」填写 `@oxmumu3/dsh-project-companion`(或精确版本 `@oxmumu3/dsh-project-companion@0.25.0`),安装后启用。它是一个标准插件包,已内置独立微信组件。已有未带 namespace 的历史安装应沿原包名更新;不要将两个名称当成同一个插件重复添加。
12
12
 
13
13
  牛村木木山制作的 DeepSeek Harness 社区插件,非 DeepSeek 或 OpenAI 官方产品。本版内置微信组件,只需添加一个标准插件包,不包含 Harness 应用或 Family 家庭助手。
14
14
 
@@ -26,7 +26,7 @@
26
26
 
27
27
  无法联网或想用离线包时,到 [Releases](https://github.com/oxmumu3/dsh-project-companion/releases) 下载对应版本的 `.tgz`,在官方管理器填写下载后的文件实际路径;无需解压、另装微信组件或运行 macOS 脚本。
28
28
 
29
- [本版发布页](https://github.com/oxmumu3/dsh-project-companion/releases/tag/v0.24.0)提供校验文件。插件尚未上架官方插件市场,npm latest 同步为本版;不要用旧版 ZIP 或第二个微信安装包代替这条单插件路径。
29
+ [本版发布页](https://github.com/oxmumu3/dsh-project-companion/releases/tag/v0.25.0)记录本版变更。插件包从 npm 安装,npm 页面提供 integrity 与 provenance 可核;0.24 起 release 不再附带离线包。插件尚未上架官方插件市场,npm latest 同步为本版;不要用旧版 ZIP 或第二个微信安装包代替这条单插件路径。
30
30
 
31
31
  ## 已有用户
32
32
 
@@ -68,7 +68,7 @@ Google 品牌已验证,Gmail、日历、Drive 数据权限已提交审核但
68
68
 
69
69
  ## 本版验证与已知问题
70
70
 
71
- 0.24.0 源码全量回归 2,365 项 / 2,328 通过 / 0 失败 / 37 跳过(跳过项均需 Family 源码树,不在本包范围)。自检只读本机状态,不发外部请求;单项探测 2 秒上限,超时或抛错显示「未知」。私人外发确认只覆盖 `personal_review.run_now` 这条路径,宿主自带的 `send_wechat`、定时投递和带内容的 `remind` / `coordinate` 不经过这道门禁——插件单方面无法覆盖全部外发路径。
71
+ 0.25.0 源码全量回归 2,365 项 / 2,328 通过 / 0 失败 / 37 跳过(跳过项均需 Family 源码树,不在本包范围)。自检只读本机状态,不发外部请求;单项探测 2 秒上限,超时或抛错显示「未知」。私人外发确认只覆盖 `personal_review.run_now` 这条路径,宿主自带的 `send_wechat`、定时投递和带内容的 `remind` / `coordinate` 不经过这道门禁——插件单方面无法覆盖全部外发路径。
72
72
 
73
73
  自动回顾仍为实验能力:自然语言 `focus` 尚未用真实模型验证实际效果,手机端呈现也未验证。历史 flomo 范围投影与模型失败未全部归因。新用户独立扫码到收件、多日与休眠恢复、真实 macOS 输入法仍分别验收。通道报告发送不等于手机收到。详见[验证记录](verification.md)。
74
74
 
@@ -25,7 +25,7 @@
25
25
 
26
26
  > 从 Gmail 搜索「subject:DeepSeek」最多1条,日历未来24小时最多2条,Drive 搜索「DeepSeek」最多1条,flomo 搜索 DeepSeek 最多2条,滴答清单列出清单最多2个,生成 我的项目 的项目简报。先不要设置提醒,不要建立计划。
27
27
 
28
- 它保留各来源范围并生成带引用的进展、阻塞和下一步;零匹配不等于读取失败。本例滴答只查清单元数据,不代表已读任务。共用入口也支持明确命名清单的未完成任务,例如“滴答「工作」清单的未完成任务最多2条”;不支持全账号任务关键词搜索或任意资源 ID,真实任务正文仍待本人限定实读。
28
+ 它保留各来源范围并生成带引用的进展、阻塞和下一步;零匹配不等于读取失败。本例滴答只查清单元数据,不代表已读任务。共用入口也支持明确命名清单的未完成任务,例如“滴答「工作」清单的未完成任务最多2条”;账户级关键词搜索按标题、正文与备注跨清单检索,单次最多 50 条并标明截断;仍不支持任意资源 ID,真实任务正文与跨清单全量扫描的边界见连接说明。
29
29
 
30
30
  Google 三项权限已正式提交,当前 `UNDER_REVIEW`,未获批准、完成 CASA 或解除已知累计 100 个账号上限,不保证任意新账号可连接。flomo 需要 MAX,滴答普通连接只申请 `tasks:read`。登录和启用不会自动建立私人资料扫描或推送。旧版实读见[历史验证记录](verification.md);当前闭环范围见[个人资料闭环](context-loop.md)。
31
31
 
package/docs/roadmap.md CHANGED
@@ -1,6 +1,14 @@
1
- # 当前收尾 · 0.20.0-preview.2 公开预览
1
+ # 当前收尾 · 0.24.2 公开版本
2
2
 
3
- 新版工作台、逻辑项目与工作区范围管理已发布。下一步优先定位自然回顾中flomo近期投影和模型失败的具体原因,观察已有每日/资讯/工作时段安排;不重放旧任务或以合成通过当手机成功。补齐独立新用户首次扫码到收件、多日与休眠恢复。Google数据权限继续独立跟进,审核中不能宣传为已批准。以下保留历史计划。
3
+ 最新公开版本 0.25.0:补上滴答账户级只读搜索(`search_task` / `search` / `list_all_tasks`);此前 0.24.2:项目工具收敛到 `look`/`manage` 两个入口,新增自检、私人外发确认与回顾关注点,首次打开有示例卡,交办记录可复用。
4
+
5
+ 下一步按影响排序:
6
+
7
+ 1. **主线合并**:本机日常运行的是私有 `0.24.1-mobile.3`,含同任务追问续接、一次性审批、状态查询不新建任务、停止当前任务、原结果回传五项,尚未进入公开主线。先把这五项并回 `main` 并补测试,再谈下一版功能。
8
+ 2. **微信主动推送 `-2`**:11-03 早报与资讯各失败两次,去掉 context 也未恢复。需要真实入站复现后再定位,不猜修、不重放旧失败。
9
+ 3. **真机截图**:产品站与 README 目前仍使用设计稿;需要在无私人数据的示例状态下实拍,替换后再对外宣传界面。
10
+ 4. **外部使用信号**:当前没有可观测的安装者留存数据,下载量与 GitHub 访问都不足以判断真实使用。是否加入匿名使用统计需本人明确决定。
11
+ 5. **历史边界保留**:Google 仍为受限公众预览,未获批不能宣传为已批准;独立新用户首次扫码到收件、多日与休眠恢复继续单独验收。以下保留历史计划。
4
12
 
5
13
  # 后续迭代
6
14
 
@@ -1,3 +1,14 @@
1
+ # 0.25.0 验证增量
2
+
3
+ 2026-11-09,补齐滴答账户级只读搜索(`search_task` / `search` / `list_all_tasks`),并把契约层一起放开。
4
+
5
+ - `node --max-old-space-size=256 --test --test-concurrency=1 test/*.test.mjs`:2,367 项 / 2,330 通过 / 0 失败 / 37 跳过(0.24.2 基线 2,365 / 2,328 / 0 / 37)。
6
+ - 新增 3 条用例:跨项目过滤与截断标记、项目列表超 1000 时拒绝且不发第二类请求、项目 ID 不匹配时拒绝。
7
+ - 更新 4 条旧断言:原先断言"滴答搜索必须被拒绝",现改为断言搜索按边界执行(`dida-rest`、`context-contracts`、`context-host`、`dida-rest-integration`)。
8
+ - 边界写死并有用例:单次返回最多 50 条、枚举最多 1000 个项目、每项目最多 1000 条任务、3 并发;超限失败而非静默截断。
9
+
10
+ **没有验证的**:本轮全部用合成响应,没有对真实滴答账号发起搜索;真实账号下的匹配质量、耗时与截断行为仍需本人限定范围实读确认。
11
+
1
12
  # 0.24.0 验证增量
2
13
 
3
14
  2026-11-04,新增自检、私人外发确认与回顾关注点三项能力;来源是对 OpenMuse 公开文档的一次阅读,实现按其可迁移部分裁剪。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxmumu3/dsh-project-companion",
3
- "version": "0.24.1",
3
+ "version": "0.25.0",
4
4
  "description": "DSH Dot: WeChat personal agent, project memory and proactive follow-up for DeepSeek Harness",
5
5
  "author": "牛村木木山",
6
6
  "license": "MIT",
@@ -26,8 +26,6 @@
26
26
  "scripts/demo.mjs",
27
27
  "scripts/prompt-report.mjs",
28
28
  "scripts/routing-report.mjs",
29
- "test/",
30
- "test/routing-corpus.mjs",
31
29
  "docs/developer-commands.md",
32
30
  "vendor/",
33
31
  "THIRD_PARTY_NOTICES.md",
@@ -12,16 +12,16 @@ const INPUT_KEYS = new Set(['operation', 'query', 'id', 'ids', 'projectId', 'ran
12
12
  const OPERATION_INPUTS = {
13
13
  gmail: { search: ['query', 'limit'], read: ['id'] }, calendar: { upcoming: ['from', 'to', 'calendarId', 'limit'] },
14
14
  drive: { search: ['query', 'limit'], recent: ['from', 'to', 'limit'], read: ['id'] }, docs: { read: ['id'] }, sheets: { read: ['id', 'range'] }, slides: { read: ['id'] },
15
- dida: { projects: ['limit'], tasks: ['projectId', 'query', 'limit'], read: ['id', 'projectId'], search: ['query'] },
15
+ dida: { projects: ['limit'], tasks: ['projectId', 'query', 'limit'], read: ['id', 'projectId'], search: ['query', 'limit'] },
16
16
  flomo: { search: ['query', 'limit'], recent: ['from', 'to', 'limit'], read: ['id', 'ids'] },
17
17
  };
18
- const READ_TOOLS = new Set(['search_threads', 'get_message', 'list_events', 'search_files', 'read_file_content', 'read_doc', 'get_values', 'read_presentation', 'list_projects', 'get_project_with_undone_tasks', 'get_project_tasks_bounded', 'get_named_project_with_undone_tasks', 'get_task_in_project', 'search', 'memo_search', 'memo_batch_get']);
18
+ const READ_TOOLS = new Set(['search_threads', 'get_message', 'list_events', 'search_files', 'read_file_content', 'read_doc', 'get_values', 'read_presentation', 'list_projects', 'get_project_with_undone_tasks', 'get_project_tasks_bounded', 'get_named_project_with_undone_tasks', 'get_task_in_project', 'search', 'search_task', 'list_all_tasks', 'memo_search', 'memo_batch_get']);
19
19
  const ARG_KEYS = {
20
20
  search_threads: ['query', 'pageSize', 'includeTrash', 'view'], get_message: ['messageId', 'messageFormat'],
21
21
  list_events: ['calendarId', 'startTime', 'endTime', 'orderBy', 'pageSize'], search_files: ['query', 'pageSize', 'excludeContentSnippets'],
22
22
  read_file_content: ['fileId', 'includeComments'], read_doc: ['documentId', 'commentsIncluded'], get_values: ['spreadsheetId', 'range'],
23
23
  read_presentation: ['presentationId', 'fields', 'commentsIncluded'], list_projects: ['limit', 'offset'],
24
- get_project_with_undone_tasks: ['project_id'], get_project_tasks_bounded: ['project_id','limit'], get_task_in_project: ['project_id', 'task_id'], search: ['query'],
24
+ get_project_with_undone_tasks: ['project_id'], get_project_tasks_bounded: ['project_id','limit'], get_task_in_project: ['project_id', 'task_id'], search: ['query','limit'], search_task: ['query','limit'], list_all_tasks: ['limit'],
25
25
  get_named_project_with_undone_tasks: ['project_name', 'limit'],
26
26
  memo_search: ['keywords', 'limit', 'start_date', 'end_date'], memo_batch_get: ['ids'],
27
27
  };
@@ -90,7 +90,7 @@ export function buildContextCall(source, input, { now = new Date() } = {}) {
90
90
  return make('get_project_with_undone_tasks', { project_id: id(input.projectId) });
91
91
  }
92
92
  if (operation === 'read') return make('get_task_in_project', { project_id: id(input.projectId), task_id: id(input.id) });
93
- if (operation === 'search') return make('search', { query: string(input.query) });
93
+ if (operation === 'search') return make('search', { query: string(input.query), ...(input.limit !== undefined ? { limit: limit(input.limit, 20) } : {}) });
94
94
  }
95
95
  if (source === 'flomo') {
96
96
  if (operation === 'search') return make('memo_search', { keywords: string(input.query), limit: limit(input.limit, 5) });
package/src/dida-rest.js CHANGED
@@ -7,7 +7,7 @@ import {validateContextCall} from './context-contracts.js';
7
7
  import {insufficientScope} from './context-transport.js';
8
8
 
9
9
  const ORIGIN='https://api.dida365.com';
10
- const MAX_BYTES=1024*1024,REQUEST_MS=20000,MAX_ITEMS=10;
10
+ const MAX_BYTES=1024*1024,REQUEST_MS=20000,MAX_ITEMS=10,SEARCH_ITEMS=50,MAX_ALL=1000,CONCURRENCY=3;
11
11
  const CONTROL=/[\u0000-\u001f\u007f]/u;
12
12
  const CODES=new Set(['CONTEXT_ARGUMENTS_INVALID','CONTEXT_UNSUPPORTED_OPERATION','CONTEXT_CANCELLED','CONTEXT_AUTH_REQUIRED','CONTEXT_INSUFFICIENT_SCOPE','CONTEXT_ABORTED','CONTEXT_TIMEOUT','CONTEXT_CLOSED','CONTEXT_HTTP_ERROR','CONTEXT_REDIRECT','CONTEXT_PROTOCOL_INVALID','CONTEXT_RESPONSE_TOO_LARGE','CONTEXT_CREDENTIALS_CHANGED']);
13
13
  const plain=v=>v!==null&&typeof v==='object'&&!Array.isArray(v);
@@ -16,12 +16,16 @@ const fail=code=>{throw error(code);};
16
16
  const validId=v=>typeof v==='string'&&/^[A-Za-z0-9_-]{1,512}$/u.test(v);
17
17
  const ident={type:'string',minLength:1,maxLength:512,pattern:'^[A-Za-z0-9_-]{1,512}$'};
18
18
  const tool=(name,properties)=>({name,inputSchema:{type:'object',additionalProperties:false,required:Object.keys(properties),properties}});
19
- const CATALOG={provenance:'bundled-contract',unsupportedOperations:['search'],tools:[
19
+ const searchTool=(name,required)=>({name,inputSchema:{type:'object',additionalProperties:false,required,properties:{...(required.includes('query')?{query:{type:'string',minLength:1,maxLength:120}}:{}) ,limit:{type:'integer',minimum:1,maximum:SEARCH_ITEMS}}}});
20
+ const CATALOG={provenance:'bundled-contract',tools:[
20
21
  tool('list_projects',{offset:{type:'integer',enum:[0]},limit:{type:'integer',minimum:1,maximum:MAX_ITEMS}}),
21
22
  tool('get_project_with_undone_tasks',{project_id:ident}),
22
23
  tool('get_project_tasks_bounded',{project_id:ident,limit:{type:'integer',minimum:1,maximum:MAX_ITEMS}}),
23
24
  tool('get_named_project_with_undone_tasks',{project_name:{type:'string',minLength:1,maxLength:180},limit:{type:'integer',minimum:1,maximum:MAX_ITEMS}}),
24
25
  tool('get_task_in_project',{project_id:ident,task_id:ident}),
26
+ searchTool('search_task',['query']),
27
+ searchTool('search',['query']),
28
+ searchTool('list_all_tasks',[]),
25
29
  ]};
26
30
 
27
31
  function validate(source,name,args){
@@ -126,6 +130,33 @@ export function createDidaRest({getToken,fetch:fetchImpl=globalThis.fetch,clock=
126
130
  }catch(e){if(CODES.has(e?.code))throw e;fail('CONTEXT_HTTP_ERROR');}
127
131
  const value=await readBody(reply,signal);await authorized(settings,signal);cancelled(settings);return value;
128
132
  };
133
+ if(name==='list_all_tasks'||name==='search_task'||name==='search'){
134
+ const take=Math.min(Number.isInteger(args.limit)?args.limit:20,SEARCH_ITEMS);
135
+ const key=name==='list_all_tasks'?null:String(args.query).toLowerCase();
136
+ const rows=await get(new URL('/open/v1/project',ORIGIN));
137
+ if(!Array.isArray(rows)||rows.length>MAX_ALL)fail('CONTEXT_PROTOCOL_INVALID');
138
+ const projects=rows.filter(row=>plain(row)&&validId(row.id)).slice(0,MAX_ALL);
139
+ const coverage={truncated:rows.length>MAX_ALL},collected=[];
140
+ for(let i=0;i<projects.length;i+=CONCURRENCY){
141
+ const batch=projects.slice(i,i+CONCURRENCY);
142
+ const pages=await Promise.all(batch.map(async row=>{
143
+ const raw=await get(new URL(`/open/v1/project/${encodeURIComponent(row.id)}/data`,ORIGIN));
144
+ if(!plain(raw)||!Array.isArray(raw.tasks))fail('CONTEXT_PROTOCOL_INVALID');
145
+ if(raw.project!==undefined&&(!plain(raw.project)||raw.project.id!==row.id))fail('CONTEXT_PROTOCOL_INVALID');
146
+ return raw.tasks.slice(0,MAX_ALL).map(t=>({row:t,projectId:row.id}));
147
+ }));
148
+ for(const page of pages)for(const entry of page)collected.push(entry);
149
+ }
150
+ collected.sort((a,b)=>{
151
+ const ta=Date.parse(a.row?.createdTime??a.row?.modifiedTime??'')||0;
152
+ const tb=Date.parse(b.row?.createdTime??b.row?.modifiedTime??'')||0;
153
+ return tb-ta;
154
+ });
155
+ const matched=key===null?collected:collected.filter(entry=>plain(entry.row)&&typeof entry.row.title==='string'&&`${entry.row.title}\n${entry.row.content??''}\n${entry.row.desc??''}`.toLowerCase().includes(key));
156
+ const items=matched.slice(0,take).map(entry=>task(entry.row,entry.projectId,null,coverage));
157
+ if(matched.length>take)coverage.truncated=true;
158
+ return{value:{items,truncated:coverage.truncated},fetchedAt:new Date(clock()).toISOString()};
159
+ }
129
160
  if(name==='get_named_project_with_undone_tasks'){
130
161
  const rows=await get(new URL('/open/v1/project',ORIGIN));
131
162
  if(!Array.isArray(rows)||rows.length>2048)fail('CONTEXT_PROTOCOL_INVALID');
@@ -1,6 +1,6 @@
1
1
  /** Local macOS distribution installer. No daemon, profile editing, login or WeChat access. */
2
2
  import {access, readFile, readdir, realpath, stat} from 'node:fs/promises';
3
- import {constants} from 'node:fs';
3
+ import {constants, readFileSync} from 'node:fs';
4
4
  import {basename, dirname, join, resolve} from 'node:path';
5
5
  import {homedir} from 'node:os';
6
6
  import {createHash} from 'node:crypto';
@@ -8,7 +8,10 @@ import {gunzipSync} from 'node:zlib';
8
8
  import {spawn} from 'node:child_process';
9
9
 
10
10
  export const OFFICIAL_HARNESS_URL='https://github.com/deepseek-ai/deepseek-harness/releases';
11
- const RUNTIMES=['0.2.0-rc.2','0.2.1-rc.2','0.2.1-rc.3'];
11
+ // One matrix, one source: the same compatibility.json that package.json declares and CI validates.
12
+ // Keeping a second hard-coded list here is how the offline installer fell behind and started
13
+ // rejecting Hosts the plugin already supported.
14
+ const RUNTIMES=JSON.parse(readFileSync(new URL('../compatibility.json',import.meta.url),'utf8'));
12
15
  const NAMES=['dsh-wechat','dsh-project-companion'];
13
16
  const BRIDGE_VERSIONS=new Set(['0.11.0','0.11.1-dot.1','0.11.1-dot.2','0.11.1-dot.3']);
14
17
  const MAX_PACKAGE=20*1024*1024;
@@ -1,69 +0,0 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import {readFile} from 'node:fs/promises';
4
- import {normalizeSurfaceAction,LOOK_VIEWS,MANAGE_OPS,SURFACE_COPY} from '../src/action-surface.js';
5
-
6
- const source=await readFile(new URL('../index.js',import.meta.url),'utf8');
7
- function enumOf(tool){
8
- const at=source.indexOf(`name:'${tool}',\n description:'`);
9
- assert.ok(at>0,tool);
10
- const match=/action:\{type:'string',required:true,enum:\[([^\]]*)\]/.exec(source.slice(at,at+8000));
11
- assert.ok(match,`${tool} action enum`);
12
- return match[1].split(',').map(value=>value.trim().replace(/^'|'$/g,'')).filter(Boolean);
13
- }
14
- const TOOLS=enumOf('project_companion');
15
-
16
- // The composite entries must only ever translate into actions that the tool
17
- // actually declares; a typo here would ship a call that the schema rejects.
18
- test('every composite view and op translates into a declared legacy action',()=>{
19
- for(const view of LOOK_VIEWS){
20
- const target=normalizeSurfaceAction({action:'look',view,project:'/synthetic/p'});
21
- assert.ok(TOOLS.includes(target.action),`look.${view} -> ${target.action} must be declared`);
22
- }
23
- for(const op of MANAGE_OPS){
24
- const target=normalizeSurfaceAction({action:'manage',op,project:'/synthetic/p',time:'09:00',everyMinutes:60,memoryKind:'goal',memoryText:'x',sourceKind:'assistant'});
25
- assert.ok(TOOLS.includes(target.action),`manage.${op} -> ${target.action} must be declared`);
26
- }
27
- assert.ok(TOOLS.includes('look')&&TOOLS.includes('manage'),'both entries stay declared');
28
- });
29
-
30
- test('look views keep the parameters the legacy handlers already rely on',()=>{
31
- assert.deepEqual(normalizeSurfaceAction({action:'look',view:'progress',project:'p',detail:'analysis'}),
32
- {action:'digest',project:'p',detail:'analysis'});
33
- assert.equal(normalizeSurfaceAction({action:'look',view:'progress',project:'p'}).detail,undefined);
34
- assert.deepEqual(normalizeSurfaceAction({action:'look',view:'task',id:'job-1'}),{action:'task_status',id:'job-1'});
35
- assert.deepEqual(normalizeSurfaceAction({action:'look',view:'status'}),{action:'status'});
36
- });
37
-
38
- // project_update is gated on the user asking; the composite must not widen it.
39
- test('look.change never invents the user request flag',()=>{
40
- assert.equal(normalizeSurfaceAction({action:'look',view:'change',project:'p'}).userRequested,false);
41
- assert.equal(normalizeSurfaceAction({action:'look',view:'change',project:'p',userRequested:true}).userRequested,true);
42
- });
43
-
44
- test('manage ops keep authorization flags exactly as the caller passed them',()=>{
45
- const remember=normalizeSurfaceAction({action:'manage',op:'remember',project:'p',memoryKind:'decision',memoryText:'t',sourceKind:'user'});
46
- assert.deepEqual(remember,{action:'remember',project:'p',memoryKind:'decision',memoryText:'t',sourceKind:'user',userRequested:false});
47
- const correct=normalizeSurfaceAction({action:'manage',op:'correct_memory',project:'p',memoryId:'m',memoryText:'t',userRequested:true});
48
- assert.equal(correct.action,'correct_memory');
49
- assert.equal(correct.userRequested,true);
50
- const daily=normalizeSurfaceAction({action:'manage',op:'daily',time:'09:10',timeZone:'America/Mexico_City'});
51
- assert.deepEqual(daily,{action:'configure_daily',time:'09:10',timeZone:'America/Mexico_City'});
52
- });
53
-
54
- test('a malformed composite fails loudly instead of guessing',()=>{
55
- assert.throws(()=>normalizeSurfaceAction({action:'look'}),/look 需要 view/);
56
- assert.throws(()=>normalizeSurfaceAction({action:'look',view:'nope'}),/look 需要 view/);
57
- assert.throws(()=>normalizeSurfaceAction({action:'manage',op:'nope'}),/manage 需要 op/);
58
- assert.equal(normalizeSurfaceAction({action:'digest',project:'p'}).action,'digest','legacy names pass through untouched');
59
- });
60
-
61
- test('the tool description teaches both entries and every discriminator',()=>{
62
- const at=source.indexOf("name:'project_companion',\n description:'");
63
- const description=/description:'([^']*)'/.exec(source.slice(at,at+4000))[1];
64
- assert.match(description,/look/);
65
- assert.match(description,/manage/);
66
- for(const view of LOOK_VIEWS)assert.ok(description.includes(view),`description must name view ${view}`);
67
- for(const op of MANAGE_OPS)assert.ok(description.includes(op),`description must name op ${op}`);
68
- assert.equal(Object.keys(SURFACE_COPY).sort().join(','),'look,manage');
69
- });
@@ -1,131 +0,0 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import { mkdtemp, mkdir, writeFile, utimes, rm, realpath } from 'node:fs/promises';
4
- import { tmpdir } from 'node:os';
5
- import { join } from 'node:path';
6
- import { createService } from '../src/service.js';
7
- import { readProjectFiles, FILE_BYTES } from '../src/sources.js';
8
-
9
- async function fixture(t, files = {}) {
10
- const root = await realpath(await mkdtemp(join(tmpdir(), 'companion-analysis-')));
11
- t.after(() => rm(root, { recursive: true, force: true }));
12
- await mkdir(join(root, '.agent', 'memory'), { recursive: true });
13
- for (const [path, value] of Object.entries(files)) {
14
- await writeFile(join(root, path), value.text);
15
- if (value.at) await utimes(join(root, path), new Date(value.at), new Date(value.at));
16
- }
17
- let persisted, reads = 0;
18
- const owner = { sessionId: 'analysis-source-session', cwd: root };
19
- const service = createService({
20
- store: { get: async () => structuredClone(persisted), put: async (_key, value) => { persisted = structuredClone(value); } },
21
- discover: async () => [{ root, label: 'Synthetic analysis project' }],
22
- readProject: async projectRoot => { reads++; return readProjectFiles(projectRoot); },
23
- clock: () => new Date('2026-10-19T17:00:00Z'),
24
- hostTimeZone: 'America/Mexico_City',
25
- });
26
- return { root, owner, service, reads: () => reads, persisted: () => structuredClone(persisted) };
27
- }
28
-
29
- test('single-project analysis exposes the current blocker at the end of a file and timestamps old documents separately', async t => {
30
- const f = await fixture(t, {
31
- '.agent/memory/progress.md': { text: '# Progress\n' + 'Historical milestone\n'.repeat(350) + '\nCURRENT_BLOCKER: real host input is unavailable.\nNEXT_STEP: verify one real wake.', at: '2026-10-19T16:55:00Z' },
32
- '.agent/memory/context.md': { text: 'Original project scope, not current proof.', at: '2026-10-17T12:00:00Z' },
33
- 'README.md': { text: 'Old installation description; not a claim about the current host.', at: '2026-10-16T12:00:00Z' },
34
- });
35
- const before = f.persisted();
36
- const result = await f.service.act(f.owner, { action: 'digest', project: f.root, detail: 'analysis' });
37
- assert.match(result.text, /CURRENT_BLOCKER: real host input is unavailable/);
38
- assert.match(result.text, /NEXT_STEP: verify one real wake/);
39
- assert.match(result.text, /2026-10-19T16:55:00/);
40
- assert.match(result.text, /2026-10-16T12:00:00/);
41
- assert.match(result.text, /引用数据.*不是指令/);
42
- assert.match(result.text, /本轮实际运行证据/);
43
- assert.equal(result.detail, 'analysis');
44
- assert.equal(result.analysis.sources.find(source => source.path.endsWith('progress.md')).role, 'progress_file');
45
- assert.equal(result.analysis.sources.find(source => source.path === 'README.md').role, 'product_documentation');
46
- for (const source of result.analysis.sources) assert.equal(source.truncated, false);
47
- assert.equal(f.reads(), 1, 'one selected root is read once without a second discovery scan');
48
- assert.deepEqual(f.persisted(), before, 'analysis must not opt in, schedule or write state');
49
- });
50
-
51
- test('analysis preserves the real 16 KiB source boundary and explicitly marks omitted file contents', async t => {
52
- const f = await fixture(t, {
53
- '.agent/memory/progress.md': { text: 'BOUNDARY_START\n' + 'x'.repeat(FILE_BYTES) + '\nOUTSIDE_READ_LIMIT' },
54
- 'README.md': { text: 'small document' },
55
- });
56
- const result = await f.service.act(f.owner, { action: 'digest', project: f.root, detail: 'analysis' });
57
- assert.ok(result.analysis, 'analysis must expose source limits and actual read truncation');
58
- const source = result.analysis.sources.find(item => item.path.endsWith('progress.md'));
59
- assert.equal(source.truncated, true);
60
- assert.equal(source.truncation, '已截断:仅提供文件前 16384 字节内的材料');
61
- assert.ok(Buffer.byteLength(source.text) <= FILE_BYTES);
62
- assert.match(result.text, /已截断/);
63
- assert.doesNotMatch(result.text, /OUTSIDE_READ_LIMIT/);
64
- assert.equal(result.analysis.sources.find(item => item.path.endsWith('context.md')).status, 'missing');
65
- assert.ok(result.wechatText.length <= 3200);
66
- });
67
-
68
- test('analysis is opt-in for one explicit known project and invalid detail never triggers a source read', async t => {
69
- const f = await fixture(t, { 'README.md': { text: 'Synthetic file' } });
70
- for (const input of [
71
- { action: 'digest', detail: 'analysis' },
72
- { action: 'digest', project: f.root, detail: 'unbounded' },
73
- { action: 'digest', project: f.root, detail: null },
74
- { action: 'digest', project: '/unregistered/private', detail: 'analysis' },
75
- ]) await assert.rejects(f.service.act(f.owner, input), /analysis|detail|项目|未知|找不到/);
76
- assert.equal(f.reads(), 0);
77
- assert.equal(f.persisted(), undefined);
78
- });
79
-
80
- test('analysis keeps the brief mobile view and default summary independent from the larger model material', async t => {
81
- const f = await fixture(t, {
82
- '.agent/memory/progress.md': { text: '# Progress\n' + 'Earlier work. '.repeat(500) + 'TAIL_BLOCKER_ONLY_FOR_ANALYSIS' },
83
- 'README.md': { text: 'Synthetic README' },
84
- });
85
- await f.service.act(f.owner, { action: 'watch' });
86
- const before = f.persisted();
87
- const summary = await f.service.act(f.owner, { action: 'digest', project: f.root });
88
- const analysis = await f.service.act(f.owner, { action: 'digest', project: f.root, detail: 'analysis' });
89
- const explicitSummary = await f.service.act(f.owner, { action: 'digest', project: f.root, detail: 'summary' });
90
- assert.match(analysis.text, /TAIL_BLOCKER_ONLY_FOR_ANALYSIS/);
91
- assert.doesNotMatch(summary.text, /TAIL_BLOCKER_ONLY_FOR_ANALYSIS/);
92
- assert.equal(explicitSummary.text, summary.text);
93
- assert.equal(analysis.wechatText, summary.wechatText);
94
- assert.ok(summary.text.length <= 3200);
95
- assert.ok(analysis.wechatText.length <= 3200);
96
- assert.deepEqual(f.persisted(), before);
97
- });
98
-
99
- test('analysis retains bounded observed event roles, full saved excerpts, original times and uncertainty', async t => {
100
- const f = await fixture(t, { 'README.md': { text: 'Synthetic README' } });
101
- await f.service.act(f.owner, { action: 'watch' });
102
- await f.service.record({ root: f.root, sessionId: f.owner.sessionId, id: 'old-hidden', kind: 'user', text: 'OLDER_EVENT_OUTSIDE_LATEST_THREE', at: '2026-10-16T12:00:00Z' });
103
- await f.service.record({ root: f.root, sessionId: f.owner.sessionId, id: 'user-control', kind: 'user', text: 'SCHEDULE_CONTROL: only check once; ' + 'x'.repeat(360) + ' NO_BUSINESS_WORK_REQUESTED', at: '2026-10-17T12:00:00Z' });
104
- await f.service.record({ root: f.root, sessionId: f.owner.sessionId, id: 'old-report', kind: 'assistant', text: 'OLD_ASSISTANT_REPORT: claimed done, not acceptance proof.', at: '2026-10-18T12:00:00Z' });
105
- await f.service.record({ root: f.root, sessionId: f.owner.sessionId, id: 'current-error', kind: 'error', text: 'CURRENT_RUNTIME_ERROR: input unavailable. ' + 'x'.repeat(600), at: '2026-10-19T16:59:00Z' });
106
- const result = await f.service.act(f.owner, { action: 'digest', project: f.root, detail: 'analysis' });
107
- assert.ok(result.analysis, 'analysis must preserve bounded observed event metadata');
108
- assert.deepEqual(result.analysis.events.map(event => event.kind), ['user', 'assistant', 'error']);
109
- assert.match(result.text, /NO_BUSINESS_WORK_REQUESTED/);
110
- assert.match(result.text, /2026-10-17T12:00:00/);
111
- assert.match(result.text, /OLD_ASSISTANT_REPORT/);
112
- assert.match(result.text, /CURRENT_RUNTIME_ERROR/);
113
- assert.doesNotMatch(result.text, /OLDER_EVENT_OUTSIDE_LATEST_THREE/);
114
- assert.match(result.text, /助手记录.*不是完成证明/);
115
- assert.match(result.text, /调度.*控制/);
116
- assert.equal(result.analysis.events.at(-1).truncated, true);
117
- assert.equal(result.analysis.events.at(-1).text.length, 500);
118
- assert.ok(result.analysis.events.every(event => event.text.length <= 500));
119
- });
120
-
121
- test('analysis does not invent complete historical events when the prior storage has no truncation metadata', async t => {
122
- const f = await fixture(t, { 'README.md': { text: 'Synthetic README' } });
123
- await f.service.act(f.owner, { action: 'watch' });
124
- const legacy = f.persisted();
125
- legacy.projects[0].events = [{ id: 'legacy-report', sessionId: f.owner.sessionId, kind: 'assistant', text: 'Old bounded assistant excerpt.', at: '2026-10-16T12:00:00Z' }];
126
- const service = createService({ store: { get: async () => legacy, put: async () => assert.fail('analysis cannot persist legacy state') }, hostTimeZone: 'UTC' });
127
- const result = await service.act(f.owner, { action: 'digest', project: f.root, detail: 'analysis' });
128
- assert.equal(result.analysis.events[0].truncated, null);
129
- assert.match(result.analysis.events[0].truncation, /完整性未知/);
130
- assert.match(result.text, /2026-10-16T12:00:00/);
131
- });
@@ -1,51 +0,0 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import {createPersonalReviewService,personalReviewRowSchema} from '../src/personal-review.js';
4
- import {reviewRuntimeHealth} from '../src/review-runtime-health.js';
5
-
6
- const owner={sessionId:'synthetic-decision-owner',cwd:'/synthetic/project'},binding='a'.repeat(64),grant='b'.repeat(64);
7
- const at='2026-10-31T23:00:00.000Z';
8
- async function fixture(t,{partial=false,unavailable=false,kind='reply',delivery='reported_sent'}={}){
9
- let row,clock=new Date('2026-10-31T22:30:00Z');const calls={read:0,model:0,send:0},materials=[],sent=[];
10
- const service=createPersonalReviewService({store:{get:async()=>structuredClone(row),put:async(_,v)=>{row=structuredClone(v);}},clock:()=>clock,
11
- readBinding:async()=>({bound:true,bindingKey:binding}),readBindingSync:()=>({bound:true,bindingKey:binding}),authorization:async()=>grant,authorizationSync:()=>true,
12
- collect:async()=>{calls.read++;return{evidence:unavailable?[]:[{id:'synthetic-evidence',source:'gmail',title:'Synthetic',text:'Synthetic deadline 2026-11-01T02:00:00.000Z',dueAt:'2026-11-01T02:00:00.000Z',dueAtBasis:'source'}],coverage:[{source:'gmail',status:unavailable?'unavailable':partial?'partial':'ok',count:unavailable?null:1,...(partial?{truncated:true}:{})}]};},
13
- summarize:async input=>{calls.model++;materials.push(input);return{items:[{key:'synthetic-item',kind,title:'合成事项',summary:'仅使用合成资料。',why:'核对这项变化。',action:'查看原通知。',unknown:'',evidenceIds:['synthetic-evidence'],priority:kind==='risk'?'high':'normal',confidence:'source',...(kind==='deadline'?{dueAt:'2026-11-01T02:00:00.000Z'}:{})}]};},
14
- send:async input=>{calls.send++;sent.push(input.text);return{status:delivery};}});
15
- t.after(()=>service.close());await service.act(owner,{action:'configure',sources:['gmail'],projects:[],schedule:{dailyTime:'09:00',timeZone:'America/Mexico_City'},requestId:'configure',userRequested:true});
16
- await service.act(owner,{action:'attention',enabled:true,requestId:'attention',userRequested:true});clock=new Date(at);
17
- return{service,calls,materials,sent,row:()=>structuredClone(row),setTime:value=>{clock=new Date(value);}};
18
- }
19
- test('partial natural attention persists a closed completed-check decision without notifying or complete watermark',async t=>{
20
- const f=await fixture(t,{partial:true});assert.equal((await f.service.tick())[0].status,'unknown');
21
- const row=f.row(),job=row.jobs.at(-1);assert.ok(job.attentionDecision);assert.equal(job.attentionDecision.outcome,'no_actionable_in_covered_scope');assert.equal(job.attentionDecision.evaluatedItems,1);
22
- assert.equal(f.calls.read,1);assert.equal(f.calls.model,1);assert.equal(f.calls.send,0);assert.deepEqual(row.watermarks,{});assert.equal(row.attentionClaims.length,0);
23
- const view=await f.service.snapshot(owner);assert.match(view.health.label,/已检查.*未发现达到提醒门槛.*覆盖/);assert.equal(view.health.state,'unknown');assert.equal(view.health.phoneReceipt,'unverified');
24
- assert.doesNotMatch(JSON.stringify(f.materials),/attentionDecision|reasonCounts|no_actionable_in_covered_scope/);assert.equal(personalReviewRowSchema.safeParse(row).success,true);
25
- });
26
- test('fully unavailable attention persists no-evaluation metadata without model, delivery or quiet claims',async t=>{
27
- const f=await fixture(t,{unavailable:true});await f.service.tick();const job=f.row().jobs.at(-1);
28
- assert.ok(job.attentionDecision);assert.equal(job.attentionDecision.outcome,'sources_unavailable');assert.equal(job.attentionDecision.evaluatedItems,0);assert.equal(job.status,'unknown');
29
- assert.equal(f.calls.model,0);assert.equal(f.calls.send,0);assert.match((await f.service.snapshot(owner)).health.label,/未能读取/);
30
- });
31
- test('last regular attention selects a proven quiet-hours deadline once, using unchanged read scope',async t=>{
32
- const f=await fixture(t,{kind:'deadline'});assert.equal((await f.service.tick())[0].status,'reported_sent');const row=f.row(),job=row.jobs.at(-1);
33
- assert.ok(job.attentionDecision);assert.equal(job.attentionDecision.deadlineThrough,'2026-11-01T15:00:00.000Z');assert.equal(job.attentionDecision.selectedItems,1);
34
- assert.equal(f.calls.send,1);assert.equal(f.calls.read,1);assert.doesNotMatch(f.sent[0],/attentionDecision|reasonCounts|deadlineThrough/);
35
- assert.deepEqual(await f.service.tick(),[]);assert.equal(f.calls.read,1);assert.equal(f.calls.send,1);assert.equal(row.attentionClaims.length,1);
36
- });
37
- test('an uncertain delivery is durably claimed and never replayed',async t=>{
38
- const f=await fixture(t,{kind:'risk',delivery:'uncertain'});assert.equal((await f.service.tick())[0].status,'uncertain');
39
- assert.equal(f.row().jobs.at(-1).attentionDecision.selectedItems,1);assert.deepEqual(await f.service.tick(),[]);assert.equal(f.calls.send,1);
40
- });
41
- test('durable decisions accept legacy absence but reject extra private fields and unknown enum values',async t=>{
42
- const f=await fixture(t);await f.service.tick();const row=f.row(),job=row.jobs.at(-1);assert.ok(job.attentionDecision);
43
- const legacy=structuredClone(row);delete legacy.jobs.at(-1).attentionDecision;assert.equal(personalReviewRowSchema.safeParse(legacy).success,true);
44
- job.attentionDecision.token='PRIVATE_CANARY';assert.equal(personalReviewRowSchema.safeParse(row).success,false);delete job.attentionDecision.token;
45
- job.attentionDecision.outcome='PRIVATE_CANARY';assert.equal(personalReviewRowSchema.safeParse(row).success,false);
46
- });
47
- test('unknown old jobs retain their uncertainty and no saved plan becomes execution',()=>{
48
- const subscription={paused:false,createdAt:'2026-10-31T22:30:00.000Z'},now=new Date(at);
49
- const health=reviewRuntimeHealth({subscription,jobs:[{createdAt:at,kind:'attention',status:'unknown'}],now});assert.equal(health.state,'unknown');assert.match(health.label,/覆盖不完整/);
50
- assert.equal(reviewRuntimeHealth({subscription,jobs:[],now}).state,'waiting');
51
- });
@@ -1,59 +0,0 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import * as attention from '../src/personal-review-attention.js';
4
-
5
- const scopeKey='a'.repeat(64);
6
- const policy={enabled:true,intervalMinutes:120,startHour:9,endHour:19,maxMessagesPerDay:2};
7
- const highRisk=(overrides={})=>({id:'synthetic-item',scopeKey,kind:'risk',priority:'high',status:'open',revision:1,notifiedRevision:0,lastNotifiedAt:null,notifications:[],evidence:[{source:'gmail',id:'synthetic-evidence'}],...overrides});
8
-
9
- test('a completed partial check explains no actionable items without claiming global no change',()=>{
10
- const output=attention.selectAttentionItems([highRisk({title:'PRIVATE_CANARY_TITLE',kind:'reply',priority:'normal'})],{now:'2026-10-31T17:00:00Z',scopeKey,coverage:[{source:'gmail',status:'partial',count:10,truncated:true},{source:'calendar',status:'ok',count:0}],remaining:2});
11
- assert.equal(output.status,'unknown');assert.deepEqual(output.selected,[]);
12
- assert.ok(output.decision,'persistable closed decision metadata must be available');
13
- assert.equal(output.decision.outcome,'no_actionable_in_covered_scope');
14
- assert.equal(output.decision.observedItems,1);assert.equal(output.decision.evaluatedItems,1);
15
- assert.equal(output.decision.reasonCounts.not_urgent,1);
16
- assert.deepEqual(output.decision.coverage,[{source:'gmail',status:'partial',count:10,truncated:true},{source:'calendar',status:'ok',count:0,truncated:false}]);
17
- assert.doesNotMatch(JSON.stringify(output.decision),/PRIVATE_CANARY|synthetic-item|synthetic-evidence|[a-f0-9]{64}/);
18
- });
19
-
20
- test('a real risk remains eligible even when another source is unavailable',()=>{
21
- const output=attention.selectAttentionItems([highRisk()],{now:'2026-10-31T17:00:00Z',scopeKey,coverage:[{source:'gmail',status:'ok',count:1},{source:'flomo',status:'unavailable',count:null}],remaining:2});
22
- assert.equal(output.status,'selected');assert.equal(output.selected.length,1);
23
- assert.ok(output.decision);assert.equal(output.decision.outcome,'selected');assert.equal(output.decision.selectedItems,1);
24
- });
25
-
26
- test('unavailable sources and exhausted budget are distinct decisions and never manufacture delivery',()=>{
27
- for(const [coverage,remaining,status,outcome]of[[[{source:'gmail',status:'unavailable',count:null}],2,'unknown','sources_unavailable'],[[{source:'gmail',status:'ok',count:1}],0,'budget_exhausted','budget_exhausted']]){
28
- const output=attention.selectAttentionItems([highRisk()],{now:'2026-10-31T17:00:00Z',scopeKey,coverage,remaining});assert.equal(output.status,status);assert.deepEqual(output.selected,[]);assert.ok(output.decision);assert.equal(output.decision.outcome,outcome);
29
- }
30
- });
31
-
32
- test('the last work-hours check covers verified deadlines before the next scheduled morning check',()=>{
33
- assert.equal(typeof attention.attentionDeadlineThrough,'function','a bounded next-check horizon is required');
34
- const now='2026-10-31T23:00:00Z'; // 17:00 Mexico; 19:00 is the quiet-hours boundary.
35
- const through=attention.attentionDeadlineThrough({now:new Date(now),timeZone:'America/Mexico_City',attention:policy,createdAt:'2026-10-30T20:59:00Z',dailyTime:'09:00',weeklyDay:1,weeklyTime:'09:00'});
36
- assert.equal(through,'2026-11-01T15:00:00.000Z');
37
- const item=highRisk({kind:'deadline',priority:'normal',dueAt:'2026-11-01T02:00:00.000Z',dueAtBasis:'source'});
38
- const prior=attention.selectAttentionItems([item],{now,scopeKey,coverage:[{source:'gmail',status:'ok',count:1}],remaining:2});assert.equal(prior.selected.length,0,'the original fixed two-hour horizon misses the quiet-hours deadline');
39
- const fixed=attention.selectAttentionItems([item],{now,scopeKey,coverage:[{source:'gmail',status:'ok',count:1}],remaining:2,deadlineThrough:through});assert.equal(fixed.selected.length,1);
40
- assert.equal(attention.selectAttentionItems([highRisk({...item,dueAtBasis:'relative'})],{now,scopeKey,coverage:[{source:'gmail',status:'ok',count:1}],remaining:2,deadlineThrough:through}).selected.length,0,'estimated dates remain estimated, not proven deadlines');
41
- });
42
-
43
- test('normal daytime horizon stays at the next check and a supplied horizon cannot exceed one day',()=>{
44
- assert.equal(typeof attention.attentionDeadlineThrough,'function');
45
- const now='2026-10-31T17:00:00Z';
46
- assert.equal(attention.attentionDeadlineThrough({now:new Date(now),timeZone:'America/Mexico_City',attention:policy,createdAt:'2026-10-30T20:59:00Z',dailyTime:'09:00'}),'2026-10-31T19:00:00.000Z');
47
- for(const deadlineThrough of ['2026-11-03T19:00:00Z','2026-10-31T16:00:00Z','not-a-date'])assert.throws(()=>attention.selectAttentionItems([],{now,scopeKey,coverage:[{source:'gmail',status:'ok',count:0}],remaining:2,deadlineThrough}));
48
- });
49
-
50
- test('a rescheduled but already claimed regular occurrence is not the next actual check',()=>{
51
- const through=attention.attentionDeadlineThrough({now:'2026-10-31T23:00:00Z',timeZone:'America/Mexico_City',attention:policy,createdAt:'2026-10-31T22:00:00Z',dailyTime:'20:00',occurrences:['daily:2026-10-31']});
52
- assert.equal(through,'2026-11-01T15:00:00.000Z');
53
- const result=attention.selectAttentionItems([highRisk({kind:'deadline',priority:'normal',dueAt:'2026-11-01T05:00:00.000Z',dueAtBasis:'source'})],{now:'2026-10-31T23:00:00Z',scopeKey,coverage:[{source:'gmail',status:'ok',count:1}],remaining:2,deadlineThrough:through});assert.equal(result.selected.length,1);
54
- });
55
-
56
- test('unknown coverage count is preserved rather than presented as zero',()=>{
57
- const result=attention.selectAttentionItems([],{now:'2026-10-31T17:00:00Z',scopeKey,coverage:[{source:'gmail',status:'partial',count:null}],remaining:2});assert.equal(result.decision.coverage[0].count,null);
58
- const aggregate=attention.selectAttentionItems([],{now:'2026-10-31T17:00:00Z',scopeKey,coverage:[{source:'project',status:'ok',count:2},{source:'project',status:'unavailable',count:null}],remaining:2});assert.equal(aggregate.decision.coverage[0].count,null);
59
- });