Skip to content

Fix #648: Wire TsconfigResolver in CLI commands#675

Open
kishansaaai wants to merge 1 commit into
repowise-dev:mainfrom
kishansaaai:fix-648-tsconfig-cli
Open

Fix #648: Wire TsconfigResolver in CLI commands#675
kishansaaai wants to merge 1 commit into
repowise-dev:mainfrom
kishansaaai:fix-648-tsconfig-cli

Conversation

@kishansaaai

@kishansaaai kishansaaai commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes the false-positive unreachable_file reports for TS/JS projects using path aliases (like @/components) in CLI commands.

The root cause was that TsconfigResolver was only being wired up during the pipeline ingestion phase. Any CLI command that rebuilt the graph in-memory without this phase (such as dead-code, health, and workspace) would fail to resolve aliases, leaving valid targets with in_degree=0.

Changes:

  • Extracted wire_tsconfig_resolver helper function in repowise.core.ingestion.tsconfig_resolver.
  • Refactored repowise/core/pipeline/phases/ingestion.py to use the shared helper.
  • Added resolver wiring calls right before graph_builder.build() in dead_code_cmd.py, health_cmd.py, and workspace_cmd.py.

Related Issues

Fixes #648

Test Plan

  • Tests pass (pytest)
  • Lint passes (ruff check .)
  • Web build passes (npm run build) (if frontend changes)

Added a dedicated regression test (test_tsconfig_cli_repro.py) that mimics the CLI command's in-memory graph rebuild with a mock @/* alias to ensure it properly connects to its target and suppresses the false unreachability finding.

Checklist

  • My code follows the project's code style
  • I have added tests for new functionality
  • All existing tests still pass
  • I have updated documentation if needed

@repowise-bot

repowise-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

✅ Health: 7.6 (unchanged)

📋 At a glance
5 hotspots touched · 3 new findings introduced · 5 co-change pairs left out · 5 files with recent fix history · 1 dead-code finding. Scoped to packages.

⚠️ Change risk: moderate (riskier than 38% of this repo's commits · raw 8.3/10)
This change's risk is driven by:

  • more lines added than baseline
  • more scattered than baseline

🩹 Review priority (files here with the most recent bug-fix history — defects cluster, so review these first)

🔎 More signals (3)

🔥 Hotspots touched (5)

  • .../commands/dead_code_cmd.py — 6 commits/90d, 2 dependents · primary owner: Raghav Chamadiya (94%)
  • .../commands/workspace_cmd.py — 13 commits/90d, 8 dependents · primary owner: Raghav Chamadiya (98%)
  • .../ingestion/tsconfig_resolver.py — 3 commits/90d, 4 dependents · primary owner: Raghav Chamadiya (97%)
2 more
  • .../health_cmd/command.py — 2 commits/90d, 1 dependents · primary owner: Raghav Chamadiya (100%)
  • .../phases/ingestion.py — 8 commits/90d, 3 dependents · primary owner: Swati Ahuja (50%)

🔗 Hidden coupling (2 files)

  • .../commands/workspace_cmd.py co-changes with these files (not in this PR):
    • docs/CLI_REFERENCE.md (7× — 🟢 routine)
    • .../init_cmd/command.py (4× — 🟢 routine)
    • docs/USER_GUIDE.md (4× — 🟢 routine)
    • .../workspace/update.py (4× — 🟢 routine)
  • .../phases/ingestion.py co-changes with .../graph/builder.py (4× — 🟢 routine) — not in this PR.

💀 Dead code (1 finding)

  • 💀 .../phases/ingestion.py _parse_one (confidence 0.65)

📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-14 18:34 UTC
Silence on a single PR with [skip repowise] in the title · Per-repo toggle on repowise.dev/settings?tab=bot

@swati510

swati510 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

The dead-code and health wirings are in place. Those are two of the three CLI commands that build a GraphBuilder, and both read include_submodules/include_nested_repos from state before the call.

The blocker is the third site. workspace_cmd.py:685 passes include_submodules=… and include_nested_repos=… to _generate_docs_for_added_repo, and that function takes neither parameter. It raises NameError and crashes repowise workspace add for every repo. The error fires before the TS-language guard, so even non-TS repos hit it. That function never resolved those flags, so calling wire_tsconfig_resolver(graph_builder, repo_path) with the defaults matches its existing behavior.

A test that invokes the workspace path would catch this. The current regression test only exercises the helper on its own. Once that's fixed and green, this is ready.

@repowise-bot repowise-bot Bot added repowise:hotspot Repowise: touches a temporal hotspot file repowise:risk-medium Repowise: change-risk elevated for this repo's history labels Jul 8, 2026
@RaghavChamadiya

Copy link
Copy Markdown
Member

Thanks for tackling this @kishansaaai. The diagnosis is spot on and the shared-helper approach is exactly right. The dead_code_cmd.py wiring is correct. But as it stands the PR does not work yet. There are three blocking issues, and GitHub already flags the branch as conflicting.

  1. The regression test can't pass.
    GraphBuilder.graph is a method, not a property (builder.py:491), and every other caller uses graph_builder.graph(). The test accesses it uncalled:

assert graph_builder.graph.has_edge(layout_path, sensor_path) # AttributeError
assert graph_builder.graph.in_degree(sensor_path) > 0

Both lines raise AttributeError: 'function' object has no attribute 'has_edge', so this test errors rather than validating the fix. Please change them to graph_builder.graph().has_edge(...) / graph_builder.graph().in_degree(...) and confirm it runs green.

  1. The health fix edits a file that no longer exists on main.
    health_cmd.py was refactored into a package on main, and health_command now lives in health_cmd/command.py. This PR patches the old monolith, which is what's causing the merge conflict. Even after resolving it, the real bug is untouched: health_cmd/command.py:197 still calls graph_builder.build() with no resolver wired. The include_submodules / include_nested_repos vars are already in scope there (command.py:172-173), so the wiring just needs to move to that line.

  2. The workspace fix raises NameError at runtime.
    _generate_docs_for_added_repo has no include_submodules or include_nested_repos in scope (not in the signature, not defined as locals), and its traverser/GraphBuilder are built without those flags. Passing them into the wire call crashes the workspace add doc-generation path for any repo, since the kwargs are evaluated before the helper's TS check runs. Simplest fix is to call wire_tsconfig_resolver(graph_builder, repo_path) and rely on the defaults, which matches how the traverser is already constructed in that function.

Minor: there's some trailing whitespace on the blank lines inside the new helper's docstring/body worth cleaning up.

For reference, I confirmed the scope is complete: dead_code, health, and workspace are the only three CLI paths that do an in-memory graph_builder.build(). update_cmd rehydrates from the DB and isn't affected.

Suggested next steps: rebase on main, move the health wiring into health_cmd/command.py, drop the two kwargs from the workspace call, and fix the test's graph() call so it actually exercises the path.

@kishansaaai kishansaaai force-pushed the fix-648-tsconfig-cli branch from eb2c555 to aed3f92 Compare July 14, 2026 18:34
@kishansaaai

kishansaaai commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Summary
This PR fixes the false-positive unreachable_file reports for TS/JS projects using path aliases (like @/components) in CLI commands.

The root cause was that TsconfigResolver was only being wired up during the pipeline ingestion phase. Any CLI command that rebuilt the graph in-memory without this phase (such as dead-code, health, and workspace) would fail to resolve aliases, leaving valid targets with in_degree=0.

Changes:

  • Extracted a wire_tsconfig_resolver helper function in repowise.core.ingestion.tsconfig_resolver.
  • Refactored repowise/core/pipeline/phases/ingestion.py to use the shared helper.
  • Added resolver wiring calls right before graph_builder.build() in dead_code_cmd.py, health_cmd/command.py (accommodating the recent monolith refactor on main), and workspace_cmd.py.

Related Issues
Fixes #648

Test Plan

  • Tests pass (pytest)
  • Lint passes (ruff check .)
  • Web build passes (npm run build) (if frontend changes)
  • Added a dedicated regression test (test_tsconfig_cli_repro.py) that mimics the CLI command's in-memory graph rebuild with a mock @/* alias to ensure it properly connects to its target and suppresses the false unreachability finding. (Updated to correctly call graph() as a method).

Checklist

  • My code follows the project's code style
  • I have added tests for new functionality
  • All existing tests still pass
  • I have updated documentation if needed

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

Labels

repowise:hotspot Repowise: touches a temporal hotspot file repowise:risk-medium Repowise: change-risk elevated for this repo's history

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] dead-code, health, and workspace CLI commands report false-positive unreachable files for TS/JS projects using @/ path aliases

3 participants