New Agent Implementation
You are implementing a new code agent backend for the Lanes VS Code extension.
IRON LAW: Agent Abstraction
When implementing new agents DO NOT add agent specific logic to any files outside of the src/codeAgents/<ClassName>.ts files.
Step 0: Gather information
Ask the user for:
- Agent internal name - lowercase identifier, e.g.
aider - Display name - user-facing label, e.g.
Aider - CLI command - shell command that launches the agent, e.g.
aider - Data directory - where the agent stores config, e.g.
.aider - Logo SVG - inline SVG for the dropdown (ask the user to provide one, or search for the official logo)
Also determine these behavioral traits:
- Hooks: Does the CLI emit lifecycle events (SessionStart, Stop, etc.)? If no, it's "hookless" and needs
captureSessionId()— useCodexAgent.tsas reference. - Prompt passing: Positional argument (
cli 'prompt') or stdin? - MCP support: If yes, how is config delivered — CLI flag, settings file, or
-coverrides? - Permission modes: What flags does the CLI accept? (e.g.
--yes,--yolo,--bypass) - Session ID format: UUID, numeric index, or something else?
- Resume support: Does the CLI support
--resume? What format?
Step 1: Study the base class and a reference agent
Read these files to understand the current abstract contract:
src/codeAgents/CodeAgent.ts— the abstract base class defines all required and optional methods, interfaces, and types. This is the source of truth for what must be implemented.- Pick the closest existing agent as reference:
- Hook-based with MCP via CLI flag:
ClaudeCodeAgent.ts - Hookless with MCP via CLI overrides:
CodexAgent.ts - Hook-based with MCP via settings file:
GeminiAgent.ts - Hook-based without MCP, stdin prompts:
CortexCodeAgent.ts
- Hook-based with MCP via CLI flag:
Step 2: Create the agent class
Create src/codeAgents/<ClassName>.ts using the reference agent from Step 1 as a template. Implement every abstract method from CodeAgent.ts and override optional base class methods as needed based on the agent's capabilities.
Step 3: Register the agent
- Factory (
src/codeAgents/factory.ts): add import and entry toagentConstructorsmap - Barrel (
src/codeAgents/index.ts): add export for the new class - Settings schema (
package.json): add tolanes.defaultAgentenum and enumDescriptions
No UI changes are needed — the dropdown derives from getAvailableAgents() + getAgent() automatically.
Step 4: Write tests
Create src/test/codeAgents/<name>-agent.test.ts following the pattern in an existing test file (e.g. gemini-agent.test.ts). Cover: config values, command building, session/status parsing, permission modes, terminal config, hooks, and MCP.
Constraints
sessionFileExtensionMUST be.claude-sessionandstatusFileExtensionMUST be.claude-status— all agents share these filenames and existing sessions depend on them.- Session IDs MUST be validated against a strict regex before use in shell commands (command injection prevention).
- Prompt text MUST be escaped when embedded in shell commands.
Verification
npm run compile— no TypeScript errorsnpm run lint— no lint errorsnpm test— all tests pass- Manual: create a session with the new agent in Extension Development Host (F5)
Converted and distributed by TomeVault — claim your Tome and manage your conversions.