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
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
# Script Template
|
|
2
|
+
|
|
3
|
+
统一的脚本模板,覆盖 Bash 和 Python 两种运行时。
|
|
4
|
+
|
|
5
|
+
## Usage Context
|
|
6
|
+
|
|
7
|
+
| Phase | Usage |
|
|
8
|
+
|-------|-------|
|
|
9
|
+
| Optional | Phase/Action 中声明 `## Scripts` 时使用 |
|
|
10
|
+
| Execution | 通过 `ExecuteScript('script-id', params)` 调用 |
|
|
11
|
+
| Output Location | `.claude/skills/{skill-name}/scripts/{script-id}.{ext}` |
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 调用接口规范
|
|
16
|
+
|
|
17
|
+
所有脚本共享相同的调用约定:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
调用者
|
|
21
|
+
↓ ExecuteScript('script-id', { key: value })
|
|
22
|
+
↓
|
|
23
|
+
脚本入口
|
|
24
|
+
├─ 参数解析 (--key value)
|
|
25
|
+
├─ 输入验证 (必需参数检查, 文件存在)
|
|
26
|
+
├─ 核心处理 (数据读取 → 转换 → 写入)
|
|
27
|
+
└─ 输出结果 (最后一行: 单行 JSON → stdout)
|
|
28
|
+
├─ 成功: {"status":"success", "output_file":"...", ...}
|
|
29
|
+
└─ 失败: stderr 输出错误信息, exit 1
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 返回格式
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
interface ScriptResult {
|
|
36
|
+
success: boolean; // exit code === 0
|
|
37
|
+
stdout: string; // 标准输出
|
|
38
|
+
stderr: string; // 标准错误
|
|
39
|
+
outputs: object; // 从 stdout 最后一行解析的 JSON
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 参数约定
|
|
44
|
+
|
|
45
|
+
| 参数 | 必需 | 说明 |
|
|
46
|
+
|------|------|------|
|
|
47
|
+
| `--input-path` | ✓ | 输入文件路径 |
|
|
48
|
+
| `--output-dir` | ✓ | 输出目录(由调用方指定) |
|
|
49
|
+
| 其他 | 按需 | 脚本特定参数 |
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Bash 实现
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
#!/bin/bash
|
|
57
|
+
# {{script_description}}
|
|
58
|
+
|
|
59
|
+
set -euo pipefail
|
|
60
|
+
|
|
61
|
+
# ============================================================
|
|
62
|
+
# 参数解析
|
|
63
|
+
# ============================================================
|
|
64
|
+
|
|
65
|
+
INPUT_PATH=""
|
|
66
|
+
OUTPUT_DIR=""
|
|
67
|
+
|
|
68
|
+
while [[ "$#" -gt 0 ]]; do
|
|
69
|
+
case $1 in
|
|
70
|
+
--input-path) INPUT_PATH="$2"; shift ;;
|
|
71
|
+
--output-dir) OUTPUT_DIR="$2"; shift ;;
|
|
72
|
+
--help)
|
|
73
|
+
echo "用法: $0 --input-path <path> --output-dir <dir>"
|
|
74
|
+
exit 0
|
|
75
|
+
;;
|
|
76
|
+
*)
|
|
77
|
+
echo "错误: 未知参数 $1" >&2
|
|
78
|
+
exit 1
|
|
79
|
+
;;
|
|
80
|
+
esac
|
|
81
|
+
shift
|
|
82
|
+
done
|
|
83
|
+
|
|
84
|
+
# ============================================================
|
|
85
|
+
# 参数验证
|
|
86
|
+
# ============================================================
|
|
87
|
+
|
|
88
|
+
[[ -z "$INPUT_PATH" ]] && { echo "错误: --input-path 是必需参数" >&2; exit 1; }
|
|
89
|
+
[[ -z "$OUTPUT_DIR" ]] && { echo "错误: --output-dir 是必需参数" >&2; exit 1; }
|
|
90
|
+
[[ ! -f "$INPUT_PATH" ]] && { echo "错误: 输入文件不存在: $INPUT_PATH" >&2; exit 1; }
|
|
91
|
+
command -v jq &> /dev/null || { echo "错误: 需要安装 jq" >&2; exit 1; }
|
|
92
|
+
|
|
93
|
+
mkdir -p "$OUTPUT_DIR"
|
|
94
|
+
|
|
95
|
+
# ============================================================
|
|
96
|
+
# 核心逻辑
|
|
97
|
+
# ============================================================
|
|
98
|
+
|
|
99
|
+
OUTPUT_FILE="$OUTPUT_DIR/result.txt"
|
|
100
|
+
ITEMS_COUNT=0
|
|
101
|
+
|
|
102
|
+
# TODO: 实现处理逻辑
|
|
103
|
+
while IFS= read -r line; do
|
|
104
|
+
echo "$line" >> "$OUTPUT_FILE"
|
|
105
|
+
((ITEMS_COUNT++))
|
|
106
|
+
done < "$INPUT_PATH"
|
|
107
|
+
|
|
108
|
+
# ============================================================
|
|
109
|
+
# 输出 JSON 结果(使用 jq 构建,避免转义问题)
|
|
110
|
+
# ============================================================
|
|
111
|
+
|
|
112
|
+
jq -n \
|
|
113
|
+
--arg output_file "$OUTPUT_FILE" \
|
|
114
|
+
--argjson items_processed "$ITEMS_COUNT" \
|
|
115
|
+
'{output_file: $output_file, items_processed: $items_processed, status: "success"}'
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Bash 常用模式
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# 文件遍历
|
|
122
|
+
for file in "$INPUT_DIR"/*.json; do
|
|
123
|
+
[[ -f "$file" ]] || continue
|
|
124
|
+
# 处理逻辑...
|
|
125
|
+
done
|
|
126
|
+
|
|
127
|
+
# 临时文件 (自动清理)
|
|
128
|
+
TEMP_FILE=$(mktemp)
|
|
129
|
+
trap "rm -f $TEMP_FILE" EXIT
|
|
130
|
+
|
|
131
|
+
# 工具依赖检查
|
|
132
|
+
require_command() {
|
|
133
|
+
command -v "$1" &> /dev/null || { echo "错误: 需要 $1" >&2; exit 1; }
|
|
134
|
+
}
|
|
135
|
+
require_command jq
|
|
136
|
+
|
|
137
|
+
# jq 处理
|
|
138
|
+
VALUE=$(jq -r '.field' "$INPUT_PATH") # 读取字段
|
|
139
|
+
jq '.field = "new"' input.json > output.json # 修改字段
|
|
140
|
+
jq -s 'add' file1.json file2.json > merged.json # 合并文件
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Python 实现
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
#!/usr/bin/env python3
|
|
149
|
+
"""
|
|
150
|
+
{{script_description}}
|
|
151
|
+
"""
|
|
152
|
+
|
|
153
|
+
import argparse
|
|
154
|
+
import json
|
|
155
|
+
import sys
|
|
156
|
+
from pathlib import Path
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def main():
|
|
160
|
+
parser = argparse.ArgumentParser(description='{{script_description}}')
|
|
161
|
+
parser.add_argument('--input-path', type=str, required=True, help='输入文件路径')
|
|
162
|
+
parser.add_argument('--output-dir', type=str, required=True, help='输出目录')
|
|
163
|
+
args = parser.parse_args()
|
|
164
|
+
|
|
165
|
+
# 验证输入
|
|
166
|
+
input_path = Path(args.input_path)
|
|
167
|
+
if not input_path.exists():
|
|
168
|
+
print(f"错误: 输入文件不存在: {input_path}", file=sys.stderr)
|
|
169
|
+
sys.exit(1)
|
|
170
|
+
|
|
171
|
+
output_dir = Path(args.output_dir)
|
|
172
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
|
173
|
+
|
|
174
|
+
# 执行处理
|
|
175
|
+
try:
|
|
176
|
+
result = process(input_path, output_dir)
|
|
177
|
+
except Exception as e:
|
|
178
|
+
print(f"错误: {e}", file=sys.stderr)
|
|
179
|
+
sys.exit(1)
|
|
180
|
+
|
|
181
|
+
# 输出 JSON 结果
|
|
182
|
+
print(json.dumps(result))
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def process(input_path: Path, output_dir: Path) -> dict:
|
|
186
|
+
"""核心处理逻辑"""
|
|
187
|
+
# TODO: 实现处理逻辑
|
|
188
|
+
|
|
189
|
+
output_file = output_dir / 'result.json'
|
|
190
|
+
|
|
191
|
+
with open(input_path, 'r', encoding='utf-8') as f:
|
|
192
|
+
data = json.load(f)
|
|
193
|
+
|
|
194
|
+
processed_count = len(data) if isinstance(data, list) else 1
|
|
195
|
+
|
|
196
|
+
with open(output_file, 'w', encoding='utf-8') as f:
|
|
197
|
+
json.dump(data, f, indent=2, ensure_ascii=False)
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
'output_file': str(output_file),
|
|
201
|
+
'items_processed': processed_count,
|
|
202
|
+
'status': 'success'
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
if __name__ == '__main__':
|
|
207
|
+
main()
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Python 常用模式
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
# 文件遍历
|
|
214
|
+
def process_files(input_dir: Path, pattern: str = '*.json') -> list:
|
|
215
|
+
return [
|
|
216
|
+
{'file': str(f), 'data': json.load(f.open())}
|
|
217
|
+
for f in input_dir.glob(pattern)
|
|
218
|
+
]
|
|
219
|
+
|
|
220
|
+
# 数据转换
|
|
221
|
+
def transform(data: dict) -> dict:
|
|
222
|
+
return {
|
|
223
|
+
'id': data.get('id'),
|
|
224
|
+
'name': data.get('name', '').strip(),
|
|
225
|
+
'timestamp': datetime.now().isoformat()
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
# 外部命令调用
|
|
229
|
+
import subprocess
|
|
230
|
+
|
|
231
|
+
def run_command(cmd: list) -> str:
|
|
232
|
+
result = subprocess.run(cmd, capture_output=True, text=True)
|
|
233
|
+
if result.returncode != 0:
|
|
234
|
+
raise RuntimeError(result.stderr)
|
|
235
|
+
return result.stdout
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## 运行时选择指南
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
任务特征
|
|
244
|
+
↓
|
|
245
|
+
├─ 文件处理 / 系统命令 / 管道操作
|
|
246
|
+
│ └─ 选 Bash (.sh)
|
|
247
|
+
│
|
|
248
|
+
├─ JSON 数据处理 / 复杂转换 / 数据分析
|
|
249
|
+
│ └─ 选 Python (.py)
|
|
250
|
+
│
|
|
251
|
+
└─ 简单读写 / 格式转换
|
|
252
|
+
└─ 任选(Bash 更轻量)
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## 生成函数
|
|
258
|
+
|
|
259
|
+
```javascript
|
|
260
|
+
function generateScript(scriptConfig) {
|
|
261
|
+
const runtime = scriptConfig.runtime || 'bash'; // 'bash' | 'python'
|
|
262
|
+
const ext = runtime === 'python' ? '.py' : '.sh';
|
|
263
|
+
|
|
264
|
+
if (runtime === 'python') {
|
|
265
|
+
return generatePythonScript(scriptConfig);
|
|
266
|
+
}
|
|
267
|
+
return generateBashScript(scriptConfig);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function generateBashScript(scriptConfig) {
|
|
271
|
+
const { description, inputs = [], outputs = [] } = scriptConfig;
|
|
272
|
+
|
|
273
|
+
const paramDefs = inputs.map(i =>
|
|
274
|
+
`${i.name.toUpperCase().replace(/-/g, '_')}="${i.default || ''}"`
|
|
275
|
+
).join('\n');
|
|
276
|
+
|
|
277
|
+
const paramParse = inputs.map(i =>
|
|
278
|
+
` --${i.name}) ${i.name.toUpperCase().replace(/-/g, '_')}="$2"; shift ;;`
|
|
279
|
+
).join('\n');
|
|
280
|
+
|
|
281
|
+
const paramValidation = inputs.filter(i => i.required).map(i => {
|
|
282
|
+
const VAR = i.name.toUpperCase().replace(/-/g, '_');
|
|
283
|
+
return `[[ -z "$${VAR}" ]] && { echo "错误: --${i.name} 是必需参数" >&2; exit 1; }`;
|
|
284
|
+
}).join('\n');
|
|
285
|
+
|
|
286
|
+
return `#!/bin/bash
|
|
287
|
+
# ${description}
|
|
288
|
+
|
|
289
|
+
set -euo pipefail
|
|
290
|
+
|
|
291
|
+
${paramDefs}
|
|
292
|
+
|
|
293
|
+
while [[ "$#" -gt 0 ]]; do
|
|
294
|
+
case $1 in
|
|
295
|
+
${paramParse}
|
|
296
|
+
*) echo "未知参数: $1" >&2; exit 1 ;;
|
|
297
|
+
esac
|
|
298
|
+
shift
|
|
299
|
+
done
|
|
300
|
+
|
|
301
|
+
${paramValidation}
|
|
302
|
+
|
|
303
|
+
# TODO: 实现处理逻辑
|
|
304
|
+
|
|
305
|
+
# 输出结果 (jq 构建)
|
|
306
|
+
jq -n ${outputs.map(o =>
|
|
307
|
+
`--arg ${o.name} "$${o.name.toUpperCase().replace(/-/g, '_')}"`
|
|
308
|
+
).join(' \\\n ')} \
|
|
309
|
+
'{${outputs.map(o => `${o.name}: $${o.name}`).join(', ')}}'
|
|
310
|
+
`;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function generatePythonScript(scriptConfig) {
|
|
314
|
+
const { description, inputs = [], outputs = [] } = scriptConfig;
|
|
315
|
+
|
|
316
|
+
const argDefs = inputs.map(i =>
|
|
317
|
+
` parser.add_argument('--${i.name}', type=${i.type || 'str'}, ${
|
|
318
|
+
i.required ? 'required=True' : `default='${i.default || ''}'`
|
|
319
|
+
}, help='${i.description || i.name}')`
|
|
320
|
+
).join('\n');
|
|
321
|
+
|
|
322
|
+
const resultFields = outputs.map(o =>
|
|
323
|
+
` '${o.name}': None # ${o.description || o.name}`
|
|
324
|
+
).join(',\n');
|
|
325
|
+
|
|
326
|
+
return `#!/usr/bin/env python3
|
|
327
|
+
"""
|
|
328
|
+
${description}
|
|
329
|
+
"""
|
|
330
|
+
|
|
331
|
+
import argparse
|
|
332
|
+
import json
|
|
333
|
+
import sys
|
|
334
|
+
from pathlib import Path
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def main():
|
|
338
|
+
parser = argparse.ArgumentParser(description='${description}')
|
|
339
|
+
${argDefs}
|
|
340
|
+
args = parser.parse_args()
|
|
341
|
+
|
|
342
|
+
# TODO: 实现处理逻辑
|
|
343
|
+
result = {
|
|
344
|
+
${resultFields}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
print(json.dumps(result))
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
if __name__ == '__main__':
|
|
351
|
+
main()
|
|
352
|
+
`;
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## 目录约定
|
|
359
|
+
|
|
360
|
+
```
|
|
361
|
+
scripts/
|
|
362
|
+
├── process-data.py # id: process-data, runtime: python
|
|
363
|
+
├── validate.sh # id: validate, runtime: bash
|
|
364
|
+
└── transform.js # id: transform, runtime: node
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
- **命名即 ID**: 文件名(不含扩展名)= 脚本 ID
|
|
368
|
+
- **扩展名即运行时**: `.py` → python, `.sh` → bash, `.js` → node
|
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
顺序模式 Phase 文件的模板。
|
|
4
4
|
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
生成 Sequential 执行模式的 Phase 文件,定义固定顺序的执行步骤。
|
|
8
|
+
|
|
9
|
+
## Usage Context
|
|
10
|
+
|
|
11
|
+
| Phase | Usage |
|
|
12
|
+
|-------|-------|
|
|
13
|
+
| Phase 3 (Phase Generation) | `config.execution_mode === 'sequential'` 时生成 |
|
|
14
|
+
| Generation Trigger | 为每个 `config.sequential_config.phases` 生成一个 phase 文件 |
|
|
15
|
+
| Output Location | `.claude/skills/{skill-name}/phases/{phase-id}.md` |
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
5
19
|
## ⚠️ 重要提示
|
|
6
20
|
|
|
7
21
|
> **Phase 0 是强制前置阶段**:在实现任何 Phase (1, 2, 3...) 之前,必须先完成 Phase 0 的规范研读。
|
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
用于生成新 Skill 入口文件的模板。
|
|
4
4
|
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
生成新 Skill 的入口文件 (SKILL.md),作为 Skill 的主文档和执行入口点。
|
|
8
|
+
|
|
9
|
+
## Usage Context
|
|
10
|
+
|
|
11
|
+
| Phase | Usage |
|
|
12
|
+
|-------|-------|
|
|
13
|
+
| Phase 2 (Structure Generation) | 创建 SKILL.md 入口文件 |
|
|
14
|
+
| Generation Trigger | `config.execution_mode` 决定架构图样式 |
|
|
15
|
+
| Output Location | `.claude/skills/{skill-name}/SKILL.md` |
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
5
19
|
## ⚠️ 重要:YAML Front Matter 规范
|
|
6
20
|
|
|
7
21
|
> **CRITICAL**: SKILL.md 文件必须以 YAML front matter 开头,即以 `---` 作为文件第一行。
|