Skip to content

Split add_package_manifest.go into focused files - #54030

Merged
pelikhan merged 6 commits into
mainfrom
copilot/file-diet-refactor-add-package-manifest
Aug 20, 2026
Merged

Split add_package_manifest.go into focused files#54030
pelikhan merged 6 commits into
mainfrom
copilot/file-diet-refactor-add-package-manifest

Conversation

CopilotAI commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

pkg/cli/add_package_manifest.go had grown to 1330 lines, mixing manifest resolution, parsing/validation, include-path extraction, skill/agent-file resolution, and remote-fetch helpers in one file — the largest non-test Go source file in the repo.

Changes

  • Split the file into 6 focused files, each owning a single responsibility:
    • add_package_manifest.go (123 lines) — shared types, error sentinels, test-stub indirection vars
    • add_package_manifest_resolve.go (188 lines) — top-level orchestration of resolving a remote package
    • add_package_manifest_parse.go (227 lines) — manifest YAML parsing & validation
    • add_package_manifest_includes.go (464 lines) — includes/files field parsing & normalization
    • add_package_manifest_skills.go (225 lines) — skill/agent file discovery
    • add_package_manifest_remote.go (177 lines) — GitHub remote-fetch wrappers & repo-spec parsing
  • No logic changes — code was moved verbatim, with per-file import blocks resolved and doc comments re-attached where split boundaries separated a comment from its declaration.
  • Added a module-boundary comment atop each file describing its responsibility, to aid future navigation.
  • Existing tests (add_package_manifest_test.go, add_package_manifest_mapping_test.go) remain unchanged in place, since they're already organized by scenario rather than by source file and continue to exercise the same package.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 29.9 AIC · ⌖ 8.24 AIC · ⊞ 9.3K ·
Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
CopilotAI changed the title [WIP] Refactor pkg/cli/add_package_manifest.go into smaller filesSplit add_package_manifest.go into focused filesAug 19, 2026
CopilotAI requested a review from pelikhanAugust 19, 2026 15:09
@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

Category: refactor · Risk: medium · Score: 40/100 (impact 20 + urgency 10 + quality 10)
Recommended action:defer

Large draft refactor (2.5K line diff); needs undraft, CI, and careful review before merge.

Automated triage — see run report for full details.

Generated by 🔧 PR Triage Agent · auto · 90.2 AIC · ⌖ 2.82 AIC · ⊞ 8.3K ·

@pelikhan
pelikhan marked this pull request as ready for review August 20, 2026 00:26
CopilotAI balanced review requested due to automatic review settings August 20, 2026 00:26
@github-actions

github-actionsBot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actionsBot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actionsBot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actionsBot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actionsBot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Lean already. Ship.

This PR is a pure mechanical file split: pkg/cli/add_package_manifest.go was split verbatim into 5 new files, each carrying only a module-boundary doc comment describing its single responsibility. No new abstractions, reinvented stdlib, or speculative flexibility were introduced, and no logic changed. Nothing to cut per ponytail-review scope.

Generated by Ponytail Reviewer for #54030

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-08-20T00:00:00Z
review_event: COMMENT
top_themes:
- refactor-only split with no changed behavior found
files_reviewed:
- pkg/cli/add_package_manifest.go
- pkg/cli/add_package_manifest_includes.go
- pkg/cli/add_package_manifest_parse.go
- pkg/cli/add_package_manifest_remote.go
- pkg/cli/add_package_manifest_resolve.go
- pkg/cli/add_package_manifest_skills.go
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 6.32 AIC · ⌖ 7.91 AIC · ⊞ 7K ·
Comment /review to run again

@github-actionsgithub-actionsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict

This looks like a straight file split of add_package_manifest.go into smaller units. I did not find an actionable correctness, performance, or maintainability regression in the changed lines.

Review notes
  • The moved functions appear byte-for-byte equivalent in behavior.
  • Imports and helper ownership still line up with their callers.
  • I did not see any changed control flow, validation rules, or error handling semantics in the extracted files.
  • The background grumpy-coder sub-agent did not return usable output before adjudication, so this review is based on independent analysis only.

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 6.32 AIC · ⌖ 7.91 AIC · ⊞ 7K
Comment /review to run again

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Splits repository-package manifest support into focused Go files while preserving behavior and existing test coverage.

Changes:

  • Separates resolution, parsing, includes, skills, and remote operations.
  • Retains shared types and test indirections centrally.
  • Adds file-level responsibility comments.
Show a summary per file
FileDescription
pkg/cli/add_package_manifest.goRetains shared types, constants, and stubs.
pkg/cli/add_package_manifest_resolve.goHandles package-resolution orchestration.
pkg/cli/add_package_manifest_parse.goHandles manifest parsing and validation.
pkg/cli/add_package_manifest_includes.goHandles include extraction and normalization.
pkg/cli/add_package_manifest_skills.goHandles skill, agent, and file discovery.
pkg/cli/add_package_manifest_remote.goHandles repository parsing and remote operations.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment threadpkg/cli/add_package_manifest.go
@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

  • Category: refactor
  • Risk: medium
  • Priority score: 42 / 100 (impact 20 + urgency 10 + quality 12)
  • Recommended action:defer

Draft PR, pure code-organization split. CI unstable. No urgency; revisit once undrafted.

Automated triage by PR Triage Agent.

Generated by 🔧 PR Triage Agent · auto · 57.1 AIC · ⌖ 2.88 AIC · ⊞ 8.3K ·

@github-actionsgithub-actionsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean, pure-refactoring split. The extracted code in add_package_manifest_includes.go is byte-for-byte identical to what was removed from add_package_manifest.go — no behavioural changes. The file-header comment is accurate and import lists are correct. LGTM.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 28.1 AIC · ⌖ 8.77 AIC · ⊞ 5.7K

@github-actionsgithub-actionsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /codebase-design — commenting on two minor module-boundary issues. No logic was changed; the split is clean overall.

📋 Key Themes & Highlights

Key Themes

  • Utility placement: stringValue (a general helper) lives in _remote.go but is called from _includes.go and _parse.go. Moving it to the shared-types file (add_package_manifest.go) clarifies its package-wide scope.
  • Domain boundary: extractManifestSkillDirs / extractManifestAgentFiles and their supporting predicates are in _includes.go but belong to the skills/agents domain. They could move to _skills.go to sharpen each file's single responsibility.

Positive Highlights

  • ✅ Excellent module-boundary comments atop each file — they make the split immediately navigable.
  • ✅ Shared error sentinels and test-stub indirection vars correctly concentrated in add_package_manifest.go.
  • ✅ No logic changes — verbatim move confirmed by the diff; existing test suite continues to exercise all paths.
  • ✅ The _resolve.go orchestration layer is noticeably cleaner to read after the extraction.
  • _remote.go thin-wrapper pattern is well executed; the For/ForHost variants show consistent naming.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 58.1 AIC · ⌖ 10.1 AIC · ⊞ 7.8K
Comment /matt to run again

return filepath.ToSlash(filepath.Join(packagePath, relativePath))
}

func stringValue(value any) (string, bool) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/codebase-design]stringValue is a generic type-assertion helper, not a remote-fetch concern — placing it in _remote.go creates a hidden cross-file dependency for _includes.go and _parse.go which call it widely.

💡 Suggestion

Move stringValue to add_package_manifest.go (the shared-types file), whose module comment explicitly describes it as home for "shared types ... used by the other files below."

// stringValue extracts a string from an untyped any value.funcstringValue(valueany) (string, bool) {
s, ok:=value.(string)
returns, ok
}

This makes its package-wide scope immediately apparent to any reader of _includes.go or _parse.go.

@copilot please address this.

// extractManifestSkillDirs parses the skills array from an aw.yml manifest, validating
// and normalizing each entry. Each entry must be a path under skills/ that represents
// the directory for a skill (e.g. "skills/my-skill").
func extractManifestSkillDirs(value any, manifestPath string) ([]string, []string) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/codebase-design]extractManifestSkillDirs and extractManifestAgentFiles live in _includes.go but belong to the skill/agent domain. They parse skills: and agents: manifest keys — and are called from _parse.go — not the includes: field. Placing them here blurs the file's single-responsibility boundary.

💡 Suggestion

Move extractManifestSkillDirs and extractManifestAgentFiles (and the supporting predicates isSupportedSkillDirPath, isSupportedAgentFilePath, etc.) into add_package_manifest_skills.go, which already owns skill/agent discovery. This matches the file's stated responsibility and removes the cross-domain coupling to _includes.go.

@copilot please address this.

Documents the architectural decision to decompose the 1330-line
pkg/cli/add_package_manifest.go into six single-responsibility files,
capturing context, decision rationale, alternatives, and consequences.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (1295 new lines in pkg/cli/) but did not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/54030-split-add-package-manifest-into-focused-files.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch — it was generated from the PR diff
  2. Complete the missing sections — add context the AI couldn't infer, refine the decision rationale, and list real alternatives you considered
  3. Commit the finalized ADR to docs/adr/ on your branch
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-54030: Split add_package_manifest.go into Focused Single-Responsibility Files

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

❓ Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say 'I'll deal with this later.' Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 0042-use-postgresql.md for PR #42).

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · sonnet46 · 100.1 AIC · ⌖ 29.6 AIC · ⊞ 9.1K ·
Comment /review to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot This PR still needs maintainer-facing follow-up.

Current blockers:

  • The ADR gate requested that the draft ADR at docs/adr/54030-split-add-package-manifest-into-focused-files.md be completed and linked from the PR body.
  • The branch can be refreshed if GitHub offers it.
  • After that, please run the pr-finisher skill and leave a concise maintainer-facing handoff with validation and any remaining risks.

Generated by 👨🍳 PR Sous Chef

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 29.9 AIC · ⌖ 8.24 AIC · ⊞ 9.3K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

CopilotAI commented Aug 20, 2026

Copy link
Copy Markdown
ContributorAuthor

@copilot This PR still needs maintainer-facing follow-up.

Current blockers:...

Completed the follow-up in 767f383: ADR-54030 is now marked Accepted at https://github.com/github/gh-aw/blob/767f383/docs/adr/54030-split-add-package-manifest-into-focused-files.md, and the package-boundary comment is separated from package cli. make fmt, make lint, make test-unit, make test, and make recompile all pass. CI remains stale after this agent push and needs a maintainer re-trigger before merge.

CopilotAI requested a review from gh-aw-botAugust 20, 2026 01:43
@pelikhan
pelikhan merged commit 9324c8b into mainAug 20, 2026
30 checks passed
@pelikhan
pelikhan deleted the copilot/file-diet-refactor-add-package-manifest branch August 20, 2026 01:52
CopilotAI mentioned this pull request Aug 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.87.2

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[file-diet] File Diet: Refactor pkg/cli/add_package_manifest.go (1330 lines)

4 participants

@gh-aw-bot@pelikhan