Skip to content

tool: add pack package for merging scattered config files - #2710

Merged
xushiwei merged 5 commits into
mainfrom
xgopilot/issue-2709-1775954715
Apr 12, 2026
Merged

xushiwei merged 5 commits into
mainfrom
xgopilot/issue-2709-1775954715

Conversation

@fennoai

@fennoai fennoai Bot commented Apr 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Implements core Pack functionality for the xgo pack command (Proposal: xgo pack Command #2709)
  • Discovers index.* config files in a directory tree, groups them by pack root, merges children using directory-relative path segments, and writes consolidated index_pack.* output
  • Supports JSON and YAML formats with collision detection, format mismatch validation, test mode (PackFlagTest) for CI verification, and deterministic output

Test plan

  • TestPackBasicSPXLayout — verifies the SPX example from the proposal
  • TestPackTestMode — test mode detects missing/stale pack files
  • TestPackNoConfigFiles — handles empty directory gracefully
  • TestPackMultipleConfigFormats — detects multiple formats in same dir
  • TestPackCollisionDetection — detects non-object collision at intermediate path
  • TestPackKeyCollisionAtLeaf — detects key collision at leaf level
  • TestPackDeterminism — output is deterministic across runs
  • TestPackMultipleRoots — handles multiple independent pack roots
  • TestPackDeeplyNested — handles deeply nested directory structures
  • TestPackSkipsSubdirsWithoutConfig — skips asset-only subdirectories
  • TestPackYAML — YAML format support
  • TestPackFormatMismatch — detects root/child format mismatch

Implement core Pack functionality for the `xgo pack` command (issue #2709).
The package discovers index.* config files in a directory tree, groups them
by pack root, merges children into the root using directory-relative paths,
and writes consolidated index_pack.* output files.

Supports JSON, YAML formats with collision detection, format mismatch
validation, test mode (-t) for CI verification, and deterministic output.
@fennoai fennoai Bot mentioned this pull request Apr 12, 2026
@codecov

codecov Bot commented Apr 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.12%. Comparing base (799f9a9) to head (acdce7f).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2710   +/-   ##
=======================================
  Coverage   94.12%   94.12%           
=======================================
  Files          32       32           
  Lines       10054    10054           
=======================================
  Hits         9463     9463           
  Misses        421      421           
  Partials      170      170           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review Summary

Well-structured Go code with clear separation of concerns, good error messages, and comprehensive test coverage. The implementation is clean and idiomatic. A few items worth addressing:

Key findings:

  • groupByPackRoot doc claims "nearest ancestor root" but implementation assigns to the shallowest (first) ancestor — behavior mismatch for nested pack roots
  • Unnecessary loop variable capture (f := f) given Go 1.24
  • Misleading "fatal error" terminology in godoc comments
  • Unchecked os.WriteFile errors in YAML test helpers
  • Minor inconsistencies in error message prefixes

Comment thread tool/pack.go
Comment thread tool/pack.go Outdated
Comment thread tool/pack.go
Comment thread tool/pack.go Outdated
Comment thread tool/pack_test.go
Comment thread tool/pack_test.go
xushiwei and others added 3 commits April 12, 2026 11:00
Co-authored-by: xgopilot[bot] <231223108+xgopilot[bot]@users.noreply.github.com>
Comment thread tool/pack_test.go
Thread the root directory through the pack call chain and use
filepath.Rel to produce root-relative paths in all error messages.
This makes err.Error() values deterministic and verifiable in tests.
Update error-checking tests to assert exact error strings.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: xushiwei <396972+xushiwei@users.noreply.github.com>
@xushiwei
xushiwei merged commit c2e7959 into main Apr 12, 2026
11 checks passed
@xushiwei
xushiwei deleted the xgopilot/issue-2709-1775954715 branch April 12, 2026 03:39
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