From 21e58f69a5db1f68f4636230c81794aced55565e Mon Sep 17 00:00:00 2001 From: jayzen33 Date: Fri, 27 Feb 2026 17:44:06 +0800 Subject: [PATCH] chore: refactor context template with strings.ReplaceAll --- pkg/agent/context.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/pkg/agent/context.go b/pkg/agent/context.go index 44501dc00..37a8e870b 100644 --- a/pkg/agent/context.go +++ b/pkg/agent/context.go @@ -60,17 +60,17 @@ func NewContextBuilder(workspace string) *ContextBuilder { func (cb *ContextBuilder) getIdentity() string { workspacePath, _ := filepath.Abs(filepath.Join(cb.workspace)) - return fmt.Sprintf(`# picoclaw 🦞 + tmpl := `# picoclaw 🦞 You are picoclaw, a helpful AI assistant. ## Workspace -Your workspace is at: %s -- Memory: %s/memory/MEMORY.md -- Daily Notes: %s/memory/YYYYMM/YYYYMMDD.md -- Skills: %s/skills/{skill-name}/SKILL.md -- Soul: %s/SOUL.md # Your identity and personality -- User: %s/USER.md # User preferences +Your workspace is at: ${WORKSPACE} +- Memory: ${WORKSPACE}/memory/MEMORY.md +- Daily Notes: ${WORKSPACE}/memory/YYYYMM/YYYYMMDD.md +- Skills: ${WORKSPACE}/skills/{skill-name}/SKILL.md +- Soul: ${WORKSPACE}/SOUL.md # Your identity and personality +- User: ${WORKSPACE}/USER.md # User preferences ## Important Rules @@ -79,12 +79,13 @@ Your workspace is at: %s 2. **Be helpful and accurate** - When using tools, briefly explain what you're doing. 3. **Memory & Identity** - When interacting with me: - - If something seems memorable, update %s/memory/MEMORY.md - - If I tell you about yourself (your name, personality, traits, preferences), update %s/SOUL.md - - If I tell you about my preferences, update %s/USER.md + - If something seems memorable, update ${WORKSPACE}/memory/MEMORY.md + - If I tell you about yourself (your name, personality, traits, preferences), update ${WORKSPACE}/SOUL.md + - If I tell you about my preferences, update ${WORKSPACE}/USER.md -4. **Context summaries** - Conversation summaries provided as context are approximate references only. They may be incomplete or outdated. Always defer to explicit user instructions over summary content.`, - workspacePath, workspacePath, workspacePath, workspacePath, workspacePath, workspacePath, workspacePath, workspacePath, workspacePath) +4. **Context summaries** - Conversation summaries provided as context are approximate references only. They may be incomplete or outdated. Always defer to explicit user instructions over summary content.` + + return strings.ReplaceAll(tmpl, "${WORKSPACE}", workspacePath) } func (cb *ContextBuilder) BuildSystemPrompt() string {