@yiyi_zhang/laoshi 0.2.0-beta.3 → 0.3.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 (139) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +3 -2
  3. package/adapters/dsh/adapter.ts +22 -1
  4. package/adapters/dsh/dsh-runtime.ts +14 -3
  5. package/adapters/dsh/install.mjs +16 -4
  6. package/adapters/dsh/plugin/index.mjs +197 -18
  7. package/adapters/dsh/plugin/package.json +1 -1
  8. package/adapters/mogao/adapter.ts +10 -1
  9. package/adapters/mogao/mogao-runtime.ts +58 -23
  10. package/adapters/mogao/skill/setup.md +6 -0
  11. package/adapters/paseo/install.mjs +13 -4
  12. package/adapters/paseo/plugin/client/data.ts +13 -2
  13. package/adapters/paseo/plugin/client/detail.tsx +244 -4
  14. package/adapters/paseo/plugin/client/format.ts +25 -117
  15. package/adapters/paseo/plugin/client/overview.tsx +3 -3
  16. package/adapters/paseo/plugin/index.server.ts +2 -1
  17. package/adapters/paseo/plugin/package.json +1 -1
  18. package/adapters/paseo/plugin/paseo-plugin.json +1 -1
  19. package/adapters/paseo/plugin/server/handlers.ts +22 -4
  20. package/adapters/paseo/plugin/server/req.ts +17 -4
  21. package/adapters/paseo/plugin/shared/contracts.ts +28 -2
  22. package/adapters/paseo/plugin/shared/view-model.ts +425 -0
  23. package/bin/ensure-version.mjs +60 -0
  24. package/bin/req-doctor.mjs +5 -0
  25. package/bin/req.mjs +18 -0
  26. package/bin/start-pipeline.mjs +5 -0
  27. package/contracts/cli-json.md +3 -1
  28. package/docs/design/builtin-capabilities.md +2 -2
  29. package/docs/design/cli-adapter.md +1 -1
  30. package/docs/design/dsh-adapter.md +11 -11
  31. package/docs/design/shared-ui.md +43 -0
  32. package/docs/guide//345/234/250/346/221/270/351/253/230/344/270/212/344/275/277/347/224/250.md +2 -1
  33. package/docs/guide//345/256/211/350/243/205/344/270/216/345/215/207/347/272/247.md +13 -8
  34. package/docs/guide//347/234/237/345/256/236/347/216/257/345/242/203/350/265/260/346/237/245.md +78 -0
  35. package/docs/guide//347/273/264/346/212/244/350/200/205/346/214/207/345/215/227.md +36 -6
  36. package/engine/prompts/00-shared-context.md +7 -0
  37. package/engine/prompts/03-design.md +2 -0
  38. package/engine/prompts/04-design-review.md +5 -1
  39. package/engine/skill-fragments/defaults.md +5 -0
  40. package/engine/src/api.ts +11 -2
  41. package/engine/src/board.ts +435 -0
  42. package/engine/src/config.ts +23 -0
  43. package/engine/src/diagnose.ts +238 -0
  44. package/engine/src/doctor.ts +25 -0
  45. package/engine/src/estimate.ts +11 -0
  46. package/engine/src/extensions.ts +271 -0
  47. package/engine/src/handover-cmd.ts +47 -0
  48. package/engine/src/handover.ts +89 -0
  49. package/engine/src/history.ts +102 -0
  50. package/engine/src/joint.ts +49 -4
  51. package/engine/src/launch.ts +20 -5
  52. package/engine/src/main.ts +1 -1
  53. package/engine/src/messages.ts +58 -0
  54. package/engine/src/pipeline.ts +121 -5
  55. package/engine/src/platform.ts +6 -0
  56. package/engine/src/reply.ts +27 -6
  57. package/engine/src/semver.ts +21 -0
  58. package/engine/src/skills-render.ts +10 -1
  59. package/package.json +5 -2
  60. package/site-dist/404.html +2 -2
  61. package/site-dist/assets/{app.CXydUhZx.js → app.DZpVs0VH.js} +1 -1
  62. package/site-dist/assets/changelog.md.CdUYbro4.js +1 -0
  63. package/site-dist/assets/{changelog.md.BU-CvyJ1.lean.js → changelog.md.CdUYbro4.lean.js} +1 -1
  64. package/site-dist/assets/chunks/@localSearchIndexroot.CHr-ITwS.js +1 -0
  65. package/site-dist/assets/chunks/{VPLocalSearchBox.CIjDV0ax.js → VPLocalSearchBox.BHkmziy1.js} +1 -1
  66. package/site-dist/assets/chunks/{theme.CWtC1Kby.js → theme.BsPChbDE.js} +2 -2
  67. package/site-dist/assets/guide_dsh.md.D0XhcUHz.js +7 -0
  68. package/site-dist/assets/guide_dsh.md.D0XhcUHz.lean.js +7 -0
  69. package/site-dist/assets/{guide_getting-started.md.BxOxfic_.js → guide_getting-started.md.BDd3nU5n.js} +1 -1
  70. package/site-dist/assets/{guide_install.md.By4WxsJG.js → guide_install.md.SsIHMfUu.js} +7 -5
  71. package/site-dist/assets/{guide_install.md.By4WxsJG.lean.js → guide_install.md.SsIHMfUu.lean.js} +7 -5
  72. package/site-dist/assets/guide_maintainer.md.CvqvRle1.js +1 -0
  73. package/site-dist/assets/guide_maintainer.md.CvqvRle1.lean.js +1 -0
  74. package/site-dist/assets/{guide_mogao.md.S0eln1Pr.js → guide_mogao.md.TCu3lgE9.js} +2 -2
  75. package/site-dist/assets/{guide_mogao.md.S0eln1Pr.lean.js → guide_mogao.md.TCu3lgE9.lean.js} +2 -2
  76. package/site-dist/assets/guide_walkthrough.md.nj_PWP9Y.js +5 -0
  77. package/site-dist/assets/guide_walkthrough.md.nj_PWP9Y.lean.js +5 -0
  78. package/site-dist/assets/reference_contracts_cli-json.md.3iU9h4rw.js +1 -0
  79. package/site-dist/assets/reference_contracts_cli-json.md.3iU9h4rw.lean.js +1 -0
  80. package/site-dist/assets/{reference_design_builtin-capabilities.md.CZYtjo_v.js → reference_design_builtin-capabilities.md.k5NXkESv.js} +2 -2
  81. package/site-dist/assets/{reference_design_builtin-capabilities.md.CZYtjo_v.lean.js → reference_design_builtin-capabilities.md.k5NXkESv.lean.js} +2 -2
  82. package/site-dist/assets/{reference_design_cli-adapter.md.pJy3x6Un.js → reference_design_cli-adapter.md.C1lcDATP.js} +1 -1
  83. package/site-dist/assets/{reference_design_cli-adapter.md.pJy3x6Un.lean.js → reference_design_cli-adapter.md.C1lcDATP.lean.js} +1 -1
  84. package/site-dist/changelog.html +5 -5
  85. package/site-dist/guide/cli.html +4 -4
  86. package/site-dist/guide/dsh.html +8 -6
  87. package/site-dist/guide/getting-started.html +5 -5
  88. package/site-dist/guide/how-it-works.html +4 -4
  89. package/site-dist/guide/index.html +4 -4
  90. package/site-dist/guide/install.html +11 -9
  91. package/site-dist/guide/intranet.html +4 -4
  92. package/site-dist/guide/maintainer.html +5 -5
  93. package/site-dist/guide/mogao.html +7 -7
  94. package/site-dist/guide/phases.html +4 -4
  95. package/site-dist/guide/project.html +4 -4
  96. package/site-dist/guide/user.html +4 -4
  97. package/site-dist/guide/walkthrough.html +34 -0
  98. package/site-dist/hashmap.json +1 -1
  99. package/site-dist/index.html +4 -4
  100. package/site-dist/reference/adr/0001-new-repo-core-and-adapters.html +4 -4
  101. package/site-dist/reference/adr/0002-two-orchestration-modes.html +4 -4
  102. package/site-dist/reference/adr/0003-generate-once-then-lock.html +4 -4
  103. package/site-dist/reference/adr/0004-external-contracts-stay-stable.html +4 -4
  104. package/site-dist/reference/adr/0005-skill-names.html +4 -4
  105. package/site-dist/reference/adr/0006-deterministic-engine-platform-capabilities.html +4 -4
  106. package/site-dist/reference/adr/0007-one-install-many-repos.html +4 -4
  107. package/site-dist/reference/adr/0008-capability-sources-and-platform-plugin.html +4 -4
  108. package/site-dist/reference/adr/index.html +4 -4
  109. package/site-dist/reference/commands.html +4 -4
  110. package/site-dist/reference/config.html +4 -4
  111. package/site-dist/reference/contracts/agent-runtime.html +4 -4
  112. package/site-dist/reference/contracts/cli-json.html +5 -5
  113. package/site-dist/reference/contracts/feature-files.html +4 -4
  114. package/site-dist/reference/contracts/index.html +4 -4
  115. package/site-dist/reference/contracts/notifier-event.html +4 -4
  116. package/site-dist/reference/contracts/result-file.html +4 -4
  117. package/site-dist/reference/contracts/spec.html +4 -4
  118. package/site-dist/reference/contracts/state.html +4 -4
  119. package/site-dist/reference/contracts/usage-record.html +4 -4
  120. package/site-dist/reference/contracts/verify.html +4 -4
  121. package/site-dist/reference/design/adapter-guide.html +4 -4
  122. package/site-dist/reference/design/architecture.html +4 -4
  123. package/site-dist/reference/design/builtin-capabilities.html +6 -6
  124. package/site-dist/reference/design/cli-adapter.html +5 -5
  125. package/site-dist/reference/design/platform-vocabulary.html +4 -4
  126. package/site-dist/reference/scope.html +4 -4
  127. package/skills/laoshi/SKILL.md +1 -3
  128. package/skills/laoshi-setup/SKILL.md +1 -1
  129. package/ui/shared/view-model.ts +424 -0
  130. package/ui/web/board.ts +1126 -0
  131. package/site-dist/assets/changelog.md.BU-CvyJ1.js +0 -1
  132. package/site-dist/assets/chunks/@localSearchIndexroot.CfgJeQRO.js +0 -1
  133. package/site-dist/assets/guide_dsh.md.0X-eYB87.js +0 -5
  134. package/site-dist/assets/guide_dsh.md.0X-eYB87.lean.js +0 -5
  135. package/site-dist/assets/guide_maintainer.md.Da1ffqxm.js +0 -1
  136. package/site-dist/assets/guide_maintainer.md.Da1ffqxm.lean.js +0 -1
  137. package/site-dist/assets/reference_contracts_cli-json.md.D6vfWOD9.js +0 -1
  138. package/site-dist/assets/reference_contracts_cli-json.md.D6vfWOD9.lean.js +0 -1
  139. /package/site-dist/assets/{guide_getting-started.md.BxOxfic_.lean.js → guide_getting-started.md.BDd3nU5n.lean.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,45 @@
2
2
 
3
3
  laoshi 的版本号遵循语义化版本,从 0.1.0 开始;每一版的标题写成 `## <版本> - <日期>`。每一版先写使用者会看到的变化,再写升级须知。laoshi 之前的历史见 paseo-req-kit 的更新记录(laoshi 从它的 1.15.0 抽出)。
4
4
 
5
+ ## 0.3.0 - 2026-11-24
6
+
7
+ 正式版(npm `latest` 标签):新增共享 Web 需求看板与验收工作台、全链路变更历史与转交、受控流程扩展、多仓库联合开发增强、预算预估与多模型评审检查,并将 Paseo(`0.11–0.17`)需求插件与 DeepSeek Harness(`dsh 0.2.2-alpha.2` / `0.2.2-rc.5`)宿主适配及文档补齐。安装:`npx -y @yiyi_zhang/laoshi@latest install --platform <平台>`。
8
+
9
+ ### 使用者会看到的变化
10
+
11
+ - **共享 Web 需求看板与验收工作台(`laoshi board`)**:任意平台均可运行 `laoshi board` 打开本机实时中文 Bento 需求看板;支持总览分组、「需要你处理」置顶、需求详情 6 站放行轨,以及验收工作台(一键试用启停、逐条 AC 勾选与提交 `acceptance.md` 结论、证据预览)。安装时可通过 `dsh` 自动托管看板(默认启用 `board: true`,`--no-board` / `--board-port` 可选配置,`laoshi doctor` 直接显示访问地址)。
12
+ - **改需求、变更历史与转交接手**:Web 看板「变更与接手」页签、Paseo 插件详情页及 CLI(`laoshi reply --change`、`laoshi handover`)支持在需求推进中发起改需求、倒序查看 `changes.md` 变更历史与 `spec.md` 提交 diff(绿增/红删高亮),并支持转交接手及完整交接记录(`.pipeline/owner.json`)。
13
+ - **受控流程扩展(`extensions`)**:支持在项目配置 `.laoshi.json` 中向固定主阶段后挂载受控的 AI/skill 或脚本扩展步骤(注入 `LAOSHI_*` 环境变量,日志保留在 `.pipeline/extensions/`),并保持 Windows 下 `cmd.exe` 兼容。
14
+ - **多仓库联合开发增强**:支持配置 `maxJointRepos`(1–10),`/laoshi-setup` 自动发现同级 Git 仓库辅助配置,需求详情页直观展示各关联仓库分支、工作区路径与质量门状态。
15
+ - **预算预估与多模型评审检查**:开工前与看板详情提供历史同档位耗时 / token 预算预估及超预算提醒;启用多模型评审小组但配置缺失或仅单个提供方时由 `laoshi doctor` 提前告警。
16
+ - **Paseo `0.11–0.17` 实机适配与插件体验**:支持 `laoshi install --platform paseo --with-plugin` 一步部署并加载 Paseo 插件,插件与 Web 看板共享状态分组与文案,修复 Paseo 0.17 下服务端打包运行时缺少 `import.meta.url` 导致的插件 RPC 报错。
17
+ - **dsh `0.2.2-rc.5` 适配与定时能力补齐**:插件实现 `schedule` 的 `expiresAt` 到期自动取消及 `scheduleNewAgent` 独立定时会话;双版本兼容 `dsh 0.2.2-alpha.2` 与 `0.2.2-rc.5` 的 `startActivation`、`subagents.interrupt`、`schedule.create`/`edit`(含 `cron.time_zone`)与 `sessions.events`。
18
+ - **摸高与通知体验打磨**:摸高超长追问/打断消息写入文件兜底,同主机中断轮次自动续接;全部停顿通知统一附上【停下原因】与【下一步请说】提示;新增《Paseo Web 与 dsh 真实环境插件走查清单》及版本范围守护。
19
+
20
+ ### 升级须知
21
+
22
+ - **Paseo**:运行 `laoshi upgrade` 升级到 `0.3.0`(支持 Paseo `0.11–0.17`;安装过插件时自动同步刷新并重载)。如果使用了非默认 `--home`,请在守护进程中设置 `LAOSHI_HOME` 或在 Paseo「设置 → 插件 → `laoshi 需求`」填写安装根路径。
23
+ - **DeepSeek Harness(dsh)**:运行 `laoshi upgrade` 升级到 `0.3.0`,同步更新 `laoshi-dsh-plugin`(同时兼容 `0.2.2-alpha.2` 与 `0.2.2-rc.5+`),并默认随宿主开启托管看板(可通过 `--no-board` 关闭)。
24
+ - **摸高**:替换为本版本 Release 附带的 `laoshi-expert-0.3.0.zip`(或运行 `node adapters/mogao/make-expert.mjs` 重新生成)。
25
+
26
+ ## 0.2.0 - 2026-11-21
27
+
28
+ 正式版(npm `latest` 标签):汇总 0.2.0-beta.1~beta.3 的全部功能(摸高适配器与专家包、Paseo 需求插件迁入、`laoshi migrate`、`laoshi permission`),并补充摸高版本自检、进程组清理、上下文控制、`laoshi diagnose` 脱敏诊断包与 Release 自动附带摸高专家包。安装:`npx -y @yiyi_zhang/laoshi@latest install --platform <平台>`。
29
+
30
+ ### 使用者会看到的变化
31
+
32
+ - **诊断包(`laoshi diagnose <需求> [--out <目录>]`)**:一键导出已脱敏的排查目录(状态、流水线日志尾部、步骤结果、步骤输出与回调事件、脱敏配置与环境摘要),方便压缩后发给维护者定位问题。
33
+ - **摸高:启动后不再"去后台、有进展通知你"**:摸高上流水线在对话的命令里运行,对话一结束就停止。入口 skill 里启动后的说明改为摸高自己的一节(命令不会马上返回、不要结束这一轮对话、持续查看输出并转述);命令输出也不再写"已在后台启动""进展会发回对话",安静超过 3 分钟时再提醒一次"流水线仍在运行"。
34
+ - **摸高:结束一次运行时连它启动的进程一起结束**:每次 `aimax run` 单独成一个进程组,结束时整组结束,步骤里留下的服务、构建守护进程不再残留;收到 `done` 回调后留 2 秒等待完整输出,避免抢跑拿到不完整回复与用量。
35
+ - **步骤控制读入的内容量**:步骤提示词要求命令输出先过滤再看、不整包解压或列出依赖包、读源码先搜索定位(有的模型实际上下文只有十万 token 左右);因上下文占满失败重做时,告诉新的 agent 换做法,从已写下的产物接着做。方案写明依赖相关结论的依据(命令和关键输出),方案审核照着重跑核实、每个结论只核实一次、`javap` 不看常量池和字节码。
36
+ - **摸高:专家要求的版本由命令自己保证**:专家里每条 laoshi 命令都带上它要求的版本(`LAOSHI_WANT_VERSION`),工作区装的不是这个版本时,命令先从 npm 镜像装上再执行;安装失败时不会在子脚本里重复尝试,更新平台设置失败时给出明确警告。
37
+ - **发布产物附带摸高专家包**:GitHub Release 除 `.tgz` 与 Windows 离线包外,同时附带该版本生成的 `laoshi-expert-0.2.0.zip`。
38
+
39
+ ### 升级须知
40
+
41
+ - **摸高**:直接替换为本版本 Release 附带的 `laoshi-expert-0.2.0.zip`(或运行 `node adapters/mogao/make-expert.mjs` 生成),不要手工修改旧专家包里的版本号。
42
+ - **Paseo / dsh**:运行 `laoshi upgrade` 即可升级到 `0.2.0`(Paseo 需求插件会顺带更新)。
43
+
5
44
  ## 0.2.0-beta.3 - 2026-11-11
6
45
 
7
46
  预发布版(npm 的 `beta` 标签,`latest` 仍是 0.1.1):摸高的回调按平台文档的格式解析,步骤做完后靠 `done` 及时进入下一步,工具调用和用量能收到。安装:`npx -y @yiyi_zhang/laoshi@beta install --platform <平台>`。
package/README.md CHANGED
@@ -4,14 +4,15 @@
4
4
 
5
5
  laoshi 是从 [paseo-req-kit](https://github.com/yiyisf/paseo-req-kit)(req-kit)中抽取出来的、与 agent 平台无关的需求开发体系:用对话对齐需求,由一组分工明确的 agent 完成方案设计、实现、评审和验证,每一步都有产出文件和验收门,流程由程序保证,而不是由 AI 或人即兴发挥。
6
6
 
7
- > **状态:准备发布 0.1.0。** 支持 Paseo 和 DeepSeek Harness(dsh)。核心从 req-kit 1.15.0 抽取,平台相关的部分都在 `adapters/` 下(见[移植记录](docs/porting-log.md)、[实施计划](docs/extraction/plan.md))。Paseo 的需求插件界面暂时仍由 paseo-req-kit 提供。
7
+ > 支持 **Paseo(`0.11–0.17`,优先 Web 端,内置 Paseo 需求插件)**、**DeepSeek Harness(`dsh 0.2.x`,内置 `laoshi-dsh-plugin` 与托管 Web 看板)**、**命令行 agent(`cli`)**与**摸高(`mogao`)**;全平台共用本地 Web 需求看板(`laoshi board`)。核心从 req-kit 抽取并持续演进(见[移植记录](docs/porting-log.md)、[架构文档](docs/design/architecture.md))。
8
8
 
9
9
  ## 安装
10
10
 
11
11
  与 paseo-req-kit 一样从 npm 分发,一步安装:
12
12
 
13
13
  ```bash
14
- npx -y @yiyi_zhang/laoshi@latest install --platform dsh # 或 --platform paseo
14
+ npx -y @yiyi_zhang/laoshi@latest install --platform dsh # dsh(默认开启托管看板)
15
+ npx -y @yiyi_zhang/laoshi@latest install --platform paseo --with-plugin # Paseo(同时安装需求插件)
15
16
  # 公司内网只有 npm 镜像时:
16
17
  npx -y --registry=https://npm.example.internal/ @yiyi_zhang/laoshi@latest install --platform dsh
17
18
  laoshi doctor --no-project
@@ -4,7 +4,9 @@
4
4
 
5
5
  import fs from "node:fs";
6
6
  import type { AgentProfile } from "../../engine/src/config.js";
7
+ import { kitVersion } from "../../engine/src/locations.js";
7
8
  import type { PlatformAdapter } from "../../engine/src/platform.js";
9
+ import { extractSemver, satisfies, supportedPlatformRange } from "../../engine/src/semver.js";
8
10
  import type { DshModels } from "./dsh-runtime.js";
9
11
  import { channelPaths, dshHome } from "./plugin/channel.mjs";
10
12
 
@@ -16,6 +18,7 @@ export const dshAdapter: PlatformAdapter = {
16
18
  services: "builtin",
17
19
  worktree: "builtin",
18
20
  scheduling: "plugin",
21
+ scheduleAgent: "plugin",
19
22
  sessionAgent: "plugin",
20
23
  activity: "plugin",
21
24
  runningTool: "plugin",
@@ -46,8 +49,26 @@ export const dshAdapter: PlatformAdapter = {
46
49
  const paths = channelPaths(dshHome(env));
47
50
  try {
48
51
  const call = pluginClient(env, 10_000);
49
- const hello = await call<{ plugin: string; approvals: string }>("hello");
52
+ const hello = await call<{ plugin: string; approvals: string; dshVersion?: string | null }>("hello");
50
53
  tools.report("ok", `已连接 laoshi 的 dsh 插件 ${hello.plugin}(${paths.socket}),审批策略:${hello.approvals}`);
54
+ const expectedPlugin = kitVersion();
55
+ if (hello.plugin && hello.plugin !== expectedPlugin) {
56
+ tools.report("warn", `dsh 插件版本(${hello.plugin})与当前 laoshi(${expectedPlugin})不一致`, "运行 `laoshi install --platform dsh` 更新插件并重启 dsh");
57
+ }
58
+ const dshRange = supportedPlatformRange("dsh");
59
+ const dshVer = hello.dshVersion ? extractSemver(hello.dshVersion) : null;
60
+ if (dshRange && dshVer) {
61
+ if (satisfies(dshVer, dshRange)) tools.report("ok", `dsh 版本 ${dshVer} 在支持范围内(${dshRange})`);
62
+ else tools.report("warn", `dsh 版本 ${dshVer} 不在已验证的支持范围(${dshRange})内`, "dsh 处于快速迭代期,如接口行为异常请检查适配更新");
63
+ }
64
+ const board = await call<{ enabled: boolean; running: boolean; url: string | null; error: string | null }>("board").catch(() => null);
65
+ if (board?.running && board.url) {
66
+ tools.report("ok", `需求看板运行中:${board.url}`);
67
+ } else if (board?.enabled) {
68
+ tools.report("warn", `需求看板已启用但未运行${board.error ? `(${board.error})` : ""}`, "重启 dsh,或直接运行 laoshi board 打开本机看板");
69
+ } else if (board) {
70
+ tools.info("dsh 插件未开启托管需求看板;可随时运行 laoshi board 打开,或在 cordis.patch.yml 中设置 board: true");
71
+ }
51
72
  const listed = await call<DshModels>("models").catch(() => null);
52
73
  if (!listed) {
53
74
  tools.report("warn", "插件没有列出 dsh 的模型(插件版本较旧?)", "重新运行安装脚本,更新 laoshi 的 dsh 插件后重启 dsh");
@@ -4,7 +4,7 @@
4
4
  //
5
5
  // Worktrees and services are laoshi's builtin ones (engine/src/builtin, laoshi M2b): the methods
6
6
  // below are placeholders the runtime layer replaces. Each role can run on its own dsh model
7
- // (stepModel). Not yet: provider quota, platform agent profiles, recurring schedules' expiry.
7
+ // (stepModel). Not yet: provider quota, platform agent profiles, event-stream wait, browser capabilities.
8
8
  import fs from "node:fs";
9
9
  import net from "node:net";
10
10
  import type { RunningTool } from "../../engine/src/scan-guard.js";
@@ -205,17 +205,28 @@ export function createRuntimeWithClient(call: PluginCall, log: (message: string)
205
205
  },
206
206
 
207
207
  async scheduleMessage(input) {
208
- if (input.expiresAt) log("dsh 的定时任务不能设截止时间:这条定时消息会一直有效,直到被取消");
209
208
  const { id } = await call<{ id: string }>("schedule", {
210
209
  sessionId: input.agentId,
211
210
  title: input.name,
212
211
  prompt: input.prompt,
213
212
  ...(input.cron ? { cron: input.cron, timeZone: localTimeZone() } : { at: input.at?.toISOString() }),
213
+ ...(input.expiresAt ? { expiresAt: input.expiresAt.toISOString() } : {}),
214
214
  });
215
215
  return scheduleId(input.agentId, id);
216
216
  },
217
217
 
218
- scheduleNewAgent: async () => null,
218
+ async scheduleNewAgent(input) {
219
+ // dsh sessions.create takes { cwd } and uses dsh's default session model.
220
+ if (stepModel(input.profile)) log("dsh 的定时会话使用 dsh 默认模型");
221
+ const r = await call<{ id: string; sessionId: string }>("scheduleAgent", {
222
+ cwd: input.cwd,
223
+ title: input.name,
224
+ prompt: input.prompt,
225
+ cron: input.cron,
226
+ timeZone: localTimeZone(),
227
+ });
228
+ return scheduleId(r.sessionId, r.id);
229
+ },
219
230
 
220
231
  async cancelSchedule(id) {
221
232
  const parsed = parseScheduleId(id);
@@ -14,6 +14,8 @@ export const options = {
14
14
  profile: { type: "string" },
15
15
  "dsh-bin": { type: "string" },
16
16
  approvals: { type: "string" },
17
+ "no-board": { type: "boolean" },
18
+ "board-port": { type: "string" },
17
19
  };
18
20
 
19
21
  const slash = (p) => p.split(path.sep).join("/");
@@ -70,16 +72,26 @@ export function setup({ kit, args, config, env = process.env, dry, report }) {
70
72
  const patchFile = path.join(profileDir, "cordis.patch.yml");
71
73
  // dsh writes the file with an empty flow list ("[]"); entries go into a block list instead.
72
74
  const current = (fs.existsSync(patchFile) ? fs.readFileSync(patchFile, "utf8") : "").replace(/^\s*\[\]\s*$/m, "");
73
- if (current.includes("laoshi-dsh-plugin")) report("ok", `${patchFile} 中已挂载插件,不改动(审批策略以文件中的为准)`);
75
+ if (current.includes("laoshi-dsh-plugin")) report("ok", `${patchFile} 中已挂载插件,不改动(审批与看板配置以文件中的为准)`);
74
76
  else {
77
+ const enableBoard = !args["no-board"];
78
+ const boardPort = args["board-port"] ? Number(args["board-port"]) || 0 : 0;
75
79
  if (!dry) {
76
80
  fs.mkdirSync(profileDir, { recursive: true });
77
- const block = `- insert:\n - id: laoshi-dsh\n name: 'laoshi-dsh-plugin'\n config:\n approvals: ${approvals}\n`;
81
+ const extraLines = [
82
+ ` kitRoot: '${slash(kit)}'`,
83
+ ` board: ${enableBoard}`,
84
+ ...(boardPort > 0 ? [` boardPort: ${boardPort}`] : []),
85
+ ];
86
+ const block = `- insert:\n - id: laoshi-dsh\n name: 'laoshi-dsh-plugin'\n config:\n approvals: ${approvals}\n${extraLines.join("\n")}\n`;
78
87
  fs.writeFileSync(patchFile, `${current}${current && !current.endsWith("\n") ? "\n" : ""}${block}`);
79
88
  }
80
- report("ok", `在 ${patchFile} 末尾挂载插件(审批策略 ${approvals})`);
89
+ report("ok", `在 ${patchFile} 末尾挂载插件(审批策略 ${approvals},需求看板${enableBoard ? "已启用" : "已关闭"})`);
81
90
  }
82
- return [`重启 dsh(profile ${profile}),让插件生效`];
91
+ return [
92
+ `重启 dsh(profile ${profile}),让插件与需求看板生效`,
93
+ "运行 laoshi doctor 可查看需求看板地址;也可随时运行 laoshi board 打开",
94
+ ];
83
95
  }
84
96
 
85
97
  /** Removes laoshi's dsh plugin and its mount. */
@@ -5,6 +5,7 @@
5
5
  // as a child of the chat, schedule a message into the chat, answer a step's approval request by
6
6
  // policy; and it relays the rest (prompt, cancel, status, history) to dsh's session controller.
7
7
  // It holds no pipeline logic: order, rounds and gates stay in the engine.
8
+ import { spawn, spawnSync } from "node:child_process";
8
9
  import crypto from "node:crypto";
9
10
  import fs from "node:fs";
10
11
  import net from "node:net";
@@ -14,7 +15,7 @@ import { channelPaths, dshHome } from "./channel.mjs";
14
15
  export const name = "laoshi-dsh";
15
16
  export const inject = ["agents", "subagents", "schedule", "approval", "sessionController", "llm"];
16
17
 
17
- const VERSION = "0.2.0-beta.3";
18
+ const VERSION = "0.3.0";
18
19
  const SHELL_TOOLS = new Set(["bash", "pwsh"]);
19
20
  const SEARCH_TOOLS = new Set(["grep", "glob"]);
20
21
 
@@ -83,8 +84,12 @@ export function apply(ctx, config = {}) {
83
84
  return items.find((i) => i.sessionId === sessionId) ?? null;
84
85
  }
85
86
 
87
+ const modernSubagents = typeof ctx.subagents.interrupt === "function" || typeof ctx.subagents.interruptByUser === "function";
88
+ const modernSchedule = typeof ctx.schedule.edit === "function" && typeof ctx.schedule.delete !== "function";
89
+
86
90
  async function events(sessionId) {
87
- const page = await sessions.page({ address: address(sessionId), maxMessages: 1000 }, timeout());
91
+ const req = { address: address(sessionId), maxMessages: 1000 };
92
+ const page = sessions.events ? await sessions.events(req, timeout()) : await sessions.page(req, timeout());
88
93
  return page.records.filter((r) => r.type === "event").map((r) => r.event);
89
94
  }
90
95
 
@@ -93,7 +98,13 @@ export function apply(ctx, config = {}) {
93
98
  const requestId = `laoshi-${crypto.randomUUID()}`;
94
99
  if (sessionId in children) {
95
100
  await ctx.subagents.prompt(
96
- { requestId, parentSessionId: children[sessionId], childSessionId: sessionId, mode: "continuable", delivery: mode, content },
101
+ {
102
+ requestId,
103
+ ...(modernSubagents ? {} : { parentSessionId: children[sessionId], mode: "continuable" }),
104
+ childSessionId: sessionId,
105
+ delivery: mode,
106
+ content,
107
+ },
97
108
  timeout(),
98
109
  );
99
110
  } else {
@@ -101,6 +112,29 @@ export function apply(ctx, config = {}) {
101
112
  }
102
113
  }
103
114
 
115
+ async function createScheduleTask({ sessionId, title, prompt: text, at, cron, timeZone }) {
116
+ if (!modernSchedule) {
117
+ const timing = cron ? { cron: { expression: cron, time_zone: timeZone } } : { at };
118
+ return ctx.schedule.create(sessionId, { title, prompt: text, ...timing });
119
+ }
120
+ const resolvedTz = typeof timeZone === "string" && timeZone.trim() ? timeZone.trim() : Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
121
+ const timing = cron ? { kind: "cron", cron: { expression: cron, time_zone: resolvedTz } } : { kind: "at", at };
122
+ return ctx.schedule.create(
123
+ {
124
+ title: typeof title === "string" && title.trim() ? title.trim() : "laoshi",
125
+ prompt: text,
126
+ timing,
127
+ target: { kind: "session", sessionId },
128
+ },
129
+ sessionId,
130
+ );
131
+ }
132
+
133
+ async function deleteScheduleTask({ sessionId, id }) {
134
+ if (modernSchedule) return ctx.schedule.edit({ id, action: "delete" }, undefined);
135
+ return ctx.schedule.delete({ sessionId, id });
136
+ }
137
+
104
138
  async function liveAgent(sessionId) {
105
139
  const live = ctx.agents.get(sessionId);
106
140
  if (live) return live;
@@ -109,7 +143,11 @@ export function apply(ctx, config = {}) {
109
143
  }
110
144
 
111
145
  const methods = {
112
- hello: async () => ({ plugin: VERSION, approvals }),
146
+ hello: async () => ({
147
+ plugin: VERSION,
148
+ approvals,
149
+ ...(process.env.DSH_VERSION?.trim() ? { dshVersion: process.env.DSH_VERSION.trim() } : {}),
150
+ }),
113
151
 
114
152
  /** The chat (or any session): does it exist, where does it work. */
115
153
  session: async ({ sessionId }) => {
@@ -123,13 +161,26 @@ export function apply(ctx, config = {}) {
123
161
  const provider = config.subagentProvider ?? "spawn";
124
162
  // The step's own model (the role's provider/model in laoshi's config); without it, the chat's.
125
163
  const agentOptions = model?.provider && model?.model ? { provider: model.provider, model: model.model, ...(model.reasoningEffort ? { reasoningEffort: model.reasoningEffort } : {}) } : null;
126
- const activation = await ctx.subagents.startActivation({
127
- provider,
128
- label,
129
- request: { prompt: [{ type: "text", text }], parent: parentAgent, cwd, ...(agentOptions ? { agentOptions } : {}) },
130
- signal: new AbortController().signal,
131
- delivery: "caller",
132
- });
164
+ const content = [{ type: "text", text }];
165
+ const spec = modernSubagents
166
+ ? {
167
+ provider,
168
+ label,
169
+ parent: parentAgent,
170
+ prompt: content,
171
+ cwd,
172
+ ...(agentOptions ? { agentOptions } : {}),
173
+ signal: new AbortController().signal,
174
+ delivery: "caller",
175
+ }
176
+ : {
177
+ provider,
178
+ label,
179
+ request: { prompt: content, parent: parentAgent, cwd, ...(agentOptions ? { agentOptions } : {}) },
180
+ signal: new AbortController().signal,
181
+ delivery: "caller",
182
+ };
183
+ const activation = await ctx.subagents.startActivation(spec);
133
184
  const childId = activation.childId;
134
185
  children[childId] = parent;
135
186
  saveChildren();
@@ -213,8 +264,13 @@ export function apply(ctx, config = {}) {
213
264
 
214
265
  /** Stop the session's current turn, then give it text. */
215
266
  interrupt: async ({ sessionId, text }) => {
216
- if (sessionId in children) ctx.subagents.interruptByParent(sessionId, children[sessionId], "continuable");
217
- else sessions.cancel({ sessionId });
267
+ if (sessionId in children) {
268
+ if (typeof ctx.subagents.interrupt === "function") ctx.subagents.interrupt(sessionId, { kind: "user" });
269
+ else if (typeof ctx.subagents.interruptByUser === "function") ctx.subagents.interruptByUser(sessionId);
270
+ else ctx.subagents.interruptByParent(sessionId, children[sessionId], "continuable");
271
+ } else {
272
+ sessions.cancel({ sessionId });
273
+ }
218
274
  if (text) await prompt(sessionId, text, "queue");
219
275
  return {};
220
276
  },
@@ -227,19 +283,128 @@ export function apply(ctx, config = {}) {
227
283
  },
228
284
 
229
285
  /** A message into the session at a time (`at`, ISO) or on a five-field cron in a time zone. */
230
- schedule: async ({ sessionId, title, prompt: text, at, cron, timeZone }) => {
231
- const timing = cron ? { cron: { expression: cron, time_zone: timeZone } } : { at };
232
- const record = await ctx.schedule.create(sessionId, { title, prompt: text, ...timing });
233
- log({ schedule: record.id, sessionId, title });
286
+ schedule: async ({ sessionId, title, prompt: text, at, cron, timeZone, expiresAt }) => {
287
+ const record = await createScheduleTask({ sessionId, title, prompt: text, at, cron, timeZone });
288
+ if (typeof expiresAt === "string" && expiresAt.trim()) {
289
+ const ms = Date.parse(expiresAt) - Date.now();
290
+ if (Number.isFinite(ms)) {
291
+ const key = `${sessionId}/${record.id}`;
292
+ const delay = Math.min(2_147_483_647, Math.max(0, ms));
293
+ const timer = setTimeout(() => {
294
+ scheduleTimers.delete(key);
295
+ deleteScheduleTask({ sessionId, id: record.id }).catch(() => {});
296
+ log({ scheduleExpired: record.id, sessionId });
297
+ }, delay);
298
+ timer.unref?.();
299
+ scheduleTimers.set(key, timer);
300
+ }
301
+ }
302
+ log({ schedule: record.id, sessionId, title, ...(expiresAt ? { expiresAt } : {}) });
234
303
  return { id: record.id };
235
304
  },
236
305
 
306
+ /** A cron schedule that creates a dedicated session in cwd and schedules into it. */
307
+ scheduleAgent: async ({ cwd, title, prompt: text, cron, timeZone }) => {
308
+ if (typeof cwd !== "string" || !cwd.trim()) throw new Error("scheduleAgent: cwd is required");
309
+ if (typeof text !== "string" || !text.trim()) throw new Error("scheduleAgent: prompt is required");
310
+ if (typeof cron !== "string" || !cron.trim()) throw new Error("scheduleAgent: cron is required");
311
+ const { sessionId } = await sessions.create({ cwd });
312
+ const record = await createScheduleTask({
313
+ sessionId,
314
+ title: typeof title === "string" && title.trim() ? title.trim() : "laoshi",
315
+ prompt: text,
316
+ cron,
317
+ timeZone,
318
+ });
319
+ log({ scheduleAgent: record.id, sessionId, title, cron });
320
+ return { id: record.id, sessionId };
321
+ },
322
+
237
323
  cancelSchedule: async ({ sessionId, id }) => {
238
- await ctx.schedule.delete({ sessionId, id });
324
+ const key = `${sessionId}/${id}`;
325
+ const timer = scheduleTimers.get(key);
326
+ if (timer) {
327
+ clearTimeout(timer);
328
+ scheduleTimers.delete(key);
329
+ }
330
+ await deleteScheduleTask({ sessionId, id });
239
331
  return {};
240
332
  },
333
+
334
+ /** Status (and optional on-demand start) of the hosted requirement board web UI. */
335
+ board: async ({ start = false } = {}) => {
336
+ if (start && !boardState.running) await startBoard();
337
+ return { enabled: boardEnabled, running: boardState.running, url: boardState.url, error: boardState.error };
338
+ },
241
339
  };
242
340
 
341
+ const scheduleTimers = new Map();
342
+
343
+ // ---- optional hosted Web requirement board (`laoshi board --no-open`)
344
+ const boardEnabled = Boolean(config.board);
345
+ const boardPort = Number(config.boardPort ?? 0) || 0;
346
+ const boardReadOnly = Boolean(config.boardReadOnly);
347
+ const kitRoot = typeof config.kitRoot === "string" && config.kitRoot.trim() ? path.resolve(config.kitRoot.trim()) : null;
348
+ const boardState = { running: false, url: null, error: null };
349
+ let boardChild = null;
350
+ let boardStartPromise = null;
351
+
352
+ function startBoard() {
353
+ if (boardStartPromise) return boardStartPromise;
354
+ const reqBin = kitRoot ? path.join(kitRoot, "bin", "req.mjs") : null;
355
+ if (!reqBin || !fs.existsSync(reqBin)) {
356
+ boardState.error = "未配置有效的 kitRoot,请重新运行 laoshi install --platform dsh";
357
+ return Promise.resolve(boardState);
358
+ }
359
+ boardStartPromise = new Promise((resolve) => {
360
+ const args = [reqBin, "board", "--no-open", "--port", String(boardPort), ...(boardReadOnly ? ["--read-only"] : [])];
361
+ const child = spawn(process.execPath, args, { stdio: ["ignore", "pipe", "pipe"], windowsHide: true, detached: process.platform !== "win32" });
362
+ boardChild = child;
363
+ boardState.error = null;
364
+ let settled = false;
365
+ const finish = () => {
366
+ if (settled) return;
367
+ settled = true;
368
+ resolve(boardState);
369
+ };
370
+ const timer = setTimeout(finish, 8_000);
371
+ child.stdout.setEncoding("utf8");
372
+ child.stdout.on("data", (chunk) => {
373
+ const m = /(http:\/\/127\.0\.0\.1:\d+\/)/.exec(chunk);
374
+ if (m) {
375
+ boardState.running = true;
376
+ boardState.url = m[1];
377
+ log({ board: m[1] });
378
+ clearTimeout(timer);
379
+ finish();
380
+ }
381
+ });
382
+ child.stderr.setEncoding("utf8");
383
+ child.stderr.on("data", (chunk) => {
384
+ if (!boardState.running && chunk.trim()) boardState.error = chunk.trim().slice(0, 300);
385
+ });
386
+ child.on("exit", (code) => {
387
+ if (boardChild === child) {
388
+ boardChild = null;
389
+ boardStartPromise = null;
390
+ boardState.running = false;
391
+ boardState.url = null;
392
+ if (!settled && code !== 0) boardState.error = boardState.error || `看板进程退出(${code})`;
393
+ }
394
+ clearTimeout(timer);
395
+ finish();
396
+ });
397
+ child.on("error", (err) => {
398
+ boardState.error = String(err?.message ?? err);
399
+ clearTimeout(timer);
400
+ finish();
401
+ });
402
+ });
403
+ return boardStartPromise;
404
+ }
405
+
406
+ if (boardEnabled) startBoard().catch(() => {});
407
+
243
408
  // ---- the local socket
244
409
  const token = crypto.randomBytes(32).toString("hex");
245
410
  const tokenOk = (given) => typeof given === "string" && given.length === token.length && crypto.timingSafeEqual(Buffer.from(given), Buffer.from(token));
@@ -285,6 +450,20 @@ export function apply(ctx, config = {}) {
285
450
  server.on("error", (e) => log({ serverError: String(e?.message ?? e) }));
286
451
 
287
452
  ctx.on("dispose", () => {
453
+ for (const timer of scheduleTimers.values()) clearTimeout(timer);
454
+ scheduleTimers.clear();
455
+ if (boardChild?.pid) {
456
+ const pid = boardChild.pid;
457
+ boardChild = null;
458
+ try {
459
+ if (process.platform === "win32") spawnSync("taskkill", ["/T", "/F", "/PID", String(pid)], { stdio: "ignore", windowsHide: true });
460
+ else process.kill(-pid, "SIGTERM");
461
+ } catch {
462
+ try {
463
+ process.kill(pid, "SIGTERM");
464
+ } catch {}
465
+ }
466
+ }
288
467
  server.close();
289
468
  fs.rmSync(paths.token, { force: true });
290
469
  if (process.platform !== "win32") fs.rmSync(paths.socket, { force: true });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laoshi-dsh-plugin",
3
- "version": "0.2.0-beta.3",
3
+ "version": "0.3.0",
4
4
  "private": true,
5
5
  "description": "laoshi's plugin for the DeepSeek Harness host: creates step agents under the chat, schedules messages, answers approvals by policy, and serves the laoshi engine over a local socket (ADR 0008).",
6
6
  "type": "module",
@@ -7,6 +7,7 @@ import { spawnSync } from "node:child_process";
7
7
  import path from "node:path";
8
8
  import { fileURLToPath } from "node:url";
9
9
  import type { PlatformAdapter } from "../../engine/src/platform.js";
10
+ import { extractSemver, satisfies, supportedPlatformRange } from "../../engine/src/semver.js";
10
11
  import { mogaoSettings } from "./mogao-runtime.js";
11
12
 
12
13
  export const mogaoAdapter: PlatformAdapter = {
@@ -23,6 +24,7 @@ export const mogaoAdapter: PlatformAdapter = {
23
24
  originEnv: { id: "AIMAX_SESSION_ID" },
24
25
  userEnv: "AIMAX_USER_NAME",
25
26
  runsInChat: true,
27
+ pinVersion: true,
26
28
  skillSetup: path.join(path.dirname(fileURLToPath(import.meta.url)), "skill", "setup.md"),
27
29
  words: {
28
30
  name: "摸高",
@@ -41,7 +43,14 @@ export const mogaoAdapter: PlatformAdapter = {
41
43
  tools.report("fail", `运行 ${settings.command} --version 失败:${r.error?.message ?? (r.stderr || r.stdout).trim()}`, "在摸高的对话或沙箱里运行;不在 PATH 中时在安装级配置的 platform.mogao.command 写上它的完整路径");
42
44
  return;
43
45
  }
44
- tools.report("ok", `aimax ${(r.stdout || "").trim()}(数据目录 ${settings.dataDir},单次运行上限 ${settings.runTimeoutMinutes} 分钟)`);
46
+ const rawVersion = (r.stdout || "").trim();
47
+ const ver = extractSemver(rawVersion);
48
+ const range = supportedPlatformRange("mogao");
49
+ if (ver && range && !satisfies(ver, range)) {
50
+ tools.report("warn", `aimax ${rawVersion} 不在已验证的支持范围(${range})内(数据目录 ${settings.dataDir})`, "如回调或输出格式有变,请检查摸高适配器更新");
51
+ } else {
52
+ tools.report("ok", `aimax ${rawVersion}${range ? `(支持范围 ${range})` : ""}(数据目录 ${settings.dataDir},单次运行上限 ${settings.runTimeoutMinutes} 分钟)`);
53
+ }
45
54
  if (!process.env.AIMAX_SESSION_ID) tools.info("没有 AIMAX_SESSION_ID:不在摸高的对话里运行,进展只写入日志");
46
55
  },
47
56
  };