dsh-gate-agent 0.1.3 → 0.1.5

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.
package/README.md CHANGED
@@ -72,8 +72,8 @@ Host 插件:用 phase/node 门禁组织讨论、规划、实施、评审、验
72
72
  | `reviewing/code-review-standalone` | 单独只读 code review | review worker;`gate-code-review` |
73
73
  | `reviewing/proposal-review` | 单独提案评审 | review worker;`gate-plan-review` |
74
74
  | `reviewing/verify-standalone` | 单独只读验收 | verify worker;`gate-user-verify` |
75
- | `docs` | 文档治理 | root;不调用 gate 技能 |
76
- | `blocked` | 冻结写入/派 worker,等待用户决定 | root;`/gate-resume` 或 `/gate-return-discuss` |
75
+ | `docs` | 文档治理 | root;按项目文档规范处理 |
76
+ | `blocked` | 冻结写入/派 worker,等待用户决定 | root;`/gate-resume` |
77
77
  | `complete` | 工作完成 | root;可重新进入 plan/implement |
78
78
 
79
79
  进入阶段不等于执行。主代理按当前 procedure 加载技能、派 worker,再用 `gate_record` 推进节点。
@@ -109,23 +109,24 @@ Host 插件:用 phase/node 门禁组织讨论、规划、实施、评审、验
109
109
  | 命令 | 参数 | 作用 |
110
110
  |---|---|---|
111
111
  | `/gate-init` | 无 | 初始化 notes、AGENTS.md、`verify-notes`、CI、git 与基础 `.gitignore`,保持 `discuss` |
112
- | `/gate-enter-plan [简单需求]` | 可选 | 进入 `orchestrating/plan` |
113
- | `/gate-enter-implement [简单说明]` | 可选 | 进入 `orchestrating/implement`;复用已通过的 task,或直接用简述 |
114
- | `/gate-docs` | 无 | 文档治理,不调用技能 |
115
- | `/gate-implement-review [范围]` | 可选 | 单独只读 code review,只输出 findings |
116
- | `/gate-code-verify [范围]` | 可选 | 单独只读验收;子代理使用 `gate-user-verify` |
117
- | `/gate-fix-bug [缺陷简述]` | 可选 | 派 fix worker 修复已授权缺陷,完成后回 discuss |
118
- | `/gate-propose-review [提案]` | 可选 | 单独提案评审,走 `gate-plan-review` 三轴 |
112
+ | `/gate-enter-plan [具体工作事项或上下文语义]` | 可选 | 基于讨论共识、既有决策与用户输入进入 `orchestrating/plan` |
113
+ | `/gate-enter-implement [具体工作事项或上下文语义]` | 可选 | 基于已确认计划或讨论后的实施说明进入 `orchestrating/implement` |
114
+ | `/gate-prd [主题或上下文语义]` | 可选 | 用户级创建/更新 PRD;仅 discuss |
115
+ | `/gate-docs [文档范围或上下文语义]` | 可选 | 进入文档治理,按项目文档规范处理 |
116
+ | `/gate-implement-review [具体工作事项或上下文语义]` | 可选 | 对当前改动做独立只读 code review,只输出 findings |
117
+ | `/gate-code-verify [具体工作事项或上下文语义]` | 可选 | 对当前改动做独立只读验收(gate-user-verify) |
118
+ | `/gate-fix-bug [具体工作事项或上下文语义]` | 可选 | 基于描述或当前上下文派 fix worker 修复已授权缺陷 |
119
+ | `/gate-propose-review [具体工作事项或上下文语义]` | 可选 | 对提案做独立只读三轴评审 |
119
120
  | `/gate-note-verify` | 无 | 只读检查 notes tree/format/lifecycle/archived |
120
121
  | `/gate-note-archive <note> [--superseded-by <new>]` | 必需 Note 路径 | 归档 implemented Note,写 Archived、移动、封印、报告入站链接 |
121
122
  | `/gate-note-board [输出路径] [标题]` | 可选 | 生成决策看板 `board.html` |
122
123
  | `/gate-note-seal` | 无 | 只给 `archived/` 中已有 Note 补写 `manifest.json` 的 SHA-256 封印 |
123
124
  | `/gate-block [原因]` | 可选 | 手动暂停,保留当前节点 |
124
125
  | `/gate-resume` | 无 | 解冻 blocked,回到 block 前的节点;轮次耗尽回 discuss |
125
- | `/gate-return-discuss` | 无 | 回到 discuss |
126
- | `/gate-status` | 无 | 只读显示当前 phase/node 与 procedure |
126
+ | `/gate-return-discuss` | 无 | 放弃当前节点,回到 discuss |
127
+ | `/gate-status` | 无 | 只读显示当前 phase/node、procedure、access 与下一步命令 |
127
128
 
128
- 直接 implement(`/gate-enter-implement [简单说明]` 或 `gate_start_phase({node:'implement',brief})`)会自动标记 `mechanical`,跳过 Note lifecycle;不需要 `mechanical:` 前缀。plan/plan-revise 手动选择 `mechanical` 时也不要求前缀,只需 `notePaths: []`。
129
+ 直接 implement(`/gate-enter-implement [具体工作事项或上下文语义]` 或 `gate_start_phase({node:'implement',brief})`)会自动标记 `mechanical`,跳过 Note lifecycle;不需要 `mechanical:` 前缀。plan/plan-revise 手动选择 `mechanical` 时也不要求前缀,只需 `notePaths: []`。
129
130
 
130
131
  离开 discuss 的授权可来自对话(包括要求用户再输入 slash command)或 `ask_user_question`;明确授权后,主代理可调用 `gate_start_phase({node:'plan'|'implement', brief})`。
131
132
 
@@ -190,7 +191,7 @@ gate 不自动 `git add`/`git commit`;完成 note-lifecycle 后由用户或主
190
191
  ### 单独 code review
191
192
 
192
193
  ```text
193
- /gate-implement-review [范围]
194
+ /gate-implement-review [具体工作事项或上下文语义]
194
195
  ```
195
196
 
196
197
  只读 review,不修改被评审对象;findings 直接输出。
@@ -198,7 +199,7 @@ gate 不自动 `git add`/`git commit`;完成 note-lifecycle 后由用户或主
198
199
  ### 单独验收
199
200
 
200
201
  ```text
201
- /gate-code-verify [范围]
202
+ /gate-code-verify [具体工作事项或上下文语义]
202
203
  ```
203
204
 
204
205
  主代理派只读 verify worker,使用 `gate-user-verify`;PASS 后 `gate_record({node:'verify-standalone', verification, workerSessionIds})` 回 discuss。
@@ -245,24 +246,27 @@ review worker 使用 `gate-plan-review` 做 Standards/Spec/Architecture 三轴
245
246
  /gate-docs
246
247
  ```
247
248
 
248
- 进入 `docs` phase,不调用 gate 技能;由主代理按项目文档规范处理。
249
+ 进入 `docs` phase,由主代理按项目文档规范处理。
249
250
 
250
251
  ### 暂停、恢复与讨论
251
252
 
252
253
  ```text
253
254
  /gate-block 等待产品决定
254
255
  /gate-resume
255
- /gate-return-discuss
256
256
  /gate-status
257
257
  ```
258
258
 
259
259
  - `/gate-block`:保留当前节点,冻结写入与 worker 派发,对话仍可继续。
260
- - `/gate-resume`:回到 block 前的节点;review 轮次耗尽时回 discuss。
261
- - `/gate-return-discuss`:放弃当前节点,回 discuss。
260
+ - `/gate-resume`:唯一的 blocked 恢复入口;回到 block 前的节点,review 轮次耗尽时回 discuss。
261
+ - `/gate-return-discuss`:放弃当前节点回 discuss;blocked 时不可直接用,先 `/gate-resume`。
262
262
  - `/gate-status`:只读查看当前 phase/node 和 procedure。
263
263
 
264
264
  ## 工具
265
265
 
266
+ ### gate_help
267
+
268
+ 只读,root-only。列出全部 `/gate-*` 命令、`gate_*` 工具用途和当前 phase/node,并说明命令由用户执行、工具由模型调用。不确定命令名或工具用途时使用。
269
+
266
270
  ### gate_start_phase
267
271
 
268
272
  只允许 root 调用,在用户已授权时从 `discuss`/`complete` 进入 `plan` 或 `implement`:
@@ -297,12 +301,20 @@ gate_record({
297
301
 
298
302
  ### gate_status
299
303
 
300
- 只读,root 和 worker 可调用。root 返回当前 procedure 与状态;worker 只返回状态,不返回 root procedure。
304
+ 只读,root 和 worker 可调用。root 返回当前 procedure、状态和 nextCommands;worker 只返回状态,不返回 root procedure。
301
305
 
302
306
  ```text
303
307
  gate_status()
304
308
  ```
305
309
 
310
+ ### gate_artifact_write
311
+
312
+ 按 `.agents/gate/artifact-policy.json` 写白名单 artifact;只写文件,不走普通 workspace write。支持精确文件、目录和 glob。
313
+
314
+ ### gate_research_dispatch
315
+
316
+ root-only;在 discuss 或 `orchestrating/plan` 派 research worker。worker 只能通过 artifact policy 写 research 文档,不获得通用 workspace 写。
317
+
306
318
  ### Note 工具
307
319
 
308
320
  - `gate_note_write`:planning worker 写 proposed Note,或原地更新 implemented Note;通用 `write`/`edit`/`apply_patch` 和仓库写被拒绝,只读 shell 可用。
@@ -331,7 +343,183 @@ gate_status()
331
343
 
332
344
  ## 配置
333
345
 
334
- 插件 Config:
346
+ ### artifact-policy.json
347
+
348
+ discuss 和 plan 默认不允许普通文件写。`handoff`、PRD、research 等产物通过**独立的 artifact 白名单**写入,而不是放开通用 `write`。
349
+
350
+ `/gate-init` 会创建:
351
+
352
+ ```text
353
+ .agents/gate/artifact-policy.json
354
+ ```
355
+
356
+ - 文件不存在时写入基础配置;
357
+ - 文件已存在时**不覆盖**,保留用户内容;
358
+ - 新建 `.gitignore` 时包含 `.scratch/`;已有 `.gitignore` 不重写。
359
+
360
+ #### 基础配置
361
+
362
+ ```json
363
+ {
364
+ "version": 1,
365
+ "artifacts": {
366
+ "handoff": {
367
+ "phases": ["*"],
368
+ "roles": ["root"],
369
+ "paths": [".scratch/handoff/**"]
370
+ },
371
+ "prd": {
372
+ "phases": ["discuss"],
373
+ "roles": ["root"],
374
+ "paths": ["docs/prd/**", ".scratch/prd/**"]
375
+ },
376
+ "research": {
377
+ "phases": ["discuss", "orchestrating/plan"],
378
+ "roles": ["root", "worker"],
379
+ "paths": ["docs/research/**", ".scratch/research/**"]
380
+ }
381
+ }
382
+ }
383
+ ```
384
+
385
+ #### 字段
386
+
387
+ | 字段 | 说明 |
388
+ |---|---|
389
+ | `version` | 必须为 `1` |
390
+ | `artifacts` | artifact kind 到规则的映射 |
391
+ | `kind` | 内置 `handoff`、`prd`、`research`;也可以增加自定义 kind |
392
+ | `phases` | 允许的 canonical phase/node key,或 `*` |
393
+ | `roles` | `root` 或 `worker` |
394
+ | `paths` | 相对 workspace 的文件、目录或 glob |
395
+
396
+ #### phases
397
+
398
+ 使用 `gate_status` 返回的 `methodologyKey` 形式:
399
+
400
+ - `discuss`
401
+ - `docs`
402
+ - `complete`
403
+ - `orchestrating/plan`
404
+ - `orchestrating/plan-review`
405
+ - `orchestrating/plan-revise`
406
+ - `orchestrating/implement`
407
+ - `orchestrating/code-review`
408
+ - `orchestrating/implement-revise`
409
+ - `orchestrating/verify`
410
+ - `orchestrating/note-lifecycle`
411
+ - `orchestrating/fix-bug`
412
+ - `reviewing/code-review-standalone`
413
+ - `reviewing/proposal-review`
414
+ - `reviewing/verify-standalone`
415
+
416
+ `*` 表示任意**非 blocked** 状态。`blocked` 始终拒绝,即使规则写了 `*`。
417
+
418
+ #### roles
419
+
420
+ - `root`:主代理;
421
+ - `worker`:任何 gate worker,包括 planning worker 和 research worker。
422
+
423
+ #### paths
424
+
425
+ 支持四种形式:
426
+
427
+ ```json
428
+ "paths": [
429
+ "docs/prd/current.md",
430
+ "docs/prd/PRD-*.md",
431
+ ".scratch/research/**/*.md",
432
+ ".scratch/handoff/**"
433
+ ]
434
+ ```
435
+
436
+ | 形式 | 含义 |
437
+ |---|---|
438
+ | `docs/prd/current.md` | 只允许这个文件 |
439
+ | `docs/prd/*.md` | 只允许该目录下直接文件,不递归 |
440
+ | `.scratch/research/**/*.md` | 递归匹配 Markdown |
441
+ | `.scratch/handoff/**` | 允许该目录下任意层级文件 |
442
+ | `docs/prd/**` | 允许该目录下任意层级文件 |
443
+
444
+ 规则:
445
+
446
+ - `*` 只匹配一个路径段;
447
+ - `**` 匹配零个或多个路径段;
448
+ - 普通路径没有通配符时按**明确文件**处理;
449
+ - 不允许绝对路径、`..`、workspace 外路径、symlink;
450
+ - 保留路径永远拒绝:
451
+ - `.agents/gate/artifact-policy.json`
452
+ - `.agents/notes/**`
453
+ - 只写文件;父目录可以由工具创建,但也要通过边界检查。
454
+
455
+ #### 如何按项目填写
456
+
457
+ 只允许一个固定 PRD 文件:
458
+
459
+ ```json
460
+ {
461
+ "version": 1,
462
+ "artifacts": {
463
+ "prd": {
464
+ "phases": ["discuss"],
465
+ "roles": ["root"],
466
+ "paths": ["docs/prd/current.md"]
467
+ }
468
+ }
469
+ }
470
+ ```
471
+
472
+ 允许按命名规则新建多个 PRD:
473
+
474
+ ```json
475
+ {
476
+ "version": 1,
477
+ "artifacts": {
478
+ "prd": {
479
+ "phases": ["discuss"],
480
+ "roles": ["root"],
481
+ "paths": ["docs/prd/PRD-*.md"]
482
+ }
483
+ }
484
+ }
485
+ ```
486
+
487
+ 允许 research 在 discuss 和 plan 写文档目录:
488
+
489
+ ```json
490
+ {
491
+ "version": 1,
492
+ "artifacts": {
493
+ "research": {
494
+ "phases": ["discuss", "orchestrating/plan"],
495
+ "roles": ["root", "worker"],
496
+ "paths": ["docs/research/**/*.md", ".scratch/research/**"]
497
+ }
498
+ }
499
+ }
500
+ ```
501
+
502
+ #### 相关工具与命令
503
+
504
+ - `gate_artifact_write({ kind, path, content })`:root/worker 按 policy 写文件;
505
+ - `gate_research_dispatch({ question, purpose? })`:root-only,在 discuss/plan 派 research worker;
506
+ - `/gate-prd [主题]`:discuss 用户命令,加载 `gate-prd` skill 并通过 artifact policy 写 PRD;
507
+ - `gate-handoff`:用户级 skill,产物写入 `.scratch/handoff/`。
508
+
509
+ 普通 `write`/`edit`/`apply_patch`/写型 shell 不受 artifact policy 放行,仍按 phase/role 矩阵处理。
510
+
511
+ #### 常见失败
512
+
513
+ | 错误 | 原因 |
514
+ |---|---|
515
+ | `artifact-policy-invalid` | policy 缺失、JSON 无效、version 不是 1、字段非法 |
516
+ | `artifact-denied` | kind 不存在、phase 不匹配、role 不匹配、path 不在白名单、blocked、保留路径、越界或 symlink |
517
+ | `subagents-unavailable` | research dispatch 时 `ctx.subagents` 不可用 |
518
+ | `wrong-phase` | research dispatch 不在 discuss 或 `orchestrating/plan` |
519
+
520
+ 修改 policy 后不需要重启 DSH;每次 artifact 写入都会重新读取文件。
521
+
522
+ ### 插件 Config
335
523
 
336
524
  ```json
337
525
  { "reviewLimit": 5 }
@@ -339,6 +527,7 @@ gate_status()
339
527
 
340
528
  `reviewLimit` 是每个 review 节点的最大轮次;默认 5,范围 1–20。达到上限仍有 findings 时进入 blocked。
341
529
 
530
+
342
531
  ## 使用边界
343
532
 
344
533
  - gate 是流程门禁,不是 OS 安全边界;未知工具和任意 shell 语义不会被完整分析。