An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Open user guide notebook documents https://github.com/siyuan-note/siyuan/issues/18266
Daniel4dd48f8355ae
diff --git a/app/guide/20210808180117-6v0mkxr/.siyuan/boxDoc.json b/app/guide/20210808180117-6v0mkxr/.siyuan/boxDoc.jsonnew file mode 100644index 0000000000..a8840aad8b--- /dev/null+++ b/app/guide/20210808180117-6v0mkxr/.siyuan/boxDoc.json@@ -0,0 +1,4 @@+{+ "spec": 1,+ "boxDocID": "20210808180117-6v0mkxr"+}\ No newline at end of filediff --git a/app/guide/20210808180117-6v0mkxr/.siyuan/conf.json b/app/guide/20210808180117-6v0mkxr/.siyuan/conf.jsonindex 5f72f47591..979e9d8b90 100644--- a/app/guide/20210808180117-6v0mkxr/.siyuan/conf.json+++ b/app/guide/20210808180117-6v0mkxr/.siyuan/conf.json@@ -9,5 +9,7 @@"docCreateSavePath": "","dailyNoteSavePath": "/daily note/{{now | date \"2006/01\"}}/{{now | date \"2006-01-02\"}}","dailyNoteTemplatePath": "",- "sortMode": 15+ "sortMode": 15,+ "encrypted": false,+ "boxCrypt": null}\ No newline at end of filediff --git a/app/guide/20210808180117-6v0mkxr/20210808180117-6v0mkxr.sy b/app/guide/20210808180117-6v0mkxr/20210808180117-6v0mkxr.synew file mode 100644index 0000000000..cceddc6004--- /dev/null+++ b/app/guide/20210808180117-6v0mkxr/20210808180117-6v0mkxr.sy@@ -0,0 +1,23 @@+{+ "ID": "20210808180117-6v0mkxr",+ "Spec": "2",+ "Type": "NodeDocument",+ "Properties": {+ "custom-hidden": "true",+ "icon": "1f4d4",+ "id": "20210808180117-6v0mkxr",+ "title": "SiYuan User Guide",+ "type": "doc",+ "updated": "20210808180117"+ },+ "Children": [+ {+ "ID": "20260722113840-ab93cmj",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260722113840-ab93cmj",+ "updated": "20260722113840"+ }+ }+ ]+}\ No newline at end of filediff --git a/app/guide/20210808180117-czj9bvb/.siyuan/boxDoc.json b/app/guide/20210808180117-czj9bvb/.siyuan/boxDoc.jsonnew file mode 100644index 0000000000..13f4d8e490--- /dev/null+++ b/app/guide/20210808180117-czj9bvb/.siyuan/boxDoc.json@@ -0,0 +1,4 @@+{+ "spec": 1,+ "boxDocID": "20210808180117-czj9bvb"+}\ No newline at end of filediff --git a/app/guide/20210808180117-czj9bvb/.siyuan/conf.json b/app/guide/20210808180117-czj9bvb/.siyuan/conf.jsonindex 5e9e353d5f..6709b75b57 100644--- a/app/guide/20210808180117-czj9bvb/.siyuan/conf.json+++ b/app/guide/20210808180117-czj9bvb/.siyuan/conf.json@@ -1,6 +1,6 @@{"name": "思源笔记用户指南",- "sort": 2,+ "sort": 3,"icon": "1f4d4","closed": false,"refCreateSaveBox": "",@@ -9,5 +9,7 @@"docCreateSavePath": "","dailyNoteSavePath": "/daily note/{{now | date \"2006/01\"}}/{{now | date \"2006-01-02\"}}","dailyNoteTemplatePath": "",- "sortMode": 15+ "sortMode": 15,+ "encrypted": false,+ "boxCrypt": null}\ No newline at end of filediff --git a/app/guide/20210808180117-czj9bvb/20210808180117-czj9bvb.sy b/app/guide/20210808180117-czj9bvb/20210808180117-czj9bvb.synew file mode 100644index 0000000000..3d3b3c72a6--- /dev/null+++ b/app/guide/20210808180117-czj9bvb/20210808180117-czj9bvb.sy@@ -0,0 +1,23 @@+{+ "ID": "20210808180117-czj9bvb",+ "Spec": "2",+ "Type": "NodeDocument",+ "Properties": {+ "custom-hidden": "true",+ "icon": "1f4d4",+ "id": "20210808180117-czj9bvb",+ "title": "思源笔记用户指南",+ "type": "doc",+ "updated": "20210808180117"+ },+ "Children": [+ {+ "ID": "20260722113904-24g72fp",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260722113904-24g72fp",+ "updated": "20260722113904"+ }+ }+ ]+}\ No newline at end of filediff --git a/app/guide/20211226090932-5lcq56f/.siyuan/boxDoc.json b/app/guide/20211226090932-5lcq56f/.siyuan/boxDoc.jsonnew file mode 100644index 0000000000..dacc865669--- /dev/null+++ b/app/guide/20211226090932-5lcq56f/.siyuan/boxDoc.json@@ -0,0 +1,4 @@+{+ "spec": 1,+ "boxDocID": "20211226090932-5lcq56f"+}\ No newline at end of filediff --git a/app/guide/20211226090932-5lcq56f/.siyuan/conf.json b/app/guide/20211226090932-5lcq56f/.siyuan/conf.jsonindex ab175baaca..11bb3e4032 100644--- a/app/guide/20211226090932-5lcq56f/.siyuan/conf.json+++ b/app/guide/20211226090932-5lcq56f/.siyuan/conf.json@@ -1,6 +1,6 @@{"name": "思源筆記用戶指南",- "sort": 3,+ "sort": 4,"icon": "1f4d4","closed": false,"refCreateSaveBox": "",@@ -9,5 +9,7 @@"docCreateSavePath": "","dailyNoteSavePath": "/daily note/{{now | date \"2006/01\"}}/{{now | date \"2006-01-02\"}}","dailyNoteTemplatePath": "",- "sortMode": 15+ "sortMode": 15,+ "encrypted": false,+ "boxCrypt": null}\ No newline at end of filediff --git a/app/guide/20211226090932-5lcq56f/20211226090932-5lcq56f.sy b/app/guide/20211226090932-5lcq56f/20211226090932-5lcq56f.synew file mode 100644index 0000000000..2a7fc26bdc--- /dev/null+++ b/app/guide/20211226090932-5lcq56f/20211226090932-5lcq56f.sy@@ -0,0 +1,23 @@+{+ "ID": "20211226090932-5lcq56f",+ "Spec": "2",+ "Type": "NodeDocument",+ "Properties": {+ "custom-hidden": "true",+ "icon": "1f4d4",+ "id": "20211226090932-5lcq56f",+ "title": "思源筆記用戶指南",+ "type": "doc",+ "updated": "20211226090932"+ },+ "Children": [+ {+ "ID": "20260722113917-mft5i5n",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260722113917-mft5i5n",+ "updated": "20260722113917"+ }+ }+ ]+}\ No newline at end of filediff --git a/app/guide/20240530133126-axarxgx/.siyuan/boxDoc.json b/app/guide/20240530133126-axarxgx/.siyuan/boxDoc.jsonnew file mode 100644index 0000000000..72a3da2548--- /dev/null+++ b/app/guide/20240530133126-axarxgx/.siyuan/boxDoc.json@@ -0,0 +1,4 @@+{+ "spec": 1,+ "boxDocID": "20240530133126-axarxgx"+}\ No newline at end of filediff --git a/app/guide/20240530133126-axarxgx/.siyuan/conf.json b/app/guide/20240530133126-axarxgx/.siyuan/conf.jsonindex 1f081d9899..53ff279caf 100644--- a/app/guide/20240530133126-axarxgx/.siyuan/conf.json+++ b/app/guide/20240530133126-axarxgx/.siyuan/conf.json@@ -1,6 +1,6 @@{"name": "SiYuan ユーザーガイド",- "sort": 4,+ "sort": 2,"icon": "1f4d4","closed": false,"refCreateSaveBox": "",@@ -9,5 +9,7 @@"docCreateSavePath": "","dailyNoteSavePath": "/daily note/{{now | date \"2006/01\"}}/{{now | date \"2006-01-02\"}}","dailyNoteTemplatePath": "",- "sortMode": 15+ "sortMode": 15,+ "encrypted": false,+ "boxCrypt": null}\ No newline at end of filediff --git a/app/guide/20240530133126-axarxgx/20240530133126-axarxgx.sy b/app/guide/20240530133126-axarxgx/20240530133126-axarxgx.synew file mode 100644index 0000000000..328dbd5371--- /dev/null+++ b/app/guide/20240530133126-axarxgx/20240530133126-axarxgx.sy@@ -0,0 +1,23 @@+{+ "ID": "20240530133126-axarxgx",+ "Spec": "2",+ "Type": "NodeDocument",+ "Properties": {+ "custom-hidden": "true",+ "icon": "1f4d4",+ "id": "20240530133126-axarxgx",+ "title": "SiYuan ユーザーガイド",+ "type": "doc",+ "updated": "20240530133126"+ },+ "Children": [+ {+ "ID": "20260722113934-k7o1x52",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20260722113934-k7o1x52",+ "updated": "20260722113934"+ }+ }+ ]+}\ No newline at end of filediff --git a/kernel/model/box_doc_test.go b/kernel/model/box_doc_test.goindex 947b35a1b3..12af48a672 100644--- a/kernel/model/box_doc_test.go+++ b/kernel/model/box_doc_test.go@@ -21,6 +21,9 @@ import ("path/filepath""testing"+ "github.com/88250/lute/ast"+ "github.com/siyuan-note/siyuan/kernel/cache"+ "github.com/siyuan-note/siyuan/kernel/conf""github.com/siyuan-note/siyuan/kernel/filesys""github.com/siyuan-note/siyuan/kernel/treenode""github.com/siyuan-note/siyuan/kernel/util"@@ -82,6 +85,58 @@ func TestFindBoxDocRejectsOrdinaryDocument(t *testing.T) {}}+func TestFindUnindexedTreePathIgnoresTextMatch(t *testing.T) {+ originalConf := Conf+ originalDataDir := util.DataDir+ originalBlockTreeDBPath := util.BlockTreeDBPath+ tempDir := t.TempDir()+ util.DataDir = filepath.Join(tempDir, "data")+ util.BlockTreeDBPath = filepath.Join(tempDir, "blocktree.db")+ Conf = NewAppConf()+ Conf.FileTree = conf.NewFileTree()+ Conf.NotebookCrypto = conf.NewNotebookCrypto()+ Conf.Sync = conf.NewSync()++ box := &Box{ID: "20260716120010-abcdefg"}+ boxConf := conf.NewBoxConf()+ boxConf.Name = "Unindexed tree test"+ if err := box.SaveConf(boxConf); nil != err {+ t.Fatal(err)+ }+ treenode.InitBlockTree(true)+ docID := "20260716120011-abcdefg"+ targetID := "20210808180117-6v0mkxr"+ tree := treenode.NewTree(box.ID, "/"+docID+".sy", "/Test", "Test")+ paragraph := &ast.Node{Type: ast.NodeParagraph, ID: "20260716120012-abcdefg"}+ paragraph.AppendChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(targetID)})+ tree.Root.AppendChild(paragraph)+ if _, err := filesys.WriteTree(tree); nil != err {+ t.Fatal(err)+ }++ t.Cleanup(func() {+ cache.RemoveTreeDataInBox(docID, box.ID)+ treenode.CloseDatabase()+ Conf = originalConf+ util.DataDir = originalDataDir+ util.BlockTreeDBPath = originalBlockTreeDBPath+ if "" != originalBlockTreeDBPath {+ treenode.InitBlockTree(false)+ }+ })++ if matchedPath := findUnindexedTreePathInAllBoxes(targetID); "" != matchedPath {+ t.Fatalf("text content was recognized as a block ID [path=%s]", matchedPath)+ }+ paragraph.ID = targetID+ if _, err := filesys.WriteTree(tree); nil != err {+ t.Fatal(err)+ }+ if matchedPath := findUnindexedTreePathInAllBoxes(targetID); "" == matchedPath {+ t.Fatal("actual block ID was not found")+ }+}+func TestBoxDocSubFileCount(t *testing.T) {originalDataDir := util.DataDirutil.DataDir = t.TempDir()diff --git a/kernel/model/tree.go b/kernel/model/tree.goindex 9052f961a8..8b27174c7c 100644--- a/kernel/model/tree.go+++ b/kernel/model/tree.go@@ -378,6 +378,7 @@ func loadParentTree(tree *parse.Tree) (ret *parse.Tree) {func findUnindexedTreePathInAllBoxes(id string) (ret string) {boxes := Conf.GetBoxes()+ luteEngine := util.NewLute()for _, box := range boxes {root := filepath.Join(util.DataDir, box.ID)paths := search.FindAllMatchedPaths(root, []string{id})@@ -401,10 +402,36 @@ func findUnindexedTreePathInAllBoxes(id string) (ret string) {result := treenode.ExistBlockTrees(rootIDs)for rootID, exist := range result {- if !exist {- return rootIDPaths[rootID]+ if exist {+ continue+ }++ matchedPath := rootIDPaths[rootID]+ relPath, relErr := filepath.Rel(root, matchedPath)+ if nil != relErr {+ return matchedPath+ }+ // 全文匹配只用于筛选候选文件,解析树后再确认是否存在真实块 ID。+ treePath := "/" + filepath.ToSlash(relPath)+ tree, loadErr := filesys.LoadTree(box.ID, treePath, luteEngine)+ if nil != loadErr || treeContainsBlockID(tree, id) {+ return matchedPath}}}return}++func treeContainsBlockID(tree *parse.Tree, id string) (ret bool) {+ if nil == tree || nil == tree.Root || "" == id {+ return+ }+ ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {+ if entering && n.IsBlock() && n.ID == id {+ ret = true+ return ast.WalkStop+ }+ return ast.WalkContinue+ })+ return+}