sandboxbox 3.0.1 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  /**
4
4
  * SandboxBox CLI - Process Containment Sandbox
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sandboxbox",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "Lightweight process containment sandbox for CLI tools - Playwright, Claude Code, and more. Pure Node.js, no dependencies.",
5
5
  "type": "module",
6
6
  "main": "cli.js",
@@ -1,6 +1,6 @@
1
- import { existsSync, cpSync, mkdirSync } from 'fs';
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
- const claudeDir = join(sandboxDir, '.claude');
30
- mkdirSync(claudeDir, { recursive: true });
31
-
32
- const hostClaudeDir = join(homedir(), '.claude');
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', '📦 Claude Code running in isolated environment...\n'));
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) {
@@ -27,23 +27,8 @@ export function createSandbox(projectDir) {
27
27
  const claudeDir = join(sandboxDir, '.claude');
28
28
  const hostClaudeDir = join(homedir(), '.claude');
29
29
 
30
- if (existsSync(hostClaudeDir)) {
31
- try {
32
- cpSync(hostClaudeDir, claudeDir, {
33
- recursive: true,
34
- filter: (src) => {
35
- return !src.includes('shell-snapshots') &&
36
- !src.includes('logs') &&
37
- !src.includes('debug') &&
38
- !src.includes('.log');
39
- }
40
- });
41
- } catch (e) {
42
- console.error('Warning: Failed to copy Claude config:', e.message);
43
- }
44
- } else {
45
- mkdirSync(claudeDir, { recursive: true });
46
- }
30
+ // Don't copy Claude files - use host directory directly
31
+ // This avoids permission issues with locked debug files
47
32
 
48
33
  const playwrightDir = join(sandboxDir, '.playwright');
49
34
  mkdirSync(playwrightDir, { recursive: true });
@@ -61,6 +46,12 @@ export function createSandbox(projectDir) {
61
46
 
62
47
  export function createSandboxEnv(sandboxDir, options = {}) {
63
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
+ }
64
55
 
65
56
  const env = {
66
57
  PATH: process.env.PATH,
@@ -75,6 +66,8 @@ export function createSandboxEnv(sandboxDir, options = {}) {
75
66
  CLAUDECODE: '1',
76
67
  NPM_CONFIG_CACHE: process.env.NPM_CONFIG_CACHE || join(hostHome, '.npm'),
77
68
  npm_config_cache: process.env.npm_config_cache || join(hostHome, '.npm'),
69
+ // Set Claude config directory for access
70
+ CLAUDE_CONFIG_DIR: hostClaudeDir,
78
71
  ...options
79
72
  };
80
73