Skip to content

feat(init): auto-populate ignore patterns from detected ecosystem#53

Merged
smochan merged 4 commits into
mainfrom
feat/auto-ignore-presets
May 30, 2026
Merged

feat(init): auto-populate ignore patterns from detected ecosystem#53
smochan merged 4 commits into
mainfrom
feat/auto-ignore-presets

Conversation

@smochan

@smochan smochan commented May 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • New `codegraph/init_presets.py` with `detect_ignore_presets()`.
  • Detects Python, Node (with React Native subtype), Go, Rust, Java (Maven + Gradle); pre-fills the matching ignore patterns.
  • Single yes/no confirms the auto list. The free-text extras prompt remains for project-specific paths.
  • Solves the "user typed y, got `ignore: [- y]`" footgun.

v0.1.2 backlog item #5.

Test plan

  • 7 unit tests in `tests/test_init_presets.py` covering each ecosystem, multi-lang dedup, malformed JSON, empty project.
  • Full suite green via pre-push hook.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown

codegraph PR review

Diff vs main · severity ≤ high

codegraph review (target: main)

Diff: +15 / -0 / ~0 nodes, +61 / -1 edges

Findings (0)

No findings.

Triggered by codegraph CI · last run

smochan added 4 commits May 30, 2026 22:36
The `unresolved_edges` count conflated two very different things:

1. External imports — `fastapi`, `os`, `react`. Static analysis without
   a venv/site-packages parse can't resolve these and isn't supposed to.
   These are expected, not errors.
2. Local-unresolved — target's root module IS in the repo but the
   specific symbol couldn't be matched (rename drift, dynamic import,
   missed binding). These are the actionable ones.

`compute_metrics` now classifies each unresolved edge by checking whether
the target's root module appears as a MODULE node's qualname-root in the
graph. New fields: `external_edges`, `unresolved_local_edges`. The
`unresolved_edges` total is kept as the sum for back-compat.

Surfaced + exposed in the markdown report and the MCP `metrics` tool.

v0.1.2 backlog item #2.
FastAPI Pydantic request-body models were being flagged dead because
the only reference to them came through a handler's parameter type
annotation, which the Python parser didn't trace.

The parser now walks each function's parameter `type` strings and the
return-type string, regex-extracts capitalized identifiers, drops
typing-scaffolding (`Optional`, `Annotated`, `Union`, ...) and FastAPI
dependency markers (`Body`, `Depends`, ...), and emits one
`CALLS` edge with `dst="unresolved::<TypeName>"` and
`metadata.via == "annotation"` per surviving name. The existing
resolver rewrites these to real `CLASS` ids when the type is in-repo,
which closes the loop for dead-code detection.

Framework-agnostic: every function with type annotations benefits, not
just route handlers. The change reuses `EdgeKind.CALLS` (rather than
introducing a new `REFERENCES` kind) because `CALLS` already flows
through the resolver and the reference-kind whitelist used by
dead-code, and Pydantic-body validation IS effectively a runtime call
into the model class.

v0.1.2 backlog item #3.
Coding agents (Claude Code, Cursor, Codex) defaulted to grep even with
polycodegraph's MCP server registered, because they had no hint that
the MCP tools existed. `codegraph init` now prompts (default yes) and
writes a `## polycodegraph` section telling the agent which MCP tool
maps to each kind of structural query.

Mirrors the `.mcp.json` behaviour: creates fresh, appends when missing,
leaves alone when the section is already there. Both CLAUDE.md and
AGENTS.md are written.

v0.1.2 backlog item #4.
The "Extra ignore patterns" free-text prompt was a footgun — a user
typed `y` thinking it was yes/no and got `ignore: [- y]` in their YAML.

Init now sniffs the repo for `pyproject.toml`, `package.json` (with
React Native detection via dependencies/devDependencies), `go.mod`,
`Cargo.toml`, `pom.xml`, `build.gradle`, and pre-fills the matching
ignore patterns. The user confirms with a single yes/no. Extras prompt
remains for project-specific paths.

New module: `codegraph/init_presets.py` with `detect_ignore_presets`.
Patterns auto + extras get de-duplicated in insertion order.

v0.1.2 backlog item #5.
@smochan smochan force-pushed the feat/auto-ignore-presets branch from b2f8783 to 26b2729 Compare May 30, 2026 17:10
@github-actions

Copy link
Copy Markdown

codegraph PR review

Diff vs main · severity ≤ high

codegraph review (target: main)

Diff: +44 / -0 / ~0 nodes, +178 / -1 edges

Findings (0)

No findings.

Triggered by codegraph CI · last run

@smochan smochan merged commit 2334969 into main May 30, 2026
5 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant