Skip to content

Conversation

MariaChrysafis
Copy link

Refactor to use official TypeScript SDK

Summary

This PR completely replaces the yukifoo implementation with the official @anthropic-ai/claude-code TypeScript SDK. The change introduces a Node.js bridge architecture where the Go SDK communicates with the TypeScript SDK via JSON over stdin/stdout, while maintaining full API compatibility with the existing Go interface.

Key Changes:

  • Module Path: Updated from github.com/yukifoo/claude-code-sdk-go to github.com/anthropic-ai/claude-code-sdk-go
  • Architecture: Replaced CLI wrapping with Node.js process bridge communicating via JSON
  • Bridge Implementation: Created bridge/claude-bridge.js that wraps the official TypeScript SDK
  • Option Mapping: Implemented mapping between Go SDK options and TypeScript SDK options
  • Error Handling: Updated all error messages and types to reflect Node.js bridge architecture
  • Setup: Added scripts/setup.sh for easy Node.js dependency installation

Review & Testing Checklist for Human

⚠️ HIGH RISK CHANGE - Complete architectural overhaul requires thorough testing

  • End-to-End Functionality: Test real Claude queries with various options (streaming/non-streaming, different models, tool restrictions, MCP configuration)
  • Option Mapping Verification: Verify that all Go SDK options correctly map to TypeScript SDK behavior (especially SystemPrompt/customSystemPrompt, Resume/sessionId, MCP configurations)
  • Message Format Compatibility: Ensure all message types (AssistantMessage, UserMessage, SystemMessage, ResultMessage) parse correctly from TypeScript SDK responses
  • Error Scenarios: Test error handling (invalid paths, Node.js not installed, bridge failures, malformed requests)
  • Cross-Platform Setup: Verify scripts/setup.sh works correctly and Node.js dependencies install properly

Notes

Requestor: Maria Chrysafis (@MariaChrysafis)
Devin Session: https://app.devin.ai/sessions/4b8df1265bc841c3957e242a19642576

Critical Implementation Details:

  • The bridge maps Go's SystemPrompt → TypeScript's customSystemPrompt
  • Session management uses ResumesessionId mapping
  • MCP server configuration format changed from slice to map structure
  • All tests passing and linting clean, but limited to unit tests - integration testing needed

Breaking Changes for Users:

  • Now requires Node.js (version 16+) as runtime dependency
  • Must run ./scripts/setup.sh or cd bridge && npm install after installation
  • Import path changed (though this was expected as part of moving away from yukifoo)

- Replace yukifoo implementation with official @anthropic-ai/claude-code TypeScript SDK
- Update module path to github.com/anthropic-ai/claude-code-sdk-go
- Implement Node.js bridge for Go-TypeScript communication via JSON over stdin/stdout
- Update all import paths and references throughout codebase
- Add setup script and bridge infrastructure in bridge/ and scripts/ directories
- Maintain full API compatibility with existing Go interface
- Update documentation, examples, and error messages
- All tests passing and linting clean

This is a complete architectural change from CLI wrapping to Node.js process integration
while maintaining backward compatibility for existing Go API users.

Co-Authored-By: Maria Chrysafis <[email protected]>
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant