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

Daniel2fd484f0debd
diff --git a/kernel/agent/agent.go b/kernel/agent/agent.go
index 0b09ee9833..f72c2adb80 100644
--- a/kernel/agent/agent.go
+++ b/kernel/agent/agent.go
@@ -54,7 +54,7 @@ const systemPrompt = `You are a SiYuan AI assistant. You help users manage their
- 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 replaces a single block's content with new markdown. To insert multiple new blocks into a document, use block.append/block.prepend (add to parent) or block.insert (add between siblings). Do NOT use block.update to add new blocks.
+- Modifying content: block.update ONLY replaces a SINGLE existing block's content with new markdown — it does NOT create or append new blocks. If you need to append new content after modifying an existing block, you MUST use TWO separate calls: first block.update to modify the existing block, then block.append/block.prepend (add to parent) or block.insert (add between siblings) to add new blocks. Never pass multiple blocks of content to block.update expecting them to be appended.
- 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.
diff --git a/kernel/mcp/tools/block.go b/kernel/mcp/tools/block.go
index e29bfa76a5..5767fe9e50 100644
--- a/kernel/mcp/tools/block.go
+++ b/kernel/mcp/tools/block.go
@@ -28,7 +28,7 @@ import (
var BlockTool = &Tool{
Name: "block",
- Description: "Block operations for SiYuan.\n- get: Get block info by ID. Requires: id.\n- get_kramdown: Get block kramdown by ID. Requires: id.\n- get_children: Get child blocks by parent ID. Requires: id.\n- tree_stat: Get tree statistics (word count, character count, block count, etc.) by document ID. Requires: id.\n- dom: Get block DOM by ID. Requires: id.\n- insert: Insert a new block. Requires: data, dataType (markdown or dom). Optional: parentID, nextID, previousID.\n- append: Append a child block. Requires: data, dataType, parentID.\n- prepend: Prepend a child block. Requires: data, dataType, parentID.\n- update: Update a block. Requires: id, data, dataType.\n- delete: Delete a block. Requires: id.\n- move: Move a block. Requires: id, parentID. Optional: previousID.\n- breadcrumb: Get block breadcrumb path. Requires: id.\n- batch_get: Batch get block info by IDs. Requires: ids (comma-separated block IDs).\n- batch_kramdown: Batch get block kramdown by IDs. Requires: ids (comma-separated block IDs).",
+ Description: "Block operations for SiYuan.\n- get: Get block info by ID. Requires: id.\n- get_kramdown: Get block kramdown by ID. Requires: id.\n- get_children: Get child blocks by parent ID. Requires: id.\n- tree_stat: Get tree statistics (word count, character count, block count, etc.) by document ID. Requires: id.\n- dom: Get block DOM by ID. Requires: id.\n- insert: Insert a new block. Requires: data, dataType (markdown or dom). Optional: parentID, nextID, previousID.\n- append: Append a NEW child block. Requires: data, dataType, parentID. Use this AFTER block.update if you need to both modify and add new content.\n- prepend: Prepend a NEW child block. Requires: data, dataType, parentID. Use this AFTER block.update if you need to both modify and add new content.\n- update: Update an existing block's content (single block only, does NOT create or append new blocks). Requires: id, data, dataType.\n- delete: Delete a block. Requires: id.\n- move: Move a block. Requires: id, parentID. Optional: previousID.\n- breadcrumb: Get block breadcrumb path. Requires: id.\n- batch_get: Batch get block info by IDs. Requires: ids (comma-separated block IDs).\n- batch_kramdown: Batch get block kramdown by IDs. Requires: ids (comma-separated block IDs).",
InputSchema: ToolSchema{
Type: "object",
Properties: map[string]Property{