Fix end-to-end startup: project registration, credentials, trust dialog, ready marker

- start.sh: auto-register project in ~/.config/context-studio/projects/ before
  launching Electron — without this acquireProjectLock() silently skips writing
  the lock file, waitForServers() never finds the registry port, all agent ports
  stay null (localhost:null errors)

- start.sh: mount all known Claude Code credential locations into container
  (~/.claude/.credentials.json, ~/.claude.json, $CLAUDE_CONFIG_DIR variants)
  not just ~/.anthropic which was empty on this system

- bin/claude: create /tmp/cs-ready-<agentId> on host after 3s delay so CS Core's
  CLI ready marker poll resolves instead of timing out after 10s

- workflow.sh: add hasTrustDialogAccepted:true to all agent settings.json so
  claude goes straight to priming without the folder trust dialog

- prereqs.sh: add ensure_api_key() — checks all credential locations, prompts
  with masked input if none found, offers to save to shell profile

- wizard.sh: trap SIGINT for graceful abort — gum confirm popup, reverts created
  project dir and cloned core dir, leaves installed packages untouched

- core.sh: set _WIZARD_CORE_CLONED=true before clone for cleanup tracking

- electron-config.js: increase serverStartupTimeout 30s→90s (config file in
  core/config/, not source — safe to edit)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Eli 2026-03-09 21:20:25 +01:00
commit 7c9b61bfce
7 changed files with 325 additions and 80 deletions

View file

@ -21,7 +21,7 @@ One command. A complete project drops out:
└── update.sh ← 🔄 update core, claude-code, OS packages
```
Run `./start.sh` → Podman container starts → Electron UI opens → talk to your agent team.
Run `./start.sh` → Podman container starts → Electron UI opens → agents prime automatically → talk to your team.
---
@ -30,14 +30,14 @@ Run `./start.sh` → Podman container starts → Electron UI opens → talk to y
```
HOST CONTAINER (cs-<project>)
───────────────────────────── ────────────────────────
Context Studio Core (Electron) ←─── All Claude Code agents
starts A2A servers mounted at same abs path
opens Electron UI bin/claude wrapper routes
manages workflow every claude call here
Context Studio Core (Electron) Claude Code binary
A2A agent servers (node) ←─── bin/claude wrapper routes
Electron UI every claude call here
workflow management mounted at same abs path
```
- **CS Core** runs on the host (Electron UI, no display issues)
- **All agents** run inside the Podman container as the current user (not root)
- **CS Core + all agent servers** run on the host (no display issues, native Electron)
- **Claude Code binary** runs inside the Podman container as the current user (not root)
- **`bin/claude`** is prepended to PATH so CS Core's server process finds it automatically
- **Paths match** host ↔ container (project mounted at the same absolute path)
@ -50,7 +50,7 @@ Context Studio Core (Electron) ←─── All Claude Code agents
| 🔀 | `git` | Auto-installed if missing |
| 🐳 | `podman` _(preferred)_ or `docker` | Auto-installed if missing |
| 🔑 | SSH key → `github.com` | Must be set up manually |
| 🗝️ | `ANTHROPIC_API_KEY` | Must be set in your environment |
| 🗝️ | Anthropic credentials | API key or `claude auth login` — wizard checks automatically |
**Auto-install supported on:** Arch · Debian/Ubuntu · RHEL/Fedora · openSUSE
@ -64,22 +64,41 @@ Context Studio Core (Electron) ←─── All Claude Code agents
The wizard guides you through:
1. 🔧 **Core setup** — clones `context-studio-core` to `~/.context-studio/core/` (once, shared)
2. 📝 **Project name & location**
3. ⚙️ **Workflow** — generate from scratch _or_ clone an existing repo
4. 🤖 **Agent preset** _(if generating)_
1. 🔧 **Prerequisites** — checks git, podman/docker, Anthropic credentials
2. 🔧 **Core setup** — clones `context-studio-core` to `~/.context-studio/core/` (once, shared)
3. 📝 **Project name & location**
4. ⚙️ **Workflow** — generate from scratch _or_ clone an existing repo
5. 🤖 **Agent preset** _(if generating)_
| Preset | Agents |
|--------|--------|
| `minimal` | 5 agents: coordinator · 2× coder · researcher · tester |
| `standard` | 9 agents: 2× coordinator · 3× coder · 2× researcher · tester · reviewer |
5. ✅ **Done** — project created, git repo initialized
6. ✅ **Done** — project created, git repo initialized
**Ctrl+C at any point** → confirmation prompt → reverts all created files (installed packages kept).
> ⚠️ **First `./start.sh`** builds the container image. Expect 515 min. Subsequent starts are instant.
---
## 🔑 Anthropic credentials
The wizard checks for credentials in this order:
1. `ANTHROPIC_API_KEY` environment variable
2. `~/.claude/.credentials.json` (default `claude auth login` location)
3. `~/.claude.json`
4. `$CLAUDE_CONFIG_DIR/.credentials.json` / `$CLAUDE_CONFIG_DIR/.claude.json`
5. `~/.anthropic/.credentials.json`
If none found, you're prompted to enter an API key (masked input) with an option to save it to `~/.zshrc` / `~/.bashrc`.
All credential files that exist are **mounted read-only** into the container so Claude Code can authenticate.
---
## ▶️ Starting your project
```bash
@ -89,9 +108,11 @@ cd ~/Projects/my-project
This will:
1. Build the container image if not yet built (first run: 515 min)
2. Start the Podman container (agents run here as your user, not root)
3. Launch the Context Studio Electron UI
4. When you close the UI → container is stopped automatically
2. Start the Podman container (agents run inside as your user, not root)
3. Register the project with Context Studio (required for server startup)
4. Launch the Context Studio Electron UI
5. Agents start, prime automatically — no trust dialogs, no manual steps
6. When you close the UI → container is stopped automatically
```bash
./stop.sh # force-stop container without closing the UI
@ -106,8 +127,8 @@ CS Core on the host needs to call `claude`. Instead of using the host's `claude`
1. Checks the agents container is running
2. Relays the call into the container via `podman exec`
3. Passes the working directory (falling back to project root if cwd isn't mounted)
4. All agents — including the main coordinator — run **inside the container**
3. Falls back to project root as workdir if cwd isn't mounted in the container
4. Creates the CS Core ready marker (`/tmp/cs-ready-<agentId>`) after 3s so `/prime` injection isn't delayed
---
@ -117,7 +138,7 @@ CS Core on the host needs to call `claude`. Instead of using the host's `claude`
🧙 wizard.sh ← entry point
📁 lib/
utils.sh ← prompts, colors, gum helpers
prereqs.sh ← auto-install git + podman/docker
prereqs.sh ← auto-install git + podman/docker + API key check
core.sh ← global core install/update
project.sh ← devcontainer + project scaffold
workflow.sh ← generate or clone workflow config
@ -136,8 +157,9 @@ CS Core on the host needs to call `claude`. Instead of using the host's `claude`
## ⚠️ Hard rules
- **`~/.context-studio/core` is READ-ONLY** — never modify, commit, or push to it
- It is a shared global dependency; the wizard only clones and `npm install`s it
- **`~/.context-studio/core/` source is READ-ONLY** — never modify source files, commit, or push to it
- `~/.context-studio/core/config/electron-config.js` is a config file — safe to edit (e.g. timeouts)
- The wizard only clones and `npm install`s core; it never touches core source
---