Skip to content

Commit 834951a

Browse files
author
catlog22
committed
feat(flow-coordinator): add slashCommand/slashArgs support for unified workflow
- Add buildNodeInstruction() to construct instructions from slashCommand field - Support slashArgs with {{variable}} interpolation - Append additional instruction as context when slashCommand is set - Update unified-workflow-spec.md with slashCommand/slashArgs documentation This enables frontend orchestrator JSON to be directly consumed by flow-coordinator skill in Claude client.
1 parent e555355 commit 834951a

2 files changed

Lines changed: 43 additions & 7 deletions

File tree

.claude/skills/flow-coordinator/SKILL.md

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Execution Modes:
4343

4444
**Unified PromptTemplate Model**: All workflow steps are natural language instructions with:
4545
- `instruction`: What to execute (natural language)
46+
- `slashCommand`: Optional slash command name (e.g., "workflow:plan")
47+
- `slashArgs`: Optional arguments for slash command (supports {{variable}})
4648
- `outputName`: Name for output reference
4749
- `contextRefs`: References to previous step outputs
4850
- `tool`: Optional CLI tool (gemini/qwen/codex/claude)
@@ -137,18 +139,14 @@ async function executeDAG(workflow, order, state, statusPath) {
137139
continue; // Will be executed when dependencies complete
138140
}
139141

140-
// Resolve context references
141-
const resolvedInstruction = resolveContextRefs(
142-
data.instruction,
143-
data.contextRefs || [],
144-
state.outputs
145-
);
142+
// Build instruction from slashCommand or raw instruction
143+
let instruction = buildNodeInstruction(data, state.outputs);
146144

147145
// Execute based on mode
148146
state.nodeStates[nodeId] = { status: 'running' };
149147
write(statusPath, JSON.stringify(state, null, 2));
150148

151-
const result = await executeNode(resolvedInstruction, data.tool, data.mode);
149+
const result = await executeNode(instruction, data.tool, data.mode);
152150

153151
// Store output for downstream nodes
154152
state.nodeStates[nodeId] = { status: 'completed', result };
@@ -162,6 +160,36 @@ async function executeDAG(workflow, order, state, statusPath) {
162160
write(statusPath, JSON.stringify(state, null, 2));
163161
}
164162

163+
/**
164+
* Build node instruction from slashCommand or raw instruction
165+
* Handles slashCommand/slashArgs fields from frontend orchestrator
166+
*/
167+
function buildNodeInstruction(data, outputs) {
168+
const refs = data.contextRefs || [];
169+
170+
// If slashCommand is set, construct instruction from it
171+
if (data.slashCommand) {
172+
// Resolve variables in slashArgs
173+
const args = data.slashArgs
174+
? resolveContextRefs(data.slashArgs, refs, outputs)
175+
: '';
176+
177+
// Build slash command instruction
178+
let instruction = `/${data.slashCommand}${args ? ' ' + args : ''}`;
179+
180+
// Append additional instruction if provided
181+
if (data.instruction) {
182+
const additionalInstruction = resolveContextRefs(data.instruction, refs, outputs);
183+
instruction = `${instruction}\n\n${additionalInstruction}`;
184+
}
185+
186+
return instruction;
187+
}
188+
189+
// Fallback: use raw instruction with context refs resolved
190+
return resolveContextRefs(data.instruction || '', refs, outputs);
191+
}
192+
165193
function resolveContextRefs(instruction, refs, outputs) {
166194
let resolved = instruction;
167195
for (const ref of refs) {

.claude/skills/flow-coordinator/spec/unified-workflow-spec.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ interface PromptTemplateNodeData {
4848
label: string; // Display label in editor
4949
instruction: string; // Natural language instruction
5050

51+
// === Slash Command (optional, overrides instruction) ===
52+
slashCommand?: string; // Slash command name (e.g., "workflow:plan")
53+
slashArgs?: string; // Arguments for slash command (supports {{variable}})
54+
5155
// === Data Flow ===
5256
outputName?: string; // Name for output reference
5357
contextRefs?: string[]; // References to previous outputs
@@ -63,6 +67,10 @@ interface PromptTemplateNodeData {
6367
}
6468
```
6569

70+
**Instruction Resolution Priority**:
71+
1. If `slashCommand` is set: `/{slashCommand} {slashArgs}` + optional `instruction` as context
72+
2. Otherwise: `instruction` directly
73+
6674
### FlowEdge
6775

6876
```typescript

0 commit comments

Comments
 (0)