dsh-ai-collab 0.0.0-stage → 0.4.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.
@@ -0,0 +1,89 @@
1
+ # 全局协作纪律(DSH 用户级)
2
+
3
+ > 本文件由 DeepSeek Harness 在每个会话注入(`$DSH_HOME/AGENTS.md`)。
4
+ > 只放**跨项目纪律**,没有任何项目事实;项目事实在 `<项目根>/AGENTS.md`。
5
+
6
+ ## 0. 每个会话的第 0 步(强制,先于任何其它工具调用)
7
+
8
+ ```powershell
9
+ & "$env:DSH_HOME\tools\ai-ensure.ps1" -Root "<当前工作区绝对路径>"
10
+ ```
11
+
12
+ 它一次做完三件事,幂等(已就绪时约 0.1–0.2 秒):
13
+
14
+ 1. 工作区没有 `.ai\llm.cmd` 且**不是临时/系统目录** → 接入骨架并生成 AGENTS.md;
15
+ 2. 框架模板有更新(`.ai\framework-hash` 不一致)→ 升级 `.ai\` 内脚本并重渲染 AGENTS.md;
16
+ 3. 兄弟项目的 `status.json` 比 `..\.ai\board.md` 新 → 刷新看板。
17
+
18
+ 输出一行 JSON:`{"adopted":false,"reason":"not-project"}` 表示临时目录/非项目,**不要**接入。
19
+ **没跑第 0 步就开始改文件 = 违规**;脚本缺失或失败要先报告,不得静默跳过。
20
+
21
+ ## 1. 先对齐任务,再动手
22
+
23
+ 用户在任意一轮给出任务后,**动手前**先给出三件事:
24
+
25
+ 1. **本轮目标**:1–3 条,可验证;
26
+ 2. **待定 / 待补充项**:缺的信息、需要用户拍板的选项、风险与影响范围;
27
+ 3. **建议方案与取舍**:推荐做法 + 备选 + 各自代价。
28
+
29
+ 得到用户确认后再执行。例外:用户当轮明确说"直接做/不用确认",或任务属于**纯只读查询**
30
+ (读日志、看状态、读文件、查环境)。
31
+
32
+ ## 2. 日志归属与看板边界
33
+
34
+ - 各项目的详细记录(进度、问题、决策、补丁、验证数据)**只保存在各项目根的 `.ai\`**,
35
+ 不写进跨项目看板,也不写进别的项目。
36
+ - 跨项目看板 `..\.ai\board.md` 只同步这些字段:项目名、阶段、焦点、阻塞、下一步、
37
+ 记录数、最后更新时间、入口链接。
38
+ - 生成看板时**只读取**各项目 `.ai\status.json` 与 `log.jsonl` 的行数,
39
+ **禁止修改项目内任何内容**。
40
+ - 看板是生成物,禁止手改;需要更新就重跑生成命令。
41
+ - **默认工作区**(`...\deepseek-harness\default-workspace`)不进入跨项目看板;
42
+ 它的任务记录写在根目录 `TASKS.md`(`add` 后自动刷新)。
43
+
44
+ ## 3. 默认只读与权限确认
45
+
46
+ - **项目内初始文件默认只读**:工程源码、配置、文档、资料,以及**后续新加入工作区或项目根的文件**,
47
+ 一律先视为只读;只有项目 `AGENTS.md` 第 3 节标为"可改"的路径才允许写。
48
+ - 以下**不受**默认只读限制:`.ai\`、项目根 `AGENTS.md`、各 AI 工具的运行产物与脚本
49
+ (构建输出、临时脚本、工具自动生成的文件)。
50
+ - 需要写初始文件或未列出的路径时:先说明原因与影响范围 → 取得用户确认 →
51
+ 更新权限表(项目 `AGENTS.md` §3,或 `.ai\placeholders.json` 的 `PERM_TABLE`)并重渲染 → 再动手。
52
+ - `.ai\` 与 `AGENTS.md` 有完全权限;但**项目日志只能追加**:
53
+ 禁止改写或删除 `log.jsonl` 已有行;写错用 `action:"correction"` + `corrects:"<被更正 id>"`。
54
+ - `status.json` 是覆盖式快照,允许整体重写;`changelog\` 可修订但须保留变更痕迹。
55
+ - 参照工程、只读资料(`*.pdf`、`*.docx` 等)永远只读。
56
+
57
+ ## 4. 三步工作法(已接入 `.ai\llm.cmd` 的项目)
58
+
59
+ 1. **开工先读**:`.ai\llm.cmd status` → `.ai\llm.cmd tail -N 10`
60
+ 2. **收工必写**:
61
+ `.ai\llm.cmd add -Tool deepseek-harness -Action <action> -Status <ok|partial|blocked|todo|failed> -Summary "<一句话中文结论>"`
62
+ 然后 `.ai\llm.cmd check`;`blocked`/`failed` 必须带 `-Issue`。
63
+ 该命令**会自动刷新跨项目看板**(父目录存在 `.ai\board.md` 时),不需要单独跑 `board`。
64
+ 3. **没写记录 = 这件事没做完**(纯只读查询且无结论可免)。
65
+
66
+ ## 5. 事实与 AGENTS.md 分区
67
+
68
+ - `AGENTS.md` 分两区:`generated` 区(模板维护:路由、权限、命令)与 `user` 区(项目自维护:
69
+ 事实、采样数据、分析方法、决策)。重渲染**只替换 generated 区**,user 区与区外内容逐字节保留;
70
+ `placeholders.json` / `log.jsonl` / `status.json` 一律不动。
71
+ - **没有分区标记的 AGENTS.md 视为项目自有文件,任何自动流程都不改写**(只在
72
+ `.ai\AGENTS.generated.md` 写参考渲染)。旧格式单行标记文件同样冻结。
73
+ 需要迁移时显式执行:`install.ps1 ... -ForceAgents`(旧内容整体迁入 user 区)
74
+ 或 `-ResetAgents`(丢弃旧内容,谨慎)。
75
+ - `.ai\placeholders.json` 只用于**首次生成**:接入时把项目事实写入 AGENTS.md 的 user 区,
76
+ 之后由项目自行维护,自动化不再改动。
77
+ - 需要切换转发文件(Claude Code / Gemini)时才执行 `.ai\llm.cmd entries -Publish`,用完 `-Remove`。
78
+
79
+ ## 6. 硬性边界
80
+
81
+ - 纯临时目录(`%TEMP%`、下载目录)、只读目录、工作区之外的路径**不要**接入;
82
+ 不要为此修改用户的工程文件。
83
+ - 不把凭据、内网地址、客户信息写进日志 / status / AGENTS.md;放 `.ai\private\`,只写键名。
84
+ - 不擅自创建 `.ai`,一律走第 0 步的 `ai-ensure`。
85
+
86
+ ## 7. 记录质量
87
+
88
+ `summary` 写"做了什么 + 结果",带上验证方式(如 `rebuild 0/0, Code=78106`)。
89
+ 细节(根因、实测数据、补丁)放 `.ai\changelog\`,用 `refs` 指过去,不要撑大 summary。
@@ -0,0 +1,114 @@
1
+ <!-- dsh-ai-collab:generated:start -->
2
+ # AGENTS.md — {{PROJECT_NAME}} 协作入口(项目根)
3
+
4
+ > 所有 AI 工具与协作者的**唯一入口**:先读本文件,再按 §2 的固定动作开工 / 收工。
5
+ > 纪律由 `.ai\llm.cmd`(封装 `llm.ps1`)强制;本文件只放**项目事实**,细节按 §6 查阅,不要往这里堆。
6
+ > 动手前先对齐本轮目标 / 待定项并取得用户确认(全局纪律 §1);工作区内文件默认只读(§3)。
7
+ > 框架版本:v2(纪律上提、单一命令、状态快照、多工具一行转发)。
8
+
9
+ ## 2. 开工 / 收工(强制,所有工具)
10
+
11
+ ```powershell
12
+ # 开工:先确保接入与同步(幂等;DSH 环境)
13
+ & "$env:DSH_HOME\tools\ai-ensure.ps1" -Root "{{PROJECT_ROOT}}"
14
+
15
+ # 再读状态(10 秒上手)
16
+ & .ai\llm.cmd status
17
+ & .ai\llm.cmd tail -N 10
18
+
19
+ # 收工:每完成一件事追加一条,然后校验
20
+ & .ai\llm.cmd add -Tool <tool> -Action <action> -Status <status> -Summary "<一句话结论>"
21
+ & .ai\llm.cmd check
22
+ ```
23
+
24
+ - `<tool>` 用:{{TOOL_LIST}}
25
+ - `<action>`:`task_start` `task_done` `fix` `diagnosis` `build` `commit` `doc` `review` `rollback` `correction` `maintenance` `handoff`
26
+ - `<status>`:`ok` `partial` `blocked` `todo` `failed`;`blocked`/`failed` 必须带 `-Issue`
27
+ - **没写记录 = 这件事没做完**;同一阶段内多次微调合并为一条。
28
+ - 禁止手写 `Get-Content` / `AppendAllText` 改日志,一律走 `llm.cmd`(编码与格式由脚本保证)。
29
+ - `llm.cmd` 是启动器(内部 `powershell -ExecutionPolicy Bypass -File llm.ps1`),个别目录的脚本执行策略会拦截 `.ps1`,用 `.cmd` 最稳。
30
+ - 字段与格式:`.ai\LOG_FORMAT.md`、`.ai\schema\log.schema.json`。
31
+
32
+ ## 3. 目录与权限
33
+
34
+ | 路径 | 权限 | 说明 |
35
+ |---|---|---|
36
+ {{PERM_TABLE}}
37
+
38
+ > **项目内初始文件默认只读**(含后续新加入工作区/项目根的文件),只有上表标为"可改"的路径可写;
39
+ > `.ai\`、`AGENTS.md`、各 AI 工具的运行产物与脚本不受此限,但 `log.jsonl` 只能追加。
40
+ > 需要写入未列出的初始文件时:先说明原因与影响范围 → 取得用户确认 →
41
+ > 把该路径加入上表(或 `.ai\placeholders.json` 的 `PERM_TABLE`)并重渲染 → 再动手。
42
+ > 参照工程与只读资料(`*.pdf` / `*.docx`)永远只读。
43
+
44
+ <!-- IF:BUILD -->
45
+ ## 4. 构建与验证
46
+
47
+ ```powershell
48
+ {{BUILD_CMD}}
49
+ ```
50
+
51
+ - 产物:{{OUTPUT_DIR}}
52
+ - 烧录 / 装载:{{FLASH_NOTE}}
53
+ - 改完必须全量 rebuild:**0 Error / 0 Warning**,尺寸写入日志 `-Verification`(如 `rebuild 0/0, Code=78106`)。
54
+ <!-- ENDIF -->
55
+ <!-- IFNOT:BUILD -->
56
+ ## 4. 构建与验证
57
+
58
+ 本工作区为**非构建型**:无编译、烧录或产物校验步骤。
59
+ <!-- ENDIF -->
60
+
61
+ ## 5. 硬性约束
62
+
63
+ - {{CONSTRAINT_1}}
64
+ - {{CONSTRAINT_2}}
65
+ - {{CONSTRAINT_3}}
66
+ - 源码编码:{{ENCODING_RULE}};批量改动走"区间替换 + 回读校验",禁止整体重写。
67
+ <!-- IF:BUILD -->
68
+ - 版本号只改 {{VERSION_FILE}}。
69
+ <!-- ENDIF -->
70
+ - 提交版本库前**必须先有对应日志记录**;提交说明与 `summary` 可对应。
71
+ - 只读目录(参照工程)不得修改;需要回滚时从其复制。
72
+
73
+ ## 6. 领域文档索引(按需查阅)
74
+
75
+ | 主题 | 位置 |
76
+ |---|---|
77
+ | 版本级变更(根因 / 验证数据 / 已知限制) | `.ai\changelog\` |
78
+ | 历史补丁(可复现每一步改动) | `.ai\changelog\patches\` |
79
+ | 日志 / 状态格式与校验 | `.ai\LOG_FORMAT.md`、`.ai\schema\log.schema.json` |
80
+ | 敏感信息规则 | `.ai\SECURITY.md` |
81
+ | 跨项目看板 | `..\.ai\board.md` |
82
+ | 工程内修改历史(对外) | 各工程 `readme.txt` |
83
+ | 任务记录清单(默认工作区) | `TASKS.md`(根目录,自动生成) |
84
+
85
+ ## 7. 多工具入口(严格单文件)
86
+
87
+ **根目录只放本文件(AGENTS.md)+ `.ai\` 一个目录**,不放任何转发文件。
88
+
89
+ - DSH、Cursor 3.x、VS Code Copilot 等直接读 `AGENTS.md`,无需额外文件。
90
+ - 只认 `CLAUDE.md` / `GEMINI.md` 的工具,二选一:
91
+ 1. **用户级一次性转发**(推荐,项目内零冗余):`~\.claude\CLAUDE.md` 写"若存在 ./AGENTS.md 则遵循";Gemini 在 `~\.gemini\settings.json` 设 `"contextFileName": "AGENTS.md"`。
92
+ 2. **临时落地**:`& .ai\llm.cmd entries -Publish` 生成 4 个转发文件,用完 `& .ai\llm.cmd entries -Remove` 收回。
93
+ - 转发母版常驻 `.ai\entries\`;改规则只改本文件,`entries -Publish -Force` 会同步。
94
+ <!-- dsh-ai-collab:generated:end -->
95
+
96
+ <!-- dsh-ai-collab:user:start -->
97
+ ## 1. 项目事实
98
+
99
+ | 项 | 值 |
100
+ |---|---|
101
+ | 项目 | {{PROJECT_NAME}}({{PROJECT_CODE}}) |
102
+ | 根目录 | `{{PROJECT_ROOT}}` |
103
+ | 摘要 | {{PROJECT_SUMMARY}} |
104
+ | MCU / 工具链 | {{MCU}} / {{TOOLCHAIN}} |
105
+ | 版本控制 | {{VCS}} |
106
+ | 工作日志 | `.ai\log.jsonl`(UTF-8 无 BOM / LF / 只追加) |
107
+ | 当前状态 | `.ai\status.json`(覆盖式,新工具先读这个) |
108
+ | 变更记录 | `.ai\changelog\`(版本级:根因 / 验证 / 已知限制) |
109
+ | 敏感值 | `.ai\private\`(见 `.ai\SECURITY.md`) |
110
+
111
+ > **本区(含上方 §1 与以下内容)由项目自行维护**:`ai-ensure` / `install.ps1` 只保留、不改写、不删除。
112
+ > 建议在此**追加**项目专有内容:采样数据与采集过程、分析方法、硬件/协议约束、验证结论、决策记录等。
113
+
114
+ <!-- dsh-ai-collab:user:end -->
package/CHANGELOG.md ADDED
@@ -0,0 +1,50 @@
1
+ # Changelog
2
+
3
+ ## 0.4.3
4
+
5
+ - Repository metadata: `repository`, `homepage`, `bugs` point at the public GitHub repository;
6
+ `README` carries the CI badge; `.gitignore` added for release artifacts.
7
+ - Market checklist updated now that the repository exists.
8
+
9
+ ## 0.4.2
10
+
11
+ - Desensitize shipped files: example paths, project names, hostnames and an internal SVN URL
12
+ are replaced with placeholders; `placeholders.sample.json` uses a neutral demo project and
13
+ the v2 `.ai\` directory.
14
+ - Market preparation: `docs/MARKET.md` release checklist, `scripts/make-market-index.mjs`
15
+ (format-1 index generator), `publishConfig.access`.
16
+
17
+ ## 0.4.1
18
+
19
+ - Declare `"os": ["win32"]`: the bundle is Windows-only for now (scaffolding runs Windows
20
+ PowerShell 5.1). macOS/Linux return `unsupported-platform` and are not supported yet.
21
+ - README and detail document state the platform restriction explicitly.
22
+
23
+ ## 0.4.0
24
+
25
+ - Security: task-list refresh is rendered inside the plugin; it no longer executes the
26
+ workspace's `.ai/llm.ps1` (a cloned repository could otherwise run code on `ai_log`).
27
+ - Config: values are normalised and validated (`autoInit`, `maxTail`, `initScript`);
28
+ rejected values produce warnings in `$DSH_HOME/logs/ai-collab-config.log`.
29
+ - Cross-platform: `workingDirectory` is no longer a hard injection; scaffolding reports
30
+ `unsupported-platform` instead of failing silently outside Windows.
31
+ - Reliability: per-workspace in-flight guard for auto-adoption, debounced board refresh,
32
+ 256 KiB log rotation, and clearer error entries.
33
+ - Packaging: locale metadata (`en`, `zh`), SVG icon, `meta.detail`, `engines.dsh`,
34
+ display-ready `files`, and a user-level `AGENTS.global.template.md`.
35
+ - Tests: new pure-JS tests for config normalisation and task rendering.
36
+
37
+ ## 0.3.6
38
+
39
+ - `ai_log` refreshes `TASKS.md` after a record; `ai-ensure` refreshes any workspace with
40
+ `.ai/tasks-enabled`.
41
+ - AGENTS.md zones: only the generated zone is replaced; the user zone is preserved.
42
+
43
+ ## 0.3.0
44
+
45
+ - Tools resolve the session working directory through `ctx.workingDirectory`.
46
+ - `ai_init` and auto-adoption run `ai-ensure` and return its parsed result.
47
+
48
+ ## 0.2.0
49
+
50
+ - First working bundle: five tools, heartbeat and tool-registration logs, Windows scaffolding.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-ai-collab contributors
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/PUBLISH.md ADDED
@@ -0,0 +1,105 @@
1
+ # PUBLISH — 维护者操作手册(npm 发布准备)
2
+
3
+ > 当前状态:**只做发布准备,未上传**。以下步骤需要你本人完成 npm 登录(我不接触凭据)。
4
+
5
+ ## 0. 前置检查(已满足)
6
+
7
+ - `package.json` 已去掉 `private`,`license: MIT`,`files` 白名单只含运行所需文件(19 项,约 32 KB 打包 / 94 KB 解包)。
8
+ - `npm pack --dry-run` 已通过,`template/.ai/**` 正常入包。
9
+ - `npm run check`、`npm test` 均通过(6 个用例)。
10
+ - 包名 `dsh-ai-collab` 在 registry.npmjs.org 上**未被占用**(查询返回 404)。
11
+
12
+ ## 1. 登录 npm(必须由你执行)
13
+
14
+ 本机 `.npmrc` 指向 `registry.npmmirror.com`(只读镜像,不能发布),发布时要显式指定官方 registry:
15
+
16
+ ```powershell
17
+ npm login --registry https://registry.npmjs.org
18
+ npm whoami --registry https://registry.npmjs.org # 应回显你的用户名
19
+ ```
20
+
21
+ 或在 CI 里使用 `NPM_TOKEN`(`//registry.npmjs.org/:_authToken=...`)。
22
+
23
+ ## 2. 发布前再验证一次
24
+
25
+ ```powershell
26
+ cd <package-dir>
27
+ npm run check
28
+ npm test
29
+ npm pack --dry-run
30
+ ```
31
+
32
+ ## 3. 发布
33
+
34
+ ```powershell
35
+ npm publish --access public --registry https://registry.npmjs.org
36
+ ```
37
+
38
+ - 首次发布建议加 `--dry-run` 先看文件清单(npm 支持 `npm publish --dry-run`)。
39
+ - 之后在 `https://registry.npmjs.org/dsh-ai-collab` 与 `npm view dsh-ai-collab version` 核对。
40
+ - 72 小时内可 `npm unpublish dsh-ai-collab@0.2.0` 撤回;超时只能发新版并 `npm deprecate`。
41
+
42
+ ## 4. 版本策略
43
+
44
+ - 修复 → `npm version patch`;新增工具/配置 → `minor`;破坏 schema → `major`。
45
+ - 每次发版更新 `README.md` 与(可选)`CHANGELOG.md`,并在 `package.json` 里同步 `version`。
46
+
47
+ ## 5. 可选:GitHub 仓库
48
+
49
+ ```powershell
50
+ cd <package-dir>
51
+ git init
52
+ git add .
53
+ git commit -m "feat: dsh-ai-collab 0.2.0"
54
+ git branch -M main
55
+ git remote add origin https://github.com/<你>/dsh-ai-collab.git
56
+ git push -u origin main
57
+ ```
58
+
59
+ 建议在仓库里放 GitHub Release(附 `npm pack` 产物)与 Issue 模板。
60
+
61
+ ## 6. 发布后验证(真实安装)
62
+
63
+ ```powershell
64
+ # 新建一个一次性 profile 做验证,避免影响 desktop
65
+ dsh --profile aicollab-test --from-default-profile web --dump-config
66
+ dsh plugin --profile aicollab-test add dsh-ai-collab
67
+ dsh --profile aicollab-test --dump-config | Select-String ai-collab
68
+ ```
69
+
70
+ 确认 `ai-collab` 行出现在组合结果中,再考虑装到 `desktop`。
71
+
72
+ ## 7. 回滚
73
+
74
+ | 场景 | 操作 |
75
+ |---|---|
76
+ | 插件导致启动失败 | 从 profile 的 `dsh.profile.bundles` 移除 `dsh-ai-collab`,重启 |
77
+ | 只想临时关闭 | 把 `cordis.patch.yml` 里该行的 `enabled` 设为 `false` |
78
+ | npm 版本有问题 | `npm deprecate dsh-ai-collab@0.2.0 "broken, use 0.1.1"` 并发布修复版 |
79
+
80
+ ## 8. 发布前仍未完成的事
81
+
82
+ - [x] 在真实 DSH 中安装验证(§6):desktop profile 以 bundle 方式运行 0.3.6,5 个工具注册、`ai_init` 实测通过。
83
+ - [ ] 补 `repository` / `homepage` 字段(需要先建 GitHub 仓库)。
84
+ - [x] `test/` 与 `dev-patch.yml` 不在 `files` 白名单内。
85
+ - [x] 非 Windows 平台:脚手架返回 `unsupported-platform`,只读工具可用。
86
+
87
+ ## 9. 社区市场收录(dshmarket / awesome-dsh-plugin)
88
+
89
+ DSH 官方 Discover 的索引由用户自行添加;社区市场 `dshmarket` 从
90
+ [awesome-dsh-plugin](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin) 精选清单读取。
91
+ 收录步骤:
92
+
93
+ 1. 发布 npm 包(§3)并建 GitHub 仓库;
94
+ 2. 在 awesome-dsh-plugin 仓库**提一条 PR**,按其模板增加本包条目(名称、仓库、描述、安装方式);
95
+ 3. 合并后 `dshmarket` 与 `awesome-dsh-plugin.com` 通常 1 天内同步;
96
+ 4. 用 `dsh plugin --profile <test> add dsh-ai-collab` 在干净 profile 复验一次;
97
+ 5. 可选:自建 format-1 `index.json`(`name`/`version`/`source`/`engines`),让用户在
98
+ **Plugins → Discover → Index sources** 里添加。
99
+
100
+ 要求与注意:
101
+
102
+ - `package.json` 必须声明 `dsh.bundle.patch`(已满足);无 build 脚本(已满足,市场默认禁 build);
103
+ - 建议声明 `engines.dsh`(已加 `>=0.2.1`),市场据此做兼容过滤;
104
+ - 不要向 `dsh-market/dsh-market` 仓库提插件条目(README 明确说明那是市场应用,不是目录)。
105
+
package/README.md CHANGED
@@ -1,3 +1,197 @@
1
- # Temporary Holding Version
1
+ # dsh-ai-collab
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
+ [![ci](https://github.com/ZhuYw3927/dsh-ai-collab/actions/workflows/ci.yml/badge.svg)](https://github.com/ZhuYw3927/dsh-ai-collab/actions/workflows/ci.yml)
4
+
5
+ A [DeepSeek Harness](https://github.com/deepseek-ai) bundle that adds a **project-agnostic AI collaboration layer** built around two ideas:
6
+
7
+ - `AGENTS.md` — the single entry file at the project root (facts: build/flash commands, constraints, read-only dirs);
8
+ - `.ai/` — one hidden folder holding an append-only work log, a current-state snapshot, a JSON schema and archive.
9
+
10
+ The point: any AI tool working in the repo (DSH, Claude Code, Cursor, Copilot, Codex) reads and writes the same progress, instead of rediscovering the project every session.
11
+
12
+ > Status: **0.4.2, experimental**. Installed and running in a live profile (Windows, DSH `0.2.2-rc.3`); not yet published to npm or a plugin market — see [Known limitations](#known-limitations).
13
+
14
+ ## Requirements
15
+
16
+ | | |
17
+ |---|---|
18
+ | DeepSeek Harness | `0.2.1+` (tested on `0.2.2-rc.3`; the `dsh`/Cordis plugin API this bundle targets) |
19
+ | Node.js | >= 20 (bundled Electron Node works) |
20
+ | OS | **Windows 10/11 only** for now (scaffolding runs Windows PowerShell 5.1; the read-only tools are OS-independent, but macOS/Linux are not supported or tested) |
21
+
22
+ ## Install
23
+
24
+ **Option A — Creator mode (recommended)**
25
+
26
+ ```
27
+ plugin_manager
28
+ action: install_bundle
29
+ target: <absolute path to this package>
30
+ ```
31
+
32
+ **Option B — CLI**
33
+
34
+ ```powershell
35
+ dsh plugin --profile desktop add "F:\path\to\dsh-ai-collab"
36
+ # then append "dsh-ai-collab" to dsh.profile.bundles in
37
+ # %USERPROFILE%\.dsh\profiles\desktop\package.json
38
+ ```
39
+
40
+ **Option C — local absolute path (legacy, not recommended)**
41
+
42
+ Older hosts accepted a raw absolute-path row in the profile patch. On current builds this
43
+ does not mount reliably; use the bundle install above. The patch form is kept only for
44
+ isolated debugging:
45
+
46
+ Add to `$DSH_HOME/profiles/desktop/cordis.patch.yml`:
47
+
48
+ ```yaml
49
+ - insert:
50
+ - id: ai-collab
51
+ name: F:\path\to\dsh-ai-collab\index.js
52
+ config:
53
+ autoInit: true
54
+ ```
55
+
56
+ Patch loading converts absolute paths to file URLs, so no pnpm install is needed. Remove the block to roll back.
57
+
58
+ Restart the app. The profile's sessions (the GUI uses `desktop`) then expose the tools below.
59
+
60
+ ## Plugin market
61
+
62
+ Release and submission steps live in [docs/MARKET.md](docs/MARKET.md): npm publish, the
63
+ awesome-dsh-plugin PR (the community market catalog), and an optional self-hosted format-1
64
+ index generated by `scripts/make-market-index.mjs`.
65
+
66
+ ## Configuration
67
+
68
+ `config` keys are read as-is (**no `Config` schema yet**, so values are not type-checked); all keys optional:
69
+
70
+ | Key | Default | Meaning |
71
+ |---|---|---|
72
+ | `autoInit` | `false` | On `session/created`, run `ai-ensure` in the session cwd unless it is a temp/system directory: scaffold `.ai/`, refresh `AGENTS.md` and the board |
73
+ | `maxTail` | `10` | How many recent log records `ai_status` returns |
74
+ | `initScript` | packaged `ai-ensure.ps1` | Override the ensure script |
75
+
76
+ ## Tools
77
+
78
+ | Tool | Does |
79
+ |---|---|
80
+ | `ai_status` | Reads `.ai/status.json` + the last N log records (start a session here) |
81
+ | `ai_log` | Appends one record to `.ai/log.jsonl`; rejects invalid enums, requires `issue` for `blocked`/`failed`; refreshes `status.json` **and the sibling board** |
82
+ | `ai_check` | Validates every record: required fields, enums, timezone, monotonic `ts`, unique `id` |
83
+ | `ai_board` | Read-only roll-up of sibling projects' `.ai/status.json` |
84
+ | `ai_init` | Ensures the workspace: scaffold if missing, refresh stale `.ai/`/`AGENTS.md`, refresh stale board (idempotent) |
85
+
86
+ ## What `ai_init` creates
87
+
88
+ ```
89
+ <project root>
90
+ ├─ AGENTS.md ← only visible file (facts + discipline pointer)
91
+ └─ .ai\
92
+ ├─ llm.ps1, llm.cmd ← CLI: status / tail / add / check / entries / archive / board / doctor
93
+ ├─ log.jsonl ← append-only, UTF-8 no BOM, LF
94
+ ├─ status.json ← current state (overwritten)
95
+ ├─ LOG_FORMAT.md, SECURITY.md, schema\log.schema.json
96
+ ├─ changelog\ ← version-level docs + patch engine
97
+ ├─ entries\ ← forwarding-file masters (publish on demand)
98
+ └─ _archive\
99
+ ```
100
+
101
+ Record shape (one JSON object per line):
102
+
103
+ ```json
104
+ {"id":"...","ts":"2026-11-04T17:10:00+08:00","tool":"claude-code","actor":"ai",
105
+ "action":"fix","status":"ok","summary":"what changed + result",
106
+ "files_modified":["src/a.c"],"verification":"rebuild 0/0, Code=78106"}
107
+ ```
108
+
109
+ `status` ∈ `ok|partial|blocked|todo|failed`; `action` ∈ `task_start|task_done|fix|diagnosis|build|commit|doc|review|rollback|correction|maintenance|handoff`.
110
+
111
+ ## Updating (after install)
112
+
113
+ The bundle is an npm package mounted into a profile. The Host loads it at boot and ships no HMR/watcher, so **code changes take effect only after a restart**.
114
+
115
+ 1. Bump `version` in `package.json` (e.g. `0.2.0` → `0.2.1`) so you can tell what is live.
116
+ 2. Reinstall from the same path (or a new version): `dsh plugin --profile desktop add "F:\path\to\dsh-ai-collab"`, or run Creator-mode `install_bundle` again.
117
+ 3. Restart the app. Every session in that profile then uses the new code on its next turn.
118
+ 4. Existing projects keep their own copied `.ai/` files. The next `ai-ensure` (or an `ai_init` tool call) sees a changed framework hash and refreshes `.ai/` + `AGENTS.md` automatically; projects you never revisit stay on the old copy until then.
119
+ 5. Global `$DSH_HOME/AGENTS.md` is independent of this bundle: editing it applies to the next request immediately, with no restart.
120
+
121
+ ## Verifying an install
122
+
123
+ Two append-only files under `$DSH_HOME/logs` record what actually happened at boot:
124
+
125
+ ```powershell
126
+ Get-Content "$DSH_HOME\logs\ai-collab-boot.log" -Tail 3 # version=… autoInit=… home=env|homedir
127
+ Get-Content "$DSH_HOME\logs\ai-collab-tools.log" -Tail 3 # tools=ai_status,… spec=file:///…/app.asar/…
128
+ ```
129
+
130
+ - A fresh boot line means `apply()` ran in this process.
131
+ - A `tools=` line means all five tools registered; `spec` shows where `@deepseek-ai/dsh-tools` was loaded from.
132
+ - `load-failed` / `register-failed` lines carry the exact resolution errors.
133
+
134
+ The plugin is mounted from outside `app.asar` (a `link:`/absolute path), so the bare `@deepseek-ai/dsh-tools` specifier is not resolvable; it is loaded from the host's real `app.asar` path instead (see `asarRoots()` in `index.js`). `DSH_HOME` is read from the host environment and may be absent when the app is launched from Explorer — the plugin then falls back to `~/.dsh` (`home=homedir`).
135
+
136
+ ## `AGENTS.md` zones: generated vs project-owned
137
+
138
+ `AGENTS.md` is split into two marked zones:
139
+
140
+ ```
141
+ <!-- dsh-ai-collab:generated:start --> … template maintened (routing, permissions, commands) …
142
+ <!-- dsh-ai-collab:generated:end -->
143
+
144
+ <!-- dsh-ai-collab:user:start --> … project facts, sampling data, analysis methods, decisions …
145
+ <!-- dsh-ai-collab:user:end -->
146
+ ```
147
+
148
+ - `ai_log` (and `ai_init`/`ai-ensure`) refresh the task list (`TASKS.md`) whenever the workspace has `.ai/tasks-enabled`.
149
+ - Re-render replaces **only** the generated zone. The user zone (and anything outside both zones) is preserved **byte-for-byte**; `placeholders.json`, `log.jsonl` and `status.json` are never touched.
150
+ - A file **without** the zone markers is treated as project-owned and is never rewritten; the rendered reference goes to `.ai/AGENTS.generated.md`. This includes legacy single-line-marker files, which are frozen.
151
+ - Explicit migration only:
152
+ - `-ForceAgents` — rebuild the generated zone and move the whole old file into the user zone (nothing deleted);
153
+ - `-ResetAgents` — discard old content and write the template (destructive, explicit).
154
+ ## Safety
155
+
156
+ - The log is **append-only**; corrections are new records (`action:"correction"`), never edits.
157
+ - `autoInit` writes **only** into project-like working directories, never into `%TEMP%` or read-only trees.
158
+ - No credentials expected in the log; a `SECURITY.md` in `.ai/` describes where secrets go (`.ai/private/`).
159
+ - The scaffold is a normal PowerShell script you can read: `ai-init.ps1` → `install.ps1` → `template/.ai/`.
160
+ - **Task lists are rendered inside the plugin** (`lib/tasks.js`); the plugin never executes a
161
+ workspace-provided `.ai/llm.ps1`, so cloning a hostile repository and logging cannot run its code.
162
+
163
+ ## Uninstall
164
+
165
+ 1. Remove `dsh-ai-collab` from `dsh.profile.bundles` (or set `enabled: false` on its row) and restart.
166
+ 2. Optionally delete the package from the profile (`dsh plugin --profile desktop remove dsh-ai-collab`).
167
+ 3. Per-project `.ai/` folders are plain files; delete at will.
168
+
169
+ ## Global discipline (user level)
170
+
171
+ The bundle ships tools and workspace scaffolding, not a user-level instruction file. To get
172
+ the mandatory "step 0" behaviour in every session, copy
173
+ [`AGENTS.global.template.md`](AGENTS.global.template.md) to `$DSH_HOME/AGENTS.md`
174
+ (or merge it into your existing one). It contains only cross-project discipline — no project facts.
175
+
176
+ ## Development
177
+
178
+ ```powershell
179
+ npm run check # node --check index.js + lib/*.js
180
+ npm test # 19 tests: tool contract, config, task rendering, AGENTS.md preservation
181
+ npm pack --dry-run
182
+ ```
183
+
184
+ ## Known limitations
185
+
186
+ - Verified against the shipped `@deepseek-ai/dsh-tools` contract (`0.2.2`): parameters use the property-map DSL, `output.render` returns an array of content blocks, and the session workspace is resolved loosely through `ctx.get('workingDirectory', false)` with a `process.cwd()` fallback. Still run the preflight in your own DSH build if you modify these parts.
187
+ - `ai_init` / `autoInit` are **Windows-only** (packaged PowerShell 5.1); the bundle is declared
188
+ `"os": ["win32"]` and macOS/Linux are not supported yet. On other platforms the scaffold tools
189
+ return `unsupported-platform` instead of failing silently.
190
+ - Config values are normalised in-process (no schemastery `Config` yet); invalid values produce warnings in `$DSH_HOME/logs/ai-collab-config.log`.
191
+ - A legacy `AGENTS.md` without zone markers is frozen by design; migrate explicitly with `-ForceAgents` or `-ResetAgents`.
192
+ - The forwarding files for Claude Code / Gemini CLI are only masters under `.ai/entries/`; publish them with `.ai\llm.cmd entries -Publish` when a tool needs auto-discovery.
193
+ - Publishing is not automated yet — see `PUBLISH.md`.
194
+
195
+ ## License
196
+
197
+ MIT — see [LICENSE](LICENSE).