Skip to content

Conversation

@christso
Copy link
Collaborator

@christso christso commented Jan 7, 2026

Summary

  • Adds copilot-cli built-in provider kind that invokes GitHub Copilot CLI via -s --allow-all-tools --no-color -p <prompt>
  • Follows same patterns as codex/claude-code providers (workspace, preread, stream logging)
  • Includes target validation, CLI log subscription, example config, and unit tests

Closes #127

Test plan

  • 9 unit tests for provider invocation, ANSI stripping, timeout, error handling, model args, custom args, input files, log streaming
  • bun run build && bun run typecheck && bun run lint && bun test all pass (385 tests, 0 failures)
  • E2E: 3 concurrent eval cases with gpt-4.1 (math, code gen, multi-line) — all pass
  • E2E: gpt-5-mini model — passes
  • E2E: custom system_prompt override — passes
  • E2E: timeout handling (1s timeout correctly reports "timed out after 1s")
  • E2E: concurrent workers (3 default) confirmed working
  • E2E: log files created in .agentv/logs/copilot-cli/ with proper headers and timestamps

🤖 Generated with Claude Code

@christso christso changed the title OpenSpec: add Copilot CLI provider proposal feat: add Copilot CLI provider Jan 7, 2026
@christso christso marked this pull request as draft January 7, 2026 05:00
@christso
Copy link
Collaborator Author

christso commented Jan 8, 2026

Cancelling this openspec proposal.

Reason: GitHub Copilot CLI lacks structured JSON output (no --json or --output-format flag), unlike Codex, Pi, and Claude Code providers which all support JSONL event streams with tool call traces.

This means copilot-cli targets would:

  • Not support tool trajectory evaluators
  • Have no structured trace data
  • Be limited to final text output only

The existing agent providers (Codex, Pi, Claude Code) are sufficient for our needs and all provide full observability.

@christso christso closed this Jan 8, 2026
@christso christso deleted the feat/add-copilot-cli-provider-openspec branch January 8, 2026 01:21
@christso christso restored the feat/add-copilot-cli-provider-openspec branch January 8, 2026 06:00
@christso christso reopened this Jan 8, 2026
christso and others added 13 commits February 1, 2026 04:14
The -p flag takes the next argument as the prompt value.
Other flags must come before -p to avoid "too many arguments" error.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…enance

Only keep copilot-cli as the canonical provider name. This follows
the principle of keeping maintenance burden low since most other
providers only have 0-1 aliases.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@christso christso force-pushed the feat/add-copilot-cli-provider-openspec branch from 03b29f5 to 06674cc Compare February 1, 2026 05:27
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 1, 2026

Deploying agentv with  Cloudflare Pages  Cloudflare Pages

Latest commit: 45a0396
Status: ✅  Deploy successful!
Preview URL: https://0d4bde77.agentv.pages.dev
Branch Preview URL: https://feat-add-copilot-cli-provide.agentv.pages.dev

View logs

@christso christso changed the title feat: add Copilot CLI provider feat(core): add copilot-cli provider Feb 1, 2026
@christso
Copy link
Collaborator Author

christso commented Feb 1, 2026

Code Review: PR #127 — Add copilot-cli Provider

Verification Results

Check Result
bun run build PASS
bun run typecheck PASS
bun run lint PASS (212 files, no issues)
bun run test PASS (385 tests across 28 files)

What Was Done Well

  • Pattern consistency — closely mirrors the codex provider structure, making the codebase predictable and maintainable
  • Testability — constructor accepts a CopilotCliRunner function for dependency injection, enabling clean unit tests without spawning real processes
  • Test coverage — 9 unit tests covering happy path, ANSI stripping, non-zero exit, timeout, empty output, model flag, custom args, input files/preread, and log streaming
  • Clean integration — CLI log subscription and progress display follow the exact same pattern as codex/pi providers
  • Alias removal — final commit removing copilot/github-copilot aliases is a justified deviation from the proposal, keeping a single canonical copilot-cli name

Issues — Should Fix

1. Security: Unescaped shell argument in locateExecutable (copilot-cli.ts:454)

const { stdout } = await execAsync(`${locator} ${candidate}`);

The candidate string from user YAML config is interpolated into a shell command without escaping. This is a pre-existing pattern from the codex provider, but propagating it further isn't ideal. Recommendation: use execFile instead of exec, or sanitize/quote the candidate. Could be addressed as a follow-up across all providers.

2. Prompt passed as CLI argument may hit OS ARG_MAX limits (copilot-cli.ts:90,170)

The full prompt (system prompt + base prompt with file contents) is passed via -p as a command-line argument. Linux ARG_MAX is typically ~2MB. Large evaluations could fail with E2BIG. The codex provider avoids this by piping via stdin (child.stdin.end(options.prompt)), while copilot-cli closes stdin immediately. Recommendation: investigate if Copilot CLI supports --prompt-file or stdin input; otherwise add a size check with a clear error.

3. Missing AGENTV_COPILOT_LOG_FORMAT env var fallback (targets.ts:950-952)

The codex resolver falls back to env.AGENTV_CODEX_LOG_FORMAT, but the copilot resolver has no equivalent env var fallback. Users setting log format via environment variables (common in CI) would expect parity. Recommendation: add env.AGENTV_COPILOT_LOG_FORMAT as a fallback in resolveCopilotConfig.


Suggestions — Nice to Have

4. Significant code duplication with codex providerCopilotCliStreamLogger and several utility functions (buildLogFilename, sanitizeForFilename, formatElapsed, pickDetail, etc.) are duplicated near-verbatim. Consider extracting shared utilities if more CLI providers are planned.

5. ANSI stripping covers CSI and OSC sequences, which is sufficient for --no-color output, but doesn't cover 8-bit CSI (\x9B). Minor concern.

6. hasPrintedLogHeader flag in progress-display.ts — first provider to emit logs claims the header label; copilot logs appearing after codex logs won't get their own header. Pre-existing issue.

7. Tests should verify -p is the last argument pair — the code comments say this is required (copilot-cli.ts:169) but tests don't assert argument ordering. An assertion like expect(invocation.args.indexOf('-p')).toBe(invocation.args.length - 2) would catch regressions.

8. Pre-existing: system_prompt/systemPrompt missing from CODEX_SETTINGS validator — the copilot provider correctly includes these, but the codex validator set is missing them (causes spurious warnings). Not introduced by this PR.


Final Assessment

This is a well-executed PR that follows established codebase patterns. Issues #1-#3 should be discussed before merge, with #2 (argument length limits) being the most impactful for real-world usage. The remaining suggestions can be addressed as follow-ups.


🤖 Generated with Claude Code

Instead of referencing input files via file:// URIs pointing to absolute
paths, copy them into the temp workspace and reference by relative path
in the prompt. This allows Copilot CLI to read the files from its cwd.

- Add copyInputFilesToWorkspace() with basename collision handling
- Add buildCopilotFilePrereadBlock() for relative-path prompt sections
- Replace buildPromptDocument with collectGuidelineFiles in invoke()
- Include copiedFiles mappings in raw response for debugging
- Update tests to assert no file:// URIs and add collision test

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@christso christso marked this pull request as ready for review February 1, 2026 06:50
@christso christso merged commit 5878d20 into main Feb 1, 2026
1 check passed
@christso christso deleted the feat/add-copilot-cli-provider-openspec branch February 1, 2026 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants