| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Add 'crates' to IGNORE_DIRS in both the TypeScript WASM engine and the mirrored Rust native engine constant. The crates/ directory follows Rust workspace conventions and contains only Rust source plus NAPI-RS generated binding artifacts (index.js / index.d.ts). Without this exclusion the WASM engine (which does not respect .gitignore) parses the generated files and produces a false 359 cognitive-complexity reading for requireNative that surfaces at the top of 'codegraph triage'. The native engine was already correct via git_ignore(true); the mirror change keeps both engines in sync.
…s.ts McpToolContext was defined in server.ts, which imported TOOL_HANDLERS from tools/index.ts (the barrel). Every tool module imported McpToolContext back from server.ts, creating a 37-file circular dependency flagged by codegraph cycles in two consecutive architectural audits. Fix: extract McpToolContext and McpToolHandler into src/mcp/types.ts, which only depends on db/index.js (outside the MCP subtree). server.ts and all 35 tool modules now import from types.ts instead of server.ts, eliminating the cycle. server.ts re-exports McpToolContext for backward compatibility.
Greptile SummaryThis PR has two independent changes: it breaks a 37-file circular dependency in the MCP layer by extracting McpToolContext and McpToolHandler into a new src/mcp/types.ts, and it adds root-level .gitignore awareness to the WASM file-collection walker to replace the previously hard-coded crates directory exclusion.
Confidence Score: 5/5Safe to merge — the MCP refactor is a pure import-path change with no runtime behavior delta, and the gitignore feature is additive with good test coverage for the intended use case. The cycle-break is a straightforward type extraction with no logic changes; all 35 tool modules change one import path, and server.ts re-exports the type for backward compatibility. The gitignore integration correctly applies root-level patterns to both the full walk and the fast-collect path, and the five new tests cover the stated regression. No broken contracts, no data-path changes. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph Before["Before (cycle)"]
S1["server.ts"] -->|imports TOOL_HANDLERS| TI1["tools/index.ts"]
TI1 -->|imports *| T1["tools/*.ts x35"]
T1 -->|imports McpToolContext| S1
end
subgraph After["After (cycle broken)"]
MT["mcp/types.ts\n-> db/index.js only"]
S2["server.ts"] -->|import type McpToolContext| MT
S2 -->|import TOOL_HANDLERS| TI2["tools/index.ts"]
TI2 -->|re-export from| MT
TI2 -->|imports *| T2["tools/*.ts x35"]
T2 -->|import type McpToolContext| MT
end
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
subgraph Before["Before (cycle)"]
S1["server.ts"] -->|imports TOOL_HANDLERS| TI1["tools/index.ts"]
TI1 -->|imports *| T1["tools/*.ts x35"]
T1 -->|imports McpToolContext| S1
end
subgraph After["After (cycle broken)"]
MT["mcp/types.ts\n-> db/index.js only"]
S2["server.ts"] -->|import type McpToolContext| MT
S2 -->|import TOOL_HANDLERS| TI2["tools/index.ts"]
TI2 -->|re-export from| MT
TI2 -->|imports *| T2["tools/*.ts x35"]
T2 -->|import type McpToolContext| MT
end
Reviews (3): Last reviewed commit: "fix: replace crates IGNORE_DIRS entry wi..." | Re-trigger Greptile |
Sorry, something went wrong.
| // Rust workspace convention — contains only Rust source and NAPI-RS generated | ||
| // binding artifacts (index.js / index.d.ts) that produce false complexity readings. | ||
| 'crates', |
There was a problem hiding this comment.
Global crates exclusion affects all analyzed repos
IGNORE_DIRS is applied to every repository this tool scans, not just repos with a Rust workspace layout. Any user project that legitimately stores code in a directory named crates (e.g. a monorepo that groups packages under crates/) will have those files silently excluded from all graph analysis — with no warning or override option. The same hard-coded entry is added to the Rust analyzer in collect_files.rs. Consider making this opt-in (e.g. via the existing config schema) rather than a global default, or at least document the side-effect in the user-facing config docs.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed. Removed 'crates' from both IGNORE_DIRS (TS) and DEFAULT_IGNORE_DIRS (Rust). Instead, added readGitignorePatterns() to the WASM walker in helpers.ts — it reads the project root .gitignore and compiles patterns into regexes, then applies them per-file during collection. The Rust engine already excludes gitignored files via the ignore crate's git_ignore(true), so removing 'crates' from DEFAULT_IGNORE_DIRS has no behavior change there. The result: tracked source files in any user directory named 'crates/' are included; only paths explicitly gitignored (e.g. crates/codegraph-core/index.js) are excluded. Tests added in tests/builder/collect-files.test.ts verify both the happy path and the regression case.
Sorry, something went wrong.
Codegraph Impact Analysis8 functions changed → 0 callers affected across 0 files
|
Sorry, something went wrong.
Remove 'crates' from both IGNORE_DIRS (TS) and DEFAULT_IGNORE_DIRS (Rust) — a blanket directory exclusion silently breaks any user project that stores legitimate code under a directory named 'crates'. For the WASM engine, add readGitignorePatterns() to helpers.ts, which reads the project root .gitignore and compiles its patterns into regexes. The WASM file walker applies these exclusions per-file, giving it the same coarse gitignore awareness the Rust engine already gets from the ignore crate's git_ignore(true). The incremental fast-collect path in collect-files.ts is updated in parallel. The Rust DEFAULT_IGNORE_DIRS entry was redundant because the native engine already uses git_ignore(true) — removing it preserves behavior for Rust repos and stops excluding 'crates/' directories in non-Rust user projects. Add tests for readGitignorePatterns() and an end-to-end collectFiles test that verifies gitignored artifacts in crates/ are excluded while tracked source files in the same directory are preserved. Impact: 5 functions changed, 8 affected
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Test plan
Closes #1621