Skip to content

Plugin System Phase 1: Runtime Slot (#9) - #20

Merged
tu11aa merged 31 commits into
developfrom
feature/runtime-plugin-slot
Apr 21, 2026
Merged

Plugin System Phase 1: Runtime Slot (#9)#20
tu11aa merged 31 commits into
developfrom
feature/runtime-plugin-slot

Conversation

@tu11aa

@tu11aa tu11aa commented Apr 21, 2026

Copy link
Copy Markdown
Owner

Summary

Phase 1 of issue #9 (Plugin/Extension System). Abstracts cmux behind a RuntimeDriver interface mirroring the existing src/drivers/ agent driver pattern, and exposes runtime ops via cockpit runtime <op> CLI so bash scripts no longer hardcode the cmux binary.

Closes the largest coupling point identified in the plugin system brainstorm (cmux-threaded through every script). Next phases (workspace/tracker/notifier slots, external plugin loading) remain deferred per spec §Non-Goals.

Spec: docs/specs/2026-04-20-plugin-system-runtime-design.md
Plan: docs/specs/2026-04-20-plugin-system-runtime-plan.md

What changed

New:

  • src/runtimes/types.tsRuntimeDriver interface + types (WorkspaceRef, RuntimeSpawnOptions, RuntimeProbeResult)
  • src/runtimes/cmux.tscreateCmuxDriver() — cmux-backed impl extracted from scattered call-sites
  • src/runtimes/registry.tsRuntimeRegistry with forProject / global / probeAll
  • src/runtimes/index.ts + tests (12 cmux tests, 6 registry tests)
  • src/commands/runtime.tscockpit runtime status|send|send-key|list|read-screen|stop

Migrated to driver:

  • src/commands/launch.ts — uses RuntimeRegistry (retains 3 bounded execSync calls for select-workspace/current-workspace; phase-1 exception documented in spec §Non-Goals)
  • src/commands/shutdown.ts — full rewrite via registry
  • src/commands/doctor.ts — now probes configured runtimes instead of hardcoded cmux check; supports per-project overrides
  • scripts/execute-reaction.sh — all cmux calls → cockpit runtime send/status; 0 \$CMUX refs remain
  • scripts/spawn-workspace.sh — existence-check block migrated; spawn block intentionally deferred

Config (backward compatible):

  • runtime?: string at top level (global default, absent = cmux)
  • runtime?: string per-project (overrides top-level)

Doc updates:

  • README.md — commands table + config JSON example + Runtime Abstraction architecture note

Contract highlights

  • RuntimeDriver.send() delivers AND commits (Enter). CmuxDriver pairs cmux send with cmux send-key Enter internally. Bash callers that previously did both explicitly now call cockpit runtime send once.
  • status() returns WorkspaceRef | null — replaces the fragile grep-list-workspaces-and-check-empty-string pattern.

Test plan

  • npm run test -- --run — 56 pass (2 pre-existing config.test.ts failures unrelated to this PR — emoji assertion mismatch that predates this work)
  • npm run lint exits 0
  • npm run build exits 0
  • cockpit doctor shows new "Runtime 'cmux' installed" check
  • cockpit runtime --help shows 6 subcommands
  • cockpit runtime list returns live workspaces
  • Manual smoke: cockpit launch + "New day" force-fresh path (tested by reviewer)
  • Manual smoke: reactor auto-fix-ci dispatch via migrated execute-reaction.sh

Pre-PR code review

Internal review flagged one landmine — cockpit runtime send --command foo bar would silently bind foo as target and discard bar. Fixed in commit d1bdda2 with an explicit guard. Other reviewer notes (regex fragility in parseList, shell-injection surface in escape, partial-send atomicity, buildRegistry duplication) are tracked as phase-2 follow-ups per spec scope.

Follow-ups (explicitly out of scope)

  • Workspace / tracker / notifier slots (phase 2)
  • External plugin loading from node_modules (phase 3)
  • tmux / Docker / SSH runtime drivers (each its own PR)
  • select-workspace / current-workspace abstraction
  • Full bash→TS rewrite of spawn-workspace.sh

tu11aa added 30 commits April 20, 2026 19:49
Abstract cmux behind a RuntimeDriver interface mirroring the existing
AgentDriver pattern. Phase 1 of issue #9 — extracts current cmux usage
across bash/TS, exposes ops via `cockpit runtime` CLI subcommand, adds
optional per-project runtime override to config.

Defers workspace/tracker/notifier slots and external plugin loading to
later phases.
15-task plan for plugin system phase 1 — runtime abstraction. TDD flow
for CmuxDriver + RuntimeRegistry, incremental migration of launch.ts,
shutdown.ts, doctor.ts, execute-reaction.sh, spawn-workspace.sh.
Prevents silent-wrong-send when user does 'cockpit runtime send --command foo bar':
commander was binding foo as target and bar as message, then the action
silently discarded one. Now errors with a clear message.

Flagged by pre-PR code review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant