claude-code-remote-pilot 0.1.1 → 0.1.2
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-pilot.js +58 -22
- package/package.json +1 -1
package/bin/claude-pilot.js
CHANGED
|
@@ -11,27 +11,70 @@ if (!fs.existsSync(scriptPath)) {
|
|
|
11
11
|
process.exit(1);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
const readline = require('readline');
|
|
15
|
+
|
|
14
16
|
function checkDep(cmd) {
|
|
15
17
|
try { execSync(`command -v ${cmd}`, { stdio: 'ignore' }); return true; }
|
|
16
18
|
catch { return false; }
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
function detectPlatform() {
|
|
22
|
+
const platform = process.platform;
|
|
23
|
+
if (platform === 'darwin') return 'macos';
|
|
24
|
+
if (platform === 'win32') return 'windows';
|
|
25
|
+
try {
|
|
26
|
+
const release = fs.readFileSync('/etc/os-release', 'utf8');
|
|
27
|
+
if (/ID=arch/i.test(release)) return 'arch';
|
|
28
|
+
if (/ID=(fedora|rhel|centos)/i.test(release)) return 'fedora';
|
|
29
|
+
} catch {}
|
|
30
|
+
return 'debian';
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
function tmuxInstallCmd() {
|
|
34
|
+
const p = detectPlatform();
|
|
35
|
+
if (p === 'macos') return 'brew install tmux';
|
|
36
|
+
if (p === 'arch') return 'sudo pacman -S --noconfirm tmux';
|
|
37
|
+
if (p === 'fedora') return 'sudo dnf install -y tmux';
|
|
38
|
+
return 'sudo apt-get install -y tmux';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function prompt(question) {
|
|
42
|
+
return new Promise((resolve) => {
|
|
43
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
44
|
+
rl.question(question, (answer) => { rl.close(); resolve(answer.trim().toLowerCase()); });
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function ensureDep(cmd, label, installCmd) {
|
|
49
|
+
if (checkDep(cmd)) return;
|
|
50
|
+
console.log(`\n${label} is not installed.`);
|
|
51
|
+
const answer = await prompt(`Install it now? (y/n) `);
|
|
52
|
+
if (answer !== 'y' && answer !== 'yes') {
|
|
53
|
+
console.log(`Skipping. Run manually: ${installCmd}`);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
console.log(`Running: ${installCmd}\n`);
|
|
57
|
+
try {
|
|
58
|
+
execSync(installCmd, { stdio: 'inherit' });
|
|
59
|
+
console.log(`\n${label} installed successfully.\n`);
|
|
60
|
+
} catch {
|
|
61
|
+
console.error(`\nInstall failed. Try running manually: ${installCmd}`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function main() {
|
|
67
|
+
await ensureDep('tmux', 'tmux', tmuxInstallCmd());
|
|
68
|
+
await ensureDep('claude', 'Claude Code CLI', 'npm install -g @anthropic-ai/claude-code');
|
|
69
|
+
|
|
70
|
+
const child = spawn('bash', [scriptPath], {
|
|
71
|
+
stdio: 'inherit',
|
|
72
|
+
env: process.env,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
child.on('exit', (code) => {
|
|
76
|
+
process.exit(code || 0);
|
|
77
|
+
});
|
|
35
78
|
}
|
|
36
79
|
|
|
37
80
|
if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
|
@@ -56,11 +99,4 @@ Attach to tmux:
|
|
|
56
99
|
process.exit(0);
|
|
57
100
|
}
|
|
58
101
|
|
|
59
|
-
|
|
60
|
-
stdio: 'inherit',
|
|
61
|
-
env: process.env,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
child.on('exit', (code) => {
|
|
65
|
-
process.exit(code || 0);
|
|
66
|
-
});
|
|
102
|
+
main();
|
package/package.json
CHANGED