@bbyx0011/ghostcode 0.1.0

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 (42) hide show
  1. package/bin/ghostcode-mcp +11 -0
  2. package/bin/ghostcode-mcp-darwin-arm64 +0 -0
  3. package/bin/ghostcode-mcp-darwin-x64 +0 -0
  4. package/bin/ghostcode-mcp-linux-x64 +0 -0
  5. package/bin/ghostcode-wrapper +11 -0
  6. package/bin/ghostcode-wrapper-darwin-arm64 +0 -0
  7. package/bin/ghostcode-wrapper-darwin-x64 +0 -0
  8. package/bin/ghostcode-wrapper-linux-x64 +0 -0
  9. package/bin/ghostcoded-darwin-arm64 +0 -0
  10. package/bin/ghostcoded-darwin-x64 +0 -0
  11. package/bin/ghostcoded-linux-x64 +0 -0
  12. package/dist/cli.d.ts +21 -0
  13. package/dist/cli.js +97 -0
  14. package/dist/daemon.d.ts +72 -0
  15. package/dist/index.d.ts +31 -0
  16. package/dist/index.js +35 -0
  17. package/dist/install.d.ts +61 -0
  18. package/dist/ipc.d.ts +121 -0
  19. package/dist/postinstall.d.ts +42 -0
  20. package/dist/session-lease.d.ts +110 -0
  21. package/dist/web.d.ts +51 -0
  22. package/hooks/hooks.json +101 -0
  23. package/package.json +29 -0
  24. package/prompts/codex-analyzer.md +64 -0
  25. package/prompts/codex-reviewer.md +73 -0
  26. package/prompts/gemini-analyzer.md +82 -0
  27. package/prompts/gemini-reviewer.md +91 -0
  28. package/scripts/hook-pre-compact.mjs +128 -0
  29. package/scripts/hook-pre-tool-use.mjs +225 -0
  30. package/scripts/hook-session-end.mjs +108 -0
  31. package/scripts/hook-session-start.mjs +243 -0
  32. package/scripts/hook-stop.mjs +143 -0
  33. package/scripts/hook-subagent-start.mjs +231 -0
  34. package/scripts/hook-subagent-stop.mjs +168 -0
  35. package/scripts/hook-user-prompt-submit.mjs +134 -0
  36. package/scripts/lib/daemon-client.mjs +165 -0
  37. package/scripts/lib/stdin.mjs +88 -0
  38. package/scripts/run.mjs +98 -0
  39. package/skills/execute/SKILL.md +481 -0
  40. package/skills/plan/SKILL.md +318 -0
  41. package/skills/research/SKILL.md +267 -0
  42. package/skills/review/SKILL.md +238 -0
@@ -0,0 +1,238 @@
1
+ ---
2
+ name: review
3
+ description: 双模型交叉审查:并行审查代码变更,分级处理 Critical/Warning/Info
4
+ aliases:
5
+ - team review
6
+ - 团队审查
7
+ do_not_use_when: 没有代码变更、或变更太小不值得双模型审查
8
+ ---
9
+
10
+ ## Purpose
11
+
12
+ 对 team-exec 产出的代码变更进行双模型独立交叉审查,捕获单模型审查遗漏的盲区,
13
+ 产出分级审查报告(Critical/Warning/Info),并强制修复所有 Critical 问题。
14
+
15
+ 双模型交叉验证的价值:Claude 擅长后端逻辑/安全审查,Gemini 擅长前端模式/可维护性审查,
16
+ 两者盲区不重叠,合并后覆盖面更广。
17
+
18
+ GhostCode 特殊性:
19
+ - Rust 核心代码审查重点:内存安全、并发安全、错误传播
20
+ - TS Plugin 审查重点:hook 生命周期正确性、IPC 协议合规、类型安全
21
+
22
+ ## Use When
23
+
24
+ - 用户输入 "team review"、"ccg:team-review"、"团队审查"
25
+ - 代码实施完成后(team-exec 或 spec-impl 之后)
26
+ - 需要多视角的代码质量评估
27
+ - 准备合并/发布前的质量门控
28
+
29
+ ## Do Not Use When
30
+
31
+ - 没有任何代码变更(git diff 为空)
32
+ - 仅修改文档/注释(可跳过双模型审查)
33
+ - 处于 Red 阶段(测试有意失败的 TDD 阶段)
34
+
35
+ ## Guardrails
36
+
37
+ - **MANDATORY**: Claude 和 Gemini 必须都完成审查后才能综合(不可只用一个)
38
+ - 审查范围限于 git diff 的变更,不做范围蔓延
39
+ - Critical 问题必须修复后才能结束,不可忽略
40
+ - Lead 可以直接修复 Critical 问题(审查阶段允许写代码)
41
+ - GhostCode 特定:Rust unsafe 代码块必须列为 Critical 级别审查
42
+
43
+ ## Steps
44
+
45
+ ### Step 0: MANDATORY Prompt 增强
46
+
47
+ 确认审查的范围:全量 git diff、特定文件列表、或特定提交范围。
48
+ 读取 `.claude/team-plan/` 下对应计划文件(若存在)作为审查基准。
49
+
50
+ ### Step 1: 收集变更产物
51
+
52
+ 运行 git diff 获取变更摘要:
53
+
54
+ ```bash
55
+ # 获取变更文件列表
56
+ git diff --name-only HEAD
57
+
58
+ # 获取统计信息
59
+ git diff --stat HEAD
60
+
61
+ # 获取完整 diff(用于模型审查)
62
+ git diff HEAD
63
+ ```
64
+
65
+ 如果有对应的计划文件,读取约束集和成功判据作为审查基准(OK-N 判据)。
66
+ 列出所有被修改的文件,分类:Rust 文件 / TS 文件 / 其他。
67
+
68
+ ### Step 1.5: 开启 Session Gate(MANDATORY,不可跳过)
69
+
70
+ 调用 ghostcode_session_gate_open(command_type="review", required_models=["codex", "gemini"])
71
+ → 得到 session_id,后续所有 submit/close 都使用此 session_id
72
+ 若 Daemon 离线 → 终止流程,报告错误「GhostCode Daemon 未运行」
73
+
74
+ ### Step 2: 多模型并行审查(PARALLEL)
75
+
76
+ **CRITICAL**: 必须在一条消息中同时发起两个 Bash 后台调用,run_in_background: true。
77
+
78
+ **Bash 调用 1(Codex 后端/Rust 审查)**:
79
+ ```bash
80
+ ~/.ghostcode/bin/ghostcode-wrapper --backend codex --workdir "$(pwd)" --timeout 600 --stdin <<'CODEX_REVIEW'
81
+ ROLE_FILE: ~/.ghostcode/prompts/codex-reviewer.md
82
+
83
+ 你正在对 GhostCode 项目(Rust 核心 + TS Plugin 多 Agent 协作平台)的代码变更进行后端审查。
84
+
85
+ 请重点审查 Rust 核心代码(src/core/src/ 相关文件),维度包括:
86
+ 1. 逻辑正确性:业务逻辑错误、边界条件处理、数据流正确性
87
+ 2. 并发安全性:竞态条件、死锁风险、tokio 任务取消安全
88
+ 3. 内存安全性:所有权规则遵守、unsafe 块使用合规性、生命周期正确性
89
+ 4. 错误处理:错误传播完整性、panic 使用场景、Result 处理覆盖率
90
+
91
+ 输出 JSON findings:
92
+ {
93
+ "findings": [
94
+ {
95
+ "severity": "Critical|Warning|Info",
96
+ "dimension": "logic|security|memory-safety|concurrency|error-handling",
97
+ "file": "文件路径",
98
+ "line": 行号,
99
+ "description": "问题描述",
100
+ "fix_suggestion": "修复建议"
101
+ }
102
+ ]
103
+ }
104
+ CODEX_REVIEW
105
+ ```
106
+
107
+ **Bash 调用 2(Gemini 前端/TS Plugin 审查)**:
108
+ ```bash
109
+ ~/.ghostcode/bin/ghostcode-wrapper --backend gemini --workdir "$(pwd)" --timeout 600 --stdin <<'GEMINI_REVIEW'
110
+ ROLE_FILE: ~/.ghostcode/prompts/gemini-reviewer.md
111
+
112
+ 你正在对 GhostCode 项目(Rust 核心 + TS Plugin 多 Agent 协作平台)的代码变更进行前端审查。
113
+
114
+ 请重点审查 TS Plugin 代码(src/plugin/src/ 相关文件),维度包括:
115
+ 1. 可维护性:代码可读性、函数复杂度、命名规范、注释质量
116
+ 2. React 最佳实践:组件设计、状态管理、副作用处理、性能优化
117
+ 3. 类型安全:类型推断正确性、类型断言使用、any 类型滥用
118
+ 4. IPC 协议合规:消息格式是否符合 Rust 核心约定、错误码处理、版本兼容性
119
+ 5. hook 生命周期:hook 调用顺序正确性、副作用清理、依赖数组完整性
120
+
121
+ 输出 JSON findings:
122
+ {
123
+ "findings": [
124
+ {
125
+ "severity": "Critical|Warning|Info",
126
+ "dimension": "patterns|maintainability|type-safety|ipc-compliance|hook-lifecycle",
127
+ "file": "文件路径",
128
+ "line": 行号,
129
+ "description": "问题描述",
130
+ "fix_suggestion": "修复建议"
131
+ }
132
+ ]
133
+ }
134
+ GEMINI_REVIEW
135
+ ```
136
+
137
+ 等待两个后台任务完成:使用 TaskOutput(block: true, timeout: 600000) 读取各自结果。
138
+
139
+ **wrapper 失败处理(按退出码分级)**:
140
+ - exit 127(命令不存在)→ 终止流程,提示「ghostcode-wrapper 未安装,请检查环境」
141
+ - exit 124(超时)→ 自动重试一次,仍失败则进入用户确认
142
+ - 其他(如 429 额度用完)→ AskUserQuestion 让用户选择:
143
+ [重试] / [跳过并记录 bypass_reason] / [终止整个流程]
144
+ - 用户选「跳过」→ ghostcode_session_gate_submit(session_id, model,
145
+ output_type="bypass", data={}, bypass=true, bypass_reason="quota_exceeded")
146
+ - 用户选「终止」→ ghostcode_session_gate_abort(session_id) 后退出
147
+
148
+ Codex wrapper 完成后,调用:
149
+ ```
150
+ ghostcode_session_gate_submit(session_id=<session_id>,
151
+ model="codex",
152
+ output_type="review_findings",
153
+ data=<codex wrapper 输出>)
154
+ ```
155
+
156
+ Gemini wrapper 完成后,调用:
157
+ ```
158
+ ghostcode_session_gate_submit(session_id=<session_id>,
159
+ model="gemini",
160
+ output_type="review_findings",
161
+ data=<gemini wrapper 输出>)
162
+ ```
163
+
164
+ ### Step 3: 综合发现
165
+
166
+ 调用 ghostcode_session_gate_close(session_id=<session_id>)
167
+ → 返回合并输出(含 partial 标记和 missing_models 列表)
168
+ → 若 SESSION_INCOMPLETE → 终止,必须补全 missing_models
169
+ → 若 partial=true → 报告顶部标注 WARNING PARTIAL_SESSION(有模型使用了 bypass)
170
+
171
+ 合并两个模型的发现,去重重叠问题。
172
+
173
+ 按严重性分级:
174
+ - **Critical**:安全漏洞、逻辑错误、数据丢失风险、Rust unsafe 误用 → 必须修复
175
+ - **Warning**:模式偏离、可维护性问题、类型不精确 → 建议修复
176
+ - **Info**:小改进建议、注释补充 → 可选修复
177
+
178
+ ### Step 4: 输出审查报告
179
+
180
+ **MANDATORY**: 审查报告必须使用表格格式输出,提升可读性和结构化程度。
181
+
182
+ ```markdown
183
+ ## 审查报告
184
+
185
+ **审查范围**:N 个文件 | +X / -Y 行
186
+ **审查模型**:Rust 后端 Agent + TS/前端 Agent 独立交叉审查
187
+
188
+ ### Critical (X 个) — 必须修复
189
+
190
+ | # | 维度 | 文件 | 行号 | 问题描述 | 修复建议 |
191
+ |---|------|------|------|----------|----------|
192
+ | C1 | 安全 | `file.rs` | 42 | 描述 | 建议 |
193
+ | C2 | 逻辑 | `handler.ts` | 15 | 描述 | 建议 |
194
+
195
+ ### Warning (Y 个) — 建议修复
196
+
197
+ | # | 维度 | 文件 | 行号 | 问题描述 | 修复建议 |
198
+ |---|------|------|------|----------|----------|
199
+ | W1 | 模式 | `utils.ts` | 88 | 描述 | 建议 |
200
+
201
+ ### Info (Z 个) — 可选
202
+
203
+ | # | 维度 | 文件 | 行号 | 问题描述 | 修复建议 |
204
+ |---|------|------|------|----------|----------|
205
+ | I1 | 维护 | `helper.rs` | 20 | 描述 | 建议 |
206
+
207
+ ### 已通过检查
208
+
209
+ | 检查项 | 状态 |
210
+ |--------|------|
211
+ | 内存安全(Rust 所有权规则) | 通过 |
212
+ | IPC 协议合规 | 通过 |
213
+ | 错误处理完整性 | 通过 |
214
+ ```
215
+
216
+ ### Step 5: 决策门
217
+
218
+ **Critical > 0**:
219
+ - 展示发现,使用 AskUserQuestion 询问:「立即修复 / 跳过」
220
+ - 选择修复 → Lead 直接修复(Rust 问题参考 Claude 建议,TS 问题参考 Gemini 建议)
221
+ - 修复后重新运行受影响的审查维度
222
+ - 重复直到 Critical = 0
223
+
224
+ **Critical = 0**:
225
+ - 报告通过,建议提交代码
226
+ - 提示:`git add -A && git commit -m "<type>: <描述>"`
227
+
228
+ ### Step 6: 上下文检查点
229
+
230
+ 报告当前上下文使用量。
231
+
232
+ ## Exit Criteria
233
+
234
+ - [ ] Claude + Gemini 审查均完成
235
+ - [ ] 所有发现已综合分级(Critical/Warning/Info)
236
+ - [ ] Critical = 0(已修复或用户明确跳过)
237
+ - [ ] 审查报告已输出
238
+ - [ ] GhostCode 特定:Rust unsafe 块已逐一审查