Multi-Agent Chat Extension Development
Expert guidance for working with the Multi-Agent Chat VS Code extension codebase - a collaborative AI team interface with specialized agents for software development.
Project Context
You are working on **Multi Agent Chat** (v1.16.1), a VS Code extension providing a collaborative AI team interface with 7 specialized agents:
**Architect** - System design and architecture**Coder** - Implementation and code writing**Executor** - Command execution and deployment**Reviewer** - Code review and quality**Documenter** - Documentation writing**Coordinator** - Task delegation and workflow**Team** - Multi-agent collaboration orchestrator**Repository:** craig-yappert/multi-agent-chat-extension
Development Workflow
1. Setup and Compilation
When starting work:
```bash
Install dependencies
npm install
Compile TypeScript
npm run compile
Watch mode for active development
npm run watch
```
2. Testing the Extension
**Debug Mode:**
Press `F5` in VS Code to launch Extension Development HostUse "Run Extension" configuration in VS Code debuggerTest all commands via `Ctrl+Shift+P` → "Multi Agent Chat: ..."**Build Package:**
```bash
npx vsce package --no-dependencies
```
3. Key Extension Commands
`Open Multi Agent Chat` - Main interface`Manage API Keys` - Secure API key management (v1.15.1+)`Initialize Multi Agent Chat Project` - Create .machat folder`Open Models Configuration` - Edit project model list`Open Agents Configuration` - Edit agent definitions`Update from Defaults` - Smart sync models/agents (v1.16.1)`Reload Model Configurations` - Refresh without restartArchitecture Deep Dive
Configuration System (v1.15.0+)
**ConfigurationRegistry** (`src/config/ConfigurationRegistry.ts`)
Two-tier loading: bundled defaults → project overrides`defaults/models.json` - 28+ models across 6 providers`defaults/agents.json` - 7 agent definitions`.machat/models.json` - Project-specific models (optional)`.machat/agents.json` - Project-specific agent customization (optional)Provider Architecture (v1.16.0)
**3-Tier Provider System:**
1. **VS Code LM API** - GitHub Copilot, Continue.dev integration
2. **Direct HTTP** - OpenAI, Google Gemini, xAI Grok
3. **Claude CLI** - Legacy Claude Max support
**Provider Files:**
`src/providers/ProviderRegistry.ts` - Selection logic`src/providers/VSCodeLMProvider.ts` - VS Code Language Model API`src/providers/HttpProvider.ts` - Base HTTP provider`src/providers/OpenAIHttpProvider.ts` - OpenAI & xAI`src/providers/GoogleHttpProvider.ts` - Google Gemini**Provider Preference Setting:**
`claude-cli` - Prefer Claude CLI (Max subscribers)`auto` - Auto-detect (VS Code LM → HTTP → CLI)`vscode-lm` - Only VS Code Language Model API`direct-api` - Only direct HTTP APIsAgent System
**Agent Configuration:**
Agents loaded from JSON via ConfigurationRegistryEach agent: provider, model, specializations, system promptProject-specific customization via `.machat/agents.json`Custom prompts as Markdown: `.machat/agents/agent-prompts/<agent-id>.md`**Inter-Agent Communication:**
`src/agentCommunication.ts` - Message routing hub`@mention` support for agent collaborationLoop prevention (max depth 3, 50 messages per conversation)Live inter-agent message display in UIStorage and Context
**Conversation Storage:**
Project-local: `.machat/conversations/`Global fallback for non-project contextsAutomatic migration utilities**Project Context:**
Agent memory isolation per projectContext scoping prevents cross-project bleeding`.machat/context/` - Agent memory & knowledge baseKey Development Tasks
Adding a New Provider
See `docs/ADDING_PROVIDERS.md` for comprehensive guide.
**Quick steps:**
1. Add provider config to `defaults/providers.json`
2. Create provider class extending `HttpProvider`
3. Implement `callModel()` method
4. Register in `ProviderRegistry.ts`
5. Update model configurations
Customizing Agent Behavior
**Via JSON** (`.machat/agents.json`):
```json
{
"coder": {
"provider": "openai",
"model": "gpt-4",
"systemPrompt": "Custom system prompt..."
}
}
```
**Via Markdown** (`.machat/agents/agent-prompts/coder.md`):
```markdown
Project Coding Standards
TypeScript Requirements
Always use strict modePrefer `interface` over `type`Testing
Write Jest tests for all new functionsAim for 80%+ code coverage```
Benefits of Markdown:
Richer formattingNo JSON escapingGit-friendly diffsLayered approach (core + project customization)Managing Settings
**Settings Hierarchy:**
1. VS Code settings (lowest priority)
2. Global settings
3. Project settings (`.machat/config.json`)
4. Workspace settings (highest priority)
**Key Settings:**
`multiAgentChat.providerPreference` - Provider selection strategy`multiAgentChat.defaultModel` - Default AI model`multiAgentChat.agents.enableInterCommunication` - Agent collaboration`multiAgentChat.performance.enableStreaming` - Response streaming`multiAgentChat.performance.quickTeamMode` - Use 3 agents vs 6Security Best Practices
**API Key Management (v1.15.1+):**
Use VS Code SecretStorage API (encrypted, OS-level)Never store keys in settings.json or project filesCommand: `Manage API Keys` for interactive setupAuto-migration from old settingsImportant Implementation Notes
Model Awareness (v1.16.1)
Agents receive detailed model information in system prompts:
Display name + model ID in promptModel descriptions for better contextConfigurationRegistry integration with ProviderManagerNo hardcoded model IDs - always use registrySafe Initialization (v1.16.1)
`initializeProject` behavior:
Creates missing files only (never overwrites)Copies `models.json` and `agents.json` from defaults"Update from Defaults" command for explicit syncSmart picker shows relevant options based on existing filesPerformance Optimization
**Caching:** 5-minute TTL response cache
**Streaming:** Faster user feedback
**Quick Team Mode:** 3 agents instead of 6
**Timeouts:** Configurable per agent
File Structure Reference
```
src/
├── settings/ # Settings management
├── conversations/ # Conversation storage
├── context/ # Project context
├── config/ # Model configurations
├── providers/ # Provider implementations
├── ui/ # Settings UI panel
├── agents.ts # Agent definitions
├── extension.ts # Main controller
├── agentCommunication.ts # Inter-agent messaging
├── performanceOptimizer.ts # Caching & optimization
defaults/
├── models.json # Model definitions
├── agents.json # Agent definitions
└── providers.json # Provider configs
.machat/ (in user projects)
├── config.json # Project settings
├── models.json # Project models (optional)
├── agents.json # Project agents (optional)
├── agents/agent-prompts/ # Custom prompts (Markdown)
├── conversations/ # Local conversations
└── context/ # Agent memory
docs/
├── USER_GUIDE_PROVIDERS.md # Provider setup
└── ADDING_PROVIDERS.md # Developer guide
```
Common Development Patterns
When Working on Agent Logic
1. Check `src/agents.ts` for agent definitions
2. Verify ConfigurationRegistry integration
3. Test with different models and providers
4. Validate inter-agent communication routing
5. Check loop prevention (depth and message limits)
When Adding Features
1. Update relevant configuration files (models.json, agents.json, providers.json)
2. Implement core logic in appropriate module
3. Add settings if needed (`package.json` contribution points)
4. Update UI (`resources/webview/`)
5. Test across different provider modes
6. Update documentation
When Debugging Issues
1. Check Extension Development Host console
2. Verify provider selection logic in ProviderRegistry
3. Check agent communication routing
4. Validate settings hierarchy resolution
5. Review conversation storage paths
6. Check API key SecretStorage migration
Best Practices
**Always use ConfigurationRegistry** for model/agent data - no hardcoded IDs**Preserve backward compatibility** - existing setups should work unchanged**Test with multiple providers** - Claude CLI, VS Code LM, HTTP APIs**Respect settings hierarchy** - project overrides global**Use TypeScript strict mode** - maintain type safety**Document breaking changes** - update CLAUDE.md and version notes**Validate JSON schemas** - models.json and agents.json must be valid**Test auto-initialization** - verify safe file creation logicCommon Issues and Solutions
**Issue:** Agent responses show wrong icon/name
**Solution:** Check `onPartialResponse` callback inheritance - strip for inter-agent responses
**Issue:** Models not loading
**Solution:** Run "Reload Model Configurations" command or restart VS Code
**Issue:** API keys not working
**Solution:** Use "Manage API Keys" command - old settings.json keys are deprecated
**Issue:** Provider not found
**Solution:** Check `providerPreference` setting and provider availability
Documentation References
**Provider Setup:** `docs/USER_GUIDE_PROVIDERS.md`**Adding Providers:** `docs/ADDING_PROVIDERS.md`**Extension Manifest:** `package.json`**Change History:** See CLAUDE.md recent changes section