Specify flag

This commit is contained in:
Onur Solmaz 2025-05-27 14:16:42 +02:00
parent 0617ccfc8a
commit 79f16cbea9
5 changed files with 23 additions and 11 deletions

View file

@ -1,7 +1,7 @@
- [x] Fix terminal output
- [x] There is too much orchestration overhead to manage locally, so we need a UI to control, view, and do stuff outside of the container. The best thing is probably to create a web UI to be run locally, and the user will be redirected to this UI when they start a web app locally.
- [ ] Flag for including vs not including non-tracked files
- [x] Flag for including vs not including non-tracked files
- [ ] Create listener for Claude turn end, to commit, push and create a PR
- [ ] GH token should not be copied into the container, huge security risk
- [ ] Specify with a flag which branch to switch to on container start
- [x] Specify with a flag which branch to switch to on container start
- [ ] Being able to specify which setup commands to run before and after the copying of Git files.

View file

@ -71,6 +71,7 @@ program
.option("--no-push", "Disable automatic branch pushing")
.option("--no-pr", "Disable automatic PR creation")
.option("--include-untracked", "Include untracked files when copying to container")
.option("-b, --branch <branch>", "Switch to specific branch on container start (creates if doesn't exist)")
.action(async (options) => {
console.log(chalk.blue("🚀 Starting new Claude Sandbox container..."));
@ -81,6 +82,7 @@ program
config.autoPush = options.push !== false;
config.autoCreatePR = options.pr !== false;
config.includeUntracked = options.includeUntracked || false;
config.targetBranch = options.branch;
const sandbox = new ClaudeSandbox(config);
await sandbox.run();

View file

@ -492,9 +492,10 @@ exec claude --dangerously-skip-permissions' > /start-claude.sh && \\
console.log(chalk.blue("• Connecting to container..."));
// Use provided branch name or generate one
// Use provided branch name, config target branch, or generate one
const targetBranch =
branchName ||
this.config.targetBranch ||
`claude/${
new Date().toISOString().replace(/[:.]/g, "-").split("T")[0]
}-${Date.now()}`;
@ -537,8 +538,14 @@ exec /bin/bash`;
git config --global url."https://\${GITHUB_TOKEN}@github.com/".insteadOf "git@github.com:"
echo "✓ Configured git to use GitHub token"
fi &&
git checkout -b "${targetBranch}" &&
echo "✓ Created branch: ${targetBranch}" &&
# Try to checkout existing branch first, then create new if it doesn't exist
if git show-ref --verify --quiet refs/heads/"${targetBranch}"; then
git checkout "${targetBranch}" &&
echo "✓ Switched to existing branch: ${targetBranch}"
else
git checkout -b "${targetBranch}" &&
echo "✓ Created new branch: ${targetBranch}"
fi &&
echo '${startupScript}' > /home/claude/start-session.sh &&
chmod +x /home/claude/start-session.sh &&
echo "✓ Startup script created"

View file

@ -38,12 +38,14 @@ export class ClaudeSandbox {
const currentBranch = await this.git.branchLocal();
console.log(chalk.blue(`Current branch: ${currentBranch.current}`));
// Generate branch name (but don't switch yet)
const timestamp = new Date()
.toISOString()
.replace(/[:.]/g, "-")
.split("T")[0];
const branchName = `claude/${timestamp}-${Date.now()}`;
// Use target branch from config or generate one
const branchName = this.config.targetBranch || (() => {
const timestamp = new Date()
.toISOString()
.replace(/[:.]/g, "-")
.split("T")[0];
return `claude/${timestamp}-${Date.now()}`;
})();
console.log(chalk.blue(`Will create branch in container: ${branchName}`));
// Discover credentials (optional - don't fail if not found)

View file

@ -23,6 +23,7 @@ export interface SandboxConfig {
bashTimeout?: number;
webUI?: boolean;
includeUntracked?: boolean;
targetBranch?: string;
}
export interface Credentials {