Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions crates/jcode-app-core/examples/print_build_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,28 @@ fn main() {
println!(" source_fingerprint: {:?}", info.source_fingerprint);

println!();
println!("current_git_hash: {}", current_git_hash(repo).expect("current_git_hash"));
println!("current_git_hash_full: {}", current_git_hash_full(repo).expect("current_git_hash_full"));
println!("current_git_diff: {}", current_git_diff(repo).expect("current_git_diff"));
println!("current_source_state: {:?}", current_source_state(repo).expect("current_source_state"));
println!("is_working_tree_dirty: {}", is_working_tree_dirty(repo).expect("is_working_tree_dirty"));
println!("current_version_file: {:?}", current_version_file().expect("current_version_file"));
println!(
"current_git_hash: {}",
current_git_hash(repo).expect("current_git_hash")
);
println!(
"current_git_hash_full: {}",
current_git_hash_full(repo).expect("current_git_hash_full")
);
println!(
"current_git_diff: {}",
current_git_diff(repo).expect("current_git_diff")
);
println!(
"current_source_state: {:?}",
current_source_state(repo).expect("current_source_state")
);
println!(
"is_working_tree_dirty: {}",
is_working_tree_dirty(repo).expect("is_working_tree_dirty")
);
println!(
"current_version_file: {:?}",
current_version_file().expect("current_version_file")
);
}
11 changes: 9 additions & 2 deletions crates/jcode-base/tests/mcp_xj07_failure_modes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ async fn unregister_restores_prior_configuration() {

// Verify the prior server is preserved and the removed one is gone.
let restored = McpConfig::load_from_file(&config_path).expect("load restored config");
assert_eq!(restored.servers.len(), 1, "must have exactly 1 server after unregister");
assert_eq!(
restored.servers.len(),
1,
"must have exactly 1 server after unregister"
);
assert!(
restored.servers.contains_key("keep-me"),
"keep-me must survive unregister"
Expand All @@ -342,7 +346,10 @@ async fn unregister_restores_prior_configuration() {
.await
.expect("keep-me must connect");
assert!(
manager.connected_servers().await.contains(&"keep-me".to_string()),
manager
.connected_servers()
.await
.contains(&"keep-me".to_string()),
"keep-me must be in connected set"
);

Expand Down
6 changes: 5 additions & 1 deletion crates/jcode-core/examples/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ fn main() {

let long = "a".repeat(120);
let truncated = util::truncate_str(&long, 20);
println!("util::truncate_str(120 chars, 20) -> len {} ({:?})", truncated.len(), truncated);
println!(
"util::truncate_str(120 chars, 20) -> len {} ({:?})",
truncated.len(),
truncated
);

let sample = "the quick brown fox jumps over the lazy dog";
let est = util::estimate_tokens(sample);
Expand Down
5 changes: 1 addition & 4 deletions crates/jcode-core/src/stdin_detect_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,7 @@ fn test_is_stdin_pipe_is_negation_of_interactive() {
fn test_is_stdin_interactive_consistency_with_is_terminal_trait() {
// Our helper should agree with the raw IsTerminal trait call.
use std::io::IsTerminal;
assert_eq!(
is_stdin_interactive(),
std::io::stdin().is_terminal()
);
assert_eq!(is_stdin_interactive(), std::io::stdin().is_terminal());
}

#[cfg(target_os = "linux")]
Expand Down
20 changes: 8 additions & 12 deletions crates/jcode-harness-api-server/src/translate_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3518,12 +3518,10 @@ fn session_tool_controls_require_attachment_and_negotiated_support() {
),
] {
let actions = state.api_request_to_legacy(&request);
assert!(
matches!(actions.as_slice(), [Outbound::Reply(frame)]
if frame.reply_to == Some(9)
&& matches!(&frame.event, ApiEvent::Error { code, .. } if code == code)
)
);
assert!(matches!(actions.as_slice(), [Outbound::Reply(frame)]
if frame.reply_to == Some(9)
&& matches!(&frame.event, ApiEvent::Error { code, .. } if code == code)
));
assert!(state.pending_simple.is_empty());
}
let mut state = tool_state();
Expand Down Expand Up @@ -3597,12 +3595,10 @@ fn tool_controls_validate_pending_attachment_and_required_session() {
] {
let actions = state
.api_request_to_legacy(&json!({"id":3,"req":"list_tools","session_id":session_id}));
assert!(
matches!(actions.as_slice(), [Outbound::Reply(frame)]
if frame.reply_to == Some(3)
&& matches!(&frame.event, ApiEvent::Error { code, .. } if code == code)
)
);
assert!(matches!(actions.as_slice(), [Outbound::Reply(frame)]
if frame.reply_to == Some(3)
&& matches!(&frame.event, ApiEvent::Error { code, .. } if code == code)
));
}
}

Expand Down
32 changes: 16 additions & 16 deletions crates/jcode-harness-api/src/sockets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ fn product_path(path: PathBuf) -> Option<PathBuf> {

/// Runtime directory holding the daemon and API sockets.
pub fn runtime_dir() -> PathBuf {
if let Ok(dir) = std::env::var("KCODE_RUNTIME_DIR") {
if let Some(path) = product_path(PathBuf::from(dir)) {
return path;
}
if let Ok(dir) = std::env::var("KCODE_RUNTIME_DIR")
&& let Some(path) = product_path(PathBuf::from(dir))
{
return path;
}
if let Ok(dir) = std::env::var("XDG_RUNTIME_DIR") {
if let Some(path) = product_path(PathBuf::from(dir)) {
return path;
}
if let Ok(dir) = std::env::var("XDG_RUNTIME_DIR")
&& let Some(path) = product_path(PathBuf::from(dir))
{
return path;
}
#[cfg(target_os = "macos")]
if let Ok(dir) = std::env::var("TMPDIR") {
Expand Down Expand Up @@ -92,21 +92,21 @@ fn sanitize(raw: String) -> String {

/// Path of the versioned harness API socket. `KCODE_API_SOCKET` overrides it.
pub fn api_socket_path() -> PathBuf {
if let Ok(custom) = std::env::var("KCODE_API_SOCKET") {
if let Some(path) = product_path(PathBuf::from(custom)) {
return path;
}
if let Ok(custom) = std::env::var("KCODE_API_SOCKET")
&& let Some(path) = product_path(PathBuf::from(custom))
{
return path;
}
runtime_dir().join("kcode-api.sock")
}

/// Path of the internal daemon socket the bridge translates onto.
/// `KCODE_SOCKET` overrides it.
pub fn legacy_socket_path() -> PathBuf {
if let Ok(custom) = std::env::var("KCODE_SOCKET") {
if let Some(path) = product_path(PathBuf::from(custom)) {
return path;
}
if let Ok(custom) = std::env::var("KCODE_SOCKET")
&& let Some(path) = product_path(PathBuf::from(custom))
{
return path;
}
runtime_dir().join("kcode.sock")
}
Expand Down
2 changes: 1 addition & 1 deletion crates/jcode-herdr/examples/round_trip_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
//! cargo run -p jcode-herdr --example round_trip_state
//! ```

use jcode_herdr::state::AgentState;
use jcode_herdr::HerdrEnv;
use jcode_herdr::state::AgentState;

fn main() {
for state in [AgentState::Working, AgentState::Idle, AgentState::Blocked] {
Expand Down
1 change: 0 additions & 1 deletion crates/jcode-tui-mermaid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ static RENDER_CACHE: LazyLock<Mutex<MermaidCache>> =
static DEFERRED_RENDER_EPOCH: AtomicU64 = AtomicU64::new(1);

/// Hash of mermaid source text to the geometry triples (w1,h1),(w2,h2),(w3,h3) for three render profiles.

/// This lets transcript clicks copy editable Mermaid text instead of PNG pixels.
static MERMAID_SOURCE_BY_HASH: LazyLock<Mutex<HashMap<u64, String>>> =
LazyLock::new(|| Mutex::new(HashMap::new()));
Expand Down
2 changes: 1 addition & 1 deletion crates/jcode-tui/src/tui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,9 +1067,9 @@ impl CacheTtlInfo {
pub use crate::provider::{cache_ttl_for_provider, cache_ttl_for_provider_model};

mod kv_cache_problem;
pub(crate) use kv_cache_problem::cache_expected_warm;
#[cfg(test)]
pub(crate) use kv_cache_problem::KvCacheProblemKind;
pub(crate) use kv_cache_problem::cache_expected_warm;
pub(crate) use kv_cache_problem::detect_kv_cache_problem;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion tests/cli_exit_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::process::{Command, Output};

fn invoke(args: &[&str]) -> Output {
let root = tempfile::tempdir().unwrap();
let output = Command::new(env!("CARGO_BIN_EXE_jcode"))
let output = Command::new(std::env::var("CARGO_BIN_EXE_jcode").expect("CARGO_BIN_EXE_jcode"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Cargo exposes this binary as CARGO_BIN_EXE_kcode at compile time, not CARGO_BIN_EXE_jcode at runtime, so this lookup fails and expect panics.

Assessment: 🟠 Major · 🔁 Occurrence: Often · 🏷️ Api mismatch

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** tests/cli_exit_status.rs
**Line:** 6:6
**Comment:**
	*Api Mismatch: Cargo exposes this binary as `CARGO_BIN_EXE_kcode` at compile time, not `CARGO_BIN_EXE_jcode` at runtime, so this lookup fails and `expect` panics.

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
👍 | 👎

.current_dir(root.path())
.env_clear()
.env("HOME", root.path())
Expand Down
Loading