Phase A of /home/g/.claude/plans/ethereal-crunching-clover.md. Three
independent changes share one goal: make /control inject actually
diagnosable + actually reliable on the common case.
A1. Surface real inject failure reasons
- inject_prompt() emits a structured single-line reason via stderr on
every failure path (no-tab, no-session, focus-timeout,
write-chars-failed) instead of returning bare 1
- Daemon callsites capture that stderr into a temp file and forward
the reason to mark_done — the user sees "no zellij tab matches
'revampit' — currently open: Kivvi, FleetCrown, OrangeCat, Revamp-It"
instead of the previous generic "inject_prompt failed"
- Applied to all 7 inject_prompt callsites in fleetcrown-daemon.sh
A2. Match agents by cwd, not just by tab name
- New _resolve_live_tab_by_cwd() walks zellij dump-layout, reconstructs
each pane's absolute cwd from the layout-level cwd + pane cwd, and
returns the tab whose pane is rooted in the target project_dir
- inject_prompt() takes an optional project_dir 3rd arg; when the
name match fails (revampit vs Revamp-It vs revamp-it kind of bug),
the cwd fallback fires
- Daemon callsites thread project_dir through. Fixes the revampit
dispatch we observed.
A3. Same-machine fast path
- home/server.ts gains POST /api/inject. Spawns bash, sources
agent-hook-lib.sh, calls inject_prompt directly. Returns
{ok:true} or {ok:false, reason}. Binds 127.0.0.1 only so the
LAN cannot reach it.
- CORS allow-list permits https://fleetcrown.vercel.app and the local
dev origins — every other origin's browser blocks the response.
- src/hooks/use-control-data.ts::inject() tries the local fast path
first with a 600ms abort timeout. Success returns; failure with a
reason re-throws (caller renders); no-daemon falls through to the
cloud path silently.
- Result: 7 hops (browser → Vercel → DB → daemon poll → exec → focus
→ write) collapse to 3 (browser → home → exec) for the common case.
Reliability follows from deletion.
Bonus: home/projects.ts::resolveProjectPath() now does a loose match
(strip hyphens + underscores) when the literal lookup misses. Lets the
cloud send "revampit" find the conf entry "revamp-it" without forcing a
rebrand. Tested with revampit; injection lands.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Every dispatch out of /api/dispatch was defaulting to 'claude' because
the caller (the UI Dispatch button) doesn't send an adapter, the
project state doesn't carry one, and the brain had no other source.
Projects that should run codex or gemini (e.g. anything cross-checking
a Claude session, or codex for OpenClaw) silently got the wrong agent.
Extended agent-projects.conf with an optional 3rd pipe-separated field:
Cockpit|/home/g/dev/cockpit
OrangeCat|/home/g/dev/orangecat|codex
Two-field entries keep their semantics (adapter stays undefined →
downstream defaults to claude, same as before). The 3rd field is
validated against @/lib/events ADAPTERS — unknown values silently
degrade to undefined so a typo doesn't poison dispatches.
Files touched:
• home/projects.ts: ProjectConfig grows an optional adapter field,
loader parses the 3rd column, new resolveProjectAdapter() helper.
• home/server.ts: /api/dispatch adapter resolution now does
caller-body ?? resolveProjectAdapter(project) ?? undefined; worker
keeps defaulting to claude when both are absent.
• home/README.md: files table updated to reflect the new format.
home/projects 11/11 (was 7) — four new cases cover the codex 3rd
field, resolveProjectAdapter, two-field entries staying undefined,
and the unknown-adapter typo-defence path. Full suite: 82/82
across the eight home/ modules. tsc clean, eslint clean.
The renderer was falling back to the project name when no projectPath was
supplied to POST /api/dispatch, producing "Work on the project at Cockpit"
instead of the real path. Meanwhile the existing system has been keeping
the tab-name → directory mapping in ~/.config/agent-projects.conf for a
while — the new home/ system just wasn't reading it.
home/projects.ts:
- projectsConfPath() resolves APP_PROJECTS_CONF / legacy env
names / default ~/.config/agent-projects.conf
- loadProjects(confPath?) parses "name|path" lines, skips comments,
returns a Map keyed by lowercase name
- resolveProjectPath(name) case-insensitive lookup
home/server.ts: when POST /api/dispatch doesn't carry an explicit
projectPath, falls back to resolveProjectPath(projectName) before invoking
the renderer. Caller-supplied still wins so test harnesses + alt routes
keep working.
Self-test (npx tsx home/projects.ts): 7/7
✓ loads valid entries, skips comments + malformed lines
✓ case-insensitive lookup (uppercase + lowercase + mixed)
✓ tab names with embedded spaces resolve
✓ unknown project returns undefined (no throw)
✓ preserves display-case in ProjectConfig.name
✓ missing conf file returns empty map without throwing
Other suites still green: worker 6/6, decide 9/9, render 12/12.
The home/ stack now produces correct project-rooted prompts for every
intent. After M9's live exercise, the renderer will print real paths
instead of the project-name fallback.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>