@oxmumu3/dsh-project-companion 0.24.1 → 0.24.2

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 (186) hide show
  1. package/README.md +2 -2
  2. package/docs/install.md +4 -4
  3. package/docs/roadmap.md +10 -2
  4. package/package.json +1 -3
  5. package/src/installation.js +5 -2
  6. package/test/action-surface.test.mjs +0 -69
  7. package/test/analysis-brief.test.mjs +0 -131
  8. package/test/attention-decision-service.test.mjs +0 -51
  9. package/test/attention-decision.test.mjs +0 -59
  10. package/test/build-release.test.mjs +0 -56
  11. package/test/bundled-wechat-storage.test.mjs +0 -44
  12. package/test/bundled-wechat.test.mjs +0 -122
  13. package/test/calendar-window.test.mjs +0 -25
  14. package/test/ci-sandbox.test.mjs +0 -55
  15. package/test/client-conversation.test.mjs +0 -98
  16. package/test/client-goal-board-native.test.mjs +0 -91
  17. package/test/client-goal-board-ui.test.mjs +0 -61
  18. package/test/client-goal-board.test.mjs +0 -128
  19. package/test/client-overlay-integration.test.mjs +0 -18
  20. package/test/client-overlay-session.test.mjs +0 -61
  21. package/test/client-overlay.test.mjs +0 -113
  22. package/test/compatibility-contract.test.mjs +0 -14
  23. package/test/context-account-auth.test.mjs +0 -373
  24. package/test/context-authorization.test.mjs +0 -11
  25. package/test/context-client.test.mjs +0 -438
  26. package/test/context-contracts.test.mjs +0 -231
  27. package/test/context-credential-writer.test.mjs +0 -36
  28. package/test/context-five-source-grant.test.mjs +0 -22
  29. package/test/context-google-auth.test.mjs +0 -252
  30. package/test/context-host.test.mjs +0 -290
  31. package/test/context-loop-host.test.mjs +0 -266
  32. package/test/context-loop.test.mjs +0 -219
  33. package/test/context-projection-diagnostics.test.mjs +0 -18
  34. package/test/context-provider.test.mjs +0 -18
  35. package/test/context-route-auth-check.test.mjs +0 -42
  36. package/test/context-route-binding-race.test.mjs +0 -91
  37. package/test/context-route-read-check.test.mjs +0 -64
  38. package/test/context-service.test.mjs +0 -111
  39. package/test/context-summary-probe.test.mjs +0 -92
  40. package/test/context-transport.test.mjs +0 -369
  41. package/test/contract-guidance.test.mjs +0 -77
  42. package/test/coordination-job-id.test.mjs +0 -89
  43. package/test/desktop-conversation.test.mjs +0 -80
  44. package/test/dida-named-project.test.mjs +0 -56
  45. package/test/dida-rest-integration.test.mjs +0 -37
  46. package/test/dida-rest.test.mjs +0 -139
  47. package/test/doctor.test.mjs +0 -136
  48. package/test/dot-appearance.test.mjs +0 -254
  49. package/test/egress-guard.test.mjs +0 -129
  50. package/test/embedded-wechat-auth.test.mjs +0 -63
  51. package/test/embedded-wechat-pairing.test.mjs +0 -202
  52. package/test/family-barrier-timeout.manual.mjs +0 -73
  53. package/test/family-context-adapter.test.mjs +0 -27
  54. package/test/family-context-intent.test.mjs +0 -66
  55. package/test/family-cross-host.test.mjs +0 -233
  56. package/test/family-flomo-refresh-cross-layer.test.mjs +0 -56
  57. package/test/family-intent.test.mjs +0 -32
  58. package/test/family-native-coordination.test.mjs +0 -26
  59. package/test/family-news-cross-host.test.mjs +0 -42
  60. package/test/family-news-intent.test.mjs +0 -29
  61. package/test/family-owner-delegation.test.mjs +0 -140
  62. package/test/family-owner-native-cross-host.test.mjs +0 -53
  63. package/test/family-owner-renewal-host.test.mjs +0 -67
  64. package/test/family-owner-renewal.test.mjs +0 -86
  65. package/test/family-personal-review-cross-host.test.mjs +0 -148
  66. package/test/family-personal-review.test.mjs +0 -73
  67. package/test/family-plan.test.mjs +0 -17
  68. package/test/family-project-admission.test.mjs +0 -7
  69. package/test/family-read-adapter.test.mjs +0 -33
  70. package/test/family-readme-full-cross-host.test.mjs +0 -52
  71. package/test/family-reminder-cross-host.test.mjs +0 -23
  72. package/test/family-reminder.test.mjs +0 -11
  73. package/test/family-renewal-brief-followup-cross-host.test.mjs +0 -161
  74. package/test/family-send-barrier-conversation-cross-host.test.mjs +0 -74
  75. package/test/family-send-barrier-cross-host.test.mjs +0 -75
  76. package/test/family-service-delivery.test.mjs +0 -36
  77. package/test/family-workbench-route.test.mjs +0 -18
  78. package/test/flomo-oauth-integration.test.mjs +0 -31
  79. package/test/followup-lifecycle.test.mjs +0 -87
  80. package/test/generation-failure.test.mjs +0 -45
  81. package/test/goal-board-collect.test.mjs +0 -12
  82. package/test/goal-board-host.test.mjs +0 -17
  83. package/test/goal-board-model-diagnostics.test.mjs +0 -23
  84. package/test/goal-board-model.test.mjs +0 -36
  85. package/test/goal-board-route.test.mjs +0 -6
  86. package/test/goal-board-service.test.mjs +0 -117
  87. package/test/goal-board-store.test.mjs +0 -32
  88. package/test/goal-board-sweep.test.mjs +0 -94
  89. package/test/goal-board-unsupported.test.mjs +0 -67
  90. package/test/google-calendar-auth.test.mjs +0 -43
  91. package/test/google-calendar-integration.test.mjs +0 -28
  92. package/test/google-calendar-rest.test.mjs +0 -112
  93. package/test/google-connection-check.test.mjs +0 -37
  94. package/test/google-secure-auth.test.mjs +0 -30
  95. package/test/google-suite-auth.test.mjs +0 -82
  96. package/test/google-suite-diagnostics.test.mjs +0 -70
  97. package/test/google-suite-integration.test.mjs +0 -45
  98. package/test/google-suite-network.test.mjs +0 -60
  99. package/test/google-suite-response.test.mjs +0 -83
  100. package/test/google-suite-rest.test.mjs +0 -146
  101. package/test/google-token-vault.test.mjs +0 -221
  102. package/test/google-vault-cold-integration.test.mjs +0 -32
  103. package/test/guidance.test.mjs +0 -56
  104. package/test/host-tool-call.test.mjs +0 -46
  105. package/test/host.test.mjs +0 -1108
  106. package/test/install.test.mjs +0 -271
  107. package/test/native-draft.test.mjs +0 -14
  108. package/test/natural-output-issue.test.mjs +0 -108
  109. package/test/news-editorial-quality.test.mjs +0 -48
  110. package/test/news-feed-service-regression.test.mjs +0 -21
  111. package/test/news-feeds.test.mjs +0 -287
  112. package/test/news-identity.test.mjs +0 -24
  113. package/test/news-model.test.mjs +0 -341
  114. package/test/news-preview-diagnostic-regression.test.mjs +0 -72
  115. package/test/news-render.test.mjs +0 -42
  116. package/test/news-service.test.mjs +0 -469
  117. package/test/news-topics.test.mjs +0 -28
  118. package/test/oauth-diagnostic-cross-layer.test.mjs +0 -22
  119. package/test/oauth-diagnostic.test.mjs +0 -28
  120. package/test/oauth-network.test.mjs +0 -32
  121. package/test/official-channels.test.mjs +0 -35
  122. package/test/onboarding-outcome.test.mjs +0 -154
  123. package/test/onboarding-retry.test.mjs +0 -81
  124. package/test/onboarding-ui.test.mjs +0 -227
  125. package/test/onboarding.test.mjs +0 -152
  126. package/test/personal-preview-regression.test.mjs +0 -65
  127. package/test/personal-preview-snooze-regression.test.mjs +0 -22
  128. package/test/personal-review-attention-receipt-host.test.mjs +0 -64
  129. package/test/personal-review-attention-receipt.test.mjs +0 -107
  130. package/test/personal-review-attention-wiring-regression.test.mjs +0 -115
  131. package/test/personal-review-attention.test.mjs +0 -55
  132. package/test/personal-review-audit.test.mjs +0 -192
  133. package/test/personal-review-availability-diagnostic.test.mjs +0 -118
  134. package/test/personal-review-availability-host.test.mjs +0 -47
  135. package/test/personal-review-collect.test.mjs +0 -76
  136. package/test/personal-review-collector-audit.test.mjs +0 -117
  137. package/test/personal-review-continuation.test.mjs +0 -77
  138. package/test/personal-review-control.test.mjs +0 -20
  139. package/test/personal-review-current-context.test.mjs +0 -81
  140. package/test/personal-review-deadline-selection.test.mjs +0 -14
  141. package/test/personal-review-delivery-failure-regression.test.mjs +0 -47
  142. package/test/personal-review-diagnostics-regression.test.mjs +0 -90
  143. package/test/personal-review-focus.test.mjs +0 -112
  144. package/test/personal-review-goals.test.mjs +0 -94
  145. package/test/personal-review-grant-calendar-regression.test.mjs +0 -33
  146. package/test/personal-review-model.test.mjs +0 -83
  147. package/test/personal-review-recovery.test.mjs +0 -96
  148. package/test/personal-review-render.test.mjs +0 -14
  149. package/test/personal-review-repair.test.mjs +0 -34
  150. package/test/personal-review-semantics-regression.test.mjs +0 -128
  151. package/test/personal-review-source-diagnostics.test.mjs +0 -85
  152. package/test/personal-review-source-reconcile.test.mjs +0 -126
  153. package/test/personal-review-source-tasks.test.mjs +0 -81
  154. package/test/personal-review-sources.test.mjs +0 -46
  155. package/test/personal-review.test.mjs +0 -228
  156. package/test/presentation.test.mjs +0 -65
  157. package/test/proactive-scheduler-boundary.test.mjs +0 -58
  158. package/test/proactive-vendor-provenance.test.mjs +0 -20
  159. package/test/project-catalog-intent.test.mjs +0 -14
  160. package/test/project-catalog-route.test.mjs +0 -44
  161. package/test/project-catalog-service.test.mjs +0 -27
  162. package/test/project-catalog.test.mjs +0 -46
  163. package/test/project-followup-loop.test.mjs +0 -553
  164. package/test/project-followup.test.mjs +0 -555
  165. package/test/project-memory-edit.test.mjs +0 -186
  166. package/test/project-memory.test.mjs +0 -382
  167. package/test/project-update-model.test.mjs +0 -584
  168. package/test/project-updates.test.mjs +0 -23
  169. package/test/review-handoff-coordination.test.mjs +0 -36
  170. package/test/review-runtime-health.test.mjs +0 -23
  171. package/test/review-workbench-projection.test.mjs +0 -173
  172. package/test/routing-corpus.mjs +0 -45
  173. package/test/routing-surface.test.mjs +0 -17
  174. package/test/service.test.mjs +0 -554
  175. package/test/sources.test.mjs +0 -32
  176. package/test/task-results.test.mjs +0 -412
  177. package/test/wechat-recovery.test.mjs +0 -181
  178. package/test/wechat-route.test.mjs +0 -83
  179. package/test/welcome-guard.test.mjs +0 -213
  180. package/test/workbench-actions.test.mjs +0 -244
  181. package/test/workbench-loop-plan.test.mjs +0 -43
  182. package/test/workbench-native-lifecycle.test.mjs +0 -91
  183. package/test/workbench-scope.test.mjs +0 -45
  184. package/test/workbench-ui.test.mjs +0 -726
  185. package/test/workbench.test.mjs +0 -325
  186. 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">
package/docs/install.md CHANGED
@@ -1,4 +1,4 @@
1
- # 安装 DSH Dot 0.24.0
1
+ # 安装 DSH Dot 0.24.2
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.24.2`),安装后启用。它是一个标准插件包,已内置独立微信组件。已有未带 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.24.2)记录本版变更。插件包从 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.24.2 源码全量回归 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
 
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.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
 
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.24.2",
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",
@@ -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
- });
@@ -1,56 +0,0 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import { spawnSync } from 'node:child_process';
4
- import { fileURLToPath } from 'node:url';
5
-
6
- const builder = fileURLToPath(new URL('../scripts/build-release.py', import.meta.url));
7
- const originalHash = '993e1e1afce3c0dcd2610bf9e84ffbfd6d08768f5c4b4fa30eeec50dc2e97d3f';
8
- const previousForkHash = 'b40031cd0928c9df76a864d6ff15bc3fe7356b6298ad2758b6272f127f965878';
9
- const forkHash = 'b0f811e7f3d4746fe27d12460f7f188d4ad8d0b5f6be44f442636ce6db3538f7';
10
- function python(source) {
11
- const bootstrap = 'import importlib.util, sys\nsys.dont_write_bytecode=True\nspec=importlib.util.spec_from_file_location("release",sys.argv[1])\nrelease=importlib.util.module_from_spec(spec)\nspec.loader.exec_module(release)\n';
12
- const result = spawnSync('python3', ['-c', bootstrap + source, builder], { encoding: 'utf8', timeout: 10000 });
13
- assert.equal(result.status, 0, result.stderr || result.stdout);
14
- return result.stdout;
15
- }
16
-
17
- test('release builder accepts only the reviewed original and two exact maintenance bridge archive pins', () => {
18
- const rows = JSON.parse(python(`import json\nprint(json.dumps([release.reviewed_bridge("dsh-wechat-0.11.0.tgz","${originalHash}"),release.reviewed_bridge("dsh-wechat-0.11.1-dot.1.tgz","${previousForkHash}"),release.reviewed_bridge("dsh-wechat-0.11.1-dot.2.tgz","${forkHash}")]))\n`));
19
- assert.deepEqual(rows.map(row => [row.name, row.version]), [['dsh-wechat', '0.11.0'], ['dsh-wechat', '0.11.1-dot.1'], ['dsh-wechat', '0.11.1-dot.2']]);
20
- assert.equal(rows[0].sourceKind, 'original_npm');
21
- assert.equal(rows[1].sourceKind, 'dot_maintained_fork');
22
- assert.equal(rows[1].sourceCommit, '1f28de0f5a9d338db884ff5b84e90e9572eaf1cc');
23
- assert.equal(rows[2].sourceKind, 'dot_maintained_fork');
24
- assert.equal(rows[2].sourceCommit, '19c3f40c85bcdd49525a09d07007978e61521f83');
25
- });
26
-
27
- test('renaming, hash substitution and arbitrary bridge versions cannot bypass the builder pin', () => {
28
- const invalid = [
29
- ['dsh-wechat-0.11.0.tgz', forkHash], ['dsh-wechat-0.11.1-dot.1.tgz', originalHash],
30
- ['dsh-wechat-0.11.1-dot.2.tgz', previousForkHash], ['dsh-wechat-0.11.1-dot.3.tgz', forkHash], ['unreviewed.tgz', forkHash],
31
- ['dsh-wechat-0.11.1-dot.1.tgz', '0'.repeat(64)],
32
- ];
33
- python(`import json\nfor name,sha in json.loads(${JSON.stringify(JSON.stringify(invalid))}):\n try:\n release.reviewed_bridge(name,sha)\n except ValueError:\n pass\n else:\n raise AssertionError("unreviewed archive accepted: "+name)\n`);
34
- });
35
-
36
- test('release archive audit rejects inner bridge metadata that differs from the reviewed version', () => {
37
- python('import io,json,tarfile,tempfile\nfrom pathlib import Path\nwith tempfile.TemporaryDirectory() as directory:\n path=Path(directory)/"synthetic.tgz"\n with tarfile.open(path,"w:gz") as archive:\n raw=json.dumps({"name":"dsh-wechat","version":"0.12.0","license":"MIT","dsh":{"bundle":{"patch":"./cordis.patch.yml"}}}).encode()\n member=tarfile.TarInfo("package/package.json");member.size=len(raw);archive.addfile(member,io.BytesIO(raw))\n try:\n release.package_audit(path,"dsh-wechat","0.11.1-dot.1")\n except ValueError:\n pass\n else:\n raise AssertionError("unreviewed inner metadata accepted")\n');
38
- });
39
-
40
- test('kit first-use instructions stay on the exact packaged release instead of the divergent default branch', () => {
41
- const rows = JSON.parse(python(`import json\nfrom pathlib import Path\nversion=json.loads((Path(release.__file__).parent.parent/"package.json").read_text())["version"]\ntext="[首次使用](first-use.md) · [许可](../THIRD_PARTY_NOTICES.md)"\nprint(json.dumps([[v,release.install_doc_for_kit(text,"https://github.com/oxmumu3/dsh-project-companion",v)] for v in [version,"9.8.7-preview.6"]]))\n`));
42
- for (const [version, rendered] of rows) {
43
- assert.equal(rendered, `[首次使用](https://github.com/oxmumu3/dsh-project-companion/blob/v${version}/docs/first-use.md) · [许可](THIRD_PARTY_NOTICES.md)`);
44
- assert(!rendered.includes('/blob/main/'));
45
- }
46
- });
47
-
48
- test('kit rendering preserves the unverified-homepage fallback instead of constructing another public owner link', () => {
49
- const rendered = python('print(release.install_doc_for_kit("[首次使用](first-use.md) · [许可](../THIRD_PARTY_NOTICES.md)","https://example.invalid/unverified","9.8.7-preview.6"))\n').trim();
50
- assert.equal(rendered, '首次使用(正式仓库入口仍待核验) · [许可](THIRD_PARTY_NOTICES.md)');
51
- });
52
-
53
- test('guarded bridge package has an exact reviewed immutable provenance pin',()=>{
54
- const row=JSON.parse(python('import json\nprint(json.dumps(release.reviewed_bridge("dsh-wechat-0.11.1-dot.3.tgz","2205931694cf84eadea55c7445d7f5ff5b2ae4c76a8f658b495120c811a7c41c")))\n'));
55
- assert.equal(row.sourceCommit,"1aa862728afcba1d811ce9ba442d6fb1bcd45ee0");assert.equal(row.deltaSha256,"794558129efb162a596c9ec9511ad24196327c3a0c1b882fbc48b751d7972a5d");
56
- });
@@ -1,44 +0,0 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import {mkdtemp,mkdir,readFile,writeFile,rm,symlink,realpath} from 'node:fs/promises';
4
- import {join} from 'node:path';
5
- import {tmpdir} from 'node:os';
6
- import {prepareOwnedWechatStorage} from '../src/bundled-wechat-storage.js';
7
- async function profile(t){const root=await mkdtemp(join(tmpdir(),'dot-owned-storage-'));t.after(()=>rm(root,{recursive:true,force:true}));return{root,ctx:{get:name=>name==='profileContext'?{dir:root}:undefined}};}
8
- test('fresh storage is inside the current profile and can be reopened without a new identity',async t=>{
9
- const {root,ctx}=await profile(t),dir=await prepareOwnedWechatStorage(ctx);assert.equal(dir,join(await realpath(root),'dot-wechat'));
10
- assert.equal(await prepareOwnedWechatStorage(ctx),dir);assert.equal(JSON.parse(await readFile(join(dir,'dot-owner.json'))).plugin,'dsh-project-companion');
11
- });
12
- test('existing unowned state is not claimed, read, overwritten or reset',async t=>{
13
- const {root,ctx}=await profile(t),dir=join(root,'dot-wechat');await mkdir(dir);const file=join(dir,'state.json');const original='PRIVATE_SYNTHETIC_BINDING_CANARY';await writeFile(file,original);
14
- await assert.rejects(prepareOwnedWechatStorage(ctx),e=>e.reason==='existing_storage');assert.equal(await readFile(file,'utf8'),original);
15
- });
16
- test('foreign profile marker is not silently rebound',async t=>{
17
- const {ctx}=await profile(t),dir=await prepareOwnedWechatStorage(ctx),marker=join(dir,'dot-owner.json');const text=JSON.stringify({version:1,plugin:'dsh-project-companion',profileDir:'/synthetic-other-profile'});await writeFile(marker,text);
18
- await assert.rejects(prepareOwnedWechatStorage(ctx),e=>e.reason==='existing_storage');assert.equal(await readFile(marker,'utf8'),text);
19
- });
20
- test('symlinked storage is rejected without following it',async t=>{
21
- const {root,ctx}=await profile(t);const other=join(root,'other');await mkdir(other);await symlink(other,join(root,'dot-wechat'));
22
- await assert.rejects(prepareOwnedWechatStorage(ctx),e=>e.reason==='existing_storage');
23
- });
24
- test('bound owned storage with a missing token can reach non-destructive QR recovery',async t=>{
25
- const {ctx}=await profile(t),dir=await prepareOwnedWechatStorage(ctx),file=join(dir,'state.json');const text=JSON.stringify({users:{synthetic:{userId:'synthetic',sessionId:'synthetic-session'}}});await writeFile(file,text);
26
- assert.equal(await prepareOwnedWechatStorage(ctx),dir);assert.equal(await readFile(file,'utf8'),text);
27
- });
28
- test('malformed owned auth and malformed state remain unchanged',async t=>{
29
- const {ctx}=await profile(t),dir=await prepareOwnedWechatStorage(ctx);await mkdir(join(dir,'auth'));const file=join(dir,'auth','token.json');await writeFile(file,'{bad-synthetic');
30
- await assert.rejects(prepareOwnedWechatStorage(ctx),e=>e.reason==='storage_unavailable');assert.equal(await readFile(file,'utf8'),'{bad-synthetic');
31
- });
32
- test('valid own synthetic binding and token are resumed without rewriting either file',async t=>{
33
- const {ctx}=await profile(t),dir=await prepareOwnedWechatStorage(ctx);await mkdir(join(dir,'auth'));
34
- const state=JSON.stringify({users:{synthetic:{userId:'synthetic'}}}),token=JSON.stringify({token:'synthetic-nonusable',baseUrl:'https://synthetic.invalid',accountId:'synthetic',userId:'synthetic'});
35
- await writeFile(join(dir,'state.json'),state);await writeFile(join(dir,'auth','token.json'),token);
36
- assert.equal(await prepareOwnedWechatStorage(ctx),dir);assert.equal(await readFile(join(dir,'state.json'),'utf8'),state);assert.equal(await readFile(join(dir,'auth','token.json'),'utf8'),token);
37
- });
38
-
39
- test('legacy credentials without QR identity can reach fail-closed local recovery without rewriting state',async t=>{
40
- const {ctx}=await profile(t),dir=await prepareOwnedWechatStorage(ctx);await mkdir(join(dir,'auth'));
41
- const state=JSON.stringify({users:{synthetic:{userId:'synthetic',sessionId:'synthetic-session'}}}),token=JSON.stringify({token:'synthetic-nonusable',baseUrl:'https://synthetic.invalid',accountId:'synthetic-bot'});
42
- await writeFile(join(dir,'state.json'),state);await writeFile(join(dir,'auth','token.json'),token);
43
- assert.equal(await prepareOwnedWechatStorage(ctx),dir);assert.equal(await readFile(join(dir,'state.json'),'utf8'),state);assert.equal(await readFile(join(dir,'auth','token.json'),'utf8'),token);
44
- });