@orchestrator-claude/cli 3.17.0 → 3.18.0
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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/templates/base/CLAUDE.md.hbs +45 -27
- package/dist/templates/base/claude/agents/orchestrator.md +84 -117
- package/dist/templates/base/claude/hooks/dangling-guard.ts +53 -0
- package/dist/templates/base/claude/hooks/gate-guardian.ts +102 -0
- package/dist/templates/base/claude/hooks/lib/api-client.ts +293 -0
- package/dist/templates/base/claude/hooks/lib/git-checkpoint.ts +91 -0
- package/dist/templates/base/claude/hooks/package.json +13 -0
- package/dist/templates/base/claude/hooks/post-compact.ts +44 -0
- package/dist/templates/base/claude/hooks/session-start.ts +97 -0
- package/dist/templates/base/claude/hooks/subagent-start.ts +50 -0
- package/dist/templates/base/claude/hooks/subagent-stop.ts +57 -0
- package/dist/templates/base/claude/hooks/tsconfig.json +18 -0
- package/dist/templates/base/claude/hooks/user-prompt.ts +95 -0
- package/dist/templates/base/claude/hooks/workflow-guard.ts +120 -0
- package/dist/templates/base/claude/settings.json +23 -22
- package/dist/templates/base/claude/skills/orchestrator/SKILL.md +108 -0
- package/package.json +1 -1
- package/templates/base/CLAUDE.md.hbs +45 -27
- package/templates/base/claude/agents/orchestrator.md +84 -117
- package/templates/base/claude/hooks/dangling-guard.ts +53 -0
- package/templates/base/claude/hooks/gate-guardian.ts +102 -0
- package/templates/base/claude/hooks/lib/api-client.ts +293 -0
- package/templates/base/claude/hooks/lib/git-checkpoint.ts +91 -0
- package/templates/base/claude/hooks/package.json +13 -0
- package/templates/base/claude/hooks/post-compact.ts +44 -0
- package/templates/base/claude/hooks/session-start.ts +97 -0
- package/templates/base/claude/hooks/subagent-start.ts +50 -0
- package/templates/base/claude/hooks/subagent-stop.ts +57 -0
- package/templates/base/claude/hooks/tsconfig.json +18 -0
- package/templates/base/claude/hooks/user-prompt.ts +95 -0
- package/templates/base/claude/hooks/workflow-guard.ts +120 -0
- package/templates/base/claude/settings.json +23 -22
- package/templates/base/claude/skills/orchestrator/SKILL.md +108 -0
- package/dist/templates/base/claude/hooks/dangling-workflow-guard.sh +0 -57
- package/dist/templates/base/claude/hooks/gate-guardian.sh +0 -84
- package/dist/templates/base/claude/hooks/orch-helpers.sh +0 -135
- package/dist/templates/base/claude/hooks/ping-pong-enforcer.sh +0 -58
- package/dist/templates/base/claude/hooks/post-phase-checkpoint.sh +0 -203
- package/dist/templates/base/claude/hooks/prompt-orchestrator.sh +0 -41
- package/dist/templates/base/claude/hooks/session-orchestrator.sh +0 -54
- package/dist/templates/base/claude/hooks/track-agent-invocation.sh +0 -230
- package/dist/templates/base/claude/hooks/workflow-guard.sh +0 -79
- package/templates/base/claude/hooks/dangling-workflow-guard.sh +0 -57
- package/templates/base/claude/hooks/gate-guardian.sh +0 -84
- package/templates/base/claude/hooks/orch-helpers.sh +0 -135
- package/templates/base/claude/hooks/ping-pong-enforcer.sh +0 -58
- package/templates/base/claude/hooks/post-phase-checkpoint.sh +0 -203
- package/templates/base/claude/hooks/prompt-orchestrator.sh +0 -41
- package/templates/base/claude/hooks/session-orchestrator.sh +0 -54
- package/templates/base/claude/hooks/track-agent-invocation.sh +0 -230
- package/templates/base/claude/hooks/workflow-guard.sh +0 -79
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* user-prompt.ts — UserPromptSubmit hook (RFC-022 Phase 2)
|
|
3
|
+
* Replaces prompt-orchestrator.sh
|
|
4
|
+
* Detects workflow type and injects hints by confidence tiers.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
log,
|
|
9
|
+
readStdin,
|
|
10
|
+
getField,
|
|
11
|
+
getActiveWorkflow,
|
|
12
|
+
getNextAction,
|
|
13
|
+
detectWorkflow,
|
|
14
|
+
outputContext,
|
|
15
|
+
} from "./lib/api-client.js";
|
|
16
|
+
|
|
17
|
+
const HOOK = "USER-PROMPT";
|
|
18
|
+
|
|
19
|
+
async function main(): Promise<void> {
|
|
20
|
+
log(HOOK, "UserPromptSubmit triggered");
|
|
21
|
+
|
|
22
|
+
const stdin = await readStdin();
|
|
23
|
+
const workflow = await getActiveWorkflow();
|
|
24
|
+
|
|
25
|
+
if (!workflow) {
|
|
26
|
+
// No active workflow — detect and suggest
|
|
27
|
+
const prompt = getField(stdin, "prompt");
|
|
28
|
+
if (!prompt) {
|
|
29
|
+
log(HOOK, "empty prompt, silence");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const detection = await detectWorkflow(prompt);
|
|
34
|
+
if (!detection) {
|
|
35
|
+
log(HOOK, "detect API failed/timeout, silence (fail-open)");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { workflowType, confidence, suggestedMode } = detection;
|
|
40
|
+
log(HOOK, `detected type=${workflowType} confidence=${confidence} mode=${suggestedMode}`);
|
|
41
|
+
|
|
42
|
+
// Tier 1: interactive_analysis
|
|
43
|
+
if (workflowType === "interactive_analysis") {
|
|
44
|
+
outputContext(
|
|
45
|
+
"UserPromptSubmit",
|
|
46
|
+
[
|
|
47
|
+
"[ORCHESTRATOR] This looks like an analytical/design request. How would you like to proceed?",
|
|
48
|
+
'(a) Continue as a free conversation (no workflow)',
|
|
49
|
+
'(b) Start an interactive_analysis workflow for structured exploration (cyclic phases: research → discuss → analyze)',
|
|
50
|
+
"",
|
|
51
|
+
'If you choose (b), I will call: mcp__orchestrator-tools__startWorkflow({ type: "interactive_analysis", prompt: "..." })',
|
|
52
|
+
].join("\n")
|
|
53
|
+
);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Tier 2: high confidence (>= 0.7)
|
|
58
|
+
if (confidence >= 0.7) {
|
|
59
|
+
const mode = suggestedMode || "standard";
|
|
60
|
+
outputContext(
|
|
61
|
+
"UserPromptSubmit",
|
|
62
|
+
`[ORCHESTRATOR] Detected: ${workflowType} workflow (confidence: ${confidence}, suggested mode: ${mode}).\nTo start: mcp__orchestrator-tools__startWorkflow({ type: "${workflowType}", prompt: "...", mode: "${mode}" })\nOr continue without a workflow if this is exploratory.`
|
|
63
|
+
);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Tier 3: medium confidence (0.5-0.69)
|
|
68
|
+
if (confidence >= 0.5) {
|
|
69
|
+
outputContext(
|
|
70
|
+
"UserPromptSubmit",
|
|
71
|
+
`[ORCHESTRATOR] Hint: this might be a ${workflowType} task. Consider starting a workflow if you plan to write code.`
|
|
72
|
+
);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Tier 4: low confidence — silence
|
|
77
|
+
log(HOOK, `Tier 4 silence (confidence=${confidence} < 0.5)`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Active workflow — inject state
|
|
82
|
+
const action = await getNextAction(workflow.id);
|
|
83
|
+
let context: string;
|
|
84
|
+
|
|
85
|
+
if (action?.hasAction && action.pendingAction) {
|
|
86
|
+
context = `[ORCHESTRATOR] Active workflow: ${workflow.id}. Next: invoke '${action.pendingAction.agent}' (${action.pendingAction.status}).`;
|
|
87
|
+
} else {
|
|
88
|
+
context = `[ORCHESTRATOR] Active workflow: ${workflow.id}. No pending actions.`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
log(HOOK, `workflow=${workflow.id} hasAction=${action?.hasAction}`);
|
|
92
|
+
outputContext("UserPromptSubmit", context);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
main().catch(() => process.exit(0));
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* workflow-guard.ts — PreToolUse[Write|Edit] hook (RFC-022 Phase 2)
|
|
3
|
+
* Replaces workflow-guard.sh
|
|
4
|
+
* Blocks writes to src/ and tests/ without active workflow.
|
|
5
|
+
* Respects SKIP_WORKFLOW_GUARD, quick/interactive modes, sub-agent writes.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
log,
|
|
10
|
+
readStdin,
|
|
11
|
+
getField,
|
|
12
|
+
getActiveWorkflow,
|
|
13
|
+
getWorkflowMode,
|
|
14
|
+
outputPreToolUse,
|
|
15
|
+
} from "./lib/api-client.js";
|
|
16
|
+
|
|
17
|
+
const HOOK = "WORKFLOW-GUARD";
|
|
18
|
+
|
|
19
|
+
async function main(): Promise<void> {
|
|
20
|
+
const stdin = await readStdin();
|
|
21
|
+
const filePath = getField(stdin, "tool_input.file_path") || getField(stdin, "file_path") || getField(stdin, "input.file_path");
|
|
22
|
+
|
|
23
|
+
log(HOOK, `file_path=${filePath}`);
|
|
24
|
+
|
|
25
|
+
// Explicit bypass
|
|
26
|
+
if (process.env.SKIP_WORKFLOW_GUARD === "true") {
|
|
27
|
+
log(HOOK, "ALLOW (SKIP_WORKFLOW_GUARD=true)");
|
|
28
|
+
outputPreToolUse({
|
|
29
|
+
decision: "allow",
|
|
30
|
+
context: "Workflow guard bypassed via SKIP_WORKFLOW_GUARD=true.",
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Only guard src/ and tests/ paths
|
|
36
|
+
if (!filePath.includes("/src/") && !filePath.includes("/tests/")) {
|
|
37
|
+
log(HOOK, "ALLOW (non-guarded path)");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Allow config/doc files
|
|
42
|
+
if (/\.(json|ya?ml|md|env(\..*)?)$/.test(filePath)) {
|
|
43
|
+
log(HOOK, "ALLOW (config/doc file)");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Check for active workflow
|
|
48
|
+
const workflow = await getActiveWorkflow();
|
|
49
|
+
|
|
50
|
+
if (workflow) {
|
|
51
|
+
const mode = await getWorkflowMode(workflow.id);
|
|
52
|
+
log(HOOK, `workflow=${workflow.id} mode=${mode || "legacy"}`);
|
|
53
|
+
|
|
54
|
+
if (mode === "quick") {
|
|
55
|
+
outputPreToolUse({
|
|
56
|
+
decision: "allow",
|
|
57
|
+
context: `Active workflow: ${workflow.id} (mode: quick). Direct writes allowed in quick mode.`,
|
|
58
|
+
});
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (mode === "interactive") {
|
|
63
|
+
outputPreToolUse({
|
|
64
|
+
decision: "allow",
|
|
65
|
+
context: `Active workflow: ${workflow.id} (mode: interactive). Note: code writes are unexpected in interactive/analysis workflows.`,
|
|
66
|
+
});
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Check if running inside a sub-agent
|
|
71
|
+
const agentId = getField(stdin, "agent_id");
|
|
72
|
+
if (agentId) {
|
|
73
|
+
const agentType = getField(stdin, "agent_type");
|
|
74
|
+
log(HOOK, `ALLOW (sub-agent: ${agentType || "unknown"}, workflow: ${workflow.id})`);
|
|
75
|
+
outputPreToolUse({
|
|
76
|
+
decision: "allow",
|
|
77
|
+
context: `Active workflow: ${workflow.id}. Sub-agent ${agentType || "unknown"} write allowed.`,
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Main agent writing directly — check SKIP_SUBAGENT_GUARD
|
|
83
|
+
if (process.env.SKIP_SUBAGENT_GUARD === "true") {
|
|
84
|
+
log(HOOK, `ALLOW (SKIP_SUBAGENT_GUARD=true, workflow: ${workflow.id})`);
|
|
85
|
+
outputPreToolUse({
|
|
86
|
+
decision: "allow",
|
|
87
|
+
context: `Active workflow: ${workflow.id}. Direct write allowed via SKIP_SUBAGENT_GUARD.`,
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Main agent direct write — DENY
|
|
93
|
+
log(HOOK, `DENY (main agent direct write, mode=${mode || "legacy"})`);
|
|
94
|
+
outputPreToolUse({
|
|
95
|
+
decision: "deny",
|
|
96
|
+
reason:
|
|
97
|
+
"Workflow Guard: Direct code writes are blocked. You must invoke a sub-agent (e.g. implementer) to write code. The sub-agent will have write access.",
|
|
98
|
+
context:
|
|
99
|
+
"Use the Agent tool to spawn an implementer sub-agent for code changes. The workflow-guard allows writes only from sub-agents (identified by agent_id in hook input).",
|
|
100
|
+
});
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// No active workflow — DENY
|
|
105
|
+
log(HOOK, "DENY (no active workflow)");
|
|
106
|
+
outputPreToolUse({
|
|
107
|
+
decision: "deny",
|
|
108
|
+
reason: "Workflow Guard: No active workflow. Direct implementation is not allowed.",
|
|
109
|
+
context: [
|
|
110
|
+
"You MUST start a workflow before writing code:",
|
|
111
|
+
'1. mcp__orchestrator-tools__detectWorkflow({ prompt: "..." })',
|
|
112
|
+
'2. mcp__orchestrator-tools__startWorkflow({ workflowType: "...", prompt: "..." })',
|
|
113
|
+
"3. Follow the nextStep returned by startWorkflow",
|
|
114
|
+
"",
|
|
115
|
+
"The workflow-guard hook blocks all writes to src/ and tests/ without an active workflow.",
|
|
116
|
+
].join("\n"),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
main().catch(() => process.exit(0));
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"hooks": {
|
|
40
40
|
"SessionStart": [
|
|
41
41
|
{
|
|
42
|
-
"matcher": "startup",
|
|
42
|
+
"matcher": "startup|resume",
|
|
43
43
|
"hooks": [
|
|
44
44
|
{
|
|
45
45
|
"type": "command",
|
|
46
|
-
"command": ".claude/hooks/session-
|
|
46
|
+
"command": "npx tsx .claude/hooks/session-start.ts",
|
|
47
47
|
"timeout": 10000,
|
|
48
48
|
"on_failure": "ignore"
|
|
49
49
|
}
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"hooks": [
|
|
57
57
|
{
|
|
58
58
|
"type": "command",
|
|
59
|
-
"command": ".claude/hooks/prompt
|
|
59
|
+
"command": "npx tsx .claude/hooks/user-prompt.ts",
|
|
60
60
|
"timeout": 10000,
|
|
61
61
|
"on_failure": "ignore"
|
|
62
62
|
}
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"hooks": [
|
|
70
70
|
{
|
|
71
71
|
"type": "command",
|
|
72
|
-
"command": ".claude/hooks/gate-guardian.
|
|
72
|
+
"command": "npx tsx .claude/hooks/gate-guardian.ts",
|
|
73
73
|
"timeout": 15000,
|
|
74
74
|
"on_failure": "warn"
|
|
75
75
|
}
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"hooks": [
|
|
81
81
|
{
|
|
82
82
|
"type": "command",
|
|
83
|
-
"command": ".claude/hooks/workflow-guard.
|
|
83
|
+
"command": "npx tsx .claude/hooks/workflow-guard.ts",
|
|
84
84
|
"timeout": 10000,
|
|
85
85
|
"on_failure": "warn"
|
|
86
86
|
}
|
|
@@ -89,12 +89,12 @@
|
|
|
89
89
|
],
|
|
90
90
|
"SubagentStart": [
|
|
91
91
|
{
|
|
92
|
-
"matcher": "implementer|specifier|planner|task-generator|reviewer|researcher
|
|
92
|
+
"matcher": "implementer|specifier|planner|task-generator|reviewer|researcher",
|
|
93
93
|
"hooks": [
|
|
94
94
|
{
|
|
95
95
|
"type": "command",
|
|
96
|
-
"command": ".claude/hooks/
|
|
97
|
-
"timeout":
|
|
96
|
+
"command": "npx tsx .claude/hooks/subagent-start.ts",
|
|
97
|
+
"timeout": 10000,
|
|
98
98
|
"on_failure": "ignore"
|
|
99
99
|
}
|
|
100
100
|
]
|
|
@@ -102,37 +102,38 @@
|
|
|
102
102
|
],
|
|
103
103
|
"SubagentStop": [
|
|
104
104
|
{
|
|
105
|
-
"matcher": "implementer|specifier|planner|task-generator|reviewer|researcher
|
|
105
|
+
"matcher": "implementer|specifier|planner|task-generator|reviewer|researcher",
|
|
106
106
|
"hooks": [
|
|
107
107
|
{
|
|
108
108
|
"type": "command",
|
|
109
|
-
"command": ".claude/hooks/
|
|
110
|
-
"timeout":
|
|
109
|
+
"command": "npx tsx .claude/hooks/subagent-stop.ts",
|
|
110
|
+
"timeout": 30000,
|
|
111
111
|
"on_failure": "ignore"
|
|
112
|
-
}
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"Stop": [
|
|
117
|
+
{
|
|
118
|
+
"matcher": "",
|
|
119
|
+
"hooks": [
|
|
113
120
|
{
|
|
114
121
|
"type": "command",
|
|
115
|
-
"command": ".claude/hooks/
|
|
122
|
+
"command": "npx tsx .claude/hooks/dangling-guard.ts",
|
|
116
123
|
"timeout": 15000,
|
|
117
|
-
"on_failure": "warn"
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
"type": "command",
|
|
121
|
-
"command": ".claude/hooks/post-phase-checkpoint.sh",
|
|
122
|
-
"timeout": 30000,
|
|
123
124
|
"on_failure": "ignore"
|
|
124
125
|
}
|
|
125
126
|
]
|
|
126
127
|
}
|
|
127
128
|
],
|
|
128
|
-
"
|
|
129
|
+
"PostCompact": [
|
|
129
130
|
{
|
|
130
131
|
"matcher": "",
|
|
131
132
|
"hooks": [
|
|
132
133
|
{
|
|
133
134
|
"type": "command",
|
|
134
|
-
"command": ".claude/hooks/
|
|
135
|
-
"timeout":
|
|
135
|
+
"command": "npx tsx .claude/hooks/post-compact.ts",
|
|
136
|
+
"timeout": 5000,
|
|
136
137
|
"on_failure": "ignore"
|
|
137
138
|
}
|
|
138
139
|
]
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: orchestrator
|
|
3
|
+
description: Workflow coordination — phase dispatch, sub-agent management, gate checks. Use when starting features/bugs/refactoring, or when the user invokes /orchestrator. The session greeting is handled by CLAUDE.md Rule #1 + hook data, NOT by this skill.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: /orchestrator
|
|
7
|
+
|
|
8
|
+
You are the **workflow orchestrator**. The main conversation coordinates all phases directly — no orchestrator sub-agent needed. Sub-agents (specifier, planner, implementer, etc.) are dispatched via the Agent tool from this conversation.
|
|
9
|
+
|
|
10
|
+
**Note:** The session greeting (AskUserQuestion on start) is handled by CLAUDE.md Rule #1 using hook-injected data. This skill is loaded only when the user chooses to start or continue a workflow.
|
|
11
|
+
|
|
12
|
+
## Step 1: Start Workflow
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
mcp__orchestrator-tools__detectWorkflow({ prompt: "user's request" })
|
|
16
|
+
mcp__orchestrator-tools__startWorkflow({ type: "feature_development|bug_fix|refactoring", prompt: "..." })
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Workflow types: `feature_development`, `bug_fix`, `refactoring`, `emergency_debug`
|
|
20
|
+
|
|
21
|
+
## Step 4: Phase Dispatch Loop
|
|
22
|
+
|
|
23
|
+
For each phase in the workflow, follow this cycle:
|
|
24
|
+
|
|
25
|
+
### 4a. Dispatch Phase Sub-Agent
|
|
26
|
+
|
|
27
|
+
| Phase | Agent | What it produces |
|
|
28
|
+
|-------|-------|-----------------|
|
|
29
|
+
| research | researcher | Research findings |
|
|
30
|
+
| specify | specifier | spec.md → artifactStore |
|
|
31
|
+
| plan | planner | plan.md → artifactStore |
|
|
32
|
+
| tasks | task-generator | tasks.md → artifactStore |
|
|
33
|
+
| implement | implementer | Code + tests |
|
|
34
|
+
| review | reviewer | Review feedback |
|
|
35
|
+
|
|
36
|
+
Dispatch the appropriate sub-agent:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
Agent(subagent_type: "{phase_agent}", prompt: "
|
|
40
|
+
[Workflow] Type: {type}, Phase: {phase}, Project: {projectId}
|
|
41
|
+
[Previous artifact] {summary of previous phase artifact, if any}
|
|
42
|
+
[Task] {phase-specific instructions from user's original request}
|
|
43
|
+
")
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Critical:** Sub-agents MUST use `artifactStore` to persist artifacts to MinIO. Include this instruction in every sub-agent prompt:
|
|
47
|
+
> Store your output artifact via mcp__orchestrator-extended__artifactStore with workflowId, type (spec|plan|tasks), and content.
|
|
48
|
+
|
|
49
|
+
### 4b. Gate Check via AskUserQuestion
|
|
50
|
+
|
|
51
|
+
After each sub-agent completes, present the artifact summary and ask for approval:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
AskUserQuestion({
|
|
55
|
+
question: "Phase '{phase}' complete.\n\n{artifact_summary}\n\nApprove to proceed to next phase?",
|
|
56
|
+
options: ["Approve", "Request changes", "Abort workflow"]
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- **Approve**: Call `advancePhase` and dispatch next phase agent
|
|
61
|
+
- **Request changes**: Re-dispatch the same sub-agent with feedback
|
|
62
|
+
- **Abort**: Call `completeWorkflow` with cancelled status
|
|
63
|
+
|
|
64
|
+
### 4c. Advance Phase
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
mcp__orchestrator-tools__advancePhase({ workflowId: "..." })
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Then loop back to 4a for the next phase.
|
|
71
|
+
|
|
72
|
+
## Step 5: Complete Workflow
|
|
73
|
+
|
|
74
|
+
After all phases are done:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
ToolSearch("select:mcp__orchestrator-extended__completeWorkflow")
|
|
78
|
+
mcp__orchestrator-extended__completeWorkflow({ workflowId: "..." })
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Summarize what was accomplished and any follow-up items.
|
|
82
|
+
|
|
83
|
+
## Rules
|
|
84
|
+
|
|
85
|
+
1. **YOU are the orchestrator** — dispatch sub-agents via Agent tool, do NOT invoke Agent(subagent_type: "orchestrator")
|
|
86
|
+
2. **Every gate uses AskUserQuestion** — NEVER auto-approve phase transitions
|
|
87
|
+
3. **Artifacts go to MinIO** — sub-agents MUST call artifactStore
|
|
88
|
+
4. **MCP tools are deferred** — call ToolSearch before first use of any mcp__* tool
|
|
89
|
+
5. **Keep sub-agent prompts focused** — include workflow context + previous artifact summary + task description
|
|
90
|
+
6. **Summarize, don't dump** — when presenting gate checks, show a concise summary of the artifact, not the full content
|
|
91
|
+
|
|
92
|
+
## Phase-Specific Skills
|
|
93
|
+
|
|
94
|
+
Load these skills for phase-specific guidance when needed:
|
|
95
|
+
|
|
96
|
+
| Skill | When |
|
|
97
|
+
|-------|------|
|
|
98
|
+
| `/artifact-production` | Before dispatching specify/plan/tasks agents |
|
|
99
|
+
| `/tdd-discipline` | Before dispatching implementer |
|
|
100
|
+
| `/project-conventions` | Before any implementation work |
|
|
101
|
+
| `/checkpoint-protocol` | After completing task groups |
|
|
102
|
+
|
|
103
|
+
## Error Recovery
|
|
104
|
+
|
|
105
|
+
- **Sub-agent fails**: Read the error, fix the issue, re-dispatch
|
|
106
|
+
- **MCP tool not found**: Call ToolSearch to load the schema, then retry
|
|
107
|
+
- **Workflow stuck**: Call `getStatus` to diagnose, present options to user via AskUserQuestion
|
|
108
|
+
- **Context getting large**: Sub-agents handle heavy work; main conversation stays lean with summaries
|
package/package.json
CHANGED
|
@@ -3,51 +3,64 @@
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
5
|
This project uses the **Orchestrator System** for autonomous workflow management.
|
|
6
|
-
|
|
6
|
+
The main conversation IS the orchestrator — it coordinates all phases directly, dispatching sub-agents as needed.
|
|
7
7
|
|
|
8
8
|
## Critical Rules
|
|
9
9
|
|
|
10
|
-
1. **
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
1. **On session start, greet via AskUserQuestion** — use `[ORCHESTRATOR-DATA]` from the SessionStart hook context (already injected). Do NOT load any skill for the greeting. Format:
|
|
11
|
+
```
|
|
12
|
+
AskUserQuestion({
|
|
13
|
+
question: "━━ Orchestrator {version} ━━\n{status_summary}\nNext: {next_item}\n\nWhat would you like to do?",
|
|
14
|
+
options: ["Start workflow for next item", "Start workflow for something else", "Free conversation"]
|
|
15
|
+
})
|
|
16
|
+
```
|
|
17
|
+
If `[ORCHESTRATOR-DATA]` is missing (API down), fallback: invoke `/orchestrator` skill.
|
|
18
|
+
If there is an active workflow, adapt greeting to show workflow state and offer "Continue workflow".
|
|
19
|
+
2. **To start or manage workflows, invoke `/orchestrator`** — it coordinates phases, dispatches sub-agents, and enforces gates via AskUserQuestion.
|
|
20
|
+
3. **NEVER implement features directly** — start a workflow first
|
|
21
|
+
4. **NEVER bump versions manually** — always use `/release patch|minor|major`
|
|
22
|
+
5. **NEVER edit `.orchestrator/orchestrator-index.json`** — state is in PostgreSQL
|
|
23
|
+
6. **Access artifacts via MCP tools** (`artifactStore`, `artifactRetrieve`), not filesystem paths
|
|
24
|
+
7. **NEVER invoke `Agent(subagent_type: "orchestrator")`** — YOU are the orchestrator (RFC-022)
|
|
25
|
+
|
|
26
|
+
## How Workflows Work
|
|
27
|
+
|
|
28
|
+
The main conversation is the orchestrator. Sub-agents (specifier, planner, implementer, etc.) are dispatched via the Agent tool directly.
|
|
18
29
|
|
|
19
30
|
```
|
|
20
|
-
1.
|
|
21
|
-
2.
|
|
22
|
-
3.
|
|
23
|
-
4.
|
|
31
|
+
1. AskUserQuestion (greeting) ← immediate, uses hook data
|
|
32
|
+
2. User chooses to start workflow
|
|
33
|
+
3. /orchestrator skill + detectWorkflow ← loads coordination context
|
|
34
|
+
4. Agent(subagent_type: "specifier") ← dispatched from main conversation
|
|
35
|
+
5. AskUserQuestion → gate check ← human approval
|
|
36
|
+
6. advancePhase ← MCP tool
|
|
37
|
+
7. Agent(subagent_type: "planner") ← next phase
|
|
38
|
+
8. ...repeat until complete...
|
|
39
|
+
9. completeWorkflow ← MCP tool
|
|
24
40
|
```
|
|
25
41
|
|
|
26
|
-
**
|
|
27
|
-
|
|
28
|
-
**Exceptions** (may be called directly): `detectWorkflow`, `startWorkflow`, `approveAction`, `completeWorkflow`, `getStatus`.
|
|
42
|
+
**Key principle:** Every phase gate uses `AskUserQuestion` — never auto-approve transitions.
|
|
29
43
|
|
|
30
44
|
Workflow types: `feature_development`, `bug_fix`, `refactoring`, `emergency_debug`
|
|
31
45
|
|
|
32
|
-
## What Hooks Enforce Automatically
|
|
46
|
+
## What Hooks Enforce Automatically (TypeScript, RFC-022)
|
|
33
47
|
|
|
34
48
|
| Hook | Trigger | What it does |
|
|
35
49
|
|------|---------|-------------|
|
|
36
|
-
| `
|
|
37
|
-
| `
|
|
38
|
-
| `
|
|
39
|
-
| `
|
|
40
|
-
| `
|
|
41
|
-
| `
|
|
42
|
-
|
|
43
|
-
|
|
50
|
+
| `session-start.ts` | SessionStart | Injects `[ORCHESTRATOR-DATA]` (version, workflow, next item) for greeting |
|
|
51
|
+
| `user-prompt.ts` | UserPromptSubmit | Detects workflow type, injects hints |
|
|
52
|
+
| `gate-guardian.ts` | Before `advancePhase` | Blocks unless IMPLEMENT phase has approval |
|
|
53
|
+
| `workflow-guard.ts` | Before Write/Edit on src/ | Blocks code writes without active workflow |
|
|
54
|
+
| `subagent-start.ts` | SubagentStart | Registers agent invocation via API |
|
|
55
|
+
| `subagent-stop.ts` | SubagentStop | Completes invocation + git checkpoint + next step guidance |
|
|
56
|
+
| `dangling-guard.ts` | Stop | Warns about dangling workflows |
|
|
57
|
+
| `post-compact.ts` | PostCompact | Re-injects workflow state after context compaction |
|
|
44
58
|
|
|
45
59
|
## Skills (On-Demand Context)
|
|
46
60
|
|
|
47
|
-
Use skills for phase-specific guidance:
|
|
48
|
-
|
|
49
61
|
| Skill | When to use |
|
|
50
62
|
|-------|------------|
|
|
63
|
+
| `/orchestrator` | **Workflow coordination** — phase dispatch, sub-agent management, gate checks |
|
|
51
64
|
| `/workflow-status` | Check current workflow state |
|
|
52
65
|
| `/artifact-production` | Phase-specific artifact formats |
|
|
53
66
|
| `/tdd-discipline` | TDD protocol during IMPLEMENT |
|
|
@@ -66,6 +79,11 @@ Use skills for phase-specific guidance:
|
|
|
66
79
|
- **Clean Architecture**: Dependencies point inward
|
|
67
80
|
- **TypeScript Strict**: `strict: true` required
|
|
68
81
|
|
|
82
|
+
## MCP Tool Notes
|
|
83
|
+
|
|
84
|
+
Extended MCP tools (`artifactStore`, `completeWorkflow`, KB graph tools) are deferred-loaded.
|
|
85
|
+
On the first call in a session you may get `No such tool available` — retry once and it will succeed.
|
|
86
|
+
|
|
69
87
|
---
|
|
70
88
|
|
|
71
89
|
*This project was initialized with the Orchestrator CLI.*
|