清理 main.go 模板代码并补充 README 文档

- 移除 main.go 中的 GoLand 自动生成模板代码,替换为项目实际入口
- 补充空的 README.md,添加项目说明、架构图、模块表和快速开始指南
This commit is contained in:
zhuyongxin
2026-05-14 15:36:42 +08:00
parent 6dba8028d3
commit b8459ef36c
2 changed files with 118 additions and 12 deletions
+50 -12
View File
@@ -1,21 +1,59 @@
package main
import (
"fmt"
"context"
"log"
"os"
"go-tiny-claw/internal/engine"
"go-tiny-claw/internal/schema"
)
//TIP <p>To run your code, right-click the code and select <b>Run</b>.</p> <p>Alternatively, click
// the <icon src="AllIcons.Actions.Execute"/> icon in the gutter and select the <b>Run</b> menu item from here.</p>
// mockProvider 模拟大模型推理
type mockProvider struct {
turn int
}
func main() {
//TIP <p>Press <shortcut actionId="ShowIntentionActions"/> when your caret is at the underlined text
// to see how GoLand suggests fixing the warning.</p><p>Alternatively, if available, click the lightbulb to view possible fixes.</p>
s := "gopher"
fmt.Printf("Hello and welcome, %s!\n", s)
func (m *mockProvider) Generate(ctx context.Context, msgs []schema.Message, _ []schema.ToolDefinition) (*schema.Message, error) {
m.turn++
if m.turn == 1 {
return &schema.Message{
Role: schema.RoleAssistant,
Content: "让我来看看当前目录下有什么文件。",
ToolCalls: []schema.ToolCall{
{ID: "call_123", Name: "bash", Arguments: []byte(`{"command": "ls -la"}`)},
},
}, nil
}
return &schema.Message{
Role: schema.RoleAssistant,
Content: "我看到了文件列表,里面包含 main.go,任务完成!",
}, nil
}
for i := 1; i <= 5; i++ {
//TIP <p>To start your debugging session, right-click your code in the editor and select the Debug option.</p> <p>We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.</p>
fmt.Println("i =", 100/i)
// mockRegistry 模拟工具执行
type mockRegistry struct{}
func (m *mockRegistry) GetAvailableTools() []schema.ToolDefinition { return nil }
func (m *mockRegistry) Execute(ctx context.Context, call schema.ToolCall) schema.ToolResult {
return schema.ToolResult{
ToolCallID: call.ID,
Output: "-rw-r--r-- 1 user group 234 Oct 24 10:00 main.go\n",
IsError: false,
}
}
func main() {
workDir, _ := os.Getwd()
p := &mockProvider{}
r := &mockRegistry{}
eng := engine.NewAgentEngine(p, r, workDir)
err := eng.Run(context.Background(), "帮我检查当前目录的文件")
if err != nil {
log.Fatalf("引擎崩溃: %v", err)
}
}