-
Notifications
You must be signed in to change notification settings - Fork 1
LLM calls now include module summaries #16
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
Merged
Merged
Conversation
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
Introduce working_dir validation so change proposals that attempt to modify files outside the current working directory are rejected. A helper function `IsPathUnderDir` is added to determine if a relative path resides inside the working directory. The `execute` function now leverages this helper to validate every proposed change, returning an error when violations are detected. Unit tests were added to cover various scenarios for the helper function, ensuring correctness across typical edge-cases (root working Dir, same-directory, sub-directories and sibling paths).
Populate the empty TODO List with a sequenced set of atomic tasks that outline how to implement the new project_root / working_dir / target_dir context-selection rules. The list gives a clear, incremental roadmap covering data-structure changes, refactors to selector/matcher logic, updates to execution context building, CLI wiring, and new/updated tests and documentation.
The ExecutionContext struct along with constructor and tests have been added in workspace/context. Update TODO_VYB.md to reflect completion of task 1, switching its checkbox from unchecked to checked.
Replaced prepareExecutionContext logic with implementation that builds and returns a workspace/context.ExecutionContext, dropping the old tuple return. The execute flow now derives relWorkDir and relTarget from the returned ExecutionContext, ensuring paths are correctly computed relative to ProjectRoot. The new prepareExecutionContext validates invariants via context.NewExecutionContext so commands fail fast when target_file resides outside working_dir. Updated imports and adapted variable handling accordingly.
The selector.Select signature now takes an *context.ExecutionContext instance, enforcing the new path-concept API (project_root / working_dir / target_dir). Selection always starts at ExecutionContext.TargetDir, recursively inspecting every file inside it while honouring exclusion / inclusion patterns and .gitignore inheritance – behaviour from the previous implementation remains unchanged. All call-sites were migrated: • cmd/template now forwards the ExecutionContext it already builds. • workspace/project/metadata creates a minimal ExecutionContext stub to preserve existing behaviour when scanning the whole workspace. Unit tests were adapted to construct an ExecutionContext. Tests are currently failing for project/selector module. Need to fix the parent exclusion inheritance logic.
Selector.Select now walks from project root (".") instead of target dir to ensure
exclusion patterns defined in ancestor directories (e.g. .gitignore files) are
considered. A new helper determines whether a directory is relevant (ancestor
or descendant of the target) so irrelevant branches are skipped early, keeping
performance acceptable. Files outside the target subtree are ignored. This
corrects exclusion behavior when the working directory is a deep sub-folder,
allowing parent .gitignore rules to apply and making unit tests pass.
…ontext.WorkingDir Replaces old relative-path helper with a direct absolute-path check against the ExecutionContext.WorkingDir. Changes include: • Removed isPathUnderDir helper and its dedicated tests. • execute() now validates each proposed file by confirming its absolute path is nested in, or equal to, ec.WorkingDir. • Added small inline isWithinDir closure to keep code readable without re-introducing a standalone helper. • Updated TODO_VYB.md marking task 4 as completed.
Now composing rich user messages that prepend module summaries before file contents when executing AI-powered commands. New helper buildExtendedUserMessage generates the payload according to required rules: • External context of module containing working_dir. • Internal context of modules between working_dir and target_dir. • Public context of sibling modules under working_dir not related to target_dir. • Public context of immediate sub-modules of target module. • Code of files exclusively inside target module. Executed via: 1. project: add LoadMetadata and FindModule utilities for metadata access and module lookup without creating new cycles. 2. template: buildExtendedUserMessage helper and integration in execute(); falls back to old logic when metadata unavailable. 3. Update TODO_VYB.md marking item 5 complete. Includes unit tests for new helpers using in-memory module trees.
Introduced an `--all` boolean flag for every dynamic template command. When set, the command now sends **all** files under the `target_dir` and its sub-modules to the LLM. The default behaviour is stricter: if metadata is available files that belong to descendant modules of the `target_dir` are filtered out, keeping only those that belong to the target module itself. Implementation details: • Register() now attaches an `--all` flag to each generated Cobra command. • execute() retrieves the flag, and when not set it filters the file list based on module membership using project metadata. • Added helper logic to resolve the target module and compare against each file’s module. No existing functionality is affected when `--all` is true; selector behaviour remains unchanged. No tests required update because selector tests are untouched and the new filtering occurs after metadata loading in runtime paths not covered by unit tests.
Adds new test case `TestSelect_TargetDirIsolation` to validate that `selector.Select` only returns files within the specified `TargetDir`. Also updates TODO_VYB.md, marking task 7 as completed.
…keep annotations while updating file lists Implements TODO 8: loads stored metadata from .vyb, builds a fresh metadata snapshot from the current filesystem, validates module name sets are identical, then patches stored metadata with the fresh snapshot to preserve annotations but refresh hashes, token counts and files. Adds exported helpers BuildMetadata and BuildMetadataFS in workspace/project so callers can generate fresh metadata using existing internal logic.
FindModule to treat root module as match for files directly in project root, ensuring files in root module are included when target_dir = project_root. Added unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances LLM requests by including module context summaries around file contents. Key changes:
- Selector.Select now uses
ExecutionContextto isolate traversal toTargetDir. - Introduces
buildExtendedUserMessageto prepend module summaries in the prompt. - Updates command execution to load/merge metadata, add a
--allflag, and wire through the new context API.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| workspace/selector/selector_test.go | Updated tests to use ExecutionContext and added isolation case |
| workspace/selector/selector.go | Switched to ExecutionContext, tightened traversal invariants |
| workspace/project/metadata_helpers_test.go | Added tests for FindModule behavior at root and nested paths |
| workspace/project/metadata_helpers.go | Implemented FindModule default logic to return root |
| workspace/project/metadata.go | Exposed BuildMetadataFS, updated selector call in buildMetadata |
| workspace/context/context_test.go | Tests added for NewExecutionContext error and success cases |
| workspace/context/context.go | Added ExecutionContext constructor and path validation |
| cmd/template/user_msg_builder_test.go | Tests verifying extended user message composition |
| cmd/template/user_msg_builder.go | New buildExtendedUserMessage implementation |
| cmd/template/template.go | Updated execution flow to use ExecutionContext, metadata merge |
Comments suppressed due to low confidence (2)
workspace/selector/selector.go:102
- Mixing the
pathpackage with filesystem traversal can break on Windows. Usefilepath.Dir(currPath)to respect the OS-specific separator.
parentDir := path.Dir(currPath)
workspace/selector/selector.go:135
- Using
path.Joinhere may produce incorrect separators on Windows; preferfilepath.Join(dir, ".gitignore")for cross-platform correctness.
gitignorePath := path.Join(dir, ".gitignore")
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.
This implements #5.
vyb code(and other templated commands) now only includes:working module(the module containing the working directory);working moduleand thetarget module(the module containing thetarget directory);target module, or a sibling of any of target module's parent modules, up to theworking module;target module;target module;--allflag is used, it also includes all the files indirectly linked to thetarget module;