claude-code-workflow 6.3.50 → 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/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/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/commands/cli.d.ts.map +1 -1
- package/ccw/dist/commands/cli.js +23 -2
- package/ccw/dist/commands/cli.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/commands/cli.ts +26 -2
- 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,22 +1,22 @@
|
|
|
1
1
|
# Autonomous Action Template
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Template for action files in Autonomous execution mode.
|
|
4
4
|
|
|
5
5
|
## Purpose
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Generate Action files for Autonomous execution mode, defining independent executable action units.
|
|
8
8
|
|
|
9
9
|
## Usage Context
|
|
10
10
|
|
|
11
11
|
| Phase | Usage |
|
|
12
12
|
|-------|-------|
|
|
13
|
-
| Phase 3 (Phase Generation) | `config.execution_mode === 'autonomous'`
|
|
14
|
-
| Generation Trigger |
|
|
13
|
+
| Phase 3 (Phase Generation) | Generated when `config.execution_mode === 'autonomous'` |
|
|
14
|
+
| Generation Trigger | Generate one action file for each `config.autonomous_config.actions` |
|
|
15
15
|
| Output Location | `.claude/skills/{skill-name}/phases/actions/{action-id}.md` |
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Template Structure
|
|
20
20
|
|
|
21
21
|
```markdown
|
|
22
22
|
# Action: {{action_name}}
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
## Scripts
|
|
35
35
|
|
|
36
36
|
\`\`\`yaml
|
|
37
|
-
#
|
|
38
|
-
# - script-id #
|
|
37
|
+
# Declare scripts used in this action (optional)
|
|
38
|
+
# - script-id # Corresponds to scripts/script-id.py or .sh
|
|
39
39
|
\`\`\`
|
|
40
40
|
|
|
41
41
|
## Execution
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
async function execute(state) {
|
|
45
45
|
{{execution_code}}
|
|
46
46
|
|
|
47
|
-
//
|
|
47
|
+
// Script execution example
|
|
48
48
|
// const result = await ExecuteScript('script-id', { input: state.context.data });
|
|
49
49
|
// if (!result.success) throw new Error(result.stderr);
|
|
50
50
|
}
|
|
@@ -71,63 +71,66 @@ return {
|
|
|
71
71
|
{{next_actions_hints}}
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
##
|
|
74
|
+
## Variable Descriptions
|
|
75
75
|
|
|
76
|
-
|
|
|
77
|
-
|
|
78
|
-
| `{{action_name}}` |
|
|
79
|
-
| `{{action_description}}` |
|
|
80
|
-
| `{{purpose}}` |
|
|
81
|
-
| `{{preconditions_list}}` |
|
|
82
|
-
| `{{execution_code}}` |
|
|
83
|
-
| `{{state_updates}}` |
|
|
84
|
-
| `{{error_handling_table}}` |
|
|
85
|
-
| `{{next_actions_hints}}` |
|
|
76
|
+
| Variable | Description |
|
|
77
|
+
|----------|-------------|
|
|
78
|
+
| `{{action_name}}` | Action name |
|
|
79
|
+
| `{{action_description}}` | Action description |
|
|
80
|
+
| `{{purpose}}` | Detailed purpose |
|
|
81
|
+
| `{{preconditions_list}}` | List of preconditions |
|
|
82
|
+
| `{{execution_code}}` | Execution code |
|
|
83
|
+
| `{{state_updates}}` | State updates |
|
|
84
|
+
| `{{error_handling_table}}` | Error handling table |
|
|
85
|
+
| `{{next_actions_hints}}` | Next action hints |
|
|
86
86
|
|
|
87
|
-
##
|
|
87
|
+
## Action Lifecycle
|
|
88
88
|
|
|
89
89
|
```
|
|
90
|
-
|
|
90
|
+
State-driven execution flow:
|
|
91
91
|
|
|
92
92
|
state.status === 'pending'
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
93
|
+
|
|
|
94
|
+
v
|
|
95
|
+
+-- Init --+ <- 1 execution, environment preparation
|
|
96
|
+
| Create working directory
|
|
97
|
+
| Initialize context
|
|
98
|
+
| status -> running
|
|
99
|
+
+----+----+
|
|
100
|
+
|
|
|
101
|
+
v
|
|
102
|
+
+-- CRUD Loop --+ <- N iterations, core business
|
|
103
|
+
| Orchestrator selects action | List / Create / Edit / Delete
|
|
104
|
+
| execute(state) | Shared pattern: collect input -> operate context.items -> return updates
|
|
105
|
+
| Update state
|
|
106
|
+
+----+----+
|
|
107
|
+
|
|
|
108
|
+
v
|
|
109
|
+
+-- Complete --+ <- 1 execution, save results
|
|
110
|
+
| Serialize output
|
|
111
|
+
| status -> completed
|
|
112
|
+
+----------+
|
|
113
|
+
|
|
114
|
+
Shared state structure:
|
|
115
|
+
state.status -> 'pending' | 'running' | 'completed'
|
|
116
|
+
state.context.items -> Business data array
|
|
117
|
+
state.completed_actions -> List of executed action IDs
|
|
115
118
|
```
|
|
116
119
|
|
|
117
|
-
##
|
|
120
|
+
## Action Type Templates
|
|
118
121
|
|
|
119
|
-
### 1.
|
|
122
|
+
### 1. Initialize Action (Init)
|
|
120
123
|
|
|
121
|
-
|
|
124
|
+
**Trigger condition**: `state.status === 'pending'`, executes once
|
|
122
125
|
|
|
123
126
|
```markdown
|
|
124
127
|
# Action: Initialize
|
|
125
128
|
|
|
126
|
-
|
|
129
|
+
Initialize Skill execution state.
|
|
127
130
|
|
|
128
131
|
## Purpose
|
|
129
132
|
|
|
130
|
-
|
|
133
|
+
Set initial state, prepare execution environment.
|
|
131
134
|
|
|
132
135
|
## Preconditions
|
|
133
136
|
|
|
@@ -151,24 +154,24 @@ async function execute(state) {
|
|
|
151
154
|
|
|
152
155
|
## Next Actions
|
|
153
156
|
|
|
154
|
-
-
|
|
155
|
-
-
|
|
157
|
+
- Success: Enter main processing loop (Orchestrator selects first CRUD action)
|
|
158
|
+
- Failure: action-abort
|
|
156
159
|
```
|
|
157
160
|
|
|
158
|
-
### 2. CRUD
|
|
161
|
+
### 2. CRUD Actions (List / Create / Edit / Delete)
|
|
159
162
|
|
|
160
|
-
|
|
163
|
+
**Trigger condition**: `state.status === 'running'`, loop until user exits
|
|
161
164
|
|
|
162
|
-
>
|
|
165
|
+
> Example shows Create action demonstrating shared pattern. List / Edit / Delete follow same structure with different execution logic and state update fields.
|
|
163
166
|
|
|
164
167
|
```markdown
|
|
165
168
|
# Action: Create Item
|
|
166
169
|
|
|
167
|
-
|
|
170
|
+
Create new item.
|
|
168
171
|
|
|
169
172
|
## Purpose
|
|
170
173
|
|
|
171
|
-
|
|
174
|
+
Collect user input, append new record to context.items.
|
|
172
175
|
|
|
173
176
|
## Preconditions
|
|
174
177
|
|
|
@@ -178,25 +181,25 @@ async function execute(state) {
|
|
|
178
181
|
|
|
179
182
|
\`\`\`javascript
|
|
180
183
|
async function execute(state) {
|
|
181
|
-
// 1.
|
|
184
|
+
// 1. Collect input
|
|
182
185
|
const input = await AskUserQuestion({
|
|
183
186
|
questions: [{
|
|
184
|
-
question: "
|
|
185
|
-
header: "
|
|
187
|
+
question: "Please enter item name:",
|
|
188
|
+
header: "Name",
|
|
186
189
|
multiSelect: false,
|
|
187
|
-
options: [{ label: "
|
|
190
|
+
options: [{ label: "Manual input", description: "Enter custom name" }]
|
|
188
191
|
}]
|
|
189
192
|
});
|
|
190
193
|
|
|
191
|
-
// 2.
|
|
194
|
+
// 2. Operate context.items (core logic differs by action type)
|
|
192
195
|
const newItem = {
|
|
193
196
|
id: Date.now().toString(),
|
|
194
|
-
name: input["
|
|
197
|
+
name: input["Name"],
|
|
195
198
|
status: 'pending',
|
|
196
199
|
created_at: new Date().toISOString()
|
|
197
200
|
};
|
|
198
201
|
|
|
199
|
-
// 3.
|
|
202
|
+
// 3. Return state update
|
|
200
203
|
return {
|
|
201
204
|
stateUpdates: {
|
|
202
205
|
context: {
|
|
@@ -211,31 +214,31 @@ async function execute(state) {
|
|
|
211
214
|
|
|
212
215
|
## Next Actions
|
|
213
216
|
|
|
214
|
-
-
|
|
215
|
-
-
|
|
217
|
+
- Continue operations: Orchestrator selects next action based on state
|
|
218
|
+
- User exit: action-complete
|
|
216
219
|
```
|
|
217
220
|
|
|
218
|
-
|
|
221
|
+
**Other CRUD Actions Differences:**
|
|
219
222
|
|
|
220
|
-
|
|
|
221
|
-
|
|
222
|
-
| List | `items.forEach(
|
|
223
|
-
| Create | `items.push(newItem)` |
|
|
224
|
-
| Edit | `items.map(
|
|
225
|
-
| Delete | `items.filter(
|
|
223
|
+
| Action | Core Logic | Extra Preconditions | Key State Field |
|
|
224
|
+
|--------|-----------|-------------------|-----------------|
|
|
225
|
+
| List | `items.forEach(-> console.log)` | None | `current_view: 'list'` |
|
|
226
|
+
| Create | `items.push(newItem)` | None | `last_created_id` |
|
|
227
|
+
| Edit | `items.map(-> replace matching)` | `selected_item_id !== null` | `updated_at` |
|
|
228
|
+
| Delete | `items.filter(-> exclude matching)` | `selected_item_id !== null` | Confirm dialog -> execute |
|
|
226
229
|
|
|
227
|
-
### 3.
|
|
230
|
+
### 3. Complete Action
|
|
228
231
|
|
|
229
|
-
|
|
232
|
+
**Trigger condition**: User explicitly exits or termination condition met, executes once
|
|
230
233
|
|
|
231
234
|
```markdown
|
|
232
235
|
# Action: Complete
|
|
233
236
|
|
|
234
|
-
|
|
237
|
+
Complete task and exit.
|
|
235
238
|
|
|
236
239
|
## Purpose
|
|
237
240
|
|
|
238
|
-
|
|
241
|
+
Serialize final state, end Skill execution.
|
|
239
242
|
|
|
240
243
|
## Preconditions
|
|
241
244
|
|
|
@@ -253,7 +256,7 @@ async function execute(state) {
|
|
|
253
256
|
actions_executed: state.completed_actions.length
|
|
254
257
|
};
|
|
255
258
|
|
|
256
|
-
console.log(
|
|
259
|
+
console.log(\`Task complete: \${summary.total_items} items, \${summary.actions_executed} operations\`);
|
|
257
260
|
|
|
258
261
|
return {
|
|
259
262
|
stateUpdates: {
|
|
@@ -267,31 +270,31 @@ async function execute(state) {
|
|
|
267
270
|
|
|
268
271
|
## Next Actions
|
|
269
272
|
|
|
270
|
-
-
|
|
273
|
+
- None (terminal state)
|
|
271
274
|
```
|
|
272
275
|
|
|
273
|
-
##
|
|
276
|
+
## Generation Function
|
|
274
277
|
|
|
275
278
|
```javascript
|
|
276
279
|
function generateAction(actionConfig, skillConfig) {
|
|
277
280
|
return `# Action: ${actionConfig.name}
|
|
278
281
|
|
|
279
|
-
${actionConfig.description ||
|
|
282
|
+
${actionConfig.description || `Execute ${actionConfig.name} operation`}
|
|
280
283
|
|
|
281
284
|
## Purpose
|
|
282
285
|
|
|
283
|
-
${actionConfig.purpose || 'TODO:
|
|
286
|
+
${actionConfig.purpose || 'TODO: Describe detailed purpose of this action'}
|
|
284
287
|
|
|
285
288
|
## Preconditions
|
|
286
289
|
|
|
287
|
-
${actionConfig.preconditions?.map(p => `- [ ] ${p}`).join('\n') || '- [ ]
|
|
290
|
+
${actionConfig.preconditions?.map(p => `- [ ] ${p}`).join('\n') || '- [ ] No special preconditions'}
|
|
288
291
|
|
|
289
292
|
## Execution
|
|
290
293
|
|
|
291
294
|
\`\`\`javascript
|
|
292
295
|
async function execute(state) {
|
|
293
|
-
// TODO:
|
|
294
|
-
|
|
296
|
+
// TODO: Implement action logic
|
|
297
|
+
|
|
295
298
|
return {
|
|
296
299
|
stateUpdates: {
|
|
297
300
|
completed_actions: [...state.completed_actions, '${actionConfig.id}']
|
|
@@ -305,7 +308,7 @@ async function execute(state) {
|
|
|
305
308
|
\`\`\`javascript
|
|
306
309
|
return {
|
|
307
310
|
stateUpdates: {
|
|
308
|
-
// TODO:
|
|
311
|
+
// TODO: Define state updates
|
|
309
312
|
${actionConfig.effects?.map(e => ` // Effect: ${e}`).join('\n') || ''}
|
|
310
313
|
}
|
|
311
314
|
};
|
|
@@ -315,13 +318,13 @@ ${actionConfig.effects?.map(e => ` // Effect: ${e}`).join('\n') || ''}
|
|
|
315
318
|
|
|
316
319
|
| Error Type | Recovery |
|
|
317
320
|
|------------|----------|
|
|
318
|
-
|
|
|
319
|
-
|
|
|
321
|
+
| Data validation failed | Return error, no state update |
|
|
322
|
+
| Execution exception | Log error, increment error_count |
|
|
320
323
|
|
|
321
324
|
## Next Actions (Hints)
|
|
322
325
|
|
|
323
|
-
-
|
|
324
|
-
-
|
|
326
|
+
- Success: Orchestrator decides based on state
|
|
327
|
+
- Failure: Retry or action-abort
|
|
325
328
|
`;
|
|
326
329
|
}
|
|
327
330
|
```
|
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
# Autonomous Orchestrator Template
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Template for orchestrator file in Autonomous execution mode.
|
|
4
4
|
|
|
5
5
|
## Purpose
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Generate Orchestrator file for Autonomous execution mode, responsible for state-driven action selection and execution loop.
|
|
8
8
|
|
|
9
9
|
## Usage Context
|
|
10
10
|
|
|
11
11
|
| Phase | Usage |
|
|
12
12
|
|-------|-------|
|
|
13
|
-
| Phase 3 (Phase Generation) | `config.execution_mode === 'autonomous'`
|
|
14
|
-
| Generation Trigger |
|
|
13
|
+
| Phase 3 (Phase Generation) | Generated when `config.execution_mode === 'autonomous'` |
|
|
14
|
+
| Generation Trigger | Create orchestrator logic to manage action selection and state updates |
|
|
15
15
|
| Output Location | `.claude/skills/{skill-name}/phases/orchestrator.md` |
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Important Notes
|
|
20
20
|
|
|
21
|
-
> **Phase 0
|
|
21
|
+
> **Phase 0 is mandatory prerequisite**: Before Orchestrator starts execution loop, Phase 0 specification review must be completed first.
|
|
22
22
|
>
|
|
23
|
-
>
|
|
24
|
-
> 1.
|
|
25
|
-
> 2. Orchestrator
|
|
26
|
-
> 3.
|
|
27
|
-
> 4. Architecture Overview
|
|
23
|
+
> When generating Orchestrator, ensure:
|
|
24
|
+
> 1. Phase 0 specification review step is included in SKILL.md
|
|
25
|
+
> 2. Orchestrator validates specification has been reviewed before starting execution loop
|
|
26
|
+
> 3. All Action files reference related specification documents
|
|
27
|
+
> 4. Architecture Overview places Phase 0 before Orchestrator
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## Template Structure
|
|
30
30
|
|
|
31
31
|
```markdown
|
|
32
32
|
# Orchestrator
|
|
33
33
|
|
|
34
34
|
## Role
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
Select and execute next action based on current state.
|
|
37
37
|
|
|
38
38
|
## State Management
|
|
39
39
|
|
|
40
|
-
###
|
|
40
|
+
### Read State
|
|
41
41
|
|
|
42
42
|
\`\`\`javascript
|
|
43
|
-
const state = JSON.parse(Read(
|
|
43
|
+
const state = JSON.parse(Read(\`${workDir}/state.json\`));
|
|
44
44
|
\`\`\`
|
|
45
45
|
|
|
46
|
-
###
|
|
46
|
+
### Update State
|
|
47
47
|
|
|
48
48
|
\`\`\`javascript
|
|
49
49
|
function updateState(updates) {
|
|
50
|
-
const state = JSON.parse(Read(
|
|
50
|
+
const state = JSON.parse(Read(\`${workDir}/state.json\`));
|
|
51
51
|
const newState = {
|
|
52
52
|
...state,
|
|
53
53
|
...updates,
|
|
54
54
|
updated_at: new Date().toISOString()
|
|
55
55
|
};
|
|
56
|
-
Write(
|
|
56
|
+
Write(\`${workDir}/state.json\`, JSON.stringify(newState, null, 2));
|
|
57
57
|
return newState;
|
|
58
58
|
}
|
|
59
59
|
\`\`\`
|
|
@@ -62,18 +62,18 @@ function updateState(updates) {
|
|
|
62
62
|
|
|
63
63
|
\`\`\`javascript
|
|
64
64
|
function selectNextAction(state) {
|
|
65
|
-
// 1.
|
|
65
|
+
// 1. Check termination conditions
|
|
66
66
|
{{termination_checks}}
|
|
67
|
-
|
|
68
|
-
// 2.
|
|
67
|
+
|
|
68
|
+
// 2. Check error limit
|
|
69
69
|
if (state.error_count >= 3) {
|
|
70
70
|
return 'action-abort';
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
// 3.
|
|
72
|
+
|
|
73
|
+
// 3. Action selection logic
|
|
74
74
|
{{action_selection_logic}}
|
|
75
|
-
|
|
76
|
-
// 4.
|
|
75
|
+
|
|
76
|
+
// 4. Default completion
|
|
77
77
|
return 'action-complete';
|
|
78
78
|
}
|
|
79
79
|
\`\`\`
|
|
@@ -83,34 +83,34 @@ function selectNextAction(state) {
|
|
|
83
83
|
\`\`\`javascript
|
|
84
84
|
async function runOrchestrator() {
|
|
85
85
|
console.log('=== Orchestrator Started ===');
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
let iteration = 0;
|
|
88
88
|
const MAX_ITERATIONS = 100;
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
while (iteration < MAX_ITERATIONS) {
|
|
91
91
|
iteration++;
|
|
92
|
-
|
|
93
|
-
// 1.
|
|
94
|
-
const state = JSON.parse(Read(
|
|
95
|
-
console.log(
|
|
96
|
-
|
|
97
|
-
// 2.
|
|
92
|
+
|
|
93
|
+
// 1. Read current state
|
|
94
|
+
const state = JSON.parse(Read(\`${workDir}/state.json\`));
|
|
95
|
+
console.log(\`[Iteration ${iteration}] Status: ${state.status}\`);
|
|
96
|
+
|
|
97
|
+
// 2. Select next action
|
|
98
98
|
const actionId = selectNextAction(state);
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
if (!actionId) {
|
|
101
101
|
console.log('No action selected, terminating.');
|
|
102
102
|
break;
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
console.log(
|
|
106
|
-
|
|
107
|
-
// 3.
|
|
104
|
+
|
|
105
|
+
console.log(\`[Iteration ${iteration}] Executing: ${actionId}\`);
|
|
106
|
+
|
|
107
|
+
// 3. Update state: current action
|
|
108
108
|
updateState({ current_action: actionId });
|
|
109
|
-
|
|
110
|
-
// 4.
|
|
109
|
+
|
|
110
|
+
// 4. Execute action
|
|
111
111
|
try {
|
|
112
|
-
const actionPrompt = Read(
|
|
113
|
-
|
|
112
|
+
const actionPrompt = Read(\`phases/actions/${actionId}.md\`);
|
|
113
|
+
|
|
114
114
|
const result = await Task({
|
|
115
115
|
subagent_type: 'universal-executor',
|
|
116
116
|
run_in_background: false,
|
|
@@ -125,18 +125,18 @@ async function runOrchestrator() {
|
|
|
125
125
|
Return JSON with stateUpdates field.
|
|
126
126
|
\`
|
|
127
127
|
});
|
|
128
|
-
|
|
128
|
+
|
|
129
129
|
const actionResult = JSON.parse(result);
|
|
130
|
-
|
|
131
|
-
// 5.
|
|
130
|
+
|
|
131
|
+
// 5. Update state: action completed
|
|
132
132
|
updateState({
|
|
133
133
|
current_action: null,
|
|
134
134
|
completed_actions: [...state.completed_actions, actionId],
|
|
135
135
|
...actionResult.stateUpdates
|
|
136
136
|
});
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
} catch (error) {
|
|
139
|
-
//
|
|
139
|
+
// Error handling
|
|
140
140
|
updateState({
|
|
141
141
|
current_action: null,
|
|
142
142
|
errors: [...state.errors, {
|
|
@@ -148,7 +148,7 @@ Return JSON with stateUpdates field.
|
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
|
|
152
152
|
console.log('=== Orchestrator Finished ===');
|
|
153
153
|
}
|
|
154
154
|
\`\`\`
|
|
@@ -167,28 +167,28 @@ Return JSON with stateUpdates field.
|
|
|
167
167
|
|
|
168
168
|
| Error Type | Recovery Strategy |
|
|
169
169
|
|------------|-------------------|
|
|
170
|
-
|
|
|
171
|
-
|
|
|
172
|
-
|
|
|
170
|
+
| Action execution failed | Retry up to 3 times |
|
|
171
|
+
| State inconsistency | Rollback to last stable state |
|
|
172
|
+
| User abort | Save current state, allow recovery |
|
|
173
173
|
```
|
|
174
174
|
|
|
175
|
-
##
|
|
175
|
+
## Variable Descriptions
|
|
176
176
|
|
|
177
|
-
|
|
|
178
|
-
|
|
179
|
-
| `{{termination_checks}}` |
|
|
180
|
-
| `{{action_selection_logic}}` |
|
|
181
|
-
| `{{action_catalog_table}}` |
|
|
182
|
-
| `{{termination_conditions_list}}` |
|
|
177
|
+
| Variable | Description |
|
|
178
|
+
|----------|-------------|
|
|
179
|
+
| `{{termination_checks}}` | Termination condition check code |
|
|
180
|
+
| `{{action_selection_logic}}` | Action selection logic code |
|
|
181
|
+
| `{{action_catalog_table}}` | Action directory table |
|
|
182
|
+
| `{{termination_conditions_list}}` | List of termination conditions |
|
|
183
183
|
|
|
184
|
-
##
|
|
184
|
+
## Generation Function
|
|
185
185
|
|
|
186
186
|
```javascript
|
|
187
187
|
function generateOrchestrator(config) {
|
|
188
188
|
const actions = config.autonomous_config.actions;
|
|
189
189
|
const terminations = config.autonomous_config.termination_conditions || [];
|
|
190
|
-
|
|
191
|
-
//
|
|
190
|
+
|
|
191
|
+
// Generate termination checks
|
|
192
192
|
const terminationChecks = terminations.map(t => {
|
|
193
193
|
const checks = {
|
|
194
194
|
'user_exit': 'if (state.status === "user_exit") return null;',
|
|
@@ -198,24 +198,24 @@ function generateOrchestrator(config) {
|
|
|
198
198
|
};
|
|
199
199
|
return checks[t] || `if (state.${t}) return null;`;
|
|
200
200
|
}).join('\n ');
|
|
201
|
-
|
|
202
|
-
//
|
|
201
|
+
|
|
202
|
+
// Generate action selection logic
|
|
203
203
|
const actionSelectionLogic = actions.map(action => {
|
|
204
204
|
if (!action.preconditions?.length) {
|
|
205
|
-
return `// ${action.name}:
|
|
205
|
+
return `// ${action.name}: No preconditions, add selection logic manually`;
|
|
206
206
|
}
|
|
207
207
|
const conditions = action.preconditions.map(p => `state.${p}`).join(' && ');
|
|
208
208
|
return `if (${conditions}) return '${action.id}';`;
|
|
209
209
|
}).join('\n ');
|
|
210
|
-
|
|
211
|
-
//
|
|
212
|
-
const actionCatalogTable = actions.map(a =>
|
|
210
|
+
|
|
211
|
+
// Generate action catalog table
|
|
212
|
+
const actionCatalogTable = actions.map(a =>
|
|
213
213
|
`| [${a.id}](actions/${a.id}.md) | ${a.description || a.name} | ${a.preconditions?.join(', ') || '-'} |`
|
|
214
214
|
).join('\n');
|
|
215
|
-
|
|
216
|
-
//
|
|
215
|
+
|
|
216
|
+
// Generate termination conditions list
|
|
217
217
|
const terminationConditionsList = terminations.map(t => `- ${t}`).join('\n');
|
|
218
|
-
|
|
218
|
+
|
|
219
219
|
return template
|
|
220
220
|
.replace('{{termination_checks}}', terminationChecks)
|
|
221
221
|
.replace('{{action_selection_logic}}', actionSelectionLogic)
|
|
@@ -224,11 +224,11 @@ function generateOrchestrator(config) {
|
|
|
224
224
|
}
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
-
##
|
|
227
|
+
## Orchestration Strategies
|
|
228
228
|
|
|
229
|
-
### 1.
|
|
229
|
+
### 1. Priority Strategy
|
|
230
230
|
|
|
231
|
-
|
|
231
|
+
Select action by predefined priority:
|
|
232
232
|
|
|
233
233
|
```javascript
|
|
234
234
|
const PRIORITY = ['action-init', 'action-process', 'action-review', 'action-complete'];
|
|
@@ -243,16 +243,16 @@ function selectByPriority(state, availableActions) {
|
|
|
243
243
|
}
|
|
244
244
|
```
|
|
245
245
|
|
|
246
|
-
### 2.
|
|
246
|
+
### 2. User-Driven Strategy
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
Ask user to select next action:
|
|
249
249
|
|
|
250
250
|
```javascript
|
|
251
251
|
async function selectByUser(state, availableActions) {
|
|
252
252
|
const response = await AskUserQuestion({
|
|
253
253
|
questions: [{
|
|
254
|
-
question: "
|
|
255
|
-
header: "
|
|
254
|
+
question: "Select next operation:",
|
|
255
|
+
header: "Operations",
|
|
256
256
|
multiSelect: false,
|
|
257
257
|
options: availableActions.map(a => ({
|
|
258
258
|
label: a.name,
|
|
@@ -260,32 +260,32 @@ async function selectByUser(state, availableActions) {
|
|
|
260
260
|
}))
|
|
261
261
|
}]
|
|
262
262
|
});
|
|
263
|
-
|
|
264
|
-
return availableActions.find(a => a.name === response["
|
|
263
|
+
|
|
264
|
+
return availableActions.find(a => a.name === response["Operations"])?.id;
|
|
265
265
|
}
|
|
266
266
|
```
|
|
267
267
|
|
|
268
|
-
### 3.
|
|
268
|
+
### 3. State-Driven Strategy
|
|
269
269
|
|
|
270
|
-
|
|
270
|
+
Fully automatic decision based on state:
|
|
271
271
|
|
|
272
272
|
```javascript
|
|
273
273
|
function selectByState(state) {
|
|
274
|
-
//
|
|
274
|
+
// Initialization
|
|
275
275
|
if (state.status === 'pending') return 'action-init';
|
|
276
|
-
|
|
277
|
-
//
|
|
276
|
+
|
|
277
|
+
// Has pending items
|
|
278
278
|
if (state.pending_items?.length > 0) return 'action-process';
|
|
279
|
-
|
|
280
|
-
//
|
|
279
|
+
|
|
280
|
+
// Needs review
|
|
281
281
|
if (state.needs_review) return 'action-review';
|
|
282
|
-
|
|
283
|
-
//
|
|
282
|
+
|
|
283
|
+
// Completed
|
|
284
284
|
return 'action-complete';
|
|
285
285
|
}
|
|
286
286
|
```
|
|
287
287
|
|
|
288
|
-
##
|
|
288
|
+
## State Machine Example
|
|
289
289
|
|
|
290
290
|
```mermaid
|
|
291
291
|
stateDiagram-v2
|