@suifei/dsh-ai-team 0.0.0-stage → 0.3.3

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 (84) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/LICENSE +21 -0
  3. package/README.md +38 -2
  4. package/client.js +2901 -0
  5. package/cordis.patch.yml +31 -0
  6. package/icon.svg +27 -0
  7. package/index.js +893 -0
  8. package/lib/domain/errors.js +36 -0
  9. package/lib/domain/ids.js +26 -0
  10. package/lib/domain/inbox.js +87 -0
  11. package/lib/domain/member-config.js +168 -0
  12. package/lib/domain/member-profile.js +53 -0
  13. package/lib/domain/policy.js +102 -0
  14. package/lib/domain/task.js +309 -0
  15. package/lib/domain/thread.js +54 -0
  16. package/lib/host/fault-adapter.js +50 -0
  17. package/lib/host/member-tools.js +225 -0
  18. package/lib/host/permission-guard.js +28 -0
  19. package/lib/host/project-registry.js +68 -0
  20. package/lib/host/project-runtime.js +73 -0
  21. package/lib/host/service.js +810 -0
  22. package/lib/host/views.js +213 -0
  23. package/lib/host/waker.js +177 -0
  24. package/lib/ledger/checkpoint.js +395 -0
  25. package/lib/ledger/events.js +398 -0
  26. package/lib/ledger/fold.js +991 -0
  27. package/lib/ledger/writer.js +983 -0
  28. package/lib/runtime/failure-policy.js +113 -0
  29. package/lib/runtime/host-agent.js +101 -0
  30. package/lib/runtime/member-runtime.js +286 -0
  31. package/lib/runtime/skill-catalog.js +27 -0
  32. package/lib/runtime/skill-loader.js +26 -0
  33. package/lib/runtime/skill-provider.js +121 -0
  34. package/lib/vendor/skillopt/LICENSE +21 -0
  35. package/lib/vendor/skillopt/requirements.txt +31 -0
  36. package/lib/vendor/skillopt/scripts/sleep.py +119 -0
  37. package/lib/vendor/skillopt/skillopt_sleep/__init__.py +20 -0
  38. package/lib/vendor/skillopt/skillopt_sleep/__main__.py +942 -0
  39. package/lib/vendor/skillopt/skillopt_sleep/adapters/__init__.py +1 -0
  40. package/lib/vendor/skillopt/skillopt_sleep/adapters/superpowers.py +1379 -0
  41. package/lib/vendor/skillopt/skillopt_sleep/backend.py +2844 -0
  42. package/lib/vendor/skillopt/skillopt_sleep/budget.py +75 -0
  43. package/lib/vendor/skillopt/skillopt_sleep/config.py +257 -0
  44. package/lib/vendor/skillopt/skillopt_sleep/consolidate.py +558 -0
  45. package/lib/vendor/skillopt/skillopt_sleep/cycle.py +1270 -0
  46. package/lib/vendor/skillopt/skillopt_sleep/dream.py +173 -0
  47. package/lib/vendor/skillopt/skillopt_sleep/evalkit.py +718 -0
  48. package/lib/vendor/skillopt/skillopt_sleep/evidence.py +143 -0
  49. package/lib/vendor/skillopt/skillopt_sleep/experiments/__init__.py +1 -0
  50. package/lib/vendor/skillopt/skillopt_sleep/experiments/gbrain_bench.py +119 -0
  51. package/lib/vendor/skillopt/skillopt_sleep/experiments/personas.py +86 -0
  52. package/lib/vendor/skillopt/skillopt_sleep/experiments/report.py +132 -0
  53. package/lib/vendor/skillopt/skillopt_sleep/experiments/run_experiment.py +178 -0
  54. package/lib/vendor/skillopt/skillopt_sleep/experiments/run_gbrain.py +209 -0
  55. package/lib/vendor/skillopt/skillopt_sleep/experiments/run_transfer.py +155 -0
  56. package/lib/vendor/skillopt/skillopt_sleep/experiments/sweep.py +164 -0
  57. package/lib/vendor/skillopt/skillopt_sleep/gate.py +50 -0
  58. package/lib/vendor/skillopt/skillopt_sleep/handoff_backend.py +173 -0
  59. package/lib/vendor/skillopt/skillopt_sleep/harvest.py +691 -0
  60. package/lib/vendor/skillopt/skillopt_sleep/harvest_codex.py +260 -0
  61. package/lib/vendor/skillopt/skillopt_sleep/harvest_copilot.py +443 -0
  62. package/lib/vendor/skillopt/skillopt_sleep/harvest_copilot_cli.py +244 -0
  63. package/lib/vendor/skillopt/skillopt_sleep/harvest_cursor.py +316 -0
  64. package/lib/vendor/skillopt/skillopt_sleep/harvest_opencode.py +364 -0
  65. package/lib/vendor/skillopt/skillopt_sleep/harvest_pi.py +311 -0
  66. package/lib/vendor/skillopt/skillopt_sleep/harvest_sources.py +135 -0
  67. package/lib/vendor/skillopt/skillopt_sleep/judges.py +344 -0
  68. package/lib/vendor/skillopt/skillopt_sleep/llm_miner.py +187 -0
  69. package/lib/vendor/skillopt/skillopt_sleep/memory.py +166 -0
  70. package/lib/vendor/skillopt/skillopt_sleep/mine.py +427 -0
  71. package/lib/vendor/skillopt/skillopt_sleep/multi_skill.py +190 -0
  72. package/lib/vendor/skillopt/skillopt_sleep/prompts.py +250 -0
  73. package/lib/vendor/skillopt/skillopt_sleep/replay.py +211 -0
  74. package/lib/vendor/skillopt/skillopt_sleep/rollout.py +184 -0
  75. package/lib/vendor/skillopt/skillopt_sleep/scheduler.py +286 -0
  76. package/lib/vendor/skillopt/skillopt_sleep/skill_resolver.py +244 -0
  77. package/lib/vendor/skillopt/skillopt_sleep/slow_update.py +141 -0
  78. package/lib/vendor/skillopt/skillopt_sleep/staging.py +3285 -0
  79. package/lib/vendor/skillopt/skillopt_sleep/state.py +283 -0
  80. package/lib/vendor/skillopt/skillopt_sleep/tasks_file.py +100 -0
  81. package/lib/vendor/skillopt/skillopt_sleep/types.py +227 -0
  82. package/lib/vendor/skillopt/src/index.js +394 -0
  83. package/package.json +62 -4
  84. package/skills/skillopt-sleep/SKILL.md +121 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,98 @@
1
+ # Changelog
2
+
3
+ ## 0.3.3 — 2026-11-09
4
+
5
+ - 产品显示名改为「文渊阁」(Wenyuan Pavilion),取藏修、校勘、纂辑之意;
6
+ - 保持包名 `@suifei/dsh-ai-team` 与内部 Team 域对象不变。
7
+
8
+ ## 0.3.2 — 2026-11-09
9
+
10
+ - 产品显示名改为「三省」(Three Departments),副标「三省六部」;
11
+ - 修复热加载时 permission 服务尚未就绪导致 `BOOT_FAILED / permission services are unavailable`,Host 显式 inject `permissionPresets` 与 `sandboxPolicy`;
12
+ - 四象限空 items / null taskNumber / 无 taskId 的决策项做健壮处理,避免点击异常与 `#null` 文案。
13
+
14
+ ## 0.3.1 — 2026-11-09
15
+
16
+ - SkillOpt 完全内置:7 个 `skillopt_*` 工具、Python engine bootstrap、`skillopt-sleep` 技能随插件分发,不再装到用户 DSH;
17
+ - 冷恢复重新 mount member preset,修复重启后 `pwsh/read/write` 工具消失;
18
+ - 失败决策自动带 taskId;跨 Project 收件箱可一键打开 Task;
19
+ - 双真实 provider SSE:DeepSeek 与 Zhipu 各自项目独立分桶;
20
+ - 测试 82 条。
21
+
22
+ ## 0.3.0 — 2026-11-09
23
+
24
+ - 并发 ProjectRuntime:启动打开全部 Project,各自 ledger/Waker/SSE/Team 工具路由;
25
+ - 跨 Project 收件箱:聚合、项目标记、按项目 ack、打开 Task 前切项目;
26
+ - V-10:新增真实 turn 中途降级 E2E 测试钩子(生产 403),守卫在工具调用前修复权限;
27
+ - billing/网络:测试专用 `ai-team-fault` LLM adapter,真实 Agent loop 验证 402 与 ECONNRESET 分类/恢复;
28
+ - 技能:新增 `ai-team-files` provider,发现 `~/.dsh/skills` 与项目技能;nuwa/distilly/darwin/SkillOpt 四个技能安装并由真实成员加载。
29
+
30
+ ## 0.2.6 — 2026-11-09
31
+
32
+ - 工具调用前权限守卫:managed member 若在 turn 中途被降级,下一步工具前先修复为 danger-full-access;修不好则拒绝;
33
+ - 非成员工具调用不受影响;
34
+ - V-10 从“仅激活时检查”前移到每次工具调用。
35
+
36
+ ## 0.2.5 — 2026-11-09
37
+
38
+ - 成员 config 新增 `preset`:`standard / ptc / minimal / cordis`,默认 `standard`;
39
+ - 资料抽屉可选择运行配方;
40
+ - 激活时 mount 对应 preset,未知配方被校验拒绝。
41
+
42
+ ## 0.2.4 — 2026-11-09
43
+
44
+ - 修复成员工具链:`agents.create` 的 setup 里 mount `standard` preset,成员获得 pwsh/read/write/edit/skill 等完整工具;
45
+ - 真实成员用 pwsh 写文件、用 skill 加载 DSH 技能并写结果;
46
+ - 健康检查暴露 `presets` 与 `skillsService`。
47
+
48
+ ## 0.2.3 — 2026-11-09
49
+
50
+ - 成员 activation/wake 注入 DSH `skills` 目录摘要(名称/描述/何时用,最多 12 条);
51
+ - 完整技能正文由成员自己的 `skill` 工具按需加载;
52
+ - 保留 `<dataDir>/skills/<name>/SKILL.md` 有界注入。
53
+
54
+ ## 0.2.2 — 2026-11-09
55
+
56
+ - 多 Project 单活动切换:每 Project 独立 ledger,`projects.json` 索引;
57
+ - Host `project.create` / `project.activate`;
58
+ - UI 新建项目弹窗 + 项目列表切换;
59
+ - 切换后重拉 bootstrap、重连 SSE,未完成 Task 由 `team/startup` 恢复;
60
+ - 已知限制:同一时刻只开一个 Project runtime,非活动项目不并发唤醒。
61
+
62
+ ## 0.2.1 — 2026-11-09
63
+
64
+ - QA checklist 硬门禁:`qaRequired` + `qaChecklist`,全部通过才能 accept。
65
+ - 启动恢复:`team/startup` 恢复未完成 Task,无定时器;真实重启 E2E 跑通。
66
+ - 抽出 `ProjectRuntime`(默认项目行为不变),为多 Project 做准备。
67
+ - 修复资料抽屉白屏(early-return 前引用 selectedTask / data null)。
68
+ - 真实浏览器验证 DM:`member.message` + wake,成员 session 前进。
69
+
70
+ ## 0.2.0 — 2026-11-09
71
+
72
+ M2.5「团队进化」迭代。
73
+
74
+ ### 新增
75
+
76
+ - 成员资料:name / role / personality / profileVersion;Human 可编辑,空个性按“不修改”处理。
77
+ - 自我进化:`team.evolve` 只允许 Agent 改自己的 personality;验收后 reflection wake 触发;真实跑通并写 `member/distilled`。
78
+ - 模型蒸馏:`member.distill(mode:'model')` 由 Host 单步调用 `llm.stream`,无工具、固定 JSON schema;真实跑通。
79
+ - 人才库:`member.leave` / `member.rejoin`,身份与 session 保留;`member.takeover` 接遗留 Task,保留 claim/takeover 历史。
80
+ - QA:`qaRequired` 硬门禁、`qaChecklist` 逐项通过、QA 优先自动 reviewer;真实 QA 自动验收。
81
+ - 备忘/技能:`team.note` / `team.skill` / `team.recall`;`<dataDir>/skills/<name>/SKILL.md` 有界加载进 prompt。
82
+ - 私信:`member.message` 只唤醒目标成员。
83
+ - 关注:`task.follow`;验收后给仍关注者生成 `followed_task_update`。
84
+ - 收件箱:真实 `data.inbox`、ack、打开 Task;失败恢复 UI(改配置 + retry)。
85
+ - 启动恢复:`team/startup` 恢复未完成 Task,无定时器;真实重启 E2E。
86
+ - 任务动作 UI:取消/重开/删除/改派;Thread 回复/验收/退回真实命令。
87
+ - 安装/卸载/升级文档与 profile 隔离检查。
88
+
89
+ ### 测试
90
+
91
+ - `node --test` 71/71。
92
+
93
+ ### 已知边界
94
+
95
+ - 单机、单 Human;多 Project 仍以默认 Project 为主。
96
+ - 技能文件只进 prompt,不是可执行工具注册。
97
+ - 外部失败注入仅覆盖真实 401;billing/网络注入仍待。
98
+ - 多 Project、V-10、真实卸载/升级演练未完成。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 suifei
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # 文渊阁 · @suifei/dsh-ai-team
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > 文渊阁:藏修、校勘、纂辑。AI Team mode for DeepSeek Harness:
4
+
5
+ AI Team mode for DeepSeek Harness: **projects, owned tasks, threads, inbox and an append-only team ledger** — one Human sentence, a team of named persistent agents keeps going, and only direction / trust / irreversible steps come back.
6
+
7
+ > M1/M2 status: the package mounts a **three-pane workbench** (left projects + agents, center `主对话 / 看板 / 态势`, right thread). The app ledger, task/thread/inbox domain and `TeamService` are implemented and covered by `node --test` (82 tests); `bootstrap`, `POST .../commands`, `GET .../board`, `GET .../quadrants` and the event-driven `GET .../events` SSE are wired to a real default-project ledger. The profile patch enforces `danger-full-access`, and the Host refuses to boot a weaker profile; `member.activate` now creates a real continuable child through the Team Host Agent, binds the session, sets/verifies `danger-full-access`, and records it in the ledger. Real activation and `member.config.update` were verified on the ai-team profile; the Host subscribes to `agent/request-error` for classification/retry/fallback (auth/billing fail closed) and to `session/event` for recovery/reset; the member row shows effective model/context/version/last failure. A member-only `team` tool exposes tasks/inbox/claim/submit/thread/reply/review through `TeamService`; the Waker delivers wake messages and records `wake/delivered`/`wake/failed`. The direct `agents.create + followup` path now completes a real two-Agent loop: 沈舟 claimed Task #1, replied in the Thread and submitted; 林岚 independently accepted it (`reviewerId=a2`, `selfExecuted=false`), leaving the task `done`. A follow-up probe wrote one Human sentence into the Main stream; Lead a1 created Task #1 itself, claimed/executed/submitted it, and a2 independently accepted it. The workbench Composer is wired to the real `stream.post` / `task.create` commands, and the Agents “+” opens an Add Member form that creates, configures, activates and optionally promotes the member to Project owner. A headless-Edge E2E opened 文渊阁, added 沈舟 as owner through the form, sent one sentence, and saw Task #1 appear on the board and in Q1. A second form submission added 林岚3 as reviewer with an explicit accept instruction; the board then showed `Done 2` / `To accept 0`. Host now broadcasts SSE on every ledger append, including member `team` tool calls. M2.5 adds versioned member profiles (name/role/personality), Agent self-evolution via `team.evolve`, a talent pool with leave/rejoin, leftover-task takeover, and QA-first automatic reviewer wake; a real QA member accepted a submitted Task with no manual reviewer instruction. The profile/talent-pool UI was verified in a real browser: saving a new name/personality bumped `profileVersion`, then leaving the team with a successor moved the member to the talent pool and transferred the leftover Task (`taken-over`) to the successor. Acceptance also schedules a reflection wake; a real Agent then called `team.evolve` itself and wrote `member/distilled`, with the new personality visible on the member. Members can add durable notes/skills (`team.note`/`team.skill`); skill bodies are read from `<dataDir>/skills/<name>/SKILL.md` (bounded, traversal-safe) and injected into activation/wake prompts. Activation/wake also injects a bounded DSH `skills` catalog (name/description/when-to-use, max 12) so members can load a full skill through their own `skill` tool. Members now mount an agent preset in `agents.create` setup; a real member used `pwsh` and then `skill` to load `diagnose-windows-sandbox-acl` and wrote the result to a file. The profile drawer can choose `standard / ptc / minimal / cordis` (default `standard`). All four were exercised end-to-end: PTC used `run_code`, minimal and cordis used `pwsh`, standard used `pwsh` + `skill`. `team.recall` searches their own notes/skills/tasks/threads; a Lead can inspect a colleague (`team.member`) and call `team.distill`. Host now has a narrow single-step distillation path: `member.distill(mode:'model')` feeds the member's profile, notes, skills and recent tasks to `llm.stream` with no tools, requires JSON output, then records `member/distilled`. A real run produced a new personality from the old one plus a missed-gate note. Free-form Lead-driven distillation can still drift; the Host path is the product entry. Restart persistence was verified: the same member/session resumed from 63 persisted events (31 zstd frames), and a post-restart Task was claimed and submitted without re-onboarding. The archived-host gate was fixed by not marking members as `origin:'subagent'`. A real 401 also produces `member/llm-failed(auth)`, member `failed`, a Human `decision_required`, and leaves the task pending without retry. See `docs/reports/M2-真实闭环验收.md`. The workbench Thread now sends real `thread.post`, `task.accept` and `task.request_changes`; the task action row also drives `task.cancel`, `task.reopen`, `task.delete` and `task.reassign` (the “demo only” tag is gone). A headless-Edge run accepted a pending Task to `done` from the UI. A Human can DM one member from the profile drawer (`member.message`), which writes to the ledger and wakes only that member; a headless-Edge run sent a DM and verified the member session advanced. The first profile-drawer E2E also exposed and fixed a white-screen bug (`selectedTask` referenced across an early return / null `data`). The Inbox page lists real `data.inbox` decisions and acknowledges them through `inbox.ack`. Follow/unfollow is persisted through `task.follow`; accepting a followed Task creates one `followed_task_update` report for each still-following member. A headless-Edge failure-recovery run used a bad provider to produce a Human decision, acknowledged it, edited the member's provider/maxTokens in the profile drawer, and retried the member back to `running` (`member/recovered`). The latest regression re-ran one sentence → Lead opens a card → QA auto-accept → owner reflection/self-evolution with one wake per stage (20 ledger events, no duplicate human/reflection wakes). On Host startup, unfinished Tasks are woken once via a `team/startup` event (no timers). A real restart test resumed a pending Task: `wake/delivered reason=startup_resume`, then claim → Thread → submit to pending acceptance (15 ledger events; tail repair recorded). The profile drawer now edits provider/model/maxTokens, adds notes/skills, and retries failed members. Task creation can mark `qaRequired` and a `qaChecklist`; non-QA Agents are rejected on accept, the Waker only offers the task to QA, and QA must pass every checklist item before acceptance. M3 adds a test-only `ai-team-fault` LLM adapter for real billing/network failure injection, cross-project Inbox (including opening a task from another project), and a filesystem SkillProvider for installed skills. SSE buckets were verified with two real providers (DeepSeek and Zhipu) producing events in two Projects. Microsoft SkillOpt's seven tools, Python engine and `skillopt-sleep` skill are bundled inside this plugin, not installed into the user's DSH. Version 0.3.3 (文渊阁 / Wenyuan Pavilion; concurrent Projects + cross-project inbox + V-10 guard E2E + billing/network injection + bundled SkillOpt; health reports 0.3.3). Install/uninstall was exercised on a throwaway `ai-team-smoke` profile: health 200 after install, 404 after removal, config clean. — see `CHANGELOG.md`, `docs/05-项目启动与执行计划.md`, `docs/08-异常恢复与模型治理.md` and `docs/reports/M1-验收矩阵.md`.
8
+
9
+ ## Install (dedicated profile)
10
+
11
+ ```sh
12
+ dsh --profile ai-team --from-default-profile web --dump-config # create the profile from the web template
13
+ dsh plugin --profile ai-team add @suifei/dsh-ai-team # install from npm
14
+ # or from a checkout:
15
+ # dsh plugin --profile ai-team add E:/works/dsh-ai-team
16
+ dsh --profile ai-team --no-open --port 0 # boot
17
+ ```
18
+
19
+ The plugin is designed for a dedicated `ai-team` profile; normal `desktop`/`web` sessions keep their preset roster unless explicitly installed. This machine also has it in `desktop` for UI preview. Multi-Project is concurrent: every Project owns its ledger and runtime, each has its own Waker/SSE/tool routing, and `activeProjectId` only selects the UI default. Full install / uninstall / upgrade steps, data locations and profile-isolation checks: [docs/10-安装卸载升级.md](docs/10-安装卸载升级.md).
20
+
21
+ ## Layout
22
+
23
+ - `index.js` — Host entry: same-origin `/ai-team/api/health`, `/ai-team/api/bootstrap`, and `POST /ai-team/api/projects/:id/commands` backed by the default-project ledger.
24
+ - `client.js` — Client entry: `sidebar.panellist` icon + `main` key `ai-team` three-pane workbench.
25
+ - `cordis.patch.yml` — bundle row.
26
+ - `lib/` — append-only ledger (`ledger/*`), task/thread/inbox domain (`domain/*`) and the host `TeamService` (`host/service.js`).
27
+ - `test/` — `node --test`: bundle smoke, ledger/fold/checkpoint, domain rules, and a real-ledger service integration.
28
+
29
+ The bundled SkillOpt integration is derived from Microsoft SkillOpt (`plugins/dsh`, MIT); its license is kept at `lib/vendor/skillopt/LICENSE`.
30
+
31
+ ## Rules
32
+
33
+ - Only `--dsw-alias-*` tokens for UI chrome; the Loop Mark is the only artwork with its own color.
34
+ - No timer / no background wake; M1 will add event-driven wake.
35
+ - A′ (native session + tool view) is only the fallback when the workbench is unavailable.
36
+
37
+ ## Docs
38
+
39
+ The phase-1 research, PRD, architecture, UX and execution plan live in the repository's `docs/` directory (index: `docs/README.md`).