Skip to content

feat(phase-1): agent-ctl core + Claude Code adapter#1

Merged
c-h- merged 1 commit intomainfrom
feat/phase-1-core
Feb 16, 2026
Merged

feat(phase-1): agent-ctl core + Claude Code adapter#1
c-h- merged 1 commit intomainfrom
feat/phase-1-core

Conversation

@c-h-
Copy link
Copy Markdown
Collaborator

@c-h- c-h- commented Feb 16, 2026

Summary

  • Implements Phase 1 of the agent-ctl spec: core types, Claude Code adapter, and CLI
  • The adapter reads session data directly from ~/.claude/projects/ and cross-references with running PIDs via ps/lsofzero file-based registry
  • CLI provides: list, peek, stop, status, launch, resume, events commands
  • 14 unit tests passing (vitest) with injectable test fixtures

Key Design Decisions

  • Adapter constructor accepts claudeDir and getPids overrides for testability
  • Session discovery uses sessions-index.json when available, falls back to scanning .jsonl files for active sessions not yet indexed
  • PID detection parses ps aux for claude --* processes, extracts cwd via /usr/sbin/lsof
  • Prefix matching on session IDs (use first 8 chars)

Test plan

  • npx tsc --noEmit — clean type-check
  • npx vitest run — 14/14 tests pass
  • agent-ctl list — shows running sessions with correct PID/model/cwd
  • agent-ctl peek <id> — shows recent assistant output
  • agent-ctl status <id> — shows session details with token counts
  • agent-ctl list --json — machine-readable output
  • agent-ctl list -a — includes stopped sessions

🤖 Generated with Claude Code

- Core types: AgentAdapter, AgentSession, LifecycleEvent interfaces
- Claude Code adapter: reads session data directly from ~/.claude/
  - list: discovers sessions from sessions-index.json + fallback JSONL scan
  - peek: extracts recent assistant messages from JSONL conversation logs
  - status: cross-references session data with running PIDs via ps/lsof
  - stop: sends SIGTERM (or SIGINT+SIGKILL with --force) to claude processes
  - launch: spawns claude with --print --stream-json flags
  - resume: uses claude --continue to resume sessions
  - events: polls for session lifecycle changes, emits NDJSON events
- CLI: list, peek, stop, status, launch, resume, events commands
  - Human-friendly table output by default, --json for machine consumption
  - Prefix matching for session IDs (e.g. first 8 chars)
- Zero file-based registry: all state derived from native Claude Code data + PIDs
- 14 unit tests passing (vitest)

Co-Authored-By: Charlie Hulcher <charlie.hulcher@gmail.com>
@c-h- c-h- marked this pull request as ready for review February 16, 2026 19:04
@c-h- c-h- merged commit 215baff into main Feb 16, 2026
c-h- added a commit that referenced this pull request Feb 20, 2026
feat(phase-1): agent-ctl core + Claude Code adapter
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