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
Danielcff2b19f6ade
diff --git a/kernel/cli/cmd/block.go b/kernel/cli/cmd/block.goindex 86c0b64f77..86d8c9e9a4 100644--- a/kernel/cli/cmd/block.go+++ b/kernel/cli/cmd/block.go@@ -23,6 +23,7 @@ import ("os""text/tabwriter"+ "github.com/siyuan-note/siyuan/kernel/filesys""github.com/siyuan-note/siyuan/kernel/model""github.com/siyuan-note/siyuan/kernel/util"@@ -179,6 +180,34 @@ var blockInfoCmd = &cobra.Command{},}+var blockStatCmd = &cobra.Command{+ Use: "stat --id <id>",+ Short: "Get block content statistics",+ RunE: func(cmd *cobra.Command, args []string) error {+ id, _ := cmd.Flags().GetString("id")+ if id == "" {+ return fmt.Errorf("--id is required")+ }+ stat := filesys.StatTree(id)+ if stat == nil {+ return fmt.Errorf("document not found or empty")+ }+ switch outputFormat {+ case "json":+ data, _ := json.MarshalIndent(stat, "", " ")+ fmt.Println(string(data))+ default:+ fmt.Printf("Characters: %d\n", stat.RuneCount)+ fmt.Printf("Words: %d\n", stat.WordCount)+ fmt.Printf("Blocks: %d\n", stat.BlockCount)+ fmt.Printf("Links: %d\n", stat.LinkCount)+ fmt.Printf("Images: %d\n", stat.ImageCount)+ fmt.Printf("Refs: %d\n", stat.RefCount)+ }+ return nil+ },+}+// ─── Write ─────────────────────────────────────────────────────────────────────var blockInsertCmd = &cobra.Command{@@ -400,6 +429,7 @@ func init() {blockKramdownCmd.Flags().String("id", "", "block ID")blockKramdownCmd.Flags().String("mode", "md", "export mode: md | textmark")blockInfoCmd.Flags().String("id", "", "document block ID")+ blockStatCmd.Flags().String("id", "", "block ID")blockInsertCmd.Flags().String("parent", "", "parent block ID")blockInsertCmd.Flags().String("data", "", "markdown content")@@ -431,6 +461,7 @@ func init() {blockCmd.AddCommand(blockDomCmd)blockCmd.AddCommand(blockKramdownCmd)blockCmd.AddCommand(blockInfoCmd)+ blockCmd.AddCommand(blockStatCmd)blockCmd.AddCommand(blockInsertCmd)blockCmd.AddCommand(blockAppendCmd)blockCmd.AddCommand(blockPrependCmd)