Skip to content

Commit 77c0413

Browse files
committed
feat(cli): Add Copilot to agent start
1 parent 8dc7f98 commit 77c0413

4 files changed

Lines changed: 23 additions & 4 deletions

File tree

‎packages/agent-manager/src/__tests__/utils/agents.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import { describe, expect, it } from 'vitest';
22
import { AGENTS } from '../../../src/utils/agents.js';
33

44
describe('AGENTS', () => {
5+
it('includes Copilot as a startable agent', () => {
6+
expect(AGENTS.copilot.command).toBe('copilot');
7+
expect(AGENTS.copilot.matches('/opt/homebrew/Caskroom/copilot-cli/1.0.60/copilot')).toBe(true);
8+
expect(AGENTS.copilot.matches('node /repo/feature-cli-copilot-cli/script.js')).toBe(false);
9+
});
10+
511
it('includes Pi as a startable agent', () => {
612
expect(AGENTS.pi.command).toBe('pi');
713
expect(AGENTS.pi.matches('pi')).toBe(true);

‎packages/agent-manager/src/utils/agents.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'path';
22
import type { AgentType } from '../adapters/AgentAdapter.js';
33

4-
export type StartableAgentType = Extract<AgentType, 'claude' | 'codex' | 'gemini_cli' | 'opencode' | 'pi'>;
4+
export type StartableAgentType = Extract<AgentType, 'claude' | 'codex' | 'copilot' | 'gemini_cli' | 'opencode' | 'pi'>;
55

66
export interface AgentConfig {
77
/** Shell command to launch the agent (sent to tmux via `send-keys`). */
@@ -18,9 +18,10 @@ export interface AgentConfig {
1818
export const AGENTS: Record<StartableAgentType, AgentConfig> = {
1919
claude: { command: 'claude', matches: matchArgv0('claude') },
2020
codex: { command: 'codex', matches: matchArgv0('codex') },
21+
copilot: { command: 'copilot', matches: matchArgv0Name('copilot-cli') },
2122
gemini_cli: { command: 'gemini', matches: matchAnyToken('gemini') },
2223
opencode: { command: 'opencode', matches: matchArgv0('opencode') },
23-
pi: { command: 'pi', matches: matchAnyBasename(['pi', 'pi.exe', 'pi.js']) },
24+
pi: { command: 'pi', matches: matchAnyBasename(['pi']) },
2425
};
2526

2627
function matchArgv0(name: string): (psCommand: string) => boolean {
@@ -31,6 +32,14 @@ function matchArgv0(name: string): (psCommand: string) => boolean {
3132
};
3233
}
3334

35+
function matchArgv0Name(name: string): (psCommand: string) => boolean {
36+
const lower = name.toLowerCase();
37+
return (psCommand) => {
38+
const token = psCommand.trim().split(/\s+/)[0];
39+
return token ? token.toLowerCase().includes(lower) : false;
40+
};
41+
}
42+
3443
function matchAnyToken(name: string): (psCommand: string) => boolean {
3544
const lower = name.toLowerCase();
3645
return (psCommand) => {

‎packages/cli/src/__tests__/commands/agent.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ vi.mock('@ai-devkit/agent-manager', () => ({
9494
AGENTS: {
9595
claude: { command: 'claude', matches: () => true },
9696
codex: { command: 'codex', matches: () => true },
97+
copilot: { command: 'copilot', matches: () => true },
9798
gemini_cli: { command: 'gemini', matches: () => true },
9899
opencode: { command: 'opencode', matches: () => true },
99100
pi: { command: 'pi', matches: () => true },

‎packages/cli/src/__tests__/tui/console/StartAgentPane.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ import {
99

1010
describe('StartAgentPane helpers', () => {
1111
it('lists supported agent start types in pane order', () => {
12-
expect(STARTABLE_AGENT_TYPES).toEqual(['claude', 'codex', 'gemini_cli', 'opencode', 'pi']);
12+
expect(STARTABLE_AGENT_TYPES).toEqual(['claude', 'codex', 'copilot', 'gemini_cli', 'opencode', 'pi']);
1313
});
1414

1515
it('cycles to the next agent type', () => {
1616
expect(nextStartAgentType('claude')).toBe('codex');
17+
expect(nextStartAgentType('codex')).toBe('copilot');
18+
expect(nextStartAgentType('copilot')).toBe('gemini_cli');
1719
expect(nextStartAgentType('opencode')).toBe('pi');
1820
expect(nextStartAgentType('pi')).toBe('claude');
1921
});
2022

2123
it('cycles to the previous agent type', () => {
22-
expect(previousStartAgentType('codex')).toBe('claude');
24+
expect(previousStartAgentType('copilot')).toBe('codex');
25+
expect(previousStartAgentType('gemini_cli')).toBe('copilot');
2326
expect(previousStartAgentType('pi')).toBe('opencode');
2427
expect(previousStartAgentType('claude')).toBe('pi');
2528
});

0 commit comments

Comments
 (0)