Resolve configuration file against the current working directory#146
Merged
Conversation
The croct.json path was joined with the working directory once, when the configuration manager was instantiated at CLI startup. Templates that scaffold a project and change into it (e.g. change-directory) ended up reading and writing croct.json in the folder the CLI was launched from instead of the project folder. The manager now resolves the configuration file against the live project directory on each operation, keeping absolute path overrides untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
👋 @marcospassos
☝️ Lastly, the title for the commit will come from the pull request title. So please provide a descriptive title that summarizes the changes in 50 characters or less using the imperative mood. |
commit: |
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
Running a template that scaffolds a project and changes into it (e.g.
croct use croct://integration/sanityin an empty folder) createdcroct.jsonin the folder the CLI was launched from instead of the project folder.The cause:
JsonConfigurationFileManagerreceived the configuration file as an absolute path pre-joined with the working directory at instantiation time. Since the manager is a memoized singleton wired at startup, the path was frozen at the invocation directory — while the template'schange-directoryaction only mutates the sharedVirtualizedWorkingDirectory, which the manager never consulted again. Notably, the manager already declared aprojectDirectorydependency that was never used.The fix:
JsonConfigurationFileManagernow resolves the configuration file per operation: absolute paths are used as-is, relative ones are joined withprojectDirectory.get()at call time.croct.json) through instead of pre-joining it.Test plan
change-directorynow loadscroct.jsonfrom the target folder; before the fix the same run failed to find the configuration and fell into the init flow at the launch directory🤖 Generated with Claude Code