fix(persona-kit): repair opencode one-shot invocation

Merged
KH
3mo ago
+43-5

Closes #269

Summary

  • stop passing unsupported --dir to opencode run; the runtime already spawns the child with the requested cwd
  • stop overriding the generated persona agent model with the CLI --model flag
  • normalize bare OpenCode persona model IDs to opencode/<model> in the generated opencode.json agent config while preserving already-qualified values
  • add regression coverage using a truthy working directory and bare deepseek-v4-flash-free model

Why

The non-interactive path was adding two stale CLI arguments after buildInteractiveSpec had already moved OpenCode model selection into opencode.json. Current OpenCode rejects --dir, and its --model parser requires provider/model values. The child process already receives cwd through spawnAndCapture, while the generated agent config carries the persona model selected by --agent. Since OpenCode agent configs also require provider/model-id, bare model IDs are normalized to the harness provider before serialization.

Validation

  • pnpm --filter @agentworkforce/persona-kit test (287 passed)
  • pnpm --filter @agentworkforce/persona-kit lint
  • pnpm --filter @agentworkforce/persona-kit typecheck

Downstream note

The daytona-monitor, cloudflare-monitor, gcp-watcher, and neon-monitor personas in AgentWorkforce/agents use the OpenCode harness with bare model strings. Before this fix, they would be exposed to the same invalid provider/model resolution on affected OpenCode versions; this PR does not modify that repository.