claude-code-workflow 6.3.49 → 6.3.51
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/commands/issue/new.md +1 -2
- package/.claude/commands/view.md +367 -0
- package/.claude/commands/workflow/unified-execute-with-file.md +807 -0
- package/.claude/skills/ccw-help/SKILL.md +72 -12
- package/.claude/skills/ccw-help/command.json +922 -520
- package/.claude/skills/ccw-help/index/all-agents.json +97 -0
- package/.claude/skills/ccw-help/index/all-commands.json +805 -0
- package/.claude/skills/ccw-help/index/by-category.json +833 -0
- package/.claude/skills/ccw-help/index/by-use-case.json +819 -0
- package/.claude/skills/ccw-help/index/command-relationships.json +160 -0
- package/.claude/skills/ccw-help/index/essential-commands.json +90 -0
- package/.claude/skills/ccw-help/scripts/auto-update.py +34 -0
- package/.claude/skills/skill-generator/SKILL.md +255 -208
- package/.claude/skills/skill-generator/phases/01-requirements-discovery.md +238 -228
- package/.claude/skills/skill-generator/phases/02-structure-generation.md +261 -262
- package/.claude/skills/skill-generator/phases/03-phase-generation.md +976 -969
- package/.claude/skills/skill-generator/phases/04-specs-templates.md +398 -398
- package/.claude/skills/skill-generator/phases/05-validation.md +417 -417
- package/.claude/skills/skill-generator/specs/cli-integration.md +131 -131
- package/.claude/skills/skill-generator/specs/execution-modes.md +399 -396
- package/.claude/skills/skill-generator/specs/reference-docs-spec.md +271 -0
- package/.claude/skills/skill-generator/specs/scripting-integration.md +265 -265
- package/.claude/skills/skill-generator/specs/skill-requirements.md +466 -466
- package/.claude/skills/skill-generator/templates/autonomous-action.md +91 -88
- package/.claude/skills/skill-generator/templates/autonomous-orchestrator.md +89 -89
- package/.claude/skills/skill-generator/templates/code-analysis-action.md +148 -149
- package/.claude/skills/skill-generator/templates/llm-action.md +367 -367
- package/.claude/skills/skill-generator/templates/script-template.md +79 -79
- package/.claude/skills/skill-generator/templates/sequential-phase.md +129 -129
- package/.claude/skills/skill-generator/templates/skill-md.md +134 -75
- package/.codex/prompts/UNIFIED_EXECUTE_COMPARISON.md +205 -0
- package/.codex/prompts/analyze-with-file.md +5 -2
- package/.codex/prompts/brainstorm-to-cycle.md +4 -3
- package/.codex/prompts/brainstorm-with-file.md +6 -2
- package/.codex/prompts/clean.md +7 -2
- package/.codex/prompts/compact.md +5 -3
- package/.codex/prompts/debug-with-file.md +6 -2
- package/.codex/prompts/execute.md +6 -2
- package/.codex/prompts/issue-execute.md +10 -2
- package/.codex/prompts/issue-new.md +390 -285
- package/.codex/prompts/lite-execute.md +8 -7
- package/.codex/prompts/lite-fix.md +6 -2
- package/.codex/prompts/lite-plan-a.md +6 -2
- package/.codex/prompts/lite-plan-b.md +6 -2
- package/.codex/prompts/lite-plan-c.md +6 -2
- package/.codex/prompts/unified-execute-with-file.md +722 -0
- package/.codex/skills/codex-issue-plan-execute/SKILL.md +239 -0
- package/.codex/skills/codex-issue-plan-execute/phases/actions/action-complete.md +173 -0
- package/.codex/skills/codex-issue-plan-execute/phases/actions/action-execute.md +220 -0
- package/.codex/skills/codex-issue-plan-execute/phases/actions/action-init.md +86 -0
- package/.codex/skills/codex-issue-plan-execute/phases/actions/action-list.md +165 -0
- package/.codex/skills/codex-issue-plan-execute/phases/actions/action-plan.md +170 -0
- package/.codex/skills/codex-issue-plan-execute/phases/orchestrator.md +210 -0
- package/.codex/skills/codex-issue-plan-execute/phases/state-schema.md +136 -0
- package/.codex/skills/codex-issue-plan-execute/prompts/execution-agent-system.md +136 -0
- package/.codex/skills/codex-issue-plan-execute/prompts/execution-agent.md +135 -0
- package/.codex/skills/codex-issue-plan-execute/prompts/planning-agent-system.md +107 -0
- package/.codex/skills/codex-issue-plan-execute/prompts/planning-agent.md +122 -0
- package/.codex/skills/codex-issue-plan-execute/specs/issue-handling.md +187 -0
- package/.codex/skills/codex-issue-plan-execute/specs/quality-standards.md +231 -0
- package/.codex/skills/codex-issue-plan-execute/specs/solution-schema.md +270 -0
- package/.codex/skills/codex-issue-plan-execute/specs/subagent-roles.md +268 -0
- package/ccw/dist/cli.d.ts.map +1 -1
- package/ccw/dist/cli.js +1 -0
- package/ccw/dist/cli.js.map +1 -1
- package/ccw/dist/commands/cli.d.ts +1 -0
- package/ccw/dist/commands/cli.d.ts.map +1 -1
- package/ccw/dist/commands/cli.js +74 -6
- package/ccw/dist/commands/cli.js.map +1 -1
- package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/cli-routes.js +16 -1
- package/ccw/dist/core/routes/cli-routes.js.map +1 -1
- package/ccw/dist/core/routes/help-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/help-routes.js +51 -1
- package/ccw/dist/core/routes/help-routes.js.map +1 -1
- package/ccw/dist/tools/cli-executor-core.d.ts.map +1 -1
- package/ccw/dist/tools/cli-executor-core.js +5 -3
- package/ccw/dist/tools/cli-executor-core.js.map +1 -1
- package/ccw/dist/tools/cli-executor-utils.d.ts +1 -0
- package/ccw/dist/tools/cli-executor-utils.d.ts.map +1 -1
- package/ccw/dist/tools/cli-executor-utils.js +3 -1
- package/ccw/dist/tools/cli-executor-utils.js.map +1 -1
- package/ccw/src/cli.ts +1 -0
- package/ccw/src/commands/cli.ts +77 -6
- package/ccw/src/core/routes/cli-routes.ts +16 -1
- package/ccw/src/core/routes/help-routes.ts +60 -1
- package/ccw/src/templates/dashboard-js/views/help.js +423 -1
- package/ccw/src/tools/cli-executor-core.ts +6 -3
- package/ccw/src/tools/cli-executor-utils.ts +5 -2
- package/package.json +1 -1
|
@@ -1,367 +1,367 @@
|
|
|
1
|
-
# LLM Action Template
|
|
2
|
-
|
|
3
|
-
LLM
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Usage Context
|
|
10
|
-
|
|
11
|
-
| Phase | Usage |
|
|
12
|
-
|-------|-------|
|
|
13
|
-
| Optional |
|
|
14
|
-
| Generation Trigger |
|
|
15
|
-
| Tools | gemini, qwen, codex (
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
##
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
interface LLMActionConfig {
|
|
23
|
-
id: string; // "llm-analyze", "llm-generate"
|
|
24
|
-
name: string; // "LLM Analysis"
|
|
25
|
-
type: 'llm'; //
|
|
26
|
-
|
|
27
|
-
// LLM
|
|
28
|
-
tool: {
|
|
29
|
-
primary: 'gemini' | 'qwen' | 'codex';
|
|
30
|
-
fallback_chain: string[]; // ['gemini', 'qwen', 'codex']
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
mode: 'analysis' | 'write';
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
prompt: {
|
|
38
|
-
template: string; //
|
|
39
|
-
variables: string[]; //
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
input: string[]; //
|
|
44
|
-
output: string; //
|
|
45
|
-
|
|
46
|
-
//
|
|
47
|
-
timeout?: number; //
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
##
|
|
54
|
-
|
|
55
|
-
```javascript
|
|
56
|
-
function generateLLMAction(config) {
|
|
57
|
-
const { id, name, tool, mode, prompt, input, output, timeout = 600000 } = config;
|
|
58
|
-
|
|
59
|
-
return `
|
|
60
|
-
# ${name}
|
|
61
|
-
|
|
62
|
-
## Action: ${id}
|
|
63
|
-
|
|
64
|
-
###
|
|
65
|
-
|
|
66
|
-
\`\`\`javascript
|
|
67
|
-
async function execute${toPascalCase(id)}(context) {
|
|
68
|
-
const workDir = context.workDir;
|
|
69
|
-
const state = context.state;
|
|
70
|
-
|
|
71
|
-
// 1.
|
|
72
|
-
const inputContext = ${JSON.stringify(input)}.map(f => {
|
|
73
|
-
const path = \`\${workDir}/\${f}\`;
|
|
74
|
-
return Read(path);
|
|
75
|
-
}).join('\\n\\n---\\n\\n');
|
|
76
|
-
|
|
77
|
-
// 2.
|
|
78
|
-
const promptTemplate = \`${prompt.template}\`;
|
|
79
|
-
const finalPrompt = promptTemplate
|
|
80
|
-
${prompt.variables.map(v => `.replace('{{${v}}}', context.${v} || '')`).join('\n ')};
|
|
81
|
-
|
|
82
|
-
// 3.
|
|
83
|
-
const tools = ['${tool.primary}', ${tool.fallback_chain.map(t => `'${t}'`).join(', ')}];
|
|
84
|
-
let result = null;
|
|
85
|
-
let usedTool = null;
|
|
86
|
-
|
|
87
|
-
for (const t of tools) {
|
|
88
|
-
try {
|
|
89
|
-
result = await callLLM(t, finalPrompt, '${mode}', ${timeout});
|
|
90
|
-
usedTool = t;
|
|
91
|
-
break;
|
|
92
|
-
} catch (error) {
|
|
93
|
-
console.log(\`\${t} failed: \${error.message}, trying next...\`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (!result) {
|
|
98
|
-
throw new Error('All LLM tools failed');
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// 4.
|
|
102
|
-
Write(\`\${workDir}/${output}\`, result);
|
|
103
|
-
|
|
104
|
-
// 5.
|
|
105
|
-
state.llm_calls = (state.llm_calls || 0) + 1;
|
|
106
|
-
state.last_llm_tool = usedTool;
|
|
107
|
-
|
|
108
|
-
return {
|
|
109
|
-
success: true,
|
|
110
|
-
output: '${output}',
|
|
111
|
-
tool_used: usedTool
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// LLM
|
|
116
|
-
async function callLLM(tool, prompt, mode, timeout) {
|
|
117
|
-
const modeFlag = mode === 'write' ? '--mode write' : '--mode analysis';
|
|
118
|
-
|
|
119
|
-
//
|
|
120
|
-
const command = \`ccw cli -p "\${escapePrompt(prompt)}" --tool \${tool} \${modeFlag}\`;
|
|
121
|
-
|
|
122
|
-
const result = Bash({
|
|
123
|
-
command,
|
|
124
|
-
timeout,
|
|
125
|
-
run_in_background: true //
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
//
|
|
129
|
-
return await waitForResult(result.task_id, timeout);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function escapePrompt(prompt) {
|
|
133
|
-
//
|
|
134
|
-
return prompt.replace(/"/g, '\\\\"').replace(/\$/g, '\\\\$');
|
|
135
|
-
}
|
|
136
|
-
\`\`\`
|
|
137
|
-
|
|
138
|
-
### Prompt
|
|
139
|
-
|
|
140
|
-
\`\`\`
|
|
141
|
-
${prompt.template}
|
|
142
|
-
\`\`\`
|
|
143
|
-
|
|
144
|
-
###
|
|
145
|
-
|
|
146
|
-
${prompt.variables.map(v => `- \`{{${v}}}\`: ${v}
|
|
147
|
-
`;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function toPascalCase(str) {
|
|
151
|
-
return str.split('-').map(s => s.charAt(0).toUpperCase() + s.slice(1)).join('');
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
---
|
|
156
|
-
|
|
157
|
-
##
|
|
158
|
-
|
|
159
|
-
### 1.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
id: llm-code-analysis
|
|
163
|
-
name: LLM Code Analysis
|
|
164
|
-
type: llm
|
|
165
|
-
tool:
|
|
166
|
-
primary: gemini
|
|
167
|
-
fallback_chain: [qwen]
|
|
168
|
-
mode: analysis
|
|
169
|
-
prompt:
|
|
170
|
-
template: |
|
|
171
|
-
PURPOSE:
|
|
172
|
-
TASK:
|
|
173
|
-
•
|
|
174
|
-
•
|
|
175
|
-
•
|
|
176
|
-
•
|
|
177
|
-
MODE: analysis
|
|
178
|
-
CONTEXT: {{code_context}}
|
|
179
|
-
EXPECTED: JSON
|
|
180
|
-
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md)
|
|
181
|
-
variables:
|
|
182
|
-
- code_context
|
|
183
|
-
input:
|
|
184
|
-
- collected-code.md
|
|
185
|
-
output: analysis-report.json
|
|
186
|
-
timeout: 900000
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
### 2.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
id: llm-doc-generation
|
|
193
|
-
name: LLM Documentation Generation
|
|
194
|
-
type: llm
|
|
195
|
-
tool:
|
|
196
|
-
primary: gemini
|
|
197
|
-
fallback_chain: [qwen, codex]
|
|
198
|
-
mode: write
|
|
199
|
-
prompt:
|
|
200
|
-
template: |
|
|
201
|
-
PURPOSE:
|
|
202
|
-
TASK:
|
|
203
|
-
•
|
|
204
|
-
•
|
|
205
|
-
•
|
|
206
|
-
•
|
|
207
|
-
MODE: write
|
|
208
|
-
CONTEXT: {{analysis_report}}
|
|
209
|
-
EXPECTED:
|
|
210
|
-
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md)
|
|
211
|
-
variables:
|
|
212
|
-
- analysis_report
|
|
213
|
-
input:
|
|
214
|
-
- analysis-report.json
|
|
215
|
-
output: generated-doc.md
|
|
216
|
-
timeout: 1200000
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
### 3.
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
id: llm-refactor-suggest
|
|
223
|
-
name: LLM Refactoring Suggestions
|
|
224
|
-
type: llm
|
|
225
|
-
tool:
|
|
226
|
-
primary: codex
|
|
227
|
-
fallback_chain: [gemini]
|
|
228
|
-
mode: analysis
|
|
229
|
-
prompt:
|
|
230
|
-
template: |
|
|
231
|
-
PURPOSE:
|
|
232
|
-
TASK:
|
|
233
|
-
•
|
|
234
|
-
•
|
|
235
|
-
•
|
|
236
|
-
•
|
|
237
|
-
MODE: analysis
|
|
238
|
-
CONTEXT: {{source_code}}
|
|
239
|
-
EXPECTED:
|
|
240
|
-
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md)
|
|
241
|
-
variables:
|
|
242
|
-
- source_code
|
|
243
|
-
input:
|
|
244
|
-
- source-files.md
|
|
245
|
-
output: refactor-suggestions.json
|
|
246
|
-
timeout: 600000
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
##
|
|
252
|
-
|
|
253
|
-
###
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
// phases/02-llm-analysis.md
|
|
257
|
-
|
|
258
|
-
const llmConfig = {
|
|
259
|
-
id: 'llm-analyze-skill',
|
|
260
|
-
name: 'Skill Pattern Analysis',
|
|
261
|
-
type: 'llm',
|
|
262
|
-
tool: {
|
|
263
|
-
primary: 'gemini',
|
|
264
|
-
fallback_chain: ['qwen']
|
|
265
|
-
},
|
|
266
|
-
mode: 'analysis',
|
|
267
|
-
prompt: {
|
|
268
|
-
template:
|
|
269
|
-
PURPOSE:
|
|
270
|
-
TASK:
|
|
271
|
-
•
|
|
272
|
-
•
|
|
273
|
-
•
|
|
274
|
-
MODE: analysis
|
|
275
|
-
CONTEXT: {{skill_source}}
|
|
276
|
-
EXPECTED:
|
|
277
|
-
|
|
278
|
-
variables: ['skill_source']
|
|
279
|
-
},
|
|
280
|
-
input: ['collected-skills.md'],
|
|
281
|
-
output: 'skill-patterns.json'
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
//
|
|
285
|
-
const result = await executeLLMAction(llmConfig, {
|
|
286
|
-
workDir: '.workflow/.scratchpad/skill-gen-xxx',
|
|
287
|
-
skill_source: Read('.workflow/.scratchpad/skill-gen-xxx/collected-skills.md')
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
###
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
// autonomous-orchestrator
|
|
295
|
-
|
|
296
|
-
const actions = [
|
|
297
|
-
{ type: 'collect', priority: 100 },
|
|
298
|
-
{ type: 'llm', id: 'llm-analyze', priority: 90 }, // LLM
|
|
299
|
-
{ type: 'process', priority: 80 },
|
|
300
|
-
{ type: 'llm', id: 'llm-generate', priority: 70 }, // LLM
|
|
301
|
-
{ type: 'validate', priority: 60 }
|
|
302
|
-
];
|
|
303
|
-
|
|
304
|
-
for (const action of sortByPriority(actions)) {
|
|
305
|
-
if (action.type === 'llm') {
|
|
306
|
-
const llmResult = await executeLLMAction(
|
|
307
|
-
getLLMConfig(action.id),
|
|
308
|
-
context
|
|
309
|
-
);
|
|
310
|
-
context.state[action.id] = llmResult;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
---
|
|
316
|
-
|
|
317
|
-
##
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
async function executeLLMActionWithRetry(config, context, maxRetries = 3) {
|
|
321
|
-
let lastError = null;
|
|
322
|
-
|
|
323
|
-
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
324
|
-
try {
|
|
325
|
-
return await executeLLMAction(config, context);
|
|
326
|
-
} catch (error) {
|
|
327
|
-
lastError = error;
|
|
328
|
-
console.log(
|
|
329
|
-
|
|
330
|
-
//
|
|
331
|
-
if (attempt < maxRetries) {
|
|
332
|
-
await sleep(Math.pow(2, attempt) * 1000);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
//
|
|
338
|
-
return {
|
|
339
|
-
success: false,
|
|
340
|
-
error: lastError.message,
|
|
341
|
-
fallback: 'manual_review_required'
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
---
|
|
347
|
-
|
|
348
|
-
##
|
|
349
|
-
|
|
350
|
-
1.
|
|
351
|
-
-
|
|
352
|
-
-
|
|
353
|
-
-
|
|
354
|
-
|
|
355
|
-
2.
|
|
356
|
-
-
|
|
357
|
-
-
|
|
358
|
-
|
|
359
|
-
3.
|
|
360
|
-
-
|
|
361
|
-
-
|
|
362
|
-
-
|
|
363
|
-
|
|
364
|
-
4.
|
|
365
|
-
-
|
|
366
|
-
-
|
|
367
|
-
-
|
|
1
|
+
# LLM Action Template
|
|
2
|
+
|
|
3
|
+
LLM action template for integrating LLM call capabilities into a Skill.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Generate LLM actions for a Skill, call Gemini/Qwen/Codex through CCW CLI unified interface for analysis or generation.
|
|
8
|
+
|
|
9
|
+
## Usage Context
|
|
10
|
+
|
|
11
|
+
| Phase | Usage |
|
|
12
|
+
|-------|-------|
|
|
13
|
+
| Optional | Use when Skill requires LLM capabilities |
|
|
14
|
+
| Generation Trigger | User selects to add llm action type |
|
|
15
|
+
| Tools | gemini, qwen, codex (supports fallback chain) |
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Configuration Structure
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
interface LLMActionConfig {
|
|
23
|
+
id: string; // "llm-analyze", "llm-generate"
|
|
24
|
+
name: string; // "LLM Analysis"
|
|
25
|
+
type: 'llm'; // Action type identifier
|
|
26
|
+
|
|
27
|
+
// LLM tool config
|
|
28
|
+
tool: {
|
|
29
|
+
primary: 'gemini' | 'qwen' | 'codex';
|
|
30
|
+
fallback_chain: string[]; // ['gemini', 'qwen', 'codex']
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Execution mode
|
|
34
|
+
mode: 'analysis' | 'write';
|
|
35
|
+
|
|
36
|
+
// Prompt config
|
|
37
|
+
prompt: {
|
|
38
|
+
template: string; // Prompt template path or inline
|
|
39
|
+
variables: string[]; // Variables to replace
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Input/Output
|
|
43
|
+
input: string[]; // Dependent context files
|
|
44
|
+
output: string; // Output file path
|
|
45
|
+
|
|
46
|
+
// Timeout config
|
|
47
|
+
timeout?: number; // Milliseconds, default 600000 (10min)
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Template Generation Function
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
function generateLLMAction(config) {
|
|
57
|
+
const { id, name, tool, mode, prompt, input, output, timeout = 600000 } = config;
|
|
58
|
+
|
|
59
|
+
return `
|
|
60
|
+
# ${name}
|
|
61
|
+
|
|
62
|
+
## Action: ${id}
|
|
63
|
+
|
|
64
|
+
### Execution Logic
|
|
65
|
+
|
|
66
|
+
\`\`\`javascript
|
|
67
|
+
async function execute${toPascalCase(id)}(context) {
|
|
68
|
+
const workDir = context.workDir;
|
|
69
|
+
const state = context.state;
|
|
70
|
+
|
|
71
|
+
// 1. Collect input context
|
|
72
|
+
const inputContext = ${JSON.stringify(input)}.map(f => {
|
|
73
|
+
const path = \`\${workDir}/\${f}\`;
|
|
74
|
+
return Read(path);
|
|
75
|
+
}).join('\\n\\n---\\n\\n');
|
|
76
|
+
|
|
77
|
+
// 2. Build prompt
|
|
78
|
+
const promptTemplate = \`${prompt.template}\`;
|
|
79
|
+
const finalPrompt = promptTemplate
|
|
80
|
+
${prompt.variables.map(v => `.replace('{{${v}}}', context.${v} || '')`).join('\n ')};
|
|
81
|
+
|
|
82
|
+
// 3. Execute LLM call (with fallback)
|
|
83
|
+
const tools = ['${tool.primary}', ${tool.fallback_chain.map(t => `'${t}'`).join(', ')}];
|
|
84
|
+
let result = null;
|
|
85
|
+
let usedTool = null;
|
|
86
|
+
|
|
87
|
+
for (const t of tools) {
|
|
88
|
+
try {
|
|
89
|
+
result = await callLLM(t, finalPrompt, '${mode}', ${timeout});
|
|
90
|
+
usedTool = t;
|
|
91
|
+
break;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.log(\`\${t} failed: \${error.message}, trying next...\`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!result) {
|
|
98
|
+
throw new Error('All LLM tools failed');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 4. Save result
|
|
102
|
+
Write(\`\${workDir}/${output}\`, result);
|
|
103
|
+
|
|
104
|
+
// 5. Update state
|
|
105
|
+
state.llm_calls = (state.llm_calls || 0) + 1;
|
|
106
|
+
state.last_llm_tool = usedTool;
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
success: true,
|
|
110
|
+
output: '${output}',
|
|
111
|
+
tool_used: usedTool
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// LLM call wrapper
|
|
116
|
+
async function callLLM(tool, prompt, mode, timeout) {
|
|
117
|
+
const modeFlag = mode === 'write' ? '--mode write' : '--mode analysis';
|
|
118
|
+
|
|
119
|
+
// Use CCW CLI unified interface
|
|
120
|
+
const command = \`ccw cli -p "\${escapePrompt(prompt)}" --tool \${tool} \${modeFlag}\`;
|
|
121
|
+
|
|
122
|
+
const result = Bash({
|
|
123
|
+
command,
|
|
124
|
+
timeout,
|
|
125
|
+
run_in_background: true // Async execution
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Wait for completion
|
|
129
|
+
return await waitForResult(result.task_id, timeout);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function escapePrompt(prompt) {
|
|
133
|
+
// Escape double quotes and special characters
|
|
134
|
+
return prompt.replace(/"/g, '\\\\"').replace(/\$/g, '\\\\$');
|
|
135
|
+
}
|
|
136
|
+
\`\`\`
|
|
137
|
+
|
|
138
|
+
### Prompt Template
|
|
139
|
+
|
|
140
|
+
\`\`\`
|
|
141
|
+
${prompt.template}
|
|
142
|
+
\`\`\`
|
|
143
|
+
|
|
144
|
+
### Variable Descriptions
|
|
145
|
+
|
|
146
|
+
${prompt.variables.map(v => `- \`{{${v}}}\`: ${v} variable`).join('\n')}
|
|
147
|
+
`;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function toPascalCase(str) {
|
|
151
|
+
return str.split('-').map(s => s.charAt(0).toUpperCase() + s.slice(1)).join('');
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Preset LLM Action Templates
|
|
158
|
+
|
|
159
|
+
### 1. Code Analysis Action
|
|
160
|
+
|
|
161
|
+
\`\`\`yaml
|
|
162
|
+
id: llm-code-analysis
|
|
163
|
+
name: LLM Code Analysis
|
|
164
|
+
type: llm
|
|
165
|
+
tool:
|
|
166
|
+
primary: gemini
|
|
167
|
+
fallback_chain: [qwen]
|
|
168
|
+
mode: analysis
|
|
169
|
+
prompt:
|
|
170
|
+
template: |
|
|
171
|
+
PURPOSE: Analyze code structure and patterns, extract key design features
|
|
172
|
+
TASK:
|
|
173
|
+
• Identify main modules and components
|
|
174
|
+
• Analyze dependencies
|
|
175
|
+
• Extract design patterns
|
|
176
|
+
• Evaluate code quality
|
|
177
|
+
MODE: analysis
|
|
178
|
+
CONTEXT: {{code_context}}
|
|
179
|
+
EXPECTED: JSON formatted analysis report with modules, dependencies, patterns, quality_score
|
|
180
|
+
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md)
|
|
181
|
+
variables:
|
|
182
|
+
- code_context
|
|
183
|
+
input:
|
|
184
|
+
- collected-code.md
|
|
185
|
+
output: analysis-report.json
|
|
186
|
+
timeout: 900000
|
|
187
|
+
\`\`\`
|
|
188
|
+
|
|
189
|
+
### 2. Documentation Generation Action
|
|
190
|
+
|
|
191
|
+
\`\`\`yaml
|
|
192
|
+
id: llm-doc-generation
|
|
193
|
+
name: LLM Documentation Generation
|
|
194
|
+
type: llm
|
|
195
|
+
tool:
|
|
196
|
+
primary: gemini
|
|
197
|
+
fallback_chain: [qwen, codex]
|
|
198
|
+
mode: write
|
|
199
|
+
prompt:
|
|
200
|
+
template: |
|
|
201
|
+
PURPOSE: Generate high-quality documentation based on analysis results
|
|
202
|
+
TASK:
|
|
203
|
+
• Generate documentation outline based on analysis report
|
|
204
|
+
• Populate chapter content
|
|
205
|
+
• Add code examples and explanations
|
|
206
|
+
• Generate Mermaid diagrams
|
|
207
|
+
MODE: write
|
|
208
|
+
CONTEXT: {{analysis_report}}
|
|
209
|
+
EXPECTED: Complete Markdown documentation with table of contents, chapters, diagrams
|
|
210
|
+
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md)
|
|
211
|
+
variables:
|
|
212
|
+
- analysis_report
|
|
213
|
+
input:
|
|
214
|
+
- analysis-report.json
|
|
215
|
+
output: generated-doc.md
|
|
216
|
+
timeout: 1200000
|
|
217
|
+
\`\`\`
|
|
218
|
+
|
|
219
|
+
### 3. Code Refactoring Suggestions Action
|
|
220
|
+
|
|
221
|
+
\`\`\`yaml
|
|
222
|
+
id: llm-refactor-suggest
|
|
223
|
+
name: LLM Refactoring Suggestions
|
|
224
|
+
type: llm
|
|
225
|
+
tool:
|
|
226
|
+
primary: codex
|
|
227
|
+
fallback_chain: [gemini]
|
|
228
|
+
mode: analysis
|
|
229
|
+
prompt:
|
|
230
|
+
template: |
|
|
231
|
+
PURPOSE: Analyze code and provide refactoring suggestions
|
|
232
|
+
TASK:
|
|
233
|
+
• Identify code smells
|
|
234
|
+
• Evaluate complexity hotspots
|
|
235
|
+
• Propose specific refactoring plans
|
|
236
|
+
• Estimate refactoring impact scope
|
|
237
|
+
MODE: analysis
|
|
238
|
+
CONTEXT: {{source_code}}
|
|
239
|
+
EXPECTED: List of refactoring suggestions with location, issue, suggestion, impact fields
|
|
240
|
+
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md)
|
|
241
|
+
variables:
|
|
242
|
+
- source_code
|
|
243
|
+
input:
|
|
244
|
+
- source-files.md
|
|
245
|
+
output: refactor-suggestions.json
|
|
246
|
+
timeout: 600000
|
|
247
|
+
\`\`\`
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Usage Examples
|
|
252
|
+
|
|
253
|
+
### Using LLM Actions in Phase
|
|
254
|
+
|
|
255
|
+
\`\`\`javascript
|
|
256
|
+
// phases/02-llm-analysis.md
|
|
257
|
+
|
|
258
|
+
const llmConfig = {
|
|
259
|
+
id: 'llm-analyze-skill',
|
|
260
|
+
name: 'Skill Pattern Analysis',
|
|
261
|
+
type: 'llm',
|
|
262
|
+
tool: {
|
|
263
|
+
primary: 'gemini',
|
|
264
|
+
fallback_chain: ['qwen']
|
|
265
|
+
},
|
|
266
|
+
mode: 'analysis',
|
|
267
|
+
prompt: {
|
|
268
|
+
template: \`
|
|
269
|
+
PURPOSE: Analyze design patterns of existing Skills
|
|
270
|
+
TASK:
|
|
271
|
+
• Extract Skill structure specification
|
|
272
|
+
• Identify Phase organization patterns
|
|
273
|
+
• Analyze Agent invocation patterns
|
|
274
|
+
MODE: analysis
|
|
275
|
+
CONTEXT: {{skill_source}}
|
|
276
|
+
EXPECTED: Structured design pattern analysis
|
|
277
|
+
\`,
|
|
278
|
+
variables: ['skill_source']
|
|
279
|
+
},
|
|
280
|
+
input: ['collected-skills.md'],
|
|
281
|
+
output: 'skill-patterns.json'
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// Execute
|
|
285
|
+
const result = await executeLLMAction(llmConfig, {
|
|
286
|
+
workDir: '.workflow/.scratchpad/skill-gen-xxx',
|
|
287
|
+
skill_source: Read('.workflow/.scratchpad/skill-gen-xxx/collected-skills.md')
|
|
288
|
+
});
|
|
289
|
+
\`\`\`
|
|
290
|
+
|
|
291
|
+
### Scheduling LLM Actions in Orchestrator
|
|
292
|
+
|
|
293
|
+
\`\`\`javascript
|
|
294
|
+
// Schedule LLM actions in autonomous-orchestrator
|
|
295
|
+
|
|
296
|
+
const actions = [
|
|
297
|
+
{ type: 'collect', priority: 100 },
|
|
298
|
+
{ type: 'llm', id: 'llm-analyze', priority: 90 }, // LLM analysis
|
|
299
|
+
{ type: 'process', priority: 80 },
|
|
300
|
+
{ type: 'llm', id: 'llm-generate', priority: 70 }, // LLM generation
|
|
301
|
+
{ type: 'validate', priority: 60 }
|
|
302
|
+
];
|
|
303
|
+
|
|
304
|
+
for (const action of sortByPriority(actions)) {
|
|
305
|
+
if (action.type === 'llm') {
|
|
306
|
+
const llmResult = await executeLLMAction(
|
|
307
|
+
getLLMConfig(action.id),
|
|
308
|
+
context
|
|
309
|
+
);
|
|
310
|
+
context.state[action.id] = llmResult;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
\`\`\`
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Error Handling
|
|
318
|
+
|
|
319
|
+
\`\`\`javascript
|
|
320
|
+
async function executeLLMActionWithRetry(config, context, maxRetries = 3) {
|
|
321
|
+
let lastError = null;
|
|
322
|
+
|
|
323
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
324
|
+
try {
|
|
325
|
+
return await executeLLMAction(config, context);
|
|
326
|
+
} catch (error) {
|
|
327
|
+
lastError = error;
|
|
328
|
+
console.log(\`Attempt ${attempt} failed: ${error.message}\`);
|
|
329
|
+
|
|
330
|
+
// Exponential backoff
|
|
331
|
+
if (attempt < maxRetries) {
|
|
332
|
+
await sleep(Math.pow(2, attempt) * 1000);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// All retries failed
|
|
338
|
+
return {
|
|
339
|
+
success: false,
|
|
340
|
+
error: lastError.message,
|
|
341
|
+
fallback: 'manual_review_required'
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
\`\`\`
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## Best Practices
|
|
349
|
+
|
|
350
|
+
1. **Select Appropriate Tool**
|
|
351
|
+
- Analysis tasks: Gemini (large context) > Qwen
|
|
352
|
+
- Generation tasks: Codex (autonomous execution) > Gemini > Qwen
|
|
353
|
+
- Code modification: Codex > Gemini
|
|
354
|
+
|
|
355
|
+
2. **Configure Fallback Chain**
|
|
356
|
+
- Always configure at least one fallback
|
|
357
|
+
- Consider tool characteristics when ordering fallbacks
|
|
358
|
+
|
|
359
|
+
3. **Timeout Settings**
|
|
360
|
+
- Analysis tasks: 10-15 minutes
|
|
361
|
+
- Generation tasks: 15-20 minutes
|
|
362
|
+
- Complex tasks: 20-60 minutes
|
|
363
|
+
|
|
364
|
+
4. **Prompt Design**
|
|
365
|
+
- Use PURPOSE/TASK/MODE/CONTEXT/EXPECTED/RULES structure
|
|
366
|
+
- Reference standard protocol templates
|
|
367
|
+
- Clearly specify output format requirements
|