-
Notifications
You must be signed in to change notification settings - Fork 364
feat: implement Agent Client Protocol (ACP) for Copilot CLI #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Shazwazza
wants to merge
10
commits into
michaelshimeles:main
Choose a base branch
from
Shazwazza:feature/copilot-acp-refactor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
626f14e
feat: add ACP-based Copilot engine implementation
Shazwazza 36428eb
docs: update copilot engine documentation
Shazwazza c9e36b7
fix: add Windows shell support for ACP spawn
Shazwazza f54b2b6
fix: document lack of token counts in Copilot ACP
Shazwazza 57f8bc7
oops
Shazwazza 99f5636
refactor: address Greptile PR review comments
Shazwazza 2b277af
oops
Shazwazza 3aae4fd
fix: replace undefined inputTokens/outputTokens with 0
Shazwazza 49ee0e2
fix: address additional Greptile comments - process exit tracking, mi…
Shazwazza c5a5aa4
fix: move stderrChunks declaration outside try block and remove extra…
Shazwazza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from "bun:test"; | ||
| import { existsSync, mkdirSync, rmSync } from "node:fs"; | ||
| import { tmpdir } from "node:os"; | ||
| import { join } from "node:path"; | ||
| import { CopilotAcpEngine } from "./copilot-acp.ts"; | ||
| import * as baseModule from "./base.ts"; | ||
|
|
||
| describe("CopilotAcpEngine", () => { | ||
| let engine: CopilotAcpEngine; | ||
| const testWorkDir = join(tmpdir(), "copilot-acp-test"); | ||
|
|
||
| beforeEach(() => { | ||
| engine = new CopilotAcpEngine(); | ||
| mkdirSync(testWorkDir, { recursive: true }); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| if (existsSync(testWorkDir)) { | ||
| rmSync(testWorkDir, { recursive: true, force: true }); | ||
| } | ||
| }); | ||
|
|
||
| describe("Basic Properties", () => { | ||
| it("should have correct name and command", () => { | ||
| expect(engine.name).toBe("GitHub Copilot"); | ||
| expect(engine.cliCommand).toBe("copilot"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("ACP Connection", () => { | ||
| it("should build prompt content correctly", () => { | ||
| const promptContent = (engine as any).buildPromptContent("test prompt"); | ||
| expect(promptContent).toEqual([{ type: "text", text: "test prompt" }]); | ||
| }); | ||
|
|
||
| it("should prepend model override as instruction", () => { | ||
| const promptContent = (engine as any).buildPromptContent("test prompt", { | ||
| modelOverride: "gpt-4", | ||
| }); | ||
| expect(promptContent).toHaveLength(2); | ||
| expect(promptContent[0]).toEqual({ type: "text", text: "[Use model: gpt-4]" }); | ||
| expect(promptContent[1]).toEqual({ type: "text", text: "test prompt" }); | ||
| }); | ||
|
|
||
| it("should handle empty prompt", () => { | ||
| const promptContent = (engine as any).buildPromptContent(""); | ||
| expect(promptContent).toEqual([{ type: "text", text: "" }]); | ||
| }); | ||
|
|
||
| it("should preserve multiline prompts", () => { | ||
| const multilinePrompt = "Line 1\nLine 2\nLine 3"; | ||
| const promptContent = (engine as any).buildPromptContent(multilinePrompt); | ||
| expect(promptContent[0].text).toBe(multilinePrompt); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Prompt Content Building", () => { | ||
| it("should handle various prompt content scenarios", async () => { | ||
| // Test with model override | ||
| const withModel = (engine as any).buildPromptContent("test", { modelOverride: "gpt-4" }); | ||
| expect(withModel[0].text).toContain("gpt-4"); | ||
| expect(withModel[1].text).toBe("test"); | ||
|
|
||
| // Test without model | ||
| const withoutModel = (engine as any).buildPromptContent("test"); | ||
| expect(withoutModel).toHaveLength(1); | ||
| expect(withoutModel[0].text).toBe("test"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Streaming Execution", () => { | ||
| it("should have executeStreaming method available", () => { | ||
| expect(engine.executeStreaming).toBeDefined(); | ||
| expect(typeof engine.executeStreaming).toBe("function"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Error Handling", () => { | ||
| it("should check if copilot command is available", async () => { | ||
| const isAvailable = await engine.isAvailable(); | ||
| // This will check actual system, but should not throw | ||
| expect(typeof isAvailable).toBe("boolean"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Integration Properties", () => { | ||
| it("should have correct engine properties", () => { | ||
| expect(engine.name).toBe("GitHub Copilot"); | ||
| expect(engine.cliCommand).toBe("copilot"); | ||
| }); | ||
|
|
||
| it("should support model override in options", () => { | ||
| const content = (engine as any).buildPromptContent("test", { | ||
| modelOverride: "custom-model", | ||
| }); | ||
| expect(content[0].text).toContain("custom-model"); | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.