Implement Option B: CS Core on host, agents inside container

- New lib/container.sh generates three files per project:
  - bin/claude: wrapper that routes every claude call into the
    agents container via `podman/docker exec --workdir $PWD`
  - start.sh: builds image if missing, starts detached container
    with project mounted at same absolute path as host, prepends
    bin/ to PATH, then launches CS Core on the host
  - stop.sh: stops and removes the agents container

- Container mounts project at identical host path so CS Core's
  working directory paths resolve correctly inside the container
- TTY detection in wrapper: uses -it when stdin is a terminal,
  -i otherwise (node-pty compatibility)
- Container stopped automatically when CS Core exits

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Eli 2026-03-09 12:29:38 +01:00
commit dcc7a2aed7
2 changed files with 132 additions and 16 deletions

View file

@ -11,6 +11,7 @@ source "$WIZARD_DIR/lib/prereqs.sh"
source "$WIZARD_DIR/lib/core.sh"
source "$WIZARD_DIR/lib/project.sh"
source "$WIZARD_DIR/lib/workflow.sh"
source "$WIZARD_DIR/lib/container.sh"
# ── Find existing projects base dir ───────────────────────────────────────
find_projects_dir() {
@ -91,8 +92,12 @@ confirm_summary() {
build_project() {
header "Building Project"
local slug
slug="$(slugify "$PROJECT_NAME")"
create_project_structure "$PROJECT_DIR" "$PROJECT_NAME"
create_devcontainer "$PROJECT_DIR" "$PROJECT_NAME"
generate_container_scripts "$PROJECT_DIR" "$PROJECT_NAME" "$slug"
if [[ "${WORKFLOW_SOURCE:-}" == "Clone from existing repo" ]]; then
clone_workflow "$PROJECT_DIR" "${WORKFLOW_REPO:-}"
@ -120,25 +125,22 @@ print_next_steps() {
echo -e "${BOLD}${GREEN} ➜ Enter your project now:${RESET}"
echo -e "${BOLD}${CYAN} cd \"$PROJECT_DIR\"${RESET}"
echo ""
echo -e "${BOLD}Next steps:${RESET}"
echo -e "${BOLD}Start everything:${RESET}"
echo -e " ${CYAN}./start.sh${RESET}"
echo -e " Builds the image (first time), starts the agents container,"
echo -e " then launches Context Studio Core on your host."
echo ""
echo -e " ${CYAN}Option A — VS Code devcontainer:${RESET}"
echo -e " code \"$PROJECT_DIR\""
echo -e " → \"Reopen in Container\""
echo -e "${BOLD}Stop the container:${RESET}"
echo -e " ${CYAN}./stop.sh${RESET}"
echo ""
echo -e " ${CYAN}Option B — CLI (must be inside the project folder):${RESET}"
echo -e " cd \"$PROJECT_DIR\""
echo -e " $CONTAINER_CMD build -t $slug .devcontainer/"
echo -e " $CONTAINER_CMD run -it --rm \\"
echo -e " -v \"\$(pwd)\":/workspace \\"
echo -e " -v \"\$HOME/.context-studio/core\":/opt/context-studio/core \\"
echo -e " -e ANTHROPIC_API_KEY=\"\$ANTHROPIC_API_KEY\" \\"
echo -e " $slug bash"
echo -e "${BOLD}How it works:${RESET}"
echo -e " • Context Studio Core runs on your host (Electron UI, no display issues)"
echo -e " • Claude Code agents run inside container ${CYAN}cs-${slug}${RESET}"
echo -e "${CYAN}bin/claude${RESET} intercepts every agent call and routes it into the container"
echo -e " • Project files are mounted at the same path on host and in container"
echo ""
echo -e " ${CYAN}Inside container — start Context Studio:${RESET}"
echo -e " node \$CS_CORE_DIR/core/start.js"
echo -e " # or headless (no Electron):"
echo -e " node \$CS_CORE_DIR/core/start.js --ui-mode=headless"
echo -e "${BOLD}VS Code (for editing):${RESET}"
echo -e " ${CYAN}code \"$PROJECT_DIR\"${RESET} → \"Reopen in Container\""
echo ""
}