An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: AI Agent https://github.com/siyuan-note/siyuan/issues/17797
Daniel24b874e0e69b
diff --git a/kernel/cli/cmd/attr.go b/kernel/cli/cmd/attr.goindex e066884f3b..8f44d7e6ee 100644--- a/kernel/cli/cmd/attr.go+++ b/kernel/cli/cmd/attr.go@@ -62,8 +62,8 @@ var attrSetCmd = &cobra.Command{Long: `Set custom attributes on a block.Common attributes:- icon Emoji hex codepoint (e.g. "1f4ca"), custom image path (e.g. "1/b3log.png"), or dynamic icon URL.- DO NOT use the emoji character (e.g. "📊").+ icon Emoji hex codepoint (e.g. "1f4ca"), emoji character (e.g. "📊"), custom image path (e.g. "1/b3log.png"), or dynamic icon URL (e.g.+ "api/icon/getDynamicIcon?type=8&color=%23d23f31&content=SiYuan&id=xxx").title-img CSS background-image format (e.g. 'background-image:url("assets/example.jpg")').DO NOT use a bare asset path.tags Comma-separated tag names.diff --git a/kernel/mcp/tools/attr.go b/kernel/mcp/tools/attr.goindex 081761f83c..229c979e28 100644--- a/kernel/mcp/tools/attr.go+++ b/kernel/mcp/tools/attr.go@@ -33,7 +33,7 @@ var AttrTool = &Tool{"action": {Type: "string", Description: "Operation", Enum: []string{"get", "set", "batch-get"}},"id": {Type: "string", Description: "Block ID"},"ids": {Type: "string", Description: "Comma-separated block IDs (for batch-get)"},- "attrs": {Type: "object", Description: "Attribute key-value pairs (for set).\nCommon attributes:\n- icon: emoji hex codepoint like \"1f4ca\" (NOT the emoji char \"📊\"), custom image path like \"1/b3log.png\", or dynamic icon URL\n- title-img: CSS format like 'background-image:url(\"assets/example.jpg\")', NOT a bare asset path\n- tags: comma-separated tag names"},+ "attrs": {Type: "object", Description: "Attribute key-value pairs (for set).\nCommon attributes:\n- icon: emoji hex codepoint like \"1f4ca\", emoji character like \"📊\", custom image path like \"1/b3log.png\", or dynamic icon URL like \"api/icon/getDynamicIcon?type=8&color=%23d23f31&content=SiYuan&id=xxx\"\n- title-img: CSS format like 'background-image:url(\"assets/example.jpg\")', NOT a bare asset path\n- tags: comma-separated tag names"},},Required: []string{"action"},},diff --git a/kernel/model/blockial.go b/kernel/model/blockial.goindex 246c04b216..f129f9270e 100644--- a/kernel/model/blockial.go+++ b/kernel/model/blockial.go@@ -19,6 +19,7 @@ package modelimport ("errors""fmt"+ "strconv""strings""time"@@ -277,6 +278,10 @@ func setNodeAttrs0(node *ast.Node, nameValues map[string]string) (oldAttrs map[s}}+ if lowerName == "icon" && "" != value {+ value = normalizeIconValue(value)+ }+if "" == value {// 删除属性if name != lowerName {@@ -349,6 +354,29 @@ func validateChars(name string, startIdx, n int) bool {return true}+func normalizeIconValue(value string) string {+ if strings.ContainsAny(value, "./") {+ return value+ }++ allASCII := true+ for _, r := range value {+ if r > 127 {+ allASCII = false+ break+ }+ }+ if allASCII {+ return value+ }++ var parts []string+ for _, r := range value {+ parts = append(parts, strconv.FormatInt(int64(r), 16))+ }+ return strings.Join(parts, "-")+}+func pushBlockAttrs(oldAttrs map[string]string, node *ast.Node) {newAttrs := parse.IAL2Map(node.KramdownIAL)data := map[string]any{"old": oldAttrs, "new": newAttrs}