diff --git a/.picoclaw.pid b/.picoclaw.pid deleted file mode 100644 index 9648e6342..000000000 --- a/.picoclaw.pid +++ /dev/null @@ -1,7 +0,0 @@ -{ - "pid": 7160, - "token": "ca0cf39c3f6188acfa724839d8382f1a", - "version": "dev", - "port": 18790, - "host": "localhost" -} \ No newline at end of file diff --git a/logs/gateway.log b/logs/gateway.log index c007e7525..be984dc4f 100644 --- a/logs/gateway.log +++ b/logs/gateway.log @@ -115,3 +115,12 @@ {"level":"debug","component":"heartbeat","time":"2026-04-18T01:43:43+08:00","caller":"D:/Desktop/一面千石/picoclaw/pkg/heartbeat/service.go:163","message":"Executing heartbeat"} {"level":"info","component":"heartbeat","time":"2026-04-18T01:43:43+08:00","caller":"D:/Desktop/一面千石/picoclaw/pkg/heartbeat/service.go:167","message":"No heartbeat prompt (HEARTBEAT.md empty or missing)"} {"level":"error","component":"gateway","config_path":"d:\\Desktop\\一面千石\\picoclaw\\config.json","error":"error opening gateway listeners: failed to open adaptive localhost listener on port 18790","home_path":"d:\\Desktop\\一面千石\\picoclaw","allow_empty":false,"debug":true,"time":"2026-04-18T01:44:16+08:00","caller":"D:/Desktop/一面千石/picoclaw/pkg/gateway/gateway.go:137","message":"Gateway startup failed"} +{"level":"info","component":"gateway","time":"2026-04-18T01:49:32+08:00","caller":"D:/Desktop/一面千石/picoclaw/pkg/gateway/gateway.go:265","message":"Shutting down..."} +{"level":"info","component":"channels","time":"2026-04-18T01:49:32+08:00","caller":"D:/Desktop/一面千石/picoclaw/pkg/channels/manager.go:672","message":"Stopping all channels"} +{"level":"info","component":"channels","time":"2026-04-18T01:49:32+08:00","caller":"D:/Desktop/一面千石/picoclaw/pkg/channels/manager.go:729","message":"All channels stopped"} +{"level":"info","component":"channels","time":"2026-04-18T01:49:32+08:00","caller":"D:/Desktop/一面千石/picoclaw/pkg/channels/manager.go:889","message":"Outbound media dispatcher stopped"} +{"level":"info","component":"channels","time":"2026-04-18T01:49:32+08:00","caller":"D:/Desktop/一面千石/picoclaw/pkg/channels/manager.go:889","message":"Outbound dispatcher stopped"} +{"level":"info","component":"devices","time":"2026-04-18T01:49:32+08:00","caller":"D:/Desktop/一面千石/picoclaw/pkg/devices/service.go:96","message":"Device event service stopped"} +{"level":"info","component":"heartbeat","time":"2026-04-18T01:49:32+08:00","caller":"D:/Desktop/一面千石/picoclaw/pkg/heartbeat/service.go:116","message":"Stopping heartbeat service"} +{"level":"info","component":"gateway","time":"2026-04-18T01:49:32+08:00","caller":"D:/Desktop/一面千石/picoclaw/pkg/gateway/gateway.go:509","message":"✓ Gateway stopped"} +{"level":"info","component":"pid","time":"2026-04-18T01:49:32+08:00","caller":"D:/Desktop/一面千石/picoclaw/pkg/pid/pidfile.go:150","message":"remove pid file: d:\\Desktop\\一面千石\\picoclaw\\.picoclaw.pid"} diff --git a/test_diff_tool.go b/test_diff_tool.go new file mode 100644 index 000000000..5aab82646 --- /dev/null +++ b/test_diff_tool.go @@ -0,0 +1,84 @@ +package main + +import ( + "context" + "fmt" + "os" + + "github.com/sipeed/picoclaw/pkg/tools" +) + +func main() { + workspace, _ := os.Getwd() + maxReadFileSize := 64 * 1024 + + fmt.Println("=== 测试 diff_files 工具 ===\n") + + tool := tools.NewDiffTool(workspace, false, maxReadFileSize) + + fmt.Printf("工具名称: %s\n", tool.Name()) + fmt.Printf("工具描述: %s\n", tool.Description()) + fmt.Println() + + testUnifiedDiff(tool) + testSideBySideDiff(tool) + testIgnoreWhitespace(tool) + + fmt.Println("\n=== 测试完成 ===") +} + +func testUnifiedDiff(tool *tools.DiffTool) { + fmt.Println("--- 测试 1: 统一差异格式 (unified diff) ---") + fmt.Println() + + args := map[string]any{ + "file_a": "test_file_a.txt", + "file_b": "test_file_b.txt", + "format": "unified", + "context_lines": 3, + } + + result := tool.Execute(context.Background(), args) + fmt.Println("结果:") + fmt.Println(result.ForLLM) + fmt.Println() +} + +func testSideBySideDiff(tool *tools.DiffTool) { + fmt.Println("--- 测试 2: 并排对比格式 (side_by_side) ---") + fmt.Println() + + args := map[string]any{ + "file_a": "test_file_a.txt", + "file_b": "test_file_b.txt", + "format": "side_by_side", + } + + result := tool.Execute(context.Background(), args) + fmt.Println("结果:") + fmt.Println(result.ForLLM) + fmt.Println() +} + +func testIgnoreWhitespace(tool *tools.DiffTool) { + fmt.Println("--- 测试 3: 忽略空白字符差异 (ignore_whitespace) ---") + fmt.Println() + + args := map[string]any{ + "file_a": "test_file_a.txt", + "file_b": "test_file_whitespace.txt", + "format": "unified", + "ignore_whitespace": false, + } + + fmt.Println("不忽略空白差异:") + result1 := tool.Execute(context.Background(), args) + fmt.Println(result1.ForLLM) + fmt.Println() + + args["ignore_whitespace"] = true + fmt.Println("忽略空白差异:") + result2 := tool.Execute(context.Background(), args) + fmt.Println(result2.ForLLM) + fmt.Println() +} diff --git a/test_file_a.txt b/test_file_a.txt new file mode 100644 index 000000000..3d043f02f --- /dev/null +++ b/test_file_a.txt @@ -0,0 +1,11 @@ +# 示例文件 A - 原始版本 +这是一个用于测试文件差异对比功能的示例文件。 + +## 功能列表 +- 支持统一差异格式 +- 支持并排对比格式 +- 支持忽略空白字符差异 + +## 注意事项 +请确保文件编码为 UTF-8。 +大文件可能需要较长时间处理。 diff --git a/test_file_b.txt b/test_file_b.txt new file mode 100644 index 000000000..7a3e0dda7 --- /dev/null +++ b/test_file_b.txt @@ -0,0 +1,16 @@ +# 示例文件 B - 修改版本 +这是一个用于测试文件差异对比功能的示例文件。 +新增的一行内容。 + +## 功能列表 +- 支持统一差异格式 +- 支持并排对比格式 +- 支持忽略空白字符差异 +- 新增:支持彩色输出(新增功能) + +## 注意事项 +请确保文件编码为 UTF-8。 +大文件可能需要较长时间处理。 + +## 更新日志 +- 2026-04-18: 新增功能说明 diff --git a/test_file_whitespace.txt b/test_file_whitespace.txt new file mode 100644 index 000000000..0296ca1b5 --- /dev/null +++ b/test_file_whitespace.txt @@ -0,0 +1,11 @@ +# 示例文件 A - 原始版本 +这是一个用于测试文件差异对比功能的示例文件。 + +## 功能列表 +- 支持统一差异格式 +- 支持并排对比格式 +- 支持忽略空白字符差异 + +## 注意事项 +请确保文件编码为 UTF-8。 +大文件可能需要较长时间处理。