Skip to content

chore: Isolate skill file normalization from layout handling - #1617

Merged
hatayama merged 2 commits into
v3-betafrom
refactor/hatayama/extract-skill-content-normalization
Jul 8, 2026
Merged

hatayama merged 2 commits into
v3-betafrom
refactor/hatayama/extract-skill-content-normalization

Conversation

@hatayama

@hatayama hatayama commented Jul 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Skill file line-ending and encoding normalization now has a focused owner instead of living inside layout detection.
  • Existing generated skill content remains byte-compatible.

User Impact

  • There is no intended behavior change. Generated skill copies continue to normalize supported text files to LF while preserving UTF-16 endianness, BOMs, non-text files, and binary content.
  • The smaller layout class makes future skill setup maintenance easier to review without mixing byte-encoding logic into directory layout rules.

Changes

  • Added focused characterization coverage before moving production code.
  • Extracted the text extension allowlist, UTF-16 detection, and byte-level normalization helpers into SkillFileContentNormalizer without changing their logic or names.
  • Updated both production callers and the focused test fixture to reference the extracted class directly.
  • Removed the old entry point from SkillInstallLayout instead of leaving a compatibility wrapper.
  • Reduced SkillInstallLayout from 571 lines to 397 lines.

Verification

  • Characterization tests were Green before and after extraction.
  • Repo-local Unity compile: 0 errors, 0 warnings.
  • SkillFileContentNormalizerTests: 6 passed.
  • SkillInstallLayoutTests: 18 passed.
  • ToolSkillSynchronizerTests: 52 passed.
  • git diff --check.

Compatibility

  • Source discovery behavior, generated byte content, and wire formats are unchanged, so no protocol version bump is required.

Deferred Review Finding

  • cubic identified a pre-existing UTF-16BE ambiguity where the little-endian line-ending heuristic runs before the explicit BE BOM check. The same ordering existed before this move-only extraction, so it is recorded as R2-28 for a separate Red-first bug-fix PR rather than mixing behavior changes into this refactor.

hatayama added 2 commits July 8, 2026 21:59
Move the existing UTF-16 little-endian coverage into a focused fixture and characterize the remaining byte-normalization branches before extracting them from SkillInstallLayout.

Cover single-byte carriage returns, UTF-16 big-endian content, non-text extensions, NUL-containing binary data, and the LF-only fast path without constraining allocation behavior.
Move text-extension policy, UTF-16 detection, and byte-level line-ending normalization from SkillInstallLayout into a focused SkillFileContentNormalizer.

Update the two production callers and focused tests to reference the extracted class directly, leaving no compatibility wrapper or behavior change.
@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR extracts skill file line-ending normalization logic into a new SkillFileContentNormalizer class, handling both single-byte and UTF-16 (LE/BE with BOM) text normalization. SkillInstallLayout is updated to delegate to this new class instead of its previous inline implementation, and tests are relocated/added accordingly.

Changes

Skill file content normalizer extraction

Layer / File(s) Summary
Normalizer contract and gating logic
Packages/src/Editor/Infrastructure/SkillSetup/SkillFileContentNormalizer.cs
New class defines UTF-16 BOM/encoding constants, a text extension allowlist, and NormalizeSkillFileContent entry point that routes normalization based on extension and content markers.
Single-byte and UTF-16 normalization implementation
Packages/src/Editor/Infrastructure/SkillSetup/SkillFileContentNormalizer.cs
Implements CR/CRLF→LF conversion for single-byte text and UTF-16 code-unit-level normalization preserving BOM and endianness, plus byte read/write helpers.
SkillInstallLayout delegation
Packages/src/Editor/Infrastructure/SkillSetup/SkillInstallLayout.cs
Removes inline UTF/BOM constants and text extension filter; installed and source skill file collection now call SkillFileContentNormalizer.NormalizeSkillFileContent.
Test coverage relocation
Assets/Tests/Editor/SkillFileContentNormalizerTests.cs, Assets/Tests/Editor/SkillInstallLayoutTests.cs
Adds six new tests covering encodings, line endings, and gating rules for the normalizer; removes the redundant UTF-16LE test and unused using directive from the layout test file.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • hatayama/unity-cli-loop#1039: Both PRs implement/consume deterministic skill text line-ending normalization.
  • hatayama/unity-cli-loop#1588: Both PRs relate to skill file content normalization (PowerShell UTF-16LE/line-ending handling) and its test verification in SkillInstallLayout.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the refactor: isolating skill file normalization from layout handling.
Description check ✅ Passed The description is directly about the same extraction, behavior preservation, and test updates in this changeset.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/hatayama/extract-skill-content-normalization

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 6 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@hatayama
hatayama merged commit ed9aed0 into v3-beta Jul 8, 2026
10 checks passed
@hatayama
hatayama deleted the refactor/hatayama/extract-skill-content-normalization branch July 8, 2026 13:15
RyanXie123 pushed a commit to RyanXie123/unity-cli-loop that referenced this pull request Sep 22, 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.

1 participant