mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
feat: 为 skill-generator 添加脚本执行能力
- 默认创建 scripts/ 目录用于存放确定性脚本 - 新增 specs/scripting-integration.md 脚本集成规范 - 新增 templates/script-python.md 和 script-bash.md 脚本模板 - 模板中添加 ## Scripts 声明和 ExecuteScript 调用示例 - 支持命名即ID、扩展名即运行时的约定 - 参数自动转换: snake_case → kebab-case - Bash 模板使用 jq 构建 JSON 输出 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,13 @@
|
||||
- 依赖: `{{input_dependency}}`
|
||||
- 配置: `{workDir}/skill-config.json`
|
||||
|
||||
## Scripts
|
||||
|
||||
\`\`\`yaml
|
||||
# 声明本阶段使用的脚本(可选)
|
||||
# - script-id # 对应 scripts/script-id.py 或 .sh
|
||||
\`\`\`
|
||||
|
||||
## Execution Steps
|
||||
|
||||
### Step 1: {{step_1_name}}
|
||||
@@ -32,10 +39,13 @@
|
||||
{{step_2_code}}
|
||||
\`\`\`
|
||||
|
||||
### Step 3: {{step_3_name}}
|
||||
### Step 3: 执行脚本(可选)
|
||||
|
||||
\`\`\`javascript
|
||||
{{step_3_code}}
|
||||
// 调用脚本示例
|
||||
// const result = await ExecuteScript('script-id', { input_path: `${workDir}/data.json` });
|
||||
// if (!result.success) throw new Error(result.stderr);
|
||||
// console.log(result.outputs.output_file);
|
||||
\`\`\`
|
||||
|
||||
## Output
|
||||
@@ -68,6 +78,44 @@
|
||||
| `{{quality_checklist}}` | 质量检查项 |
|
||||
| `{{next_phase_link}}` | 下一阶段链接 |
|
||||
|
||||
## 脚本调用说明
|
||||
|
||||
### 目录约定
|
||||
|
||||
```
|
||||
scripts/
|
||||
├── process-data.py # id: process-data, runtime: python
|
||||
├── validate.sh # id: validate, runtime: bash
|
||||
└── transform.js # id: transform, runtime: node
|
||||
```
|
||||
|
||||
- **命名即 ID**:文件名(不含扩展名)= 脚本 ID
|
||||
- **扩展名即运行时**:`.py` → python, `.sh` → bash, `.js` → node
|
||||
|
||||
### 调用语法
|
||||
|
||||
```javascript
|
||||
// 一行调用
|
||||
const result = await ExecuteScript('script-id', { key: value });
|
||||
|
||||
// 检查结果
|
||||
if (!result.success) throw new Error(result.stderr);
|
||||
|
||||
// 获取输出
|
||||
const { output_file } = result.outputs;
|
||||
```
|
||||
|
||||
### 返回格式
|
||||
|
||||
```typescript
|
||||
interface ScriptResult {
|
||||
success: boolean; // exit code === 0
|
||||
stdout: string; // 标准输出
|
||||
stderr: string; // 标准错误
|
||||
outputs: object; // 从 stdout 解析的 JSON 输出
|
||||
}
|
||||
```
|
||||
|
||||
## Phase 类型模板
|
||||
|
||||
### 1. 收集型 Phase (Collection)
|
||||
|
||||
Reference in New Issue
Block a user