@orchestrator-claude/cli 1.4.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/README.md +74 -0
- package/dist/api-client/OrchestratorAPIClient.d.ts +111 -0
- package/dist/api-client/OrchestratorAPIClient.d.ts.map +1 -0
- package/dist/api-client/OrchestratorAPIClient.js +176 -0
- package/dist/api-client/OrchestratorAPIClient.js.map +1 -0
- package/dist/api-client/index.d.ts +11 -0
- package/dist/api-client/index.d.ts.map +1 -0
- package/dist/api-client/index.js +10 -0
- package/dist/api-client/index.js.map +1 -0
- package/dist/api-client/retry.d.ts +29 -0
- package/dist/api-client/retry.d.ts.map +1 -0
- package/dist/api-client/retry.js +85 -0
- package/dist/api-client/retry.js.map +1 -0
- package/dist/api-client/types.d.ts +148 -0
- package/dist/api-client/types.d.ts.map +1 -0
- package/dist/api-client/types.js +10 -0
- package/dist/api-client/types.js.map +1 -0
- package/dist/commands/AgentsCommand.d.ts +74 -0
- package/dist/commands/AgentsCommand.d.ts.map +1 -0
- package/dist/commands/AgentsCommand.js +170 -0
- package/dist/commands/AgentsCommand.js.map +1 -0
- package/dist/commands/InitCommand.d.ts +63 -0
- package/dist/commands/InitCommand.d.ts.map +1 -0
- package/dist/commands/InitCommand.js +150 -0
- package/dist/commands/InitCommand.js.map +1 -0
- package/dist/commands/MigrateCommand.d.ts +93 -0
- package/dist/commands/MigrateCommand.d.ts.map +1 -0
- package/dist/commands/MigrateCommand.js +260 -0
- package/dist/commands/MigrateCommand.js.map +1 -0
- package/dist/commands/StatusCommand.d.ts +61 -0
- package/dist/commands/StatusCommand.d.ts.map +1 -0
- package/dist/commands/StatusCommand.js +142 -0
- package/dist/commands/StatusCommand.js.map +1 -0
- package/dist/commands/TemplatesCommand.d.ts +69 -0
- package/dist/commands/TemplatesCommand.d.ts.map +1 -0
- package/dist/commands/TemplatesCommand.js +147 -0
- package/dist/commands/TemplatesCommand.js.map +1 -0
- package/dist/commands/WorkflowCommand.d.ts +82 -0
- package/dist/commands/WorkflowCommand.d.ts.map +1 -0
- package/dist/commands/WorkflowCommand.js +203 -0
- package/dist/commands/WorkflowCommand.js.map +1 -0
- package/dist/config/CLIConfig.d.ts +66 -0
- package/dist/config/CLIConfig.d.ts.map +1 -0
- package/dist/config/CLIConfig.js +60 -0
- package/dist/config/CLIConfig.js.map +1 -0
- package/dist/formatters/OutputFormatter.d.ts +102 -0
- package/dist/formatters/OutputFormatter.d.ts.map +1 -0
- package/dist/formatters/OutputFormatter.js +182 -0
- package/dist/formatters/OutputFormatter.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +249 -0
- package/dist/index.js.map +1 -0
- package/dist/templates/.gitkeep +0 -0
- package/dist/templates/TemplateEngine.d.ts +90 -0
- package/dist/templates/TemplateEngine.d.ts.map +1 -0
- package/dist/templates/TemplateEngine.js +149 -0
- package/dist/templates/TemplateEngine.js.map +1 -0
- package/dist/templates/base/CLAUDE.md.hbs +362 -0
- package/dist/templates/base/claude/agents/implementer.md +446 -0
- package/dist/templates/base/claude/agents/orchestrator.md +155 -0
- package/dist/templates/base/claude/agents/planner.md +348 -0
- package/dist/templates/base/claude/agents/researcher.md +390 -0
- package/dist/templates/base/claude/agents/reviewer.md +444 -0
- package/dist/templates/base/claude/agents/specifier.md +331 -0
- package/dist/templates/base/claude/agents/task-generator.md +382 -0
- package/dist/templates/base/claude/hooks/post-artifact-generate.sh +39 -0
- package/dist/templates/base/claude/hooks/post-implement-validate.sh +139 -0
- package/dist/templates/base/claude/hooks/post-phase-checkpoint.sh +322 -0
- package/dist/templates/base/claude/hooks/pre-agent-invoke.sh +34 -0
- package/dist/templates/base/claude/hooks/pre-phase-advance.sh +40 -0
- package/dist/templates/base/claude/hooks/track-agent-invocation.sh +230 -0
- package/dist/templates/base/claude/orchestrator-config.json +141 -0
- package/dist/templates/base/claude/settings.json +80 -0
- package/dist/templates/base/claude/skills/artifact-validator/SKILL.md +226 -0
- package/dist/templates/base/claude/skills/docs-guardian/SKILL.md +230 -0
- package/dist/templates/base/claude/skills/kb-lookup/SKILL.md +257 -0
- package/dist/templates/base/claude/skills/phase-gate-evaluator/SKILL.md +274 -0
- package/dist/templates/base/claude/skills/workflow-status/SKILL.md +322 -0
- package/dist/templates/base/docker-compose.yml.hbs +20 -0
- package/dist/templates/base/mcp.json.hbs +37 -0
- package/dist/templates/base/orchestrator/.state/.gitkeep +0 -0
- package/dist/templates/base/orchestrator-index.json.hbs +37 -0
- package/dist/templates/base/package.json.hbs +40 -0
- package/dist/templates/default/.orchestrator/orchestrator-index.json +19 -0
- package/dist/templates/default/README.md +58 -0
- package/dist/templates/default/docker-compose.yml +24 -0
- package/dist/templates/default/template.json +10 -0
- package/dist/templates/projects/api/files/index.ts.hbs +30 -0
- package/dist/templates/projects/api/files/server.ts.hbs +63 -0
- package/dist/templates/projects/api/files/tsconfig.json.hbs +27 -0
- package/dist/templates/projects/api/files/vitest.config.ts.hbs +28 -0
- package/dist/templates/projects/api/template.config.json +238 -0
- package/dist/templates/projects/api/template.config.ts +149 -0
- package/dist/templates/projects/cli/files/cli.ts.hbs +50 -0
- package/dist/templates/projects/cli/files/index.ts.hbs +8 -0
- package/dist/templates/projects/cli/files/tsconfig.json.hbs +27 -0
- package/dist/templates/projects/cli/files/vitest.config.ts.hbs +28 -0
- package/dist/templates/projects/cli/template.config.json +213 -0
- package/dist/templates/projects/cli/template.config.ts +126 -0
- package/dist/templates/projects/frontend/files/App.tsx.hbs +31 -0
- package/dist/templates/projects/frontend/files/index.html.hbs +13 -0
- package/dist/templates/projects/frontend/files/main.tsx.hbs +22 -0
- package/dist/templates/projects/frontend/files/tsconfig.json.hbs +34 -0
- package/dist/templates/projects/frontend/files/tsconfig.node.json.hbs +10 -0
- package/dist/templates/projects/frontend/files/vite.config.ts.hbs +19 -0
- package/dist/templates/projects/frontend/files/vitest.config.ts.hbs +36 -0
- package/dist/templates/projects/frontend/template.config.json +241 -0
- package/dist/templates/projects/frontend/template.config.ts +153 -0
- package/dist/templates/projects/minimal/files/claude-settings.json.hbs +20 -0
- package/dist/templates/projects/minimal/files/env.example.hbs +17 -0
- package/dist/templates/projects/minimal/files/gitignore.hbs +41 -0
- package/dist/templates/projects/minimal/files/index.ts.hbs +13 -0
- package/dist/templates/projects/minimal/files/tsconfig.json.hbs +27 -0
- package/dist/templates/projects/minimal/template.config.json +185 -0
- package/dist/templates/projects/minimal/template.config.ts +88 -0
- package/package.json +37 -0
- package/templates/.gitkeep +0 -0
- package/templates/base/CLAUDE.md.hbs +362 -0
- package/templates/base/claude/agents/implementer.md +446 -0
- package/templates/base/claude/agents/orchestrator.md +155 -0
- package/templates/base/claude/agents/planner.md +348 -0
- package/templates/base/claude/agents/researcher.md +390 -0
- package/templates/base/claude/agents/reviewer.md +444 -0
- package/templates/base/claude/agents/specifier.md +331 -0
- package/templates/base/claude/agents/task-generator.md +382 -0
- package/templates/base/claude/hooks/post-artifact-generate.sh +39 -0
- package/templates/base/claude/hooks/post-implement-validate.sh +139 -0
- package/templates/base/claude/hooks/post-phase-checkpoint.sh +322 -0
- package/templates/base/claude/hooks/pre-agent-invoke.sh +34 -0
- package/templates/base/claude/hooks/pre-phase-advance.sh +40 -0
- package/templates/base/claude/hooks/track-agent-invocation.sh +230 -0
- package/templates/base/claude/orchestrator-config.json +141 -0
- package/templates/base/claude/settings.json +80 -0
- package/templates/base/claude/skills/artifact-validator/SKILL.md +226 -0
- package/templates/base/claude/skills/docs-guardian/SKILL.md +230 -0
- package/templates/base/claude/skills/kb-lookup/SKILL.md +257 -0
- package/templates/base/claude/skills/phase-gate-evaluator/SKILL.md +274 -0
- package/templates/base/claude/skills/workflow-status/SKILL.md +322 -0
- package/templates/base/docker-compose.yml.hbs +20 -0
- package/templates/base/mcp.json.hbs +37 -0
- package/templates/base/orchestrator/.state/.gitkeep +0 -0
- package/templates/base/orchestrator-index.json.hbs +37 -0
- package/templates/base/package.json.hbs +40 -0
- package/templates/default/.orchestrator/orchestrator-index.json +19 -0
- package/templates/default/README.md +58 -0
- package/templates/default/docker-compose.yml +24 -0
- package/templates/default/template.json +10 -0
- package/templates/projects/api/files/index.ts.hbs +30 -0
- package/templates/projects/api/files/server.ts.hbs +63 -0
- package/templates/projects/api/files/tsconfig.json.hbs +27 -0
- package/templates/projects/api/files/vitest.config.ts.hbs +28 -0
- package/templates/projects/api/template.config.json +238 -0
- package/templates/projects/api/template.config.ts +149 -0
- package/templates/projects/cli/files/cli.ts.hbs +50 -0
- package/templates/projects/cli/files/index.ts.hbs +8 -0
- package/templates/projects/cli/files/tsconfig.json.hbs +27 -0
- package/templates/projects/cli/files/vitest.config.ts.hbs +28 -0
- package/templates/projects/cli/template.config.json +213 -0
- package/templates/projects/cli/template.config.ts +126 -0
- package/templates/projects/frontend/files/App.tsx.hbs +31 -0
- package/templates/projects/frontend/files/index.html.hbs +13 -0
- package/templates/projects/frontend/files/main.tsx.hbs +22 -0
- package/templates/projects/frontend/files/tsconfig.json.hbs +34 -0
- package/templates/projects/frontend/files/tsconfig.node.json.hbs +10 -0
- package/templates/projects/frontend/files/vite.config.ts.hbs +19 -0
- package/templates/projects/frontend/files/vitest.config.ts.hbs +36 -0
- package/templates/projects/frontend/template.config.json +241 -0
- package/templates/projects/frontend/template.config.ts +153 -0
- package/templates/projects/minimal/files/claude-settings.json.hbs +20 -0
- package/templates/projects/minimal/files/env.example.hbs +17 -0
- package/templates/projects/minimal/files/gitignore.hbs +41 -0
- package/templates/projects/minimal/files/index.ts.hbs +13 -0
- package/templates/projects/minimal/files/tsconfig.json.hbs +27 -0
- package/templates/projects/minimal/template.config.json +185 -0
- package/templates/projects/minimal/template.config.ts +88 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Engine
|
|
3
|
+
*
|
|
4
|
+
* Renders templates using Handlebars and manages bundled templates.
|
|
5
|
+
* Used by offline commands (init, templates, migrate).
|
|
6
|
+
*
|
|
7
|
+
* @module templates
|
|
8
|
+
*/
|
|
9
|
+
import Handlebars from 'handlebars';
|
|
10
|
+
import { readFileSync, readdirSync, statSync, existsSync } from 'fs';
|
|
11
|
+
import { join, resolve, dirname } from 'path';
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
/**
|
|
14
|
+
* Template Engine
|
|
15
|
+
*
|
|
16
|
+
* Manages bundled templates and renders them with Handlebars.
|
|
17
|
+
*/
|
|
18
|
+
export class TemplateEngine {
|
|
19
|
+
templatesPath;
|
|
20
|
+
templates;
|
|
21
|
+
/**
|
|
22
|
+
* Create template engine
|
|
23
|
+
*
|
|
24
|
+
* @param templatesPath - Path to templates directory (default: bundled templates)
|
|
25
|
+
*/
|
|
26
|
+
constructor(templatesPath) {
|
|
27
|
+
this.templatesPath = templatesPath ?? this.resolveTemplatesPath();
|
|
28
|
+
this.templates = new Map();
|
|
29
|
+
this.loadTemplates();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* List available templates
|
|
33
|
+
*
|
|
34
|
+
* @returns Array of template metadata
|
|
35
|
+
*/
|
|
36
|
+
listTemplates() {
|
|
37
|
+
return Array.from(this.templates.values());
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get template metadata
|
|
41
|
+
*
|
|
42
|
+
* @param name - Template name
|
|
43
|
+
* @returns Template metadata or undefined
|
|
44
|
+
*/
|
|
45
|
+
getTemplate(name) {
|
|
46
|
+
return this.templates.get(name);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Render template file
|
|
50
|
+
*
|
|
51
|
+
* @param templateName - Template name
|
|
52
|
+
* @param fileName - File name within template
|
|
53
|
+
* @param context - Rendering context
|
|
54
|
+
* @returns Rendered content
|
|
55
|
+
*/
|
|
56
|
+
renderFile(templateName, fileName, context) {
|
|
57
|
+
const template = this.templates.get(templateName);
|
|
58
|
+
if (!template) {
|
|
59
|
+
throw new Error(`Template not found: ${templateName}`);
|
|
60
|
+
}
|
|
61
|
+
if (!template.files.includes(fileName)) {
|
|
62
|
+
throw new Error(`File not found in template ${templateName}: ${fileName}`);
|
|
63
|
+
}
|
|
64
|
+
const filePath = join(this.templatesPath, templateName, fileName);
|
|
65
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
66
|
+
const compiledTemplate = Handlebars.compile(content);
|
|
67
|
+
return compiledTemplate(context);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Check if template exists
|
|
71
|
+
*
|
|
72
|
+
* @param name - Template name
|
|
73
|
+
* @returns True if template exists
|
|
74
|
+
*/
|
|
75
|
+
hasTemplate(name) {
|
|
76
|
+
return this.templates.has(name);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Resolve templates path
|
|
80
|
+
*
|
|
81
|
+
* Finds templates directory relative to this module.
|
|
82
|
+
* In production (bundled), templates are in dist/templates.
|
|
83
|
+
* In development, templates are in packages/cli/templates.
|
|
84
|
+
*/
|
|
85
|
+
resolveTemplatesPath() {
|
|
86
|
+
// Get __dirname equivalent in ES modules
|
|
87
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
88
|
+
const __dirname = dirname(__filename);
|
|
89
|
+
// Try production path (dist/templates)
|
|
90
|
+
const prodPath = resolve(__dirname, '../../templates');
|
|
91
|
+
if (existsSync(prodPath)) {
|
|
92
|
+
return prodPath;
|
|
93
|
+
}
|
|
94
|
+
// Try development path
|
|
95
|
+
const devPath = resolve(__dirname, '../../../templates');
|
|
96
|
+
if (existsSync(devPath)) {
|
|
97
|
+
return devPath;
|
|
98
|
+
}
|
|
99
|
+
throw new Error('Templates directory not found');
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Load all templates from templates directory
|
|
103
|
+
*/
|
|
104
|
+
loadTemplates() {
|
|
105
|
+
if (!existsSync(this.templatesPath)) {
|
|
106
|
+
return; // No templates available
|
|
107
|
+
}
|
|
108
|
+
const entries = readdirSync(this.templatesPath);
|
|
109
|
+
for (const entry of entries) {
|
|
110
|
+
const entryPath = join(this.templatesPath, entry);
|
|
111
|
+
const stat = statSync(entryPath);
|
|
112
|
+
if (stat.isDirectory()) {
|
|
113
|
+
const metadata = this.loadTemplateMetadata(entry);
|
|
114
|
+
if (metadata) {
|
|
115
|
+
this.templates.set(entry, metadata);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Load template metadata
|
|
122
|
+
*/
|
|
123
|
+
loadTemplateMetadata(templateName) {
|
|
124
|
+
const templatePath = join(this.templatesPath, templateName);
|
|
125
|
+
const metadataPath = join(templatePath, 'template.json');
|
|
126
|
+
if (!existsSync(metadataPath)) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
const content = readFileSync(metadataPath, 'utf-8');
|
|
131
|
+
const metadata = JSON.parse(content);
|
|
132
|
+
// Validate required fields
|
|
133
|
+
if (!metadata.name || !metadata.description || !metadata.version) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
return metadata;
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Create default template engine
|
|
145
|
+
*/
|
|
146
|
+
export function createTemplateEngine() {
|
|
147
|
+
return new TemplateEngine();
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=TemplateEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateEngine.js","sourceRoot":"","sources":["../../src/templates/TemplateEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,E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AC;gBAClD,IAAI,QAAQ,EAAE,CAAC;oBACb,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;gBACtC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACK,oBAAoB,CAAC,YAAoB;QAC/C,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;QAC5D,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;QAEzD,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAqB,CAAC;YAEzD,2BAA2B;YAC3B,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACjE,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,IAAI,cAAc,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This project uses the **Orchestrator System** for autonomous workflow management. When handling feature requests, bug fixes, or refactoring tasks, you MUST use the orchestrator workflow instead of implementing directly.
|
|
6
|
+
|
|
7
|
+
## Critical Rule
|
|
8
|
+
|
|
9
|
+
**NEVER implement features directly.** Always use the orchestrator workflow:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
User Request → Detect Workflow → Research (if needed) → SPECIFY → PLAN → TASKS → Implement
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## How to Start a Workflow
|
|
16
|
+
|
|
17
|
+
When a user requests a new feature, bug fix, or refactoring:
|
|
18
|
+
|
|
19
|
+
### 1. Detect Workflow Type
|
|
20
|
+
|
|
21
|
+
Use the MCP tool to detect the workflow type:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
mcp__orchestrator-tools__detectWorkflow({ prompt: "user request here" })
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Workflow types:
|
|
28
|
+
- `feature_development` - New features, new functionality
|
|
29
|
+
- `bug_fix` - Bug fixes, error corrections
|
|
30
|
+
- `refactoring` - Code refactoring, improvements
|
|
31
|
+
- `emergency_debug` - Urgent debugging
|
|
32
|
+
|
|
33
|
+
### 2. Start Workflow and Get Next Step
|
|
34
|
+
|
|
35
|
+
**MANDATORY:** After detecting workflow type, call `startWorkflow` to create the workflow:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
mcp__orchestrator-tools__startWorkflow({ workflowType: "feature-development", prompt: "user request here" })
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This returns a deterministic `nextStep` instruction:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"success": true,
|
|
46
|
+
"workflowId": "wf-123",
|
|
47
|
+
"nextStep": {
|
|
48
|
+
"action": "invoke_agent",
|
|
49
|
+
"subagent_type": "orchestrator",
|
|
50
|
+
"prompt": "Start workflow feature-development (ID: wf-123) for user request: ..."
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 3. Execute nextStep (Invoke Orchestrator Agent)
|
|
56
|
+
|
|
57
|
+
**IMMEDIATELY** follow the `nextStep` instruction by invoking the orchestrator agent via Task tool:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
Use the Task tool with subagent_type from nextStep.subagent_type
|
|
61
|
+
Prompt: nextStep.prompt
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The orchestrator agent will:
|
|
65
|
+
1. Set pending actions for specialized agents
|
|
66
|
+
2. Return control to CLI for Ping-Pong pattern
|
|
67
|
+
3. CLI invokes agents via Task tool as directed by getNextAction()
|
|
68
|
+
4. Process continues until workflow completes
|
|
69
|
+
|
|
70
|
+
## Available MCP Tools
|
|
71
|
+
|
|
72
|
+
### orchestrator-tools
|
|
73
|
+
- `detectWorkflow` - Detect workflow type from user prompt
|
|
74
|
+
- `startWorkflow` - **Create workflow and get deterministic nextStep instruction** (MANDATORY after detectWorkflow)
|
|
75
|
+
- `advancePhase` - Advance to the next workflow phase
|
|
76
|
+
- `evaluateGate` - Evaluate if a phase gate passes
|
|
77
|
+
- `validateArtifact` - Validate artifact against schema
|
|
78
|
+
- `createCheckpoint` - Create a git checkpoint
|
|
79
|
+
- `getStatus` - Get current workflow status
|
|
80
|
+
- `getWorkflows` - List workflows with phase configs (including `requiresApproval`)
|
|
81
|
+
- `getNextAction` - Get the next pending action (Ping-Pong pattern)
|
|
82
|
+
|
|
83
|
+
### knowledge-base
|
|
84
|
+
- `search` - Search the knowledge base
|
|
85
|
+
- `getDocument` - Get a specific document
|
|
86
|
+
- `getConstitution` - Get the project constitution
|
|
87
|
+
- `listByTier` - List documents by tier
|
|
88
|
+
- `listByCategory` - List documents by category
|
|
89
|
+
|
|
90
|
+
## Auto-Advance Behavior (requiresApproval)
|
|
91
|
+
|
|
92
|
+
**CRITICAL**: Each workflow phase has a `requiresApproval` configuration.
|
|
93
|
+
|
|
94
|
+
### How It Works
|
|
95
|
+
|
|
96
|
+
1. **Load workflow config** at start using `getWorkflows`:
|
|
97
|
+
```
|
|
98
|
+
mcp__orchestrator-tools__getWorkflows()
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
2. **Check each phase's `requiresApproval`**:
|
|
102
|
+
- `requiresApproval: false` → **AUTO-ADVANCE** after gate passes (no user interaction)
|
|
103
|
+
- `requiresApproval: true` → **PAUSE** and ask user for approval
|
|
104
|
+
|
|
105
|
+
### Default Configuration (feature-development)
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
SPECIFY → requiresApproval: false → auto-advance
|
|
109
|
+
PLAN → requiresApproval: false → auto-advance
|
|
110
|
+
TASKS → requiresApproval: false → auto-advance
|
|
111
|
+
IMPLEMENT → requiresApproval: true → PAUSE HERE
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Expected Behavior
|
|
115
|
+
|
|
116
|
+
- **DO NOT ask user** between SPECIFY → PLAN → TASKS phases
|
|
117
|
+
- **Run these phases sequentially** invoking each agent automatically
|
|
118
|
+
- **ONLY pause** before IMPLEMENT phase (or phases with `requiresApproval: true`)
|
|
119
|
+
- This reduces unnecessary interactions and speeds up the workflow
|
|
120
|
+
|
|
121
|
+
### Example Flow
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
User: "Create a calculator function"
|
|
125
|
+
|
|
126
|
+
Claude:
|
|
127
|
+
1. detectWorkflow({ prompt: "Create a calculator function" }) → feature-development
|
|
128
|
+
2. startWorkflow({ workflowType: "feature-development", prompt: "..." }) → { nextStep: {...} }
|
|
129
|
+
3. Execute nextStep → Invoke orchestrator agent via Task tool
|
|
130
|
+
4. getNextAction() → { agent: "specifier", status: "awaiting_agent" }
|
|
131
|
+
5. Invoke specifier via Task tool → spec.md created
|
|
132
|
+
6. getNextAction() → { agent: "planner", status: "awaiting_agent" }
|
|
133
|
+
7. Invoke planner via Task tool → plan.md created
|
|
134
|
+
8. getNextAction() → { agent: "task-generator", status: "awaiting_agent" }
|
|
135
|
+
9. Invoke task-generator via Task tool → tasks.md created
|
|
136
|
+
10. getNextAction() → { status: "awaiting_approval" }
|
|
137
|
+
11. Ask user: "Artifacts ready. Approve implementation?"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Workflow Phases
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
RESEARCH (optional)
|
|
144
|
+
↓
|
|
145
|
+
SPECIFY
|
|
146
|
+
↓
|
|
147
|
+
PLAN
|
|
148
|
+
↓
|
|
149
|
+
TASKS
|
|
150
|
+
↓
|
|
151
|
+
[HUMAN APPROVAL REQUIRED]
|
|
152
|
+
↓
|
|
153
|
+
IMPLEMENT
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Each phase produces artifacts in `.orchestrator/artifacts/`:
|
|
157
|
+
- `research/` - Research context documents
|
|
158
|
+
- `specify/` - Specifications (spec.md)
|
|
159
|
+
- `plan/` - Technical plans (plan.md)
|
|
160
|
+
- `tasks/` - Task backlogs (tasks.md)
|
|
161
|
+
- `implement/` - Implementation reports
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Workflow Execution Pattern (Ping-Pong Híbrido)
|
|
166
|
+
|
|
167
|
+
### Critical Rule: Always Check for Pending Actions
|
|
168
|
+
|
|
169
|
+
**MANDATORY:** After EVERY Task tool invocation that involves workflow orchestration, you MUST:
|
|
170
|
+
|
|
171
|
+
1. **Call `mcp__orchestrator-tools__getNextAction()`**
|
|
172
|
+
2. **Analyze the response and take appropriate action**
|
|
173
|
+
|
|
174
|
+
### Status → Action Mapping
|
|
175
|
+
|
|
176
|
+
| Status | Your Action |
|
|
177
|
+
|--------|-------------|
|
|
178
|
+
| `awaiting_agent` | **Immediately** invoke the specified agent via Task tool |
|
|
179
|
+
| `awaiting_approval` | **Ask user** for approval, then call `approveAction()` |
|
|
180
|
+
| `running` | Agent is currently executing, do nothing |
|
|
181
|
+
| No pending action | Workflow is complete or paused |
|
|
182
|
+
|
|
183
|
+
### Workflow Execution Loop
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
// MANDATORY PATTERN for workflow execution
|
|
187
|
+
|
|
188
|
+
// 1. Detect workflow type
|
|
189
|
+
const detection = await detectWorkflow({ prompt: "Create authentication API" });
|
|
190
|
+
|
|
191
|
+
// 2. Start workflow and get nextStep (DETERMINISTIC)
|
|
192
|
+
const startResult = await startWorkflow({
|
|
193
|
+
workflowType: detection.workflowType,
|
|
194
|
+
prompt: "Create authentication API"
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// 3. Execute nextStep - invoke orchestrator agent
|
|
198
|
+
await invokeTool("Task", {
|
|
199
|
+
subagent_type: startResult.nextStep.subagent_type, // "orchestrator"
|
|
200
|
+
prompt: startResult.nextStep.prompt
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// 4. Check for pending actions (Ping-Pong loop)
|
|
204
|
+
const action = await getNextAction();
|
|
205
|
+
|
|
206
|
+
// 5. Handle the action
|
|
207
|
+
if (action.hasAction && action.pendingAction.status === "awaiting_agent") {
|
|
208
|
+
// Immediately invoke the specified agent
|
|
209
|
+
await invokeTool("Task", {
|
|
210
|
+
subagent_type: action.pendingAction.agent,
|
|
211
|
+
prompt: action.pendingAction.prompt
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// 6. REPEAT: Check for next action after agent completes
|
|
215
|
+
const nextAction = await getNextAction();
|
|
216
|
+
// ... continue loop
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (action.hasAction && action.pendingAction.status === "awaiting_approval") {
|
|
220
|
+
// Inform user and wait for approval
|
|
221
|
+
console.log("⚠️ Workflow requires approval before continuing to IMPLEMENT phase.");
|
|
222
|
+
console.log("Review artifacts and type 'yes' to proceed.");
|
|
223
|
+
|
|
224
|
+
// After user approves:
|
|
225
|
+
await approveAction({ workflowId: action.workflowId });
|
|
226
|
+
|
|
227
|
+
// Then check for next action again
|
|
228
|
+
const nextAction = await getNextAction();
|
|
229
|
+
// ...
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### What NOT to Do
|
|
234
|
+
|
|
235
|
+
- ❌ **NEVER** skip `startWorkflow` after `detectWorkflow` - it creates the workflow and returns deterministic `nextStep`
|
|
236
|
+
- ❌ **NEVER** ignore `nextStep` from `startWorkflow` - it tells you exactly which agent to invoke
|
|
237
|
+
- ❌ **NEVER** ignore `getNextAction()` after Task tool invocation
|
|
238
|
+
- ❌ **NEVER** decide which agent to invoke without checking `pendingAction`
|
|
239
|
+
- ❌ **NEVER** skip to IMPLEMENT phase without user approval
|
|
240
|
+
- ❌ **NEVER** execute multiple phases in a single agent invocation
|
|
241
|
+
- ❌ **NEVER** use Write/Edit tools to create artifacts during orchestration (let specialized agents do it)
|
|
242
|
+
- ❌ **NEVER** invoke agents out of order defined by `pendingAction`
|
|
243
|
+
|
|
244
|
+
### Why This Pattern?
|
|
245
|
+
|
|
246
|
+
**Problem (LIM-001):** Context window bloat when orchestrator executes all phases internally in one invocation.
|
|
247
|
+
|
|
248
|
+
**Solution (Ping-Pong Híbrido):** Orchestrator acts as **dispatcher**, creating `pendingActions` that guide the CLI to invoke specialized agents in separate, isolated invocations.
|
|
249
|
+
|
|
250
|
+
**Benefits:**
|
|
251
|
+
- Each agent invocation has isolated context (< 12k tokens)
|
|
252
|
+
- Total token usage reduced by 40%+
|
|
253
|
+
- No hallucination from massive context
|
|
254
|
+
- Real agent metrics (not simulated)
|
|
255
|
+
- Workflow resumable after crashes (pendingAction persists)
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## MANDATORY: IMPLEMENT Phase Delegation
|
|
260
|
+
|
|
261
|
+
> **WARNING**
|
|
262
|
+
>
|
|
263
|
+
> The IMPLEMENT phase REQUIRES delegation to the implementer subagent.
|
|
264
|
+
> Direct implementation is FORBIDDEN and will break workflow governance.
|
|
265
|
+
|
|
266
|
+
### Trigger Phrases
|
|
267
|
+
|
|
268
|
+
When user approves implementation with ANY of these phrases:
|
|
269
|
+
|
|
270
|
+
**English:**
|
|
271
|
+
- "yes", "yes, implement", "proceed", "go ahead", "continue"
|
|
272
|
+
- "start implementation", "implement it", "do it"
|
|
273
|
+
|
|
274
|
+
**Portuguese:**
|
|
275
|
+
- "sim", "prossiga", "continue", "pode implementar"
|
|
276
|
+
- "manda ver", "vai la", "implementa"
|
|
277
|
+
|
|
278
|
+
### Required Actions (IN ORDER)
|
|
279
|
+
|
|
280
|
+
1. **ANNOUNCE DELEGATION:**
|
|
281
|
+
```
|
|
282
|
+
I will now delegate to the implementer agent to execute the tasks.
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
2. **ADVANCE PHASE:**
|
|
286
|
+
```
|
|
287
|
+
mcp__orchestrator-tools__advancePhase({ workflowId: "current-workflow-id" })
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
3. **INVOKE IMPLEMENTER (REQUIRED):**
|
|
291
|
+
```
|
|
292
|
+
Use the Task tool with subagent_type="implementer"
|
|
293
|
+
|
|
294
|
+
Prompt:
|
|
295
|
+
Execute all tasks from .orchestrator/artifacts/tasks/tasks.md
|
|
296
|
+
|
|
297
|
+
Context:
|
|
298
|
+
- Specification: .orchestrator/artifacts/specify/spec.md
|
|
299
|
+
- Plan: .orchestrator/artifacts/plan/plan.md
|
|
300
|
+
- Tasks: .orchestrator/artifacts/tasks/tasks.md
|
|
301
|
+
|
|
302
|
+
Requirements:
|
|
303
|
+
- Follow TDD (write tests BEFORE implementation)
|
|
304
|
+
- Maintain 80% minimum coverage
|
|
305
|
+
- Update orchestrator-index.json after EACH task
|
|
306
|
+
- Create checkpoint after every 3-5 tasks
|
|
307
|
+
- Generate implementation-report.md at the end
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### FORBIDDEN Actions
|
|
311
|
+
|
|
312
|
+
- Using Edit/Write tools directly for code implementation
|
|
313
|
+
- Skipping Task tool invocation
|
|
314
|
+
- Writing production code without implementer agent
|
|
315
|
+
- Forgetting to update orchestrator-index.json
|
|
316
|
+
|
|
317
|
+
### Self-Verification Checklist
|
|
318
|
+
|
|
319
|
+
Before proceeding, verify:
|
|
320
|
+
- [ ] Did I announce delegation to the user?
|
|
321
|
+
- [ ] Did I call advancePhase via MCP?
|
|
322
|
+
- [ ] Did I use Task tool with subagent_type="implementer"?
|
|
323
|
+
- [ ] Is the implementer prompt complete with all context?
|
|
324
|
+
|
|
325
|
+
If ANY answer is NO -> STOP and correct before continuing.
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Quality Rules
|
|
330
|
+
|
|
331
|
+
- **TDD**: Write tests BEFORE implementation
|
|
332
|
+
- **Coverage**: Minimum 80% test coverage
|
|
333
|
+
- **SOLID**: Follow SOLID principles
|
|
334
|
+
- **Clean Architecture**: Dependencies point inward
|
|
335
|
+
- **TypeScript Strict**: `strict: true` required
|
|
336
|
+
|
|
337
|
+
## Project Structure
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
.orchestrator/
|
|
341
|
+
├── artifacts/ # Generated artifacts by phase
|
|
342
|
+
├── memory/
|
|
343
|
+
│ └── knowledge-base/
|
|
344
|
+
│ ├── core/ # CONSTITUTION.md (immutable rules)
|
|
345
|
+
│ └── contextual/ # Project context
|
|
346
|
+
├── checkpoints/ # Checkpoint metadata
|
|
347
|
+
└── orchestrator-index.json # Workflow state
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Important Notes
|
|
351
|
+
|
|
352
|
+
1. **Always start with workflow detection** - Don't skip this step
|
|
353
|
+
2. **Let agents do their work** - Don't bypass the workflow
|
|
354
|
+
3. **Validate artifacts** - Use the artifact-validator skill
|
|
355
|
+
4. **Check gates** - Use phase-gate-evaluator before advancing
|
|
356
|
+
5. **Create checkpoints** - After each validated artifact
|
|
357
|
+
6. **Consult CONSTITUTION** - For project rules and constraints
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
*This project was initialized with the Orchestrator CLI.*
|
|
362
|
+
*Generated: {{currentDate}}*
|