feat(storage): support configurable runtime output directory#2127
Merged
yiliang114 merged 12 commits intoMar 20, 2026
Conversation
…2014) Add `advanced.runtimeOutputDir` setting and `QWEN_RUNTIME_DIR` env var to redirect runtime output (temp files, debug logs, session data, todos, insights) to a custom directory while keeping config files at ~/.qwen. - Introduce `Storage.setRuntimeBaseDir()` / `getRuntimeBaseDir()` with tilde expansion and relative path resolution - Add `AsyncLocalStorage`-based `runWithRuntimeBaseDir()` for concurrent session isolation in ACP integration - Update all runtime path methods to use `getRuntimeBaseDir()` instead of `getGlobalQwenDir()` (temp, debug, ide, projects, history dirs) - Config paths (settings, oauth, installation_id, etc.) remain pinned to `~/.qwen` regardless of runtime dir configuration - Add comprehensive tests covering path resolution, env var priority, async context isolation, and config path stability
Contributor
📋 Review SummaryThis PR introduces a configurable runtime output directory feature, allowing users to redirect temporary files, debug logs, and other runtime data to a custom location via settings or environment variables. The implementation is well-architected with proper path resolution, tilde expansion, and async context isolation for concurrent sessions. 🔍 General Feedback
🎯 Specific Feedback🟡 High
🟢 Medium
🔵 Low
✅ Highlights
|
This was referenced Mar 6, 2026
…time-output-dir # Conflicts: # packages/cli/src/acp-integration/service/filesystem.ts # packages/cli/src/acp-integration/session/Session.ts # packages/cli/src/services/insight/generators/StaticInsightGenerator.ts
扩展 setRuntimeBaseDir 以支持 Windows 风格的波浪号路径 (~\), 使用统一的路径分割逻辑处理 Unix 和 Windows 风格的路径分隔符 Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
添加 ensuredDebugDirPath 追踪变量,当 runtime base dir 发生变更时, 确保在新的目录下创建 debug 子目录 Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
新增 runWithAcpRuntimeOutputDir 辅助函数,在 ACP Agent 的 loadSession 和 listSessions 操作中应用配置的 runtimeOutputDir Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
为 self = this 的用法添加解释性注释,说明在嵌套回调中需要使用 this Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Update storage.test.ts to call getUserSkillsDirs() instead of the non-existent getUserSkillsDir() method. The method was renamed to return an array of skill directories.
…in test
Replace hardcoded forward-slash path `.qwen/todos/` with `path.join('.qwen', 'todos')` to fix Windows CI failure where paths use backslashes.
Made-with: Cursor
xaelistic
pushed a commit
to xaelistic/qwen-code
that referenced
this pull request
Jun 7, 2026
…2127) * feat(storage): support configurable runtime output directory (QwenLM#2014) Add `advanced.runtimeOutputDir` setting and `QWEN_RUNTIME_DIR` env var to redirect runtime output (temp files, debug logs, session data, todos, insights) to a custom directory while keeping config files at ~/.qwen. - Introduce `Storage.setRuntimeBaseDir()` / `getRuntimeBaseDir()` with tilde expansion and relative path resolution - Add `AsyncLocalStorage`-based `runWithRuntimeBaseDir()` for concurrent session isolation in ACP integration - Update all runtime path methods to use `getRuntimeBaseDir()` instead of `getGlobalQwenDir()` (temp, debug, ide, projects, history dirs) - Config paths (settings, oauth, installation_id, etc.) remain pinned to `~/.qwen` regardless of runtime dir configuration - Add comprehensive tests covering path resolution, env var priority, async context isolation, and config path stability * fix(core/storage): 支持 Windows 风格波浪号路径 扩展 setRuntimeBaseDir 以支持 Windows 风格的波浪号路径 (~\), 使用统一的路径分割逻辑处理 Unix 和 Windows 风格的路径分隔符 Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> * fix(core/debugLogger): runtime base dir 变更时创建新 debug 目录 添加 ensuredDebugDirPath 追踪变量,当 runtime base dir 发生变更时, 确保在新的目录下创建 debug 子目录 Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> * feat(cli/acp): 支持 ACP runtime output dir 配置 新增 runWithAcpRuntimeOutputDir 辅助函数,在 ACP Agent 的 loadSession 和 listSessions 操作中应用配置的 runtimeOutputDir Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> * docs(vscode-ide-companion/acpConnection): 补充 this 别名的使用说明 为 self = this 的用法添加解释性注释,说明在嵌套回调中需要使用 this Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> * feat(cli): add runtime output directory configuration support * fix(core): update test to use getUserSkillsDirs method Update storage.test.ts to call getUserSkillsDirs() instead of the non-existent getUserSkillsDir() method. The method was renamed to return an array of skill directories. * fix(core/todoWrite): use path.join for cross-platform path assertion in test Replace hardcoded forward-slash path `.qwen/todos/` with `path.join('.qwen', 'todos')` to fix Windows CI failure where paths use backslashes. Made-with: Cursor --------- Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Support configurable runtime output directory, allowing users to redirect runtime output (temp files, debug logs, session data, todos, insights, etc.) to a custom directory via the
advanced.runtimeOutputDirsetting or theQWEN_RUNTIME_DIRenvironment variable, while config files (settings.json, oauth, installation_id, etc.) remain at~/.qwen.This is an initial implementation for issue #2014, providing flexible runtime output path management for enterprise Agent deployment scenarios.
Dive Deeper
Core Design
Storageclass extensions (packages/core/src/config/storage.ts):setRuntimeBaseDir()/getRuntimeBaseDir()static methods~) expansion and relative path resolution (with optional cwd base directory)QWEN_RUNTIME_DIRenv var >setRuntimeBaseDir()value >getGlobalQwenDir()defaultAsyncLocalStorageto implementrunWithRuntimeBaseDir()for isolating runtime paths across concurrent ACP sessionsPath classification:
getRuntimeBaseDir()):tmp/,debug/,ide/,projects/,history/,todos/,insights/~/.qwen):settings.json,oauth_creds.json,installation_id,google_accounts.json,mcp-oauth-tokens.json,commands/,memory.md,bin/,skills/Settings integration (
packages/cli/src/config/settingsSchema.ts+config.ts):runtimeOutputDirstring setting under theadvancedcategoryloadCliConfig()callsStorage.setRuntimeBaseDir()during initializationACP session isolation (
packages/cli/src/acp-integration/session/Session.ts):Sessionsnapshots the currentruntimeBaseDirat construction timeprompt()wraps execution inStorage.runWithRuntimeBaseDir()to ensure concurrent sessions have isolated pathsAdapted modules:
StaticInsightGenerator: insight output directoryinsightCommand: projects directory lookuptodoWrite: todo file read/writeTest Coverage
storage.test.ts: Path resolution, env var priority, tilde expansion, relative paths, null/undefined/empty string reset, runtime path methods, config path stability, AsyncLocalStorage concurrent isolationconfig.test.ts:loadCliConfigruntimeOutputDir settings integrationSession.test.ts: ACP sessionrunWithRuntimeBaseDirinvocation verificationStaticInsightGenerator.test.ts: Insight output uses runtime directoryinsightCommand.test.ts: Insight command uses runtime directorytodoWrite.test.ts: Todo read/write uses runtime directoryReviewer Test Plan
npm run testto confirm all tests pass~/.qwen/settings.json:{ "advanced": { "runtimeOutputDir": "/tmp/qwen-runtime-test" } }/tmp/qwen-runtime-test/QWEN_RUNTIME_DIR=/tmp/qwen-env-testand verify the env var takes priority over the setting~/.qwen/settings.jsonand other config files are unaffected~/.qwendirectoryTesting Matrix
Linked issues / bugs
Closes #2014