An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/17865
Daniel09c214a984d0
diff --git a/kernel/cli/cmd/root.go b/kernel/cli/cmd/root.goindex d2983ee573..23168ccf0e 100644--- a/kernel/cli/cmd/root.go+++ b/kernel/cli/cmd/root.go@@ -46,18 +46,11 @@ var rootCmd = &cobra.Command{return nil}- // 确定工作目录- if exePath, err := os.Executable(); err == nil {- if resolved, err2 := filepath.EvalSymlinks(exePath); err2 == nil {- exePath = resolved- }- util.WorkingDir = filepath.Dir(exePath)- }-- // 尝试在常见位置查找 appearance 目录- appDir := findAppDir()- if appDir != "" {- util.WorkingDir = appDir+ // 默认工作目录取内核可执行文件所在目录的上一级(打包后的 resources/,appearance/、stage/ 所在目录),+ // 而非内核可执行文件所在目录本身(resources/kernel/)。resolveWorkingDir() 会校验 appearance/langs 实际存在,+ // 兼容开发态等多种目录布局。+ if workingDir := resolveWorkingDir(); workingDir != "" {+ util.WorkingDir = workingDir}langsDir := filepath.Join(util.WorkingDir, "appearance", "langs")@@ -96,7 +89,10 @@ var rootCmd = &cobra.Command{},}-func findAppDir() string {+// resolveWorkingDir 从内核可执行文件路径出发,探测若干候选目录,返回首个包含 appearance/langs 的目录作为+// 工作目录(打包后为 resources/,开发态视目录布局而定);找不到返回空串。rootCmd.PersistentPreRunE 与+// serve 子命令的 --wd 默认值都走这个函数,确保两条启动路径行为一致。+func resolveWorkingDir() string {if exePath, err := os.Executable(); err == nil {if resolved, err2 := filepath.EvalSymlinks(exePath); err2 == nil {exePath = resolveddiff --git a/kernel/cli/cmd/serve.go b/kernel/cli/cmd/serve.goindex 8200cec671..ad33660402 100644--- a/kernel/cli/cmd/serve.go+++ b/kernel/cli/cmd/serve.go@@ -88,8 +88,9 @@ var serveCmd = &cobra.Command{}func init() {- // 与 util.Boot() 中的默认值保持一致,确保两条启动路径行为相同。- serveCmd.Flags().StringVar(&serveWdPath, "wd", util.WorkingDir, "working directory of SiYuan")+ // --wd 默认值取内核可执行文件所在目录的上一级(打包后的 resources/,appearance/、stage/ 所在目录),+ // 与 rootCmd.PersistentPreRunE 走同一个 resolveWorkingDir(),确保两条启动路径行为一致。+ serveCmd.Flags().StringVar(&serveWdPath, "wd", resolveWorkingDir(), "working directory of SiYuan")serveCmd.Flags().StringVar(&servePort, "port", "0", "port of the HTTP server")serveCmd.Flags().StringVar(&serveReadOnly, "readonly", "false", "read-only mode")serveCmd.Flags().StringVar(&serveAccessAuthCode, "accessAuthCode", "", "access auth code")