mirror of
https://github.com/lWolvesl/claw-code.git
synced 2026-04-02 07:41:52 +08:00
Improve memory inspection presentation
Reformat /memory into the same structured console style as the other polished commands and enumerate discovered instruction files in ancestry order with line counts and previews. This makes repo instruction memory easier to inspect without changing the underlying discovery behavior. Constraint: Memory reporting must reflect only the instruction files discovered from current directory ancestry Rejected: Add memory editing commands in the same slice | presentation polish was a cleaner, lower-risk improvement to ship first Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep instruction-file ordering stable so ancestry-based memory debugging stays predictable Tested: cargo fmt --manifest-path ./rust/Cargo.toml --all; cargo clippy --manifest-path ./rust/Cargo.toml --workspace --all-targets -- -D warnings; cargo test --manifest-path ./rust/Cargo.toml --workspace Not-tested: Manual inspection of repos with many nested CLAUDE files
This commit is contained in:
@@ -877,27 +877,33 @@ fn render_config_report() -> Result<String, Box<dyn std::error::Error>> {
|
||||
}
|
||||
|
||||
fn render_memory_report() -> Result<String, Box<dyn std::error::Error>> {
|
||||
let project_context = ProjectContext::discover(env::current_dir()?, DEFAULT_DATE)?;
|
||||
let cwd = env::current_dir()?;
|
||||
let project_context = ProjectContext::discover(&cwd, DEFAULT_DATE)?;
|
||||
let mut lines = vec![format!(
|
||||
"memory: files={}",
|
||||
"Memory
|
||||
Working directory {}
|
||||
Instruction files {}",
|
||||
cwd.display(),
|
||||
project_context.instruction_files.len()
|
||||
)];
|
||||
if project_context.instruction_files.is_empty() {
|
||||
lines.push("Discovered files".to_string());
|
||||
lines.push(
|
||||
" No CLAUDE instruction files discovered in the current directory ancestry."
|
||||
.to_string(),
|
||||
);
|
||||
} else {
|
||||
for file in project_context.instruction_files {
|
||||
lines.push("Discovered files".to_string());
|
||||
for (index, file) in project_context.instruction_files.iter().enumerate() {
|
||||
let preview = file.content.lines().next().unwrap_or("").trim();
|
||||
let preview = if preview.is_empty() {
|
||||
"<empty>"
|
||||
} else {
|
||||
preview
|
||||
};
|
||||
lines.push(format!(" {}. {}", index + 1, file.path.display(),));
|
||||
lines.push(format!(
|
||||
" {} ({}) {}",
|
||||
file.path.display(),
|
||||
" lines={} preview={}",
|
||||
file.content.lines().count(),
|
||||
preview
|
||||
));
|
||||
@@ -1334,8 +1340,9 @@ mod tests {
|
||||
format_cost_report, format_model_report, format_model_switch_report,
|
||||
format_permissions_report, format_permissions_switch_report, format_resume_report,
|
||||
format_status_report, normalize_permission_mode, parse_args, parse_git_status_metadata,
|
||||
render_init_claude_md, render_repl_help, resume_supported_slash_commands, status_context,
|
||||
CliAction, SlashCommand, StatusUsage, DEFAULT_MODEL,
|
||||
render_init_claude_md, render_memory_report, render_repl_help,
|
||||
resume_supported_slash_commands, status_context, CliAction, SlashCommand, StatusUsage,
|
||||
DEFAULT_MODEL,
|
||||
};
|
||||
use runtime::{ContentBlock, ConversationMessage, MessageRole};
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -1564,6 +1571,15 @@ mod tests {
|
||||
assert!(status.contains("Memory files 4"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn memory_report_uses_sectioned_layout() {
|
||||
let report = render_memory_report().expect("memory report should render");
|
||||
assert!(report.contains("Memory"));
|
||||
assert!(report.contains("Working directory"));
|
||||
assert!(report.contains("Instruction files"));
|
||||
assert!(report.contains("Discovered files"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_report_uses_sectioned_layout() {
|
||||
let report = super::render_config_report().expect("config report should render");
|
||||
|
||||
Reference in New Issue
Block a user