Skip to content
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

Navie misunderstands the intended file path #2063

Open
kgilpin opened this issue Oct 13, 2024 · 2 comments
Open

Navie misunderstands the intended file path #2063

kgilpin opened this issue Oct 13, 2024 · 2 comments
Assignees
Labels
bug Something isn't working navie navie-plan

Comments

@kgilpin
Copy link
Contributor

kgilpin commented Oct 13, 2024

Instructed to specifically generate code for a full file path:

@generate /Users/kgilpin/source/appland/appmap-js/packages/search/src/snippet-index.ts

When Navie lists files, non-file names are detected as files, and the actual file name is not detected. Navie then emits changes to the wrong file.

73909 [Stderr] Tokens (prompt/compl/total): 0/0/0
73909 [Stderr] List files response:
73909 [Stderr] ```json
73909 [Stderr] [
73909 [Stderr]   "snippet_content",
73909 [Stderr]   "snippet_boost",
73909 [Stderr]   "file_content",
73909 [Stderr]   "file_boost"
73909 [Stderr] ]
73909 [Stderr] ```
73909 [Stderr] Explain received context request: search
73909 [Stderr] Collecting context with parameters: sourceDirectories: /Users/kgilpin/source/appland/appmap-js/packages/search, charLimit: 0, locations: snippet_content, snippet_boost, file_content, file_boost
73909 [Stderr] Parsed locations: snippet_content, snippet_boost, file_content, file_boost
73909 [Stdout] [context-service] Retrieving full context of files: snippet_content, snippet_boost, file_content, file_boost
73909 [Stderr] No context found
73909 [Stdout] [context-service] Added 0 characters of file context
73909 [Stdout] [context-service] Searching for context
73909 [Stderr] Tokens (prompt/compl/total): 0/0/0
73909 [Stderr] Vector terms response:
73909 [Stderr] Context: auth
73909 [Stderr] Instructions: Search for matching snippets
73909 [Stderr] ---
73909 [Stderr] Terms: +auth authentication authorization boost score fts5 sql
73909 [Stderr] Explain received context request: search
73909 [Stderr] Collecting context with parameters: sourceDirectories: /Users/kgilpin/source/appland/appmap-js/packages/search, charLimit: 48018, keywords: auth, authentication, authorization, boost, score, fts5, sql, labels: explain(high), feature(high)

If I change the question to @generate src/snippet-index.ts, then I get a listing of the full code and the UI shows the correct file path, but clicking the "Apply" button results in the wavy "apply" animation and then the checkmark, but the file is not modified. The initial file contents is simply:

// TODO
Screen Shot 2024-10-13 at 9 02 48 AM Screen Shot 2024-10-13 at 9 03 56 AM

Trajectory

4861736c-8592-40a4-a2ef-c0dc5863fd9c.zip


Plan solution in the navie package only.

Copy link

github-actions bot commented Oct 13, 2024

Title

Fix file path resolution and context retrieval in Navie context service

Problem

Navie is incorrectly interpreting file paths when instructed to generate code modifications for a specific file. This leads to non-file names being treated as files and the actual file name not being recognized or modified correctly.

Analysis

The problem arises when Navie is instructed to access or modify a file using an explicitly given full file path. Instead of correctly identifying the file and its contents, Navie misidentifies non-file names as actual files and vice versa. This leads to context retrieval issues and incorrect file modifications during code generation tasks. The symptoms of this issue include:

  • Erroneous listing of files containing non-file content.
  • Missing or zero character context retrieved for actual target files.
  • The apply function indicating that changes have been made, but with no actual modification done to the expected file.

The key issues to resolve include:

  1. Correctly parsing and resolving full file paths.
  2. Ensuring accurate identification of the actual file context and excluding non-file identifiers from being treated as files.
  3. Properly applying the changes to the identified file to reflect modifications in the user's workspace.

Proposed Changes

  1. Path Resolution Logic:

    • Modify the logic responsible for resolving and listing file paths to ensure that only valid file paths are processed as files.
    • Validate file existence before context retrieval and modification to prevent non-file names from being interpreted as files.

    Relevant File:

    • Update functions related to path resolving to include checks ensuring that paths correspond to actual files.
  2. Context Collection Improvements:

    • Refine the context collection process to ensure accurate retrieval of file content and metadata relevant only to existing files.
    • Log and handle cases where no context is found due to unrecognized paths or files, provide feedback for corrective actions.

    Relevant Files:

    • Update context fetching methods in the same context.ts file to handle directory and file validation appropriately.
  3. File Modification Routine:

    • Enhance the algorithm to ensure it accurately modifies the file once identified. Ensure that the UI reflects the actual changes made.
    • Implement a sanity check step in the file modification process to verify that the intended modifications have been applied.

    Relevant Test Files:

    • Extend existing tests to cover scenarios with full file path commands.
    • Mock intended file path resolutions and confirm that the actual file is targeted for modifications.

By implementing these changes, the file path resolution will be corrected, ensuring that the correct file context is retrieved and used for code generation tasks. This should effectively resolve the issue of incorrect file path interpretation and related context errors in the Navie package.

@getappmap getappmap deleted a comment from github-actions bot Oct 13, 2024
@getappmap getappmap deleted a comment from github-actions bot Oct 13, 2024
@dividedmind
Copy link
Collaborator

I'm trying to understand this problem and I see two separate bugs here:

  1. @generate /Users/kgilpin/source/appland/appmap-js/packages/search/src/snippet-index.ts question doesn't lead to /Users/kgilpin/source/appland/appmap-js/packages/search/src/snippet-index.ts being detected as a file path (my guess is due to lack of examples with absolute paths),
  2. applying changes doesn't work with relative paths.

Is that a correct understanding?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working navie navie-plan
Projects
None yet
Development

No branches or pull requests

4 participants