feat: add Anthropic account auth and usage - #20
Conversation
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Important Review available on request
Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| if len(args) > 0 && args[0] == "login" { | ||
| options, positionals, err := parseCommonOptions(args[1:]) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if len(positionals) != 0 || options.name != "" || options.providerAccountID != "" || options.ownerID != "" { | ||
| return errors.New("usage: prism claude login [--profile <name>]") | ||
| } | ||
| client, err := prismClient(ctx, options) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| return loginProvider(ctx, "anthropic", client, stdout) |
There was a problem hiding this comment.
Suggestion: The login branch parses --help into options.help but never handles it before resolving credentials and invoking loginProvider. As a result, prism claude login --help starts the Anthropic OAuth flow instead of displaying help, unlike the standard provider command path. Check options.help and print the login usage before calling prismClient. [incorrect condition logic]
Severity Level: Major ⚠️
- ⚠️ `prism claude login --help` launches Anthropic OAuth unexpectedly.
- ⚠️ Users cannot inspect alias-specific login usage safely.
- ⚠️ Existing provider help handling correctly avoids credential resolution.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** internal/cli/claude.go
**Line:** 33:45
**Comment:**
*Incorrect Condition Logic: The login branch parses `--help` into `options.help` but never handles it before resolving credentials and invoking `loginProvider`. As a result, `prism claude login --help` starts the Anthropic OAuth flow instead of displaying help, unlike the standard provider command path. Check `options.help` and print the login usage before calling `prismClient`.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| listener, err := net.Listen("tcp", "127.0.0.1:0") | ||
| if err != nil { | ||
| return AuthorizationGrant{}, errors.New("could not start the Anthropic OAuth callback") | ||
| } | ||
| defer listener.Close() | ||
|
|
||
| port := listener.Addr().(*net.TCPAddr).Port | ||
| redirectURI := fmt.Sprintf("http://localhost:%d/callback", port) | ||
| expectedHost := fmt.Sprintf("localhost:%d", port) |
There was a problem hiding this comment.
Suggestion: The callback listener is bound exclusively to IPv4 127.0.0.1, but the registered redirect uses localhost. On systems where the browser resolves localhost to IPv6 (::1) without falling back to IPv4, the browser cannot reach this listener and every Anthropic login attempt waits until timeout. Bind to a loopback address compatible with the redirect or use an IPv4 redirect hostname consistently. [api mismatch]
Severity Level: Major ⚠️
- ❌ Anthropic browser login can wait five minutes and time out.
- ❌ No Anthropic credential is saved after timeout.
- ⚠️ Failure affects hosts with IPv6-only localhost resolution.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** internal/anthropic/oauth.go
**Line:** 59:67
**Comment:**
*Api Mismatch: The callback listener is bound exclusively to IPv4 `127.0.0.1`, but the registered redirect uses `localhost`. On systems where the browser resolves `localhost` to IPv6 (`::1`) without falling back to IPv4, the browser cannot reach this listener and every Anthropic login attempt waits until timeout. Bind to a loopback address compatible with the redirect or use an IPv4 redirect hostname consistently.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
User description
Refs circlesac/prism#65
Changes
prism anthropic auth login, list, remove, and usage commandsprism claude loginas an Anthropic login aliasprism usagetableTesting
go test -mod=vendor -race ./...go vet -mod=vendor ./...gofmtcleanNotes
CodeAnt-AI Description
Add Anthropic account login and Claude usage tracking
What Changed
prism anthropic auth loginor theprism claude loginalias, then list, view, and remove saved accountsprism anthropic usageshows Claude account quotas, and combinedprism usagenow includes Claude alongside ChatGPT and OpenCodeImpact
✅ Claude accounts can be added and managed✅ Claude quotas visible in provider usage reports✅ Partial usage results remain available during provider outages💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.