Overview
The file pkg/cli/update_actions.go has grown to 1144 lines, making it the largest non-test Go source file in the repository. It mixes several distinct responsibilities — action-version resolution (GitHub API + git-based fallback), cooldown/version-gating logic, workflow-file rewriting, and skill-ref updating — which increases coupling and makes targeted testing harder. This task involves refactoring it into smaller, focused files with clearer boundaries.
Current State
- File:
pkg/cli/update_actions.go
- Size: 1144 lines
- Test Coverage:
pkg/cli/update_actions_test.go (1256 lines) + pkg/cli/update_actions_integration_test.go exist — ratio ≈ 1.1x (source vs. unit test), indicating solid existing coverage that should be preserved/relocated alongside any split.
- Complexity: 18 top-level functions spanning 4 loosely related domains (action classification, release resolution via API/git, workflow-file mutation, skill-ref mutation).
Full File Analysis
Detailed Breakdown
Functions and approximate line ranges:
isCoreAction (28), isGhAwNativeAction (35) — small classification helpers (~30 lines total)
actionUpdateDeps struct, cachedLatestRelease, cachedSHA types, newCachedActionUpdateDeps (61), defaultActionUpdateDeps (133) — dependency-injection/caching scaffolding (~100 lines)
UpdateActions (156), updateActions (160–402, ~240 lines) — top-level orchestrator for actions-lock.json updates
getLatestActionRelease (403), getLatestActionReleaseWithDeps (407–538, ~130 lines) — GitHub Releases API-based version resolution
getLatestActionReleaseViaGit (539–654, ~115 lines) — git-tag-based fallback version resolution
parseActionTagRefs (655), findCooledDownActionVersion (692), getActionSHAForTag (745–803, ~60 lines) — tag parsing and cooldown-window gating logic
UpdateActionsInWorkflowFiles (804), updateActionsInWorkflowFiles (833–911, ~80 lines) — orchestrator for rewriting .md workflow files
updateSkillRefsInContent (912), updateSkillRefsInContentWithResolver (916), updateSkillRefValue (982–1016, ~100 lines) — skill reference (source:) rewriting
updateActionRefsInContentWithDeps (1017–1144, ~127 lines) — action ref (uses:) rewriting in Markdown content
There are two clear domains mixed in this file: (1) resolving the latest/cooled-down action version (API + git fallback + cooldown), and (2) rewriting references (action uses: and skill source:) in workflow Markdown files. The dependency-injection scaffolding (actionUpdateDeps, caches) is shared infrastructure used by both.
Refactoring Strategy
Proposed File Splits
-
update_actions_deps.go
- Contents:
actionUpdateDeps struct, cachedLatestRelease, cachedSHA, newCachedActionUpdateDeps, defaultActionUpdateDeps
- Responsibility: dependency-injection/caching scaffolding shared by resolution and rewriting logic
- Estimated LOC: ~110
-
update_actions_release.go
- Functions:
isCoreAction, isGhAwNativeAction, getLatestActionRelease, getLatestActionReleaseWithDeps, getLatestActionReleaseViaGit, parseActionTagRefs, findCooledDownActionVersion, getActionSHAForTag
- Responsibility: resolving the latest eligible action version (API + git fallback) and applying cooldown-window gating
- Estimated LOC: ~450
-
update_actions_lockfile.go
- Functions:
UpdateActions, updateActions
- Responsibility: top-level command orchestrating
actions-lock.json updates
- Estimated LOC: ~250
-
update_actions_workflow_refs.go
- Functions:
UpdateActionsInWorkflowFiles, updateActionsInWorkflowFiles, updateSkillRefsInContent, updateSkillRefsInContentWithResolver, updateSkillRefValue, updateActionRefsInContentWithDeps
- Responsibility: rewriting
uses: action refs and source: skill refs inside workflow Markdown files
- Estimated LOC: ~340
Shared Utilities
No new utility file is needed beyond update_actions_deps.go; the dependency struct already serves as the shared abstraction point between resolution and rewriting logic.
Interface Abstractions
No new interfaces are strictly required — actionUpdateDeps already acts as a functional dependency-injection seam. Keep function signatures unchanged so callers in update_command.go/tests are unaffected.
Test Coverage Plan
Split update_actions_test.go (1256 lines) and update_actions_integration_test.go along the same boundaries:
-
update_actions_release_test.go
- Test cases: core/native action classification, API release resolution (major/minor/patch gating), git-fallback resolution, tag parsing, cooldown-window edge cases (exactly-at-boundary, expired, still-cooling)
- Target coverage: >80%
-
update_actions_lockfile_test.go
- Test cases: full
updateActions orchestration happy path, no-updates-needed path, disableReleaseBump flag behavior, error propagation from resolver
- Target coverage: >80%
-
update_actions_workflow_refs_test.go
- Test cases: rewriting single/multiple
uses: refs in Markdown, skill source: ref rewriting, no-compile flag behavior, approve-flag gating, malformed content handling
- Target coverage: >80%
Keep update_actions_integration_test.go as-is or split only if it becomes easier to maintain against the new file boundaries.
Implementation Guidelines
- Preserve Behavior: Ensure all existing functionality works identically
- Maintain Exports: Keep public API unchanged (exported functions/types)
- Add Tests First: Write tests for each new file before refactoring
- Incremental Changes: Split one module at a time
- Run Tests Frequently: Verify
make test-unit passes after each split
- Update Imports: Ensure all import paths are correct
- Document Changes: Add comments explaining module boundaries
Acceptance Criteria
Additional Context
- Repository Guidelines: Follow patterns in
.github/agents/developer.instructions.agent.md
- Code Organization: Prefer many small files grouped by functionality
- Testing: Match existing test patterns in
pkg/cli/*_test.go
Priority: Medium
Effort: Medium (4-way split with corresponding test relocation, no behavioral changes expected)
Expected Impact: Improved maintainability, easier targeted testing of release-resolution vs. Markdown-rewriting logic, reduced file-level coupling
Generated by 🧹 Daily File Diet · auto · 69.8 AIC · ⌖ 3.95 AIC · ⊞ 9.7K · ◷
Overview
The file
pkg/cli/update_actions.gohas grown to 1144 lines, making it the largest non-test Go source file in the repository. It mixes several distinct responsibilities — action-version resolution (GitHub API + git-based fallback), cooldown/version-gating logic, workflow-file rewriting, and skill-ref updating — which increases coupling and makes targeted testing harder. This task involves refactoring it into smaller, focused files with clearer boundaries.Current State
pkg/cli/update_actions.gopkg/cli/update_actions_test.go(1256 lines) +pkg/cli/update_actions_integration_test.goexist — ratio ≈ 1.1x (source vs. unit test), indicating solid existing coverage that should be preserved/relocated alongside any split.Full File Analysis
Detailed Breakdown
Functions and approximate line ranges:
isCoreAction(28),isGhAwNativeAction(35) — small classification helpers (~30 lines total)actionUpdateDepsstruct,cachedLatestRelease,cachedSHAtypes,newCachedActionUpdateDeps(61),defaultActionUpdateDeps(133) — dependency-injection/caching scaffolding (~100 lines)UpdateActions(156),updateActions(160–402, ~240 lines) — top-level orchestrator foractions-lock.jsonupdatesgetLatestActionRelease(403),getLatestActionReleaseWithDeps(407–538, ~130 lines) — GitHub Releases API-based version resolutiongetLatestActionReleaseViaGit(539–654, ~115 lines) — git-tag-based fallback version resolutionparseActionTagRefs(655),findCooledDownActionVersion(692),getActionSHAForTag(745–803, ~60 lines) — tag parsing and cooldown-window gating logicUpdateActionsInWorkflowFiles(804),updateActionsInWorkflowFiles(833–911, ~80 lines) — orchestrator for rewriting.mdworkflow filesupdateSkillRefsInContent(912),updateSkillRefsInContentWithResolver(916),updateSkillRefValue(982–1016, ~100 lines) — skill reference (source:) rewritingupdateActionRefsInContentWithDeps(1017–1144, ~127 lines) — action ref (uses:) rewriting in Markdown contentThere are two clear domains mixed in this file: (1) resolving the latest/cooled-down action version (API + git fallback + cooldown), and (2) rewriting references (action
uses:and skillsource:) in workflow Markdown files. The dependency-injection scaffolding (actionUpdateDeps, caches) is shared infrastructure used by both.Refactoring Strategy
Proposed File Splits
update_actions_deps.goactionUpdateDepsstruct,cachedLatestRelease,cachedSHA,newCachedActionUpdateDeps,defaultActionUpdateDepsupdate_actions_release.goisCoreAction,isGhAwNativeAction,getLatestActionRelease,getLatestActionReleaseWithDeps,getLatestActionReleaseViaGit,parseActionTagRefs,findCooledDownActionVersion,getActionSHAForTagupdate_actions_lockfile.goUpdateActions,updateActionsactions-lock.jsonupdatesupdate_actions_workflow_refs.goUpdateActionsInWorkflowFiles,updateActionsInWorkflowFiles,updateSkillRefsInContent,updateSkillRefsInContentWithResolver,updateSkillRefValue,updateActionRefsInContentWithDepsuses:action refs andsource:skill refs inside workflow Markdown filesShared Utilities
No new utility file is needed beyond
update_actions_deps.go; the dependency struct already serves as the shared abstraction point between resolution and rewriting logic.Interface Abstractions
No new interfaces are strictly required —
actionUpdateDepsalready acts as a functional dependency-injection seam. Keep function signatures unchanged so callers inupdate_command.go/tests are unaffected.Test Coverage Plan
Split
update_actions_test.go(1256 lines) andupdate_actions_integration_test.goalong the same boundaries:update_actions_release_test.goupdate_actions_lockfile_test.goupdateActionsorchestration happy path, no-updates-needed path, disableReleaseBump flag behavior, error propagation from resolverupdate_actions_workflow_refs_test.gouses:refs in Markdown, skillsource:ref rewriting, no-compile flag behavior, approve-flag gating, malformed content handlingKeep
update_actions_integration_test.goas-is or split only if it becomes easier to maintain against the new file boundaries.Implementation Guidelines
make test-unitpasses after each splitAcceptance Criteria
make test-unit)make lint)make build)Additional Context
.github/agents/developer.instructions.agent.mdpkg/cli/*_test.goPriority: Medium
Effort: Medium (4-way split with corresponding test relocation, no behavioral changes expected)
Expected Impact: Improved maintainability, easier targeted testing of release-resolution vs. Markdown-rewriting logic, reduced file-level coupling