๐Ÿ–ฅ๏ธ TUI Integration Plan v0.8

FreeBSD jail-worker integration strategy for replacing Claude-specific runtime pieces with an open-source TUI engine

07.03.2026 — v0.8

Status: Planning phase, runtime integration started
Goal: Replace Claude-specific jail worker execution with a selectable open-source TUI engine while preserving the current host/jail protocol
Primary recommendation: Validate coding-agent on the FreeBSD host and inside the jail before expanding installation UX

1. Current State

Current engine: Claude-backed jail worker execution

Problems:

2. Goal: Replace Claude at the Jail Worker Boundary

Vision: Clawdie keeps its FreeBSD jail architecture and swaps the engine inside the jail worker first

3. TUI Provider Options

3.1 coding-agent (Recommended) โญ

Primary recommendation: Good architectural fit if it proves viable on FreeBSD and inside the jail

Project: github.com/badlogic/pi-mono

Status: Candidate

Why recommended:

3.2 Claude Code (Fallback During Migration)

Status: Current default

3.3 Codex CLI (Experimental)

Status: Not primary for FreeBSD

4. Provider Support Matrix

Provider coding-agent Claude Code Codex CLI
OpenAI Likely โŒ โœ…
Anthropic Likely โœ… โŒ
Google Likely โŒ โŒ
FreeBSD support Untested โœ… โš ๏ธ Bug
Non-interactive worker mode Untested โœ… Untested
Jail compatibility Untested โœ… Untested

5. Runtime Validation Flow

5.1 Step 1: Validate on the FreeBSD Host

# Build or install coding-agent on the host first
# Confirm:
# - binary exists
# - --version works
# - non-interactive stdin/stdout mode works
# - no TTY is required

5.2 Step 2: Validate Inside the Jail

# Repeat the same checks inside the jail
# The critical question is whether coding-agent works in the same
# non-interactive shape as the jail worker:
# - stdin prompt in
# - stdout result out
# - stderr errors
# - no inherited TTY

5.3 Step 3: Wire Engine Selection

AGENT_ENGINE=pi-tui
PI_TUI_BIN=coding-agent
PI_TUI_MODEL=your-model-here

# Keep Claude available as fallback during migration
# AGENT_ENGINE=claude remains the safe default

5.4 Step 4: Add Provider UX Later

Note: Installation-time provider selection should come after jail-worker viability is proven. Runtime proof is the current blocker, not setup prompts.

Future setup UX:

  1. Offer engine selection only after coding-agent is proven viable
  2. Then add provider and model selection on top of the engine switch
  3. Keep host and jail configuration consistent

6. ZFS Jail Setup (Native FreeBSD Isolation)

Native FreeBSD isolation: Jails remain the primary runtime model. Do not bypass them just to make the TUI swap easier.

6.1 Create ZFS Datasets

zfs create -o mountpoint=/jails zroot/jails
zfs create -o mountpoint=/jails/clawdie-cp zroot/jails/clawdie-cp
zfs create -o mountpoint=/jails/clawdie-cp-data zroot/jails/clawdie-cp-data

6.2 Start and Enter Jail

service jail start clawdie-cp
jls
jexec clawdie-cp /bin/csh

7. Architecture

7.1 Runtime Boundary

Clawdie AI Stack:
โ”œโ”€โ”€ Host Runner
โ”‚   โ””โ”€โ”€ src/jail-runner.ts
โ”‚
โ”œโ”€โ”€ Jail Worker
โ”‚   โ””โ”€โ”€ container/agent-runner/src/index.ts
โ”‚       โ”œโ”€โ”€ ClaudeSdkEngine
โ”‚       โ””โ”€โ”€ PiTuiEngine
โ”‚
โ””โ”€โ”€ Runtime Isolation
    โ””โ”€โ”€ FreeBSD jails

Key rule:
- preserve host/jail protocol
- swap engine inside the jail worker
- add provider UX only after the worker path is stable

7.2 Engine Abstraction

interface AgentEngine {
  name: string;
  runTurn(input: AgentTurnInput): Promise<AgentTurnResult>;
}

class ClaudeSdkEngine implements AgentEngine { ... }
class PiTuiEngine implements AgentEngine { ... }

8. Benefits

8.1 Runtime Stability

8.2 Provider Flexibility

8.3 Operational Clarity

8.4 Future-Proof

9. Implementation Timeline

Week 1: FreeBSD Viability

Week 2: Jail Worker Integration

Week 3: Feature Gap Review

Week 4: Setup UX and Documentation

10. Current Status

Component Status Notes
Host/jail engine switch Started Engine abstraction exists, PI TUI parity not proven
coding-agent on FreeBSD host Untested Must prove build and worker-mode execution first
coding-agent inside jail Untested Critical deployment gate
Session parity with Claude Incomplete Resume and continuation behavior still need work
ZFS jail support Ready Native FreeBSD isolation

11. Next Steps

  1. โœ… Choose candidate engine: coding-agent
  2. โณ Prove coding-agent builds and runs on FreeBSD host
  3. โณ Prove coding-agent works inside the jail without a TTY
  4. โณ Run one jailed Clawdie turn with AGENT_ENGINE=pi-tui
  5. โณ Review feature gaps versus Claude
  6. โณ Add setup UX only if runtime testing succeeds
  7. โณ Release after the live runtime path is stable

12. Testing Strategies

12.1 Option A: Build from Source

cd ~
git clone https://github.com/badlogic/pi-mono.git
cd pi-mono
npm install
npm run build
node packages/coding-agent/dist/index.js --version
printf 'Say hello in one sentence.\n' | node packages/coding-agent/dist/index.js --non-interactive --stdin

12.2 Option B: NPM Install

npm install -g @mariozechner/coding-agent
coding-agent --version
printf 'Say hello in one sentence.\n' | coding-agent --non-interactive --stdin

12.3 Option C: Jail Isolation

jexec clawdie-cp /bin/csh
pkg install node24 npm git
# Build or install coding-agent in the jail
# Then repeat the same non-interactive stdin/stdout smoke test

12.4 Recommended Testing Flow

  1. Stage 1: Build or install on the host
  2. Stage 2: Prove non-interactive worker mode on the host
  3. Stage 3: Prove the same flow inside the jail
  4. Stage 4: Test one real Clawdie jailed turn with AGENT_ENGINE=pi-tui
  5. Stage 5: Document findings and gaps

12.5 Testing Checklist

Test Command Expected
Build succeeds npm run build No errors
Non-interactive host run printf '... ' | coding-agent --non-interactive --stdin Exit 0, usable stdout, no TTY needed
Non-interactive jail run printf '... ' | coding-agent --non-interactive --stdin Same behavior inside jail
Single jailed Clawdie turn AGENT_ENGINE=pi-tui Host/jail protocol still works
Session parity Run follow-up turn Resume behavior is defined and predictable