sandboxbox 3.0.34 → 3.0.35
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/package.json +1 -1
- package/utils/sandbox.js +59 -0
package/package.json
CHANGED
package/utils/sandbox.js
CHANGED
|
@@ -66,6 +66,25 @@ export function createSandbox(projectDir, options = {}) {
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
// Ensure .claude is in .gitignore in the sandbox workspace
|
|
70
|
+
const gitignorePath = join(workspaceDir, '.gitignore');
|
|
71
|
+
if (!existsSync(gitignorePath)) {
|
|
72
|
+
writeFileSync(gitignorePath, `# Claude Code settings (project-specific, not to be committed)
|
|
73
|
+
.claude/
|
|
74
|
+
|
|
75
|
+
# Dependencies
|
|
76
|
+
node_modules/
|
|
77
|
+
*.log
|
|
78
|
+
.DS_Store
|
|
79
|
+
`);
|
|
80
|
+
} else {
|
|
81
|
+
// Add .claude to existing .gitignore if not already present
|
|
82
|
+
const gitignoreContent = readFileSync(gitignorePath, 'utf8');
|
|
83
|
+
if (!gitignoreContent.includes('.claude/')) {
|
|
84
|
+
writeFileSync(gitignorePath, gitignoreContent + '\n# Claude Code settings (project-specific, not to be committed)\n.claude/\n');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
69
88
|
// Set up host repo as origin in sandbox (pointing to host directory)
|
|
70
89
|
try {
|
|
71
90
|
execSync(`git remote add origin "${projectDir}"`, {
|
|
@@ -114,6 +133,18 @@ export function createSandbox(projectDir, options = {}) {
|
|
|
114
133
|
// Upstream may not exist yet, ignore error
|
|
115
134
|
}
|
|
116
135
|
|
|
136
|
+
// Copy project's .claude/settings.json if it exists (project-level Claude settings)
|
|
137
|
+
const projectClaudeSettingsPath = join(projectDir, '.claude', 'settings.json');
|
|
138
|
+
if (existsSync(projectClaudeSettingsPath)) {
|
|
139
|
+
const sandboxClaudeSettingsPath = join(workspaceDir, '.claude', 'settings.json');
|
|
140
|
+
mkdirSync(join(workspaceDir, '.claude'), { recursive: true });
|
|
141
|
+
cpSync(projectClaudeSettingsPath, sandboxClaudeSettingsPath);
|
|
142
|
+
|
|
143
|
+
if (VERBOSE_OUTPUT) {
|
|
144
|
+
console.log('✅ Copied project Claude settings to sandbox');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
117
148
|
// Batch fetch git identity settings for efficiency
|
|
118
149
|
const gitSettings = execSync(`git config --global --get user.name && git config --global --get user.email && git config --global --get color.ui`, {
|
|
119
150
|
stdio: 'pipe',
|
|
@@ -130,6 +161,34 @@ export function createSandbox(projectDir, options = {}) {
|
|
|
130
161
|
shell: true
|
|
131
162
|
});
|
|
132
163
|
|
|
164
|
+
// Configure Git remote to host for bidirectional synchronization
|
|
165
|
+
try {
|
|
166
|
+
execSync(`cd "${workspaceDir}" && git remote add host "${projectDir}"`, {
|
|
167
|
+
stdio: 'pipe',
|
|
168
|
+
shell: true
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
if (VERBOSE_OUTPUT) {
|
|
172
|
+
console.log('✅ Configured Git remote to host repository');
|
|
173
|
+
}
|
|
174
|
+
} catch (error) {
|
|
175
|
+
// Remote might already exist, try to update it
|
|
176
|
+
try {
|
|
177
|
+
execSync(`cd "${workspaceDir}" && git remote set-url host "${projectDir}"`, {
|
|
178
|
+
stdio: 'pipe',
|
|
179
|
+
shell: true
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
if (VERBOSE_OUTPUT) {
|
|
183
|
+
console.log('✅ Updated Git remote to host repository');
|
|
184
|
+
}
|
|
185
|
+
} catch (updateError) {
|
|
186
|
+
if (VERBOSE_OUTPUT) {
|
|
187
|
+
console.log('⚠️ Could not configure Git remote to host');
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
133
192
|
// Setup Claude settings in sandbox
|
|
134
193
|
const hostClaudeDir = join(homedir(), '.claude');
|
|
135
194
|
const sandboxClaudeDir = join(sandboxDir, '.claude');
|