mirror of
https://github.com/lWolvesl/claw-code.git
synced 2026-04-02 22:31:51 +08:00
feat(cli): align slash help/status/model handling
Centralize slash command parsing in the commands crate so the REPL can share help metadata and grow toward Claude Code parity without duplicating handlers. This adds shared /help and /model parsing, routes REPL dispatch through the shared parser, and upgrades /status to report model and token totals. To satisfy the required verification gate, this also fixes existing workspace clippy and test blockers in runtime, tools, api, and compat-harness that were unrelated to the new command behavior but prevented fmt/clippy/test from passing cleanly. Constraint: Preserve existing prompt-mode and REPL behavior while adding real slash commands Constraint: cargo fmt, clippy, and workspace tests must pass before shipping command-surface work Rejected: Keep command handling only in main.rs | would deepen duplication with commands crate and resume path Confidence: high Scope-risk: moderate Reversibility: clean Directive: Extend new slash commands through the shared commands crate first so REPL and resume entrypoints stay consistent Tested: cargo fmt; cargo clippy --workspace --all-targets -- -D warnings; cargo test --workspace Not-tested: live Anthropic network execution beyond existing mocked/integration coverage
This commit is contained in:
@@ -24,9 +24,10 @@ impl UpstreamPaths {
|
||||
.as_ref()
|
||||
.canonicalize()
|
||||
.unwrap_or_else(|_| workspace_dir.as_ref().to_path_buf());
|
||||
let repo_root = workspace_dir
|
||||
let primary_repo_root = workspace_dir
|
||||
.parent()
|
||||
.map_or_else(|| PathBuf::from(".."), Path::to_path_buf);
|
||||
let repo_root = resolve_upstream_repo_root(&primary_repo_root);
|
||||
Self { repo_root }
|
||||
}
|
||||
|
||||
@@ -53,6 +54,42 @@ pub struct ExtractedManifest {
|
||||
pub bootstrap: BootstrapPlan,
|
||||
}
|
||||
|
||||
fn resolve_upstream_repo_root(primary_repo_root: &Path) -> PathBuf {
|
||||
let candidates = upstream_repo_candidates(primary_repo_root);
|
||||
candidates
|
||||
.into_iter()
|
||||
.find(|candidate| candidate.join("src/commands.ts").is_file())
|
||||
.unwrap_or_else(|| primary_repo_root.to_path_buf())
|
||||
}
|
||||
|
||||
fn upstream_repo_candidates(primary_repo_root: &Path) -> Vec<PathBuf> {
|
||||
let mut candidates = vec![primary_repo_root.to_path_buf()];
|
||||
|
||||
if let Some(explicit) = std::env::var_os("CLAUDE_CODE_UPSTREAM") {
|
||||
candidates.push(PathBuf::from(explicit));
|
||||
}
|
||||
|
||||
for ancestor in primary_repo_root.ancestors().take(4) {
|
||||
candidates.push(ancestor.join("claude-code"));
|
||||
candidates.push(ancestor.join("clawd-code"));
|
||||
}
|
||||
|
||||
candidates.push(
|
||||
primary_repo_root
|
||||
.join("reference-source")
|
||||
.join("claude-code"),
|
||||
);
|
||||
candidates.push(primary_repo_root.join("vendor").join("claude-code"));
|
||||
|
||||
let mut deduped = Vec::new();
|
||||
for candidate in candidates {
|
||||
if !deduped.iter().any(|seen: &PathBuf| seen == &candidate) {
|
||||
deduped.push(candidate);
|
||||
}
|
||||
}
|
||||
deduped
|
||||
}
|
||||
|
||||
pub fn extract_manifest(paths: &UpstreamPaths) -> std::io::Result<ExtractedManifest> {
|
||||
let commands_source = fs::read_to_string(paths.commands_path())?;
|
||||
let tools_source = fs::read_to_string(paths.tools_path())?;
|
||||
|
||||
Reference in New Issue
Block a user