claude-code-workflow 6.3.48 → 6.3.49
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/.claude/CLAUDE.md +6 -8
- package/.claude/agents/action-planning-agent.md +28 -45
- package/.claude/agents/cli-lite-planning-agent.md +93 -1
- package/.claude/agents/code-developer.md +144 -27
- package/.claude/commands/ccw-coordinator.md +175 -21
- package/.claude/commands/ccw-debug.md +832 -0
- package/.claude/commands/ccw.md +90 -9
- package/.claude/commands/cli/cli-init.md +1 -0
- package/.claude/commands/issue/convert-to-plan.md +718 -0
- package/.claude/commands/issue/from-brainstorm.md +382 -0
- package/.claude/commands/memory/tips.md +332 -0
- package/.claude/commands/workflow/analyze-with-file.md +804 -0
- package/.claude/commands/workflow/brainstorm/auto-parallel.md +18 -43
- package/.claude/commands/workflow/brainstorm/role-analysis.md +705 -0
- package/.claude/commands/workflow/brainstorm-with-file.md +1153 -0
- package/.claude/commands/workflow/debug-with-file.md +7 -5
- package/.claude/commands/workflow/execute.md +6 -4
- package/.claude/commands/workflow/lite-plan.md +2 -2
- package/.claude/commands/workflow/plan-verify.md +162 -327
- package/.claude/commands/workflow/plan.md +162 -26
- package/.claude/commands/workflow/replan.md +78 -2
- package/.claude/commands/workflow/{review-fix.md → review-cycle-fix.md} +6 -6
- package/.claude/commands/workflow/review-module-cycle.md +2 -2
- package/.claude/commands/workflow/review-session-cycle.md +2 -2
- package/.claude/commands/workflow/tools/conflict-resolution.md +16 -26
- package/.claude/commands/workflow/tools/context-gather.md +81 -118
- package/.claude/commands/workflow/tools/task-generate-agent.md +94 -10
- package/.claude/skills/ccw-help/command.json +4 -4
- package/.claude/skills/lite-skill-generator/SKILL.md +650 -0
- package/.claude/skills/lite-skill-generator/templates/simple-skill.md +68 -0
- package/.claude/skills/lite-skill-generator/templates/style-guide.md +64 -0
- package/.claude/skills/skill-generator/SKILL.md +277 -85
- package/.claude/skills/skill-generator/phases/01-requirements-discovery.md +4 -15
- package/.claude/skills/skill-generator/phases/02-structure-generation.md +72 -17
- package/.claude/skills/skill-generator/phases/03-phase-generation.md +218 -51
- package/.claude/skills/skill-generator/phases/04-specs-templates.md +111 -41
- package/.claude/skills/skill-generator/phases/05-validation.md +139 -56
- package/.claude/skills/skill-generator/templates/autonomous-action.md +78 -268
- package/.claude/skills/skill-generator/templates/autonomous-orchestrator.md +14 -0
- package/.claude/skills/skill-generator/templates/code-analysis-action.md +12 -0
- package/.claude/skills/skill-generator/templates/llm-action.md +12 -0
- package/.claude/skills/skill-generator/templates/script-template.md +368 -0
- package/.claude/skills/skill-generator/templates/sequential-phase.md +14 -0
- package/.claude/skills/skill-generator/templates/skill-md.md +14 -0
- package/.claude/skills/skill-tuning/SKILL.md +130 -266
- package/.claude/skills/skill-tuning/phases/orchestrator.md +95 -283
- package/.claude/skills/skill-tuning/specs/problem-taxonomy.md +90 -198
- package/.claude/skills/skill-tuning/specs/tuning-strategies.md +193 -1345
- package/.claude/workflows/cli-templates/schemas/plan-verify-agent-schema.json +47 -0
- package/.claude/workflows/cli-templates/schemas/verify-json-schema.json +158 -0
- package/.claude/workflows/cli-tools-usage.md +1 -1
- package/.codex/AGENTS.md +1 -3
- package/.codex/prompts/analyze-with-file.md +607 -0
- package/.codex/prompts/brainstorm-to-cycle.md +455 -0
- package/.codex/prompts/brainstorm-with-file.md +933 -0
- package/.codex/prompts/debug-with-file.md +15 -20
- package/.codex/skills/ccw-cli-tools/SKILL.md +559 -0
- package/ccw/dist/commands/cli.d.ts.map +1 -1
- package/ccw/dist/commands/cli.js +29 -5
- package/ccw/dist/commands/cli.js.map +1 -1
- package/ccw/dist/commands/issue.d.ts +2 -0
- package/ccw/dist/commands/issue.d.ts.map +1 -1
- package/ccw/dist/commands/issue.js +62 -20
- package/ccw/dist/commands/issue.js.map +1 -1
- package/ccw/dist/config/litellm-api-config-manager.d.ts.map +1 -1
- package/ccw/dist/config/litellm-api-config-manager.js +5 -3
- package/ccw/dist/config/litellm-api-config-manager.js.map +1 -1
- package/ccw/dist/config/litellm-provider-models.d.ts +73 -0
- package/ccw/dist/config/litellm-provider-models.d.ts.map +1 -0
- package/ccw/dist/config/litellm-provider-models.js +172 -0
- package/ccw/dist/config/litellm-provider-models.js.map +1 -0
- package/ccw/dist/config/provider-models.d.ts +25 -51
- package/ccw/dist/config/provider-models.d.ts.map +1 -1
- package/ccw/dist/config/provider-models.js +84 -149
- package/ccw/dist/config/provider-models.js.map +1 -1
- package/ccw/dist/config/storage-paths.d.ts.map +1 -1
- package/ccw/dist/config/storage-paths.js +23 -5
- package/ccw/dist/config/storage-paths.js.map +1 -1
- package/ccw/dist/core/auth/csrf-middleware.js +3 -3
- package/ccw/dist/core/auth/csrf-middleware.js.map +1 -1
- package/ccw/dist/core/dashboard-generator.d.ts.map +1 -1
- package/ccw/dist/core/dashboard-generator.js +3 -1
- package/ccw/dist/core/dashboard-generator.js.map +1 -1
- package/ccw/dist/core/routes/claude-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/claude-routes.js +206 -14
- package/ccw/dist/core/routes/claude-routes.js.map +1 -1
- package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/cli-routes.js.map +1 -1
- package/ccw/dist/core/routes/commands-routes.d.ts +7 -0
- package/ccw/dist/core/routes/commands-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/commands-routes.js +480 -0
- package/ccw/dist/core/routes/commands-routes.js.map +1 -0
- package/ccw/dist/core/routes/model-routes.d.ts +11 -0
- package/ccw/dist/core/routes/model-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/model-routes.js +112 -0
- package/ccw/dist/core/routes/model-routes.js.map +1 -0
- package/ccw/dist/core/routes/nav-status-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/nav-status-routes.js +84 -1
- package/ccw/dist/core/routes/nav-status-routes.js.map +1 -1
- package/ccw/dist/core/routes/provider-routes.d.ts +11 -0
- package/ccw/dist/core/routes/provider-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/provider-routes.js +67 -0
- package/ccw/dist/core/routes/provider-routes.js.map +1 -0
- package/ccw/dist/core/routes/skills-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/skills-routes.js +219 -7
- package/ccw/dist/core/routes/skills-routes.js.map +1 -1
- package/ccw/dist/core/routes/system-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/system-routes.js +58 -6
- package/ccw/dist/core/routes/system-routes.js.map +1 -1
- package/ccw/dist/core/server.d.ts.map +1 -1
- package/ccw/dist/core/server.js +13 -0
- package/ccw/dist/core/server.js.map +1 -1
- package/ccw/dist/mcp-server/index.js +2 -2
- package/ccw/dist/mcp-server/index.js.map +1 -1
- package/ccw/dist/tools/claude-cli-tools.d.ts +48 -11
- package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
- package/ccw/dist/tools/claude-cli-tools.js +146 -50
- package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
- package/ccw/dist/tools/cli-config-manager.d.ts +1 -13
- package/ccw/dist/tools/cli-config-manager.d.ts.map +1 -1
- package/ccw/dist/tools/cli-config-manager.js +3 -27
- package/ccw/dist/tools/cli-config-manager.js.map +1 -1
- package/ccw/dist/tools/cli-executor-core.d.ts.map +1 -1
- package/ccw/dist/tools/cli-executor-core.js +7 -2
- package/ccw/dist/tools/cli-executor-core.js.map +1 -1
- package/ccw/dist/tools/cli-executor-state.d.ts.map +1 -1
- package/ccw/dist/tools/cli-history-store.d.ts +11 -0
- package/ccw/dist/tools/cli-history-store.d.ts.map +1 -1
- package/ccw/dist/tools/cli-history-store.js +82 -2
- package/ccw/dist/tools/cli-history-store.js.map +1 -1
- package/ccw/dist/tools/command-registry.d.ts +7 -0
- package/ccw/dist/tools/command-registry.d.ts.map +1 -1
- package/ccw/dist/tools/command-registry.js +14 -1
- package/ccw/dist/tools/command-registry.js.map +1 -1
- package/ccw/dist/tools/generate-module-docs.d.ts.map +1 -1
- package/ccw/dist/tools/generate-module-docs.js +11 -7
- package/ccw/dist/tools/generate-module-docs.js.map +1 -1
- package/ccw/dist/tools/litellm-executor.d.ts +1 -0
- package/ccw/dist/tools/litellm-executor.d.ts.map +1 -1
- package/ccw/dist/tools/litellm-executor.js +11 -9
- package/ccw/dist/tools/litellm-executor.js.map +1 -1
- package/ccw/dist/types/skill-types.d.ts +97 -0
- package/ccw/dist/types/skill-types.d.ts.map +1 -0
- package/ccw/dist/types/skill-types.js +6 -0
- package/ccw/dist/types/skill-types.js.map +1 -0
- package/ccw/src/commands/cli.ts +36 -5
- package/ccw/src/commands/issue.ts +81 -26
- package/ccw/src/config/litellm-api-config-manager.ts +5 -3
- package/ccw/src/config/litellm-provider-models.ts +222 -0
- package/ccw/src/config/provider-models.ts +91 -190
- package/ccw/src/config/storage-paths.ts +20 -5
- package/ccw/src/core/auth/csrf-middleware.ts +3 -3
- package/ccw/src/core/dashboard-generator.ts +3 -1
- package/ccw/src/core/routes/claude-routes.ts +233 -15
- package/ccw/src/core/routes/cli-routes.ts +2 -3
- package/ccw/src/core/routes/commands-routes.ts +620 -0
- package/ccw/src/core/routes/nav-status-routes.ts +95 -1
- package/ccw/src/core/routes/provider-routes.ts +78 -0
- package/ccw/src/core/routes/skills-routes.ts +266 -45
- package/ccw/src/core/routes/system-routes.ts +102 -50
- package/ccw/src/core/server.ts +13 -0
- package/ccw/src/mcp-server/index.ts +2 -2
- package/ccw/src/templates/dashboard-css/18-cli-settings.css +35 -0
- package/ccw/src/templates/dashboard-css/37-commands.css +193 -0
- package/ccw/src/templates/dashboard-js/components/navigation.js +4 -0
- package/ccw/src/templates/dashboard-js/i18n.js +116 -0
- package/ccw/src/templates/dashboard-js/views/cli-manager.js +249 -4
- package/ccw/src/templates/dashboard-js/views/commands-manager.js +503 -0
- package/ccw/src/templates/dashboard-js/views/issue-manager.js +7 -7
- package/ccw/src/templates/dashboard-js/views/mcp-manager.js +2 -7
- package/ccw/src/templates/dashboard-js/views/skills-manager.js +164 -23
- package/ccw/src/templates/dashboard.html +7 -0
- package/ccw/src/tools/claude-cli-tools.ts +170 -56
- package/ccw/src/tools/cli-config-manager.ts +2 -33
- package/ccw/src/tools/cli-executor-core.ts +8 -2
- package/ccw/src/tools/cli-history-store.ts +92 -2
- package/ccw/src/tools/command-registry.ts +16 -1
- package/ccw/src/tools/generate-module-docs.ts +11 -7
- package/ccw/src/tools/litellm-executor.ts +13 -9
- package/ccw/src/types/skill-types.ts +99 -0
- package/package.json +1 -1
- package/.claude/commands/enhance-prompt.md +0 -93
- package/.claude/commands/memory/code-map-memory.md +0 -687
- package/.claude/commands/memory/docs.md +0 -615
- package/.claude/commands/memory/load-skill-memory.md +0 -182
- package/.claude/commands/memory/skill-memory.md +0 -525
- package/.claude/commands/memory/swagger-docs.md +0 -773
- package/.claude/commands/memory/tech-research-rules.md +0 -310
- package/.claude/commands/memory/workflow-skill-memory.md +0 -517
- package/.claude/commands/task/breakdown.md +0 -208
- package/.claude/commands/task/create.md +0 -152
- package/.claude/commands/task/execute.md +0 -270
- package/.claude/commands/task/replan.md +0 -441
- package/.claude/commands/version.md +0 -254
- package/.claude/commands/workflow/action-plan-verify.md +0 -485
- package/.claude/commands/workflow/brainstorm/api-designer.md +0 -587
- package/.claude/commands/workflow/brainstorm/data-architect.md +0 -220
- package/.claude/commands/workflow/brainstorm/product-manager.md +0 -200
- package/.claude/commands/workflow/brainstorm/product-owner.md +0 -200
- package/.claude/commands/workflow/brainstorm/scrum-master.md +0 -200
- package/.claude/commands/workflow/brainstorm/subject-matter-expert.md +0 -200
- package/.claude/commands/workflow/brainstorm/system-architect.md +0 -389
- package/.claude/commands/workflow/brainstorm/ui-designer.md +0 -221
- package/.claude/commands/workflow/brainstorm/ux-expert.md +0 -221
- package/.claude/commands/workflow/debug.md +0 -331
- package/.claude/commands/workflow/develop-with-file.md +0 -1044
- package/.claude/skills/ccw-loop/README.md +0 -303
- package/.claude/skills/skill-generator/templates/script-bash.md +0 -277
- package/.claude/skills/skill-generator/templates/script-python.md +0 -198
- package/.codex/prompts/debug.md +0 -318
- package/ccw/src/core/routes/mcp-routes.ts.backup +0 -549
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
# Python Script Template
|
|
2
|
-
|
|
3
|
-
Python 脚本模板,用于生成技能中的确定性脚本。
|
|
4
|
-
|
|
5
|
-
## 模板代码
|
|
6
|
-
|
|
7
|
-
```python
|
|
8
|
-
#!/usr/bin/env python3
|
|
9
|
-
"""
|
|
10
|
-
{{script_description}}
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
import argparse
|
|
14
|
-
import json
|
|
15
|
-
import sys
|
|
16
|
-
from pathlib import Path
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def main():
|
|
20
|
-
# 1. 定义参数
|
|
21
|
-
parser = argparse.ArgumentParser(description='{{script_description}}')
|
|
22
|
-
parser.add_argument('--input-path', type=str, required=True,
|
|
23
|
-
help='输入文件路径')
|
|
24
|
-
parser.add_argument('--output-dir', type=str, required=True,
|
|
25
|
-
help='输出目录(由调用方指定)')
|
|
26
|
-
# 添加更多参数...
|
|
27
|
-
|
|
28
|
-
args = parser.parse_args()
|
|
29
|
-
|
|
30
|
-
# 2. 验证输入
|
|
31
|
-
input_path = Path(args.input_path)
|
|
32
|
-
if not input_path.exists():
|
|
33
|
-
print(f"错误: 输入文件不存在: {input_path}", file=sys.stderr)
|
|
34
|
-
sys.exit(1)
|
|
35
|
-
|
|
36
|
-
output_dir = Path(args.output_dir)
|
|
37
|
-
output_dir.mkdir(parents=True, exist_ok=True)
|
|
38
|
-
|
|
39
|
-
# 3. 执行核心逻辑
|
|
40
|
-
try:
|
|
41
|
-
result = process(input_path, output_dir)
|
|
42
|
-
except Exception as e:
|
|
43
|
-
print(f"错误: {e}", file=sys.stderr)
|
|
44
|
-
sys.exit(1)
|
|
45
|
-
|
|
46
|
-
# 4. 输出 JSON 结果
|
|
47
|
-
print(json.dumps(result))
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def process(input_path: Path, output_dir: Path) -> dict:
|
|
51
|
-
"""
|
|
52
|
-
核心处理逻辑
|
|
53
|
-
|
|
54
|
-
Args:
|
|
55
|
-
input_path: 输入文件路径
|
|
56
|
-
output_dir: 输出目录
|
|
57
|
-
|
|
58
|
-
Returns:
|
|
59
|
-
dict: 包含输出结果的字典
|
|
60
|
-
"""
|
|
61
|
-
# TODO: 实现处理逻辑
|
|
62
|
-
|
|
63
|
-
output_file = output_dir / 'result.json'
|
|
64
|
-
|
|
65
|
-
# 示例:读取并处理数据
|
|
66
|
-
with open(input_path, 'r', encoding='utf-8') as f:
|
|
67
|
-
data = json.load(f)
|
|
68
|
-
|
|
69
|
-
# 处理数据...
|
|
70
|
-
processed_count = len(data) if isinstance(data, list) else 1
|
|
71
|
-
|
|
72
|
-
# 写入输出
|
|
73
|
-
with open(output_file, 'w', encoding='utf-8') as f:
|
|
74
|
-
json.dump(data, f, indent=2, ensure_ascii=False)
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
'output_file': str(output_file),
|
|
78
|
-
'items_processed': processed_count,
|
|
79
|
-
'status': 'success'
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if __name__ == '__main__':
|
|
84
|
-
main()
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## 变量说明
|
|
88
|
-
|
|
89
|
-
| 变量 | 说明 |
|
|
90
|
-
|------|------|
|
|
91
|
-
| `{{script_description}}` | 脚本功能描述 |
|
|
92
|
-
|
|
93
|
-
## 使用规范
|
|
94
|
-
|
|
95
|
-
### 输入参数
|
|
96
|
-
|
|
97
|
-
- 使用 `argparse` 定义参数
|
|
98
|
-
- 参数名使用 kebab-case:`--input-path`
|
|
99
|
-
- 必需参数设置 `required=True`
|
|
100
|
-
- 可选参数提供 `default` 值
|
|
101
|
-
|
|
102
|
-
### 输出格式
|
|
103
|
-
|
|
104
|
-
- 最后一行打印单行 JSON
|
|
105
|
-
- 包含所有输出文件路径和关键数据
|
|
106
|
-
- 错误信息输出到 stderr
|
|
107
|
-
|
|
108
|
-
### 错误处理
|
|
109
|
-
|
|
110
|
-
```python
|
|
111
|
-
# 验证错误 - 直接退出
|
|
112
|
-
if not valid:
|
|
113
|
-
print("错误信息", file=sys.stderr)
|
|
114
|
-
sys.exit(1)
|
|
115
|
-
|
|
116
|
-
# 运行时错误 - 捕获并退出
|
|
117
|
-
try:
|
|
118
|
-
result = process()
|
|
119
|
-
except Exception as e:
|
|
120
|
-
print(f"错误: {e}", file=sys.stderr)
|
|
121
|
-
sys.exit(1)
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## 常用模式
|
|
125
|
-
|
|
126
|
-
### 文件处理
|
|
127
|
-
|
|
128
|
-
```python
|
|
129
|
-
def process_files(input_dir: Path, pattern: str = '*.json') -> list:
|
|
130
|
-
results = []
|
|
131
|
-
for file in input_dir.glob(pattern):
|
|
132
|
-
with open(file, 'r') as f:
|
|
133
|
-
data = json.load(f)
|
|
134
|
-
results.append({'file': str(file), 'data': data})
|
|
135
|
-
return results
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### 数据转换
|
|
139
|
-
|
|
140
|
-
```python
|
|
141
|
-
def transform_data(data: dict) -> dict:
|
|
142
|
-
return {
|
|
143
|
-
'id': data.get('id'),
|
|
144
|
-
'name': data.get('name', '').strip(),
|
|
145
|
-
'timestamp': datetime.now().isoformat()
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### 调用外部命令
|
|
150
|
-
|
|
151
|
-
```python
|
|
152
|
-
import subprocess
|
|
153
|
-
|
|
154
|
-
def run_command(cmd: list) -> str:
|
|
155
|
-
result = subprocess.run(cmd, capture_output=True, text=True)
|
|
156
|
-
if result.returncode != 0:
|
|
157
|
-
raise RuntimeError(result.stderr)
|
|
158
|
-
return result.stdout
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
## 生成函数
|
|
162
|
-
|
|
163
|
-
```javascript
|
|
164
|
-
function generatePythonScript(scriptConfig) {
|
|
165
|
-
return `#!/usr/bin/env python3
|
|
166
|
-
"""
|
|
167
|
-
${scriptConfig.description}
|
|
168
|
-
"""
|
|
169
|
-
|
|
170
|
-
import argparse
|
|
171
|
-
import json
|
|
172
|
-
import sys
|
|
173
|
-
from pathlib import Path
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
def main():
|
|
177
|
-
parser = argparse.ArgumentParser(description='${scriptConfig.description}')
|
|
178
|
-
${scriptConfig.inputs.map(i =>
|
|
179
|
-
` parser.add_argument('--${i.name}', type=${i.type || 'str'}, ${i.required ? 'required=True' : `default='${i.default}'`},
|
|
180
|
-
help='${i.description}')`
|
|
181
|
-
).join('\n')}
|
|
182
|
-
args = parser.parse_args()
|
|
183
|
-
|
|
184
|
-
# TODO: 实现处理逻辑
|
|
185
|
-
result = {
|
|
186
|
-
${scriptConfig.outputs.map(o =>
|
|
187
|
-
` '${o.name}': None # ${o.description}`
|
|
188
|
-
).join(',\n')}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
print(json.dumps(result))
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if __name__ == '__main__':
|
|
195
|
-
main()
|
|
196
|
-
`;
|
|
197
|
-
}
|
|
198
|
-
```
|
package/.codex/prompts/debug.md
DELETED
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Interactive hypothesis-driven debugging with NDJSON logging, iterative until resolved
|
|
3
|
-
argument-hint: BUG="<bug description or error message>"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Workflow Debug Command
|
|
7
|
-
|
|
8
|
-
## Overview
|
|
9
|
-
|
|
10
|
-
Evidence-based interactive debugging command. Systematically identifies root causes through hypothesis-driven logging and iterative verification.
|
|
11
|
-
|
|
12
|
-
**Core workflow**: Explore → Add Logging → Reproduce → Analyze Log → Fix → Verify
|
|
13
|
-
|
|
14
|
-
## Bug Description
|
|
15
|
-
|
|
16
|
-
**Target bug**: $BUG
|
|
17
|
-
|
|
18
|
-
## Execution Process
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
Session Detection:
|
|
22
|
-
├─ Check if debug session exists for this bug
|
|
23
|
-
├─ EXISTS + debug.log has content → Analyze mode
|
|
24
|
-
└─ NOT_FOUND or empty log → Explore mode
|
|
25
|
-
|
|
26
|
-
Explore Mode:
|
|
27
|
-
├─ Locate error source in codebase
|
|
28
|
-
├─ Generate testable hypotheses (dynamic count)
|
|
29
|
-
├─ Add NDJSON logging instrumentation
|
|
30
|
-
└─ Output: Hypothesis list + await user reproduction
|
|
31
|
-
|
|
32
|
-
Analyze Mode:
|
|
33
|
-
├─ Parse debug.log, validate each hypothesis
|
|
34
|
-
└─ Decision:
|
|
35
|
-
├─ Confirmed → Fix root cause
|
|
36
|
-
├─ Inconclusive → Add more logging, iterate
|
|
37
|
-
└─ All rejected → Generate new hypotheses
|
|
38
|
-
|
|
39
|
-
Fix & Cleanup:
|
|
40
|
-
├─ Apply fix based on confirmed hypothesis
|
|
41
|
-
├─ User verifies
|
|
42
|
-
├─ Remove debug instrumentation
|
|
43
|
-
└─ If not fixed → Return to Analyze mode
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Implementation
|
|
47
|
-
|
|
48
|
-
### Session Setup & Mode Detection
|
|
49
|
-
|
|
50
|
-
```javascript
|
|
51
|
-
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
|
|
52
|
-
|
|
53
|
-
const bugSlug = "$BUG".toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 30)
|
|
54
|
-
const dateStr = getUtc8ISOString().substring(0, 10)
|
|
55
|
-
|
|
56
|
-
const sessionId = `DBG-${bugSlug}-${dateStr}`
|
|
57
|
-
const sessionFolder = `.workflow/.debug/${sessionId}`
|
|
58
|
-
const debugLogPath = `${sessionFolder}/debug.log`
|
|
59
|
-
|
|
60
|
-
// Auto-detect mode
|
|
61
|
-
const sessionExists = fs.existsSync(sessionFolder)
|
|
62
|
-
const logHasContent = sessionExists && fs.existsSync(debugLogPath) && fs.statSync(debugLogPath).size > 0
|
|
63
|
-
|
|
64
|
-
const mode = logHasContent ? 'analyze' : 'explore'
|
|
65
|
-
|
|
66
|
-
if (!sessionExists) {
|
|
67
|
-
bash(`mkdir -p ${sessionFolder}`)
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
### Explore Mode
|
|
74
|
-
|
|
75
|
-
**Step 1.1: Locate Error Source**
|
|
76
|
-
|
|
77
|
-
```javascript
|
|
78
|
-
// Extract keywords from bug description
|
|
79
|
-
const keywords = extractErrorKeywords("$BUG")
|
|
80
|
-
// e.g., ['Stack Length', '未找到', 'registered 0']
|
|
81
|
-
|
|
82
|
-
// Search codebase for error locations
|
|
83
|
-
for (const keyword of keywords) {
|
|
84
|
-
Grep({ pattern: keyword, path: ".", output_mode: "content", "-C": 3 })
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Identify affected files and functions
|
|
88
|
-
const affectedLocations = [...] // from search results
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
**Step 1.2: Generate Hypotheses (Dynamic)**
|
|
92
|
-
|
|
93
|
-
```javascript
|
|
94
|
-
// Hypothesis categories based on error pattern
|
|
95
|
-
const HYPOTHESIS_PATTERNS = {
|
|
96
|
-
"not found|missing|undefined|未找到": "data_mismatch",
|
|
97
|
-
"0|empty|zero|registered 0": "logic_error",
|
|
98
|
-
"timeout|connection|sync": "integration_issue",
|
|
99
|
-
"type|format|parse": "type_mismatch"
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Generate hypotheses based on actual issue (NOT fixed count)
|
|
103
|
-
function generateHypotheses(bugDescription, affectedLocations) {
|
|
104
|
-
const hypotheses = []
|
|
105
|
-
|
|
106
|
-
// Analyze bug and create targeted hypotheses
|
|
107
|
-
// Each hypothesis has:
|
|
108
|
-
// - id: H1, H2, ... (dynamic count)
|
|
109
|
-
// - description: What might be wrong
|
|
110
|
-
// - testable_condition: What to log
|
|
111
|
-
// - logging_point: Where to add instrumentation
|
|
112
|
-
|
|
113
|
-
return hypotheses // Could be 1, 3, 5, or more
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const hypotheses = generateHypotheses("$BUG", affectedLocations)
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
**Step 1.3: Add NDJSON Instrumentation**
|
|
120
|
-
|
|
121
|
-
For each hypothesis, add logging at the relevant location:
|
|
122
|
-
|
|
123
|
-
**Python template**:
|
|
124
|
-
```python
|
|
125
|
-
# region debug [H{n}]
|
|
126
|
-
try:
|
|
127
|
-
import json, time
|
|
128
|
-
_dbg = {
|
|
129
|
-
"sid": "{sessionId}",
|
|
130
|
-
"hid": "H{n}",
|
|
131
|
-
"loc": "{file}:{line}",
|
|
132
|
-
"msg": "{testable_condition}",
|
|
133
|
-
"data": {
|
|
134
|
-
# Capture relevant values here
|
|
135
|
-
},
|
|
136
|
-
"ts": int(time.time() * 1000)
|
|
137
|
-
}
|
|
138
|
-
with open(r"{debugLogPath}", "a", encoding="utf-8") as _f:
|
|
139
|
-
_f.write(json.dumps(_dbg, ensure_ascii=False) + "\n")
|
|
140
|
-
except: pass
|
|
141
|
-
# endregion
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
**JavaScript/TypeScript template**:
|
|
145
|
-
```javascript
|
|
146
|
-
// region debug [H{n}]
|
|
147
|
-
try {
|
|
148
|
-
require('fs').appendFileSync("{debugLogPath}", JSON.stringify({
|
|
149
|
-
sid: "{sessionId}",
|
|
150
|
-
hid: "H{n}",
|
|
151
|
-
loc: "{file}:{line}",
|
|
152
|
-
msg: "{testable_condition}",
|
|
153
|
-
data: { /* Capture relevant values */ },
|
|
154
|
-
ts: Date.now()
|
|
155
|
-
}) + "\n");
|
|
156
|
-
} catch(_) {}
|
|
157
|
-
// endregion
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
**Output to user**:
|
|
161
|
-
```
|
|
162
|
-
## Hypotheses Generated
|
|
163
|
-
|
|
164
|
-
Based on error "$BUG", generated {n} hypotheses:
|
|
165
|
-
|
|
166
|
-
{hypotheses.map(h => `
|
|
167
|
-
### ${h.id}: ${h.description}
|
|
168
|
-
- Logging at: ${h.logging_point}
|
|
169
|
-
- Testing: ${h.testable_condition}
|
|
170
|
-
`).join('')}
|
|
171
|
-
|
|
172
|
-
**Debug log**: ${debugLogPath}
|
|
173
|
-
|
|
174
|
-
**Next**: Run reproduction steps, then come back for analysis.
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
### Analyze Mode
|
|
180
|
-
|
|
181
|
-
```javascript
|
|
182
|
-
// Parse NDJSON log
|
|
183
|
-
const entries = Read(debugLogPath).split('\n')
|
|
184
|
-
.filter(l => l.trim())
|
|
185
|
-
.map(l => JSON.parse(l))
|
|
186
|
-
|
|
187
|
-
// Group by hypothesis
|
|
188
|
-
const byHypothesis = groupBy(entries, 'hid')
|
|
189
|
-
|
|
190
|
-
// Validate each hypothesis
|
|
191
|
-
for (const [hid, logs] of Object.entries(byHypothesis)) {
|
|
192
|
-
const hypothesis = hypotheses.find(h => h.id === hid)
|
|
193
|
-
const latestLog = logs[logs.length - 1]
|
|
194
|
-
|
|
195
|
-
// Check if evidence confirms or rejects hypothesis
|
|
196
|
-
const verdict = evaluateEvidence(hypothesis, latestLog.data)
|
|
197
|
-
// Returns: 'confirmed' | 'rejected' | 'inconclusive'
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
**Output**:
|
|
202
|
-
```
|
|
203
|
-
## Evidence Analysis
|
|
204
|
-
|
|
205
|
-
Analyzed ${entries.length} log entries.
|
|
206
|
-
|
|
207
|
-
${results.map(r => `
|
|
208
|
-
### ${r.id}: ${r.description}
|
|
209
|
-
- **Status**: ${r.verdict}
|
|
210
|
-
- **Evidence**: ${JSON.stringify(r.evidence)}
|
|
211
|
-
- **Reason**: ${r.reason}
|
|
212
|
-
`).join('')}
|
|
213
|
-
|
|
214
|
-
${confirmedHypothesis ? `
|
|
215
|
-
## Root Cause Identified
|
|
216
|
-
|
|
217
|
-
**${confirmedHypothesis.id}**: ${confirmedHypothesis.description}
|
|
218
|
-
|
|
219
|
-
Ready to fix.
|
|
220
|
-
` : `
|
|
221
|
-
## Need More Evidence
|
|
222
|
-
|
|
223
|
-
Add more logging or refine hypotheses.
|
|
224
|
-
`}
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
---
|
|
228
|
-
|
|
229
|
-
### Fix & Cleanup
|
|
230
|
-
|
|
231
|
-
```javascript
|
|
232
|
-
// Apply fix based on confirmed hypothesis
|
|
233
|
-
// ... Edit affected files
|
|
234
|
-
|
|
235
|
-
// After user verifies fix works:
|
|
236
|
-
|
|
237
|
-
// Remove debug instrumentation (search for region markers)
|
|
238
|
-
const instrumentedFiles = Grep({
|
|
239
|
-
pattern: "# region debug|// region debug",
|
|
240
|
-
output_mode: "files_with_matches"
|
|
241
|
-
})
|
|
242
|
-
|
|
243
|
-
for (const file of instrumentedFiles) {
|
|
244
|
-
// Remove content between region markers
|
|
245
|
-
removeDebugRegions(file)
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
console.log(`
|
|
249
|
-
## Debug Complete
|
|
250
|
-
|
|
251
|
-
- Root cause: ${confirmedHypothesis.description}
|
|
252
|
-
- Fix applied to: ${modifiedFiles.join(', ')}
|
|
253
|
-
- Debug instrumentation removed
|
|
254
|
-
`)
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
---
|
|
258
|
-
|
|
259
|
-
## Debug Log Format (NDJSON)
|
|
260
|
-
|
|
261
|
-
Each line is a JSON object:
|
|
262
|
-
|
|
263
|
-
```json
|
|
264
|
-
{"sid":"DBG-xxx-2025-12-18","hid":"H1","loc":"file.py:func:42","msg":"Check dict keys","data":{"keys":["a","b"],"target":"c","found":false},"ts":1734567890123}
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
| Field | Description |
|
|
268
|
-
|-------|-------------|
|
|
269
|
-
| `sid` | Session ID |
|
|
270
|
-
| `hid` | Hypothesis ID (H1, H2, ...) |
|
|
271
|
-
| `loc` | Code location |
|
|
272
|
-
| `msg` | What's being tested |
|
|
273
|
-
| `data` | Captured values |
|
|
274
|
-
| `ts` | Timestamp (ms) |
|
|
275
|
-
|
|
276
|
-
## Session Folder
|
|
277
|
-
|
|
278
|
-
```
|
|
279
|
-
.workflow/.debug/DBG-{slug}-{date}/
|
|
280
|
-
├── debug.log # NDJSON log (main artifact)
|
|
281
|
-
└── resolution.md # Summary after fix (optional)
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
## Iteration Flow
|
|
285
|
-
|
|
286
|
-
```
|
|
287
|
-
First Call (/prompts:debug BUG="error"):
|
|
288
|
-
├─ No session exists → Explore mode
|
|
289
|
-
├─ Extract error keywords, search codebase
|
|
290
|
-
├─ Generate hypotheses, add logging
|
|
291
|
-
└─ Await user reproduction
|
|
292
|
-
|
|
293
|
-
After Reproduction (/prompts:debug BUG="error"):
|
|
294
|
-
├─ Session exists + debug.log has content → Analyze mode
|
|
295
|
-
├─ Parse log, evaluate hypotheses
|
|
296
|
-
└─ Decision:
|
|
297
|
-
├─ Confirmed → Fix → User verify
|
|
298
|
-
│ ├─ Fixed → Cleanup → Done
|
|
299
|
-
│ └─ Not fixed → Add logging → Iterate
|
|
300
|
-
├─ Inconclusive → Add logging → Iterate
|
|
301
|
-
└─ All rejected → New hypotheses → Iterate
|
|
302
|
-
|
|
303
|
-
Output:
|
|
304
|
-
└─ .workflow/.debug/DBG-{slug}-{date}/debug.log
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
## Error Handling
|
|
308
|
-
|
|
309
|
-
| Situation | Action |
|
|
310
|
-
|-----------|--------|
|
|
311
|
-
| Empty debug.log | Verify reproduction triggered the code path |
|
|
312
|
-
| All hypotheses rejected | Generate new hypotheses with broader scope |
|
|
313
|
-
| Fix doesn't work | Iterate with more granular logging |
|
|
314
|
-
| >5 iterations | Escalate with collected evidence |
|
|
315
|
-
|
|
316
|
-
---
|
|
317
|
-
|
|
318
|
-
**Now execute the debug workflow for bug**: $BUG
|