Skip to content

feat: configurable save directories via environment variables#1

Open
glassdimly wants to merge 1 commit intolearningpro:mainfrom
glassdimly:feat/configurable-save-directories
Open

feat: configurable save directories via environment variables#1
glassdimly wants to merge 1 commit intolearningpro:mainfrom
glassdimly:feat/configurable-save-directories

Conversation

@glassdimly
Copy link
Copy Markdown

Summary

Adds two environment variables to control where conversations are saved, allowing users to customize or disable either save location:

  • OPENCODE_AUTOSAVE_DIR — Local (project-level) save directory. Defaults to ./conversations. Set to false to disable local saves entirely.
  • OPENCODE_AUTOSAVE_GLOBAL_DIR — Global (secondary) save base directory. Defaults to ~/.conversations. The project name is appended as a subdirectory automatically. Set to false to disable.

Motivation

Currently both save paths are hardcoded, which means:

  • Every project gets a ./conversations/ directory created in the project root, which can pollute repos and requires .gitignore entries
  • The global backup path (~/.conversations/) can't be redirected to a preferred location (e.g. ~/Notes/conversations/)
  • There's no way to disable either save location

This is a common pain point — for example, users who only want a single centralized archive have to manually patch the plugin's dist/index.js after every npm install.

Changes

  • src/types.ts: Added resolveConfig() that reads env vars and builds config with localEnabled/globalEnabled flags and custom paths
  • src/file-manager.ts: getGlobalSaveDirectory() now accepts config and uses the configured base directory
  • src/index.ts: Plugin init respects localEnabled; skips local directory creation and writes when disabled. Both save locations nullable throughout.
  • README.md: Documented the new environment variables with usage examples

Backward Compatibility

All defaults are unchanged. With no env vars set, behavior is identical to v1.1.0.

Add OPENCODE_AUTOSAVE_DIR and OPENCODE_AUTOSAVE_GLOBAL_DIR environment
variables to control where conversations are saved. Either location can
be set to a custom path or disabled entirely by setting the value to
'false'.

This allows users to:
- Disable local project saves (avoid polluting project directories)
- Redirect global saves to a custom location (e.g. ~/Notes/)
- Disable either or both save locations independently

All defaults remain unchanged for backward compatibility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant