Skip to content

refactor: dedupe framework configs via framework-shared#810

Merged
kelsonpw merged 1 commit into
mainfrom
refactor/simplify-frameworks
May 22, 2026
Merged

refactor: dedupe framework configs via framework-shared#810
kelsonpw merged 1 commit into
mainfrom
refactor/simplify-frameworks

Conversation

@kelsonpw
Copy link
Copy Markdown
Member

@kelsonpw kelsonpw commented May 17, 2026

Summary

Pulls four classes of inline duplication out of the 18 *-wizard-agent.ts
framework configs and into a single src/lib/framework-shared.ts module —
without changing any behaviour the agent or user can see.

The shared module exports:

  • Outro stringsSUCCESS_MESSAGE_INTEGRATION_COMPLETE,
    OUTRO_DASHBOARD_LINE (18 + 17 inlinings before).
  • Detection blurbJS_TS_PROJECT_TYPE_DETECTION (5 inlinings).
  • Env-var shape buildersapiKeyOnlyEnv, apiKeyAndServerUrlEnv,
    emptyEnv (8 + 4 + 5 inlinings).
  • Detection helpersnoVersionFromPackageJson (14 inlinings) and
    nodeInstalledVersion(pkgName) (2 near-identical async closures).
  • Prompt fragment builderframeworkDocsIdLine(id) (14 inlinings).

framework-shared.test.ts pins the exact wording of every shared string
so a future refactor can't silently drift the agent's system prompt or the
user-facing outro copy.

Scope discipline

Locked files untouched (verified with git diff origin/main -- ... ==
empty):

  • src/lib/constants.tsIntegration enum values + order preserved.
  • src/lib/registry.tsFRAMEWORK_REGISTRY traversal order preserved.
  • src/lib/commandments.ts — left alone per the PR-perf(agent): tighten commandments + framework prompts for scale and quality #799 caution; no
    verbatim duplication found between universal + browser-only blocks that
    was worth touching.
  • src/lib/framework-config.ts — interface untouched.
  • src/utils/wizard-abort.ts — explicitly off-limits, never opened.
  • src/ui/tui/, src/lib/agent-*.ts — sibling agent territory.

Framework detection order is unchanged: the Integration enum literal
values are byte-identical, and the registry's insertion order is the same.

Test plan

  • pnpm tsc --noEmit — clean.
  • pnpm lint — prettier + eslint clean.
  • pnpm test — 297 -> 298 test files, 4469 -> 4477 tests, all green.
  • New framework-shared.test.ts (8 tests) pins every shared string +
    builder output to the pre-refactor wording.
  • Existing framework-detection.test.ts still passes (detection order
    preserved).

Note

Low Risk
Low risk refactor that centralizes previously inlined prompt/UI/env/version helpers; primary risk is accidental string/shape drift impacting wizard prompts or env var writing, mitigated by new snapshot-like tests.

Overview
Refactors many *-wizard-agent.ts framework configs to import shared prompt/outro strings and small helper functions from a new src/lib/framework-shared.ts, reducing duplicated inline literals and env-var/version closures.

Adds framework-shared unit tests to pin the exact wording and return shapes of the shared constants/builders, and updates a few JS framework configs (e.g. Next.js/Vue) to reuse a common nodeInstalledVersion(...) implementation.

Reviewed by Cursor Bugbot for commit 37279cc. Bugbot is set up for automated code reviews on this repo. Configure here.

…ework-shared

Pulls repeated outro strings, env-var shapes, project-type blurbs, and the
'Framework docs ID' prompt builder out of every per-framework wizard agent and
into a single src/lib/framework-shared.ts module.

The strings are kept identical to what each framework was inlining (verified
in framework-shared.test.ts), so the agent's system prompt and the user's
outro copy stay byte-for-byte the same. Detection order, env-var keys,
project-type detection text, and analytics tags are unchanged.

Behaviours preserved:
- 'Amplitude integration complete' across 18 frameworks -> 1 const
- 'Visit your Amplitude dashboard...' across 17 frameworks -> 1 const
- 'JavaScript/TypeScript project. Look for...' across 5 frameworks -> 1 const
- 'Framework docs ID: <id> (use amplitude://docs/...)' across 14 frameworks -> 1 builder
- apiKey-only env shape across 8 frameworks -> 1 builder
- apiKey+serverUrl env shape across 4 frameworks -> 1 builder
- empty env across 5 frameworks -> 1 builder
- getVersion: () => undefined across 14 frameworks -> 1 fn
- node getInstalledVersion across 2 frameworks -> 1 builder
@kelsonpw kelsonpw requested a review from a team as a code owner May 17, 2026 03:48
@kelsonpw kelsonpw removed the request for review from a team May 18, 2026 18:04
@kelsonpw kelsonpw merged commit d9e3a04 into main May 22, 2026
13 checks passed
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