Skip to content

feat: add ACP transport for cross-tool consultations#6

Merged
avifenesh merged 4 commits intomainfrom
feature/acp-native-281
Mar 2, 2026
Merged

feat: add ACP transport for cross-tool consultations#6
avifenesh merged 4 commits intomainfrom
feature/acp-native-281

Conversation

@avifenesh
Copy link
Contributor

Summary

  • Add ACP (Agent Client Protocol) as an additional transport alongside existing CLI subprocess invocation
  • ACP provides standardized JSON-RPC 2.0 communication supported by all major AI coding tools (Claude, Gemini, Codex, Copilot, Kiro, OpenCode)
  • Auto-detect ACP availability per provider, prefer when available, fall back to CLI
  • Add Kiro as a new consultation target (ACP-only provider)

Changes

New files (acp/)

  • acp/client.js - AcpClient JSON-RPC 2.0 class: spawn, initialize, session, prompt, streaming chunks, timeout, shutdown
  • acp/providers.js - 6-provider registry with command detection
  • acp/run.js - CLI entry point with --detect mode, output sanitization, path containment

Updated

  • skills/consult/SKILL.md - ACP Transport section, Kiro provider, transport field in session schema
  • commands/consult.md - ACP detection in Phase 2b, kiro in tool allow-list, node/npx/kiro-cli tools
  • agents/consult-agent.md - Extended tool permissions, Kiro in non-continuable list

Tests

  • scripts/test-acp-client.js - 122 tests (mock ACP protocol, provider registry, arg validation, sanitization)
  • scripts/test-command-templates.js - 17 new ACP regression assertions

Security

  • Question-file path containment (reject paths outside cwd)
  • Error messages sanitized through REDACTION_PATTERNS
  • Auto-approve only read/search/think permissions from ACP agents
  • O(N^2) string concat replaced with array+join for chunk accumulation

Test plan

  • npm test passes (122 ACP + template tests)
  • Mock ACP subprocess test covers connect/initialize/session/prompt/close
  • All 6 providers in registry with correct configs
  • Argument validation edge cases (timeout=0, NaN, shell metacharacters)
  • Path containment rejects absolute paths outside cwd

Closes agent-sh/agentsys#281

Add ACP (Agent Client Protocol) as an additional transport alongside
existing CLI subprocess invocation. ACP provides standardized JSON-RPC
2.0 communication supported by all major AI coding tools.

New files:
- acp/client.js: AcpClient class handling spawn, initialize, session,
  prompt, streaming chunk collection, and graceful shutdown
- acp/providers.js: Provider registry mapping tool names to ACP adapter
  configs (claude, gemini, codex, copilot, kiro, opencode)
- acp/run.js: CLI entry point that encapsulates full ACP lifecycle into
  a single Bash-invocable command with --detect mode

Updated:
- SKILL.md: ACP Transport section with provider table, command templates,
  detection, and transport field in session schema
- consult.md: ACP detection in Phase 2b, kiro in tool allow-list
- consult-agent.md: node/npx/kiro-cli tool permissions
- test-command-templates.js: 17 new assertions for ACP provider table,
  command templates, transport selection docs, kiro in tool lists
- test-acp-client.js: 94 tests covering AcpClient constructor, provider
  registry, run.js argument validation, output sanitization patterns,
  module exports, and file existence
- package.json: wire test:acp and test:templates scripts
- Remove excessive inline comments from client.js and run.js
- Fix consult-agent.md: add Kiro to non-continuable list
- Fix test-acp-client.js: replace setTimeout race with proper
  async/await, move IIFE tests into sequential async runner
- Add mock ACP subprocess test (connect, initialize, session,
  prompt, chunk events, close)
- Add missing edge case tests (timeout=0, NaN timeout, leading-dash
  session-id, detectAllAcpSupport, isCommandAvailable positive path)
- Test count: 94 -> 121
Security:
- Sanitize error messages in writeError() (run.js)
- Add question-file path containment check (reject paths outside cwd)

Performance:
- Replace O(N^2) string concat with array+join for chunk accumulation
- Close readline interface on unexpected subprocess exit (resource leak)

Correctness:
- Accept --effort arg in run.js (was hardcoded to 'medium')
- Fix model fallback (was using agentInfo.name as model ID)
- Add .catch handler to test runner (prevent silent crash)
- Add path-containment test case

Test count: 121 -> 122
@avifenesh avifenesh merged commit ae35695 into main Mar 2, 2026
3 checks passed
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.

Make consult and debate ACP-native (cross-platform, cross-agent)

1 participant