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
Danielfff44b5d4cdd
diff --git a/kernel/cli/cmd/root.go b/kernel/cli/cmd/root.goindex 33741136e3..9e784b3962 100644--- a/kernel/cli/cmd/root.go+++ b/kernel/cli/cmd/root.go@@ -40,6 +40,11 @@ var rootCmd = &cobra.Command{Use: "SiYuan-Kernel",Version: util.Ver,PersistentPreRunE: func(cmd *cobra.Command, args []string) error {+ // workspace 子命令不需要工作空间校验+ if cmd.Parent() != nil && cmd.Parent().Name() == "workspace" {+ return nil+ }+// 确定工作目录if exePath, err := os.Executable(); err == nil {exePath, _ = filepath.EvalSymlinks(exePath)diff --git a/kernel/cli/cmd/workspace.go b/kernel/cli/cmd/workspace.goindex 0c141ff4cc..ddd00ebb66 100644--- a/kernel/cli/cmd/workspace.go+++ b/kernel/cli/cmd/workspace.go@@ -19,6 +19,7 @@ package cmdimport ("encoding/json""fmt"+ "os""path/filepath""github.com/siyuan-note/siyuan/kernel/util"@@ -68,23 +69,38 @@ var workspaceInfoCmd = &cobra.Command{Use: "info",Short: "Show current workspace info",RunE: func(cmd *cobra.Command, args []string) error {+ dir := workspacePath+ if dir == "" {+ dir = resolveDefaultWorkspace()+ }switch outputFormat {case "json":data, _ := json.MarshalIndent(map[string]any{- "path": util.WorkspaceDir,+ "path": dir,"version": util.Ver,- "valid": util.IsWorkspaceDir(util.WorkspaceDir),+ "valid": util.IsWorkspaceDir(dir),}, "", " ")fmt.Println(string(data))default:- fmt.Printf("Path: %s\n", util.WorkspaceDir)+ fmt.Printf("Path: %s\n", dir)fmt.Printf("Version: %s\n", util.Ver)- fmt.Printf("IsValid: %v\n", util.IsWorkspaceDir(util.WorkspaceDir))+ fmt.Printf("IsValid: %v\n", util.IsWorkspaceDir(dir))}return nil},}+func resolveDefaultWorkspace() string {+ if p := os.Getenv("SIYUAN_WORKSPACE_PATH"); p != "" {+ return p+ }+ paths, _ := util.ReadWorkspacePaths()+ if len(paths) > 0 {+ return paths[len(paths)-1]+ }+ return filepath.Join(util.HomeDir, "SiYuan")+}+func init() {rootCmd.AddCommand(workspaceCmd)workspaceCmd.AddCommand(workspaceListCmd)