feat(tui): PR-0 — TUI-only ISOLATION .claude.json seed

First PR of the TUI-mode A-path (interactive claude → cc_entrypoint=cli →
subscription pool, so the proxy stays usable for Pro subscribers post-6/15).

Adds a `tui` opt-in param to prepareIsolatedEnvironment (lib/sandbox/manager.mjs).
When tui:true (and only then):
- chmod 700 the per-reqId dir + ephemeralRoot (credential-wall, spec §5.5)
- seed ephemeral .claude.json via _seedTuiClaudeJson: read ~/.claude.json
  (or tuiSeedSource), STRIP projects (no owner history leak), stamp
  hasCompletedOnboarding + bypassPermissionsModeAccepted, preserve
  oauthAccount/userID, write mode 0o600, never log contents
- return reqId in isolationCtx (PR-2 driver derives tmux session name —
  maintainer decision P1: reuse isolationCtx, no server.mjs call-site edits)

DEFAULT PATH BYTE-FOR-BYTE UNCHANGED: when tui falsy, none of the above runs;
the only return-shape change is the additive reqId field existing callers
ignore. Reviewer verified this invariant airtight (server.mjs:1347/:1564 pass
no tui arg).

Seed carries NO MCP-disable weight (T6 negative control: --strict-mcp-config
in PR-2 is the mechanism, not the seed). The seed also does NOT suppress the
per-directory trust-folder dialog — corrected a review-fix overclaim that
attributed trust-dialog suppression to bypassPermissionsModeAccepted (that
flag only suppresses the bypass-permissions dialog; the trust dialog still
appears and PR-2's driver MUST answer it "1", per the spikes).

Tests: Suite 45 (45a default-path-unchanged, 45b tui-seed perms/markers/
strip, 45c missing-source minimal seed). 816 pass / 0 fail.

ADR 0002 Amendment 9 § tuiSeed extension note added.

Authority: design spec docs/superpowers/specs/2026-05-30-tui-mode-production-design.md
§7.1/§5.5/§12.1; implementation plan + maintainer decisions; ADR 0002 Amd 9;
claude CLI v2.1.158.

Co-Authored-By: jaekwon-park <insainty21@gmail.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-30 19:09:12 +10:00
co-authored by jaekwon-park Claude Opus 4.8
parent 0e334f9cac
commit 1fd27e1c11
4 changed files with 328 additions and 5 deletions
+11
View File
@@ -1726,4 +1726,15 @@ export const ISOLATION = {
// 1). No additional CLI flags are needed at the orchestrator level.
// Per ADR 0002 Amendment 9 § 7: absence means the orchestrator passes args
// through unchanged from spawn().
// TUI-mode reuses this ISOLATION shape unchanged for Layers 1+2.
// The .claude.json seed extension (onboarding/trust/bypass markers) is an
// orchestrator-side opt-in: the session driver (PR-2/PR-3) calls
// prepareIsolatedEnvironment({ ..., tui:true }) to seed the ephemeral home.
// The seed logic lives in lib/sandbox/manager.mjs _seedTuiClaudeJson(),
// gated on the tui param so the default stream-json path is unchanged.
//
// NOTE (T6 negative control): the seed does NOT disable managed MCP — that
// is the spawn-argv flag --strict-mcp-config (PR-2). See spec §5.2 + §7.1.
// Authority: claude CLI v2.1.158 + ADR 0002 Amendment 9 (tuiSeed extension).
};