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.
Files changed (90) hide show
  1. package/.claude/commands/issue/new.md +1 -2
  2. package/.claude/commands/view.md +367 -0
  3. package/.claude/commands/workflow/unified-execute-with-file.md +807 -0
  4. package/.claude/skills/ccw-help/SKILL.md +72 -12
  5. package/.claude/skills/ccw-help/command.json +922 -520
  6. package/.claude/skills/ccw-help/index/all-agents.json +97 -0
  7. package/.claude/skills/ccw-help/index/all-commands.json +805 -0
  8. package/.claude/skills/ccw-help/index/by-category.json +833 -0
  9. package/.claude/skills/ccw-help/index/by-use-case.json +819 -0
  10. package/.claude/skills/ccw-help/index/command-relationships.json +160 -0
  11. package/.claude/skills/ccw-help/index/essential-commands.json +90 -0
  12. package/.claude/skills/ccw-help/scripts/auto-update.py +34 -0
  13. package/.claude/skills/skill-generator/SKILL.md +255 -208
  14. package/.claude/skills/skill-generator/phases/01-requirements-discovery.md +238 -228
  15. package/.claude/skills/skill-generator/phases/02-structure-generation.md +261 -262
  16. package/.claude/skills/skill-generator/phases/03-phase-generation.md +976 -969
  17. package/.claude/skills/skill-generator/phases/04-specs-templates.md +398 -398
  18. package/.claude/skills/skill-generator/phases/05-validation.md +417 -417
  19. package/.claude/skills/skill-generator/specs/cli-integration.md +131 -131
  20. package/.claude/skills/skill-generator/specs/execution-modes.md +399 -396
  21. package/.claude/skills/skill-generator/specs/reference-docs-spec.md +271 -0
  22. package/.claude/skills/skill-generator/specs/scripting-integration.md +265 -265
  23. package/.claude/skills/skill-generator/specs/skill-requirements.md +466 -466
  24. package/.claude/skills/skill-generator/templates/autonomous-action.md +91 -88
  25. package/.claude/skills/skill-generator/templates/autonomous-orchestrator.md +89 -89
  26. package/.claude/skills/skill-generator/templates/code-analysis-action.md +148 -149
  27. package/.claude/skills/skill-generator/templates/llm-action.md +367 -367
  28. package/.claude/skills/skill-generator/templates/script-template.md +79 -79
  29. package/.claude/skills/skill-generator/templates/sequential-phase.md +129 -129
  30. package/.claude/skills/skill-generator/templates/skill-md.md +134 -75
  31. package/.codex/prompts/UNIFIED_EXECUTE_COMPARISON.md +205 -0
  32. package/.codex/prompts/analyze-with-file.md +5 -2
  33. package/.codex/prompts/brainstorm-to-cycle.md +4 -3
  34. package/.codex/prompts/brainstorm-with-file.md +6 -2
  35. package/.codex/prompts/clean.md +7 -2
  36. package/.codex/prompts/compact.md +5 -3
  37. package/.codex/prompts/debug-with-file.md +6 -2
  38. package/.codex/prompts/execute.md +6 -2
  39. package/.codex/prompts/issue-execute.md +10 -2
  40. package/.codex/prompts/issue-new.md +390 -285
  41. package/.codex/prompts/lite-execute.md +8 -7
  42. package/.codex/prompts/lite-fix.md +6 -2
  43. package/.codex/prompts/lite-plan-a.md +6 -2
  44. package/.codex/prompts/lite-plan-b.md +6 -2
  45. package/.codex/prompts/lite-plan-c.md +6 -2
  46. package/.codex/prompts/unified-execute-with-file.md +722 -0
  47. package/.codex/skills/codex-issue-plan-execute/SKILL.md +239 -0
  48. package/.codex/skills/codex-issue-plan-execute/phases/actions/action-complete.md +173 -0
  49. package/.codex/skills/codex-issue-plan-execute/phases/actions/action-execute.md +220 -0
  50. package/.codex/skills/codex-issue-plan-execute/phases/actions/action-init.md +86 -0
  51. package/.codex/skills/codex-issue-plan-execute/phases/actions/action-list.md +165 -0
  52. package/.codex/skills/codex-issue-plan-execute/phases/actions/action-plan.md +170 -0
  53. package/.codex/skills/codex-issue-plan-execute/phases/orchestrator.md +210 -0
  54. package/.codex/skills/codex-issue-plan-execute/phases/state-schema.md +136 -0
  55. package/.codex/skills/codex-issue-plan-execute/prompts/execution-agent-system.md +136 -0
  56. package/.codex/skills/codex-issue-plan-execute/prompts/execution-agent.md +135 -0
  57. package/.codex/skills/codex-issue-plan-execute/prompts/planning-agent-system.md +107 -0
  58. package/.codex/skills/codex-issue-plan-execute/prompts/planning-agent.md +122 -0
  59. package/.codex/skills/codex-issue-plan-execute/specs/issue-handling.md +187 -0
  60. package/.codex/skills/codex-issue-plan-execute/specs/quality-standards.md +231 -0
  61. package/.codex/skills/codex-issue-plan-execute/specs/solution-schema.md +270 -0
  62. package/.codex/skills/codex-issue-plan-execute/specs/subagent-roles.md +268 -0
  63. package/ccw/dist/cli.d.ts.map +1 -1
  64. package/ccw/dist/cli.js +1 -0
  65. package/ccw/dist/cli.js.map +1 -1
  66. package/ccw/dist/commands/cli.d.ts +1 -0
  67. package/ccw/dist/commands/cli.d.ts.map +1 -1
  68. package/ccw/dist/commands/cli.js +74 -6
  69. package/ccw/dist/commands/cli.js.map +1 -1
  70. package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
  71. package/ccw/dist/core/routes/cli-routes.js +16 -1
  72. package/ccw/dist/core/routes/cli-routes.js.map +1 -1
  73. package/ccw/dist/core/routes/help-routes.d.ts.map +1 -1
  74. package/ccw/dist/core/routes/help-routes.js +51 -1
  75. package/ccw/dist/core/routes/help-routes.js.map +1 -1
  76. package/ccw/dist/tools/cli-executor-core.d.ts.map +1 -1
  77. package/ccw/dist/tools/cli-executor-core.js +5 -3
  78. package/ccw/dist/tools/cli-executor-core.js.map +1 -1
  79. package/ccw/dist/tools/cli-executor-utils.d.ts +1 -0
  80. package/ccw/dist/tools/cli-executor-utils.d.ts.map +1 -1
  81. package/ccw/dist/tools/cli-executor-utils.js +3 -1
  82. package/ccw/dist/tools/cli-executor-utils.js.map +1 -1
  83. package/ccw/src/cli.ts +1 -0
  84. package/ccw/src/commands/cli.ts +77 -6
  85. package/ccw/src/core/routes/cli-routes.ts +16 -1
  86. package/ccw/src/core/routes/help-routes.ts +60 -1
  87. package/ccw/src/templates/dashboard-js/views/help.js +423 -1
  88. package/ccw/src/tools/cli-executor-core.ts +6 -3
  89. package/ccw/src/tools/cli-executor-utils.ts +5 -2
  90. package/package.json +1 -1
@@ -1,367 +1,367 @@
1
- # LLM Action Template
2
-
3
- LLM 动作模板,用于在 Skill 中集成 LLM 调用能力。
4
-
5
- ## Purpose
6
-
7
- Skill 生成 LLM 动作,通过 CCW CLI 统一接口调用 Gemini/Qwen/Codex 进行分析或生成。
8
-
9
- ## Usage Context
10
-
11
- | Phase | Usage |
12
- |-------|-------|
13
- | Optional | Skill 需要 LLM 能力时使用 |
14
- | Generation Trigger | 用户选择添加 llm 动作类型 |
15
- | Tools | gemini, qwen, codex (支持 fallback chain) |
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; // 毫秒,默认 600000 (10min)
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. 执行 LLM 调用 ( 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. 保存结果
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
- // 使用 CCW CLI 统一接口
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} 变量`).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
- ## 预置 LLM 动作模板
158
-
159
- ### 1. 代码分析动作
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: 分析代码结构和模式,提取关键设计特征
172
- TASK:
173
- 识别主要模块和组件
174
- 分析依赖关系
175
- 提取设计模式
176
- 评估代码质量
177
- MODE: analysis
178
- CONTEXT: {{code_context}}
179
- EXPECTED: JSON 格式的分析报告,包含 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. 文档生成动作
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: 根据分析结果生成高质量文档
202
- TASK:
203
- 基于分析报告生成文档大纲
204
- 填充各章节内容
205
- 添加代码示例和说明
206
- 生成 Mermaid 图表
207
- MODE: write
208
- CONTEXT: {{analysis_report}}
209
- EXPECTED: 完整的 Markdown 文档,包含目录、章节、图表
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
- ```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: 分析代码并提供重构建议
232
- TASK:
233
- 识别代码异味 (code smells)
234
- 评估复杂度热点
235
- 提出具体重构方案
236
- 估算重构影响范围
237
- MODE: analysis
238
- CONTEXT: {{source_code}}
239
- EXPECTED: 重构建议列表,每项包含 location, issue, suggestion, impact
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
- ### Phase 中使用 LLM 动作
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: 分析现有 Skill 的设计模式
270
- TASK:
271
- 提取 Skill 结构规范
272
- 识别 Phase 组织模式
273
- 分析 Agent 调用模式
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
- ### Orchestrator 中调度 LLM 动作
292
-
293
- ```javascript
294
- // autonomous-orchestrator 中的 LLM 动作调度
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
- ```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
- // 指数退避
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
- - 分析任务:Gemini(大上下文)> Qwen
352
- - 生成任务:Codex(自主执行)> Gemini > Qwen
353
- - 代码修改:Codex > Gemini
354
-
355
- 2. **配置 Fallback Chain**
356
- - 总是配置至少一个 fallback
357
- - 考虑工具特性选择 fallback 顺序
358
-
359
- 3. **超时设置**
360
- - 分析任务:10-15 分钟
361
- - 生成任务:15-20 分钟
362
- - 复杂任务:20-60 分钟
363
-
364
- 4. **提示词设计**
365
- - 使用 PURPOSE/TASK/MODE/CONTEXT/EXPECTED/RULES 结构
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