Skip to content

refactor(internal): full idiomatic restructure with cobra CLI, typed structs, tool registry, and tests#1

Open
kilo-code-bot[bot] wants to merge 1 commit intomainfrom
session/agent_77443e77-d111-4e53-a755-9abec6443368
Open

refactor(internal): full idiomatic restructure with cobra CLI, typed structs, tool registry, and tests#1
kilo-code-bot[bot] wants to merge 1 commit intomainfrom
session/agent_77443e77-d111-4e53-a755-9abec6443368

Conversation

@kilo-code-bot
Copy link
Copy Markdown

@kilo-code-bot kilo-code-bot Bot commented Mar 30, 2026

Summary

  • Restructure from flat single-file layout to idiomatic Go package structure with cmd/, internal/ packages
  • Replace hand-rolled flag parsing with cobra CLI for 20+ commands
  • Introduce client.Client interface with context propagation, timeouts, and response size limits
  • Add typed API structs (TriageResult, Issue, PullRequest, Label, etc.) replacing map[string]any
  • Rewrite MCP server with declarative tool registry eliminating massive DRY violation
  • Fix 33 code review findings (4 Critical, 6 High, 13 Medium, 7 Low, 3 Nitpick)
  • Add unit + integration tests (28 Go files, ~40 test cases across 7 test files)

Bug Fixes

  • [Critical] Unguarded type assertion panic in printTriageMarkdown — now uses typed structs
  • [Critical] http.NewRequest error silently ignored — now checked in client/client.go
  • [Critical] No HTTP client timeout — added 30s timeout via config.Config
  • [Critical] json.Unmarshal error ignored in triage — now returns error

Security

  • URL-encode all user-supplied --owner/--repo via url.PathEscape/url.QueryEscape
  • Warn on stderr if GITEA_URL uses non-HTTPS scheme
  • io.LimitReader with configurable max response size (default 10MB)

Architecture

cmd/gitea-robot/          # Cobra CLI entry point (7 files)
internal/config/          # Config struct with timeout validation
internal/client/          # HTTP client interface (Get/Post/Patch/Delete)
internal/cmdutil/         # Shared flag helpers (RequireOwnerRepo, ReadBody)
internal/gitea/           # Typed API operations (8 files)
internal/mcp/             # MCP server with tool registry (6 files)
internal/triage/          # Markdown formatting

Test Coverage

  • internal/client/client_test.go — httptest mock server (GET/POST/PATCH/DELETE/timeout)
  • internal/gitea/gitea_test.go — httptest integration for all API operations
  • internal/triage/format_test.go — triage markdown output
  • internal/mcp/registry_test.go — MCP tool registry, arg validation
  • internal/mcp/server_test.go — JSON-RPC server integration
  • internal/cmdutil/cmdutil_test.go — flag helpers

CI/CD

  • Added go test -race ./... to both GitHub and Gitea CI workflows
  • Added set -e to Gitea release upload step
  • Added Windows builds to both release workflows
  • Fixed .gitignore to not match cmd/gitea-robot/ directory

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.

0 participants