feat: storagePath config for custom session-state storage location (#379) - #380
Merged
Conversation
added 4 commits
September 9, 2026 19:47
) Add top-level storagePath option to relocate the per-session state directory. Absolute paths used as-is, ~/... expanded against home, relative paths resolved against the project directory. Resolved once per session (transient SessionState.storageDir, never persisted). WARN instead of auto-migration when the custom location is empty but the default location holds the session file. Default behavior unchanged when unset.
…cwd-fallback, non-persistence) - Add getConfig layering test (global + project override + unset) - Add validateConfigTypes non-string rejection test - Add custom-location resume happy path (no spurious WARN) - Add process.cwd() fallback test (projectDir omitted) - Assert transient storageDir never appears in persisted JSON - Move default-loc regression cleanup into finally - Remove dead ensureStorageDir helper (pre-existing, touched by PR)
…tate, WARN wording) - Add SessionStateRegistry.getOrCreate projectDir wiring test (relative storagePath must resolve against the registry's projectDir, not cwd) - Add resetSessionState clears transient storageDir test - Cover storagePath: undefined in validateConfigTypes test - WARN wording: 'no state' -> 'no valid state' (corrupt-file edge) - Update devlog WORKLOG (19 tests, 1131 total, dual-agent review status, deferred follow-ups)
Closed
📦 Built Plugin ArtifactBranch: Option A — Install from npm PR tag (recommended)opencode plugin opencode-acp@pr-380 --globalEach push to this PR publishes a new version under the Option B — Install from GitHubopencode plugin "github:ranxianglei/opencode-acp#2026-09-09_custom-storage-path" --globalOption C — Download artifact
tar xzf opencode-acp-pr380.tgz
cp -r package/dist ~/.cache/opencode/packages/opencode-acp@latest/node_modules/opencode-acp/dist
This comment is automatically updated on each push. |
This was referenced Sep 9, 2026
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.
Summary
Fixes #379 — 支持压缩内容自定义存储位置 (support custom storage location for compressed content).
Adds a new optional top-level config option
storagePaththat relocates where ACP persists per-session state files ({sessionId}.json). The location was previously hardcoded to$XDG_DATA_HOME/opencode/storage/plugin/acp.Path semantics
$XDG_DATA_HOME/opencode/storage/plugin/acp(unchanged)/abs/path~/~/xrel/pathThe resolved directory is computed once per session in
ensureSessionInitializedand carried onSessionState.storageDir— a transient field that is never written to the persisted JSON (covered by a dedicated test).Migration policy
No auto-migration (by design — moving user data silently is worse than warning). If
storagePathis set, no valid state is found there, but a state file exists at the default location, ACP logs a one-time WARN per session telling the user to move the file manually. SwitchingstoragePathfrom one custom location to another is a documented follow-up.Changes
lib/config.ts—PluginConfig.storagePath?: string+mergeLayermerge (3-layer override works)lib/config-validation.ts—VALID_CONFIG_KEYS+ string type checkdcp.schema.json—storagePathproperty (schema isadditionalProperties: false)lib/state/persistence.ts—getDefaultStorageDir()/resolveStorageDir()(exported);storageDir?threaded through path/save/load/stats helpers;saveSessionStatereadssessionState.storageDirlib/state/types.ts— transientSessionState.storageDirlib/state/state.ts—createSessionState/resetSessionState/ensureSessionInitialized(resolve + migration WARN) / registryprojectDirconstructor argindex.ts—new SessionStateRegistry(logger, ctx.directory)tests/storage-path.test.ts— 19 new tests (1131 total, all passing)CONFIGURATION.md/CONFIGURATION.zh-CN.md— parameter entry + recipedevlog/2026-09-09_custom-storage-path/— REQ / DESIGN / WORKLOGVerification
npm run typecheck✓,npm run build✓,npm run test→ 1131/1131 ✓./scripts/ci/check-pr.sh→ all checks passed (version unchanged)Compatibility
dcpnaming changeFollow-ups (tracked in devlog WORKLOG §7)
storagePath(writability)ACP_STORAGE_DIRenv var override (deferred — config option is the supported path)