An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:technologist: Add kernel API `/api/history/createDocHistory` https://github.com/siyuan-note/siyuan/issues/17774
Daniel3c875a8b461b
diff --git a/kernel/api/history.go b/kernel/api/history.goindex 6f3aadbdb1..0fee9dad23 100644--- a/kernel/api/history.go+++ b/kernel/api/history.go@@ -261,3 +261,27 @@ func rollbackAttributeViewHistory(c *gin.Context) {return}}++func createDocHistory(c *gin.Context) {+ ret := gulu.Ret.NewResult()+ defer c.JSON(http.StatusOK, ret)++ arg, ok := util.JsonArg(c, ret)+ if !ok {+ return+ }++ var id string+ if !util.ParseJsonArgs(arg, ret,+ util.BindJsonArg("id", &id, true, true),+ ) {+ return+ }++ err := model.CreateDocHistory(id)+ if err != nil {+ ret.Code = -1+ ret.Msg = err.Error()+ return+ }+}diff --git a/kernel/api/router.go b/kernel/api/router.goindex 38033cb65a..8fbb93947f 100644--- a/kernel/api/router.go+++ b/kernel/api/router.go@@ -167,6 +167,7 @@ func ServeAPI(ginServer *gin.Engine) {ginServer.Handle("POST", "/api/history/reindexHistory", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, reindexHistory)ginServer.Handle("POST", "/api/history/searchHistory", model.CheckAuth, model.CheckAdminRole, searchHistory)ginServer.Handle("POST", "/api/history/getHistoryItems", model.CheckAuth, model.CheckAdminRole, getHistoryItems)+ ginServer.Handle("POST", "/api/history/createDocHistory", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, createDocHistory)ginServer.Handle("POST", "/api/outline/getDocOutline", model.CheckAuth, getDocOutline)diff --git a/kernel/model/history.go b/kernel/model/history.goindex 9b1d7810ed..06d90ede8b 100644--- a/kernel/model/history.go+++ b/kernel/model/history.go@@ -842,6 +842,15 @@ func generateOpTypeHistory(tree *parse.Tree, opType string) {indexHistoryDir(filepath.Base(historyDir), util.NewLute())}+func CreateDocHistory(id string) (err error) {+ tree, err := LoadTreeByBlockID(id)+ if err != nil {+ return+ }+ generateOpTypeHistory(tree, HistoryOpUpdate)+ return+}+func generateTreeHistory(tree *parse.Tree, historyDir string) {historyPath := filepath.Join(historyDir, tree.Box, tree.Path)var err error