fleetcode/AMP_INTEGRATION.md

173 lines
4.2 KiB
Markdown

# Amp Integration in FleetCode
Amp has been added as a coding agent option in FleetCode, alongside Claude and Codex.
## What Changed
### Files Modified
1. **[index.html](file:///home/anish/usr/FleetCode/index.html)** - Added Amp to the coding agent dropdown
2. **[server.ts](file:///home/anish/usr/FleetCode/server.ts)** - Added Amp command execution
3. **[main.ts](file:///home/anish/usr/FleetCode/main.ts)** - Added Amp support for Electron mode
4. **[renderer.ts](file:///home/anish/usr/FleetCode/renderer.ts)** - Updated UI logic for Amp
5. **[README.md](file:///home/anish/usr/FleetCode/README.md)** - Updated documentation
## How It Works
When you select "Amp" as your coding agent and create a session:
1. FleetCode creates a new git worktree for the session
2. Spawns a terminal (PTY) in that worktree
3. Runs any setup commands you configured
4. Executes `amp` command in the terminal
## Using Amp
### Prerequisites
Amp is run via `npx` and doesn't need to be installed system-wide:
```bash
# Amp is run using:
nix shell nixpkgs#nodejs -c npx -y @sourcegraph/amp
# This automatically:
# - Provides Node.js via Nix
# - Downloads and runs the latest @sourcegraph/amp package
```
### Creating an Amp Session
1. Click "New Session" in FleetCode
2. Select your project directory (git repository)
3. Choose the parent branch
4. **Select "Amp" from the Coding Agent dropdown**
5. Optionally add setup commands
6. Click "Create Session"
FleetCode will:
- Create a git worktree
- Start a terminal session
- Launch `amp` in the worktree
## Features
### What Works with Amp
✅ Git worktree isolation
✅ Persistent sessions
✅ Terminal theming
✅ Setup commands (environment variables, etc.)
✅ Session management (rename, close, delete)
### Differences from Claude
Unlike Claude, Amp doesn't require:
- `--session-id` or `--resume` flags
- `--dangerously-skip-permissions` flag
- MCP server configuration
Amp sessions are simpler - just run `amp` and it starts.
## Code Implementation
### Terminal Command
When you select Amp, FleetCode runs:
```bash
nix shell nixpkgs#nodejs -c npx -y @sourcegraph/amp
```
This uses Nix to provide Node.js and npx to run the latest Amp package.
Claude in comparison requires session management:
```bash
claude --session-id <uuid>
```
### UI Behavior
- **Skip Permissions checkbox**: Hidden for Amp (only needed for Claude)
- **Session persistence**: Works the same as other agents
- **MCP servers**: Not shown for Amp sessions
## Customization
If you need to pass additional flags to Amp, you can:
1. Add them in the **Setup Commands** field:
```bash
export AMP_CONFIG=/path/to/config
```
2. Or modify the code in `server.ts` and `main.ts`:
```typescript
} else if (config.codingAgent === "amp") {
ptyProcess.write("nix shell nixpkgs#nodejs -c npx -y @sourcegraph/amp --your-flags-here\r");
}
```
## Testing
To test Amp integration:
```bash
# Start the web server
npm run server
# Or for Electron
npm run dev
```
Then:
1. Create a new session
2. Select "Amp" as the coding agent
3. Choose a project
4. Verify that `amp` launches in the terminal
## Troubleshooting
### "nix: command not found"
Nix is not installed. Install it from https://nixos.org/download.html
### "npx: command not found"
The nix shell should provide Node.js and npx. If this fails, check your Nix installation:
```bash
# Test Nix shell
nix shell nixpkgs#nodejs -c node --version
```
### Amp doesn't start
Check the terminal output in the FleetCode session - you'll see any errors from the `amp` command.
### Want to pass custom flags?
Edit the setup commands or modify `server.ts`/`main.ts` as shown above.
## Future Enhancements
Possible improvements for Amp integration:
- [ ] Amp-specific settings panel
- [ ] Custom Amp flags input field
- [ ] Amp session persistence (if Amp supports session IDs)
- [ ] Amp-specific MCP server integration
- [ ] Amp status indicators
## Summary
Amp is now fully integrated into FleetCode! You can:
1. ✅ Select Amp from the coding agent dropdown
2. ✅ Create Amp sessions in isolated git worktrees
3. ✅ Run multiple Amp sessions in parallel
4. ✅ Use all FleetCode features (themes, persistence, etc.)
Enjoy using Amp in FleetCode! 🚀