feat: add ccr activate command for Agent SDK integration
#976
+105
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
I'm the author of d-kimuson/claude-code-viewer, which uses the Agent SDK to provide a web-based GUI for Claude Code. I received this issue from a user who wanted to use it with claude-code-router.
After reading the implementation, I realized it should work in principle by running
ccr startand setting the appropriate environment variables. However, manually converting the config file to environment variables is cumbersome. I thought it would be beneficial to have a CLI command that just handles the environment variable setup. This would enable seamless integration not only with claude-code-viewer but with any Agent SDK-based application.Implementation
This PR adds a
ccr activatecommand to achieve this goal. This is also a proof of concept - if a different interface design is preferred, feel free to reject this and recreate it, or let me know and I can make the changes.Usage
Basic Usage
With Agent SDK Applications
Technical Details
ccr codeinto a sharedcreateEnvVariables()functionactivatecommand outputs in shell-friendly format by default (no--shellflag needed)ccr codeuses internallyTesting
Tested on my local environment:
ccr activateoutputs correct environment variables ✅eval $(ccr activate)successfully sets environment variables ✅ccr codestill works correctly with refactored code ✅