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: Command Line Interface https://github.com/siyuan-note/siyuan/issues/17674
Daniel38c85d246951
diff --git a/kernel/cli/cmd/database.go b/kernel/cli/cmd/database.goindex be9476df0e..cdd43f76fd 100644--- a/kernel/cli/cmd/database.go+++ b/kernel/cli/cmd/database.go@@ -161,6 +161,7 @@ var databaseKeyAddCmd = &cobra.Command{if err := model.AddAttributeViewKey(avID, keyID, name, keyType, icon, prev); err != nil {return err}+ model.AppendPushReloadAttrViewEntry(avID)fmt.Println(keyID)return nil},@@ -179,6 +180,7 @@ var databaseKeyRemoveCmd = &cobra.Command{if err := model.RemoveAttributeViewKey(avID, keyID, removeRelation); err != nil {return err}+ model.AppendPushReloadAttrViewEntry(avID)fmt.Println("ok")return nil},@@ -254,6 +256,7 @@ var databaseItemAddCmd = &cobra.Command{if err := model.AddAttributeViewBlock(nil, srcs, avID, blockID, viewID, groupID, previousID, ignoreFill); err != nil {return err}+ model.AppendPushReloadAttrViewEntry(avID)fmt.Println("ok")return nil},@@ -275,6 +278,7 @@ var databaseItemRemoveCmd = &cobra.Command{if err := model.RemoveAttributeViewBlock(ids, avID); err != nil {return err}+ model.AppendPushReloadAttrViewEntry(avID)fmt.Println("ok")return nil},@@ -298,6 +302,7 @@ var databaseItemUpdateCmd = &cobra.Command{if _, err := model.UpdateAttributeViewCell(nil, avID, keyID, itemID, valueData); err != nil {return err}+ model.AppendPushReloadAttrViewEntry(avID)fmt.Println("ok")return nil},diff --git a/kernel/cli/cmd/history.go b/kernel/cli/cmd/history.goindex 9939dde01c..cca1e90b35 100644--- a/kernel/cli/cmd/history.go+++ b/kernel/cli/cmd/history.go@@ -21,6 +21,8 @@ import ("fmt""github.com/siyuan-note/siyuan/kernel/model"+ "github.com/siyuan-note/siyuan/kernel/treenode"+ "github.com/siyuan-note/siyuan/kernel/util""github.com/spf13/cobra")@@ -114,6 +116,11 @@ var historyRollbackCmd = &cobra.Command{if err := model.RollbackDocHistory(historyPath); err != nil {return err}+ docID := util.GetTreeID(historyPath)+ if bt := treenode.GetBlockTree(docID); bt != nil {+ model.AppendPushReloadProtyleEntry(bt.RootID)+ }+ model.AppendPushReloadFiletreeEntry()fmt.Println("ok")return nil},diff --git a/kernel/cli/cmd/import.go b/kernel/cli/cmd/import.goindex cb59f615da..9f893cb261 100644--- a/kernel/cli/cmd/import.go+++ b/kernel/cli/cmd/import.go@@ -53,6 +53,7 @@ var importMdCmd = &cobra.Command{if err := model.ImportFromLocalPath(notebook, absPath, resolvePath(notebook, toPath, hpath)); err != nil {return err}+ model.AppendPushReloadFiletreeEntry()fmt.Println("ok")return nil},@@ -81,6 +82,7 @@ var importSYCmd = &cobra.Command{if err := model.ImportSY(absPath, notebook, resolvePath(notebook, toPath, hpath)); err != nil {return err}+ model.AppendPushReloadFiletreeEntry()fmt.Println("ok")return nil},diff --git a/kernel/cli/cmd/repo.go b/kernel/cli/cmd/repo.goindex 1f13f5db9f..08e74fe779 100644--- a/kernel/cli/cmd/repo.go+++ b/kernel/cli/cmd/repo.go@@ -24,6 +24,7 @@ import ("time""github.com/siyuan-note/siyuan/kernel/model"+ "github.com/siyuan-note/siyuan/kernel/treenode""github.com/spf13/cobra")@@ -132,7 +133,9 @@ var repoCheckoutCmd = &cobra.Command{if id == "" {return fmt.Errorf("--id is required")}- model.CheckoutRepo(id)+ model.CheckoutRepoDirect(id)+ model.AppendPushReloadFiletreeEntry()+ model.AppendPushReloadUIEntry()fmt.Println("ok")return nil},@@ -238,6 +241,9 @@ var repoFileRollbackCmd = &cobra.Command{if err := model.RollbackRepoSnapshotFile(id); err != nil {return err}+ if bt := treenode.GetBlockTree(id); bt != nil {+ model.AppendPushReloadProtyleEntry(bt.RootID)+ }fmt.Println("ok")return nil},diff --git a/kernel/model/box.go b/kernel/model/box.goindex fbbf09e0d0..07c9d2df94 100644--- a/kernel/model/box.go+++ b/kernel/model/box.go@@ -807,6 +807,10 @@ func FullReindex(needResetScroll bool) {}}+func FullReindexDirect() {+ fullReindex()+}+func fullReindex() {pushSQLInsertBlocksFTSMsg, pushSQLDeleteBlocksMsg = true, truedefer func() {diff --git a/kernel/model/push_queue.go b/kernel/model/push_queue.goindex b204321d59..bc8290cadb 100644--- a/kernel/model/push_queue.go+++ b/kernel/model/push_queue.go@@ -75,6 +75,14 @@ func AppendPushReloadProtyleEntry(id string) {appendPushEntry(pushEntry{Action: "reloadProtyle", ID: id})}+func AppendPushReloadAttrViewEntry(avID string) {+ appendPushEntry(pushEntry{Action: "reloadAttrView", ID: avID})+}++func AppendPushReloadUIEntry() {+ appendPushEntry(pushEntry{Action: "reloadUI"})+}+func AppendPushReloadFiletreeEntry() {appendPushEntry(pushEntry{Action: "reloadFiletree"})}@@ -158,6 +166,10 @@ func PollPushQueue() {if bt != nil {util.PushReloadProtyle(bt.RootID)}+ case "reloadAttrView":+ util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]any{"id": e.ID})+ case "reloadUI":+ util.ReloadUI()case "reloadFiletree":util.BroadcastByType("filetree", "reloadFiletree", 0, "", nil)case "reloadTag":diff --git a/kernel/model/repository.go b/kernel/model/repository.goindex db6b87d732..34b72901a6 100644--- a/kernel/model/repository.go+++ b/kernel/model/repository.go@@ -915,6 +915,10 @@ func CheckoutRepo(id string) {task.AppendTask(task.RepoCheckout, checkoutRepo, id)}+func CheckoutRepoDirect(id string) {+ checkoutRepo(id)+}+func checkoutRepo(id string) {var err errorif 1 > len(Conf.Repo.Key) {@@ -966,7 +970,7 @@ func checkoutRepo(id string) {return}- FullReindex(true)+ FullReindexDirect()if syncEnabled {task.AppendAsyncTaskWithDelay(task.PushMsg, 7*time.Second, util.PushMsg, Conf.Language(134), 0)