Skip to content

init scanner: Python directory-selection edge cases (root entrypoints, env-only repos) #173

@skakri

Description

@skakri

Follow-ups from Codex review on #167, after the index walker floors venv/site-packages (FLOOR_DIRS) — so the danger (indexing installed deps) is resolved; these are init-UX completeness refinements:

  1. Root-level entrypoints omitted when a package dir exists. A repo with both root manage.py/main.py AND a package dir: the package dir is the natural default, so the fallback never promotes ., and directly_contains_source returns false for . — so init -y writes only the package binding and omits the root entrypoints. Want: include the repo root (or root .py files) when it directly contains Python source alongside a package dir.

  2. env-only repos still get python = ["."]. When the only .py files are under env//.env/, add_file_to_dir_counts increments the aggregate . candidate, which the fallback promotes (. isn't a dependency-named path). Now SAFE — the walker floors site-packages/.venv/venv/__pycache__, so python=["."] won't ingest the deps — but cosmetically the binding is broader than ideal. Want: don't promote . when its only Python files live under a dependency tree.

Both are in crates/rag-rat-cli/src/init/scan.rs (default_dir / candidate_dirs fallback / directly_contains_source). Deferred from #167 to keep the language PR focused; the walker floor + the fallback dependency-dir filter already shipped there cover the safety-critical part.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions