ai-devkit icon indicating copy to clipboard operation
ai-devkit copied to clipboard

perf(agent-manager): pass canHandle as isCandidate in adapters' standalone captureProcessSnapshot calls

Open codeaholicguy opened this issue 2 months ago • 0 comments

Problem

#266 lets captureProcessSnapshot take an isCandidate predicate, so lsof / ps lstart enrichment runs only for PIDs an adapter can handle. AgentManager.listAgents passes it. But 8 adapter call sites call captureProcessSnapshot(this.processNames) without a predicate when they run standalone, without the shared context:

  • Claude, Codex, Copilot, Gemini, Grok, Kiro, OpenCode and Pi detectAgents / helper methods;
  • Antigravity too, after #257.

For the adapters that declare "node" in processNames (Gemini, Kiro, Pi), a standalone call still enriches every Node.js process on the machine.

Proposed approach

Where each adapter falls back to capturing its own snapshot, pass { isCandidate: (p) => this.canHandle(p) }. Keep the parent-process data that wrapper handling needs (see the Kiro notes in #266: processes that don't pass canHandle are still returned, just not enriched).

Acceptance criteria

  • [ ] Every adapter's fallback captureProcessSnapshot call passes an isCandidate predicate based on its canHandle.
  • [ ] A test per adapter family (at least one node-based adapter) shows that with unrelated node processes in the snapshot, lsof / ps lstart receive only the adapter's candidate PIDs when called standalone.
  • [ ] Detection results are unchanged (existing tests pass, including Kiro's parent-chain and Gemini/Pi wrapper handling).

Depends on #266.

codeaholicguy avatar Sep 28 '26 11:09 codeaholicguy