Skip to content

feat(#368): extract AgentDriver and PlatformProvider interfaces - #379

Merged
admarble merged 6 commits into
mainfrom
feature/368-extract-agentdriver-interface-from-phase-executor-
Mar 22, 2026
Merged

admarble merged 6 commits into
mainfrom
feature/368-extract-agentdriver-interface-from-phase-executor-

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

Pre-PR AC Verification

AC Source Description Status Evidence
AC-1 Original AgentDriver interface defined ✅ drivers/agent-driver.ts
AC-2 Original Interface exposes name, executePhase(), isAvailable() ✅ drivers/agent-driver.ts:39-56
AC-3 Original ClaudeCodeDriver wraps query() — no behavior change ✅ drivers/claude-code.ts
AC-4 Original phase-executor.ts uses interface, not SDK directly ✅ No SDK import in phase-executor.ts
AC-5 Original ExecutionConfig.agent field (default: "claude-code") ✅ types.ts:58-62
AC-6 Original CLI --agent option wired ✅ bin/cli.ts, verified with --help
AC-7 Original Driver registry (simple map) ✅ drivers/index.ts
AC-8 Original All existing tests pass unchanged ✅ 1577 passed (same baseline)
AC-9 Original SDK import only in ClaudeCodeDriver ✅ grep confirms
AC-10 Original PlatformProvider interface defined ✅ platforms/platform-provider.ts
AC-11 Original GitHubProvider wraps gh CLI calls ✅ platforms/github.ts
AC-12 Original gh calls consolidated (orchestration layer) ⚠️ Partial GitHubProvider implemented; consuming files not yet migrated to use it (deferred — scope note in spec)
AC-13 Original ExecutionConfig.platform field (default: "github") ✅ types.ts:63-67
AC-14 Original Platform registry (simple map) ✅ platforms/index.ts
AC-15 Original CLI --platform option wired ✅ bin/cli.ts, verified with --help

Test Coverage

Changed File Tier Has Tests?
drivers/agent-driver.ts Standard Types only
drivers/claude-code.ts Critical ✅ claude-code.test.ts
drivers/index.ts Standard ✅ index.test.ts
platforms/platform-provider.ts Standard Types only
platforms/github.ts Critical ✅ github.test.ts
platforms/index.ts Standard ✅ index.test.ts
phase-executor.ts Critical ✅ Existing run.test.ts (unchanged)

Quality Gates

  • ✅ npm run build — 0 errors
  • ✅ npm run lint — 0 errors, 0 warnings
  • ✅ npm test — 1577 passed (2 pre-existing failures in doctor.test.ts)

Closes #368

🤖 Generated with Claude Code

Extract two interfaces that decouple workflow orchestration from
(a) agent execution and (b) platform operations:

- AgentDriver interface in src/lib/workflow/drivers/agent-driver.ts
- ClaudeCodeDriver wraps existing query() call — no behavior change
- Driver registry with getDriver() in drivers/index.ts
- PlatformProvider interface in src/lib/workflow/platforms/platform-provider.ts
- GitHubProvider wraps existing gh CLI calls — no behavior change
- Platform registry with getPlatform() in platforms/index.ts
- phase-executor.ts now uses AgentDriver interface (no SDK import)
- --agent and --platform CLI flags for sequant run
- ExecutionConfig.agent and ExecutionConfig.platform fields
- Unit tests for driver registry, platform registry, ClaudeCodeDriver, GitHubProvider

Pure refactor — all existing tests pass unchanged.

Closes #368

Entire-Checkpoint: e99199aa159d
Migrate all orchestration-layer gh CLI calls into GitHubProvider:
- phase-detection.ts: 3 execSync("gh issue view...") → GitHubProvider.fetchIssueCommentBodiesSync()
- pr-status.ts: spawnSync("gh pr view...") → GitHubProvider.getPRMergeStatusSync()
- system.ts: execSync("gh auth status") → GitHubProvider.checkAuthSync()
- doctor.ts: execSync("gh issue list...") → GitHubProvider.listClosedIssuesSync()
- worktree-manager.ts: 4 spawnSync("gh",...) → GitHubProvider.viewPRByBranchSync() + createPRCliSync()

This completes AC-12 (gh calls consolidated). All gh CLI calls in src/
now live exclusively in platforms/github.ts.

Entire-Checkpoint: 61a587bf7624
- Remove --platform CLI flag, ExecutionConfig.platform, and RunOptions.platform
  since getPlatform() is never called by production code (YAGNI)
- Convert 4 execSync template-string calls in GitHubProvider to spawnSync with
  array args to eliminate command injection pattern
- Update test mocks to match spawnSync usage (phase-detection, doctor,
  run-resume, github provider tests)
- Add sessionId to AgentExecutionConfig for driver-level session resume
- ClaudeCodeDriver passes resume: config.sessionId to query() when set
- phase-executor restores canResume safety guard (no resume when worktree
  isolation active — prevents SDK crash from cwd mismatch)
- Add getPRHeadBranchSync to GitHubProvider for PR branch lookup
- Hook pre-tool.sh now calls GitHubProvider via scripts/pr-head-branch.ts
  with fallback to direct gh CLI
Hook pre-tool.sh calls gh directly (not via GitHubProvider) because
hooks are bash with strict latency requirements — a TypeScript bridge
adds ~1-2s overhead for no functional benefit. GitHubProvider has the
equivalent method (getPRHeadBranchSync) for TypeScript callers.

Same exclusion rationale as skills (see Non-Goals in #368).
@admarble
admarble force-pushed the feature/368-extract-agentdriver-interface-from-phase-executor- branch from c21248f to 3ea0225 Compare March 22, 2026 23:53
@admarble
admarble merged commit 781ae03 into main Mar 22, 2026
6 checks passed
@admarble
admarble deleted the feature/368-extract-agentdriver-interface-from-phase-executor- branch March 22, 2026 23:53
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.

Extract AgentDriver interface from phase-executor.ts

1 participant