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
Daniel440fa9afdb40
diff --git a/kernel/cli/cmd/asset.go b/kernel/cli/cmd/asset.goindex c3149a9ad9..06cb605376 100644--- a/kernel/cli/cmd/asset.go+++ b/kernel/cli/cmd/asset.go@@ -55,6 +55,11 @@ var assetUploadCmd = &cobra.Command{files[i] = abs}+ if dryRun {+ fmt.Printf("[dry-run] Would upload %d file(s) to document %s\n", len(files), id)+ return nil+ }+succMap, err := model.InsertLocalAssets(id, files, true)if err != nil {return err@@ -108,11 +113,20 @@ var assetCleanCmd = &cobra.Command{RunE: func(cmd *cobra.Command, args []string) error {singlePath, _ := cmd.Flags().GetString("path")if singlePath != "" {+ if dryRun {+ fmt.Printf("[dry-run] Would remove unused asset: %s\n", singlePath)+ return nil+ }ret := model.RemoveUnusedAsset(singlePath)fmt.Println(ret)return nil}+ if dryRun {+ fmt.Println("[dry-run] Would clean unused assets")+ return nil+ }+removed := model.RemoveUnusedAssets()if len(removed) == 0 {fmt.Println("No unused assets to clean.")diff --git a/kernel/cli/cmd/attr.go b/kernel/cli/cmd/attr.goindex 8f44d7e6ee..6cdf1fc83b 100644--- a/kernel/cli/cmd/attr.go+++ b/kernel/cli/cmd/attr.go@@ -91,6 +91,15 @@ Examples:nameValues[strings.TrimSpace(parts[0])] = parts[1]}+ if dryRun {+ var parts []string+ for k, v := range nameValues {+ parts = append(parts, fmt.Sprintf("%s=%s", k, v))+ }+ fmt.Printf("[dry-run] Would set attributes on block %s: %s\n", id, strings.Join(parts, ", "))+ return nil+ }+if err := model.SetBlockAttrs(id, nameValues); err != nil {return err}diff --git a/kernel/cli/cmd/block.go b/kernel/cli/cmd/block.goindex 86511b0716..0c63e7bb1f 100644--- a/kernel/cli/cmd/block.go+++ b/kernel/cli/cmd/block.go@@ -193,6 +193,14 @@ var blockInsertCmd = &cobra.Command{return fmt.Errorf("--parent is required")}+ if dryRun {+ fmt.Printf("[dry-run] Would insert block under parent %s\n", parentID)+ if previousID != "" {+ fmt.Printf(" after previous sibling %s\n", previousID)+ }+ return nil+ }+data, err := resolveData(cmd)if err != nil {return err@@ -224,6 +232,11 @@ var blockAppendCmd = &cobra.Command{return fmt.Errorf("--parent is required")}+ if dryRun {+ fmt.Printf("[dry-run] Would append block to parent %s\n", parentID)+ return nil+ }+data, err := resolveData(cmd)if err != nil {return err@@ -254,6 +267,11 @@ var blockPrependCmd = &cobra.Command{return fmt.Errorf("--parent is required")}+ if dryRun {+ fmt.Printf("[dry-run] Would prepend block to parent %s\n", parentID)+ return nil+ }+data, err := resolveData(cmd)if err != nil {return err@@ -284,6 +302,11 @@ var blockUpdateCmd = &cobra.Command{return fmt.Errorf("--id is required")}+ if dryRun {+ fmt.Printf("[dry-run] Would update block %s\n", id)+ return nil+ }+data, err := resolveData(cmd)if err != nil {return err@@ -314,6 +337,11 @@ var blockDeleteCmd = &cobra.Command{return fmt.Errorf("--id is required")}+ if dryRun {+ fmt.Printf("[dry-run] Would delete block %s\n", id)+ return nil+ }+transactions := []*model.Transaction{{DoOperations: []*model.Operation{{Action: "delete",@@ -339,6 +367,14 @@ var blockMoveCmd = &cobra.Command{return fmt.Errorf("--id and --parent are required")}+ if dryRun {+ fmt.Printf("[dry-run] Would move block %s to parent %s\n", id, parentID)+ if previousID != "" {+ fmt.Printf(" after previous sibling %s\n", previousID)+ }+ return nil+ }+transactions := []*model.Transaction{{DoOperations: []*model.Operation{{Action: "move",diff --git a/kernel/cli/cmd/bookmark.go b/kernel/cli/cmd/bookmark.goindex b3847e482b..b7c27672ae 100644--- a/kernel/cli/cmd/bookmark.go+++ b/kernel/cli/cmd/bookmark.go@@ -77,6 +77,12 @@ var bookmarkRemoveCmd = &cobra.Command{if label == "" {return fmt.Errorf("--label is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would remove bookmark \"%s\"\n", label)+ return nil+ }+if err := model.RemoveBookmark(label); err != nil {return err}@@ -97,6 +103,12 @@ var bookmarkRenameCmd = &cobra.Command{if newLabel == "" {return fmt.Errorf("--new is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would rename bookmark \"%s\" to \"%s\"\n", oldLabel, newLabel)+ return nil+ }+if err := model.RenameBookmark(oldLabel, newLabel); err != nil {return err}diff --git a/kernel/cli/cmd/dailynote.go b/kernel/cli/cmd/dailynote.goindex eb604d8bfc..c537866dde 100644--- a/kernel/cli/cmd/dailynote.go+++ b/kernel/cli/cmd/dailynote.go@@ -39,6 +39,11 @@ var dailynoteCreateCmd = &cobra.Command{return fmt.Errorf("--notebook is required")}+ if dryRun {+ fmt.Printf("[dry-run] Would create daily note in notebook %s\n", notebook)+ return nil+ }+p, _, err := model.CreateDailyNote(notebook)if err != nil {return err@@ -62,6 +67,11 @@ var dailynoteAppendCmd = &cobra.Command{return fmt.Errorf("--notebook is required")}+ if dryRun {+ fmt.Printf("[dry-run] Would ensure daily note in notebook %s and append block\n", notebook)+ return nil+ }+data, err := resolveData(cmd)if err != nil {return err@@ -98,6 +108,11 @@ var dailynotePrependCmd = &cobra.Command{return fmt.Errorf("--notebook is required")}+ if dryRun {+ fmt.Printf("[dry-run] Would ensure daily note in notebook %s and prepend block\n", notebook)+ return nil+ }+data, err := resolveData(cmd)if err != nil {return errdiff --git a/kernel/cli/cmd/database.go b/kernel/cli/cmd/database.goindex cdd43f76fd..389b53e875 100644--- a/kernel/cli/cmd/database.go+++ b/kernel/cli/cmd/database.go@@ -157,6 +157,12 @@ var databaseKeyAddCmd = &cobra.Command{if avID == "" || name == "" || keyType == "" {return fmt.Errorf("--av, --name and --type are required")}++ if dryRun {+ fmt.Printf("[dry-run] Would add key \"%s\" (type=%s) to database %s\n", name, keyType, avID)+ return nil+ }+keyID := ast.NewNodeID()if err := model.AddAttributeViewKey(avID, keyID, name, keyType, icon, prev); err != nil {return err@@ -177,6 +183,12 @@ var databaseKeyRemoveCmd = &cobra.Command{if avID == "" || keyID == "" {return fmt.Errorf("--av and --key are required")}++ if dryRun {+ fmt.Printf("[dry-run] Would remove key %s from database %s\n", keyID, avID)+ return nil+ }+if err := model.RemoveAttributeViewKey(avID, keyID, removeRelation); err != nil {return err}@@ -208,10 +220,20 @@ var databaseCleanCmd = &cobra.Command{RunE: func(cmd *cobra.Command, args []string) error {avID, _ := cmd.Flags().GetString("av")if avID != "" {+ if dryRun {+ fmt.Printf("[dry-run] Would clean unused database %s\n", avID)+ return nil+ }model.RemoveUnusedAttributeView(avID)fmt.Println(avID)return nil}++ if dryRun {+ fmt.Println("[dry-run] Would clean unused databases")+ return nil+ }+removed := model.RemoveUnusedAttributeViews()fmt.Printf("%d database(s) cleaned\n", len(removed))return nil@@ -242,6 +264,11 @@ var databaseItemAddCmd = &cobra.Command{return fmt.Errorf("--block is required for non-detached rows")}+ if dryRun {+ fmt.Printf("[dry-run] Would add row to database %s\n", avID)+ return nil+ }+src := map[string]any{"isDetached": isDetached,}@@ -275,6 +302,12 @@ var databaseItemRemoveCmd = &cobra.Command{for i := range ids {ids[i] = strings.TrimSpace(ids[i])}++ if dryRun {+ fmt.Printf("[dry-run] Would remove %d row(s) from database %s\n", len(ids), avID)+ return nil+ }+if err := model.RemoveAttributeViewBlock(ids, avID); err != nil {return err}@@ -299,6 +332,12 @@ var databaseItemUpdateCmd = &cobra.Command{if err := json.Unmarshal([]byte(valueStr), &valueData); err != nil {return fmt.Errorf("invalid JSON: %s", err)}++ if dryRun {+ fmt.Printf("[dry-run] Would update cell in database %s: key=%s item=%s\n", avID, keyID, itemID)+ return nil+ }+if _, err := model.UpdateAttributeViewCell(nil, avID, keyID, itemID, valueData); err != nil {return err}diff --git a/kernel/cli/cmd/document.go b/kernel/cli/cmd/document.goindex 012e009076..951ede64eb 100644--- a/kernel/cli/cmd/document.go+++ b/kernel/cli/cmd/document.go@@ -79,6 +79,11 @@ var documentCreateCmd = &cobra.Command{dir = "/"}+ if dryRun {+ fmt.Printf("[dry-run] Would create document \"%s\" in notebook %s\n", title, notebook)+ return nil+ }+id := ast.NewNodeID()docPath := path.Join(dir, id+".sy")_, err := model.CreateDocByMd(notebook, docPath, title, markdown, nil, nil)@@ -145,6 +150,12 @@ var documentRemoveCmd = &cobra.Command{if id == "" {return fmt.Errorf("--id is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would remove document %s\n", id)+ return nil+ }+tree, err := model.LoadTreeByBlockID(id)if err != nil {return err@@ -172,6 +183,12 @@ var documentRenameCmd = &cobra.Command{if title == "" {return fmt.Errorf("--title is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would rename document %s to \"%s\"\n", id, title)+ return nil+ }+tree, err := model.LoadTreeByBlockID(id)if err != nil {return err@@ -196,6 +213,12 @@ var documentMoveCmd = &cobra.Command{if id == "" || toNotebook == "" {return fmt.Errorf("--id and --notebook are required")}++ if dryRun {+ fmt.Printf("[dry-run] Would move document %s to notebook %s\n", id, toNotebook)+ return nil+ }+tree, err := model.LoadTreeByBlockID(id)if err != nil {return err@@ -217,6 +240,12 @@ var documentDuplicateCmd = &cobra.Command{if id == "" {return fmt.Errorf("--id is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would duplicate document %s\n", id)+ return nil+ }+tree, err := model.LoadTreeByBlockID(id)if err != nil {return errdiff --git a/kernel/cli/cmd/export.go b/kernel/cli/cmd/export.goindex 84409e30ce..2216def9d6 100644--- a/kernel/cli/cmd/export.go+++ b/kernel/cli/cmd/export.go@@ -39,8 +39,13 @@ var exportMdCmd = &cobra.Command{return fmt.Errorf("--id is required")}- _, content := model.ExportMarkdownContent(id, 4, 0, true, false, false, false, false)output, _ := cmd.Flags().GetString("output")+ if dryRun && output != "" {+ fmt.Printf("[dry-run] Would export markdown for document %s to %s\n", id, output)+ return nil+ }++ _, content := model.ExportMarkdownContent(id, 4, 0, true, false, false, false, false)if output != "" {return os.WriteFile(output, []byte(content), 0644)}@@ -58,8 +63,13 @@ var exportHTMLCmd = &cobra.Command{return fmt.Errorf("--id is required")}- _, dom, _ := model.ExportHTML(id, "", false, false, false)output, _ := cmd.Flags().GetString("output")+ if dryRun && output != "" {+ fmt.Printf("[dry-run] Would export HTML for document %s to %s\n", id, output)+ return nil+ }++ _, dom, _ := model.ExportHTML(id, "", false, false, false)if output != "" {return os.WriteFile(output, []byte(dom), 0644)}@@ -77,8 +87,13 @@ var exportPreviewCmd = &cobra.Command{return fmt.Errorf("--id is required")}- html := model.ExportPreview(id, false)output, _ := cmd.Flags().GetString("output")+ if dryRun && output != "" {+ fmt.Printf("[dry-run] Would export preview HTML for document %s to %s\n", id, output)+ return nil+ }++ html := model.ExportPreview(id, false)if output != "" {return os.WriteFile(output, []byte(html), 0644)}@@ -100,6 +115,11 @@ var exportDocxCmd = &cobra.Command{return fmt.Errorf("--output is required for docx")}+ if dryRun {+ fmt.Printf("[dry-run] Would export docx for document %s to %s\n", id, output)+ return nil+ }+fullPath, err := model.ExportDocx(id, output, false, false)if err != nil {return err@@ -118,8 +138,17 @@ var exportSYCmd = &cobra.Command{return fmt.Errorf("--id is required")}- _, zipPath := model.ExportPandocConvertZip([]string{id}, "", ".sy")output, _ := cmd.Flags().GetString("output")+ if dryRun {+ if output != "" {+ fmt.Printf("[dry-run] Would export .sy.zip for document %s to %s\n", id, output)+ } else {+ fmt.Printf("[dry-run] Would export .sy.zip for document %s to temp path\n", id)+ }+ return nil+ }++ _, zipPath := model.ExportPandocConvertZip([]string{id}, "", ".sy")if output == "" {fmt.Println(zipPath)return nil@@ -141,8 +170,17 @@ var exportMdZipCmd = &cobra.Command{return fmt.Errorf("--id is required")}- _, zipPath := model.ExportPandocConvertZip([]string{id}, "", ".md")output, _ := cmd.Flags().GetString("output")+ if dryRun {+ if output != "" {+ fmt.Printf("[dry-run] Would export markdown zip for document %s to %s\n", id, output)+ } else {+ fmt.Printf("[dry-run] Would export markdown zip for document %s to temp path\n", id)+ }+ return nil+ }++ _, zipPath := model.ExportPandocConvertZip([]string{id}, "", ".md")if output == "" {fmt.Println(zipPath)return nil@@ -159,11 +197,20 @@ var exportDataCmd = &cobra.Command{Use: "data [--output <file>]",Short: "Export full workspace data backup",RunE: func(cmd *cobra.Command, args []string) error {+ output, _ := cmd.Flags().GetString("output")+ if dryRun {+ if output != "" {+ fmt.Printf("[dry-run] Would export full data backup to %s\n", output)+ } else {+ fmt.Println("[dry-run] Would export full data backup to temp path")+ }+ return nil+ }+zipPath, err := model.ExportData()if err != nil {return err}- output, _ := cmd.Flags().GetString("output")if output == "" {fmt.Println(zipPath)return nildiff --git a/kernel/cli/cmd/file.go b/kernel/cli/cmd/file.goindex 9017a3e54f..cfcd1ea837 100644--- a/kernel/cli/cmd/file.go+++ b/kernel/cli/cmd/file.go@@ -102,6 +102,12 @@ var fileWriteCmd = &cobra.Command{if err != nil {return err}++ if dryRun {+ fmt.Printf("[dry-run] Would write file: %s\n", args[0])+ return nil+ }+src, _ := cmd.Flags().GetString("file")var data []byteif src != "" {@@ -132,6 +138,12 @@ var fileDeleteCmd = &cobra.Command{if err != nil {return err}++ if dryRun {+ fmt.Printf("[dry-run] Would delete: %s\n", args[0])+ return nil+ }+info, err := os.Stat(p)if err != nil {return err@@ -162,6 +174,12 @@ var fileRenameCmd = &cobra.Command{if err != nil {return err}++ if dryRun {+ fmt.Printf("[dry-run] Would rename/move: %s -> %s\n", args[0], args[1])+ return nil+ }+if err := os.MkdirAll(filepath.Dir(newP), 0755); err != nil {return err}@@ -186,6 +204,12 @@ var fileCopyCmd = &cobra.Command{if err != nil {return err}++ if dryRun {+ fmt.Printf("[dry-run] Would copy: %s -> %s\n", args[0], args[1])+ return nil+ }+if err := copyPath(src, dst); err != nil {return err}diff --git a/kernel/cli/cmd/history.go b/kernel/cli/cmd/history.goindex cca1e90b35..077f576376 100644--- a/kernel/cli/cmd/history.go+++ b/kernel/cli/cmd/history.go@@ -113,6 +113,11 @@ var historyRollbackCmd = &cobra.Command{return fmt.Errorf("--path is required")}+ if dryRun {+ fmt.Printf("[dry-run] Would rollback to history version: %s\n", historyPath)+ return nil+ }+if err := model.RollbackDocHistory(historyPath); err != nil {return err}@@ -130,6 +135,11 @@ var historyClearCmd = &cobra.Command{Use: "clear",Short: "Clear all history",RunE: func(cmd *cobra.Command, args []string) error {+ if dryRun {+ fmt.Println("[dry-run] Would clear all history")+ return nil+ }+if err := model.ClearWorkspaceHistory(); err != nil {return err}diff --git a/kernel/cli/cmd/import.go b/kernel/cli/cmd/import.goindex 9f893cb261..3e9b414867 100644--- a/kernel/cli/cmd/import.go+++ b/kernel/cli/cmd/import.go@@ -50,6 +50,11 @@ var importMdCmd = &cobra.Command{return err}+ if dryRun {+ fmt.Printf("[dry-run] Would import Markdown from \"%s\" to notebook %s\n", filePath, notebook)+ return nil+ }+if err := model.ImportFromLocalPath(notebook, absPath, resolvePath(notebook, toPath, hpath)); err != nil {return err}@@ -79,6 +84,11 @@ var importSYCmd = &cobra.Command{return err}+ if dryRun {+ fmt.Printf("[dry-run] Would import .sy.zip from \"%s\" to notebook %s\n", filePath, notebook)+ return nil+ }+if err := model.ImportSY(absPath, notebook, resolvePath(notebook, toPath, hpath)); err != nil {return err}@@ -102,6 +112,11 @@ var importDataCmd = &cobra.Command{return err}+ if dryRun {+ fmt.Printf("[dry-run] Would import data backup from \"%s\"\n", filePath)+ return nil+ }+if err := model.ImportData(absPath); err != nil {return err}diff --git a/kernel/cli/cmd/notebook.go b/kernel/cli/cmd/notebook.goindex 81aab848b2..d5c1010581 100644--- a/kernel/cli/cmd/notebook.go+++ b/kernel/cli/cmd/notebook.go@@ -62,6 +62,12 @@ var notebookCreateCmd = &cobra.Command{if name == "" {return fmt.Errorf("--name is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would create notebook \"%s\"\n", name)+ return nil+ }+id, err := model.CreateBox(name)if err != nil {return err@@ -80,6 +86,12 @@ var notebookRemoveCmd = &cobra.Command{if id == "" {return fmt.Errorf("--id is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would remove notebook %s\n", id)+ return nil+ }+if err := model.RemoveBox(id); err != nil {return err}@@ -101,6 +113,12 @@ var notebookRenameCmd = &cobra.Command{if name == "" {return fmt.Errorf("--name is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would rename notebook %s to \"%s\"\n", id, name)+ return nil+ }+if err := model.RenameBox(id, name); err != nil {return err}@@ -118,6 +136,12 @@ var notebookOpenCmd = &cobra.Command{if id == "" {return fmt.Errorf("--id is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would open notebook %s\n", id)+ return nil+ }+existed, err := model.Mount(id)if err != nil {return err@@ -145,6 +169,12 @@ var notebookCloseCmd = &cobra.Command{if id == "" {return fmt.Errorf("--id is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would close notebook %s\n", id)+ return nil+ }+model.Unmount(id)time.Sleep(1 * time.Second)sql.FlushQueue()diff --git a/kernel/cli/cmd/ref.go b/kernel/cli/cmd/ref.goindex 6980b7c6d9..7a9d3a34f0 100644--- a/kernel/cli/cmd/ref.go+++ b/kernel/cli/cmd/ref.go@@ -95,6 +95,11 @@ var refRefreshCmd = &cobra.Command{return fmt.Errorf("--id is required")}+ if dryRun {+ fmt.Printf("[dry-run] Would refresh backlinks for block %s\n", id)+ return nil+ }+model.RefreshBacklink(id)fmt.Println("ok")return nildiff --git a/kernel/cli/cmd/repo.go b/kernel/cli/cmd/repo.goindex 08e74fe779..3110009e2a 100644--- a/kernel/cli/cmd/repo.go+++ b/kernel/cli/cmd/repo.go@@ -84,6 +84,12 @@ var repoCreateCmd = &cobra.Command{Short: "Create a snapshot",RunE: func(cmd *cobra.Command, args []string) error {memo, _ := cmd.Flags().GetString("memo")++ if dryRun {+ fmt.Println("[dry-run] Would create snapshot")+ return nil+ }+if err := model.IndexRepo(memo); err != nil {return err}@@ -101,6 +107,12 @@ var repoTagCmd = &cobra.Command{if id == "" || name == "" {return fmt.Errorf("--id and --name are required")}++ if dryRun {+ fmt.Printf("[dry-run] Would tag snapshot %s with \"%s\"\n", id, name)+ return nil+ }+if err := model.TagSnapshot(id, name); err != nil {return err}@@ -117,6 +129,12 @@ var repoUntagCmd = &cobra.Command{if name == "" {return fmt.Errorf("--name is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would remove snapshot tag \"%s\"\n", name)+ return nil+ }+if err := model.RemoveTagSnapshot(name); err != nil {return err}@@ -133,6 +151,12 @@ var repoCheckoutCmd = &cobra.Command{if id == "" {return fmt.Errorf("--id is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would rollback workspace to snapshot %s\n", id)+ return nil+ }+model.CheckoutRepoDirect(id)model.AppendPushReloadFiletreeEntry()model.AppendPushReloadUIEntry()@@ -196,6 +220,11 @@ var repoPurgeCmd = &cobra.Command{Use: "purge",Short: "Purge old snapshots",RunE: func(cmd *cobra.Command, args []string) error {+ if dryRun {+ fmt.Println("[dry-run] Would purge old snapshots")+ return nil+ }+if err := model.PurgeRepo(); err != nil {return err}@@ -217,11 +246,17 @@ var repoFileGetCmd = &cobra.Command{if id == "" {return fmt.Errorf("--id is required")}++ output, _ := cmd.Flags().GetString("output")+ if dryRun && output != "" {+ fmt.Printf("[dry-run] Would export snapshot file %s to %s\n", id, output)+ return nil+ }+data, path, err := model.GetRepoFile(id)if err != nil {return err}- output, _ := cmd.Flags().GetString("output")if output != "" {return os.WriteFile(output, data, 0644)}@@ -238,6 +273,12 @@ var repoFileRollbackCmd = &cobra.Command{if id == "" {return fmt.Errorf("--id is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would rollback file %s from snapshot\n", id)+ return nil+ }+if err := model.RollbackRepoSnapshotFile(id); err != nil {return err}@@ -274,6 +315,12 @@ var repoFileExportCmd = &cobra.Command{if id == "" {return fmt.Errorf("--id is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would export snapshot file %s to temp path\n", id)+ return nil+ }+exportPath, err := model.ExportRepoFile(id)if err != nil {return errdiff --git a/kernel/cli/cmd/root.go b/kernel/cli/cmd/root.goindex 9a82a54fb6..d2983ee573 100644--- a/kernel/cli/cmd/root.go+++ b/kernel/cli/cmd/root.go@@ -34,6 +34,7 @@ import (var (workspacePath stringoutputFormat string+ dryRun bool)var rootCmd = &cobra.Command{@@ -130,6 +131,7 @@ func init() {rootCmd.PersistentFlags().StringVarP(&workspacePath, "workspace", "w", "", "workspace path")rootCmd.PersistentFlags().StringVarP(&outputFormat, "format", "f", "table", "output format: table | json")+ rootCmd.PersistentFlags().BoolVar(&dryRun, "dry-run", false, "dry run mode: validate and print what would happen without making changes")}func Execute() error {diff --git a/kernel/cli/cmd/sync.go b/kernel/cli/cmd/sync.goindex b3d43a516e..f397e1514f 100644--- a/kernel/cli/cmd/sync.go+++ b/kernel/cli/cmd/sync.go@@ -34,6 +34,12 @@ var syncCmd = &cobra.Command{if model.Conf.Sync.Mode == 3 {return fmt.Errorf("full-manual mode requires 'push' or 'pull' subcommand")}++ if dryRun {+ fmt.Println("[dry-run] Would sync data with cloud")+ return nil+ }+model.SyncData(true)fmt.Println("ok")return nil@@ -44,6 +50,11 @@ var syncPushCmd = &cobra.Command{Use: "push",Short: "Upload to cloud",RunE: func(cmd *cobra.Command, args []string) error {+ if dryRun {+ fmt.Println("[dry-run] Would upload to cloud")+ return nil+ }+model.SyncDataUpload()fmt.Println("ok")return nil@@ -54,6 +65,11 @@ var syncPullCmd = &cobra.Command{Use: "pull",Short: "Download from cloud",RunE: func(cmd *cobra.Command, args []string) error {+ if dryRun {+ fmt.Println("[dry-run] Would download from cloud")+ return nil+ }+model.SyncDataDownload()fmt.Println("ok")return nildiff --git a/kernel/cli/cmd/tag.go b/kernel/cli/cmd/tag.goindex 1e2f82aa1a..1ddf681a1a 100644--- a/kernel/cli/cmd/tag.go+++ b/kernel/cli/cmd/tag.go@@ -58,6 +58,12 @@ var tagRemoveCmd = &cobra.Command{if label == "" {return fmt.Errorf("--label is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would remove tag \"%s\"\n", label)+ return nil+ }+if err := model.RemoveTag(label); err != nil {return err}@@ -78,6 +84,12 @@ var tagRenameCmd = &cobra.Command{if newLabel == "" {return fmt.Errorf("--new is required")}++ if dryRun {+ fmt.Printf("[dry-run] Would rename tag \"%s\" to \"%s\"\n", oldLabel, newLabel)+ return nil+ }+if err := model.RenameTag(oldLabel, newLabel); err != nil {return err}