Skip to content

Refactor: consolidate duplicated code, use typed symbols, pin packages#5

Merged
phmatray merged 1 commit into
mainfrom
refactor/codebase-cleanup
Mar 7, 2026
Merged

Refactor: consolidate duplicated code, use typed symbols, pin packages#5
phmatray merged 1 commit into
mainfrom
refactor/codebase-cleanup

Conversation

@phmatray
Copy link
Copy Markdown
Contributor

@phmatray phmatray commented Mar 7, 2026

Summary

  • Consolidate glob matching: 3 duplicate wildcard implementations → single GlobMatcher utility class
  • Remove ContentDir duplication: Delete ToolUtils.GetContentDir, fix env var bypass in GetRepoOutlineTool
  • Fix double ApplyExtraExtensions: Remove redundant call in Program.cs
  • Extract IndexStore helpers: WriteJsonAtomically for atomic saves, GetSymbolContent overload accepting pre-loaded index
  • Eliminate redundant work: SearchWithScores avoids re-scoring, cached GetSymbol results avoid double lookups
  • Reduce tool boilerplate: ResolveRepoOrError and BuildMeta helpers replace repeated try/catch and meta-building patterns across 8 tools
  • Pin NuGet packages: Replace wildcards with exact versions (TreeSitter.DotNet 1.3.0, MAB.DotIgnore 3.0.2, Anthropic 12.8.0, etc.)
  • Use typed Symbol records: Replace List<Dictionary<string, JsonElement>> with List<Symbol> throughout CodeIndex, delete JsonElementHelpers.cs

Net reduction of ~270 lines. All 109 tests passing.

Test plan

  • dotnet build — 0 errors, 0 warnings
  • dotnet test — 109/109 tests passing
  • No new dependencies added

- Consolidate 3 glob/wildcard implementations into single GlobMatcher utility
- Remove ToolUtils.GetContentDir duplication, fix env var bypass in GetRepoOutlineTool
- Fix double ApplyExtraExtensions call in Program.cs
- Extract WriteJsonAtomically helper and add GetSymbolContent overload in IndexStore
- Add SearchWithScores to avoid re-scoring, cache GetSymbol results to avoid double lookup
- Extract ResolveRepoOrError and BuildMeta helpers to reduce tool boilerplate
- Pin all NuGet package versions (TreeSitter.DotNet 1.3.0, MAB.DotIgnore 3.0.2, etc.)
- Replace List<Dictionary<string, JsonElement>> with List<Symbol> throughout CodeIndex
- Delete JsonElementHelpers.cs (no longer needed with typed symbols)
- All 109 tests passing, net reduction of ~320 lines
@phmatray phmatray merged commit 1702ffe into main Mar 7, 2026
2 checks passed
@phmatray phmatray deleted the refactor/codebase-cleanup branch March 7, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant