claude-flow 1.0.10 → 1.0.11
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/claude-flow +77 -0
- package/package.json +2 -2
- package/scripts/install.js +57 -0
- package/src/cli/cli-core.ts +1 -1
- package/src/cli/commands/index.ts +126 -0
- package/src/cli/main.ts +1 -1
package/bin/claude-flow
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
|
|
7
|
+
// Special handling for init command
|
|
8
|
+
if (process.argv[2] === 'init') {
|
|
9
|
+
// Use the Node.js init script that handles Deno installation
|
|
10
|
+
const initScript = path.join(__dirname, '..', 'scripts', 'init.js');
|
|
11
|
+
const child = spawn('node', [initScript, ...process.argv.slice(3)], {
|
|
12
|
+
stdio: 'inherit',
|
|
13
|
+
env: process.env
|
|
14
|
+
});
|
|
15
|
+
child.on('exit', (code) => process.exit(code || 0));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Check if compiled binary exists
|
|
20
|
+
const binaryPath = __filename + '-binary';
|
|
21
|
+
if (fs.existsSync(binaryPath)) {
|
|
22
|
+
// Use compiled binary
|
|
23
|
+
const child = spawn(binaryPath, process.argv.slice(2), { stdio: 'inherit' });
|
|
24
|
+
child.on('exit', (code) => process.exit(code));
|
|
25
|
+
} else {
|
|
26
|
+
// Fallback to Deno execution
|
|
27
|
+
const mainPath = path.join(__dirname, '..', 'src', 'cli', 'main.ts');
|
|
28
|
+
|
|
29
|
+
// Try to find deno in common locations
|
|
30
|
+
let denoPath = 'deno';
|
|
31
|
+
const os = require('os');
|
|
32
|
+
const possiblePaths = [
|
|
33
|
+
path.join(os.homedir(), '.deno', 'bin', 'deno'),
|
|
34
|
+
'/usr/local/bin/deno',
|
|
35
|
+
'/usr/bin/deno',
|
|
36
|
+
'deno' // Try PATH as last resort
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
let denoFound = false;
|
|
40
|
+
for (const p of possiblePaths) {
|
|
41
|
+
try {
|
|
42
|
+
if (p === 'deno' || fs.existsSync(p)) {
|
|
43
|
+
denoPath = p;
|
|
44
|
+
// Test if it works
|
|
45
|
+
const testChild = spawn(p, ['--version'], { stdio: 'pipe' });
|
|
46
|
+
testChild.on('close', (code) => {
|
|
47
|
+
if (code === 0) denoFound = true;
|
|
48
|
+
});
|
|
49
|
+
if (p !== 'deno') {
|
|
50
|
+
denoFound = true;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} catch (e) {
|
|
55
|
+
// Continue to next path
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const child = spawn(denoPath, ['run', '--allow-all', mainPath, ...process.argv.slice(2)], {
|
|
60
|
+
stdio: 'inherit',
|
|
61
|
+
env: { ...process.env }
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
child.on('error', (err) => {
|
|
65
|
+
if (err.code === 'ENOENT') {
|
|
66
|
+
console.error('Error: Deno is not installed. Please install Deno first:');
|
|
67
|
+
console.error('Visit https://deno.land/ for installation instructions.');
|
|
68
|
+
console.error('Or run: curl -fsSL https://deno.land/x/install/install.sh | sh');
|
|
69
|
+
process.exit(1);
|
|
70
|
+
} else {
|
|
71
|
+
console.error('Error executing claude-flow:', err.message);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
child.on('exit', (code) => process.exit(code || 0));
|
|
77
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-flow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "Advanced AI agent orchestration system for Claude Code",
|
|
5
5
|
"main": "src/cli/main.ts",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"postinstall": "node scripts/install.js",
|
|
11
|
-
"build": "PATH=\"/home/codespace/.deno/bin:$PATH\" deno compile --allow-all --no-check --output=bin/claude-flow src/cli/main.ts",
|
|
11
|
+
"build": "PATH=\"/home/codespace/.deno/bin:$PATH\" deno compile --allow-all --no-check --output=bin/claude-flow-binary src/cli/main.ts",
|
|
12
12
|
"build:simple": "PATH=\"/home/codespace/.deno/bin:$PATH\" deno compile --allow-all --no-check --output=bin/claude-flow-simple src/cli/simple-cli.ts",
|
|
13
13
|
"test": "deno task test"
|
|
14
14
|
},
|
package/scripts/install.js
CHANGED
|
@@ -50,6 +50,55 @@ async function installDeno() {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
// Build the binary
|
|
54
|
+
async function buildBinary() {
|
|
55
|
+
console.log('Building Claude-Flow binary...');
|
|
56
|
+
|
|
57
|
+
// Create bin directory if it doesn't exist
|
|
58
|
+
const binDir = path.join(__dirname, '..', 'bin');
|
|
59
|
+
if (!fs.existsSync(binDir)) {
|
|
60
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Try to find deno in common locations
|
|
64
|
+
let denoPath = 'deno';
|
|
65
|
+
const possiblePaths = [
|
|
66
|
+
path.join(os.homedir(), '.deno', 'bin', 'deno'),
|
|
67
|
+
'/usr/local/bin/deno',
|
|
68
|
+
'/usr/bin/deno'
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
for (const p of possiblePaths) {
|
|
72
|
+
if (fs.existsSync(p)) {
|
|
73
|
+
denoPath = p;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
const build = spawn(denoPath, [
|
|
80
|
+
'compile',
|
|
81
|
+
'--allow-all',
|
|
82
|
+
'--no-check',
|
|
83
|
+
'--output=' + path.join(binDir, 'claude-flow-binary'),
|
|
84
|
+
path.join(__dirname, '..', 'src', 'cli', 'main.ts')
|
|
85
|
+
], { stdio: 'inherit' });
|
|
86
|
+
|
|
87
|
+
build.on('close', (code) => {
|
|
88
|
+
if (code === 0) {
|
|
89
|
+
console.log('Binary built successfully!');
|
|
90
|
+
resolve();
|
|
91
|
+
} else {
|
|
92
|
+
reject(new Error('Failed to build binary'));
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
build.on('error', (err) => {
|
|
97
|
+
reject(err);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
53
102
|
// Main installation process
|
|
54
103
|
async function main() {
|
|
55
104
|
try {
|
|
@@ -59,6 +108,14 @@ async function main() {
|
|
|
59
108
|
await installDeno();
|
|
60
109
|
}
|
|
61
110
|
|
|
111
|
+
// Try to build the binary
|
|
112
|
+
try {
|
|
113
|
+
await buildBinary();
|
|
114
|
+
} catch (buildError) {
|
|
115
|
+
console.warn('Failed to build binary:', buildError.message);
|
|
116
|
+
console.log('Falling back to runtime execution mode.');
|
|
117
|
+
}
|
|
118
|
+
|
|
62
119
|
console.log('Claude-Flow installation completed!');
|
|
63
120
|
console.log('You can now use: npx claude-flow or claude-flow (if installed globally)');
|
|
64
121
|
|
package/src/cli/cli-core.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { red, green, yellow, blue, bold, cyan } from "https://deno.land/std@0.22
|
|
|
8
8
|
import { ensureDir } from "https://deno.land/std@0.224.0/fs/mod.ts";
|
|
9
9
|
import { join } from "https://deno.land/std@0.224.0/path/mod.ts";
|
|
10
10
|
|
|
11
|
-
export const VERSION = "1.0.
|
|
11
|
+
export const VERSION = "1.0.11";
|
|
12
12
|
|
|
13
13
|
interface CommandContext {
|
|
14
14
|
args: string[];
|
|
@@ -12,6 +12,129 @@ let orchestrator: Orchestrator | null = null;
|
|
|
12
12
|
let configManager: ConfigManager | null = null;
|
|
13
13
|
let persistence: JsonPersistenceManager | null = null;
|
|
14
14
|
|
|
15
|
+
async function checkAndInstallDeno(): Promise<boolean> {
|
|
16
|
+
try {
|
|
17
|
+
// Check if Deno is already available
|
|
18
|
+
const checkCommand = new Deno.Command("deno", {
|
|
19
|
+
args: ["--version"],
|
|
20
|
+
stdout: "null",
|
|
21
|
+
stderr: "null",
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const result = await checkCommand.output();
|
|
26
|
+
if (result.success) {
|
|
27
|
+
info("✓ Deno is already installed");
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
} catch {
|
|
31
|
+
// Deno not found, continue to installation
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
warning("Deno not found. Installing Deno automatically...");
|
|
35
|
+
|
|
36
|
+
// Determine OS and install Deno
|
|
37
|
+
const os = Deno.build.os;
|
|
38
|
+
const homeDir = Deno.env.get("HOME") || Deno.env.get("USERPROFILE") || "";
|
|
39
|
+
const denoDir = `${homeDir}/.deno`;
|
|
40
|
+
|
|
41
|
+
if (os === "windows") {
|
|
42
|
+
error("Please install Deno manually on Windows from https://deno.land/");
|
|
43
|
+
console.log("Run: irm https://deno.land/install.ps1 | iex");
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Download and install Deno for Unix-like systems
|
|
48
|
+
info("Downloading Deno installer...");
|
|
49
|
+
|
|
50
|
+
const installScript = await fetch("https://deno.land/x/install/install.sh");
|
|
51
|
+
if (!installScript.ok) {
|
|
52
|
+
throw new Error("Failed to download Deno installer");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const scriptContent = await installScript.text();
|
|
56
|
+
const tempFile = await Deno.makeTempFile({ suffix: ".sh" });
|
|
57
|
+
await Deno.writeTextFile(tempFile, scriptContent);
|
|
58
|
+
|
|
59
|
+
// Make script executable
|
|
60
|
+
await Deno.chmod(tempFile, 0o755);
|
|
61
|
+
|
|
62
|
+
// Run the installer
|
|
63
|
+
const installCommand = new Deno.Command("sh", {
|
|
64
|
+
args: [tempFile],
|
|
65
|
+
env: {
|
|
66
|
+
...Deno.env.toObject(),
|
|
67
|
+
DENO_INSTALL: denoDir,
|
|
68
|
+
},
|
|
69
|
+
stdout: "inherit",
|
|
70
|
+
stderr: "inherit",
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const installResult = await installCommand.output();
|
|
74
|
+
|
|
75
|
+
// Clean up temp file
|
|
76
|
+
await Deno.remove(tempFile);
|
|
77
|
+
|
|
78
|
+
if (!installResult.success) {
|
|
79
|
+
throw new Error("Failed to install Deno");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
success("✓ Deno installed successfully!");
|
|
83
|
+
|
|
84
|
+
// Export path instructions
|
|
85
|
+
const denoBinPath = `${denoDir}/bin`;
|
|
86
|
+
const shellConfig = os === "darwin" ? "~/.zshrc" : "~/.bashrc";
|
|
87
|
+
|
|
88
|
+
info("\nTo use Deno, add it to your PATH:");
|
|
89
|
+
console.log(` export DENO_INSTALL="${denoDir}"`);
|
|
90
|
+
console.log(` export PATH="$DENO_INSTALL/bin:$PATH"`);
|
|
91
|
+
console.log(`\nAdd these lines to your ${shellConfig} file to make it permanent.`);
|
|
92
|
+
|
|
93
|
+
// Try to add to current session PATH
|
|
94
|
+
const currentPath = Deno.env.get("PATH") || "";
|
|
95
|
+
if (!currentPath.includes(denoBinPath)) {
|
|
96
|
+
Deno.env.set("PATH", `${denoBinPath}:${currentPath}`);
|
|
97
|
+
info(`\n✓ Temporarily added Deno to PATH for this session`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Create a shell script to help users
|
|
101
|
+
const setupScript = `#!/bin/bash
|
|
102
|
+
# Claude-Flow Deno Setup Script
|
|
103
|
+
# This script sets up Deno in your environment
|
|
104
|
+
|
|
105
|
+
export DENO_INSTALL="${denoDir}"
|
|
106
|
+
export PATH="$DENO_INSTALL/bin:$PATH"
|
|
107
|
+
|
|
108
|
+
# Check if Deno is accessible
|
|
109
|
+
if command -v deno &> /dev/null; then
|
|
110
|
+
echo "✓ Deno is now available in your PATH"
|
|
111
|
+
deno --version
|
|
112
|
+
else
|
|
113
|
+
echo "❌ Failed to add Deno to PATH"
|
|
114
|
+
echo "Please manually add the following to your ${shellConfig}:"
|
|
115
|
+
echo ' export DENO_INSTALL="${denoDir}"'
|
|
116
|
+
echo ' export PATH="$DENO_INSTALL/bin:$PATH"'
|
|
117
|
+
fi
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
await Deno.writeTextFile("setup-deno.sh", setupScript);
|
|
121
|
+
await Deno.chmod("setup-deno.sh", 0o755);
|
|
122
|
+
|
|
123
|
+
info("\n✓ Created setup-deno.sh script");
|
|
124
|
+
console.log(" Run: source ./setup-deno.sh");
|
|
125
|
+
console.log(" to set up Deno in your current shell\n");
|
|
126
|
+
|
|
127
|
+
return true;
|
|
128
|
+
|
|
129
|
+
} catch (err) {
|
|
130
|
+
error(`Failed to install Deno: ${(err as Error).message}`);
|
|
131
|
+
console.log("\nPlease install Deno manually:");
|
|
132
|
+
console.log(" curl -fsSL https://deno.land/x/install/install.sh | sh");
|
|
133
|
+
console.log(" or visit: https://deno.land/");
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
15
138
|
async function getPersistence(): Promise<JsonPersistenceManager> {
|
|
16
139
|
if (!persistence) {
|
|
17
140
|
persistence = new JsonPersistenceManager();
|
|
@@ -61,6 +184,9 @@ export function setupCommands(cli: CLI): void {
|
|
|
61
184
|
try {
|
|
62
185
|
success("Initializing Claude Code integration files...");
|
|
63
186
|
|
|
187
|
+
// Check and install Deno first
|
|
188
|
+
const denoInstalled = await checkAndInstallDeno();
|
|
189
|
+
|
|
64
190
|
const force = ctx.flags.force as boolean || ctx.flags.f as boolean;
|
|
65
191
|
const minimal = ctx.flags.minimal as boolean || ctx.flags.m as boolean;
|
|
66
192
|
|
package/src/cli/main.ts
CHANGED