Skip to content

Git inspection collapses nested untracked files and omits them from changed-only context #107

Closed

Description

@MatthiasLew

Problem

When source files are created under a new untracked directory, Git inspection reports a directory entry such as src/ rather than the individual file paths. Downstream changed-only context can consequently omit all new source code. This was reproduced while building AI Threat Lab with ai-dev-cli-tools 1.3.0, against main commit 5c9f1b7bd4677d32b1650ebd62519044072e599a.

Reproduction

  1. Initialize a Git repository.
  2. Create src/new_package/service.py containing a small Python function without staging the directory.
  3. Run ai-dev git inspect --json.
  4. Run ai-dev context build --changed-only --explain --json.

Observed: Git inspection lists src/ as an untracked/changed file; changed-only context can return no selected source files.

Expected: src/new_package/service.py is reported as an untracked/changed file and is eligible for context selection and symbol analysis.

Cause and proposed fix

src/ai_dev_tools/git/inspect.py invokes git status --porcelain=v2 --branch -z, whose default untracked mode collapses directories. Add --untracked-files=all to that same invocation. Preserve NUL-delimited paths and Git ignore rules without adding another subprocess.

Acceptance criteria

  • A nested untracked Python file is included in changed-file and context reports.
  • Paths with spaces work.
  • Git-ignored directories remain excluded.
  • Symbol analysis includes functions in new untracked source files.
  • Status inspection still uses one Git subprocess.

Existing patch and evidence

Patch preserved in PR #105 (closed in favor of this issue at the maintainer's request), commit 23b4daff33ab8d202719d9e31e108d14bedc848c.

Two new regression tests failed before the fix and passed after it. Focused Git/context suites: 30 passed. Full local suite: 733 passed, 6 skipped; coverage gate 90%; Ruff and package build passed. PR CI, Docs and CodeQL subsequently passed. The separate benchmark typing failure found during local validation is tracked independently.

This issue replaces PR #105 as the work item; no patch has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions