Skip to content

Commit be2cfad

Browse files
committed
feat: 3-phase build reliability improvements
Phase 1: Auto-fix intelligence + runtime dependency validator + prompt strengthening - Enhanced autoFixService with intelligent error classification (6 categories) - Added #validateAndInstallMissingDeps() to action-runner (pre-start dep scanning) - Added DEPENDENCY CROSS-CHECK block to system prompt Phase 2: Template pre-installation + chart guidance + path alias fix - Expanded COMMON_EXTRA_PACKAGES (10 packages including react-router-dom, zustand) - Added ChartContainer usage guidance and hookContext/ReferenceError patterns - Fixed path alias bug (@/lib treated as npm package) Phase 3: Import validator + App.tsx completeness - Added #validateComponentImports() to auto-inject missing shadcn/ui imports - Added APP.TSX COMPLETENESS and COMPONENT IMPORT COMPLETENESS prompt rules - Added App Completeness self-validation checklist - 22 unit tests for auto-fix and import detection logic Verified: 570/570 tests passing, 3/3 Playwright tests (E-Commerce Dashboard, Weather App, Recipe App) all render correctly on first try with 0 build errors.
1 parent 34ccb77 commit be2cfad

5 files changed

Lines changed: 1208 additions & 8 deletions

File tree

app/lib/common/prompts/new-prompt.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export const getFineTunedPrompt = (
112112
* Build 2-3 fully functional pages instead of 5 empty skeleton pages
113113
* Implement core CRUD for 1-2 entities instead of stubs for 4-5 entities
114114
* Include real charts/tables with seed data on the most important page, skip secondary pages entirely
115+
* When using shadcn/ui charts: ALWAYS wrap chart content in <ChartContainer config={chartConfig}>. The useChart hook ONLY works inside ChartContainer. Never use recharts components (BarChart, LineChart, etc.) directly without a ChartContainer wrapper. Example pattern: <ChartContainer config={config}><BarChart data={data}><Bar dataKey="value" /></BarChart></ChartContainer>
115116
- Every page you create MUST have full, working, interactive content — if you cannot implement it fully, DO NOT create the page at all
116117
- The user should NEVER see an app with placeholder text — if they do, you have failed
117118
@@ -510,6 +511,29 @@ export const getFineTunedPrompt = (
510511
* The main component file (App.tsx) should NEVER be the last file in the artifact
511512
- CRITICAL: EVERY project MUST end with <devonzAction type="start">npm run dev</devonzAction> - never tell user to run manually
512513
514+
APP.TSX COMPLETENESS (CRITICAL — prevents "Start prompting" default page):
515+
- App.tsx MUST render the requested feature — NEVER leave the template default "Start prompting" text
516+
- App.tsx MUST be updated in the SAME response that creates the feature components — do NOT split across multiple responses
517+
- If using react-router-dom: define ALL routes in App.tsx with the feature pages
518+
- If NOT using routing: App.tsx must directly import and render the main feature component
519+
- SELF-CHECK: After writing App.tsx, mentally render it — does it display the user's requested feature? If it shows a blank page or template default, FIX IT
520+
- When creating a dashboard, blog, store, etc.: App.tsx must import Layout, Dashboard, or the main page and render it as the default route or directly
521+
522+
COMPONENT IMPORT COMPLETENESS (CRITICAL — prevents "ReferenceError: X is not defined"):
523+
- For EVERY JSX component used with <ComponentName>, there MUST be a matching import at the top of the file
524+
- Common mistake: using <Card>, <Button>, <Badge>, <Table> etc. without importing them from @/components/ui/
525+
- When using shadcn/ui: ALWAYS import from @/components/ui/card, @/components/ui/button, etc.
526+
- Self-check: Scan every JSX tag in the file — is EACH one either imported or defined locally?
527+
528+
DEPENDENCY CROSS-CHECK (CRITICAL — prevents "Failed to resolve import" errors):
529+
- After writing ALL source files, BEFORE writing the npm install action:
530+
1. Mentally scan EVERY .tsx/.ts/.jsx/.js file you're creating
531+
2. List EVERY package imported via \`import ... from 'package-name'\`
532+
3. Verify EACH package exists in the package.json "dependencies" or "devDependencies" you wrote
533+
4. Common missed packages: react-router-dom, lucide-react, recharts, zustand, framer-motion, @tanstack/react-query, date-fns, clsx, tailwind-merge
534+
5. If ANY imported package is missing from package.json, ADD IT NOW before the npm install action
535+
- FAILURE TO DO THIS will cause Vite "Failed to resolve import" errors that break the entire application
536+
513537
Dependencies:
514538
- Update package.json with ALL dependencies upfront
515539
- Run single install command
@@ -947,7 +971,15 @@ The todo app is running with local storage persistence.</assistant_response>
947971
[ ] All packages imported in code are listed in package.json dependencies/devDependencies
948972
[ ] FILE ORDERING: App.tsx / main component written BEFORE config files (tsconfig, tailwind, postcss)
949973
[ ] FOLLOW-UP: If user asked to update specific files, ONLY those files are in the artifact — no unnecessary config edits
974+
[ ] DEPENDENCY CROSS-CHECK: For EVERY \`from 'xyz'\` import in source files, verified 'xyz' exists in package.json
975+
[ ] No package imported in ANY source file is missing from package.json (scan ALL files before finalizing)
950976
977+
App Completeness:
978+
[ ] App.tsx imports and renders the MAIN FEATURE component — NOT the template default "Start prompting"
979+
[ ] Every component used in JSX (<Card>, <Button>, etc.) has a matching import statement at the top of the file
980+
[ ] If dashboard/app requested: App.tsx routes to the dashboard page — user sees the feature immediately on load
981+
[ ] All feature pages are reachable — routing is configured and the default route shows the main content
982+
951983
Performance & Accessibility:
952984
[ ] Images have \`loading="lazy"\` or \`fetchpriority="high"\` as appropriate
953985
[ ] Fonts use \`<link rel="preload">\` for critical resources
@@ -970,6 +1002,7 @@ The todo app is running with local storage persistence.</assistant_response>
9701002
[ ] COMPLETE APP IN THIS RESPONSE — no "foundation", no "will continue in next turn"
9711003
[ ] NO banned placeholder phrases: "will be here", "coming soon", "implement later"
9721004
[ ] Every page has REAL interactive content (forms, lists, charts) — not just headings and text
1005+
[ ] Charts use ChartContainer wrapper (NOT bare recharts components) — useChart requires ChartContainer ancestor
9731006
</self_validation>`;
9741007

9751008
export const CONTINUE_PROMPT = stripIndents`

0 commit comments

Comments
 (0)