Skip to content

refactor: split oversized files for code clarity#63

Merged
Patel230 merged 20 commits into
mainfrom
refactor/code-clarity
Jun 19, 2026
Merged

refactor: split oversized files for code clarity#63
Patel230 merged 20 commits into
mainfrom
refactor/code-clarity

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

Summary

Code-clarity refactor of the hawk agent: split every oversized source file (>1000 LOC) into smaller, single-responsibility files. Pure mechanical extraction — no behavior, API, or public-symbol changes. All splits keep the same package, so external/import surfaces are untouched.

Files split (16 commits, one logical split each)

  • cmd/chat.go (1501) → chat_tools.go, chat_update.go
  • cmd/markdown.go (1137) → markdown_renderer.go
  • internal/engine/review/review_bot.go (1282) → review_bot_rules.go
  • internal/multiagent/agents/persona.go (1236) → persona_builtins.go
  • internal/feature/fingerprint/project.go (1450) → project_detect.go, project_conventions.go
  • internal/intelligence/repomap/depgraph.go (1329) → depgraph_build.go, depgraph_analysis.go
  • internal/intelligence/repomap/summary.go (1047) → summary_helpers.go
  • internal/intelligence/repomap/health_score.go (1030) → health_score_dimensions.go
  • internal/engine/project/project_analyzer.go (1224) → project_metrics.go, project_patterns.go, project_report.go
  • internal/engine/scaffold/scaffold.go (1182) → scaffold_builtins.go
  • internal/engine/semantic_diff.go (1105) → semantic_diff_helpers.go
  • internal/engine/code/code_explainer.go (1036) → code_explainer_helpers.go
  • internal/tool/codegen.go (1180) → codegen_builtins.go
  • internal/feature/eval/tasks_go.go (1332) → tasks_go_more.go
  • internal/codegraph/codegraph_cgo.go (1487) → codegraph_cgo_query.go (cgo-tagged)
  • internal/codegraph/algorithms_cgo.go (1050) → algorithms_cgo_more.go (cgo-tagged)

After this pass, no non-test hawk source file exceeds ~920 LOC. (Remaining >1000 LOC files are in external/ ecosystem repos — separate Go modules, out of scope — and long table-driven *_test.go files.)

Boundary check

Verified the internal/ boundary is hard: every external/ ecosystem repo is its own Go module and none import github.com/GrayCodeAI/hawk/internal/....

Test plan

  • CGO_ENABLED=1 go build ./... — clean
  • CGO_ENABLED=1 go vet ./... — clean
  • CGO_ENABLED=1 go test ./... — 107 packages ok, 0 failures
  • golangci-lint run on every touched package — 0 issues
  • pre-push hook (govulncheck + test + vet) — passed

Made with Cursor

Patel230 added 20 commits June 19, 2026 18:39
Extract the Bubble Tea event loop (Update, applyPromptArrowKey) into
chat_update.go and the tool-registry construction (essential/optional
tools, defaultRegistry) into chat_tools.go. chat.go now holds only model
construction and lifecycle, dropping from 1501 to 582 LOC.

Pure code movement; no behavior or public API changes.
@Patel230 Patel230 force-pushed the refactor/code-clarity branch from e34d623 to e3e68b2 Compare June 19, 2026 15:28
@Patel230 Patel230 merged commit abd6ed1 into main Jun 19, 2026
18 checks passed
@Patel230 Patel230 deleted the refactor/code-clarity branch June 19, 2026 17:13
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