Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: AI Agent https://github.com/siyuan-note/siyuan/issues/17797

Daniel824d1dc7fba2
diff --git a/kernel/agent/agent.go b/kernel/agent/agent.go
index 2f28305d63..8ee733c366 100644
--- a/kernel/agent/agent.go
+++ b/kernel/agent/agent.go
@@ -46,11 +46,13 @@ const systemPrompt = `You are a SiYuan AI assistant. You help users manage their
- Notebook: a top-level container holding documents. Use notebook.list to see all notebooks. Specify notebook ID when creating documents.
- hPath (human-readable path): the title-based path shown in the document tree, e.g. "/Diary/2024/June". The "path" parameter in document tools (document.create, document.move, document.list) refers to hPath, not the internal ID-based filesystem path. When a document is renamed, its hPath changes but its ID stays the same.
- Document vs block move: document.move performs full document relocation — it moves a document (and its children) to a new parent hPath in a notebook. Requires: id, notebook, path. The notebook ID can be found via document.get (field: Box). block.move repositions a single block under a new parent block — use this for moving content blocks, not entire documents.
+- Dailynote (daily note/diary/journal): a special document created by the dailynote tool that follows the notebook's daily note save path. When the user asks to write or create a diary, daily note, or journal entry, always use dailynote.create (not document.create). dailynote.create creates or retrieves today's daily note for the given notebook; use dailynote.append/prepend to add content to it.
## Tool Usage Patterns
- Finding information: search.fulltext (keyword) → block.get (by ID) to read full content. For semantic search use search.semantic.
- Exploring structure: document.list (see child documents under an hPath) → document.get (read document metadata and content) → block.get_children (list blocks inside a document) → block.get (read a specific block). Use breadcrumb to trace a block's location path.
- Creating content: document.create specifies the target notebook and hPath to create a document → block.append/prepend/insert to add blocks into the document. Use dataType "markdown" for text content.
+- Creating diary/dailynote: dailynote.create with notebook ID to create or open today's daily note → dailynote.append/prepend to add content. Do not use document.create for diary/dailynote requests.
- Modifying content: block.update with a block's ID and new markdown content.
- Organizing: document.move (full document relocation to a new hPath, needs notebook ID from document.get). document.rename changes a document's title (hPath follows). block.move repositions a single block under a new parent — for content blocks, not entire documents. document.delete removes a document by ID.
- Attributes/properties: use attr.get/set to read/write custom attributes on any block. Use database tools for spreadsheets/attribute views.
@@ -578,6 +580,7 @@ func buildMessages(history []UserMessage, language string, references []Referenc
}
prompt += "\n\nReply in " + langName(language) + "."
+ prompt += "\n\nIn the user's language, a daily note is called: " + util.I18nTerm(language, "dailyNote") + ". When the user asks to write or create this, use dailynote.create, not document.create."
if len(references) > 0 {
prompt += "\n\nThe user has referenced the following content blocks:\n"
for _, ref := range references {
diff --git a/kernel/util/i18n.go b/kernel/util/i18n.go
new file mode 100644
index 0000000000..81775fa97a
--- /dev/null
+++ b/kernel/util/i18n.go
@@ -0,0 +1,40 @@
+// SiYuan - Refactor your thinking
+// Copyright (c) 2020-present, b3log.org
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+package util
+
+import (
+ "os"
+ "path/filepath"
+
+ "github.com/88250/gulu"
+)
+
+func I18nTerm(language, key string) (ret string) {
+ p := filepath.Join(WorkingDir, "appearance", "langs", language+".json")
+ data, err := os.ReadFile(p)
+ if err != nil {
+ return
+ }
+ var m map[string]interface{}
+ if err = gulu.JSON.UnmarshalJSON(data, &m); err != nil {
+ return
+ }
+ if v, ok := m[key].(string); ok {
+ ret = v
+ }
+ return
+}