Skip to content

Commit cd76d4f

Browse files
authored
Merge branch 'main' into gimli/fix-linux-portability
2 parents 391ba8f + 5eb4244 commit cd76d4f

23 files changed

Lines changed: 226 additions & 1612 deletions

AGENTS.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

CODEX_EXECUTION_GUIDE.md

Lines changed: 0 additions & 52 deletions
This file was deleted.

HARNESS_CHECKLIST.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

README.md

Lines changed: 87 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,117 @@
1-
# Portable Coder
1+
# Portable Claude Code
22

3-
Portable multi-provider coding CLI launcher with harness-first planning.
3+
A portable Claude Code launcher you can copy to any Windows computer or flash drive and run without a system-wide install.
44

5-
**Goal:** Run Claude Code and other AI coding CLIs from a portable folder (e.g., flash drive) without requiring installation on the host machine, while maintaining isolated auth state and the ability to access files on the local machine.
5+
## What it does
66

7-
## Current Status
8-
-**Cross-platform support:** Works on Linux, macOS, and Windows
9-
-**Portable auth state:** Auth credentials stored in portable folder, not host home directory
10-
-**Supported tools:** Codex CLI, Claude Code
11-
- Planning control-plane is established (`AGENTS.md`, `HARNESS_CHECKLIST.md`, `docs/*`)
12-
- Active plan: `docs/exec-plans/active/EP-001-portable-coder-foundation-and-multi-provider-mvp.md`
7+
- Launches [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI with your local filesystem accessible
8+
- Stores OAuth credentials portably inside the repo's `state/` folder (no registry or system config pollution)
9+
- On Windows: runs Claude Code inside a bundled QEMU Linux VM (no WSL required)
10+
- Supports API key mode if you prefer to skip OAuth
1311

14-
## Platform-Specific Behavior
12+
## Requirements
1513

16-
| Platform | Default Mode | Behavior |
17-
|----------|-------------|----------|
18-
| **Linux** | `host-native` | Runs tools directly with portable auth isolation |
19-
| **macOS** | `host-native` | Runs tools directly with portable auth isolation |
20-
| **Windows** | `linux-portable` | Runs tools in bundled QEMU VM with portable auth |
21-
22-
On **Linux/macOS**, the `--mode linux-portable` flag runs tools in "portable-native" mode, which uses isolated auth state in `state/auth/<tool>/host/` but runs the tool directly on the host. This provides true portability without requiring a VM.
14+
- **Node.js** — either bundled in `runtime/node/` or installed on the host
15+
- **Claude Code** — either installed globally (`npm install -g @anthropic-ai/claude-code`) or bundled in `runtime/`
16+
- **Windows VM mode only**: QEMU runtime (download with `pcoder runtime bootstrap`)
2317

2418
## Quick Start
2519

26-
### Linux / macOS
27-
```bash
28-
# 1. Initialize settings
29-
./scripts/pcoder setup --init
20+
### First time
3021

31-
# 2. Verify setup
32-
./scripts/pcoder doctor
22+
```bat
23+
REM 1. Initialize settings (creates state/settings.json)
24+
scripts\pcoder setup --init
3325
34-
# 3. Run a tool (uses portable auth isolation by default)
35-
./scripts/pcoder run codex -- "your prompt here"
36-
./scripts/pcoder run claude -- "your prompt here"
37-
```
26+
REM 2. Log in with your Anthropic account (OAuth - credentials stay portable)
27+
scripts\pcoder auth login
3828
39-
### Windows
40-
1. Bootstrap runtime payload: `scripts/runtime/windows/bootstrap-runtime.cmd`
41-
- Optional launcher path: `scripts/pcoder runtime bootstrap`
42-
- Optional URL overrides: `PCODER_QEMU_INSTALLER_URL`, `PCODER_QEMU_SHA512_URL`, `PCODER_UBUNTU_IMAGE_URL`
43-
2. Run onboarding once: `scripts/pcoder setup --init`
44-
3. Choose auth modes as needed:
45-
- OAuth: `scripts/pcoder setup --codex-auth oauth --claude-auth oauth`
46-
- API keys: `scripts/pcoder setup --codex-auth api --claude-auth api`
47-
4. Inject required env vars only for API mode (`OPENAI_API_KEY` and/or `ANTHROPIC_AUTH_TOKEN`)
48-
5. Run `scripts/pcoder doctor`
49-
6. Launch in VM mode: `scripts/pcoder run <tool> --mode linux-portable`
50-
7. Use `--no-sync-back` if you do not want VM changes copied back automatically
29+
REM 3. Check everything looks good
30+
scripts\pcoder doctor
31+
```
5132

52-
On Windows, `pcoder run` defaults to `--mode linux-portable`.
33+
### Launch Claude Code
5334

54-
Auth management:
55-
- `scripts/pcoder auth status`
56-
- `scripts/pcoder auth login codex`
57-
- `scripts/pcoder auth login claude`
58-
- `scripts/pcoder auth logout codex`
59-
- `scripts/pcoder auth logout claude`
35+
```bat
36+
REM Launch in current directory
37+
scripts\pcoder
6038
61-
Windows smoke test:
62-
- `scripts/runtime/windows/smoke-check.cmd`
39+
REM Launch in a specific project
40+
scripts\pcoder run --project C:\path\to\my-project
6341
64-
## CI
65-
- GitHub Actions workflow: `.github/workflows/ci.yml`
66-
- Runner target: Blacksmith runner label `blacksmith-2vcpu-ubuntu-2404`
42+
REM Pass args directly to claude
43+
scripts\pcoder -- --help
44+
```
6745

68-
## Claude PR Runner
69-
- Workflow: `.github/workflows/claude-pr-runner.yml`
70-
- Trigger: mention `@claude` in PR comments/reviews (or run manually via `workflow_dispatch`)
71-
- Runner target: Blacksmith runner label `blacksmith-2vcpu-ubuntu-2404`
72-
- Configure one auth secret:
73-
- `ANTHROPIC_API_KEY` (API key mode), or
74-
- `CLAUDE_CODE_OAUTH_TOKEN` (OAuth mode)
46+
### API key mode (skip OAuth)
7547

76-
Supported tool IDs:
77-
- `codex`
78-
- `claude`
48+
```bat
49+
REM Switch to API key mode
50+
scripts\pcoder setup --claude-auth api
7951
80-
## How It Works
52+
REM Set your key before launching
53+
set ANTHROPIC_API_KEY=sk-ant-...
54+
scripts\pcoder
55+
```
8156

82-
Portable Coder provides **portable auth isolation** - running AI coding tools with their configuration and credentials stored in the portable folder rather than the host's home directory.
57+
## Windows: VM vs Host-Native
8358

84-
### Key Concepts
59+
By default on Windows, Claude runs inside a bundled portable Linux VM (QEMU). This gives full Linux compatibility without requiring WSL or any host configuration.
8560

86-
- **Portable Auth State**: When using OAuth mode, auth tokens are stored in `state/auth/<tool>/host/home/` instead of `~/.claude` or `~/.openai`. This allows you to copy the portable folder to another machine and remain authenticated.
61+
**VM mode (default on Windows)**
62+
```bat
63+
REM Bootstrap the VM runtime first (one-time download)
64+
scripts\pcoder runtime bootstrap
8765
88-
- **Execution Modes**:
89-
- `host-native`: Runs the tool directly on the host using the portable auth state
90-
- `linux-portable`: On Windows, runs the tool inside a bundled QEMU VM for full Linux isolation; on Linux/macOS, falls back to portable-native execution
66+
REM Then just run normally
67+
scripts\pcoder
68+
```
9169

92-
- **No Secrets in Bundle**: API keys are never stored in the portable folder. In API mode, keys are injected via environment variables at runtime.
70+
**Host-native mode** (if claude is installed directly on Windows)
71+
```bat
72+
scripts\pcoder setup --windows-mode host-native
73+
scripts\pcoder
74+
```
9375

94-
### Directory Structure
76+
## Commands
77+
78+
| Command | Description |
79+
|---|---|
80+
| `pcoder` | Launch Claude Code in current directory |
81+
| `pcoder doctor` | Check environment health |
82+
| `pcoder setup --init` | Initialize settings |
83+
| `pcoder setup --show` | Show current settings |
84+
| `pcoder setup --claude-auth <oauth|api>` | Change auth mode |
85+
| `pcoder setup --windows-mode <linux-portable|host-native>` | Change Windows run mode |
86+
| `pcoder auth status` | Show auth status |
87+
| `pcoder auth login` | Log in via OAuth |
88+
| `pcoder auth logout` | Log out |
89+
| `pcoder runtime probe` | Show available runtimes |
90+
| `pcoder runtime bootstrap` | Download Windows VM runtime (QEMU + Ubuntu) |
91+
| `pcoder run [--project <path>] [--mode <mode>] [-- <claude args>]` | Run with options |
92+
93+
## File Layout
9594

9695
```
9796
PortableCoder/
98-
├── apps/ # Provider tool wrappers and configs
99-
├── profiles/ # User/provider profiles and model routing
100-
│ ├── defaults/ # Default profile templates
101-
│ └── profiles.json # Profile definitions
102-
├── runtime/ # Bundled dependencies (QEMU, Linux VM on Windows)
103-
│ └── linux/ # Linux runtime assets (VM image, cloud-init)
104-
├── scripts/ # Launchers and scripts
105-
│ ├── adapters/ # Tool adapter catalog
106-
│ ├── pcoder # Main POSIX launcher
107-
│ ├── pcoder.cmd # Main Windows launcher
108-
│ ├── pcoder.cjs # Core launcher logic
109-
│ └── runtime/ # Platform-specific runtime scripts
110-
├── state/ # Local state (gitignored - portable!)
111-
│ ├── auth/ # Isolated auth credentials
112-
│ │ ├── claude/host/home/ # Claude OAuth state
113-
│ │ └── codex/host/home/ # Codex OAuth state
114-
│ ├── active-profile.txt
115-
│ └── settings.json
116-
└── docs/ # Planning and governance artifacts
97+
scripts/
98+
pcoder.cmd <- Windows launcher (double-click or run from cmd)
99+
pcoder <- Linux/macOS launcher
100+
pcoder.cjs <- Main launcher logic (Node.js)
101+
runtime/windows/ <- Windows VM helper scripts
102+
runtime/
103+
node/ <- (optional) bundled Node.js
104+
linux/ <- VM image and SSH key (after bootstrap)
105+
qemu/ <- QEMU binaries (after bootstrap)
106+
state/
107+
settings.json <- Your settings (auto-created)
108+
auth/ <- Portable OAuth credentials (stays with the drive)
109+
profiles/
110+
profiles.json <- Anthropic profile config
117111
```
118112

119-
## Testing
120-
121-
Run the smoke test on Linux/macOS:
122-
```bash
123-
./scripts/pcoder doctor
124-
./scripts/pcoder run codex --mode linux-portable -- --version
125-
./scripts/pcoder run claude --mode linux-portable -- --version
126-
```
113+
## Portability Notes
127114

128-
## Planning Workflow
129-
Read in order:
130-
1. `AGENTS.md`
131-
2. `HARNESS_CHECKLIST.md`
132-
3. `docs/PLANS.md`
133-
4. active ExecPlan in `docs/exec-plans/active/`
115+
- Copy the entire `PortableCoder/` folder to a flash drive or another machine and it works
116+
- OAuth credentials are stored in `state/auth/` so they travel with the folder
117+
- No registry writes, no system PATH changes, no admin rights required (VM mode may need Hyper-V or software TCG fallback)

0 commit comments

Comments
 (0)