claude-orchestration 1.0.4 → 1.0.5

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/bin/cli.js CHANGED
@@ -3,39 +3,18 @@
3
3
  import { promises as fs } from "node:fs";
4
4
  import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
+ import { Command } from "commander";
7
+ import { checkbox, confirm } from "@inquirer/prompts";
6
8
 
7
9
  const __filename = fileURLToPath(import.meta.url);
8
10
  const __dirname = path.dirname(__filename);
9
11
 
10
- if (process.argv.includes("--help") || process.argv.includes("-h")) {
11
- console.log(`
12
- Usage: npx claude-orchestration
13
-
14
- Scaffolds Claude orchestration workflows into your project.
15
-
16
- Creates a .claude/ directory with workflow templates for:
17
- - feature.md Building new functionality
18
- - bugfix.md Diagnosing and fixing bugs
19
- - refactor.md Improving code structure
20
- - pr.md Creating pull requests
21
- - docs.md Writing documentation
22
-
23
- Options:
24
- -h, --help Show this help message
25
- -v, --version Show version number
26
- `);
27
- process.exit(0);
28
- }
29
-
30
- if (process.argv.includes("--version") || process.argv.includes("-v")) {
31
- const pkg = JSON.parse(
32
- await fs.readFile(path.join(__dirname, "..", "package.json"), "utf-8")
33
- );
34
- console.log(pkg.version);
35
- process.exit(0);
36
- }
12
+ const pkg = JSON.parse(
13
+ await fs.readFile(path.join(__dirname, "..", "package.json"), "utf-8")
14
+ );
37
15
 
38
16
  const SOURCE_DIR = path.join(__dirname, "..", "templates", "claude");
17
+ const WORKFLOWS_DIR = path.join(SOURCE_DIR, "workflows");
39
18
  const DEST_NAME = ".claude";
40
19
 
41
20
  const ORCHESTRATION_INSTRUCTION = `
@@ -45,6 +24,38 @@ const ORCHESTRATION_INSTRUCTION = `
45
24
  For complex tasks, refer to .claude/orchestration.md for available workflows.
46
25
  `;
47
26
 
27
+ const ROOT_WORKFLOWS = [
28
+ {
29
+ name: "todo.md",
30
+ description: "Multi-step task management (uses 15-20% more tokens)",
31
+ checked: false,
32
+ },
33
+ ];
34
+
35
+ async function getWorkflowFolders() {
36
+ const entries = await fs.readdir(WORKFLOWS_DIR, { withFileTypes: true });
37
+ return entries
38
+ .filter((entry) => entry.isDirectory())
39
+ .map((entry) => entry.name);
40
+ }
41
+
42
+ async function getWorkflowFiles(folder) {
43
+ const folderPath = path.join(WORKFLOWS_DIR, folder);
44
+ const entries = await fs.readdir(folderPath, { withFileTypes: true });
45
+ return entries
46
+ .filter((entry) => entry.isFile() && entry.name.endsWith(".md"))
47
+ .map((entry) => entry.name);
48
+ }
49
+
50
+ function formatFolderName(folder) {
51
+ return folder.charAt(0).toUpperCase() + folder.slice(1);
52
+ }
53
+
54
+ function formatWorkflowName(filename) {
55
+ const name = filename.replace(".md", "");
56
+ return name.charAt(0).toUpperCase() + name.slice(1);
57
+ }
58
+
48
59
  async function findClaudeMdFiles(projectDir) {
49
60
  const entries = await fs.readdir(projectDir, { withFileTypes: true });
50
61
  return entries
@@ -76,30 +87,136 @@ async function updateClaudeMd(projectDir) {
76
87
  }
77
88
  }
78
89
 
79
- async function copyDir(src, dest) {
80
- await fs.mkdir(dest, { recursive: true });
81
- const entries = await fs.readdir(src, { withFileTypes: true });
90
+ async function copyFile(src, dest) {
91
+ await fs.mkdir(path.dirname(dest), { recursive: true });
92
+ await fs.copyFile(src, dest);
93
+ console.log(` Created: ${path.relative(process.cwd(), dest)}`);
94
+ }
95
+
96
+ async function runInteractiveSetup() {
97
+ console.log("Claude Orchestration Setup\n");
98
+
99
+ const folders = await getWorkflowFolders();
100
+ const selectedFiles = [];
101
+
102
+ // Step 1: Select workflow folders
103
+ const selectedFolders = await checkbox({
104
+ message: "Select workflow categories:",
105
+ choices: folders.map((folder) => ({
106
+ name: formatFolderName(folder),
107
+ value: folder,
108
+ checked: true,
109
+ })),
110
+ });
111
+
112
+ // Step 2: For each selected folder, select individual workflows
113
+ for (const folder of selectedFolders) {
114
+ const files = await getWorkflowFiles(folder);
115
+
116
+ const selectedWorkflows = await checkbox({
117
+ message: `Select ${formatFolderName(folder)} workflows:`,
118
+ choices: files.map((file) => ({
119
+ name: formatWorkflowName(file),
120
+ value: file,
121
+ checked: true,
122
+ })),
123
+ });
124
+
125
+ for (const file of selectedWorkflows) {
126
+ selectedFiles.push({ folder, file });
127
+ }
128
+ }
129
+
130
+ // Step 3: Select root-level workflows (like todo.md)
131
+ if (ROOT_WORKFLOWS.length > 0) {
132
+ const selectedRootWorkflows = await checkbox({
133
+ message: "Select additional workflows:",
134
+ choices: ROOT_WORKFLOWS.map((w) => ({
135
+ name: `${w.name} - ${w.description}`,
136
+ value: w.name,
137
+ checked: w.checked,
138
+ })),
139
+ });
140
+
141
+ for (const file of selectedRootWorkflows) {
142
+ selectedFiles.push({ folder: null, file });
143
+ }
144
+ }
145
+
146
+ if (selectedFiles.length === 0) {
147
+ const continueWithOrchestration = await confirm({
148
+ message: "No workflows selected. Install only the orchestration guide?",
149
+ default: true,
150
+ });
151
+
152
+ if (!continueWithOrchestration) {
153
+ console.log("Setup cancelled.");
154
+ process.exit(0);
155
+ }
156
+ }
157
+
158
+ return selectedFiles;
159
+ }
160
+
161
+ async function getAllWorkflows() {
162
+ const folders = await getWorkflowFolders();
163
+ const allFiles = [];
164
+
165
+ for (const folder of folders) {
166
+ const files = await getWorkflowFiles(folder);
167
+ for (const file of files) {
168
+ allFiles.push({ folder, file });
169
+ }
170
+ }
82
171
 
83
- for (const entry of entries) {
84
- const srcPath = path.join(src, entry.name);
85
- const destPath = path.join(dest, entry.name);
172
+ for (const w of ROOT_WORKFLOWS) {
173
+ allFiles.push({ folder: null, file: w.name });
174
+ }
175
+
176
+ return allFiles;
177
+ }
86
178
 
87
- if (entry.isDirectory()) {
88
- await copyDir(srcPath, destPath);
179
+ async function copySelectedWorkflows(selectedFiles, targetDir) {
180
+ const workflowsDir = path.join(targetDir, "workflows");
181
+
182
+ for (const { folder, file } of selectedFiles) {
183
+ if (folder) {
184
+ const src = path.join(WORKFLOWS_DIR, folder, file);
185
+ const dest = path.join(workflowsDir, folder, file);
186
+ await copyFile(src, dest);
89
187
  } else {
90
- await fs.copyFile(srcPath, destPath);
91
- console.log(` Created: ${path.relative(process.cwd(), destPath)}`);
188
+ const src = path.join(WORKFLOWS_DIR, file);
189
+ const dest = path.join(workflowsDir, file);
190
+ await copyFile(src, dest);
92
191
  }
93
192
  }
94
193
  }
95
194
 
96
- async function main() {
195
+ async function main(options) {
97
196
  const targetDir = path.join(process.cwd(), DEST_NAME);
98
197
 
99
- console.log("Claude Orchestration Setup\n");
100
-
101
198
  try {
102
- await copyDir(SOURCE_DIR, targetDir);
199
+ let selectedFiles;
200
+
201
+ if (options.all) {
202
+ selectedFiles = await getAllWorkflows();
203
+ console.log("Claude Orchestration Setup\n");
204
+ console.log("Installing all workflows...\n");
205
+ } else {
206
+ selectedFiles = await runInteractiveSetup();
207
+ console.log();
208
+ }
209
+
210
+ await fs.mkdir(targetDir, { recursive: true });
211
+
212
+ const orchestrationSrc = path.join(SOURCE_DIR, "orchestration.md");
213
+ const orchestrationDest = path.join(targetDir, "orchestration.md");
214
+ await copyFile(orchestrationSrc, orchestrationDest);
215
+
216
+ if (selectedFiles.length > 0) {
217
+ await copySelectedWorkflows(selectedFiles, targetDir);
218
+ }
219
+
103
220
  await updateClaudeMd(process.cwd());
104
221
  console.log("\nDone! Orchestration files have been added to .claude/");
105
222
  } catch (error) {
@@ -108,4 +225,13 @@ async function main() {
108
225
  }
109
226
  }
110
227
 
111
- main();
228
+ const program = new Command();
229
+
230
+ program
231
+ .name("claude-orchestration")
232
+ .description("Scaffolds Claude orchestration workflows into your project")
233
+ .version(pkg.version)
234
+ .option("-a, --all", "Install all workflows without prompting")
235
+ .action((options) => main(options));
236
+
237
+ program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-orchestration",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "CLI tool to scaffold Claude orchestration workflows into your project",
5
5
  "bin": {
6
6
  "claude-orchestration": "bin/cli.js"
@@ -26,5 +26,9 @@
26
26
  ],
27
27
  "engines": {
28
28
  "node": ">=18.0.0"
29
+ },
30
+ "dependencies": {
31
+ "commander": "^13.0.0",
32
+ "@inquirer/prompts": "^7.0.0"
29
33
  }
30
34
  }
@@ -1,41 +1,101 @@
1
- # Orchestration
1
+ # Orchestration Protocol
2
2
 
3
- ## Technology Detection
3
+ **MANDATORY: Process this file BEFORE any tool usage.**
4
4
 
5
- Before selecting a workflow, determine the technology stack:
5
+ ---
6
6
 
7
- **React Project Indicators:**
8
- - Files with `.jsx` or `.tsx` extensions
9
- - Imports from `react`, `react-dom`, or `@react-*` packages
10
- - React hooks (`useState`, `useEffect`, `useContext`, etc.)
11
- - JSX syntax (`<Component />`, `<div className=...>`)
12
- - `package.json` with `react` as a dependency
13
- - Frameworks: Next.js, Remix, Gatsby, Create React App
7
+ ## 1. CLASSIFY TASK
14
8
 
15
- If React indicators are present → use `workflows/react/` directory
9
+ ### STOP CHECKPOINT #1
16
10
 
17
- ## Available Workflows
11
+ | Signal Words | Workflow |
12
+ |--------------|----------|
13
+ | build, create, add, implement, new | `feature.md` |
14
+ | fix, broken, error, crash, bug | `bugfix.md` |
15
+ | clean up, improve, restructure, rename | `refactor.md` |
16
+ | slow, optimize, performance, speed | `performance.md` |
17
+ | review, check, PR, merge | `review.md` |
18
+ | PR description, pull request title | `pr.md` |
19
+ | document, README, explain | `docs.md` |
20
+ | complex, multi-step, plan | `todo.md` |
18
21
 
19
- | Workflow | Use When |
20
- |----------|----------|
21
- | `feature.md` | Building new functionality |
22
- | `bugfix.md` | Diagnosing and fixing bugs |
23
- | `refactor.md` | Improving code without behavior changes |
24
- | `performance.md` | Profiling and optimizing performance |
25
- | `review.md` | Reviewing code for merge |
26
- | `pr.md` | Generating PR title and description |
27
- | `docs.md` | Writing or updating documentation |
28
- | `todo.md` | Creating and managing TODO lists for complex tasks |
22
+ **Complexity:** 1-2 ops (simple) | 3+ ops (complex → also use `todo.md`)
29
23
 
30
- **Workflow Path:**
31
- - React projects: `workflows/react/{workflow}.md`
32
- - Other projects: `workflows/{workflow}.md`
24
+ **Technology:** React (`.jsx`/`.tsx`, react imports, hooks) → `workflows/react/` | Other → `workflows/`
33
25
 
34
- ## Rules
26
+ ---
35
27
 
36
- - Use judgment to select **at most one** workflow per task
37
- - Skip workflows for trivial tasks (typos, simple renames, one-line fixes)
38
- - Workflows are process guidance, not rigid scripts
39
- - Read the workflow file before starting, adapt steps as needed
40
- - Use `todo.md` workflow for any task requiring 3+ distinct steps
28
+ ## 2. DECLARE BINDING
41
29
 
30
+ ### ⛔ STOP CHECKPOINT #2
31
+
32
+ Before ANY tool use, declare:
33
+
34
+ ```
35
+ ORCHESTRATION_BINDING:
36
+ - Task: [description]
37
+ - Classification: [workflow]
38
+ - Workflow: [path]
39
+ - Complexity: [1-2 ops / 3+ ops]
40
+ - Technology: [React / Other / N/A]
41
+ ```
42
+
43
+ ---
44
+
45
+ ## 3. EXEMPT TASKS
46
+
47
+ Exemption requires ALL: single file, 1-2 ops, zero architectural impact, obvious correctness, no debugging.
48
+
49
+ **NOT exempt:** "quick bug fix" (needs investigation), "small feature" (needs context), "make it faster" (needs measurement).
50
+
51
+ Exempt binding:
52
+ ```
53
+ ORCHESTRATION_BINDING:
54
+ - Task: [description]
55
+ - Classification: EXEMPT
56
+ - Justification: [criteria met]
57
+ ```
58
+
59
+ ---
60
+
61
+ ## 4. VIOLATIONS
62
+
63
+ | Type | Indicator |
64
+ |------|-----------|
65
+ | Missing Binding | Tool use without declaration |
66
+ | Premature Tool Use | Edit before workflow read |
67
+ | Scope Creep | Unplanned files modified |
68
+ | False Exemption | Exempt claim for complex task |
69
+
70
+ **Self-correct:** STOP → DECLARE violation → RETURN to checkpoint → REBIND → CONTINUE
71
+
72
+ ---
73
+
74
+ ## 5. EXECUTION
75
+
76
+ **Pre-Work:** Binding declared, workflow read, "Before Coding" answered
77
+
78
+ **Mid-Work:** Within scope, no unplanned files, todo tracking if 3+ ops
79
+
80
+ **Completion:** Validation done, then declare:
81
+ ```
82
+ ORCHESTRATION_COMPLETE:
83
+ - Task: [description]
84
+ - Workflow: [used]
85
+ - Files: [modified]
86
+ ```
87
+
88
+ ---
89
+
90
+ ## 6. WORKFLOW REFERENCE
91
+
92
+ | Workflow | React | Other |
93
+ |----------|-------|-------|
94
+ | feature | `workflows/react/feature.md` | `workflows/feature.md` |
95
+ | bugfix | `workflows/react/bugfix.md` | `workflows/bugfix.md` |
96
+ | refactor | `workflows/react/refactor.md` | `workflows/refactor.md` |
97
+ | performance | `workflows/react/performance.md` | `workflows/performance.md` |
98
+ | review | `workflows/react/review.md` | `workflows/review.md` |
99
+ | pr | `workflows/react/pr.md` | `workflows/pr.md` |
100
+ | docs | `workflows/react/docs.md` | `workflows/docs.md` |
101
+ | todo | `workflows/react/todo.md` | `workflows/todo.md` |