Skip to content

Support global context paths by merging built-in defaults with user-specified paths #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DanielPe05
Copy link

@DanielPe05 DanielPe05 commented May 6, 2025

This change adds first-class support for “global context paths” in OpenCode. Previously, OpenCode only loaded a fixed set of built-in context files. With this PR you can now append your own Markdown or instruction files—globally or per-project—while preserving the existing defaults.

What’s changed:

  • Add processContextPaths()
  • Starts from the built-in defaultContextPaths
  • Appends any contextPaths from your Viper config
  • Resolves relative paths against the configured working directory
  • Leaves absolute paths untouched
  • Deduplicates the final list
  • Wire processContextPaths() into Load() so it runs after reading global & local configs, but before unmarshalling into Config.
  • Provide a ContextPaths() helper to retrieve the normalized list at runtime.
  • Update README with a Context Paths section showing how to configure and use this feature.

Copy link
Collaborator

@kujtimiihoxha kujtimiihoxha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are adding the defaults either way can we remove the default setting for viper in the setDefaults method ? Also I think ContextPaths is not being used

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.

2 participants