Skip to content

Commit 1cf3c20

Browse files
Patel230Cursor Agent
andauthored
docs(repomap): package-level README, doc.go, and per-file comments (#52)
* docs(repomap): add doc.go explaining dual-package split with internal/context/repomap A go-doc compatible overview that supersedes the previous 3-line package comment on repomap.go (kept for backward compatibility). It documents: - the package's role as the deep code-analysis engine (call graph, search, quality signals, API scanning, incremental indexing) - the dual-package relationship with internal/context/repomap, which is the prompt-injection shim and shares no code with this package - the stdlib-only core (no CGO, no tree-sitter binary) - extension points: new language parsers, new smell heuristics, new HTTP framework scanners - performance and scaling notes (MaxFiles cap, in-process LRU cache, persistent IncrementalMap at .hawk/repomap-cache.json) * docs(repomap): add leading comments to Core, Static analysis, Quality signals, API surface, and Incremental files (16 files) Each comment is a 1-3 line description of what the file does, written so that 'go doc' on any file in the package produces a useful summary. Comments are deliberately concise; the deeper architecture overview lives in doc.go and README.md. Files in this commit: - Core/cache.go in-process LRU symbol cache - Core/gitignore.go composed .gitignore rule walker - Core/watcher.go fsnotify wrapper - Symbols/parser.go original regex-based Go extractor - Symbols/parser_enhanced.go AST-based Go extractor - Symbols/parser_langs.go regex extractors for non-Go languages - Symbols/treesitter.go tree-sitter-style scope-aware extractor - Symbols/patterns.go index include/exclude pattern loader - Static/callgraph.go Go caller/callee graph from go/ast - Static/depgraph.go package-level dep graph (go.mod + package.json) - Static/imports.go file-level import graph - Static/hierarchy.go project -> package -> file 3-level summary - Static/interface_extract.go exported API surface (signatures only) - Static/cochange.go git-history co-change matrix - Static/changeset.go change-set-aware working set from git diff - Static/ownership.go git + CODEOWNERS ownership map - Quality/smells.go design smell detectors - Quality/complexity.go cyclomatic complexity - Quality/health_score.go weighted health-score rollup - Quality/doclint.go doc-comment coverage - Quality/dead_code.go unreferenced declaration detector - Quality/migration_detector.go deprecated-API migration suggestions - API/api_scanner.go HTTP route scanners + OpenAPI export - Incr/incremental.go CodeIndexer interface and reindex loop - Incr/incremental_map.go persistent on-disk symbol cache * docs(repomap): add leading comments to Search, Grouping, and remaining Symbols files (18 files) Second batch of file-level leading comments, covering the Search and navigation files (BM25, PageRank, reranking, prediction, change-set context), the Grouping file (file_grouper, summary), and the remaining Symbols files (parser, parser_enhanced, parser_langs, treesitter, patterns, watcher). Each comment is intentionally short; see doc.go and README.md for the architecture overview. * docs(context/repomap): clarify that this package is the prompt-injection shim The previous package comment described what the package did but did not call out the boundary with internal/intelligence/repomap, which is the deeper analysis engine. The two packages share no code and serve different callers (this one is the context layer's narrow budgeted-map entry point; the other is the full analysis toolkit). The new comment makes the boundary explicit, points readers at the deep package for symbol-level search / quality / API features, and adds implementation notes on the PageRank pass and file-size limits. * docs(repomap): add README with architecture overview and entry-point map The README is the human-facing entry point for the package. It contains: - One-paragraph overview (what Generate does, what else lives here) - Architecture diagram (mermaid) of the file groups and their data flow - File-group table mapping every group to its files and purpose - Entry-point map listing the headline public APIs by group - Storage model (in-process LRU, persistent .hawk/repomap-cache.json, fsnotify watch protocol) - Extension points: how to add a new language parser, a new code smell, a new HTTP framework scanner - Performance characteristics and known scaling limits per subsystem - A pointer to doc.go (machine-readable) and doc_test.go (worked example), plus the cross-reference back to internal/context/repomap * docs(repomap): add worked example in doc_test.go Adds ExampleGenerate (a godoc-consumable worked example) and TestExampleGenerate_isRunnable (the actual validator for 'go test'). The example is callable but the output depends on a temp directory path that is not stable across runs, so the example function intentionally omits a '// Output:' comment. The test function is the source of truth. The example walks through the full primary use case: - create a tiny project under t.TempDir() with one Go and one Python file - call Generate with explicit Options - render the result with Format - assert the output is non-empty and contains the expected files and symbols The test is wired to the rest of the package's tests so 'go test ./internal/intelligence/repomap/...' exercises it alongside the existing test suite. * fix(docs): drop 'Package repomap:' prefix from per-file comments (group 1) go doc treats a comment that begins with 'Package <name>' as a package-level doc comment, even when it lives in a non-doc.go file. The previous per-file leading comments all started with '// Package repomap: <filename> ...' which caused go doc to dump all 30+ file comments at the package level instead of showing the doc.go overview and the per-file comments in their proper place. The fix: replace the 'Package repomap: <filename>' prefix with just '<filename>' so the comments are recognised as file-level doc comments by go doc and godoc. * fix(docs): drop 'Package repomap:' prefix from per-file comments (group 2) Second batch of the same fix, covering the Search, Grouping, and remaining Symbols files. See the prior commit for context. * fix(repomap): rename shadowed err in doc_test.go to writeErr (lint) --------- Co-authored-by: Cursor Agent <agent@cursor.sh>
1 parent 87b7e1c commit 1cf3c20

38 files changed

Lines changed: 654 additions & 8 deletions

internal/context/repomap/repomap.go

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
1-
// Package repomap builds an AST-ranked overview of a codebase within a token
2-
// budget, in the spirit of Aider's repository map.
1+
// Package repomap is the prompt-injection shim that produces a token-budgeted
2+
// repository overview for hawk's context layer. It builds an import/refer
3+
// graph over the source files in root, ranks the nodes with a PageRank
4+
// pass, and renders the highest-ranked files (and their top symbols) as a
5+
// compact text block capped at Options.Budget tokens.
36
//
4-
// It constructs a graph where files are nodes and edges are import/reference
5-
// dependencies, ranks the nodes with a PageRank-like pass, and emits a compact
6-
// textual map (file -> key symbols) constrained to a configurable token budget.
7+
// # Relationship to internal/intelligence/repomap
78
//
8-
// The package is intentionally dependency-light: Go files are parsed with
9-
// go/parser + go/ast; other languages fall back to a small regex extractor.
10-
// Only the standard library is used.
9+
// hawk ships a second package, internal/intelligence/repomap, that exposes
10+
// a much larger surface: call graphs, search, quality signals, API
11+
// scanning, incremental indexing, and so on. That package is the deep
12+
// analysis engine. THIS package is intentionally narrow: one entry point
13+
// (RepoMap), a single Graph type, a self-contained scan/rank/render
14+
// pipeline, and a stdlib-only dependency surface. The two packages share
15+
// no code; they merely share a name and a goal (a useful map of a
16+
// repository). The deep package's doc.go spells this out from the other
17+
// side of the boundary.
18+
//
19+
// Callers that need more than a budgeted text block - symbol-level
20+
// navigation, BM25 search, dead-code detection, OpenAPI export, etc. -
21+
// should import internal/intelligence/repomap directly instead of
22+
// extending this one.
23+
//
24+
// # Implementation notes
25+
//
26+
// Go files are parsed with go/parser and go/ast; other languages fall
27+
// back to a small regex extractor. Only the standard library is used.
28+
// Files larger than 1 MiB, hidden directories, and a small set of
29+
// well-known build/vendor trees are skipped during the scan. The
30+
// PageRank pass uses the standard damped iteration with dangling-mass
31+
// redistribution and exits early once the total node-to-node delta
32+
// drops below 1e-9.
1133
package repomap
1234

1335
import (
Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
# `internal/intelligence/repomap/`
2+
3+
> Deep code-analysis engine for hawk: language-aware symbol extraction,
4+
> static analysis, search, quality signals, API scanning, and incremental
5+
> indexing. Distinct from `internal/context/repomap`, which is the narrow
6+
> prompt-injection shim used by the context layer.
7+
8+
## What it does
9+
10+
`Generate(dir, opts)` walks a directory, dispatches each supported source
11+
file to a language-aware parser, and returns a `RepoMap`: a token-budgeted
12+
summary of files and their top-level symbols suitable for injection into
13+
LLM prompts. Around that core the package accumulates a large set of
14+
specialised analyses - call graph, import graph, type hierarchy, code
15+
ownership, BM25 search, cyclomatic complexity, code smells, dead-code
16+
detection, health score, doc linter, migration detector, HTTP route
17+
scanner, and an incremental file-hash cache - that all share the same
18+
parsed-symbol substrate.
19+
20+
The package is stdlib-only at its core (`go/parser`, `go/ast`, `go/token`,
21+
`encoding/*`). The only third-party dependency is `github.com/fsnotify
22+
/fsnotify` for file watching; hawk's `internal/scoring` and
23+
`internal/ui/icons` are pulled in where they are used. Tree-sitter is
24+
deliberately not required: Go is parsed with `go/ast` and other languages
25+
are handled by an enhanced regex extractor with scope tracking.
26+
27+
## Architecture
28+
29+
```mermaid
30+
flowchart TB
31+
subgraph Entry["Entry point"]
32+
REPOMAP[repomap.go<br/>Generate, RepoMap, Options]
33+
end
34+
35+
subgraph Core["Core"]
36+
CACHE[cache.go<br/>in-process LRU]
37+
WATCHER[watcher.go<br/>fsnotify wrapper]
38+
GITIGNORE[gitignore.go<br/>composed rules]
39+
PATTERNS[patterns.go<br/>include/exclude loader]
40+
end
41+
42+
subgraph Symbols["Symbols / parsing"]
43+
PARSER[parser.go<br/>regex-Go]
44+
ENHANCED[parser_enhanced.go<br/>AST-Go]
45+
LANGS[parser_langs.go<br/>regex non-Go]
46+
TS[treesitter.go<br/>scope-aware]
47+
end
48+
49+
subgraph Static["Static analysis"]
50+
CALL[callgraph.go]
51+
DEP[depgraph.go]
52+
IMP[imports.go]
53+
HIER[hierarchy.go]
54+
IFACE[interface_extract.go]
55+
COCHG[cochange.go]
56+
CHG[changeset.go]
57+
OWN[ownership.go]
58+
SHAP[shapley.go]
59+
end
60+
61+
subgraph Search["Search / navigation"]
62+
NAV[navigation.go]
63+
SEM[semantic.go]
64+
SEMSRCH[semantic_search.go]
65+
RERANK[rerank.go]
66+
PR[pagerank.go]
67+
PRED[predict.go]
68+
end
69+
70+
subgraph Quality["Quality signals"]
71+
CPLX[complexity.go]
72+
SMELL[smells.go]
73+
HEALTH[health_score.go]
74+
DOC[doclint.go]
75+
DEAD[dead_code.go]
76+
MIG[migration_detector.go]
77+
end
78+
79+
subgraph API["API surface"]
80+
SCAN[api_scanner.go]
81+
end
82+
83+
subgraph Incr["Incremental"]
84+
INCR[incremental.go]
85+
INCRM[incremental_map.go]
86+
end
87+
88+
subgraph Group["Grouping"]
89+
GROUPER[file_grouper.go]
90+
SUMMARY[summary.go]
91+
end
92+
93+
REPOMAP --> CACHE
94+
REPOMAP --> WATCHER
95+
REPOMAP --> GITIGNORE
96+
REPOMAP --> PATTERNS
97+
REPOMAP --> PARSER
98+
REPOMAP --> ENHANCED
99+
REPOMAP --> LANGS
100+
REPOMAP --> TS
101+
Static --> IMP
102+
Static --> CALL
103+
Search --> PR
104+
Search --> SEM
105+
Search --> SEMSRCH
106+
Quality --> CPLX
107+
Quality --> SMELL
108+
Quality --> HEALTH
109+
Quality --> DOC
110+
Quality --> DEAD
111+
Quality --> MIG
112+
API --> SCAN
113+
Incr --> INCR
114+
Incr --> INCRM
115+
Group --> GROUPER
116+
Group --> SUMMARY
117+
```
118+
119+
## File groups
120+
121+
| Group | Files | Purpose |
122+
|------------------------|--------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------|
123+
| **Core** | `repomap.go`, `cache.go`, `watcher.go`, `gitignore.go`, `patterns.go` | Entry point, file scanning, file watching, in-process and persistent caches |
124+
| **Symbols / parsing** | `parser.go`, `parser_enhanced.go`, `parser_langs.go`, `treesitter.go` | Language-aware symbol extraction: regex Go, AST Go, regex non-Go, scope-aware (tree-sitter-like) |
125+
| **Static analysis** | `callgraph.go`, `depgraph.go`, `imports.go`, `hierarchy.go`, `interface_extract.go`, `cochange.go`, `changeset.go`, `ownership.go`, `shapley.go` | Callers/callees, package-level deps, import graph, type hierarchy, exported surface, git-history co-change, change-set context, ownership, Shapley value ranker |
126+
| **Search / navigation**| `navigation.go`, `semantic.go`, `semantic_search.go`, `rerank.go`, `pagerank.go`, `predict.go` | LSP-free navigation index, BM25 search, PageRank ranking, reranking, relevance prediction |
127+
| **Quality signals** | `complexity.go`, `smells.go`, `health_score.go`, `doclint.go`, `dead_code.go`, `migration_detector.go` | Cyclomatic complexity, code smells, health rollup, doc linter, dead code, deprecated-API detection |
128+
| **API surface** | `api_scanner.go` | HTTP route scanners (Chi, net/http, Gin, Echo, Gorilla, Fiber) + OpenAPI export |
129+
| **Incremental** | `incremental.go`, `incremental_map.go` | `CodeIndexer` interface and reindex loop, persistent on-disk symbol cache |
130+
| **Grouping** | `file_grouper.go`, `summary.go` | File grouping, codebase summary suitable for prompt injection |
131+
132+
## Entry points
133+
134+
The full public surface is read from the source. The headline entry points
135+
are:
136+
137+
- **`Generate(dir string, opts Options) (*RepoMap, error)`** in `repomap.go` -
138+
the canonical entry point. Walks `dir`, parses every supported file,
139+
and returns a `RepoMap` with `Files` and a `TokenEst`.
140+
- **`(*RepoMap).Format(maxTokens int) string`** in `repomap.go` - renders
141+
the map as text, truncating to fit `maxTokens`.
142+
- **`BuildCallGraph(root string) (*CallGraph, error)`** in `callgraph.go` -
143+
Go-only caller/callee graph from `go/ast`.
144+
- **`BuildDepGraph` / `NewDepGraph` / `BuildFromGoMod` / `BuildFromPackageJSON`**
145+
in `depgraph.go` - Go and JS/TS dependency graphs.
146+
- **`BuildImportGraph(root string) (*ImportGraph, error)`** in `imports.go` -
147+
file-level import graph.
148+
- **`NewNavIndex` / `(*NavIndex).BuildIndex` / `(*NavIndex).GoToDefinition` /
149+
`(*NavIndex).FindReferences` / `(*NavIndex).FindImplementations`** in
150+
`navigation.go` - the LSP-free navigation API.
151+
- **`BuildSemanticIndex` / `(*SemanticIndex).Search` /
152+
`NewSemanticSearchIndex`** in `semantic.go` / `semantic_search.go` -
153+
chunked TF-IDF and BM25 search.
154+
- **`BuildSymbolGraph` / `(*SymbolGraph).TopSymbols`** in `pagerank.go` -
155+
symbol-level PageRank.
156+
- **`NewComplexityAnalyzer` / `(*ComplexityAnalyzer).FindHotspots`** in
157+
`complexity.go` - complexity hotspots.
158+
- **`NewSmellDetector` / `(*SmellDetector).ScanDirectory`** in `smells.go`
159+
- code smell detection.
160+
- **`NewHealthScorer` / `(*HealthScorer).Score` / `FormatScore` /
161+
`CompareScores`** in `health_score.go` - health score rollup and
162+
before/after diff.
163+
- **`NewDeadCodeDetector` / `(*DeadCodeDetector).Detect`** in
164+
`dead_code.go` - dead-code detection.
165+
- **`NewMigrationDetector` / `(*MigrationDetector).Scan` /
166+
`FormatOpportunities` / `AutoFix`** in `migration_detector.go` -
167+
deprecated-API migration.
168+
- **`NewAPIScanner` / `(*APIScanner).Scan` / `FormatAPIMap` /
169+
`GenerateOpenAPI`** in `api_scanner.go` - HTTP route scanner.
170+
- **`NewIncrementalMap(cacheDir string) (*IncrementalMap, error)`** in
171+
`incremental_map.go` - persistent on-disk symbol cache.
172+
- **`IncrementalReindex(dir string, ignore []string, indexer CodeIndexer)
173+
(added, skipped, removed int, err error)`** in `incremental.go` - the
174+
diff-and-reindex loop for the `CodeIndexer` interface.
175+
- **`NewFileWatcher(root string, onChange func(path string))
176+
(*FileWatcher, error)`** in `watcher.go` - fsnotify wrapper.
177+
- **`NewSummaryGenerator(projectDir string, maxTokens int)
178+
*SummaryGenerator` / `RenderForPrompt` / `RenderCompact`** in
179+
`summary.go` - the prompt-injectable codebase summary.
180+
- **`BuildHierarchy(root string) (*HierarchicalSummary, error)`** in
181+
`hierarchy.go` - 3-level project summary.
182+
- **`PredictRelevantFiles` / `NewRecentEditTracker`** in `predict.go` -
183+
relevance prediction from prompt, recent edits, import graph, and
184+
symbol map.
185+
- **`BuildCoChangeAnalysis(root string, commitLimit int)
186+
(*CoChangeAnalysis, error)`** in `cochange.go` - git-history co-change.
187+
- **`FromGitDiff` / `FromGitDiffRange`** in `changeset.go` - change-set
188+
context.
189+
- **`NewOwnershipMap` / `(*OwnershipMap).Compute`** in `ownership.go` -
190+
per-file ownership.
191+
- **`NewShapleyRanker(chunks []CodeChunk) *ShapleyRanker`** in `shapley.go`
192+
- Shapley-value chunk ranking.
193+
- **`NewAPIScanner`** in `api_scanner.go` - HTTP route scanner factory.
194+
195+
## Storage model
196+
197+
- **In-process symbol cache** (`cache.go`): an LRU keyed by
198+
`(path, modtime)` capped at `defaultMaxSymbolCacheEntries` (5000). It
199+
is consulted by `parseFileSymbols` in `repomap.go` and is cleared on
200+
process exit.
201+
- **Persistent incremental cache** (`incremental_map.go`): JSON file at
202+
`<cacheDir>/repomap-cache.json` (typically `.hawk/repomap-cache.json`)
203+
keyed by SHA-256 of file content. `IncrementalReindex` diffs the
204+
project tree against the cached hash set and re-parses only changed
205+
files.
206+
- **Watch protocol** (`watcher.go`): `NewFileWatcher(root, onChange)` walks
207+
the tree, registers every non-hidden, non-vendor directory with
208+
`fsnotify.Watcher`, and invokes `onChange(path)` on
209+
`Write`/`Create`/`Remove` events for supported source files. `Start`
210+
launches the event loop goroutine; `Stop` terminates it.
211+
212+
## Extension points
213+
214+
### Add a new language parser
215+
216+
1. Add the extension to `isSupportedExt` in `repomap.go` so the walker
217+
picks up the new files.
218+
2. Add a new case to `parseFileSymbols` in `repomap.go` that dispatches
219+
to a `parseX` function.
220+
3. Add the `parseX(src string) []Symbol` function. For most languages
221+
you can copy the `jsSpec` / `cSpec` patterns in `parser_langs.go`.
222+
4. If the language needs scope-aware extraction, add a new
223+
`TreeSitterParser` method in `treesitter.go` instead.
224+
5. Optionally wire the same extension into `detectLang` in
225+
`internal/context/repomap/scan.go` if the prompt-injection shim
226+
should also pick it up.
227+
228+
### Add a new code smell
229+
230+
1. Add a `Detector func(...) []CodeSmell` field on `SmellDetector` in
231+
`smells.go`.
232+
2. Wire the new field into `NewSmellDetector` and `ScanDirectory`.
233+
3. Tune `SmellThresholds` defaults if the new smell has tunable limits.
234+
235+
### Add a new HTTP framework scanner
236+
237+
1. Add a `ScanX(content, file string) []APIEndpoint` function in
238+
`api_scanner.go` using one of the existing scanners (e.g. `ScanChi`)
239+
as a template.
240+
2. Add the corresponding case to `DetectFramework` so the dispatcher
241+
knows to use the new scanner.
242+
3. If the new framework uses a different routing style, update
243+
`FormatAPIMap` and `GenerateOpenAPI` to handle the new metadata.
244+
245+
## Performance and scaling
246+
247+
- **`Generate`** is O(N) in the number of files with a hard cap on
248+
`Options.MaxFiles` (default 500). The walk is single-threaded; the
249+
per-file parsing is also single-threaded but the work is bounded per
250+
file.
251+
- **Symbol cache** (`cache.go`) keeps hot files in memory; it is
252+
process-local and does not survive a restart.
253+
- **IncrementalMap** (`incremental_map.go`) persists hashes and symbol
254+
lists on disk. `IncrementalReindex` only re-parses files whose SHA-256
255+
has changed. For very large repositories (tens of thousands of files)
256+
prefer the incremental path over `Generate`.
257+
- **Static-analysis passes** (`callgraph`, `depgraph`, `pagerank`,
258+
`shapley`) are O(V + E) per iteration over the symbol graph and scale
259+
linearly with the number of declarations, not the number of lines.
260+
- **BM25 search** (`semantic_search.go`) is O(Q * D) per query, where Q
261+
is the number of query terms and D is the number of indexed documents.
262+
IDF and average document length are precomputed and cached.
263+
- **Health score** (`health_score.go`) is O(F) per dimension (F = file
264+
count) and runs all dimensions in sequence; for very large projects
265+
the per-file scans are the bottleneck.
266+
- **Tree-sitter path** is not used. The "tree-sitter-style" scope-aware
267+
extractor in `treesitter.go` is a pure-Go regex implementation that
268+
avoids the CGO and binary dependencies of the real library.
269+
270+
## Relationship to `internal/context/repomap`
271+
272+
`internal/context/repomap` is a much narrower package - essentially just
273+
`RepoMap(root, budget) (string, error)`. It is the prompt-injection shim
274+
that hawk's context layer calls when it needs a budgeted overview for the
275+
system prompt. It does its own AST parsing, PageRank pass, and rendering
276+
and shares no code with this package beyond the name.
277+
278+
Callers that need more than a budgeted text block (symbol-level
279+
navigation, BM25 search, dead-code detection, OpenAPI export, etc.)
280+
should import `internal/intelligence/repomap` (this package) directly.
281+
See the comment at the top of `internal/context/repomap/repomap.go` for
282+
the other side of the boundary.
283+
284+
## See also
285+
286+
- `doc.go` - go-doc compatible package overview.
287+
- `doc_test.go` - worked example (calls `Generate` + `Format`).
288+
- `internal/context/repomap/doc.go` - the shim's perspective.

internal/intelligence/repomap/api_scanner.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// api_scanner.go discovers HTTP endpoints in a project
2+
// by detecting the framework (Chi, net/http, Gin, Echo, Gorilla mux, or
3+
// Fiber) and extracting route declarations into an APIMap. FormatAPIMap
4+
// renders the routes as text; GenerateOpenAPI produces a 3.x OpenAPI
5+
// document for the same set.
16
package repomap
27

38
import (

internal/intelligence/repomap/cache.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// cache.go implements the in-process LRU symbol cache keyed
2+
// by (path, modtime). It is consulted by parseFileSymbols before re-parsing
3+
// and is cleared on process exit; for a persistent cache, use IncrementalMap.
14
package repomap
25

36
import (

internal/intelligence/repomap/callgraph.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// callgraph.go builds a per-function caller/callee graph
2+
// from a Go tree using go/parser and go/ast. It supports bounded BFS
3+
// traversals in both directions (CallersOf, CalleesOf) and a symmetric
4+
// Neighborhood helper used by the navigation index.
15
package repomap
26

37
import (

internal/intelligence/repomap/changeset.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// changeset.go derives a focused ChangeSetContext from
2+
// a git diff (working tree or a range against a base ref). The context
3+
// lists changed files, files affected by the changes (dependents), and
4+
// files needed to understand the changes (imports), and is used to build
5+
// smaller, change-set-aware LLM prompts.
16
package repomap
27

38
import (

internal/intelligence/repomap/cochange.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// cochange.go mines the last N git commits to build a
2+
// co-occurrence matrix of files that change together, and exposes
3+
// RelatedFiles for "what else should I look at" recommendations after a
4+
// file has been touched.
15
package repomap
26

37
import (

internal/intelligence/repomap/complexity.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// complexity.go computes cyclomatic and cognitive
2+
// complexity per function (Go files via go/ast, other languages via
3+
// brace-tracking regex), aggregates a ComplexityReport per file, and
4+
// surfaces refactoring suggestions and a MaintainabilityIndex for the
5+
// health score. FindHotspots walks an entire project and returns the
6+
// highest-complexity functions first.
17
package repomap
28

39
import (

internal/intelligence/repomap/dead_code.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// dead_code.go flags top-level declarations (functions,
2+
// methods, types, vars, consts) that appear to be unreferenced. It is
3+
// deliberately conservative: declarations reachable from tests, interface
4+
// implementations, or via reflection are not flagged. FormatDeadCode
5+
// produces a human-readable summary, GenerateRemovalPlan a structured
6+
// edit script.
17
package repomap
28

39
import (

0 commit comments

Comments
 (0)