index.ts
1.32 KB
import type { ProjectProfile } from '../../../types/project-profile';
import { getProjectProfile } from '../../../utils/project-profile';
import type { FrameworkStrategy } from './types';
import { reactStrategy } from './react';
import { vue3Strategy } from './vue3';
/**
* Registered framework strategies. To support a new framework, add a strategy
* module under this folder and append it here — the CODE node dispatch and all
* existing strategies stay untouched (Open-Closed Principle).
*/
const STRATEGIES: FrameworkStrategy[] = [reactStrategy, vue3Strategy];
/**
* Resolve a strategy from an explicit profile. Falls back to React when no
* framework matches (React is the legacy default and must remain unchanged).
*/
export function getStrategyForProfile(profile?: ProjectProfile | null): FrameworkStrategy {
const fw = (profile?.framework || '').toLowerCase();
const matched = STRATEGIES.find((s) => fw.includes(s.id));
return matched ?? reactStrategy;
}
/**
* Resolve the active strategy from the runtime project profile (set per run by
* the orchestration backend via `setProjectProfile`).
*/
export function getActiveStrategy(): FrameworkStrategy {
return getStrategyForProfile(getProjectProfile());
}
export type { FrameworkStrategy, FramePromptInput, ComponentPromptInput, RootInjectionInput } from './types';