feat: 添加初始项目结构和基础文件
CI - 构建、测试和质量检查 / Rust 代码检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / 单元测试 (push) Has been cancelled
CI - 构建、测试和质量检查 / 代码格式检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / Clippy 代码质量检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs, ubuntu-latest, x86_64-unknown-linux-gnu) (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs.exe, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
CI - 构建、测试和质量检查 / Rust 代码检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / 单元测试 (push) Has been cancelled
CI - 构建、测试和质量检查 / 代码格式检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / Clippy 代码质量检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs, ubuntu-latest, x86_64-unknown-linux-gnu) (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs.exe, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
- 添加 Rust GUI 桌面应用程序入口点 - 添加 TypeScript/JavaScript 项目基础结构文件 - 包含组件、工具、命令、服务和工具定义 - 添加配置文件如 .gitignore、.gitattributes 和 LICENSE - 包含图片资源和演示文件 - 为各种功能模块添加占位符和类型定义
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
//! Integration Tests for Claude Code Rust
|
||||
|
||||
use claude_code_rs::{
|
||||
cli::Cli,
|
||||
config::Settings,
|
||||
state::AppState,
|
||||
tools::ToolRegistry,
|
||||
skills::{SkillRegistry, SkillExecutor, SkillContext, BuiltinSkills, SkillCategory},
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[test]
|
||||
fn test_cli_initialization() {
|
||||
// Test that CLI can be parsed
|
||||
let cli = Cli::parse_from(vec!["claude-code"]);
|
||||
// Should not panic
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_settings_load() {
|
||||
// Settings should load with defaults
|
||||
let settings = Settings::load();
|
||||
// May fail if no config file exists, but should not panic
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_tool_system_integration() {
|
||||
let registry = ToolRegistry::new();
|
||||
|
||||
// Test that all expected tools are registered
|
||||
let tools = registry.list();
|
||||
let tool_names: Vec<&str> = tools.iter().map(|t| t.name()).collect();
|
||||
|
||||
assert!(tool_names.contains(&"file_read"));
|
||||
assert!(tool_names.contains(&"file_edit"));
|
||||
assert!(tool_names.contains(&"file_write"));
|
||||
assert!(tool_names.contains(&"execute_command"));
|
||||
assert!(tool_names.contains(&"search"));
|
||||
assert!(tool_names.contains(&"list_files"));
|
||||
assert!(tool_names.contains(&"git_operations"));
|
||||
assert!(tool_names.contains(&"task_management"));
|
||||
assert!(tool_names.contains(&"note_edit"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_skill_system_integration() {
|
||||
let mut registry = SkillRegistry::new();
|
||||
|
||||
// Register all built-in skills
|
||||
for (skill, categories) in BuiltinSkills::all() {
|
||||
registry.register(Arc::new(skill), categories);
|
||||
}
|
||||
|
||||
// Verify all categories are represented
|
||||
let categories = registry.get_categories();
|
||||
assert!(categories.contains(&SkillCategory::Git));
|
||||
assert!(categories.contains(&SkillCategory::Utility));
|
||||
|
||||
// Test skill execution
|
||||
let registry_arc = Arc::new(registry);
|
||||
let executor = SkillExecutor::new(registry_arc);
|
||||
|
||||
let context = SkillContext {
|
||||
cwd: std::env::current_dir()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
env: std::collections::HashMap::new(),
|
||||
tool_registry: None,
|
||||
data: std::collections::HashMap::new(),
|
||||
};
|
||||
|
||||
// Test each skill
|
||||
for skill_name in vec!["commit", "review", "test", "document", "build"] {
|
||||
let result = executor.execute(skill_name, "", context.clone()).await;
|
||||
assert!(
|
||||
result.is_ok(),
|
||||
"Skill {} should execute successfully",
|
||||
skill_name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lib_exports() {
|
||||
// Verify all public types are exported
|
||||
use claude_code_rs::{
|
||||
Skill, SkillRegistry, SkillExecutor, SkillContext, SkillParams,
|
||||
SkillResult, SkillError, SkillCategory
|
||||
};
|
||||
// If this compiles, exports are correct
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_new_tools_functionality() {
|
||||
use serde_json::json;
|
||||
|
||||
let registry = ToolRegistry::new();
|
||||
|
||||
// Test git status
|
||||
let git_result = registry.execute("git_operations", json!({
|
||||
"operation": "status"
|
||||
})).await;
|
||||
|
||||
// May fail if not in git repo, but should not panic
|
||||
let _ = git_result;
|
||||
|
||||
// Test task creation
|
||||
let task_result = registry.execute("task_management", json!({
|
||||
"operation": "create",
|
||||
"subject": "Integration Test Task",
|
||||
"description": "Testing task management tool",
|
||||
"priority": "high"
|
||||
})).await;
|
||||
|
||||
assert!(task_result.is_ok(), "Task creation should succeed");
|
||||
|
||||
// Test note creation
|
||||
let note_result = registry.execute("note_edit", json!({
|
||||
"operation": "create",
|
||||
"title": "Integration Test Note",
|
||||
"content": "Testing note edit tool",
|
||||
"tags": ["test", "integration"]
|
||||
})).await;
|
||||
|
||||
assert!(note_result.is_ok(), "Note creation should succeed");
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
//! Tests for Skills Framework
|
||||
|
||||
use claude_code_rs::skills::{SkillRegistry, SkillExecutor, SkillContext, SkillCategory, BuiltinSkills};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[test]
|
||||
fn test_skill_registry_creation() {
|
||||
let registry = SkillRegistry::new();
|
||||
assert!(registry.list_names().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_skill_registration() {
|
||||
let mut registry = SkillRegistry::new();
|
||||
|
||||
// Register built-in skills
|
||||
for (skill, categories) in BuiltinSkills::all() {
|
||||
registry.register(Arc::new(skill), categories);
|
||||
}
|
||||
|
||||
// Should have 5 skills now
|
||||
assert_eq!(registry.list_names().len(), 5);
|
||||
|
||||
// Check specific skills exist
|
||||
assert!(registry.has("commit"));
|
||||
assert!(registry.has("review"));
|
||||
assert!(registry.has("test"));
|
||||
assert!(registry.has("document"));
|
||||
assert!(registry.has("build"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_skill_search() {
|
||||
let mut registry = SkillRegistry::new();
|
||||
|
||||
// Register built-in skills
|
||||
for (skill, categories) in BuiltinSkills::all() {
|
||||
registry.register(Arc::new(skill), categories);
|
||||
}
|
||||
|
||||
// Search for "commit"
|
||||
let results = registry.search("commit");
|
||||
assert!(!results.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_skill_categories() {
|
||||
let mut registry = SkillRegistry::new();
|
||||
|
||||
// Register built-in skills
|
||||
for (skill, categories) in BuiltinSkills::all() {
|
||||
registry.register(Arc::new(skill), categories);
|
||||
}
|
||||
|
||||
// Check Git category
|
||||
let git_skills = registry.list_by_category(SkillCategory::Git);
|
||||
assert!(!git_skills.is_empty());
|
||||
|
||||
// Check Utility category (should have multiple)
|
||||
let utility_skills = registry.list_by_category(SkillCategory::Utility);
|
||||
assert_eq!(utility_skills.len(), 5);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_skill_executor() {
|
||||
let mut registry = SkillRegistry::new();
|
||||
|
||||
// Register built-in skills
|
||||
for (skill, categories) in BuiltinSkills::all() {
|
||||
registry.register(Arc::new(skill), categories);
|
||||
}
|
||||
|
||||
let registry_arc = Arc::new(registry);
|
||||
let executor = SkillExecutor::new(registry_arc);
|
||||
|
||||
// List skills
|
||||
let skills = executor.list_skills();
|
||||
assert_eq!(skills.len(), 5);
|
||||
|
||||
// Execute commit skill
|
||||
let context = SkillContext {
|
||||
cwd: ".".to_string(),
|
||||
env: std::collections::HashMap::new(),
|
||||
tool_registry: None,
|
||||
data: std::collections::HashMap::new(),
|
||||
};
|
||||
|
||||
let result = executor.execute("commit", "", context).await;
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_skill_help() {
|
||||
let mut registry = SkillRegistry::new();
|
||||
|
||||
// Register built-in skills
|
||||
for (skill, categories) in BuiltinSkills::all() {
|
||||
registry.register(Arc::new(skill), categories);
|
||||
}
|
||||
|
||||
let registry_arc = Arc::new(registry);
|
||||
let executor = SkillExecutor::new(registry_arc);
|
||||
|
||||
// Get help for commit skill
|
||||
let help = executor.get_help("commit");
|
||||
assert!(help.is_ok());
|
||||
let help_text = help.unwrap();
|
||||
assert!(help_text.contains("Skill: commit"));
|
||||
assert!(help_text.contains("Examples:"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_skill_parameter_parsing() {
|
||||
let mut registry = SkillRegistry::new();
|
||||
|
||||
// Register built-in skills
|
||||
for (skill, categories) in BuiltinSkills::all() {
|
||||
registry.register(Arc::new(skill), categories);
|
||||
}
|
||||
|
||||
let registry_arc = Arc::new(registry);
|
||||
let executor = SkillExecutor::new(registry_arc);
|
||||
|
||||
// Parse input with flags
|
||||
let params = executor.parse_input("--message=\"test message\" --verbose");
|
||||
assert_eq!(params.named_params.get("message"), Some(&"test message".to_string()));
|
||||
assert!(params.flags.contains_key("verbose"));
|
||||
|
||||
// Parse input with positional args
|
||||
let params2 = executor.parse_input("file1.rs file2.rs");
|
||||
assert_eq!(params2.args.len(), 2);
|
||||
assert_eq!(params2.args[0], "file1.rs");
|
||||
assert_eq!(params2.args[1], "file2.rs");
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
//! Tests for Tools Module
|
||||
|
||||
use claude_code_rs::tools::{ToolRegistry, ToolOutput};
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_tool_registry_creation() {
|
||||
let registry = ToolRegistry::new();
|
||||
let tools = registry.list();
|
||||
|
||||
// Should have 9 tools now (6 original + 3 new)
|
||||
assert!(tools.len() >= 6);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_file_read_tool() {
|
||||
let registry = ToolRegistry::new();
|
||||
let tool = registry.get("file_read").expect("file_read tool should exist");
|
||||
|
||||
assert_eq!(tool.name(), "file_read");
|
||||
assert!(!tool.description().is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_git_operations_tool() {
|
||||
let registry = ToolRegistry::new();
|
||||
let tool = registry.get("git_operations").expect("git_operations tool should exist");
|
||||
|
||||
assert_eq!(tool.name(), "git_operations");
|
||||
assert!(tool.description().contains("Git"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_task_management_tool() {
|
||||
let registry = ToolRegistry::new();
|
||||
let tool = registry.get("task_management").expect("task_management tool should exist");
|
||||
|
||||
assert_eq!(tool.name(), "task_management");
|
||||
assert!(tool.description().contains("task"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_note_edit_tool() {
|
||||
let registry = ToolRegistry::new();
|
||||
let tool = registry.get("note_edit").expect("note_edit tool should exist");
|
||||
|
||||
assert_eq!(tool.name(), "note_edit");
|
||||
assert!(tool.description().contains("note"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_task_create_and_list() {
|
||||
use serde_json::json;
|
||||
|
||||
let registry = ToolRegistry::new();
|
||||
|
||||
// Create a task
|
||||
let create_result = registry.execute("task_management", json!({
|
||||
"operation": "create",
|
||||
"subject": "Test Task",
|
||||
"description": "This is a test task"
|
||||
})).await;
|
||||
|
||||
assert!(create_result.is_ok());
|
||||
|
||||
// List tasks
|
||||
let list_result = registry.execute("task_management", json!({
|
||||
"operation": "list"
|
||||
})).await;
|
||||
|
||||
assert!(list_result.is_ok());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_note_create_and_search() {
|
||||
use serde_json::json;
|
||||
|
||||
let registry = ToolRegistry::new();
|
||||
|
||||
// Create a note
|
||||
let create_result = registry.execute("note_edit", json!({
|
||||
"operation": "create",
|
||||
"title": "Test Note",
|
||||
"content": "This is a test note content",
|
||||
"tags": ["test", "example"]
|
||||
})).await;
|
||||
|
||||
assert!(create_result.is_ok());
|
||||
|
||||
// Search notes
|
||||
let search_result = registry.execute("note_edit", json!({
|
||||
"operation": "search",
|
||||
"search_query": "test"
|
||||
})).await;
|
||||
|
||||
assert!(search_result.is_ok());
|
||||
}
|
||||
Reference in New Issue
Block a user