Skip to content

Generalize process-to-session mapping for CLI agent adapters#45

Merged
codeaholicguy merged 5 commits intomainfrom
feature-generalize-session-mapping
Mar 20, 2026
Merged

Generalize process-to-session mapping for CLI agent adapters#45
codeaholicguy merged 5 commits intomainfrom
feature-generalize-session-mapping

Conversation

@codeaholicguy
Copy link
Owner

Summary

  • Extract shared process detection, session matching, and agent naming into reusable utilities (utils/process.ts, utils/session.ts, utils/matching.ts) so no adapter calls execSync directly
  • Refactor ClaudeCodeAdapter and CodexAdapter to use shared utilities while keeping adapter-specific logic (session dir scanning, JSONL parsing, status determination)
  • Implement 1:1 greedy matching algorithm that pairs processes to sessions by CWD match + closest birthtime-to-start-time delta (3min tolerance)

Motivation

Both adapters duplicated ~70% of their logic: process discovery via ps aux, CWD lookup via lsof, start time calculation, session scanning, multi-pass matching, and agent naming. Adding a new CLI agent required rewriting all of this. Shell calls were scattered inside each adapter and not batched.

@codeaholicguy codeaholicguy merged commit c84735c into main Mar 20, 2026
1 check passed
@codeaholicguy codeaholicguy deleted the feature-generalize-session-mapping branch March 20, 2026 16:29
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