react.ts 1.14 KB
import { generateFramePrompt, generateComponentPrompt, injectRootComponentPrompt } from '../prompt';
import { DEFAULT_APP_CONTENT } from '../constants';
import type { FrameworkStrategy } from './types';

/**
 * React strategy — a thin wrapper that delegates to the existing, battle-tested
 * React prompts **unchanged**. The original `prompt.ts` is never modified, so
 * established React behaviour is preserved byte-for-byte. This wrapper exists
 * purely so the CODE node can treat every framework uniformly via the
 * `FrameworkStrategy` interface.
 */
export const reactStrategy: FrameworkStrategy = {
    id: 'react',
    label: 'React',
    isVue: false,
    entryFileName: 'index.tsx',
    rootFileName: 'App.tsx',
    defaultAppContent: DEFAULT_APP_CONTENT,

    buildFramePrompt: (i) => generateFramePrompt(i),
    buildComponentPrompt: (i) => generateComponentPrompt(i),
    buildRootInjectionPrompt: (i) => injectRootComponentPrompt(i),

    // React prompts already honour the project profile's component library
    // through the injected `<profile_rules>` constraint block, so no extra
    // guidance is needed here.
    libraryGuidance: () => '',
};