Skip to content

feat(cli): add --report flag for structured JSON export reports - #66

Merged
alexey1312 merged 3 commits into
mainfrom
feat/export-report
Feb 25, 2026
Merged

feat(cli): add --report flag for structured JSON export reports#66
alexey1312 merged 3 commits into
mainfrom
feat/export-report

Conversation

@alexey1312

@alexey1312 alexey1312 commented Feb 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add --report <path> option to all single export commands (colors, icons, images, typography) for structured JSON reports
  • New ExportReport struct with version, timing, stats, warnings, and asset manifest — replaces fragile regex parsing in exfig-action
  • WarningCollector actor captures warnings during export; ManifestTracker tracks file writes with FNV-1a checksums and action detection (created/modified/unchanged/deleted)
  • Report written even on export failure (success: false); report write failure is non-fatal

Test plan

  • 32 unit + integration tests covering ExportReport serialization, WarningCollector, ManifestTracker (created/modified/unchanged), AssetManifest JSON, deleted file detection, and integration scenarios
  • Build passes (swift build)
  • Lint passes (swiftlint --strict)
  • Format passes (swiftformat --lint)
  • Manual test: exfig colors -i exfig.pkl --report results.json produces valid JSON
  • CI passes on macOS + Linux

🤖 Generated with Claude Code

Single export commands (colors, icons, images, typography) now support
`--report <path>` to write a structured JSON report with timing, stats,
warnings, and asset manifest — replacing fragile regex parsing in
exfig-action.

- ExportReport struct with version, timing, stats, warnings, manifest
- WarningCollector actor to capture warnings during export
- ManifestTracker with file action detection (created/modified/unchanged/deleted)
- FNV-1a content checksums via existing FNV1aHasher
- Report written even on export failure (success: false)
- Report write failure is non-fatal (logs warning, doesn't fail export)
- 32 unit + integration tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @alexey1312, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the command-line interface (CLI) by introducing a robust reporting mechanism for single asset export commands. It provides users with structured JSON reports containing comprehensive details about each export, including execution metrics, warnings, and a detailed manifest of all affected files. This new capability streamlines integration with automated workflows and external tools by offering a reliable, machine-readable output of export results and file changes.

Highlights

  • Structured JSON Reports: Introduced a --report <path> flag for single export commands (colors, icons, images, typography) to generate structured JSON reports containing comprehensive export details.
  • ExportReport Structure: Implemented a new ExportReport struct to encapsulate export metadata, including version, timing, success status, error messages, asset statistics, collected warnings, and an optional asset manifest.
  • Warning Collection: Developed a WarningCollector actor to centralize the collection of warnings emitted during export processes, ensuring all warnings are captured in the report.
  • File Change Tracking: Created a ManifestTracker actor to monitor file write operations, classifying changes as created, modified, unchanged, or deleted using FNV-1a checksums and comparison with previous reports.
  • Robust Reporting: Ensured that a report is generated even if the export process fails, providing success: false and error details. Additionally, failures in writing the report itself are non-fatal, logging a warning without halting the export command.
Changelog
  • Sources/ExFigCLI/Output/FileWriter.swift
    • Integrated ManifestTracker to record file write and copy operations, including action type and checksums.
  • Sources/ExFigCLI/Report/AssetManifest.swift
    • Added AssetManifest struct to represent a collection of ManifestEntry objects.
    • Defined ManifestEntry struct to detail individual file changes, including path, action, checksum, and asset type.
    • Introduced FileAction enum (created, modified, unchanged, deleted) to classify file operations.
  • Sources/ExFigCLI/Report/ExportReport.swift
    • Added ExportReport struct for structured JSON output, including fields for version, command, config, timing, success status, error, stats, warnings, and an optional AssetManifest.
    • Defined ReportStats struct for asset counts.
  • Sources/ExFigCLI/Report/ExportReportWriter.swift
    • Added writeExportReport function to handle writing the ExportReport to disk, with error handling to prevent export failure.
  • Sources/ExFigCLI/Report/ManifestTracker.swift
    • Added ManifestTracker actor to manage the collection of ManifestEntry data, determine file actions, and build the final AssetManifest, including detection of deleted files by comparing against previous reports.
    • Introduced ManifestTrackerStorage for global access to the active tracker.
  • Sources/ExFigCLI/Report/WarningCollector.swift
    • Added WarningCollector actor to accumulate warning messages during an export.
    • Introduced WarningCollectorStorage for global access to the active collector.
  • Sources/ExFigCLI/Subcommands/ExportColors.swift
    • Added a --report option to the subcommand.
    • Modified run() method to initialize WarningCollector and ManifestTracker if --report is used.
    • Wrapped export logic in do-catch blocks to capture success/failure and timing.
    • Constructed and wrote ExportReport after export completion, incorporating collected warnings and manifest data.
    • Ensured WarningCollector and ManifestTracker are cleared after use.
  • Sources/ExFigCLI/Subcommands/ExportIcons.swift
    • Added a --report option to the subcommand.
    • Modified run() method to initialize WarningCollector and ManifestTracker if --report is used.
    • Wrapped export logic in do-catch blocks to capture success/failure and timing.
    • Constructed and wrote ExportReport after export completion, incorporating collected warnings and manifest data.
    • Ensured WarningCollector and ManifestTracker are cleared after use.
  • Sources/ExFigCLI/Subcommands/ExportImages.swift
    • Added a --report option to the subcommand.
    • Modified run() method to initialize WarningCollector and ManifestTracker if --report is used.
    • Wrapped export logic in do-catch blocks to capture success/failure and timing.
    • Constructed and wrote ExportReport after export completion, incorporating collected warnings and manifest data.
    • Ensured WarningCollector and ManifestTracker are cleared after use.
  • Sources/ExFigCLI/Subcommands/ExportTypography.swift
    • Added a --report option to the subcommand.
    • Modified run() method to initialize WarningCollector and ManifestTracker if --report is used.
    • Wrapped export logic in do-catch blocks to capture success/failure and timing.
    • Constructed and wrote ExportReport after export completion, incorporating collected warnings and manifest data.
    • Ensured WarningCollector and ManifestTracker are cleared after use.
  • Sources/ExFigCLI/TerminalUI/TerminalUI.swift
    • Modified the warning method to forward messages to the active WarningCollector when present.
  • Tests/ExFigTests/Report/DeletedFileDetectionTests.swift
    • Added tests for detecting deleted files in the manifest.
  • Tests/ExFigTests/Report/ExportReportIntegrationTests.swift
    • Added integration tests for ExportReport functionality, covering valid JSON output, failure reporting, non-fatal report write failures, and empty manifests.
  • Tests/ExFigTests/Report/ExportReportTests.swift
    • Added unit tests for ExportReport JSON serialization, including success, failure, warnings, and manifest inclusion.
  • Tests/ExFigTests/Report/ManifestTrackerTests.swift
    • Added unit tests for ManifestTracker to verify file action detection (created, modified, unchanged), checksum consistency, and manifest building.
  • Tests/ExFigTests/Report/WarningCollectorTests.swift
    • Added unit tests for WarningCollector to verify warning collection and retrieval.
  • openspec/changes/archive/2026-02-24-export-report/.openspec.yaml
    • Renamed the OpenSpec configuration file to an archive path.
  • openspec/changes/archive/2026-02-24-export-report/design.md
    • Renamed the design document to an archive path.
  • openspec/changes/archive/2026-02-24-export-report/proposal.md
    • Renamed the proposal document to an archive path.
  • openspec/changes/archive/2026-02-24-export-report/specs/export-report/spec.md
    • Renamed the specification document to an archive path.
  • openspec/changes/archive/2026-02-24-export-report/tasks.md
    • Renamed the tasks document to an archive path and marked all tasks as completed.
  • openspec/specs/export-report/spec.md
    • Added a new, finalized specification document for the export report capability.
Activity
  • The author, alexey1312, initiated this pull request to introduce a --report flag for structured JSON export reports in the CLI.
  • New Swift files for AssetManifest, ExportReport, ExportReportWriter, ManifestTracker, and WarningCollector were added to support the reporting feature.
  • Existing CLI subcommand files (ExportColors.swift, ExportIcons.swift, ExportImages.swift, ExportTypography.swift) were updated to integrate the new reporting logic and --report flag.
  • The TerminalUI.swift file was modified to funnel warnings into the new WarningCollector.
  • A comprehensive suite of unit and integration tests has been added for the new reporting components, covering various scenarios including file action detection, report serialization, and error handling.
  • The original OpenSpec documents related to this feature have been archived, and a new, finalized specification document has been added.
  • According to the PR description, unit and integration tests are covered, build, lint, and format checks pass. Manual testing and CI checks are still pending.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

The pull request introduces a new --report flag to single export commands, enabling structured JSON reports for better integration with CI/CD pipelines and tools like exfig-action. The changes include new structs for ExportReport, AssetManifest, ManifestEntry, and FileAction, along with WarningCollector and ManifestTracker to gather warnings and track file operations. The implementation correctly integrates these components into the export workflow, ensuring reports are generated even on failure and that file actions (created, modified, unchanged, deleted) and checksums are accurately recorded. Unit and integration tests cover the new functionality thoroughly. The changes align well with the project's existing patterns for batch reporting and error handling.

Comment thread Sources/ExFigCLI/Output/FileWriter.swift Outdated
Comment thread Sources/ExFigCLI/TerminalUI/TerminalUI.swift Outdated
alexey1312 and others added 2 commits February 24, 2026 10:43
Fix TOCTOU race in capturePreState, extract duplicated determineAction
logic, add diagnostics for nil checksums and decode failures, create
parent directories before report write, improve error descriptions for
non-LocalizedError types, and add ReportStats factory methods.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@alexey1312
alexey1312 merged commit 8649fae into main Feb 25, 2026
3 checks passed
@alexey1312
alexey1312 deleted the feat/export-report branch February 25, 2026 05:00
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