This document provides a comprehensive analysis of the amp-orchestra repository architecture and implementation roadmap for advanced developer features including interactive chat, environment switching, model configuration, and parallel testing capabilities.
Amp-Orchestra is a monorepo containing a desktop Amp chat interface with sophisticated backend integration capabilities. The architecture follows a modular approach with clear separation between UI (Tauri/React), backend services, and Amp CLI orchestration.
desktop-ui (Tauri/React) → Node Sidecar → @ampsm/amp-client → Amp CLI Binary → Amp Cloud API
packages/
├── amp-client/ # Amp CLI orchestration (complete)
│ ├── auth.ts # Login/version validation
│ ├── client.ts # runIteration(), continueThread(), streaming
│ └── config.ts # Environment/path resolution
├── workspace/ # Git + filesystem helpers (stubs)
│ ├── git/ # Git operations (needs implementation)
│ ├── filesystem/ # FileDiffTracker (todo)
│ └── workspace/ # WorkspaceManager (todo)
└── shared/ # Common utilities (placeholder)
desktop-ui/ # React + Tauri frontend
├── components/
│ ├── FileExplorer.tsx
│ ├── Editor.tsx
│ └── Terminal.tsx
├── contexts/ThemeContext.tsx
└── App.tsx # Three-panel layout
The system uses sophisticated environment detection:
Production Mode:
- Uses
ampcommand from system PATH - Connects to Amp Cloud API
- Standard authentication flow
Development Mode:
- Uses custom CLI binary path (e.g.,
./bin/amp-dev) - Can override with
AMP_CLI_PATHenvironment variable - Optional local server via
AMP_URL=https://localhost:7002
- Environment-driven via
AMP_TOKEN,AMP_AUTH_CMD ensureAmpAuth()validates CLI accessibility- Version checking with
amp --version - Token redaction for security
The client streams JSONL events:
assistant_message- Chat responsestoken_usage- Usage metricstool_start/tool_finish- Tool execution telemetrysession_result- Final results
SessionManager
class SessionManager {
private sessions: Map<string, AmpClient> = new Map();
async createSession(config: SessionConfig): Promise<string>
async sendMessage(sessionId: string, prompt: string): Promise<void>
streamEvents(sessionId: string): EventEmitter
async stopSession(sessionId: string): Promise<void>
}IPC Events
chat/send- {sessionId, prompt}chat/stream- Server-sent events for real-time updateschat/stop- Process terminationsession/create- New chat sessionsession/list- Active sessions
- First Message: SessionManager calls
client.runIteration() - Follow-ups: Uses
continueThread()with persistent threadId - Working Directory: Defaults to workspace root or specified worktree
- Streaming: Real-time event forwarding to UI
Environment Options:
| Option | Configuration |
|---|---|
| Production | { ampCliPath: "production" } |
| Local CLI | { ampCliPath: "/path/to/amp-local" } |
| Local Server | { ampServerUrl: "https://localhost:7002" } |
Settings UI:
- Environment dropdown in main toolbar
- Validation with visual feedback
- Session restart on environment change
- Persistent configuration storage
interface EnvironmentConfig {
name: string;
ampCliPath?: string;
ampServerUrl?: string;
authMethod?: 'token' | 'command';
}
// Existing amp-client automatically handles these configurations
// via getAmpEnvironment() and getAmpCliPath()Model Selector:
- Header dropdown: "Model: (default) / gpt-4 / claude-3 / ..."
- Per-session model override
- Real-time switching capability
Advanced Combinations Panel:
- Multi-model selection
- Batch run configuration
- Custom model parameters
Extend existing modelOverride parameter:
// Current: limited to "gpt-5", "glm-4.5"
// Enhanced: generic model passing
if (modelOverride) {
args.push("--try-model", modelOverride);
}WorktreeManager
class WorktreeManager {
async createWorktree(baseSha: string, branchName: string): Promise<string>
async cleanup(branchName: string): Promise<void>
listWorktrees(): Promise<Worktree[]>
}BatchRunner
interface BatchConfig {
prompt: string;
combinations: Array<{
model: string;
branchPointSha?: string;
customArgs?: string[];
}>;
}
class BatchRunner {
async runBatch(config: BatchConfig): Promise<BatchResult[]>
async getBatchHistory(): Promise<BatchResult[]>
}- Worktree Creation: Use
git worktree add --detachfor isolation - Parallel Execution:
Promise.allSettledwith CPU-bounded concurrency - Result Aggregation: Collect metrics, diffs, and telemetry
- Persistence: Store results in
batch-results/*.json
Benchmark Dashboard:
- Results table: combination | success | tokens | duration | diff
- Historical comparison
- Export capabilities
- Progress indicators for running batches
{
"defaultEnvironment": "production",
"customCliPath": "/path/to/amp-dev",
"localServerUrl": "https://localhost:7002",
"theme": "dark",
"recentWorkspaces": ["/path/to/project1", "/path/to/project2"],
"modelPreferences": {
"default": "gpt-4",
"coding": "claude-3",
"analysis": "gpt-4-turbo"
},
"batchSettings": {
"maxConcurrency": 4,
"timeout": 300000
}
}Location: ~/.config/amp-orchestra/config.json
Management: ConfigStore with IPC synchronization
Backup: Automatic versioning for recovery
- OS keychain integration for token storage
- Environment variable redaction in logs
- Secure IPC communication
- Session limits to prevent resource exhaustion
- Graceful cleanup of child processes
- Sandbox worktree operations
- Configuration file encryption for sensitive data
- Audit logging for environment switches
- Secure cleanup of temporary files
- Connection pooling for Amp CLI instances
- Efficient streaming buffer management
- Worktree cleanup automation
- Background processing for heavy operations
- Progressive loading of large result sets
- Debounced configuration updates
- Mock Amp CLI responses
- Configuration validation
- Session lifecycle management
- End-to-end chat flows
- Environment switching scenarios
- Batch run execution
- Concurrent session handling
- Large file processing
- Memory usage monitoring
- Implement missing workspace/git utilities
- Create Node sidecar process with SessionManager
- Wire live streaming UI to backend
- Basic chat functionality
- Environment switching UI
- Model selector implementation
- Configuration persistence
- Enhanced error handling
- Batch runner implementation
- Benchmark dashboard
- Advanced configuration options
- Performance optimizations
- Problem: Multiple Amp processes consuming resources
- Solution: Session limits and queuing system
- Problem: Worktree disk bloat
- Solution: Automated cleanup with
git worktree prune
- Problem: Production/development confusion
- Solution: Clear visual indicators and confirmation dialogs
- Problem: Invalid JSON in streaming data
- Solution: Robust parsing with error recovery
Amp-Orchestra provides a solid foundation with its existing CLI wrapper and streaming capabilities. The proposed architecture leverages these strengths while adding the sophisticated features needed for advanced development workflows.
The implementation roadmap prioritizes core functionality first, then builds advanced features incrementally. This approach ensures a stable base while enabling powerful developer tools for model experimentation, environment management, and automated testing workflows.
The modular design allows for independent development of features while maintaining clean integration points and consistent user experience across all components.