Skip to content
Merged
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
1 change: 1 addition & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ disallowed-methods = []
disallowed-types = []

too-many-arguments-threshold = 10
doc-valid-idents = ["OpenAI", "OpenRouter", ".."]
allow-unwrap-in-tests = true
allow-print-in-tests = true
allowed-duplicate-crates = [
Expand Down
29 changes: 9 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ backon = { version = "1", default-features = false }
base64 = { version = "0.22", default-features = false }
bat = { version = "0.25", default-features = false }
clap = { version = "4", default-features = false }
comfy-table = { version = "7", default-features = false }
comrak = { version = "0.41", default-features = false }
clean-path = { version = "0.2", default-features = false }
comfy-table = { version = "7", default-features = false }
comrak = { version = "0.49", default-features = false }
crossbeam-channel = { version = "0.5", default-features = false }
crossterm = { version = "0.29", default-features = false }
dhat = { version = "0.3", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/jp_cli/src/cmd/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ impl Query {
biased,
signals.recv(),
|signal| {
debug!(?signal, "Received signal.");
info!(?signal, "Received signal.");
match signal {
// Stop processing events, but gracefully store the
// conversation state.
Expand Down
6 changes: 3 additions & 3 deletions crates/jp_cli/src/cmd/query/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl StreamEventHandler {
// If the response includes reasoning, we add two newlines
// after the reasoning, but before the content.
if !matches!(reasoning_display, ReasoningDisplayConfig::Hidden) && reasoning_ended {
message = format!("\n---\n\n{message}");
message = format!("\n\n---\n\n{message}");
}

Some(message)
Expand Down Expand Up @@ -503,7 +503,7 @@ fn build_tool_call_response(
}

if handler.render_tool_calls {
if !data.ends_with('\n') {
if !data.is_empty() && !data.ends_with('\n') {
data.push('\n');
}

Expand Down Expand Up @@ -594,7 +594,7 @@ mod tests {
},
chunk: ChatResponse::message("Answer"),
show_reasoning: true,
output: Some("\n---\n\nAnswer".into()),
output: Some("\n\n---\n\nAnswer".into()),
mutated_handler: StreamEventHandler {
reasoning_tokens: "I reasoned".into(),
content_tokens: "Answer".into(),
Expand Down
4 changes: 2 additions & 2 deletions crates/jp_cli/src/cmd/query/response_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ impl ResponseHandler {
let empty_lines_end_count = lines.iter().rev().take_while(|s| s.is_empty()).count();

let options = comrak::Options {
render: comrak::RenderOptions {
unsafe_: true,
render: comrak::options::Render {
r#unsafe: true,
prefer_fenced: true,
experimental_minimize_commonmark: true,
..Default::default()
Expand Down
18 changes: 2 additions & 16 deletions crates/jp_cli/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{
};

use duct::Expression;
use itertools::Itertools;
use jp_config::{
AppConfig, PartialAppConfig, ToPartial as _, model::parameters::PartialReasoningConfig,
};
Expand Down Expand Up @@ -272,19 +271,6 @@ pub(crate) fn edit_query(

fn build_config_text(config: &AppConfig) -> String {
let model_id = &config.assistant.model.id;
let mut tools = config
.conversation
.tools
.iter()
.filter_map(|(k, cfg)| cfg.enable().then_some(k))
.sorted()
.collect::<Vec<_>>()
.join(", ");

if tools.is_empty() {
tools = "(none)".to_owned();
}

let mut active_config = PartialAppConfig::empty();
active_config.assistant.model.id = model_id.to_partial();
active_config.assistant.model.parameters.reasoning = config
Expand Down Expand Up @@ -318,9 +304,9 @@ fn build_history_text(history: &ConversationStream) -> String {
.unwrap_or_else(|_| event.timestamp.to_string());

let options = comrak::Options {
render: comrak::RenderOptions {
render: comrak::options::Render {
width: 80,
unsafe_: true,
r#unsafe: true,
prefer_fenced: true,
experimental_minimize_commonmark: true,
..Default::default()
Expand Down
3 changes: 2 additions & 1 deletion crates/jp_config/src/providers/llm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ use crate::{
openai::{OpenaiConfig, PartialOpenaiConfig},
openrouter::{OpenrouterConfig, PartialOpenrouterConfig},
},
util::merge_nested_indexmap,
};

/// Provider configuration.
#[derive(Debug, Clone, PartialEq, Config)]
#[config(default, rename_all = "snake_case")]
pub struct LlmProviderConfig {
/// Aliases for specific provider/model combinations.
#[setting(nested)]
#[setting(nested, merge = merge_nested_indexmap)]
pub aliases: IndexMap<String, ModelIdConfig>,

/// Anthropic API configuration.
Expand Down
6 changes: 4 additions & 2 deletions crates/jp_config/src/types/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,15 @@ impl ToPartial for MergedString {
#[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize, ConfigEnum)]
#[serde(rename_all = "snake_case")]
pub enum MergedStringStrategy {
/// Append the string to the previous value.
/// Append this string to the existing string, using the `separator` value.
#[default]
Append,

/// Prepend the string to the previous value.
/// Prepend this string to the existing string, using the `separator` value.
Prepend,

/// Replace the existing string with this one.
///
/// See [`schematic::merge::replace`].
Replace,
}
Expand Down
1 change: 1 addition & 0 deletions crates/jp_config/src/types/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ where

/// Strings that are merged using the specified merge strategy.
#[derive(Debug, Config, Default, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct MergedVec<T> {
/// The vec value.
#[setting(default = vec![])]
Expand Down
2 changes: 1 addition & 1 deletion crates/jp_conversation/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub enum Error {
Thread(String),

/// Unknown conversation ID.
#[error("unknown conversation ID")]
#[error("unknown conversation ID: {0}")]
UnknownId(ConversationId),

/// Configuration error.
Expand Down
7 changes: 7 additions & 0 deletions crates/jp_workspace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ impl Workspace {
let _err = events
.entry(metadata.active_conversation_id)
.or_default()
// FIXME: This can fail without recourse, if the active conversation
// has a corrupt (or missing) events file. The user has to manually
// change the `active_conversation_id` in their user local storage
// to fix this state.
//
// Instead, we should perhaps track "bad" conversation IDs and skip
// them when retrying loading the workspace state.
.set(storage.load_conversation_events(&metadata.active_conversation_id)?);

self.state = State {
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ coverage-ci: _coverage-ci-setup
cargo llvm-cov --no-cfg-coverage --no-cfg-coverage-nightly --no-report --doc
cargo llvm-cov report --doctests --lcov --output-path lcov.info

_coverage-ci-setup: (_rustup_component "llvm-tools-preview") (_install "cargo-llvm-cov@" + llvm_cov_version + " cargo-nextest@" + nextest_version + " cargo-expand@" + expand_version) _install_ci_matchers
_coverage-ci-setup: (_rustup_component "llvm-tools") (_install "cargo-llvm-cov@" + llvm_cov_version + " cargo-nextest@" + nextest_version + " cargo-expand@" + expand_version) _install_ci_matchers

# Check for security vulnerabilities on CI.
[group('ci')]
Expand Down
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# accidentally use unstable features that would not work on the stable release.
#
# When releasing a new version of the binary, we build it with the stable compiler.
channel = "nightly-2025-11-11"
components = ["cargo", "rustfmt", "clippy", "rust-analyzer", "llvm-tools-preview"]
channel = "nightly-2025-11-30" # later versions break llvm-cov, need to investigate.
components = ["cargo", "rustfmt", "clippy", "rust-analyzer", "llvm-tools"]
Loading