refactor(copilot): PathResolver::new takes a required home argument - #209
Open
ecalifornica wants to merge 1 commit into
Open
refactor(copilot): PathResolver::new takes a required home argument#209ecalifornica wants to merge 1 commit into
ecalifornica wants to merge 1 commit into
Conversation
|
🔍 Preview deployed: https://02f6bbff.toolpath.pages.dev |
ecalifornica
force-pushed
the
robert/config-copilot
branch
from
August 14, 2026 19:49
60769e4 to
66796b1
Compare
ecalifornica
commented
Aug 17, 2026
Comment on lines
+72
to
+77
| let resolver = toolpath_copilot::PathResolver::new(home); | ||
| match &config.copilot_home { | ||
| Some(dir) => resolver.with_copilot_dir(dir), | ||
| None => resolver, | ||
| } | ||
| }) |
Collaborator
Author
There was a problem hiding this comment.
Previous behavior: if neither $HOME nor $USERPROFILE are set $COPILOT_HOME replaces the root. The new resolver returns None. Is this the desired behavior?
…185) toolpath-copilot reads no environment variable. The caller supplies the home directory and the strict-parsing flag. The crate keeps the layout below the home directory: Copilot data is in <home>/.copilot. PathResolver::new(home) takes the home directory as a required argument. CopilotConvo::new(home) and ConvoIO::new(home) take the same argument. with_copilot_dir stays as the full override, and it wins against the home-derived default. The home directory is always present, so the 6 pure path accessors return a path instead of a Result. The CHANGELOG lists them. list_session_dirs, find_session_dir, events_file, and workspace_file keep their Result. Their error is a failed directory read or an unresolved session id, not a missing home. Strict events parsing is a parameter. EventReader::read_lines_with and EventReader::read_session_dir_with take the flag directly. CopilotConvo::with_strict and ConvoIO::with_strict store it, default false, and pass it to the reader. path-cli: providers::copilot_resolver returns Option<PathResolver>. require_copilot_resolver turns None into an error for the 5 commands that target Copilot. Config reads $COPILOT_EVENTS_STRICT, and providers::copilot_strict turns its presence into the flag every CopilotConvo receives. toolpath-copilot 0.2.0: breaking.
ecalifornica
force-pushed
the
robert/config-copilot
branch
from
August 18, 2026 20:09
66796b1 to
4d96f45
Compare
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.
Part of #185: the crate reads no environment variable,
Configowns every read, and the caller supplies what the crate used to resolve itself.Judgment calls:
read_lines(path)andread_session_dir(dir)stay lenient. Context: an events file is a Copilot CLI session log (~/.copilot/session-state/<id>/events.jsonl) with a reverse-engineered schema, and the preview reader is deliberately tolerant of shape variations. Strict reading reports an unparseable line as an error and is an explicit opt-in viawith_strict(bool),read_lines_with, orread_session_dir_with. The flag is in this PR because$COPILOT_EVENTS_STRICTselects it, and this refactor moves every environment read out of the crate.$COPILOT_EVENTS_STRICTset, whatever its value. This matches the deletedstd::env::var(...).is_ok()check exactly.Configstores the rawOption<String>;providers::copilot_strictowns the presence-is-the-signal interpretation.$COPILOT_HOMEmoves toConfigwith its meaning intact:copilot_resolverinjects it throughwith_copilot_dir, which wins against the home-derived default.$COPILOT_HOMEset but no home directory inConfig,copilot_resolverreturnsNoneand the CLI reports the missing home.$COPILOT_HOMEreplaces the data root, not the home, so it cannot satisfynew(home). The environment is rare and the error names the fix. Both variables keep their behavior whenever a home directory exists.