refactor: dedupe framework configs via framework-shared#810
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pulls four classes of inline duplication out of the 18
*-wizard-agent.tsframework configs and into a single
src/lib/framework-shared.tsmodule —without changing any behaviour the agent or user can see.
The shared module exports:
SUCCESS_MESSAGE_INTEGRATION_COMPLETE,OUTRO_DASHBOARD_LINE(18 + 17 inlinings before).JS_TS_PROJECT_TYPE_DETECTION(5 inlinings).apiKeyOnlyEnv,apiKeyAndServerUrlEnv,emptyEnv(8 + 4 + 5 inlinings).noVersionFromPackageJson(14 inlinings) andnodeInstalledVersion(pkgName)(2 near-identical async closures).frameworkDocsIdLine(id)(14 inlinings).framework-shared.test.tspins the exact wording of every shared stringso 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.ts—Integrationenum values + order preserved.src/lib/registry.ts—FRAMEWORK_REGISTRYtraversal order preserved.src/lib/commandments.ts— left alone per the PR-perf(agent): tighten commandments + framework prompts for scale and quality #799 caution; noverbatim 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
Integrationenum literalvalues 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.framework-shared.test.ts(8 tests) pins every shared string +builder output to the pre-refactor wording.
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.tsframework configs to import shared prompt/outro strings and small helper functions from a newsrc/lib/framework-shared.ts, reducing duplicated inline literals and env-var/version closures.Adds
framework-sharedunit 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 commonnodeInstalledVersion(...)implementation.Reviewed by Cursor Bugbot for commit 37279cc. Bugbot is set up for automated code reviews on this repo. Configure here.