Skip to content

refactor(opencode): PathResolver::new takes a required home argument - #210

Open
ecalifornica wants to merge 1 commit into
robert/config-copilotfrom
robert/config-opencode
Open

refactor(opencode): PathResolver::new takes a required home argument#210
ecalifornica wants to merge 1 commit into
robert/config-copilotfrom
robert/config-opencode

Conversation

@ecalifornica

@ecalifornica ecalifornica commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Part of #185: the crate reads no environment variable, Config owns every read, and the caller supplies what the crate used to resolve itself.

Judgment calls:

  • The XDG root is a resolver argument, not a pre-computed data dir in the CLI. Context: opencode's data root is $XDG_DATA_HOME/opencode before the home fallback (<home>/.local/share/opencode). with_xdg_data_home(xdg) stores the root and the resolver appends opencode: the append is layout knowledge, so it belongs to the crate, and the CLI owns only the value. The precedence is stated in one place and unit-tested: with_data_dir, then with_xdg_data_home, then the home default.
  • Preserved quirk, not this PR's bug: an empty-but-set $XDG_DATA_HOME produces the relative data dir opencode, exactly as the in-crate read did (its is_empty guard never fired after the join). Empty-as-unset is a separate change.
  • Snapshot diffs need a resolver. Context: opencode keeps a per-project bare git repository beside its database, and a turn's real unified diff comes from a tree-to-tree comparison in that repository. to_view(session) and derive_path(session, config) skip it; the _with_resolver variants and the ConversationProvider impl open it. path-cli calls the resolver-bearing functions, so its file diffs are unchanged.

@ecalifornica ecalifornica changed the title robert/config opencode refactor(opencode): PathResolver::new takes a required home argument Aug 14, 2026
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown

🔍 Preview deployed: https://42c0bfc9.toolpath.pages.dev

@ecalifornica
ecalifornica force-pushed the robert/config-opencode branch from 61393ef to c186b8a Compare August 14, 2026 19:49
@ecalifornica
ecalifornica requested a review from akesling August 17, 2026 18:01
@ecalifornica
ecalifornica marked this pull request as ready for review August 17, 2026 18:01
…185)

toolpath-opencode reads no environment variable. The caller supplies
the home directory and the XDG data root. The crate keeps the layout
knowledge: the data directory is <xdg>/opencode, or
<home>/.local/share/opencode.

PathResolver::with_xdg_data_home sets the XDG data root, and the
resolver appends opencode to it. with_data_dir stays as the full
override. path-cli passes the configured value through verbatim, so
$XDG_DATA_HOME keeps its behavior for CLI users.

The 7 path accessors whose only failure mode was a missing home
return a path instead of a Result. The SQLite reads and the directory
reads keep their Result.

The snapshot git repository needs a resolver. to_view and derive_path
skip it; to_view_with_resolver, derive_path_with_resolver, and the
ConversationProvider impl open it.

path-cli: providers::opencode_resolver returns Option<PathResolver>,
require_opencode_resolver serves the 5 commands that target opencode,
and harness_bundle omits opencode when the configuration carries no
home directory.
@ecalifornica
ecalifornica force-pushed the robert/config-opencode branch from c186b8a to 73d0fcd Compare August 18, 2026 20:09
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