v1.6 System Prompt 工程化 + 渐进式技能发现

重构 system prompt 为动态组装系统:PromptComposer 聚合核心身份、AGENTS.md
项目规范和 Skills 目录;新增 read_skill 工具实现技能按需加载;包重命名
internal/context -> internal/prompt 消除 stdlib 冲突。
This commit is contained in:
aruo
2026-05-17 00:05:31 +08:00
parent d84fdbd24e
commit 3e91c7d0a1
8 changed files with 319 additions and 25 deletions
+7 -8
View File
@@ -6,6 +6,7 @@ import (
"log"
"sync"
"go-tiny-claw/internal/prompt"
"go-tiny-claw/internal/provider"
"go-tiny-claw/internal/schema"
"go-tiny-claw/internal/tools"
@@ -19,6 +20,7 @@ type AgentEngine struct {
// WorkDir (工作区): 借鉴 OpenClaw 的理念,Agent 必须有一个明确的物理边界
WorkDir string
EnableThinking bool // 【新增】慢思考模式开关
composer *prompt.PromptComposer
}
func NewAgentEngine(p provider.LLMProvider, r tools.Registry, workDir string, enableThinking bool) *AgentEngine {
@@ -27,6 +29,7 @@ func NewAgentEngine(p provider.LLMProvider, r tools.Registry, workDir string, en
registry: r,
WorkDir: workDir,
EnableThinking: enableThinking,
composer: prompt.NewPromptComposer(workDir),
}
}
@@ -60,15 +63,11 @@ func (e *AgentEngine) Run(ctx context.Context, userPrompt string) error {
log.Printf("[Engine] 引擎启动,锁定工作区: %s\n", e.WorkDir)
log.Printf("[Engine] 慢思考模式 (Thinking Phase): %v\n", e.EnableThinking)
systemMsg := e.composer.Build()
contextHistory := []schema.Message{
{
Role: schema.RoleSystem,
Content: "You are go-tiny-claw, an expert coding assistant. You have full access to tools in the workspace.",
},
{
Role: schema.RoleUser,
Content: userPrompt,
},
systemMsg, // 注入动态组装的内核、AGENTS.md 与 Skills
{Role: schema.RoleUser, Content: userPrompt},
}
turnCount := 0