Skip to content

Refactor Gemini/Antigravity log parsing and unify indentation helpers#36568

Closed
Copilot wants to merge 3 commits into
mainfrom
copilot/refactor-semantic-function-clustering-please-work
Closed

Refactor Gemini/Antigravity log parsing and unify indentation helpers#36568
Copilot wants to merge 3 commits into
mainfrom
copilot/refactor-semantic-function-clustering-please-work

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 3, 2026

This issue identified avoidable duplication across Gemini/Antigravity engine log parsing and scattered indentation utilities. This PR consolidates the shared logic into reusable helpers while preserving existing engine behavior and call-site semantics.

  • Engine log parsing deduplication

    • Added parseSingleJSONResponseLogMetrics(...) in pkg/workflow/single_json_response_logs.go.
    • Switched both GeminiEngine.ParseLogMetrics and AntigravityEngine.ParseLogMetrics to delegate to the shared parser.
    • Removed duplicated per-engine JSON response parsing structs/logic from gemini_logs.go and antigravity_logs.go.
  • Indentation helper consolidation

    • Added stringutil.LeadingWhitespace and stringutil.IndentLines in pkg/stringutil/stringutil.go.
    • Routed duplicated indentation logic in:
      • pkg/parser/frontmatter_hash.go (indentationOf)
      • pkg/cli/codemod_network_firewall.go (removed local indentLines)
      • pkg/cli/yaml_frontmatter_utils.go (getIndentation now delegates to shared helper)
  • Focused coverage for new shared behavior

    • Added pkg/workflow/single_json_response_logs_test.go to validate equivalent Gemini/Antigravity metrics parsing.
    • Added tests for LeadingWhitespace and IndentLines in pkg/stringutil/stringutil_test.go.
// shared parser usage
func (e *GeminiEngine) ParseLogMetrics(logContent string, verbose bool) LogMetrics {
	return parseSingleJSONResponseLogMetrics(logContent, verbose, geminiLogsLog, "Gemini")
}

func (e *AntigravityEngine) ParseLogMetrics(logContent string, verbose bool) LogMetrics {
	return parseSingleJSONResponseLogMetrics(logContent, verbose, antigravityLogsLog, "Antigravity")
}

Copilot AI and others added 2 commits June 3, 2026 04:10
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor semantic function clustering in Antigravity/Gemini engine clone Refactor Gemini/Antigravity log parsing and unify indentation helpers Jun 3, 2026
Copilot AI requested a review from gh-aw-bot June 3, 2026 04:13
@pelikhan pelikhan marked this pull request as ready for review June 3, 2026 04:18
Copilot AI review requested due to automatic review settings June 3, 2026 04:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces duplication by centralizing (1) Gemini/Antigravity line-delimited JSON log metrics parsing into a shared workflow helper and (2) multiple ad-hoc indentation utilities into pkg/stringutil, while adding focused unit tests to lock in the shared behaviors.

Changes:

  • Added a shared parseSingleJSONResponseLogMetrics helper and routed both Gemini and Antigravity engines to use it.
  • Introduced stringutil.LeadingWhitespace and stringutil.IndentLines, then updated call sites to delegate to these helpers.
  • Added unit tests covering the new shared parser behavior and the new string utilities.
Show a summary per file
File Description
pkg/workflow/single_json_response_logs.go New shared parser for line-delimited single-JSON-response style engine logs.
pkg/workflow/single_json_response_logs_test.go Tests that Gemini/Antigravity metrics parsing remains equivalent after refactor.
pkg/workflow/gemini_logs.go Removes duplicated parsing logic; delegates metrics parsing to the shared helper.
pkg/workflow/antigravity_logs.go Removes duplicated parsing logic; delegates metrics parsing to the shared helper.
pkg/stringutil/stringutil.go Adds shared indentation helpers (LeadingWhitespace, IndentLines).
pkg/stringutil/stringutil_test.go Adds tests validating the new indentation helpers.
pkg/parser/frontmatter_hash.go Switches indentation calculation to use stringutil.LeadingWhitespace.
pkg/cli/yaml_frontmatter_utils.go Replaces local indentation extraction with stringutil.LeadingWhitespace.
pkg/cli/codemod_network_firewall.go Replaces local indentLines with stringutil.IndentLines.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 9/9 changed files
  • Comments generated: 2

Comment on lines 10 to 11
// Gemini CLI outputs a single JSON response when using --output-format json.
// We parse the last valid JSON line (most complete response) and aggregate stats.
Comment on lines 10 to 11
// Antigravity CLI outputs a single JSON response when using --output-format json.
// We parse the last valid JSON line (most complete response) and aggregate stats.
@pelikhan pelikhan closed this Jun 3, 2026
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.

[refactor] Semantic function clustering: Antigravity/Gemini engine clone + scattered indentation helpers

4 participants