Skip to content

Minify JSON on read and pretty-print on write in init local ops#396

Merged
MathurAditya724 merged 3 commits intomainfrom
fix/adi/read-file
Mar 11, 2026
Merged

Minify JSON on read and pretty-print on write in init local ops#396
MathurAditya724 merged 3 commits intomainfrom
fix/adi/read-file

Conversation

@MathurAditya724
Copy link
Copy Markdown
Member

@MathurAditya724 MathurAditya724 commented Mar 11, 2026

Summary

  • read-files: Minifies .json file contents via JSON.stringify() to strip unnecessary whitespace before sending to the remote wizard workflow. Falls back to raw content if parsing fails (truncated files, JSONC, etc.).
  • apply-patchset: Pretty-prints .json files when writing back to disk, restoring readable indentation that was lost during minification. For modify actions, the existing file's indentation style (tabs vs spaces, indent width) is detected and preserved. For create actions, a default of 2-space indentation is used.

Implementation details

  • Indenter constant with SPACE and TAB whitespace characters
  • JsonIndent type with replacer and length fields for structured indent description
  • detectJsonIndent() inspects the first indented line of existing file content to determine the indent style
  • prettyPrintJson() re-serializes JSON with the detected (or default) indentation, with safe fallback if parsing fails
  • resolvePatchContent() extracted from applyPatchset to keep complexity under the lint threshold

Parse and re-serialize .json file contents via JSON.stringify to strip
unnecessary whitespace and formatting before sending to the remote
wizard workflow. Falls back to raw content if parsing fails (truncated
files, JSONC, etc.).
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 11, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Init

  • Enforce canonical feature display order by betegon in #388
  • Accept multiple delimiter formats for --features flag by betegon in #386
  • Add git safety checks before wizard modifies files by betegon in #379
  • Add experimental warning before wizard runs by betegon in #378
  • Add init command for guided Sentry project setup by betegon in #283

Other

  • (issue-list) Redesign table to match Sentry web UI by BYK in #372
  • Add --dry-run flag to mutating commands by BYK in #387
  • Return-based output with OutputConfig on buildCommand by BYK in #380
  • Add --fields flag for context-window-friendly JSON output by BYK in #373
  • Magic @ selectors (@latest, @most_frequent) for issue commands by BYK in #371
  • Input hardening against agent hallucinations by BYK in #370
  • Add response caching for read-only API calls by BYK in #330

Bug Fixes 🐛

Init

  • Remove implementation detail from help text by betegon in #385
  • Truncate uncommitted file list to first 5 entries by MathurAditya724 in #381

Other

  • (api) Convert --data to query params for GET requests by BYK in #383
  • (docs) Remove double borders and fix column alignment on landing page tables by betegon in #369
  • Add trace ID validation to trace view + UUID dash-stripping by BYK in #375

Internal Changes 🔧

Init

  • Remove --force flag by betegon in #377
  • Remove dead determine-pm step label by betegon in #374

Other

  • Convert remaining Tier 1 commands to return-based output by BYK in #382
  • Converge Tier 1 commands to writeOutput helper by BYK in #376

Other

  • Minify JSON on read and pretty-print on write in init local ops by MathurAditya724 in #396

🤖 This preview updates automatically when you update the PR.

@MathurAditya724 MathurAditya724 requested a review from betegon March 11, 2026 18:18
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 11, 2026

Codecov Results 📊

104 passed | Total: 104 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 900 uncovered lines.
✅ Project coverage is 95.5%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    95.50%    95.50%        —%
==========================================
  Files          142       142         —
  Lines        19999     20021       +22
  Branches         0         0         —
==========================================
+ Hits         19100     19121       +21
- Misses         899       900        +1
- Partials         0         0         —

Generated by Codecov Action

Since read-files minifies JSON before sending to the remote workflow,
the patchset content comes back without formatting. This restores
readable indentation when writing JSON files back to disk.

For modify actions, the existing file's indentation style (tabs vs
spaces, indent width) is detected and preserved. For create actions,
a default of 2-space indentation is used. Falls back to raw content
if JSON parsing fails.
@MathurAditya724 MathurAditya724 changed the title Minify JSON files in read-files local op Minify JSON on read and pretty-print on write in init local ops Mar 11, 2026
Instead of passing path, patch content, and action as separate args,
pass the whole patch object and let the function destructure what it
needs.
@MathurAditya724 MathurAditya724 merged commit 5cf9324 into main Mar 11, 2026
21 checks passed
@MathurAditya724 MathurAditya724 deleted the fix/adi/read-file branch March 11, 2026 18:43
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.

2 participants