githubnext/chopinPublic

Let's compose rich plans together

Port Chopin tools to AI SDK tools #187

Mergedlavaman131merged 4 commits intofeat/harness-1-foundationfromrefs/pull/187/head
  1. LA

    Part of GitHub stack #202 (#181 harness).

    Part of #181. This is slice 2 of 5 stacked PRs for the pluggable agent harness RFC. It covers RFC phase 4: Chopin's tools on AI SDK. Phase 9, the author's own runtime adapter, is deferred.

    Stacked on #186 (`feat/harness-1-foundation`), which is stacked on #185. Review those first; this diff contains only the slice 2 commits.

    ## What changes

    - **Document tools are AI SDK `tool()`s.** `apps/server/src/agent/tools.ts` exports the 10 document tools with a `contextSchema`. The room and repository come from `toolsContext` at call time, never from model input. Names, schemas, `skipPermission` flags and behavior are unchanged. - **Repository tools are AI SDK `tool()`s.** `read_repository_file`, `list_repository_tree`, `search_repository` and `repository_history` in `apps/server/src/agent/repository.ts` read the repository and the owner's token from `toolsContext`. Their options no longer accept a token or repository. - **Host-side GitHub MCP tools: `apps/server/src/harness/github-tools.ts`.** - `githubTools(owner)` connects with `createMCPClient` over HTTP, using the owner's token with the read-only header and the `pull_requests` toolset. - It loads exactly `list_pull_requests` and `pull_request_read` (all nine methods) through `tools({ schemas })`. Search tools aren't loaded. - `bindRepository` overwrites `owner` and `repo` from context, supplies Chopin's own descriptions, and keeps the MCP client's `toModelOutput` converter. - Failures map to `Unavailable` or `MissingTool(name)`. - Clients are cached per owner token and closed on rotation or expiry. - **Temporary Copilot bridge.** `apps/server/src/agent/copilot-bridge.ts` converts the AI SDK tools into Copilot SDK tools, so the current Planner keeps running unchanged. Slice 3 deletes it when the Planner moves to `HarnessAgent`. `githubTools` has no runtime consumer until then; the current Planner still reaches GitHub through its existing MCP connection and argument gate.

    Commits: - `d6d499b` Port Planner tools to AI SDK with Copilot bridge - `ad2bb07` Bind GitHub MCP tools to channel repositories - `011c666` Bind document tools at call time and retain shared GitHub clients (review round) - `dba0f53` Keep MCP model-output conversion on bound GitHub tools (P3 review finding; fixed after the review loop ended)

    ## Review

    Both reviewers rated the patch correct, with no blocking findings from round 2 on. The workflow's review loop didn't approve, but only because the Edge check was blocked by a GitHub Next SSO prompt. The user has since completed SSO, and the check below passed. The remaining P3 finding (bound tools dropped `toModelOutput`) is fixed in `dba0f53`, with a test that fails without the fix.

    ## Interactive Edge verification

    In Microsoft Edge, signed in as lavaman131 against a local build of `dba0f53`'s parent (`011c666`), I asked `@chopin` on the `golden-wind` document: "Quote the first heading of README.md in this repository, and name the title and number of one recent pull request in this repository." The Planner made 2 tool calls and replied: README heading "# Chopin"; recent PR #186, "Add the AI SDK harness contract suite". Both come from the channel's repository. Evidence, re-run at the final commit `dba0f53`: the tool list shows `Read repository file` and `Github-list pull requests`, and the reply cites README "# Chopin" and PR #187.

    ![Planner turn with 2 tools expanded: Read repository file and Github-list pull requests](https://github.com/user-attachments/assets/97195b30-09cf-4b7f-a748-18b8616f2c58)

    ![Planner cites README heading and PR #186 at 011c666](https://github.com/user-attachments/assets/14d6cdec-e4a2-4d0d-85bd-e4d359eb0991)

    The server log for that session still lists `github/search_pull_requests`. That's the current Copilot path's MCP connection, where the existing gate denies it. Slice 3 replaces that connection with `githubTools`.

    ## Still open

    - The GitHub App user-token path for `githubTools` is covered by unit tests and a real `@ai-sdk/mcp` client against a local MCP server, but not yet against GitHub's server. Slice 3 exercises it end to end. The account-without-Copilot case is also unverified.

    Assistant-model: GPT-6 Sol, Claude Sonnet 5, Claude Opus 5.5 Assistant-workflow: harness-stack (run f6f676b9-6506-489b-93e2-2616ea55c6a8) Assistant-verification: bun run ci passed: dprint, oxlint, tokens at dba0f53 Assistant-verification: bun run types passed: all workspaces and E2E at dba0f53 Assistant-verification: bun test passed: 1556 pass, 2 skip, 0 fail at dba0f53 Assistant-verification: bun run e2e passed: CI=1, 228 passed and 2 flaky that passed on retry (responsive-workspace.e2e.ts:110 and :186) at dba0f53 Assistant-verification: bindRepository toModelOutput unit passed: fails without the fix, passes with it Assistant-verification: reviewer probe passed: real @ai-sdk/mcp client against a local MCP server offering search tools loaded only list_pull_requests and pull_request_read, and forged owner/repo was replaced by the channel repository Assistant-verification: agent-browser Edge manual scenario passed: @chopin cited README heading "# Chopin" and PR #186 from the channel repository at 011c666 Assistant-verification: agent-browser Edge manual scenario passed: at dba0f53, @chopin used read_repository_file and github list_pull_requests and cited README "# Chopin" and PR #187 Assistant-verification: agent-browser recording failed: 60 fps MP4 over the WSL-to-Windows CDP bridge froze after the first frame; not uploaded Co-authored-by: @lavaman131

  2. chopinmentionedlast month on GitHub

  3. chopinsubscribedlast month on GitHub

  4. lavaman131mentionedlast month on GitHub

  5. lavaman131subscribedlast month on GitHub

  6. lavaman131added-to-stacklast month on GitHub

  7. lavaman131referenced this in Add the gh-stack dev skill #189last month on GitHub

  8. lavaman131removed-from-stacklast month on GitHub

  9. lavaman131added-to-stacklast month on GitHub

  10. lavaman131convert-to-draftlast month on GitHub

  11. lavaman131referenced this in Run the Planner on HarnessAgent with a Copilot SDK adapter #192last month on GitHub

  12. lavaman131referenced this in Move workers to structured output and add harness deployment modes #194last month on GitHub

  13. lavaman131referenced this in Add the Pi harness adapter and E2E harness coverage #195last month on GitHub

  14. lavaman131ready-for-reviewlast month on GitHub

  15. MA

    No review summary.

  16. lavaman131removed-from-stacklast month on GitHub

  17. lavaman131base-ref-force-pushedlast month on GitHub

  18. lavaman131head-ref-force-pushed e1fe0b064953last month on GitHub

  19. lavaman131added-to-stacklast month on GitHub

  20. lavaman131merged bbd08196498alast month on GitHub

  21. lavaman131closedlast month on GitHub

  22. lavaman131head-ref-deletedlast month on GitHub