generated from nhcarrigan/template
feat: CLI v2.1.81–v2.1.104 support (#261)
## Summary Implements support for all Claude Code CLI changes from v2.1.81 through v2.1.104, closing issues #253–#260. ### Changes - **#253** — New `CwdChanged` hook event: parse and emit `claude:cwd-changed` Tauri event; new `CwdChangedEvent` type - **#254** — New `FileChanged` hook event: parse and emit `claude:file-changed` Tauri event; new `FileChangedEvent` type - **#255** — Idle-return prompt: TUI-only feature, not present in `--output-format stream-json` mode — closed as not applicable - **#256** — New `TaskCreated` and `PermissionDenied` hook events: parse and emit `claude:task-created` / `claude:permission-denied` Tauri events; `PermissionDenied` also triggers `CharacterState::Permission` character animation - **#257** — Defer permission request: no PreToolUse hook response mechanism in Hikari Desktop — closed as not applicable - **#258** — `Monitor` tool: added `"Monitor"` to `SEARCH_TOOLS` constant so it maps to `CharacterState::Searching` - **#259** — `disableSkillShellExecution` setting: wired through `ClaudeStartOptions`, `HikariConfig`, `--settings` JSON, TypeScript interface, and exposed in the Config Sidebar UI - **#260** — Updated `SUPPORTED_CLI_VERSION` constant from `"2.1.80"` to `"2.1.104"` All changes pass `check-all.sh` (ESLint → Prettier → svelte-check → Vitest → Clippy → cargo test with llvm-cov). ✨ This PR was created with help from Hikari~ 🌸 Reviewed-on: #261 Co-authored-by: Hikari <hikari@nhcarrigan.com> Co-committed-by: Hikari <hikari@nhcarrigan.com>
This commit was merged in pull request #261.
This commit is contained in:
@@ -318,6 +318,42 @@ pub struct PostCompactEvent {
|
||||
pub conversation_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct CwdChangedEvent {
|
||||
pub cwd: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub conversation_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct FileChangedEvent {
|
||||
pub file: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub conversation_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct TaskCreatedEvent {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub task_id: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub description: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub parent_tool_use_id: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub conversation_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct PermissionDeniedEvent {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub tool_name: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub reason: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub conversation_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct AgentStartEvent {
|
||||
pub tool_use_id: String,
|
||||
@@ -741,4 +777,137 @@ mod tests {
|
||||
assert!(serialized.contains("\"session_id\":\"sess-xyz\""));
|
||||
assert!(!serialized.contains("conversation_id"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cwd_changed_event_serialization() {
|
||||
let event = CwdChangedEvent {
|
||||
cwd: "/home/naomi/code/my-project".to_string(),
|
||||
conversation_id: Some("conv-abc".to_string()),
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&event).unwrap();
|
||||
assert!(serialized.contains("\"cwd\":\"/home/naomi/code/my-project\""));
|
||||
assert!(serialized.contains("\"conversation_id\":\"conv-abc\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cwd_changed_event_omits_none_fields() {
|
||||
let event = CwdChangedEvent {
|
||||
cwd: "/tmp/workspace".to_string(),
|
||||
conversation_id: None,
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&event).unwrap();
|
||||
assert!(serialized.contains("\"cwd\":\"/tmp/workspace\""));
|
||||
assert!(!serialized.contains("conversation_id"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_file_changed_event_serialization() {
|
||||
let event = FileChangedEvent {
|
||||
file: "/home/naomi/code/my-project/src/main.rs".to_string(),
|
||||
conversation_id: Some("conv-abc".to_string()),
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&event).unwrap();
|
||||
assert!(serialized.contains("\"file\":\"/home/naomi/code/my-project/src/main.rs\""));
|
||||
assert!(serialized.contains("\"conversation_id\":\"conv-abc\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_file_changed_event_omits_none_fields() {
|
||||
let event = FileChangedEvent {
|
||||
file: "/tmp/test.txt".to_string(),
|
||||
conversation_id: None,
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&event).unwrap();
|
||||
assert!(serialized.contains("\"file\":\"/tmp/test.txt\""));
|
||||
assert!(!serialized.contains("conversation_id"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_task_created_event_serialization() {
|
||||
let event = TaskCreatedEvent {
|
||||
task_id: Some("task-abc123".to_string()),
|
||||
description: Some("Explore the codebase".to_string()),
|
||||
parent_tool_use_id: Some("toolu_xyz".to_string()),
|
||||
conversation_id: Some("conv-abc".to_string()),
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&event).unwrap();
|
||||
assert!(serialized.contains("\"task_id\":\"task-abc123\""));
|
||||
assert!(serialized.contains("\"description\":\"Explore the codebase\""));
|
||||
assert!(serialized.contains("\"parent_tool_use_id\":\"toolu_xyz\""));
|
||||
assert!(serialized.contains("\"conversation_id\":\"conv-abc\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_task_created_event_omits_none_fields() {
|
||||
let event = TaskCreatedEvent {
|
||||
task_id: None,
|
||||
description: None,
|
||||
parent_tool_use_id: None,
|
||||
conversation_id: None,
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&event).unwrap();
|
||||
assert_eq!(serialized, "{}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_task_created_event_partial_fields() {
|
||||
let event = TaskCreatedEvent {
|
||||
task_id: Some("task-001".to_string()),
|
||||
description: None,
|
||||
parent_tool_use_id: None,
|
||||
conversation_id: None,
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&event).unwrap();
|
||||
assert!(serialized.contains("\"task_id\":\"task-001\""));
|
||||
assert!(!serialized.contains("description"));
|
||||
assert!(!serialized.contains("parent_tool_use_id"));
|
||||
assert!(!serialized.contains("conversation_id"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_permission_denied_event_serialization() {
|
||||
let event = PermissionDeniedEvent {
|
||||
tool_name: Some("Bash".to_string()),
|
||||
reason: Some("Tool not in allow list".to_string()),
|
||||
conversation_id: Some("conv-abc".to_string()),
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&event).unwrap();
|
||||
assert!(serialized.contains("\"tool_name\":\"Bash\""));
|
||||
assert!(serialized.contains("\"reason\":\"Tool not in allow list\""));
|
||||
assert!(serialized.contains("\"conversation_id\":\"conv-abc\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_permission_denied_event_omits_none_fields() {
|
||||
let event = PermissionDeniedEvent {
|
||||
tool_name: None,
|
||||
reason: None,
|
||||
conversation_id: None,
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&event).unwrap();
|
||||
assert_eq!(serialized, "{}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_permission_denied_event_partial_fields() {
|
||||
let event = PermissionDeniedEvent {
|
||||
tool_name: Some("Edit".to_string()),
|
||||
reason: None,
|
||||
conversation_id: None,
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&event).unwrap();
|
||||
assert!(serialized.contains("\"tool_name\":\"Edit\""));
|
||||
assert!(!serialized.contains("reason"));
|
||||
assert!(!serialized.contains("conversation_id"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user