mirror of
https://github.com/lWolvesl/claw-code.git
synced 2026-04-01 23:31:53 +08:00
feat: default OAuth config for claude.com, merge UI polish rendering
This commit is contained in:
5
.claude.json
Normal file
5
.claude.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"defaultMode": "dontAsk"
|
||||||
|
}
|
||||||
|
}
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,3 +2,6 @@ __pycache__/
|
|||||||
archive/
|
archive/
|
||||||
.omx/
|
.omx/
|
||||||
.clawd-agents/
|
.clawd-agents/
|
||||||
|
# Claude Code local artifacts
|
||||||
|
.claude/settings.local.json
|
||||||
|
.claude/sessions/
|
||||||
|
|||||||
21
CLAUDE.md
Normal file
21
CLAUDE.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# CLAUDE.md
|
||||||
|
|
||||||
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||||
|
|
||||||
|
## Detected stack
|
||||||
|
- Languages: Rust.
|
||||||
|
- Frameworks: none detected from the supported starter markers.
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
- Run Rust verification from `rust/`: `cargo fmt`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo test --workspace`
|
||||||
|
- `src/` and `tests/` are both present; update both surfaces together when behavior changes.
|
||||||
|
|
||||||
|
## Repository shape
|
||||||
|
- `rust/` contains the Rust workspace and active CLI/runtime implementation.
|
||||||
|
- `src/` contains source files that should stay consistent with generated guidance and tests.
|
||||||
|
- `tests/` contains validation surfaces that should be reviewed alongside code changes.
|
||||||
|
|
||||||
|
## Working agreement
|
||||||
|
- Prefer small, reviewable changes and keep generated bootstrap files aligned with actual repo workflows.
|
||||||
|
- Keep shared defaults in `.claude.json`; reserve `.claude/settings.local.json` for machine-local overrides.
|
||||||
|
- Do not overwrite existing `CLAUDE.md` content automatically; update it intentionally when repo workflows change.
|
||||||
1
rust/.claude/sessions/session-1775012674485.json
Normal file
1
rust/.claude/sessions/session-1775012674485.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"messages":[{"blocks":[{"text":"clear","type":"text"}],"role":"user"},{"blocks":[{"text":"\n\nI've cleared the conversation. How can I help you today?","type":"text"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":4272,"output_tokens":17}}],"version":1}
|
||||||
1
rust/.claude/sessions/session-1775012687059.json
Normal file
1
rust/.claude/sessions/session-1775012687059.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"messages":[{"blocks":[{"text":"exit","type":"text"}],"role":"user"},{"blocks":[{"text":"\n\nGoodbye! 👋","type":"text"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":4272,"output_tokens":10}}],"version":1}
|
||||||
1
rust/.claude/sessions/session-1775013221875.json
Normal file
1
rust/.claude/sessions/session-1775013221875.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"messages":[],"version":1}
|
||||||
@@ -1,22 +1,27 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"content": "Phase 0: Structural Cleanup — spawn 4 agents for 0.1-0.4",
|
"content": "Architecture & dependency analysis",
|
||||||
"activeForm": "Executing Phase 0: Structural Cleanup via sub-agents",
|
"activeForm": "Complete",
|
||||||
|
"status": "completed"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"content": "Runtime crate deep analysis",
|
||||||
|
"activeForm": "Complete",
|
||||||
|
"status": "completed"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"content": "CLI & Tools analysis",
|
||||||
|
"activeForm": "Complete",
|
||||||
|
"status": "completed"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"content": "Code quality verification",
|
||||||
|
"activeForm": "Complete",
|
||||||
|
"status": "completed"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"content": "Synthesize findings into unified report",
|
||||||
|
"activeForm": "Writing report",
|
||||||
"status": "in_progress"
|
"status": "in_progress"
|
||||||
},
|
|
||||||
{
|
|
||||||
"content": "Phase 1.1-1.2: Status bar with live HUD and token counter",
|
|
||||||
"activeForm": "Awaiting Phase 0",
|
|
||||||
"status": "pending"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"content": "Phase 2.4: Remove artificial 8ms stream delay",
|
|
||||||
"activeForm": "Awaiting Phase 0",
|
|
||||||
"status": "pending"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"content": "Phase 3.1: Collapsible tool output",
|
|
||||||
"activeForm": "Awaiting Phase 0",
|
|
||||||
"status": "pending"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -28,7 +28,7 @@ use runtime::{
|
|||||||
parse_oauth_callback_request_target, save_oauth_credentials, ApiClient, ApiRequest,
|
parse_oauth_callback_request_target, save_oauth_credentials, ApiClient, ApiRequest,
|
||||||
AssistantEvent, CompactionConfig, ConfigLoader, ConfigSource, ContentBlock,
|
AssistantEvent, CompactionConfig, ConfigLoader, ConfigSource, ContentBlock,
|
||||||
ConversationMessage, ConversationRuntime, MessageRole, OAuthAuthorizationRequest,
|
ConversationMessage, ConversationRuntime, MessageRole, OAuthAuthorizationRequest,
|
||||||
OAuthTokenExchangeRequest, PermissionMode, PermissionPolicy, ProjectContext, RuntimeError,
|
OAuthConfig, OAuthTokenExchangeRequest, PermissionMode, PermissionPolicy, ProjectContext, RuntimeError,
|
||||||
Session, TokenUsage, ToolError, ToolExecutor, UsageTracker,
|
Session, TokenUsage, ToolError, ToolExecutor, UsageTracker,
|
||||||
};
|
};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
@@ -428,15 +428,26 @@ fn print_bootstrap_plan() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_oauth_config() -> OAuthConfig {
|
||||||
|
OAuthConfig {
|
||||||
|
client_id: String::from("9d1c250a-e61b-44d9-88ed-5944d1962f5e"),
|
||||||
|
authorize_url: String::from("https://platform.claude.com/oauth/authorize"),
|
||||||
|
token_url: String::from("https://platform.claude.com/v1/oauth/token"),
|
||||||
|
callback_port: None,
|
||||||
|
manual_redirect_url: None,
|
||||||
|
scopes: vec![
|
||||||
|
String::from("user:profile"),
|
||||||
|
String::from("user:inference"),
|
||||||
|
String::from("user:sessions:claude_code"),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn run_login() -> Result<(), Box<dyn std::error::Error>> {
|
fn run_login() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let cwd = env::current_dir()?;
|
let cwd = env::current_dir()?;
|
||||||
let config = ConfigLoader::default_for(&cwd).load()?;
|
let config = ConfigLoader::default_for(&cwd).load()?;
|
||||||
let oauth = config.oauth().ok_or_else(|| {
|
let default_oauth = default_oauth_config();
|
||||||
io::Error::new(
|
let oauth = config.oauth().unwrap_or(&default_oauth);
|
||||||
io::ErrorKind::NotFound,
|
|
||||||
"OAuth config is missing. Add settings.oauth.clientId/authorizeUrl/tokenUrl first.",
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
let callback_port = oauth.callback_port.unwrap_or(DEFAULT_OAUTH_CALLBACK_PORT);
|
let callback_port = oauth.callback_port.unwrap_or(DEFAULT_OAUTH_CALLBACK_PORT);
|
||||||
let redirect_uri = runtime::loopback_redirect_uri(callback_port);
|
let redirect_uri = runtime::loopback_redirect_uri(callback_port);
|
||||||
let pkce = generate_pkce_pair()?;
|
let pkce = generate_pkce_pair()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user