Skip to content

Add Claude API support alongside Cursor API - #46

Open
jonathanKingston wants to merge 3 commits into
mainfrom
claude/sdk-api-parity-0VtLN
Open

Add Claude API support alongside Cursor API#46
jonathanKingston wants to merge 3 commits into
mainfrom
claude/sdk-api-parity-0VtLN

Conversation

@jonathanKingston

Copy link
Copy Markdown
Collaborator

Summary

This PR adds support for Claude agents as an alternative to Cursor agents throughout the codebase. Users can now configure a claudeApiKey in .copserc and interact with Claude agents for pull requests, artifacts, and issue automation, with the same feature parity as the existing Cursor integration.

Key Changes

  • New Claude API module (lib/claude-api.ts): Implements the full Claude API client with support for:

    • Listing agents by PR URL
    • Finding the latest agent for a PR
    • Adding follow-up messages to agents
    • Launching new agents for PRs or repositories
    • Listing and downloading artifacts
  • Claude replies module (lib/claude-replies.ts): Mirrors the Cursor replies pattern, handling follow-up vs. launch logic for Claude agents

  • Configuration support: Added claudeApiKey field to Copserc config interface

  • Web server updates (web/server.ts):

    • API endpoints now support ?agent=cursor|claude query parameter to select which agent type to use
    • Download redirect endpoint supports both /api/cursor/agents/... and /api/claude/agents/... paths
    • Reply delivery now supports "claude" mode alongside "github" and "cursor"
  • CLI command updates:

    • status.ts: Watch mode now displays Claude PR agents and fetches Claude artifacts when configured
    • artifacts.ts: Tries Cursor first, then Claude when downloading artifacts
    • pr-comments.ts: Interactive loop supports Claude agent replies
    • create-issue.ts: Can launch Claude agents for issues via @claude mentions
  • Mock provider support (lib/mock-api-provider.ts): Added Claude agent mocking for tests with separate tracking of Claude agents, artifacts, followups, and launches

  • Test coverage: Added comprehensive tests for Claude reply logic and mock provider integration

Implementation Details

  • Claude and Cursor APIs are kept separate with distinct function names (aliased on import) to avoid conflicts
  • The web server intelligently routes requests based on the agent query parameter or URL path segment
  • Both agent types follow the same patterns for finding agents, managing artifacts, and sending replies
  • The mock provider maintains separate data structures for Cursor and Claude to support testing both simultaneously

https://claude.ai/code/session_0148LH62Tjtqruhtd5dRE5fd

claude and others added 3 commits March 15, 2026 22:27
Adds claudeApiKey config field and a complete Claude API client
(lib/claude-api.ts) mirroring the Cursor API module. All commands
(pr-comments, create-issue, artifacts, status TUI, web dashboard)
now route to the appropriate agent API based on the PR's agent type.
The ApiProvider interface, MockApiProvider, and test suite are extended
with Claude-specific methods and coverage.

https://claude.ai/code/session_0148LH62Tjtqruhtd5dRE5fd
…deo-0d69

Fix flaky mock-provider status test by bypassing stale disk cache
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.

3 participants