shipgate-cli 0.0.0-stage → 0.2.1

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 (122) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +258 -2
  3. package/agents/context-builder.md +158 -0
  4. package/agents/debug-executor.md +234 -0
  5. package/assets/gates/classifier.js +245 -0
  6. package/assets/gates/dsh/index.js +767 -0
  7. package/assets/gates/dsh/policy.json +93 -0
  8. package/assets/gates/index.js +3 -0
  9. package/assets/gates/pi/index.js +1121 -0
  10. package/assets/gates/pi/policy.json +93 -0
  11. package/assets/gates/policy.js +4199 -0
  12. package/assets/gates/profiles/ai4s-dry-lab.json +64 -0
  13. package/assets/gates/profiles/ai4s-quant.json +36 -0
  14. package/assets/pi-extensions/auto-continue.ts +176 -0
  15. package/assets/pi-extensions/goal-mode.ts +313 -0
  16. package/bin/shipgate.mjs +9 -0
  17. package/commands/ai-spec.md +9 -0
  18. package/commands/api-first.md +33 -0
  19. package/commands/code-review.md +7 -0
  20. package/commands/codebase-context.md +19 -0
  21. package/commands/debug-ui.md +147 -0
  22. package/commands/debug.md +101 -0
  23. package/commands/dev-env-scan.md +18 -0
  24. package/commands/dev-host-init.md +28 -0
  25. package/commands/discover-skill-opportunities.md +33 -0
  26. package/commands/fork-sync.md +17 -0
  27. package/commands/gh-actions.md +26 -0
  28. package/commands/goal-driven-development.md +7 -0
  29. package/commands/intent-grill.md +7 -0
  30. package/commands/iteration-manager.md +7 -0
  31. package/commands/loop-engineer.md +21 -0
  32. package/commands/nodejs-npm-auto-release.md +12 -0
  33. package/commands/prd.md +7 -0
  34. package/commands/project-health-audit.md +7 -0
  35. package/commands/ralph-yolo.md +346 -0
  36. package/commands/ralph.md +226 -0
  37. package/commands/security-audit.md +7 -0
  38. package/commands/ux-experience-audit.md +133 -0
  39. package/docs/ARCHITECTURE.md +63 -0
  40. package/docs/GATES.md +106 -0
  41. package/docs/HARNESS.md +215 -0
  42. package/package.json +48 -4
  43. package/references/ADR-FORMAT.md +67 -0
  44. package/references/CONTEXT-FORMAT.md +62 -0
  45. package/references/mcp-config-template.json +54 -0
  46. package/scripts/fix-skill-frontmatter.mjs +66 -0
  47. package/scripts/migrate-skillpack.mjs +257 -0
  48. package/skills/ai-spec/SKILL.md +90 -0
  49. package/skills/api-first-modular/SKILL.md +411 -0
  50. package/skills/code-debugger/SKILL.md +379 -0
  51. package/skills/code-review/SKILL.md +62 -0
  52. package/skills/codebase-context/SKILL.md +139 -0
  53. package/skills/debug-ui/SKILL.md +220 -0
  54. package/skills/dev-env-scan/SKILL.md +147 -0
  55. package/skills/dev-host-init/SKILL.md +198 -0
  56. package/skills/dev-host-init/scripts/fill-placeholders.py +226 -0
  57. package/skills/dev-host-init/scripts/host-scan.ps1 +159 -0
  58. package/skills/dev-host-init/scripts/host-scan.sh +201 -0
  59. package/skills/dev-host-init/scripts/render-now.py +488 -0
  60. package/skills/dev-host-init/scripts/tools-catalog.py +229 -0
  61. package/skills/dev-host-init/templates/graph-first-gate.ts +291 -0
  62. package/skills/dev-host-init/templates/host-injection.template.md +725 -0
  63. package/skills/discover-skill-opportunities/SKILL.md +145 -0
  64. package/skills/discover-skill-opportunities/references/accounting-finance-ops.md +24 -0
  65. package/skills/discover-skill-opportunities/references/business-consulting.md +24 -0
  66. package/skills/discover-skill-opportunities/references/evidence-and-privacy.md +39 -0
  67. package/skills/discover-skill-opportunities/references/finance-investment.md +24 -0
  68. package/skills/discover-skill-opportunities/references/legal-and-compliance.md +24 -0
  69. package/skills/discover-skill-opportunities/references/output-contract.md +75 -0
  70. package/skills/discover-skill-opportunities/references/product-and-operations.md +24 -0
  71. package/skills/discover-skill-opportunities/references/quant-trading.md +24 -0
  72. package/skills/discover-skill-opportunities/references/scientific-research.md +24 -0
  73. package/skills/discover-skill-opportunities/references/scoring-rubric.md +45 -0
  74. package/skills/discover-skill-opportunities/references/session-skill-review.md +78 -0
  75. package/skills/discover-skill-opportunities/references/software-development.md +24 -0
  76. package/skills/fork-sync/SKILL.md +86 -0
  77. package/skills/gh-actions-architect/SKILL.md +395 -0
  78. package/skills/goal-driven-development/SKILL.md +132 -0
  79. package/skills/intent-grill/SKILL.md +46 -0
  80. package/skills/iteration-manager/SKILL.md +53 -0
  81. package/skills/loop-engineer/SKILL.md +108 -0
  82. package/skills/nodejs-npm-auto-release/SKILL.md +141 -0
  83. package/skills/prd/SKILL.md +63 -0
  84. package/skills/project-health-audit/SKILL.md +64 -0
  85. package/skills/ralph/SKILL.md +329 -0
  86. package/skills/ralph-yolo/SKILL.md +623 -0
  87. package/skills/security-audit/SKILL.md +114 -0
  88. package/skills/security-audit/references/audit-checklist.md +135 -0
  89. package/skills/security-audit/references/evidence-conventions.md +54 -0
  90. package/skills/security-audit/references/findings-schema.md +37 -0
  91. package/skills/security-audit/references/stack-signatures.md +66 -0
  92. package/skills/shipgate/SKILL.md +40 -0
  93. package/skills/shipgate-install/SKILL.md +87 -0
  94. package/skills/shipgate-quality/SKILL.md +80 -0
  95. package/skills/shipgate-security/SKILL.md +97 -0
  96. package/skills/shipgate-spec/SKILL.md +67 -0
  97. package/skills/ux-experience-audit/SKILL.md +202 -0
  98. package/src/cli.mjs +117 -0
  99. package/src/commands/ask.mjs +82 -0
  100. package/src/commands/deploy.mjs +589 -0
  101. package/src/commands/gates.mjs +83 -0
  102. package/src/commands/policy.mjs +67 -0
  103. package/src/gates/quality.mjs +123 -0
  104. package/src/gates/security.mjs +92 -0
  105. package/src/gates/ship.mjs +74 -0
  106. package/src/gates/spec.mjs +88 -0
  107. package/src/harness/index.mjs +203 -0
  108. package/src/inject/render.mjs +75 -0
  109. package/src/lib/cfg.mjs +66 -0
  110. package/src/lib/engines.mjs +182 -0
  111. package/src/lib/exec.mjs +80 -0
  112. package/src/lib/fsx.mjs +119 -0
  113. package/src/lib/gate.mjs +288 -0
  114. package/src/lib/log.mjs +31 -0
  115. package/src/lib/skills.mjs +347 -0
  116. package/src/lib/state.mjs +41 -0
  117. package/src/lib/update.mjs +67 -0
  118. package/src/version.mjs +14 -0
  119. package/templates/agents-snippet.md +82 -0
  120. package/templates/dev-profile.schema.json +119 -0
  121. package/templates/prd.json.example +64 -0
  122. package/templates/rule.json.example +28 -0
@@ -0,0 +1,63 @@
1
+ # 架构
2
+
3
+ 三层,职责不许越界:
4
+
5
+ ```
6
+ bin/shipgate.mjs ─► src/cli.mjs(解析 argv、加载配置、分发)
7
+ │
8
+ ┌───────────────┼────────────────┬──────────────────┐
9
+ ▼ ▼ ▼ ▼
10
+ src/gates/* src/harness/* src/inject/* src/lib/*
11
+ 判断过不过 知道装到哪 幂等写注入 fsx/exec/cfg/state/skills/update
12
+ ```
13
+
14
+ ## 1. 闸层(`src/gates/`)
15
+
16
+ 每个闸输出统一的 `Verdict`:
17
+
18
+ ```js
19
+ { gate, ok, code, summary, findings[], evidence }
20
+ ```
21
+
22
+ - `code` 就是路由结论:`0` 通过 / `1` 拦下 / `2` 用法错 / `3` 环境缺。
23
+ - 闸不写文件、不装东西。`quality` / `security` 只做**委派**(调 aislop / 检查 cbh),不重写引擎逻辑。
24
+ - `spec` 与 `ship` 是内置判据(契约完整性、manifest 一致性)。
25
+
26
+ ## 2. 适配层(`src/harness/`)
27
+
28
+ 一份 `harness profile`:
29
+
30
+ ```js
31
+ { id, label, detect, skills, inject, gate }
32
+ ```
33
+
34
+ `gate` 只有自由度高的 harness 才需要(pi / dsh),指向 `assets/gates/` 里那份 vendored 硬门控产物(classifier / policy 引擎 / pi 与 dsh 两套适配 / profiles)。Claude Code / Codex / Gemini / Cursor / Kimi / Antigravity 不带 `gate`,靠 skills + 注入文档约束——文档里明确写"软约束",不假装有硬门控。
35
+
36
+ 技能落点:pi 与 dsh 共用 `~/.agents/skills`(dsh 的原生用户技能根;`~/.dsh/skills` 不是,写那里会变成 dsh 读不到的死代码),Antigravity 用 `~/.gemini/antigravity/skills`,其余见 `docs/HARNESS.md` 的矩阵。
37
+
38
+ ## 3.5 技能包
39
+
40
+ `skills/` 是随包分发的 27 个开发 skill(22 个全周期 + 5 个闸用法),`commands/` 22 个 slash command,`agents/` 2 个 subagent。安装时按 harness 能力落到对应目录(见 `docs/HARNESS.md`),清单从磁盘扫描而来,新增 skill 不需要改代码。
41
+
42
+ 自定义 harness 从 `~/.config/shipgate/config.json` 的 `custom` 读取,不改代码就能接新 agent。
43
+
44
+ ## 3. 渲染层(`src/inject/`)
45
+
46
+ 注入 = 托管区块,幂等是硬要求:
47
+
48
+ - 区块内不含时间戳 → 同样输入必出同样字节。
49
+ - 区块外内容永不改写;没有区块时只**追加**。
50
+ - 每次改写前留 `*.shipgate-bak.<YYYYMMDD>`(每天一份,避免刷屏)。
51
+
52
+ ## 数据落点
53
+
54
+ | 文件 | 作用 |
55
+ |---|---|
56
+ | `~/.config/shipgate/config.json` | 全局配置(harness 列表、阈值、自动更新) |
57
+ | `~/.config/shipgate/manifest.json` | 受管状态(每 harness 的 skills hash、注入版本、安装时间) |
58
+ | `~/.cache/shipgate/last-update-check` | 每日一次更新检查的日期戳 |
59
+ | `<repo>/.shipgate/config.json` | 项目级覆盖(阈值、spec 目录、scope) |
60
+
61
+ ## 零依赖
62
+
63
+ 运行时只用 Node 内置模块(`fs` / `path` / `child_process` / `crypto` / `fetch`)。理由:这台机器只有 8 GiB 内存且常年吃紧,任何依赖都会让 `install` 变成不确定事件。
package/docs/GATES.md ADDED
@@ -0,0 +1,106 @@
1
+ # 四道闸
2
+
3
+ | 闸 | 管什么 | 触发 | 引擎 | 通过判据 |
4
+ |---|---|---|---|---|
5
+ | spec | 改动有没有成立的契约 | 任何代码改动前 | 内置 | `tasks/CHG-*/` 三件齐全 + SPEC status 非 draft + 有 AC |
6
+ | quality | AI 留下的 slop | 每次编辑后 / 提交前 | aislop | `score >= min` 且无 error 级发现 |
7
+ | security | 授权范围内的漏洞面 | 提交前 / 发布前(显式) | cbh | scope 合法 + 引擎在 + 人为确认 |
8
+ | ship | 产物是否装到位 | 装 / 升级 / 换 harness | 内置 | manifest 与磁盘一致 |
9
+
10
+ ## 退出码
11
+
12
+ | 码 | 含义 | 下一步 |
13
+ |---|---|---|
14
+ | 0 | 通过 | 继续 |
15
+ | 1 | 闸拦下 | 读 findings,修完重跑;不要改阈值绕过 |
16
+ | 2 | 用法错 | 例如 security 缺 `--scope` |
17
+ | 3 | 环境缺 | 引擎未装 / 输出无法解析 |
18
+
19
+ code 3 有两种含义,先分清再动手:
20
+
21
+ | 现象 | 含义 | 处置 |
22
+ |---|---|---|
23
+ | `aislop 未安装` / `cbh 未安装` | 引擎不在 PATH | `shipgate doctor` 里的 install 列给的命令可直接执行 |
24
+ | `aislop 输出无法解析(exit=…)` | 引擎在但跑不起来 | 单独跑 `aislop scan . --json` 看真实报错;`.cmd` 垫片启动问题、引擎崩溃都在这一类 |
25
+
26
+ ### 引擎自检
27
+
28
+ ```bash
29
+ shipgate doctor # 引擎节:绝对路径 + 版本 +「bin 目录不在 PATH」告警
30
+ which aislop && aislop doctor # Formatting/Linting/Code Quality/AI Slop 全 ready
31
+ which cbh && cbh --help # cbh 无 --version,只能看子命令
32
+ ```
33
+
34
+ 引擎是**进程级共享**的:装在 PATH 上一次,所有 harness 的 shell 工具都能调;只有**闸用法 skill** 是按 harness 分发的。
35
+
36
+ ## spec 闸细节
37
+
38
+ - 扫描 `cfg.spec.dir`(默认 `tasks`)下的 `CHG-*` 目录;也可直接指向一个 CHG 目录。
39
+ - 缺件、`status: draft`、无验收判据都判不通过。
40
+ - **没有 CHG 目录也判不通过**——"无契约"正是它要拦的情况。
41
+
42
+ ## quality 闸细节
43
+
44
+ - 调 `aislop scan <dir> --json`,自己按 `--min` 判定,不依赖项目 `.aislop/config.yml`。
45
+ - `scoreable: false`(引擎未跑起来)按不通过处理,summary 里列出 `coverage.failedEngines`。
46
+ - 阈值优先级:`--min` > 项目 `.shipgate/config.json` > 全局配置 > 80。
47
+
48
+ ### 引擎级错误(`engine-error`)与“未安装”、“输出无法解析”的区别
49
+
50
+ | 现象 | 含义 | 退出码 | 处置 |
51
+ |---|---|---|---|
52
+ | `aislop 未安装` / `cbh 未安装` | 引擎不在 PATH | 3 | 按 `shipgate doctor` 给的命令装 |
53
+ | `aislop 输出无法解析(exit=…)` | aislop 本身没跑起来 | 3 | 单独跑 `aislop scan . --json` 看真实报错 |
54
+ | `无法评分(ruff 引擎报错)` | aislop 跑了,但底层引擎崩了(诊断里是 `<engine>/engine-error`) | 3 | 看 `evidence.hint`;典型是老 glibc 上 aislop 自带的 Python 引擎加载失败 |
55
+ | `score < min` / `N 个 error 级发现` | 代码问题 | 1 | `aislop fix` 或改代码 |
56
+
57
+ 判据:只有 `rule` 以 `engine-error` 结尾的诊断算引擎级错误;普通 finding 仍按 error 计,不会被降级成“环境问题”。
58
+
59
+ 典型根因(实测):aislop 0.23.0 的 `tools/python/linux-x64/aislop-python` 要求 GLIBC ≥ 2.34。Ubuntu 20.04(2.31)上它静默失败,ruff 输出为空 → aislop 记一条 `ruff/engine-error`。处置:`chmod a-x <该二进制>`(回退到 PATH 上的 ruff),`shipgate doctor` 会在引擎节直接报 `AISLOP_PYTHON_ENGINE_UNUSABLE` 并给出带绝对路径的命令。
60
+
61
+ ## security 闸细节
62
+
63
+ - 只做**前置合规校验**:scope 存在、非空、有范围段落、cbh 在。
64
+ - 不自动发探测包(红线)。通过后打印 `cbh recon/surface/classify/triage` 的下一步。
65
+ - cbh 实际子命令:`recon` / `surface` / `diff` / `classify` / `triage` / `report` / `scope`;**没有 `--version`**(查版本用 `pip show claude-bughunter`)。
66
+ - 想把它变成自动扫描器是错的:主动探测在错误范围上会构成违法。
67
+
68
+ ## ship 闸细节
69
+
70
+ 校验每个受管 harness:
71
+
72
+ 1. manifest 里记录的 skill 文件都在,且与源逐文件一致(判据同 `installSkills`:目的自加文件不算漂移);
73
+ 2. 注入文件里有 `<!-- shipgate:begin vN -->` 区块,**且版本等于当前模板的版本**(旧版残留区块算漂移);
74
+ 3. 带 gate 的 harness 有 `policy.js` 等硬门控产物。
75
+
76
+ 谁能让它失败:
77
+
78
+ | 命令 | 行为 |
79
+ |---|---|
80
+ | `shipgate doctor` | 跑一遍一致性检查;有 finding 时退出码 1(体检必须能红) |
81
+ | `shipgate status --strict` | 同样的检查;不一致时退出码 1,适合 CI |
82
+ | `shipgate status` | 默认只是状态表,不校验、不改退出码 |
83
+
84
+ ## 技能包与闸的联动
85
+
86
+ 四道闸不是孤立的命令:技能包里的 skill 会在对应时机调用它们。
87
+
88
+ | 阶段 | skill | 触发哪道闸 |
89
+ |---|---|---|
90
+ | 立项 / 改需求 | `ai-spec`、`prd`、`intent-grill` | 写完后 `shipgate spec check` |
91
+ | 写代码 | `goal-driven-development`、`ralph` | 每次编辑后 `shipgate quality` |
92
+ | 调试 | `code-debugger`、`debug-ui` | 修完 `shipgate quality` |
93
+ | 审查 | `code-review`、`security-audit` | `shipgate quality` + `shipgate security --scope` |
94
+ | 发布 | `nodejs-npm-auto-release`、`gh-actions-architect` | 提交前两道闸都要绿 |
95
+
96
+ 纪律:skill 负责「怎么做」,闸负责「过不过」。skill 写完代码不能自己宣告完成,必须跑闸拿到退出码。
97
+
98
+ ## 硬门控与闸的区别(别混)
99
+
100
+ | | 硬门控(gate bundle) | 四道闸(shipgate gates) |
101
+ |---|---|---|
102
+ | 作用时机 | agent 执行命令时 | 阶段交付时 |
103
+ | 拦截方式 | 进程级:直接拦下命令 | 退出码:判不通过,交给人/agent 修 |
104
+ | 覆盖 harness | pi / dsh(有 hook 面) | 全部 |
105
+ | 策略来源 | `shipgate policy` | `shipgate quality --min` 等 |
106
+
@@ -0,0 +1,215 @@
1
+ # harness 矩阵与适配
2
+
3
+ ## 内置
4
+
5
+ | id | 标签 | 探测路径 | skills | commands | agents | 注入文件 | 硬门控 |
6
+ |---|---|---|---|---|---|---|---|
7
+ | `claude` | Claude Code | `~/.claude` | `~/.claude/skills` | `~/.claude/commands` | `~/.claude/agents` | `~/.claude/CLAUDE.md` | — |
8
+ | `pi` | pi agent | `~/.pi` | `~/.agents/skills` | `~/.pi/agent/prompts` | — | `~/.pi/agent/APPEND_SYSTEM.md` | `~/.pi/agent/extensions/enforce-rules` |
9
+ | `dsh` | dsh | `~/.dsh` | `~/.agents/skills`(与 pi 同一链接) | — | — | `~/.dsh/AGENTS.md` | `~/.dsh/extensions/enforce-rules` |
10
+ | `codex` | Codex CLI | `~/.codex` | `~/.codex/skills` | — | — | `~/.codex/AGENTS.md` | — |
11
+ | `gemini` | Gemini CLI | `~/.gemini` | `~/.gemini/skills` | — | — | `~/.gemini/GEMINI.md` | — |
12
+ | `cursor` | Cursor | `~/.cursor` | `~/.cursor/skills` | — | — | `~/.cursor/rules/shipgate.mdc` | — |
13
+ | `kimi` | Kimi Code | `~/.kimi-code` | `~/.kimi-code/skills` | —(官方不支持 Claude commands) | — | `~/.kimi-code/AGENTS.md` | — |
14
+ | `antigravity` | Antigravity | `~/.antigravity` | `~/.gemini/antigravity/skills` | — | — | —(全局规则路径未验证) | — |
15
+
16
+ ### Cursor 的 skills 依据(2026-11-28 实测)
17
+
18
+ `skills: null` 是过期声明,已改为 `~/.cursor/skills`:
19
+
20
+ - 用户级 skill 已存在于 `~/.cursor/skills/shidianguji-fetcher/SKILL.md`;
21
+ - `~/.cursor/skills-cursor/` 下有 20 个 Cursor 内置 skill(`create-skill`、`create-rule`、`loop`、`babysit` …),说明 Agent Skills 已在该版本落地;
22
+ - 写入用户级路径与官方内置同构,不会覆盖内置集(内置在 `skills-cursor/`,分发只写 `skills/`)。
23
+
24
+ ### 引擎共享,指导分发
25
+
26
+ `aislop` / `cbh` 是**进程级依赖**:装在 PATH 上一次,claude / pi / dsh / codex / gemini / cursor / kimi / antigravity 的 shell 工具都能调。ShipGate 不需要也不应该给每个 harness 装一份引擎。
27
+
28
+ 按 harness 分发的是**闸用法 skill**(`shipgate-quality` / `shipgate-security`):每个 harness 的 skills 根各一份,内容相同。所以多 agent 环境下的验收是两件事:
29
+
30
+ 1. `shipgate doctor` 引擎节全绿、且没提示「bin 目录不在 PATH」;
31
+ 2. 各 harness 的 skills 根里都有这两份 skill(`shipgate status` 的 skills 列不为 0)。
32
+
33
+ ### 未纳入:ZCode
34
+
35
+ ZCode 是智谱的 GUI IDE,**本机未安装**(无 `~/.zcode`),且 3.0 起切换自有 Agent 内核、不再内置其他 Agent 适配。当前的诚实处理是**不假装支持**:
36
+
37
+ - `shipgate doctor` 不会列出 zcode(未探测到)。
38
+ - 若将来机器上出现 `~/.zcode/skills`,按下面的「自定义 harness」用 `custom` 配置接入,不改代码。
39
+ - 探测方式:`ls -d ~/.zcode ~/AppData/Roaming/ZCode 2>/dev/null`。
40
+
41
+ ### Antigravity 的两个路径别混
42
+
43
+ | 用途 | 路径 |
44
+ |---|---|
45
+ | 全局 skills(ShipGate 写这里) | `~/.gemini/antigravity/skills/<name>/SKILL.md` |
46
+ | 项目级 skills | `<repo>/.agent/skills/` |
47
+ | IDE 自身设置 | `~/.antigravity/settings.json`(不入本工具受管) |
48
+
49
+ 注意单复数:Antigravity 项目级是 **`.agent`**,pi/dsh 的共享技能根是 **`.agents`**,两者不是同一个目录。
50
+
51
+ 能力缺失不是缺陷:harness 没有对应目录就跳过,并在输出里写明「commands 跳过:harness 无 commands 目录」,不静默。
52
+
53
+ **pi 的 prompts 就是它的 slash command 目录**:格式(frontmatter `description` + `# /name`)与 ShipGate 的 `commands/*.md` 一致,所以 22 个命令原样复用。目标位置已有同名文件时(比如你自己手写的 prompt),ShipGate 会备份为 `*.shipgate-bak.<日期>` 并在输出里明确报出「覆盖了 N 个」,不会静默覆盖。
54
+
55
+ ## 两类 harness,两种约束策略
56
+
57
+ **成熟 harness(claude / codex / gemini / cursor / kimi / antigravity)**:有各自的权限与工具治理面,ShipGate 没有可挂的 hook。给它们 skills + 注入文档,靠「agent 读到规则后自觉 + `shipgate quality` 可验证」——文档里明确标注**软约束**。
58
+
59
+ **自由度高的 harness(pi / dsh 等)**:能自由读源码、跑命令。除 skills + 注入外,装一份进程级硬门控产物:破坏性命令分级拦截、跳层直读拦截、受保护工作区清场拦截。
60
+
61
+ ## 装备清单
62
+
63
+ | 资产 | 源目录 | 目标 |
64
+ |---|---|---|
65
+ | skills | `skills/<name>/SKILL.md`(27 个) | `<harness>/skills/<name>/` |
66
+ | commands | `commands/*.md`(22 个) | `<harness>/commands/`(仅 claude) |
67
+ | agents | `agents/*.md`(2 个) | `<harness>/agents/`(仅 claude) |
68
+ | 注入 | `templates/agents-snippet.md` | `<harness>` 入口文档的托管区块 |
69
+ | 硬门控 | `assets/gates/**` | `<harness gate.dest>` |
70
+
71
+ skills 的分发判据是**整棵目录摘要**(`hashTree`):入口 `SKILL.md`、`scripts/`、`references/`、模板任一变化都会重拷;并逐源文件比对目的目录(`sourceTreeDrift`),被篡改或半拷贝的技能会在下次 `install` 自愈。目的端用户自己加的文件不算漂移,不会造成每次安装都报“有变化”。
72
+
73
+ ## 硬门控产物
74
+
75
+ `assets/gates/` 是 vendored 产物,源出 `agent-config-bridge` 的 `bridge/gates/`:
76
+
77
+ ```
78
+ assets/gates/
79
+ ├── index.js 扩展入口
80
+ ├── classifier.js 命令分类
81
+ ├── policy.js 策略引擎
82
+ ├── pi/index.js pi 适配
83
+ ├── pi/policy.json pi 默认策略
84
+ ├── dsh/index.js dsh 适配
85
+ ├── dsh/policy.json dsh 默认策略
86
+ └── profiles/ 域配置(ai4s 等)
87
+ ```
88
+
89
+ `policy.json` 由 `shipgate policy` 管理:真源是 `~/.config/shipgate/gate-policy.json`,各 harness 的 `policy.json` 是它的投影。
90
+
91
+ 合并方向是**出厂文档为 base、真源只提供 config**:
92
+
93
+ | 层 | 提供什么 | 为什么 |
94
+ |---|---|---|
95
+ | `assets/gates/<kind>/policy.json` | `checks` / `reminder` / `description` / `version` | 每个 kind 的规则文档不一样(pi v6、dsh v7);拿别处的文档当 base 就会让一个 harness 的旧副本变成另一个的规则 |
96
+ | harness 既有 `policy.json` 的 `config` | 机器本地设置 | 提升回真源,`--sync` 才能一致投影 |
97
+ | 真源 `gate-policy.json` 的 `config` | 授权与阈值(最终裁定) | 唯一真源;protected worktrees 安装时取并集、之后严格按真源覆盖,所以 `--rm-protected` 能真正生效 |
98
+
99
+ 真源文件因此只含 `config`。安装/同步都是幂等的:重复执行不会把文档字段写回真源。
100
+
101
+ ### 入口与模块格式(per-kind)
102
+
103
+ `assets/gates/index.js` 是 **pi** 的入口,不能原样复制给 dsh:
104
+
105
+ | 产物 | pi | dsh |
106
+ |---|---|---|
107
+ | `index.js` | `export { default } from './pi/index.js'` | `export { apply, inject } from './dsh/index.js'` |
108
+ | `package.json` | 不写 | `{"type":"module"}`(否则 Node 按 CJS 解析,插件在 `export` 处就失败) |
109
+
110
+ 安装时按 `harness.gate.kind` 写对应入口,未知 kind 回退到 pi 入口、不写 `package.json`。dsh 的实际挂载行仍是操作者的事(`cordis.patch.yml` 属 dsh 设置面),但挂上之后产物必须能加载。
111
+
112
+ 升级方式:bridge 侧变更后重新导出覆盖该目录,CHANGELOG 记录来源 hash。
113
+
114
+ ## `~/.agents/skills` 归属(避免两个项目抢同一目录)
115
+
116
+ 本机 `~/.agents/skills` 是指向 `~/.claude/skills` 的链接(pi 与 dsh 都把 `.agents/skills` 当原生技能根)。分工必须明确:
117
+
118
+ | 谁 | 对 `~/.agents/skills` 做什么 |
119
+ |---|---|
120
+ | `agent-config-bridge` | 负责**创建/维护**这条链接(adopt pi 时) |
121
+ | ShipGate | 只做**复制**;检测到链接时**跟随**到真实目标,不建链、不删链 |
122
+
123
+ 因此两者同时存在时,写入落到同一份(`~/.claude/skills`),幂等且不产生第二份副本。`install --dry-run` 会打印 `skills → <真实路径>(跟随链接 <声明路径>)`;链接断开则 fail-closed 报错,并提示去 bridge 重建链接。
124
+
125
+ ## 续跑扩展(可选,不进默认安装)
126
+
127
+ `assets/pi-extensions/` 下有 `goal-mode.ts` 与 `auto-continue.ts`(源出 agent-config-bridge,ShipGate 现在拥有维护责任)。二者都驱动轮次边界,**互斥**:
128
+
129
+ ```bash
130
+ shipgate install --with-goal-mode # 带预算与空转保护
131
+ shipgate install --with-auto-continue # 无轮数上限
132
+ ```
133
+
134
+ 同时指定 → 退出码 2。目标已存在会先备份 `*.shipgate-bak.<日期>` 再覆盖。
135
+
136
+ ## 遗留门控检测(doctor)
137
+
138
+ `shipgate doctor` 会报告与 agent-config-bridge 并存导致的冲突,**只报告不自动删**:
139
+
140
+ | code | 含义 | 处理 |
141
+ |---|---|---|
142
+ | `LEGACY_GATE_DUPLICATE` | pi 同时装了 `coding-gateways`(bridge) 与 `enforce-rules`(ShipGate) | 按提示停用其中一份 |
143
+ | `LEGACY_POLICY_SOURCE` | 存在第二份 policy 真源 `~/.config/agent-config-bridge/gate-policy.json` | 统一到 `~/.config/shipgate/gate-policy.json` |
144
+ | `DSH_GATE_MISMOUNT` | dsh 的 cordis.patch 挂的不是 `enforce-rules` | 改挂接行指向 ShipGate 产物 |
145
+
146
+ ## skill 根卫生(doctor)
147
+
148
+ skills 根是**共用**资源:`~/.agents/skills` 是 `~/.claude/skills` 的链接,pi / dsh / claude 读的是同一份。往里塞任何非 skill 的东西都会变成 skill,因此有三条约定。
149
+
150
+ ### 约定 1:备份永远落在根外
151
+
152
+ 清理命令的落点是 `~/.config/shipgate/backups/<kind>-<YYYY-MM-DD>/`,**不是** `<skillsRoot>/_flat-backup`。
153
+
154
+ 原因(pi 1.4.0 `dist/core/skills.js` 实读):
155
+
156
+ | 加载规则 | 后果 |
157
+ |---|---|
158
+ | `name = frontmatter.name ?? parentDirName` | 备份目录里的 `*.md` 若没有 `name:`,名字变成目录名(`_flat-backup` → 非法字符告警) |
159
+ | 非 `SKILL.md` 文件只要有 `description` 就加载 | 旧版扁平 skill 被重新注册 |
160
+ | 同名后到者 skipped | 被跳过的是**新版目录**,生效的是**旧版扁平文件** —— 静默降级 |
161
+
162
+ 改前实测:`~/.claude/skills/_flat-backup/` 让 pi 报出 21 条 collision + 10 条 warning(10 个真实同名、10 个伪名、1 个 `skills` 伪名)。
163
+
164
+ ### 约定 2:`doctor` 报四类发现
165
+
166
+ | code | 判据 | 处置 |
167
+ |---|---|---|
168
+ | `FLAT_SKILL_DUPLICATE` | 根内 `<name>.md` 与 `<name>/SKILL.md` 并存 | 给「移到根外备份目录」的命令 |
169
+ | `SKILL_STRAY_DIR` | 根的直接子目录无 `SKILL.md` 但有 `.md` | 同上(这种目录一旦被当 skill path 传入就会产生伪技能) |
170
+ | `SKILL_NAME_COLLISION` | 同一 root 内多个文件声明同一 `name` | 只报告,列出 winner / 被跳过者 |
171
+ | `SKILL_INVALID_NAME` / `SKILL_DESCRIPTION_TOO_LONG` | 不满足 `^[a-z0-9-]+$`、≤64、无 `--`;`description` > 1024 | 只报告,要求在**源 skill** 里改(改分发副本会被下次 install 覆盖) |
172
+
173
+ 全部**只报告不删除**;命令按平台生成(Windows → `Move-Item`,POSIX → `mv`)。同一物理目录被多个 harness 共用时只报一次并列出共用者。
174
+
175
+ ### 约定 3:分发物在出厂前就校验
176
+
177
+ `node scripts/migrate-skillpack.mjs --check` 与单测同时校验 27 个 skill 的 `name` / `description` 取值,所以超规内容在 CI 就红,不会等 pi 启动才告警。
178
+
179
+ ### 边界:agent-config-bridge 不写 skills 根
180
+
181
+ 核查结论(2026-11-28):
182
+
183
+ - `bridge/lib/source.js` 的 `scanSkills` 只认「目录且含 `SKILL.md`」,扁平 `.md` 仅进 `flatDuplicates` 计数,从不桥接;
184
+ - 全仓 `flat-backup` 命中 0;
185
+ - 备份落点是 `backupsDir(repo) = <repo>/.bridge/backups`(`bridge/lib/paths.js`),在 skills 根之外。
186
+
187
+ 因此根目录卫生由 ShipGate 单方面负责:**不往根里塞东西 + 报告根里的问题**。
188
+
189
+ ## 自定义 harness
190
+
191
+ ```jsonc
192
+ // ~/.config/shipgate/config.json
193
+ {
194
+ "harnesses": ["claude", "pi"],
195
+ "custom": {
196
+ "dsh": {
197
+ "label": "DSH",
198
+ "detect": "~/.dsh",
199
+ "skills": "~/.dsh/skills",
200
+ "inject": "~/.dsh/AGENTS.md",
201
+ "gate": { "dest": "~/.dsh/extensions/enforce-rules", "kind": "dsh" }
202
+ }
203
+ }
204
+ }
205
+ ```
206
+
207
+ 规则:
208
+ - `detect` 省略 → 视为总是存在(允许安装)。
209
+ - `skills` / `commands` / `agents` 为 null → 跳过对应分发(像 cursor)。
210
+ - `gate` 省略 → 软约束;`gate.kind` 决定用 `pi` 还是 `dsh` 适配。
211
+ - 改完配置直接 `shipgate install --harness dsh`,不需要改代码。
212
+
213
+ ## 为什么注入区块而不是整文件
214
+
215
+ 每个 harness 的入口文档都是用户长期手写的(本机实测:CLAUDE.md 479 行、AGENTS.md 387 行、GEMINI.md 335 行)。ShipGate 只追加/替换带标记的一段,且首次改动前备份 `*.shipgate-bak.<日期>`。这样 `revoke` 能真正回到装之前的状态。
package/package.json CHANGED
@@ -1,6 +1,50 @@
1
1
  {
2
2
  "name": "shipgate-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.1",
4
+ "description": "ShipGate — the full-lifecycle gate chain for AI-written code: 27 dev skills, spec/quality/security/ship gates, hard gates, and one-command deployment across coding harnesses.",
5
+ "type": "module",
6
+ "bin": {
7
+ "shipgate": "bin/shipgate.mjs"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "src",
12
+ "skills",
13
+ "commands",
14
+ "agents",
15
+ "references",
16
+ "templates",
17
+ "assets",
18
+ "scripts",
19
+ "docs",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "engines": {
24
+ "node": ">=20"
25
+ },
26
+ "scripts": {
27
+ "test": "node --test test/*.test.mjs",
28
+ "doctor": "node bin/shipgate.mjs doctor",
29
+ "skillpack:check": "node scripts/migrate-skillpack.mjs --check"
30
+ },
31
+ "keywords": [
32
+ "code-quality",
33
+ "ai-slop",
34
+ "security-audit",
35
+ "spec-driven",
36
+ "coding-agent",
37
+ "claude-code",
38
+ "codex",
39
+ "gemini-cli",
40
+ "pi-agent",
41
+ "skills",
42
+ "hard-gates",
43
+ "gate"
44
+ ],
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/hhx465453939/ShipGate.git"
48
+ },
49
+ "license": "MIT"
50
+ }
@@ -0,0 +1,67 @@
1
+ # ADR Format Reference
2
+
3
+ Architecture Decision Records capture decisions that are **hard to reverse**, **surprising without context**, and **the result of a real trade-off**.
4
+
5
+ ## When to Write an ADR
6
+
7
+ All three must be true:
8
+ 1. **Hard to reverse** — the cost of changing your mind later is meaningful
9
+ 2. **Surprising without context** — a future reader will wonder "why did they do it this way?"
10
+ 3. **The result of a real trade-off** — there were genuine alternatives and you picked one for specific reasons
11
+
12
+ If any of the three is missing, **skip the ADR**.
13
+
14
+ ## File Location
15
+
16
+ ```
17
+ docs/adr/NNNN-kebab-case-title.md
18
+ ```
19
+
20
+ Number sequentially starting from `0001`.
21
+
22
+ ## Template
23
+
24
+ ```markdown
25
+ # ADR-NNNN: [Short Decision Title]
26
+
27
+ ## Status
28
+
29
+ [Proposed | Accepted | Deprecated | Superseded by ADR-XXXX]
30
+
31
+ ## Context
32
+
33
+ [What forces are at play? What problem are we solving? What constraints exist?
34
+ Keep it factual — this section explains WHY a decision was needed.]
35
+
36
+ ## Decision
37
+
38
+ [What did we decide? State it clearly in one or two sentences.
39
+ Then explain the approach if needed.]
40
+
41
+ ## Consequences
42
+
43
+ ### Positive
44
+ - [Good thing that follows from this decision]
45
+ - [Another benefit]
46
+
47
+ ### Negative
48
+ - [Trade-off we accepted]
49
+ - [Limitation this creates]
50
+
51
+ ### Neutral
52
+ - [Something that changes but isn't clearly good or bad]
53
+ ```
54
+
55
+ ## Examples of Good ADR Titles
56
+
57
+ - `0001-use-event-sourcing-for-orders.md`
58
+ - `0002-postgres-for-write-model-redis-for-read.md`
59
+ - `0003-reject-graphql-in-favor-of-rest.md`
60
+ - `0004-monorepo-with-turborepo.md`
61
+
62
+ ## Anti-patterns
63
+
64
+ - ADR for obvious choices ("use git for version control")
65
+ - ADR for easily reversible decisions ("use blue for the button")
66
+ - ADR without alternatives considered (if there's no trade-off, there's no decision)
67
+ - ADR as a spec (keep implementation details in code, not ADRs)
@@ -0,0 +1,62 @@
1
+ # CONTEXT.md Format Reference
2
+
3
+ This file defines the canonical format for `CONTEXT.md` — the shared domain language document maintained by the `/intent-grill` skill.
4
+
5
+ ## Purpose
6
+
7
+ CONTEXT.md is a **glossary and nothing else**. It captures the precise meanings of domain terms so that AI agents and developers share the same vocabulary. It is NOT a spec, a scratchpad, or an implementation guide.
8
+
9
+ ## Structure
10
+
11
+ ```markdown
12
+ # [Project Name] Context
13
+
14
+ ## Language
15
+
16
+ **[Term]**:
17
+ [One clear sentence defining this term in the project's domain.]
18
+ _Avoid_: [terms that are easily confused with this one]
19
+
20
+ **[Another Term]**:
21
+ [Definition.]
22
+ _Avoid_: [confusable terms]
23
+
24
+ ## Relationships
25
+
26
+ - A **[Term A]** contains many **[Term B]**
27
+ - A **[Term C]** can only apply to a **[Term A]** in state `pending`
28
+
29
+ ## Flagged Ambiguities
30
+
31
+ - "[word]" is used in code to mean both X and Y — needs resolution
32
+ - "[word]" means different things in module A vs module B
33
+ ```
34
+
35
+ ## Rules
36
+
37
+ 1. **One term per entry** — don't bundle related terms
38
+ 2. **Definition is domain-level** — no implementation details (no "stored in column X")
39
+ 3. **_Avoid_ is mandatory** — every term must list at least one confusable alternative
40
+ 4. **Relationships are structural** — "A has many B", not "A calls B.save()"
41
+ 5. **Flagged Ambiguities are temporary** — resolve them during grilling, then promote to Language
42
+ 6. **Update inline** — don't batch; capture terms the moment they're clarified
43
+ 7. **Keep it short** — if CONTEXT.md exceeds 2 pages, the domain model needs refactoring
44
+
45
+ ## Multi-Context Repos
46
+
47
+ If a repo has multiple bounded contexts, use a `CONTEXT-MAP.md` at root:
48
+
49
+ ```markdown
50
+ # Context Map
51
+
52
+ | Context | Path | Description |
53
+ |---------|------|-------------|
54
+ | Ordering | src/ordering/CONTEXT.md | Order lifecycle and fulfillment |
55
+ | Billing | src/billing/CONTEXT.md | Payment processing and invoicing |
56
+
57
+ ## Cross-Context Terms
58
+
59
+ - **Customer** in Ordering = **Payer** in Billing (same entity, different roles)
60
+ ```
61
+
62
+ Each bounded context gets its own `CONTEXT.md` in its directory.
@@ -0,0 +1,54 @@
1
+ {
2
+ "$schema": "MCP Server Configuration for GitNexus",
3
+ "_comment": "Copy the 'gitnexus' entry into your settings.json mcpServers section",
4
+
5
+ "system_level": {
6
+ "_path_unix": "~/.claude/settings.json",
7
+ "_path_windows": "%USERPROFILE%/.claude/settings.json",
8
+ "_description": "Available to all projects on this machine",
9
+ "mcpServers": {
10
+ "gitnexus": {
11
+ "command": "gitnexus",
12
+ "args": ["mcp"],
13
+ "type": "stdio"
14
+ }
15
+ }
16
+ },
17
+
18
+ "project_level": {
19
+ "_path": ".claude/settings.local.json",
20
+ "_description": "Available only to this project",
21
+ "mcpServers": {
22
+ "gitnexus": {
23
+ "command": "gitnexus",
24
+ "args": ["mcp"],
25
+ "type": "stdio"
26
+ }
27
+ }
28
+ },
29
+
30
+ "with_custom_db_path": {
31
+ "_description": "For repos where .gitnexus/ is in a non-standard location",
32
+ "mcpServers": {
33
+ "gitnexus": {
34
+ "command": "gitnexus",
35
+ "args": ["mcp", "--db-path", "/path/to/.gitnexus"],
36
+ "type": "stdio"
37
+ }
38
+ }
39
+ },
40
+
41
+ "available_mcp_tools": [
42
+ "list_repos — Discover indexed repositories",
43
+ "query — Hybrid BM25 + vector search over the graph",
44
+ "cypher — Ad hoc Cypher queries against the schema",
45
+ "context — Callers, callees, processes for one symbol",
46
+ "impact — Blast radius (upstream/downstream) with risk summary",
47
+ "detect_changes — Map git diffs to affected symbols and processes",
48
+ "rename — Graph-assisted multi-file rename with dry_run preview",
49
+ "api_impact — Pre-change impact report for an API route handler",
50
+ "route_map — API route → handler → consumer mappings",
51
+ "tool_map — MCP/RPC tool definitions and handlers",
52
+ "shape_check — Response shape vs consumer property access mismatches"
53
+ ]
54
+ }