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
Loading