Bump version to 1.6.3

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ryan Ward
2026-06-12 14:17:06 -05:00
co-authored by Claude Opus 4.6
parent 4ba9706e35
commit 59cfd0e2f5
152 changed files with 8276 additions and 1664 deletions
@@ -13,15 +13,8 @@ use crate::{
},
};
/// Minimum number of tokens users' input should have before kicking off input detection
/// to switch from AI input to command input.
/// This could be tuned.
const MINIMUM_COMMAND_DETECTION_TOKEN_LENGTH: u8 = 2;
/// Minimum number of tokens users' input should have before kicking off input detection
/// to switch from command input to AI input.
/// This could be tuned.
const MINIMUM_NATURAL_LANGUAGE_DETECTION_TOKEN_LENGTH: u8 = 2;
/// Minimum number of characters the input buffer must have before classification runs.
const MINIMUM_CLASSIFICATION_CHAR_LENGTH: usize = 3;
/// The percentage of input tokens that can be recognized as a natural language word before
/// we consider the input as natural language. This could be tuned.
@@ -43,20 +36,32 @@ impl InputClassifier for HeuristicClassifier {
let word_tokens = parse_query_into_tokens(input.buffer_text.as_str());
let total_word_token_count = word_tokens.len();
log::info!(
"[input-classifier] detect_input_type called: buffer={:?}, word_tokens={}, current={:?}",
&input.buffer_text,
total_word_token_count,
context.current_input_type
);
if total_word_token_count == 1
&& is_one_off_natural_language_word_or_prefix(&word_tokens[0].to_lowercase())
{
log::info!("[input-classifier] → one-off NL word, returning AI");
return InputType::AI;
}
if is_likely_shell_command(&input, total_word_token_count).await {
log::info!("[input-classifier] → is_likely_shell_command=true, returning Shell");
return InputType::Shell;
}
self.classify_input(input, context)
let result = self.classify_input(input, context)
.await
.map(|result| result.to_input_type())
.unwrap_or(context.current_input_type)
.unwrap_or(context.current_input_type);
log::info!("[input-classifier] → classify_input returned {:?}", result);
result
}
async fn classify_input(
@@ -96,18 +101,12 @@ impl InputClassifier for HeuristicClassifier {
async fn natural_language_detection_heuristic(
input: ParsedTokensSnapshot,
word_tokens: Vec<String>,
current_input_type: InputType,
_current_input_type: InputType,
include_last_token: bool,
) -> ClassificationResult {
let word_tokens_count = word_tokens.len();
let _word_tokens_count = word_tokens.len();
let min_token_length = if matches!(current_input_type, InputType::AI) {
MINIMUM_COMMAND_DETECTION_TOKEN_LENGTH
} else {
MINIMUM_NATURAL_LANGUAGE_DETECTION_TOKEN_LENGTH
};
if min_token_length > word_tokens_count as u8 {
if input.buffer_text.len() < MINIMUM_CLASSIFICATION_CHAR_LENGTH {
return ClassificationResult::pure_shell();
}
+12 -19
View File
@@ -58,20 +58,16 @@ pub fn is_prefix_of_natural_language_word(input: &str) -> bool {
pub async fn is_likely_shell_command(
input: &ParsedTokensSnapshot,
word_tokens_count: usize,
_word_tokens_count: usize,
) -> bool {
const YIELD_BATCH_SIZE: usize = 5;
let mut likely_command_token_count = 0;
let total_token_count = input.parsed_tokens.len();
let mut is_first_token_command = false;
for (idx, token) in input.parsed_tokens.iter().enumerate() {
// Periodically, yield to the executor so this task can be aborted if
// requested.
if idx % YIELD_BATCH_SIZE == 0 {
futures_lite::future::yield_now().await;
}
// Early return if we encounter a one-off command / keyword at the beginning of the line.
if token.token_index == 0 && ONE_OFF_SHELL_COMMAND_KEYWORDS.contains(&token.token.as_str())
{
return true;
@@ -82,10 +78,6 @@ pub async fn is_likely_shell_command(
{
likely_command_token_count += 1;
}
if token.token_index == 0 {
is_first_token_command = token.token_description.is_some();
}
}
// When token count is lower than 2, we should make sure all tokens
@@ -98,16 +90,17 @@ pub async fn is_likely_shell_command(
DETECT_AS_COMMAND_THRESHOLD
};
// Classify as shell if:
// 1) We hit significant threshold of likely shell command tokens.
// 2) When there are fewer than 3 tokens, the first token is a valid top-level command.
if likely_command_token_count >= (total_token_count as f32 * command_threshold) as usize
|| (word_tokens_count < 3 && is_first_token_command)
{
return true;
}
false
let threshold_count = (total_token_count as f32 * command_threshold) as usize;
let is_shell = likely_command_token_count >= threshold_count;
log::info!(
"[input-classifier] is_likely_shell_command: tokens={}, cmd_tokens={}, threshold={:.2} (need {}), result={}",
total_token_count,
likely_command_token_count,
command_threshold,
threshold_count,
is_shell
);
is_shell
}
/// Returns true if the first token is a command that is installed on the system.