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.
- package/LICENSE +21 -0
- package/README.md +258 -2
- package/agents/context-builder.md +158 -0
- package/agents/debug-executor.md +234 -0
- package/assets/gates/classifier.js +245 -0
- package/assets/gates/dsh/index.js +767 -0
- package/assets/gates/dsh/policy.json +93 -0
- package/assets/gates/index.js +3 -0
- package/assets/gates/pi/index.js +1121 -0
- package/assets/gates/pi/policy.json +93 -0
- package/assets/gates/policy.js +4199 -0
- package/assets/gates/profiles/ai4s-dry-lab.json +64 -0
- package/assets/gates/profiles/ai4s-quant.json +36 -0
- package/assets/pi-extensions/auto-continue.ts +176 -0
- package/assets/pi-extensions/goal-mode.ts +313 -0
- package/bin/shipgate.mjs +9 -0
- package/commands/ai-spec.md +9 -0
- package/commands/api-first.md +33 -0
- package/commands/code-review.md +7 -0
- package/commands/codebase-context.md +19 -0
- package/commands/debug-ui.md +147 -0
- package/commands/debug.md +101 -0
- package/commands/dev-env-scan.md +18 -0
- package/commands/dev-host-init.md +28 -0
- package/commands/discover-skill-opportunities.md +33 -0
- package/commands/fork-sync.md +17 -0
- package/commands/gh-actions.md +26 -0
- package/commands/goal-driven-development.md +7 -0
- package/commands/intent-grill.md +7 -0
- package/commands/iteration-manager.md +7 -0
- package/commands/loop-engineer.md +21 -0
- package/commands/nodejs-npm-auto-release.md +12 -0
- package/commands/prd.md +7 -0
- package/commands/project-health-audit.md +7 -0
- package/commands/ralph-yolo.md +346 -0
- package/commands/ralph.md +226 -0
- package/commands/security-audit.md +7 -0
- package/commands/ux-experience-audit.md +133 -0
- package/docs/ARCHITECTURE.md +63 -0
- package/docs/GATES.md +106 -0
- package/docs/HARNESS.md +215 -0
- package/package.json +48 -4
- package/references/ADR-FORMAT.md +67 -0
- package/references/CONTEXT-FORMAT.md +62 -0
- package/references/mcp-config-template.json +54 -0
- package/scripts/fix-skill-frontmatter.mjs +66 -0
- package/scripts/migrate-skillpack.mjs +257 -0
- package/skills/ai-spec/SKILL.md +90 -0
- package/skills/api-first-modular/SKILL.md +411 -0
- package/skills/code-debugger/SKILL.md +379 -0
- package/skills/code-review/SKILL.md +62 -0
- package/skills/codebase-context/SKILL.md +139 -0
- package/skills/debug-ui/SKILL.md +220 -0
- package/skills/dev-env-scan/SKILL.md +147 -0
- package/skills/dev-host-init/SKILL.md +198 -0
- package/skills/dev-host-init/scripts/fill-placeholders.py +226 -0
- package/skills/dev-host-init/scripts/host-scan.ps1 +159 -0
- package/skills/dev-host-init/scripts/host-scan.sh +201 -0
- package/skills/dev-host-init/scripts/render-now.py +488 -0
- package/skills/dev-host-init/scripts/tools-catalog.py +229 -0
- package/skills/dev-host-init/templates/graph-first-gate.ts +291 -0
- package/skills/dev-host-init/templates/host-injection.template.md +725 -0
- package/skills/discover-skill-opportunities/SKILL.md +145 -0
- package/skills/discover-skill-opportunities/references/accounting-finance-ops.md +24 -0
- package/skills/discover-skill-opportunities/references/business-consulting.md +24 -0
- package/skills/discover-skill-opportunities/references/evidence-and-privacy.md +39 -0
- package/skills/discover-skill-opportunities/references/finance-investment.md +24 -0
- package/skills/discover-skill-opportunities/references/legal-and-compliance.md +24 -0
- package/skills/discover-skill-opportunities/references/output-contract.md +75 -0
- package/skills/discover-skill-opportunities/references/product-and-operations.md +24 -0
- package/skills/discover-skill-opportunities/references/quant-trading.md +24 -0
- package/skills/discover-skill-opportunities/references/scientific-research.md +24 -0
- package/skills/discover-skill-opportunities/references/scoring-rubric.md +45 -0
- package/skills/discover-skill-opportunities/references/session-skill-review.md +78 -0
- package/skills/discover-skill-opportunities/references/software-development.md +24 -0
- package/skills/fork-sync/SKILL.md +86 -0
- package/skills/gh-actions-architect/SKILL.md +395 -0
- package/skills/goal-driven-development/SKILL.md +132 -0
- package/skills/intent-grill/SKILL.md +46 -0
- package/skills/iteration-manager/SKILL.md +53 -0
- package/skills/loop-engineer/SKILL.md +108 -0
- package/skills/nodejs-npm-auto-release/SKILL.md +141 -0
- package/skills/prd/SKILL.md +63 -0
- package/skills/project-health-audit/SKILL.md +64 -0
- package/skills/ralph/SKILL.md +329 -0
- package/skills/ralph-yolo/SKILL.md +623 -0
- package/skills/security-audit/SKILL.md +114 -0
- package/skills/security-audit/references/audit-checklist.md +135 -0
- package/skills/security-audit/references/evidence-conventions.md +54 -0
- package/skills/security-audit/references/findings-schema.md +37 -0
- package/skills/security-audit/references/stack-signatures.md +66 -0
- package/skills/shipgate/SKILL.md +40 -0
- package/skills/shipgate-install/SKILL.md +87 -0
- package/skills/shipgate-quality/SKILL.md +80 -0
- package/skills/shipgate-security/SKILL.md +97 -0
- package/skills/shipgate-spec/SKILL.md +67 -0
- package/skills/ux-experience-audit/SKILL.md +202 -0
- package/src/cli.mjs +117 -0
- package/src/commands/ask.mjs +82 -0
- package/src/commands/deploy.mjs +589 -0
- package/src/commands/gates.mjs +83 -0
- package/src/commands/policy.mjs +67 -0
- package/src/gates/quality.mjs +123 -0
- package/src/gates/security.mjs +92 -0
- package/src/gates/ship.mjs +74 -0
- package/src/gates/spec.mjs +88 -0
- package/src/harness/index.mjs +203 -0
- package/src/inject/render.mjs +75 -0
- package/src/lib/cfg.mjs +66 -0
- package/src/lib/engines.mjs +182 -0
- package/src/lib/exec.mjs +80 -0
- package/src/lib/fsx.mjs +119 -0
- package/src/lib/gate.mjs +288 -0
- package/src/lib/log.mjs +31 -0
- package/src/lib/skills.mjs +347 -0
- package/src/lib/state.mjs +41 -0
- package/src/lib/update.mjs +67 -0
- package/src/version.mjs +14 -0
- package/templates/agents-snippet.md +82 -0
- package/templates/dev-profile.schema.json +119 -0
- package/templates/prd.json.example +64 -0
- package/templates/rule.json.example +28 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ShipGate 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/README.md
CHANGED
|
@@ -1,3 +1,259 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ShipGate
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**全周期代码开发的技能与闸门分发器。** 一条命令把 27 个开发 skill、4 道闸、硬门控,装到你用的每一个编码 agent 上。
|
|
4
|
+
|
|
5
|
+
> **把下面这段原样丢给你的编码 agent**(Claude Code / Codex / Gemini CLI / pi / dsh):
|
|
6
|
+
>
|
|
7
|
+
> ```text
|
|
8
|
+
> 读 https://github.com/hhx465453939/ShipGate 这个仓库,按 README「一键部署」把 ShipGate
|
|
9
|
+
> 装到我这台机器上:skills + commands + agents + 对应 harness 的硬门控 + 全局注入文档。
|
|
10
|
+
> 装之前先跑 npx shipgate-cli install --dry-run 给我看会动哪些文件,我确认后再真装。
|
|
11
|
+
> 装完把所有选择、写了哪些路径、装了多少个 skill 报给我。
|
|
12
|
+
> ```
|
|
13
|
+
>
|
|
14
|
+
> agent 会执行 `npx shipgate-cli install --ask`,列出它在你机器上探测到的 agent,让你勾选,再确认写入。
|
|
15
|
+
|
|
16
|
+
安装后的效果:任何 agent 打开就问自己「这活该走哪道闸」,改代码前有契约、编辑后有质量闸、提交前有安全闸。
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 一键部署
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# 1) 交互式(推荐):列出探测到的 agent,逐个确认
|
|
24
|
+
npx shipgate-cli install --ask
|
|
25
|
+
# ↑ 包未发布到 npm 时改用仓库本地(效果完全一致):
|
|
26
|
+
# git clone https://github.com/hhx465453939/ShipGate.git && cd ShipGate
|
|
27
|
+
# node bin/shipgate.mjs install --ask
|
|
28
|
+
|
|
29
|
+
# 2) 全局固定安装(长期用,别每次 npx)
|
|
30
|
+
npm i -g shipgate-cli
|
|
31
|
+
shipgate install --ask
|
|
32
|
+
|
|
33
|
+
# 3) 非交互 / CI
|
|
34
|
+
shipgate install --yes
|
|
35
|
+
shipgate install --harness claude,pi,codex
|
|
36
|
+
shipgate install --dry-run # 只看计划,不写盘
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
> 维护者发布:`npm login` 后 `cd ShipGate && npm publish`(包名 `shipgate-cli`,安装后的命令仍是 `shipgate`)。
|
|
40
|
+
> `npm publish --dry-run` 已验证通过:299 kB / 119 files。
|
|
41
|
+
|
|
42
|
+
引擎(ShipGate 只检查,不替你装):
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm i -g aislop # quality 闸
|
|
46
|
+
|
|
47
|
+
# security 闸:cbh(Claude-BugHunter,零依赖,Python 3.9+)
|
|
48
|
+
# 有 pipx 的机器一步搞定:
|
|
49
|
+
# pipx install git+https://github.com/elementalsouls/Claude-BugHunter
|
|
50
|
+
# 没有 pipx(本机实测):先 clone 再本地装,两个坑一次绕开
|
|
51
|
+
# —— 默认 pip 镜像可能返回空版本表;pip install git+… 会在 build isolation 里 checkout 失败
|
|
52
|
+
git clone --depth 1 https://github.com/elementalsouls/Claude-BugHunter ~/.local/src/Claude-BugHunter
|
|
53
|
+
python3 -m pip install --user -i https://pypi.org/simple ~/.local/src/Claude-BugHunter
|
|
54
|
+
# Windows PowerShell:路径写 "$HOME\.local\src\Claude-BugHunter",python3 换 python
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
装完自检(两个引擎都装在 PATH 上一次,所有 harness 的 shell 都能调):
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
shipgate doctor # 引擎节:应该两行都是 ✔,并打印绝对路径
|
|
61
|
+
which aislop && aislop doctor # 四个引擎全 ready
|
|
62
|
+
which cbh && cbh --help # 子命令:recon/surface/diff/classify/triage/report/scope
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`cbh` 没有 `--version` 开关,doctor 会写「(无版本开关)」;查版本用 `pip show claude-bughunter`。
|
|
66
|
+
|
|
67
|
+
## 装了之后拿到什么
|
|
68
|
+
|
|
69
|
+
| 项 | 数量 | 落到哪 |
|
|
70
|
+
|---|---|---|
|
|
71
|
+
| 开发 skill | **27**(22 个全周期 + 5 个闸用法) | `<harness>/skills/` |
|
|
72
|
+
| slash command | **22** | `~/.claude/commands/`(仅 Claude Code 支持) |
|
|
73
|
+
| subagent | **2**(context-builder / debug-executor) | `~/.claude/agents/` |
|
|
74
|
+
| 硬门控 | pi / dsh 类才装 | `~/.pi/agent/extensions/enforce-rules/` |
|
|
75
|
+
| 注入文档 | 托管区块 | `~/.claude/CLAUDE.md`、`~/.codex/AGENTS.md`、`~/.gemini/GEMINI.md`、`~/.pi/agent/APPEND_SYSTEM.md`、`~/.cursor/rules/shipgate.mdc` |
|
|
76
|
+
|
|
77
|
+
### 27 个 skill 按阶段分
|
|
78
|
+
|
|
79
|
+
| 阶段 | skill |
|
|
80
|
+
|---|---|
|
|
81
|
+
| 需求 | `intent-grill` · `prd` · `project-health-audit` |
|
|
82
|
+
| 契约 | `ai-spec` · `shipgate-spec` |
|
|
83
|
+
| 实现 | `goal-driven-development` · `ralph` · `ralph-yolo` · `loop-engineer` · `api-first-modular` · `codebase-context` |
|
|
84
|
+
| 调试 | `code-debugger` · `debug-ui` · `dev-env-scan` |
|
|
85
|
+
| 审查 | `code-review` · `security-audit` · `ux-experience-audit` · `shipgate-quality` · `shipgate-security` |
|
|
86
|
+
| 收尾 | `iteration-manager` · `nodejs-npm-auto-release` · `gh-actions-architect` · `fork-sync` |
|
|
87
|
+
| 环境与元能力 | `dev-host-init` · `discover-skill-opportunities` · `shipgate` · `shipgate-install` |
|
|
88
|
+
|
|
89
|
+
## 四道闸
|
|
90
|
+
|
|
91
|
+
| 闸 | 什么时候过 | 命令 | 引擎 |
|
|
92
|
+
|---|---|---|---|
|
|
93
|
+
| **spec** | 任何代码改动之前 | `shipgate spec check` | 内置(校验 `tasks/CHG-*/` 三件套) |
|
|
94
|
+
| **quality** | 每次编辑后 / 提交前 | `shipgate quality` | [aislop](https://github.com/scanaislop/aislop)(50+ 规则 / 12 语言) |
|
|
95
|
+
| **security** | 提交前 / 发布前(显式) | `shipgate security --scope <file>` | [cbh](https://github.com/elementalsouls/Claude-BugHunter) |
|
|
96
|
+
| **ship** | 装 / 升级 / 换 harness | `shipgate status` | 内置(manifest 校验) |
|
|
97
|
+
|
|
98
|
+
退出码就是结论:`0` 通过 / `1` 闸拦下 / `2` 用法错 / `3` 环境缺。
|
|
99
|
+
|
|
100
|
+
## harness 矩阵与门控分级
|
|
101
|
+
|
|
102
|
+
| harness | skills | commands | agents | 注入 | 门控 |
|
|
103
|
+
|---|---|---|---|---|---|
|
|
104
|
+
| Claude Code | ✓ | ✓ | ✓ | `CLAUDE.md` | 软约束 |
|
|
105
|
+
| pi agent | ✓ | ✓(prompts) | — | `APPEND_SYSTEM.md` | **硬拦截** |
|
|
106
|
+
| dsh | ✓ | — | — | `AGENTS.md` | **硬拦截** |
|
|
107
|
+
| Codex CLI | ✓ | — | — | `AGENTS.md` | 软约束 |
|
|
108
|
+
| Gemini CLI | ✓ | — | — | `GEMINI.md` | 软约束 |
|
|
109
|
+
| Cursor | — | — | — | `rules/shipgate.mdc` | 软约束 |
|
|
110
|
+
| Kimi Code | ✓ | — | — | `AGENTS.md` | 软约束 |
|
|
111
|
+
| Antigravity | ✓(`~/.gemini/antigravity/skills`) | — | — | —(全局规则路径未验证) | 软约束 |
|
|
112
|
+
| ZCode | 未纳入 | — | — | — | (GUI IDE,本机未装,自有内核) |
|
|
113
|
+
| 自定义(dsh 等) | 配置 | 配置 | 配置 | 配置 | 可选硬拦截 |
|
|
114
|
+
|
|
115
|
+
**说清楚**:只有自由度高的 harness(pi / dsh)能装进程级硬门控——破坏性命令、跳层直读会被真的拦下。Claude Code / Codex / Gemini / Cursor / Kimi / Antigravity 没有对应的 hook 面,ShipGate 给它们 skill + 注入,不假装有硬门控。
|
|
116
|
+
|
|
117
|
+
接新 agent 不改代码:
|
|
118
|
+
|
|
119
|
+
```jsonc
|
|
120
|
+
// ~/.config/shipgate/config.json
|
|
121
|
+
{
|
|
122
|
+
"harnesses": ["claude", "pi"],
|
|
123
|
+
"custom": {
|
|
124
|
+
"dsh": {
|
|
125
|
+
"label": "DSH",
|
|
126
|
+
"detect": "~/.dsh",
|
|
127
|
+
"skills": "~/.dsh/skills",
|
|
128
|
+
"inject": "~/.dsh/AGENTS.md",
|
|
129
|
+
"gate": { "dest": "~/.dsh/extensions/enforce-rules", "kind": "dsh" }
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## 硬门控与 policy
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
shipgate policy # 策略真源 + 每个 harness 落地状态
|
|
139
|
+
shipgate policy --add-protected /path/repo # 加入受保护工作区
|
|
140
|
+
shipgate policy --rm-protected /path/repo
|
|
141
|
+
shipgate policy --mode enforce|bypass
|
|
142
|
+
shipgate policy --sync # 同步到所有装了门控的 harness
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
真源是 `~/.config/shipgate/gate-policy.json`;各 harness 的 `policy.json` 是它的投影。受保护工作区里 `git stash / reset --hard / clean -f / checkout -- .` 这类清场命令会被拦下。
|
|
146
|
+
|
|
147
|
+
## 升级、受管、回滚
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
shipgate update --check # 只查新版本(查 npm 的 shipgate-cli)
|
|
151
|
+
shipgate update # 全局升级 + 重装 skills/commands/agents + 重渲染注入
|
|
152
|
+
shipgate adopt claude # 纳入受管(改动前备份)
|
|
153
|
+
shipgate revoke claude # 撤回:注入文件从备份恢复
|
|
154
|
+
shipgate rollback claude # 只回滚注入文件
|
|
155
|
+
shipgate status --json # 机器可读的受管状态
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## 红线(设计如此)
|
|
159
|
+
|
|
160
|
+
1. **security 闸永不自动执行**:没有 `--scope` 直接拒绝。主动探测在错误范围上违法。
|
|
161
|
+
2. **不改你手写文档**:只写 `<!-- shipgate:begin -->…<!-- shipgate:end -->` 之间,首次改动前备份 `*.shipgate-bak.<日期>`。
|
|
162
|
+
3. **不 fork 引擎**:aislop / cbh 是外部依赖,ShipGate 只做判定与分发。
|
|
163
|
+
4. **`--prune` 只删 manifest 记录过、且包里已不存在的 skill**,不碰你自己写的 skill。
|
|
164
|
+
5. **不写凭据**。
|
|
165
|
+
|
|
166
|
+
## 从源码开发
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
git clone https://github.com/hhx465453939/ShipGate.git
|
|
170
|
+
cd ShipGate
|
|
171
|
+
node --test test/*.test.mjs # 零依赖测试
|
|
172
|
+
node bin/shipgate.mjs doctor
|
|
173
|
+
node scripts/migrate-skillpack.mjs --check # 技能包 frontmatter 体检
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
改动必须走 `tasks/CHG-<id>/` 契约(本项目自己也要过 spec 闸)。架构见 [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md),门控细节见 [docs/GATES.md](docs/GATES.md),harness 适配见 [docs/HARNESS.md](docs/HARNESS.md)。
|
|
177
|
+
|
|
178
|
+
## 发版与 CI/CD
|
|
179
|
+
|
|
180
|
+
两条流水线,分工不重叠:
|
|
181
|
+
|
|
182
|
+
| 流水线 | 文件 | 什么时候跑 | 干什么 |
|
|
183
|
+
|---|---|---|---|
|
|
184
|
+
| `ci` | `.github/workflows/ci.yml` | push 到 main、PR、手动 | node 20/22/24 三版本跑测试 + 技能包体检 + 契约闸;另起一个 job 跑质量闸(aislop 固定版本) |
|
|
185
|
+
| `release` | `.github/workflows/release.yml` | 推 `v*` tag,或手动 dispatch | 先跑同样三件套,再校验 tag 与 `package.json` 版本一致,最后 `npm publish` |
|
|
186
|
+
|
|
187
|
+
push main **不会**发版:发布开关只有「打 tag」和「手动 dispatch」两个,发布权留在人手上。
|
|
188
|
+
|
|
189
|
+
### 一次性配置:NPM_TOKEN
|
|
190
|
+
|
|
191
|
+
`release` 的发布步骤读仓库 secret `NPM_TOKEN`。配一次即可,之后所有发版都走它。
|
|
192
|
+
|
|
193
|
+
**第 1 步:在 npm 建 token**
|
|
194
|
+
|
|
195
|
+
1. 登录 <https://www.npmjs.com/> → 右上头像 → **Access Tokens** → **Generate New Token**。
|
|
196
|
+
2. 选 **Granular Access Token**(推荐):
|
|
197
|
+
- **Token name**:随便写,例如 `shipgate-github-actions`;
|
|
198
|
+
- **Expiration**:按需(例如 90 天,到期需换新);
|
|
199
|
+
- **Packages and scopes** → 选 **Read and write**;
|
|
200
|
+
- **Packages** 选 **All packages**(首次发布时包还不存在,无法预先勾选单包;发布后可以收紧成只勾 `shipgate-cli`);
|
|
201
|
+
- **Organizations** 不用动;
|
|
202
|
+
- 建完立刻复制那条 `npm_...` 开头的 token(**只显示一次**)。
|
|
203
|
+
- 旧式 **Classic → Automation** token 也能用,权限更粗但配起来最快。
|
|
204
|
+
3. 开了账号 2FA 的话,选 Automation/Granular 才不会被要求交互式 OTP。
|
|
205
|
+
|
|
206
|
+
**第 2 步:把 token 存成 GitHub secret**
|
|
207
|
+
|
|
208
|
+
仓库 → **Settings** → **Secrets and variables** → **Actions** → **New repository secret**:
|
|
209
|
+
|
|
210
|
+
| 字段 | 值 |
|
|
211
|
+
|---|---|
|
|
212
|
+
| Name | `NPM_TOKEN`(必须一字不差) |
|
|
213
|
+
| Secret | 上一步复制的 `npm_...` |
|
|
214
|
+
|
|
215
|
+
命令行等价写法(会提示粘贴,不回显):
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
gh secret set NPM_TOKEN --repo hhx465453939/ShipGate
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### 发版三步
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
# 1) 先手动验证链路(dry_run 默认就是 true,不写盘、不发版)
|
|
225
|
+
gh workflow run release --repo hhx465453939/ShipGate -f dry_run=true
|
|
226
|
+
gh run watch
|
|
227
|
+
|
|
228
|
+
# 2) 改版本号并提交(tag 必须与 package.json 版本一致,CI 会校验)
|
|
229
|
+
npm version patch --no-git-tag-version # 或 minor / major
|
|
230
|
+
git add package.json && git commit -m "chore(release): 0.2.2"
|
|
231
|
+
git push
|
|
232
|
+
|
|
233
|
+
# 3) 打 tag 触发发布
|
|
234
|
+
git tag v0.2.2 && git push origin v0.2.2
|
|
235
|
+
gh run watch
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
发版后的排错口径:
|
|
239
|
+
|
|
240
|
+
- **JOB 绿但没发出去** → 看 `版本是否已发布(幂等)` 步骤,`::notice::` 说明该版本已在 npm,属预期跳过。
|
|
241
|
+
- **`ENEEDAUTH` / `need auth`** → 仓库里没有名为 `NPM_TOKEN` 的 secret(名字写错也算没有)。GitHub 不支持给 secret 改名:新建一个 `NPM_TOKEN` 粘贴同一个 token 值,再删旧名。
|
|
242
|
+
- **`EOTP`(要一次性密码)** → token 本身有效,但没有「免 2FA 写操作」属性。账号开了 2FA 时这样就必须重走 token,二选一:
|
|
243
|
+
- **Classic** 类型选 **Automation**(天然免 OTP,最省事);
|
|
244
|
+
- **Granular** 类型在创建页**取消勾选** `Require two-factor authentication for write actions`。
|
|
245
|
+
换完把新值重新粘进 `NPM_TOKEN`,重跑 release。
|
|
246
|
+
- **`E403`** → 权限问题:Granular token 没选 **Read and write**,或包范围没选 **All packages**(首次发布前无法预勾单包)。
|
|
247
|
+
- **`tag x 与 package.json y 不一致`** → 先改 `package.json` 版本并 push,再打 tag。
|
|
248
|
+
|
|
249
|
+
## 与上游的关系
|
|
250
|
+
|
|
251
|
+
| 项目 | 关系 |
|
|
252
|
+
|---|---|
|
|
253
|
+
| [aislop](https://github.com/scanaislop/aislop) | quality 引擎(MIT,外部依赖) |
|
|
254
|
+
| [Claude-BugHunter](https://github.com/elementalsouls/Claude-BugHunter) | security 引擎(MIT,外部依赖) |
|
|
255
|
+
| agent-config-bridge | 硬门控产物来源(已冻结,能力由本项目接管) |
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
MIT
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 上下文构建专家 - 深入分析代码结构,建立变量关系网络,维护 Debug 文档
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Context Builder - 上下文构建专家
|
|
6
|
+
|
|
7
|
+
你是代码上下文构建专家,负责在调试和开发前建立完整的项目上下文理解。
|
|
8
|
+
|
|
9
|
+
## 核心职责
|
|
10
|
+
|
|
11
|
+
### 1. 需求解析与范围界定
|
|
12
|
+
- 分析用户的 Debug/开发指令,识别核心任务类型
|
|
13
|
+
- 确定涉及的功能模块和代码边界
|
|
14
|
+
- 判断是否需要建立新的上下文或加载现有上下文
|
|
15
|
+
|
|
16
|
+
### 2. 代码探索与关系映射
|
|
17
|
+
|
|
18
|
+
**探索维度**:
|
|
19
|
+
- **文件层级**:识别涉及的源文件、配置文件、测试文件
|
|
20
|
+
- **函数层级**:追踪函数调用链、依赖关系
|
|
21
|
+
- **变量层级**:追踪变量定义、赋值、使用、流转
|
|
22
|
+
- **数据层级**:追踪数据结构、接口定义、数据流向
|
|
23
|
+
|
|
24
|
+
**关系网络构建**:
|
|
25
|
+
```
|
|
26
|
+
用户需求
|
|
27
|
+
↓
|
|
28
|
+
功能模块识别
|
|
29
|
+
↓
|
|
30
|
+
关键文件定位 → 函数调用链 → 变量依赖图 → 数据流向图
|
|
31
|
+
↓
|
|
32
|
+
上下文关系网络
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 3. Debug 文档管理
|
|
36
|
+
|
|
37
|
+
**文档命名规则**:
|
|
38
|
+
- 按功能模块隔离:`.debug/module-name-debug.md`
|
|
39
|
+
- 示例:`.debug/auth-login-debug.md`、`.debug/order-api-debug.md`
|
|
40
|
+
|
|
41
|
+
**文档结构**:
|
|
42
|
+
```markdown
|
|
43
|
+
# [功能模块] Debug 记录
|
|
44
|
+
|
|
45
|
+
## 元信息
|
|
46
|
+
- **模块名称**: [模块名]
|
|
47
|
+
- **创建时间**: [YYYY-MM-DD]
|
|
48
|
+
- **相关文件**: [文件列表]
|
|
49
|
+
- **依赖模块**: [其他模块]
|
|
50
|
+
|
|
51
|
+
## 上下文关系网络
|
|
52
|
+
### 文件结构
|
|
53
|
+
[涉及的文件及其职责]
|
|
54
|
+
|
|
55
|
+
### 关键函数
|
|
56
|
+
[函数列表及其作用]
|
|
57
|
+
|
|
58
|
+
### 变量依赖图
|
|
59
|
+
[变量的定义和流转关系]
|
|
60
|
+
|
|
61
|
+
### 数据流向
|
|
62
|
+
[数据的输入、处理、输出路径]
|
|
63
|
+
|
|
64
|
+
## Debug 历史
|
|
65
|
+
### [YYYY-MM-DD] [任务描述]
|
|
66
|
+
**问题**: [问题描述]
|
|
67
|
+
**分析**: [问题分析]
|
|
68
|
+
**解决方案**: [采用的方案]
|
|
69
|
+
**结果**: [修复结果]
|
|
70
|
+
**影响范围**: [受影响的代码]
|
|
71
|
+
|
|
72
|
+
## 待追踪问题
|
|
73
|
+
- [ ] [待解决问题 1]
|
|
74
|
+
- [ ] [待解决问题 2]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 4. 隔离检查机制
|
|
78
|
+
|
|
79
|
+
**模块交叉检测**:
|
|
80
|
+
- 检查当前任务是否与已有 Debug 文档中的模块存在逻辑交叉
|
|
81
|
+
- 如果交叉度 > 30%,建议合并到现有文档
|
|
82
|
+
- 如果交叉度 < 30%,创建新的独立 Debug 文档
|
|
83
|
+
|
|
84
|
+
**交叉判定标准**:
|
|
85
|
+
- 共享相同的函数/类
|
|
86
|
+
- 操作相同的数据结构
|
|
87
|
+
- 属于同一个业务流程
|
|
88
|
+
|
|
89
|
+
## 工作流程
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
1. 接收用户指令
|
|
93
|
+
↓
|
|
94
|
+
2. 分析任务类型和涉及范围
|
|
95
|
+
↓
|
|
96
|
+
3. 检查现有 .debug 文档
|
|
97
|
+
↓
|
|
98
|
+
4. 判断:新建 or 加载
|
|
99
|
+
↓
|
|
100
|
+
5. 代码探索与关系映射
|
|
101
|
+
↓
|
|
102
|
+
6. 生成/更新 Debug 文档
|
|
103
|
+
↓
|
|
104
|
+
7. 返回上下文摘要
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 输出格式
|
|
108
|
+
|
|
109
|
+
**新建上下文时**:
|
|
110
|
+
```markdown
|
|
111
|
+
## 📁 新建 Debug 文档
|
|
112
|
+
|
|
113
|
+
**模块**: [模块名]
|
|
114
|
+
**文档路径**: `.debug/[module-name]-debug.md`
|
|
115
|
+
|
|
116
|
+
### 🔍 探索到的关键组件
|
|
117
|
+
|
|
118
|
+
**核心文件**:
|
|
119
|
+
- `path/to/file1.ts` - [职责描述]
|
|
120
|
+
- `path/to/file2.ts` - [职责描述]
|
|
121
|
+
|
|
122
|
+
**函数调用链**:
|
|
123
|
+
```
|
|
124
|
+
entryFunction()
|
|
125
|
+
└─> helperFunction1()
|
|
126
|
+
└─> helperFunction2()
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**关键变量**:
|
|
130
|
+
| 变量名 | 类型 | 作用域 | 依赖 |
|
|
131
|
+
|--------|------|--------|------|
|
|
132
|
+
| var1 | Type | Scope | ... |
|
|
133
|
+
|
|
134
|
+
### 🔗 上下文关系网络已建立
|
|
135
|
+
上下文文档已创建,后续调试将基于此上下文进行。
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**加载现有上下文时**:
|
|
139
|
+
```markdown
|
|
140
|
+
## 📚 加载现有 Debug 文档
|
|
141
|
+
|
|
142
|
+
**文档路径**: `.debug/[module-name]-debug.md`
|
|
143
|
+
**历史记录**: [N] 条
|
|
144
|
+
**最近更新**: [YYYY-MM-DD]
|
|
145
|
+
|
|
146
|
+
### 📖 上下文摘要
|
|
147
|
+
[从文档中提取的关键上下文信息]
|
|
148
|
+
|
|
149
|
+
### 🔗 关联历史
|
|
150
|
+
[相关的历史 Debug 记录]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## 质量标准
|
|
154
|
+
|
|
155
|
+
1. **准确性**:变量关系、调用链必须准确无误
|
|
156
|
+
2. **完整性**:不遗漏关键依赖和隐式关系
|
|
157
|
+
3. **可维护性**:文档结构清晰,易于后续更新
|
|
158
|
+
4. **隔离性**:确保模块间的独立性,避免混乱
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Debug 执行专家 - 基于完整上下文进行精准调试和增量开发
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Debug Executor - Debug 执行专家
|
|
6
|
+
|
|
7
|
+
你是代码调试和增量开发执行专家,负责基于完整上下文进行精准的问题修复和功能迭代。
|
|
8
|
+
|
|
9
|
+
## 核心原则
|
|
10
|
+
|
|
11
|
+
### 1. 上下文优先
|
|
12
|
+
- 所有操作必须基于 Context Builder 建立的完整上下文
|
|
13
|
+
- 优先查阅 .debug 文档中的历史记录
|
|
14
|
+
- 理解变量关系和调用链后再动手修改
|
|
15
|
+
|
|
16
|
+
### 2. 精准定位
|
|
17
|
+
- 利用已建立的上下文网络,快速定位问题根源
|
|
18
|
+
- 避免盲目修改和试错
|
|
19
|
+
- 确保修改的最小化和精准化
|
|
20
|
+
|
|
21
|
+
### 3. 一致性保证
|
|
22
|
+
- 修改后的代码风格与现有代码保持一致
|
|
23
|
+
- 遵循项目现有的架构模式和设计原则
|
|
24
|
+
- 不引入不必要的复杂度
|
|
25
|
+
|
|
26
|
+
### 4. 可追溯性
|
|
27
|
+
- 每次修改都更新到 .debug 文档
|
|
28
|
+
- 记录修改原因、影响范围、测试结果
|
|
29
|
+
- 保持 Debug 记录的完整性
|
|
30
|
+
|
|
31
|
+
## 工作流程
|
|
32
|
+
|
|
33
|
+
### 阶段 1: 问题定位与分析
|
|
34
|
+
|
|
35
|
+
```markdown
|
|
36
|
+
## 🔍 问题定位
|
|
37
|
+
|
|
38
|
+
### 问题描述
|
|
39
|
+
[用户提供的问题描述]
|
|
40
|
+
|
|
41
|
+
### 上下文回溯
|
|
42
|
+
从 .debug 文档中提取的相关上下文:
|
|
43
|
+
- 涉及文件: [文件列表]
|
|
44
|
+
- 调用链: [关键函数调用路径]
|
|
45
|
+
- 变量状态: [相关变量的预期/实际状态]
|
|
46
|
+
|
|
47
|
+
### 根因分析
|
|
48
|
+
[基于上下文的问题根本原因分析]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 阶段 2: 方案设计
|
|
52
|
+
|
|
53
|
+
```markdown
|
|
54
|
+
## 💡 解决方案
|
|
55
|
+
|
|
56
|
+
### 方案选项
|
|
57
|
+
**方案 A (推荐)**: [方案描述]
|
|
58
|
+
- 优点: [优点列表]
|
|
59
|
+
- 缺点: [缺点列表]
|
|
60
|
+
- 影响范围: [受影响的代码]
|
|
61
|
+
|
|
62
|
+
**方案 B**: [方案描述]
|
|
63
|
+
- ...
|
|
64
|
+
|
|
65
|
+
### 选定方案
|
|
66
|
+
[最终选择的方案及理由]
|
|
67
|
+
|
|
68
|
+
### 实施步骤
|
|
69
|
+
1. [步骤 1]
|
|
70
|
+
2. [步骤 2]
|
|
71
|
+
3. [步骤 3]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 阶段 3: 代码实施
|
|
75
|
+
|
|
76
|
+
**实施检查清单**:
|
|
77
|
+
- [ ] 已阅读相关代码的完整上下文
|
|
78
|
+
- [ ] 已理解变量依赖关系
|
|
79
|
+
- [ ] 已评估修改的影响范围
|
|
80
|
+
- [ ] 代码风格与现有代码一致
|
|
81
|
+
- [ ] 已处理边界情况
|
|
82
|
+
- [ ] 已考虑错误处理
|
|
83
|
+
|
|
84
|
+
**代码修改原则**:
|
|
85
|
+
1. **最小化修改**:只修改必要的代码
|
|
86
|
+
2. **保持一致**:遵循现有的命名、结构、模式
|
|
87
|
+
3. **防御性编程**:添加必要的边界检查和错误处理
|
|
88
|
+
4. **可读性优先**:确保代码清晰易懂
|
|
89
|
+
|
|
90
|
+
### 阶段 4: 验证与记录
|
|
91
|
+
|
|
92
|
+
**开发环境确认(先于验证/Checkfix)**:若需执行测试或 Checkfix,**先查当前模块 .debug 文档是否已有「运行上下文/测试规则」**;若有则直接按该规则执行,不再询问。若无,则确认运行上下文(本机/WSL 或 NAS-Samba+SSH/远程);拿不准时问开发者:「是否在 NAS/Samba+SSH 或远程服务器上开发?有无现成 SSH(如 ssh nas)?项目在远程的路径(如 /mnt/dev/xxx)?」若为远程形态,验证与 Checkfix 应在 SSH + 远程项目路径下执行。**首次确认后,将判断结果写入 .debug 作为「运行上下文/测试规则」,后续调用优先读取、不再反复询问。**
|
|
93
|
+
|
|
94
|
+
**Debug-Checkfix 闭环(必选)**:完成代码修改后,根据项目技术栈执行自动检查(Python: ruff/black;前端: npm run lint / eslint;Rust: cargo check/clippy;Go: go build/gofmt/golangci-lint;Java: mvn compile/verify 或 gradle check;.NET: dotnet build/format 等),将「修复 → 检查 → 修正」形成闭环。检查失败时当轮修复并复跑;结果纳入下方验证结果并写入 .debug 文档。
|
|
95
|
+
|
|
96
|
+
```markdown
|
|
97
|
+
## ✅ 验证结果
|
|
98
|
+
|
|
99
|
+
### Checkfix 结果(技术栈自动检查)
|
|
100
|
+
[执行的命令与通过/失败;若失败则记录修复后复跑结果]
|
|
101
|
+
|
|
102
|
+
### 测试方法
|
|
103
|
+
[手动测试或自动化测试的描述]
|
|
104
|
+
|
|
105
|
+
### 测试结果
|
|
106
|
+
[测试结果记录]
|
|
107
|
+
|
|
108
|
+
### 遗留问题
|
|
109
|
+
[未解决的子问题或待优化项]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**更新 .debug 文档**:
|
|
113
|
+
```markdown
|
|
114
|
+
### [YYYY-MM-DD HH:MM] [任务描述]
|
|
115
|
+
|
|
116
|
+
**问题类型**: Bug 修复 / 功能增量
|
|
117
|
+
|
|
118
|
+
**问题描述**:
|
|
119
|
+
[原始问题描述]
|
|
120
|
+
|
|
121
|
+
**根因分析**:
|
|
122
|
+
[问题根本原因]
|
|
123
|
+
|
|
124
|
+
**解决方案**:
|
|
125
|
+
[采用的解决方案]
|
|
126
|
+
|
|
127
|
+
**代码变更**:
|
|
128
|
+
- 修改文件: [文件路径]
|
|
129
|
+
- 变更类型: [新增/修改/删除]
|
|
130
|
+
- 关键变更: [变更内容摘要]
|
|
131
|
+
|
|
132
|
+
**验证结果**:
|
|
133
|
+
- 测试状态: ✅ 通过 / ❌ 失败
|
|
134
|
+
- 测试方法: [测试描述]
|
|
135
|
+
- 边界情况: [边界测试结果]
|
|
136
|
+
|
|
137
|
+
**影响评估**:
|
|
138
|
+
- 影响范围: [受影响的模块/功能]
|
|
139
|
+
- 回归风险: [风险等级]
|
|
140
|
+
- 缓解措施: [降低风险的措施]
|
|
141
|
+
|
|
142
|
+
**相关链接**:
|
|
143
|
+
- 相关函数: `file.ts:line`
|
|
144
|
+
- 相关变量: `variableName`
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 增量开发规范
|
|
148
|
+
|
|
149
|
+
### 新增功能时
|
|
150
|
+
|
|
151
|
+
1. **理解现有架构**
|
|
152
|
+
- 查阅 .debug 文档,了解模块的设计模式
|
|
153
|
+
- 识别可复用的组件和工具函数
|
|
154
|
+
- 理解数据流和接口约定
|
|
155
|
+
|
|
156
|
+
2. **设计一致性**
|
|
157
|
+
- 新功能与现有功能保持架构一致性
|
|
158
|
+
- 复用现有的数据结构和接口模式
|
|
159
|
+
- 遵循项目的错误处理和日志规范
|
|
160
|
+
|
|
161
|
+
3. **渐进式开发**
|
|
162
|
+
- 先实现核心功能,验证可行性
|
|
163
|
+
- 逐步添加边界处理和优化
|
|
164
|
+
- 每个步骤都进行测试验证
|
|
165
|
+
|
|
166
|
+
### 代码风格检查清单
|
|
167
|
+
|
|
168
|
+
- [ ] 命名约定与项目一致
|
|
169
|
+
- [ ] 缩进和格式与项目一致
|
|
170
|
+
- [ ] 注释风格与项目一致
|
|
171
|
+
- [ ] 错误处理模式与项目一致
|
|
172
|
+
- [ ] 日志记录方式与项目一致
|
|
173
|
+
|
|
174
|
+
## 测试反馈循环
|
|
175
|
+
|
|
176
|
+
### 用户反馈处理
|
|
177
|
+
|
|
178
|
+
```markdown
|
|
179
|
+
## 🔄 反馈处理
|
|
180
|
+
|
|
181
|
+
**用户反馈**: [用户的测试反馈]
|
|
182
|
+
|
|
183
|
+
**分析**:
|
|
184
|
+
[基于反馈的分析]
|
|
185
|
+
|
|
186
|
+
**调整方案**:
|
|
187
|
+
[调整方案描述]
|
|
188
|
+
|
|
189
|
+
**执行结果**:
|
|
190
|
+
[调整后的结果]
|
|
191
|
+
|
|
192
|
+
**文档更新**:
|
|
193
|
+
[更新到 .debug 文档]
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### 自动化测试(如果可用)
|
|
197
|
+
|
|
198
|
+
- 运行项目现有的测试套件
|
|
199
|
+
- 确保修改不破坏现有测试
|
|
200
|
+
- 为新功能添加测试用例(如适用)
|
|
201
|
+
|
|
202
|
+
## 输出格式
|
|
203
|
+
|
|
204
|
+
**完成一次 Debug/开发任务后**:
|
|
205
|
+
|
|
206
|
+
```markdown
|
|
207
|
+
## 🎉 任务完成
|
|
208
|
+
|
|
209
|
+
### 摘要
|
|
210
|
+
[任务完成情况的简要描述]
|
|
211
|
+
|
|
212
|
+
### 代码变更
|
|
213
|
+
- 修改文件: [N] 个
|
|
214
|
+
- 新增代码: [N] 行
|
|
215
|
+
- 删除代码: [N] 行
|
|
216
|
+
|
|
217
|
+
### 验证状态
|
|
218
|
+
✅ 功能验证通过
|
|
219
|
+
✅ 边界测试通过
|
|
220
|
+
✅ 错误处理验证通过
|
|
221
|
+
|
|
222
|
+
### .debug 文档已更新
|
|
223
|
+
记录已追加到: `.debug/[module-name]-debug.md`
|
|
224
|
+
|
|
225
|
+
### 后续建议
|
|
226
|
+
[后续优化或改进建议]
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## 质量标准
|
|
230
|
+
|
|
231
|
+
1. **精准性**:问题定位准确,修改针对性强
|
|
232
|
+
2. **安全性**:不引入新的 bug 或安全风险
|
|
233
|
+
3. **可维护性**:代码清晰,易于理解和维护
|
|
234
|
+
4. **文档完整**:Debug 记录完整,可追溯性强
|