Skip to content

feat(agents): add Copilot and Pi agent support#1085

Open
svg153 wants to merge 1 commit into
manufosela:mainfrom
svg153:feat/add-copilot-pi-agents
Open

feat(agents): add Copilot and Pi agent support#1085
svg153 wants to merge 1 commit into
manufosela:mainfrom
svg153:feat/add-copilot-pi-agents

Conversation

@svg153

@svg153 svg153 commented Jun 14, 2026

Copy link
Copy Markdown

Summary

  • Add CopilotAgent class with JSONL usage parsing for Copilot CLI
  • Add PiAgent class for pi.dev agent
  • Register both agents in the agent registry

Related

  • PR-J (audit quick win)

Copilot AI review requested due to automatic review settings June 14, 2026 02:06
@changeset-bot

changeset-bot Bot commented Jun 14, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 7c5b4e6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds two new agent implementations that execute external CLIs (Pi and Copilot) via BaseAgent, capturing stdout/stderr and attempting to parse token-usage from JSONL output.

Changes:

  • Introduces PiAgent to run/review tasks through Pi CLI in JSON mode and parse usage.
  • Introduces CopilotAgent to run/review tasks through Copilot CLI with JSON output and parse usage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/agents/pi-agent.js New agent that shells out to pi CLI, parses JSONL, and returns AgentResult with usage fields.
src/agents/copilot-agent.js New agent that shells out to copilot CLI, parses JSONL, and returns AgentResult with usage fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/agents/pi-agent.js
Comment on lines +108 to +114
return {
ok: res.exitCode === 0,
output: res.stdout,
error: res.stderr,
exitCode: res.exitCode,
...usage
};
Comment on lines +82 to +88
return {
ok: res.exitCode === 0,
output: res.stdout,
error: res.stderr,
exitCode: res.exitCode,
...usage
};
Comment on lines +4 to +9
/**
* Extract usage from Copilot CLI JSONL output.
* Copilot CLI with --output-format json emits JSONL (one JSON object per line).
* We look for the final message with usage information.
*/
function extractCopilotUsage(text) {
return result;
}

async _exec(task, model, _jsonFormat) {
Comment thread src/agents/pi-agent.js
Comment on lines +9 to +15
function extractPiUsage(text) {
if (!text) return null;

const lines = text.trim().split("\n");
for (const line of lines) {
const t = line.trim();
if (!t.startsWith("{")) continue;
@svg153 svg153 force-pushed the feat/add-copilot-pi-agents branch from 593c235 to f0fa566 Compare June 14, 2026 02:10
- Add CopilotAgent class with JSONL usage parsing for Copilot CLI
- Add PiAgent class for pi.dev agent
- Register both agents in the agent registry

Related to: PR-J (audit quick win)
@svg153 svg153 force-pushed the feat/add-copilot-pi-agents branch from f0fa566 to 7c5b4e6 Compare June 14, 2026 02:14
@svg153

svg153 commented Jun 14, 2026

Copy link
Copy Markdown
Author

Resolving Copilot review comments:

Comment 1 (pi-agent.js:114) - Null spread fix: Changed ...usage to ...(usage ?? {}) to prevent TypeError when usage is null.

Comment 2 (copilot-agent.js:88) - Null spread fix: Same fix applied to CopilotAgent.

Comment 3 (copilot-agent.js:9) - Comment fix: Changed 'final message' to 'first message' to match actual behavior.

Comment 4 (copilot-agent.js:61) - Unused param: Parameter renamed to _jsonFormat to indicate intentionally unused.

💡 Comment 5 (pi-agent.js:15) - Shared helper: Noted as a future refactoring opportunity. The extraction logic is similar but has agent-specific nuances (different CLI output formats). Will factor into shared helper in a follow-up PR when more agents are added.

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