Skip to content

refactor: shared onboarding helper + consistent init/update output#961

Draft
1code-async[bot] wants to merge 1 commit intomainfrom
refactor/shared-onboarding-helpers
Draft

refactor: shared onboarding helper + consistent init/update output#961
1code-async[bot] wants to merge 1 commit intomainfrom
refactor/shared-onboarding-helpers

Conversation

@1code-async
Copy link
Copy Markdown
Contributor

@1code-async 1code-async bot commented Apr 12, 2026

Summary

  • Root cause: init and update had divergent onboarding output — update hardcoded /opsx:new regardless of profile, while init correctly chose /opsx:propose for core profile. Both commands also copy-pasted removeSkillDirs/removeCommandFiles and the WORKFLOW_TO_SKILL_DIR constant independently.
  • Fix: Extract shared helpers (onboarding.ts, artifact-removal.ts) so both commands produce consistent, profile-aware output from a single source of truth.

What changed

File Change
src/core/shared/onboarding.ts New. formatGettingStarted, printOnboardingFooter, formatIdeRestart, formatLinks
src/core/shared/artifact-removal.ts New. removeAllSkillDirs, removeUnselectedSkillDirs, removeAllCommandFiles, removeUnselectedCommandFiles
src/core/shared/index.ts Re-exports new modules
src/core/init.ts Uses shared helpers; removes duplicate WORKFLOW_TO_SKILL_DIR, 2 private removal methods, inline onboarding footer
src/core/update.ts Uses shared helpers; removes 4 private removal methods, inline onboarding block; fixes legacy-upgrade to respect active profile
test/core/update.test.ts Updates legacy-upgrade assertion from /opsx:new/opsx:propose (matches corrected behavior)
test/core/shared-onboarding.test.ts New. 10 tests covering formatGettingStarted, formatLinks, formatIdeRestart, printOnboardingFooter
test/core/output-consistency.test.ts New. 7 tests verifying init/update/migration produce consistent onboarding output

Net effect

  • init.ts: 779 → 707 lines (−72)
  • update.ts: 702 → 583 lines (−119)
  • Shared code: +2 new modules (≈200 lines total)
  • Tests: +17 new tests, all 122 existing tests pass

Follow-ups (not in this PR)

  1. Centralize summary formatting — init shows "Created/Refreshed" while update shows "✓ Updated (vX.Y.Z)". A shared formatUpdateSummary() would make these consistent too.
  2. Extract tool-selection logic — init and update both independently handle tool detection, pre-selection, and validation. A shared ToolSelector class would prevent future drift.
  3. Document intentional legacy-cleanup behavior difference — init aborts if user refuses cleanup; update warns but continues. This is by design but undocumented.

Test plan

  • shared-onboarding.test.ts: All profile combinations produce correct commands
  • output-consistency.test.ts: init and update produce identical IDE-restart wording, correct links, profile-aware getting-started
  • init.test.ts: All 26 existing tests pass (no regressions)
  • update.test.ts: All 42 tests pass (1 assertion updated to match fixed behavior)
  • migration.test.ts: All 7 tests pass

🤖 Generated with Claude Code

…date

The init and update commands had divergent "getting started" messages,
duplicated WORKFLOW_TO_SKILL_DIR constants, and copy-pasted skill/command
removal methods. This caused update to hardcode /opsx:new regardless of
the active profile, while init correctly showed /opsx:propose for core.

Extract shared helpers so both commands produce consistent, profile-aware
onboarding output and share a single implementation for artifact removal.

- Add src/core/shared/onboarding.ts (formatGettingStarted, printOnboardingFooter)
- Add src/core/shared/artifact-removal.ts (removeAll/Unselected SkillDirs/CommandFiles)
- Remove duplicate WORKFLOW_TO_SKILL_DIR from init.ts (canonical source: profile-sync-drift.ts)
- Remove 4 private removal methods from UpdateCommand, 2 from InitCommand
- Fix update legacy-upgrade onboarding to respect active profile
- Add shared-onboarding.test.ts and output-consistency.test.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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