sandboxbox 3.0.0 → 3.0.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/cli.js +1 -1
- package/package.json +1 -1
- package/utils/commands/claude.js +9 -10
- package/utils/sandbox.js +13 -18
package/cli.js
CHANGED
package/package.json
CHANGED
package/utils/commands/claude.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { existsSync,
|
|
1
|
+
import { existsSync, mkdirSync } from 'fs';
|
|
2
2
|
import { resolve, join } from 'path';
|
|
3
|
-
import { homedir } from 'os';
|
|
3
|
+
import { homedir, platform } from 'os';
|
|
4
4
|
import { color } from '../colors.js';
|
|
5
5
|
import { createSandbox, createSandboxEnv, runInSandbox } from '../sandbox.js';
|
|
6
6
|
|
|
@@ -26,21 +26,20 @@ export async function claudeCommand(projectDir, command = 'claude') {
|
|
|
26
26
|
process.on('SIGTERM', cleanup);
|
|
27
27
|
|
|
28
28
|
try {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (existsSync(hostClaudeDir)) {
|
|
34
|
-
cpSync(hostClaudeDir, claudeDir, { recursive: true });
|
|
29
|
+
let hostClaudeDir = join(homedir(), '.claude');
|
|
30
|
+
if (platform() === 'win32') {
|
|
31
|
+
// Convert Windows path to Unix style for bash
|
|
32
|
+
hostClaudeDir = hostClaudeDir.replace(/^([A-Z]):/, '/$1').replace(/\\/g, '/');
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
const env = createSandboxEnv(sandboxDir, {
|
|
38
36
|
ANTHROPIC_AUTH_TOKEN: process.env.ANTHROPIC_AUTH_TOKEN,
|
|
39
|
-
CLAUDECODE: '1'
|
|
37
|
+
CLAUDECODE: '1',
|
|
38
|
+
HOME: hostClaudeDir // Set HOME to host Claude directory for Claude Code
|
|
40
39
|
});
|
|
41
40
|
|
|
42
41
|
console.log(color('green', `✅ Sandbox created: ${sandboxDir}`));
|
|
43
|
-
console.log(color('cyan',
|
|
42
|
+
console.log(color('cyan', `📦 Claude Code using host config: ${hostClaudeDir}\n`));
|
|
44
43
|
|
|
45
44
|
await runInSandbox(`claude ${command}`, [], sandboxDir, env);
|
|
46
45
|
|
package/utils/sandbox.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mkdtempSync, rmSync, cpSync, existsSync, mkdirSync } from 'fs';
|
|
2
|
-
import { tmpdir, homedir } from 'os';
|
|
3
|
-
import { join } from 'path';
|
|
2
|
+
import { tmpdir, homedir, platform } from 'os';
|
|
3
|
+
import { join, resolve } from 'path';
|
|
4
4
|
import { spawn, execSync } from 'child_process';
|
|
5
5
|
|
|
6
6
|
export function createSandbox(projectDir) {
|
|
@@ -25,23 +25,10 @@ export function createSandbox(projectDir) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const claudeDir = join(sandboxDir, '.claude');
|
|
28
|
-
mkdirSync(claudeDir, { recursive: true });
|
|
29
|
-
|
|
30
28
|
const hostClaudeDir = join(homedir(), '.claude');
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
recursive: true,
|
|
35
|
-
filter: (src) => {
|
|
36
|
-
return !src.includes('shell-snapshots') &&
|
|
37
|
-
!src.includes('logs') &&
|
|
38
|
-
!src.includes('debug') &&
|
|
39
|
-
!src.includes('.log');
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
} catch (e) {
|
|
43
|
-
}
|
|
44
|
-
}
|
|
29
|
+
|
|
30
|
+
// Don't copy Claude files - use host directory directly
|
|
31
|
+
// This avoids permission issues with locked debug files
|
|
45
32
|
|
|
46
33
|
const playwrightDir = join(sandboxDir, '.playwright');
|
|
47
34
|
mkdirSync(playwrightDir, { recursive: true });
|
|
@@ -59,6 +46,12 @@ export function createSandbox(projectDir) {
|
|
|
59
46
|
|
|
60
47
|
export function createSandboxEnv(sandboxDir, options = {}) {
|
|
61
48
|
const hostHome = homedir();
|
|
49
|
+
let hostClaudeDir = join(hostHome, '.claude');
|
|
50
|
+
|
|
51
|
+
// Convert Windows path to Unix style for shell commands
|
|
52
|
+
if (platform() === 'win32') {
|
|
53
|
+
hostClaudeDir = hostClaudeDir.replace(/^([A-Z]):/, '/$1').replace(/\\/g, '/');
|
|
54
|
+
}
|
|
62
55
|
|
|
63
56
|
const env = {
|
|
64
57
|
PATH: process.env.PATH,
|
|
@@ -73,6 +66,8 @@ export function createSandboxEnv(sandboxDir, options = {}) {
|
|
|
73
66
|
CLAUDECODE: '1',
|
|
74
67
|
NPM_CONFIG_CACHE: process.env.NPM_CONFIG_CACHE || join(hostHome, '.npm'),
|
|
75
68
|
npm_config_cache: process.env.npm_config_cache || join(hostHome, '.npm'),
|
|
69
|
+
// Set Claude config directory for access
|
|
70
|
+
CLAUDE_CONFIG_DIR: hostClaudeDir,
|
|
76
71
|
...options
|
|
77
72
|
};
|
|
78
73
|
|