builder.io 1.6.86 → 1.6.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/index.cjs +936 -522
- package/cli/index.cjs.map +4 -4
- package/core/index.cjs +170 -64
- package/core/index.mjs +170 -64
- package/node/index.cjs +1 -1
- package/node/index.mjs +1 -1
- package/package.json +1 -1
- package/server/index.cjs +263 -157
- package/server/index.mjs +263 -157
- package/types/cli/abort-signal-any.d.ts +1 -1
- package/types/cli/code-tools.d.ts +2 -1
- package/types/cli/codegen.d.ts +4 -2
- package/types/cli/launch/InitStateMachine.d.ts +1 -0
- package/types/cli/launch/dev-server-orchestrator.d.ts +31 -7
- package/types/cli/launch/github.d.ts +2 -1
- package/types/cli/launch/logger.d.ts +0 -6
- package/types/cli/utils/component-group-mdx-prompt.d.ts +1 -1
- package/types/cli/utils/repo-indexing-group-prompts.d.ts +1 -1
- package/types/cli/utils/workspace-path-resolver.d.ts +52 -0
- package/types/cli/utils/workspace-path-resolver.unit.d.ts +1 -0
- package/types/common/builder/builder-sdks.d.ts +1 -0
- package/types/common/utils.d.ts +6 -0
- package/types/core/adapters/vue/index.d.ts +14 -0
- package/types/core/adapters/vue/vue-api-key.d.ts +6 -0
- package/types/core/adapters/vue/vue-components.d.ts +4 -0
- package/types/core/adapters/vue/vue-ensure-builder-setup.d.ts +7 -0
- package/types/core/adapters/vue/vue-registry-parse.d.ts +16 -0
- package/types/core/adapters/vue/vue-registry.d.ts +5 -0
- package/types/tsconfig.tsbuildinfo +1 -1
- package/types/types.d.ts +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function abortSignalAny(
|
|
1
|
+
export declare function abortSignalAny(input: (AbortSignal | undefined)[]): AbortSignal;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CodeGenTools, CommitMode, ContentMessageItemToolResult, ProjectFile, WorkspaceFolder } from "$/ai-utils";
|
|
1
|
+
import type { CodeGenTools, CommitMode, ContentMessageItemToolResult, FusionConfig, ProjectFile, WorkspaceFolder } from "$/ai-utils";
|
|
2
2
|
import type { DevToolsSys } from "../core";
|
|
3
3
|
import { type DevServerOrchestrator } from "./launch/dev-server-orchestrator";
|
|
4
4
|
import type { CodeGenEventEmitter } from "./codegen";
|
|
@@ -37,6 +37,7 @@ export interface ToolContext extends Partial<FusionContext> {
|
|
|
37
37
|
path: string;
|
|
38
38
|
name?: string;
|
|
39
39
|
}>;
|
|
40
|
+
patchFusionConfig: (patch: Partial<FusionConfig>) => void;
|
|
40
41
|
readFile: (filePath: string) => Promise<string | null>;
|
|
41
42
|
writeFile: (filePath: string, content: string | Uint8Array) => Promise<boolean>;
|
|
42
43
|
deleteFile: (filePath: string) => Promise<boolean>;
|
package/types/cli/codegen.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DevToolsSys } from "../types";
|
|
2
2
|
import { type Credentials } from "./credentials";
|
|
3
|
-
import type { CodegenFeedback, CodegenTurn, CommitMode, CustomInstruction,
|
|
3
|
+
import type { CodegenFeedback, CodegenTurn, CommitMode, CustomInstruction, GenerateCompletionState, GenerateCompletionStep, GenerateCompletionStepGit, GenerateUserMessage, UserContext, WorkspaceConfiguration, WorkspaceFolder } from "$/ai-utils";
|
|
4
4
|
import prettier from "prettier";
|
|
5
5
|
import { type FusionContext } from "./code-tools";
|
|
6
6
|
import EventEmitter from "node:events";
|
|
@@ -39,7 +39,6 @@ export type CodeGenSessionOptions = CodeGenSessionOptionsSession | CodeGenSessio
|
|
|
39
39
|
export type CodeGenEventEmitter = EventEmitter<{
|
|
40
40
|
step: [GenerateCompletionStep];
|
|
41
41
|
idle: [];
|
|
42
|
-
fusionConfigPatch: [Partial<FusionConfig>];
|
|
43
42
|
}>;
|
|
44
43
|
export declare class CodeGenSession {
|
|
45
44
|
#private;
|
|
@@ -159,8 +158,11 @@ export declare class CodeGenSession {
|
|
|
159
158
|
sendMessage(message: GenerateUserMessage, immediate?: boolean): Promise<void>;
|
|
160
159
|
getTurns(): CodegenTurn[];
|
|
161
160
|
getSessionContext(): SessionContext;
|
|
161
|
+
runSetupCommand(): Promise<import("./launch/dev-server-orchestrator").SetupCommandResult | undefined>;
|
|
162
|
+
abortSetupCommand(): void;
|
|
162
163
|
abort(cleanCurrentMessage?: boolean): Promise<boolean>;
|
|
163
164
|
stopEventLoop(): Promise<void>;
|
|
165
|
+
requestRefresh(): void;
|
|
164
166
|
close(): Promise<void>;
|
|
165
167
|
emitGitStatus(): Promise<GenerateCompletionStepGit | null>;
|
|
166
168
|
connectToEventLoop(shouldReplay: boolean, onStep: (step: GenerateCompletionStep) => void): () => void;
|
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
import type { DevToolsSys } from "@builder.io/dev-tools/core";
|
|
2
2
|
import { type RequestHandler as ProxyRequestHandler } from "http-proxy-middleware";
|
|
3
|
+
import EventEmitter from "events";
|
|
3
4
|
import { type ChildProcessByStdio } from "node:child_process";
|
|
4
5
|
import type { Readable } from "node:stream";
|
|
5
6
|
import type { FusionConfig } from "$/ai-utils";
|
|
6
|
-
export type
|
|
7
|
+
export type DevCommandState = "running" | "stopped" | "unset";
|
|
8
|
+
export type SetupCommandState = "not-installed" | "installing" | "installed" | "install-failed";
|
|
9
|
+
export type DevServerState = Exclude<SetupCommandState | DevCommandState, "installed">;
|
|
10
|
+
export interface SetupCommandResult {
|
|
11
|
+
code: number | null;
|
|
12
|
+
output: string;
|
|
13
|
+
}
|
|
7
14
|
export interface DevServerOrchestrator {
|
|
8
|
-
|
|
9
|
-
|
|
15
|
+
devCommand: string;
|
|
16
|
+
setupCommand: string | undefined;
|
|
17
|
+
setupState: SetupCommandState;
|
|
18
|
+
devState: DevCommandState;
|
|
19
|
+
state: DevServerState;
|
|
10
20
|
proxyTarget: string;
|
|
11
21
|
proxyPort: number;
|
|
12
22
|
proxyMiddleware: ProxyRequestHandler | undefined;
|
|
13
23
|
pid: number | undefined;
|
|
14
|
-
|
|
24
|
+
abortSetupCommand: () => void;
|
|
25
|
+
setEnvVariable: (key: string, value: string | undefined) => void;
|
|
26
|
+
ensureDevCommand: (abortSignal?: AbortSignal) => Promise<boolean>;
|
|
27
|
+
ensureSetupCommand: (abortSignal?: AbortSignal) => Promise<boolean>;
|
|
28
|
+
setupCommandPromise: Promise<SetupCommandResult> | undefined;
|
|
29
|
+
runSetupCommand: (signal?: AbortSignal) => Promise<SetupCommandResult>;
|
|
30
|
+
setSetupCommand: (newCommand: string, signal?: AbortSignal) => Promise<SetupCommandResult>;
|
|
15
31
|
setCommand: (newCommand: string, signal?: AbortSignal) => Promise<boolean>;
|
|
16
32
|
setPort: (newPort: number) => Promise<boolean>;
|
|
17
33
|
pingServer: (signal?: AbortSignal) => Promise<Response>;
|
|
@@ -21,12 +37,20 @@ export interface DevServerOrchestrator {
|
|
|
21
37
|
getAllStdout: () => string;
|
|
22
38
|
getAllStderr: () => string;
|
|
23
39
|
getOutput: () => string;
|
|
40
|
+
getSetupOutput: () => string;
|
|
24
41
|
waitUntilIdle: (initialWaitMs?: number, idleTimeMs?: number) => Promise<void>;
|
|
25
42
|
onClose: (callback: (code: number | null) => void) => void;
|
|
26
|
-
onStdout: (callback: (data: string) => void) => void;
|
|
27
|
-
onStderr: (callback: (data: string) => void) => void;
|
|
28
43
|
restart: (abortSignal?: AbortSignal) => Promise<void>;
|
|
44
|
+
emitter: EventEmitter<{
|
|
45
|
+
close: [number | null];
|
|
46
|
+
stdout: [string];
|
|
47
|
+
stderr: [string];
|
|
48
|
+
installStdout: [string];
|
|
49
|
+
installStderr: [string];
|
|
50
|
+
setupState: [SetupCommandState];
|
|
51
|
+
devState: [DevCommandState];
|
|
52
|
+
}>;
|
|
29
53
|
}
|
|
30
|
-
export declare function devServerOrchestrator(sys: DevToolsSys, fusionConfig: FusionConfig): Promise<DevServerOrchestrator>;
|
|
54
|
+
export declare function devServerOrchestrator(sys: DevToolsSys, fusionConfig: FusionConfig, initialSetupState: "installed" | "not-installed" | "install-failed"): Promise<DevServerOrchestrator>;
|
|
31
55
|
export declare const checkPortsListenedByPid: (pid: number) => number[];
|
|
32
56
|
export declare function killProcess(sys: DevToolsSys, proc: ChildProcessByStdio<null, Readable, Readable> | undefined, abortSignal?: AbortSignal, timeout?: number): Promise<boolean>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DevToolsSys } from "@builder.io/dev-tools/core";
|
|
2
2
|
import type { Credentials } from "cli/credentials";
|
|
3
3
|
export declare const getInitialDescription: (projectId: string) => string;
|
|
4
|
-
export declare function updatePRDescription({ repoFullName, githubToken, prNumber, projectId, sys, credentials, builderProjectBranchName, }: {
|
|
4
|
+
export declare function updatePRDescription({ repoFullName, githubToken, prNumber, projectId, sys, credentials, builderProjectBranchName, gitWorkingDirectory, }: {
|
|
5
5
|
repoFullName: string;
|
|
6
6
|
githubToken: string;
|
|
7
7
|
prNumber: number;
|
|
@@ -9,6 +9,7 @@ export declare function updatePRDescription({ repoFullName, githubToken, prNumbe
|
|
|
9
9
|
sys: DevToolsSys;
|
|
10
10
|
credentials: Credentials;
|
|
11
11
|
builderProjectBranchName: string | undefined;
|
|
12
|
+
gitWorkingDirectory?: string;
|
|
12
13
|
}): Promise<{
|
|
13
14
|
success: boolean;
|
|
14
15
|
lastTurn: any;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { ChildProcessByStdio } from "child_process";
|
|
2
|
-
import type { Readable } from "stream";
|
|
3
1
|
/**
|
|
4
2
|
* Initialize logging by wrapping all console methods to write to logs file
|
|
5
3
|
*/
|
|
@@ -8,10 +6,6 @@ export declare function initializeLogging(): void;
|
|
|
8
6
|
* Reset console methods to their original state
|
|
9
7
|
*/
|
|
10
8
|
export declare function resetLogging(): void;
|
|
11
|
-
/**
|
|
12
|
-
* Capture and log child process output
|
|
13
|
-
*/
|
|
14
|
-
export declare function setupChildProcessLogging(childProcess: ChildProcessByStdio<null, Readable, Readable>, prefix: string): void;
|
|
15
9
|
/**
|
|
16
10
|
* Display intro message with logging
|
|
17
11
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const COMPONENT_GROUP_MDX_PROMPT = "# Component Group Documentation Generation\n\n## Objective\nGenerate comprehensive MDX documentation for a specific component group, analyzing their interfaces, relationships, and usage patterns using only the relevant files provided in the input.\n\n## Instructions\n\n### 1. Component Analysis\nFor the given component group, analyze each relevant file by:\n- **Interface examination** - Extract and document all props, their types, and descriptions\n- **
|
|
1
|
+
export declare const COMPONENT_GROUP_MDX_PROMPT = "# Component Group Documentation Generation\n\n## Objective\nGenerate comprehensive MDX documentation for a specific component group, analyzing their interfaces, relationships, and usage patterns using only the relevant files provided in the input.\n\n## Instructions\n\n### 1. Component Analysis\nFor the given component group, analyze each relevant file by:\n- **Interdependency mapping** - Document how components depend on each other\n- **Interface examination** - Extract and document all props, their types, and descriptions\n- **Context analysis** - Identify shared state, contexts, or communication patterns\n- **Compositional patterns** - Document required parent-child relationships\n- **Usage pattern analysis** - Identify how components work together\n- **Example extraction** - Find real usage examples from the codebase\n\n### 2. Documentation Structure\nCreate comprehensive documentation covering:\n- **Group rationale** - Why these components work together and when to use them\n- **Architectural overview** - How the components form a cohesive system\n- **Component interfaces** - Detailed prop documentation with interdependencies\n- **Composition patterns** - Required and optional usage combinations\n- **Integration examples** - Real-world scenarios showing the group in action\n- **Best practices** - Recommended usage patterns and guidelines\n\n## Required Output Format\n\nGenerate an MDX file with this structure:\n\n```mdx\n---\n# {{GROUP_NAME}} Components\n\n## Overview\n\n### Purpose\n{{GROUP_DESCRIPTION}}\n\n### When to Use\n[Expand on the use cases mentioned in the description - be specific about scenarios, user needs, and implementation contexts]\n\n### Architecture\n[Explain the architectural pattern based on coupling strength:]\n- **Critical/Strong Coupling**: Describe the required relationships, shared context, or compositional hierarchy\n- **Moderate Coupling**: Explain how components enhance each other\n- **No Coupling**: Note that this is a standalone component\n\n### Component Interdependencies\n[Map out component relationships - only for groups with coupling:]\n- Required parent-child relationships\n- Shared context dependencies \n- Communication patterns between components\n\n## Components\n\n### [PrimaryComponent] {Primary Component for groups with coupling}\n[Mark the main/root component for coupled groups]\n\n**Purpose:** [What this specific component does within the group]\n\n**Interface:**\n```typescript\ninterface [PrimaryComponent]Props {\n // Document all props with types and descriptions\n children: React.ReactNode; // Required child components (for coupled groups)\n property: string; // Description of what this prop does\n onAction?: () => void; // Optional callback description\n}\n```\n\n**Dependencies:** [For coupled groups - what this component requires]\n**Provides:** [For coupled groups - what context/state this component provides to children]\n\n**Usage Example:**\n```tsx\nimport { [PrimaryComponent] } from '@your-library/components';\n\nfunction Example() {\n return (\n <[PrimaryComponent]\n property=\"value\"\n onAction={() => console.log('action')}\n >\n {/* Required children for coupled groups */}\n </[PrimaryComponent]>\n );\n}\n```\n\n### [DependentComponent] {Dependent Component for groups with coupling}\n[Mark components that depend on the primary component]\n\n**Purpose:** [What this specific component does within the group]\n\n**Interface:**\n```typescript\ninterface [DependentComponent]Props {\n // Props specific to this component\n // Note any props that are passed down from parent context\n}\n```\n\n**Context Dependencies:** [What context/state this component requires from parent]\n**Parent Requirements:** [Required parent components for proper functionality]\n\n**Usage Example:**\n```tsx\n// Must be used within [PrimaryComponent] for coupled groups\n<[PrimaryComponent]>\n <[DependentComponent] prop=\"value\">\n Content\n </[DependentComponent]>\n</[PrimaryComponent]>\n```\n\n### [StandaloneComponent] {For uncoupled components}\n[For components with no coupling]\n\n**Purpose:** [What this component does and when to use it]\n\n**Interface:**\n```typescript\ninterface [StandaloneComponent]Props {\n // All props with types and descriptions\n}\n```\n\n**Usage Example:**\n```tsx\nimport { [StandaloneComponent] } from '@your-library/components';\n\nfunction Example() {\n return (\n <[StandaloneComponent]\n property=\"value\"\n onAction={() => console.log('action')}\n />\n );\n}\n```\n\n## Integration Patterns\n\n### Basic Usage {Only for coupled groups}\n```tsx\nimport { [PrimaryComponent], [DependentComponent1], [DependentComponent2] } from '@your-library/components';\n\n// Minimal required structure\nfunction BasicExample() {\n return (\n <[PrimaryComponent]>\n <[DependentComponent1]>Required content</[DependentComponent1]>\n <[DependentComponent2]>More content</[DependentComponent2]>\n </[PrimaryComponent]>\n );\n}\n```\n\n### Advanced Usage {Only for coupled groups}\n```tsx\n// Complex usage with all features\nfunction AdvancedExample() {\n return (\n <[PrimaryComponent] \n property=\"value\" \n onAction={handleAction}\n >\n <[DependentComponent1] prop=\"value\">\n <Content />\n </[DependentComponent1]>\n <[DependentComponent2] prop=\"value\">\n <MoreContent />\n </[DependentComponent2]>\n </[PrimaryComponent]>\n );\n}\n```\n\n### Common Variations {Adapt based on component types}\n```tsx\n// Show different ways to use the component(s)\n// Include conditional rendering, different prop combinations, etc.\n```\n\n## Component Relationships {Only for coupled groups}\n\n### Data Flow\n[Explain how data flows between components in the group]\n\n### Context Sharing\n[Document shared contexts, providers, or state management]\n\n### Event Handling\n[Describe how events bubble up or propagate between components]\n\n## Best Practices\n\n### Usage Guidelines\n- [Specific recommendation based on component purpose and use cases]\n- [Another recommendation focusing on accessibility or performance]\n- [Usage pattern guidance based on the group's architecture]\n\n### Accessibility {When relevant}\n- [ARIA relationships between components for coupled groups]\n- [Keyboard navigation patterns]\n- [Screen reader considerations]\n\n### Performance {When relevant}\n- [Optimization recommendations]\n- [State management best practices]\n- [Rendering performance considerations]\n\n## Common Patterns {Expand based on component functionality}\n\n### Pattern 1: [Specific Pattern Name]\n```tsx\n// Example showing a specific usage pattern\n// Include comments explaining why this pattern is recommended\n```\n\n### Pattern 2: [Another Pattern Name]\n```tsx\n// Another common pattern with explanation\n```\n\n```\n\n## File Generation Requirements\n\n**File Naming:**\n- Use kebab-case derived from group name: `{{GROUP_NAME_KEBAB}}.mdx`\n- Place in `repo-indexing/` folder\n- Example: `repo-indexing/{{GROUP_NAME_KEBAB}}.mdx`\n\n**Content Requirements:**\n1. **Use coupling strength context** - Adapt documentation structure based on couplingStrength value\n2. **Extract real interfaces** - Don't create placeholder interfaces, extract actual TypeScript interfaces from the codebase\n3. **Leverage group description** - Expand on the provided description with specific use cases and implementation guidance\n4. **Document interdependencies** - For coupled groups, clearly explain component relationships and requirements\n5. **Include practical examples** - Use realistic, working code examples that demonstrate proper usage\n6. **Show integration patterns** - For coupled groups, demonstrate required composition patterns\n**Coupling-Specific Requirements:**\n- **Critical/Strong Coupling**: Focus on required relationships, composition patterns, and shared context\n- **Moderate Coupling**: Show how components enhance each other and optional usage patterns \n- **No Coupling**: Document standalone usage, variants, and individual component capabilities\n\n\n## Input Format\nYou will receive a single component group object:\n```json\n{\n \"name\": \"{{GROUP_NAME}}\", \n \"description\": \"{{GROUP_DESCRIPTION}}\",\n \"components\": [{{COMPONENT_LIST}}],\n \"relevantFiles\": [{{FILE_LIST}}],\n}\n```\n\n## Output\nReturn only the complete MDX file content, ready to be saved as `repo-indexing/{{GROUP_NAME_KEBAB}}.mdx`";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const REPO_INDEXING_GROUP_PROMPT = "# Component Repository Analysis and Grouping\n\n## Objective\nAnalyze the repository to identify and categorize
|
|
1
|
+
export declare const REPO_INDEXING_GROUP_PROMPT = "# Component Repository Analysis and Grouping\n\n## Objective\nAnalyze the repository to identify and categorize components based on **mandatory architectural interdependency**, creating groups ONLY when components literally cannot function independently and MUST be used together.\n\n## Component Grouping Philosophy - STRICT CRITERIA\n\n### ONLY Group Components That Meet ALL These Requirements:\n\n1. **Mandatory Compositional Architecture**\n - Components that literally cannot render or function without their counterparts\n - Parent components that are meaningless without specific child components\n - Child components that will throw errors or fail without their required parent\n - Example: `Table` requires `TableHeader`, `TableBody`, `TableRow`, `TableCell` to be functional\n\n2. **Exclusive Required Context Dependencies**\n - Components that share context where the context is NOT optional\n - Child components that will fail without the parent's required context\n - Components with hard-coded provider-consumer relationships that cannot be bypassed\n - Example: `FormField` + `FormLabel` + `FormControl` sharing required form context\n\n3. **Critical Runtime Dependencies**\n - Components that reference each other's internal APIs or state directly\n - Components that communicate through required internal protocols\n - Components where removing one breaks the others at runtime\n\n### What MUST REMAIN SEPARATE - Even If They Share Code\n\n**Shared Infrastructure \u2260 Interdependency**\n- AreaChart, BarChart, LineChart are SEPARATE even if they use shared cartesian infrastructure\n- Each chart can render independently without the others\n- Shared internal components are implementation details, not architectural coupling\n\n**Thematic Similarity \u2260 Coupling** \n- Button, IconButton, ToggleButton stay separate (each works alone)\n- Input, Select, TextArea stay separate (independent form controls)\n- Card, Panel, Modal stay separate (independent containers)\n\n**Optional Composition \u2260 Required Composition**\n- Components that CAN work together but don't HAVE to\n- Components where composition is for convenience, not necessity\n\n## Strict Validation Test\nBefore grouping ANY components, ask these questions. ALL must be \"YES\":\n\n1. **Removal Test**: If I remove one component from this group, do the others become non-functional or throw errors?\n2. **Independence Test**: Can ANY component in this group render successfully in complete isolation?\n3. **Context Test**: Do these components share context that is absolutely required (not optional)?\n4. **API Test**: Do these components directly call each other's methods or access each other's internal state?\n\nIf ANY answer is \"NO\" \u2192 DO NOT GROUP\n\n## Examples of CORRECT Grouping\n\n** Table Group** (Critical Coupling)\n```json\n{\n \"name\": \"Table\",\n \"components\": [\"Table\", \"TableHeader\", \"TableBody\", \"TableRow\", \"TableCell\"]\n}\n```\nWhy: Table component cannot render without TableHeader, TableBody, etc. Each piece is meaningless alone.\n\n**Form Field Group** (Strong Coupling) \n```json\n{\n \"name\": \"FormField\", \n \"components\": [\"FormField\", \"FormLabel\", \"FormControl\", \"FormMessage\"]\n}\n```\nWhy: These share required form context and cannot function independently.\n\n## Examples of INCORRECT Grouping\n\n** Charts Group** (Shared Infrastructure \u2260 Coupling)\n```json\n// WRONG - Don't do this\n{\n \"name\": \"Charts\",\n \"components\": [\"AreaChart\", \"BarChart\", \"LineChart\", \"PieChart\"]\n}\n```\nWhy: Each chart renders independently. Shared infrastructure is an implementation detail.\n\n** Button Group** (Thematic Similarity \u2260 Coupling)\n```json\n// WRONG - Don't do this \n{\n \"name\": \"Buttons\",\n \"components\": [\"Button\", \"IconButton\", \"ToggleButton\"]\n}\n```\nWhy: Each button type works completely independently.\n\n## Default Assumption: KEEP SEPARATE\n- When in doubt, create separate groups for each component\n- Err on the side of independence rather than grouping\n- Most components should end up in individual groups\n\n## Instructions\n\n### 1. Component Discovery\n- Scan the entire repository for all components\n- Identify component files, their exports, and related files\n\n### 2. Interdependency Analysis\nFor each component, analyze:\n- **Required Dependencies**: What other components MUST be present for this to work?\n- **Context Requirements**: Does this component require specific context providers?\n- **Compositional Rules**: Are there mandatory parent-child relationships?\n- **Shared State**: Do components communicate through shared internal state?\n\n### 3. Coupling Strength Assessment\nEvaluate coupling strength:\n- **Critical Coupling**: Components cannot function without each other\n- **Strong Coupling**: Components are designed to work together with shared context\n- **Moderate Coupling**: Components enhance each other but can work independently\n- **Weak Coupling**: Components are thematically related but functionally independent\n\n### 4. Group Formation Rules\n- **Group together**: Components with Critical or Strong coupling\n- **Consider grouping**: Components with Moderate coupling (case-by-case basis)\n- **Keep separate**: Components with Weak coupling or functional independence\n\n### 5. Relevant Files Collection\nFor each group, include:\n- Primary component files (.tsx, .ts)\n- Context providers or shared state files\n- Type definition files specific to the group\n- Hook files that bind the components together\n- Test files that test the group as a unit\n- Documentation files specific to the group\n- Example files showing the components working together\n\n## Required Output Format\n\nGenerate a component-groups.json file with this structure:\n\n```json\n[\n {\n \"name\": \"Table\",\n \"description\": \"Use this component group to generate components that handle tabular data with required hierarchical structure\",\n \"components\": [\"Table\", \"TableHeader\", \"TableBody\", \"TableRow\", \"TableCell\"],\n \"relevantFiles\": [\"table.tsx\", \"table-header.tsx\", \"table-body.tsx\", \"table-row.tsx\", \"table-cell.tsx\", \"table-context.tsx\", \"table.types.ts\"]\n },\n {\n \"name\": \"AreaChart\",\n \"description\": \"Use this component to generate area chart functionality\",\n \"components\": [\"AreaChart\"],\n \"relevantFiles\": [\"src/area-chart/index.tsx\", \"src/area-chart/interfaces.ts\"]\n },\n {\n \"name\": \"BarChart\", \n \"description\": \"Use this component to generate bar chart functionality\",\n \"components\": [\"BarChart\"],\n \"relevantFiles\": [\"src/bar-chart/index.tsx\", \"src/bar-chart/interfaces.ts\"]\n }\n]\n```\n\n### Coupling Strength Definitions:\n- **\"critical\"**: Components cannot function without each other (Table group)\n- **\"strong\"**: Components share exclusive context/state (Form group) \n- **\"moderate\"**: Components enhance each other but can work alone (ButtonGroup + Button)\n- **\"none\"**: Component is functionally independent (standalone Button)\n\n## Quality Requirements\n\n**Be Conservative:**\n- Prefer individual component groups over multi-component groups\n- Only group when there's undeniable architectural interdependency\n- Most components should be individual groups\n\n**Component Coverage:**\n- Include ALL components found in the repository\n- Every component must appear in exactly one group\n- Prefer smaller, focused groups over large, loosely-coupled groups\n- Create individual groups for truly independent components\n\n**Grouping Validation:**\nFor each proposed group, ask:\n1. Would removing any component make the others useless or broken?\n2. Is there a required parent-child rendering relationship?\n3. Do they share mandatory (not optional) context or state?\n\nIf you can't answer \"YES\" confidently to at least one of these, keep components separate.\n\n**File Selection:**\n- Include files that are essential to understanding the group's architecture\n- Focus on files that show interdependencies between components\n- Include context providers, shared hooks, and type definitions\n- Exclude generic utility files unless they're group-specific\n\n## Anti-Patterns to Avoid\n\n**Don't group by theme alone**\n- Wrong: Group Button, IconButton, ToggleButton because they're all \"buttons\"\n- Right: Keep them separate because each works independently\n\n**Don't create mega-groups** \n- Wrong: Group all form-related components together\n- Right: Group only those that share context (FormField + FormLabel + FormControl)\n\n**Don't group by visual similarity**\n- Wrong: Group Card, Panel, Container because they're all \"containers\" \n- Right: Keep separate because they serve different architectural purposes\n\n**Don't group by shared infrastructure**\n- Wrong: Group AreaChart, BarChart, LineChart because they use shared cartesian components\n- Right: Keep separate because each chart works independently\n\n## Output Requirements\n- Return ONLY the JSON array\n- No additional commentary or explanation\n- Ensure valid JSON format\n- Include all required fields for each group\n- Validate that every component appears exactly once\n- Most groups should contain only one component";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { WorkspaceFolder, WorkspaceConfiguration } from "@builder.io/ai-utils";
|
|
2
|
+
import type { DevToolsSys } from "../../types";
|
|
3
|
+
export interface ResolveWorkspacePathOptions {
|
|
4
|
+
filePath: string;
|
|
5
|
+
forceWorkspace?: boolean;
|
|
6
|
+
workspace?: WorkspaceConfiguration;
|
|
7
|
+
workingDirectory: string;
|
|
8
|
+
sys: DevToolsSys;
|
|
9
|
+
canCollapseWorkspace?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ResolveWorkspacePathResult {
|
|
12
|
+
resolvedPath: string;
|
|
13
|
+
workspaceFolder?: WorkspaceFolder;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolves a workspace file path to its actual file system path.
|
|
17
|
+
*
|
|
18
|
+
* This function handles various workspace configurations:
|
|
19
|
+
* - Single workspace named "." (treats paths as direct relative paths)
|
|
20
|
+
* - Multiple workspaces (matches path prefixes to workspace names/folder names)
|
|
21
|
+
* - No workspace configuration (falls back to working directory)
|
|
22
|
+
*
|
|
23
|
+
* @param options Configuration object containing all required parameters
|
|
24
|
+
* @param options.filePath A file path that may include a workspace prefix (e.g., "workspace1/path/to/file.js")
|
|
25
|
+
* @param options.forceWorkspace If true, will try the first workspace as fallback when no workspace folder is found
|
|
26
|
+
* @param options.workspace Optional workspace configuration with folders
|
|
27
|
+
* @param options.workingDirectory The base working directory to resolve paths against
|
|
28
|
+
* @param options.sys DevToolsSys object providing path resolution functions
|
|
29
|
+
* @returns Object containing the resolved file system path and matched workspace folder
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* import { createNodeSys } from '@builder.io/dev-tools/node';
|
|
34
|
+
*
|
|
35
|
+
* const result = resolveWorkspacePath({
|
|
36
|
+
* filePath: 'frontend/src/components/Button.tsx',
|
|
37
|
+
* workingDirectory: '/home/user/project',
|
|
38
|
+
* sys: createNodeSys(),
|
|
39
|
+
* workspace: {
|
|
40
|
+
* folders: [
|
|
41
|
+
* { name: 'frontend', path: './packages/frontend' },
|
|
42
|
+
* { name: 'backend', path: './packages/backend' }
|
|
43
|
+
* ]
|
|
44
|
+
* }
|
|
45
|
+
* });
|
|
46
|
+
* // Returns: {
|
|
47
|
+
* // resolvedPath: '/home/user/project/packages/frontend/src/components/Button.tsx',
|
|
48
|
+
* // workspaceFolder: { name: 'frontend', path: './packages/frontend' }
|
|
49
|
+
* // }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveWorkspacePath(options: ResolveWorkspacePathOptions): ResolveWorkspacePathResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/types/common/utils.d.ts
CHANGED
|
@@ -20,3 +20,9 @@ export declare function shouldSkipFolder(sys: DevToolsSys, skipFolders: Set<stri
|
|
|
20
20
|
export declare function getPackageManager(): string;
|
|
21
21
|
export declare function isWindows(): boolean;
|
|
22
22
|
export declare function builderNpxPackage(): "\"@builder.io/dev-tools\"" | "builder.io";
|
|
23
|
+
/**
|
|
24
|
+
* Sanitizes a component name for use in filesystem paths by replacing invalid characters with underscores
|
|
25
|
+
* @param name The component name to sanitize
|
|
26
|
+
* @returns A sanitized string safe for use in filesystem paths
|
|
27
|
+
*/
|
|
28
|
+
export declare function sanitizeComponentName(name: string): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CreateDevToolsOptions, DevToolsAdapter, DevToolsSys } from "../../../types";
|
|
2
|
+
export declare function createVueDevTools(sys: CreateDevToolsOptions): Promise<DevToolsAdapter>;
|
|
3
|
+
export declare function createVueDevToolsSys(sys: DevToolsSys): Promise<VueDevToolsSys>;
|
|
4
|
+
export interface VueDevToolsSys extends DevToolsSys {
|
|
5
|
+
srcDir: string | null;
|
|
6
|
+
componentsDir: string;
|
|
7
|
+
builderComponentPath: string;
|
|
8
|
+
registryPath: string;
|
|
9
|
+
vueConfigPath: string;
|
|
10
|
+
typescriptEnabled: boolean;
|
|
11
|
+
configType: "webpack" | "vite" | "";
|
|
12
|
+
isNuxt: boolean;
|
|
13
|
+
addExternalPackage: (pkgName: string) => void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { VueDevToolsSys } from "./index";
|
|
2
|
+
import type { EnvInfo } from "../../../types";
|
|
3
|
+
export declare function getVueApiKey(sys: VueDevToolsSys): Promise<EnvInfo>;
|
|
4
|
+
export declare function setVueApiKey(sys: VueDevToolsSys, publicApiKey: string): Promise<EnvInfo>;
|
|
5
|
+
export declare const VUE_VITE_BUILDER_KEY_ENV = "VITE_PUBLIC_BUILDER_KEY";
|
|
6
|
+
export declare const VUE_WEBPACK_BUILDER_KEY_ENV = "PUBLIC_BUILDER_KEY";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { VueDevToolsSys } from "./index";
|
|
2
|
+
import type { ComponentInfo } from "../../../types";
|
|
3
|
+
export declare function parseVueComponent(sys: VueDevToolsSys, filePath: string, readAllInputTypes: boolean): Promise<ComponentInfo | null>;
|
|
4
|
+
export declare function getVueComponentsFromPath(sys: VueDevToolsSys, filePath: string, readAllInputTypes: boolean): Promise<ComponentInfo[] | null>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { VueDevToolsSys } from "./index";
|
|
2
|
+
import type { ModifiedFile } from "../../../types";
|
|
3
|
+
export declare function vueEnsureBuilderSetup(sys: VueDevToolsSys): Promise<{
|
|
4
|
+
errors: string[];
|
|
5
|
+
}>;
|
|
6
|
+
export declare function vueEnsureFigmaImportSetup(sys: VueDevToolsSys): Promise<ModifiedFile[]>;
|
|
7
|
+
export declare function vueEnsureBuilderRegistry(sys: VueDevToolsSys): Promise<ModifiedFile[]>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type ts from "typescript";
|
|
2
|
+
import type { ComponentInfo } from "../../../types";
|
|
3
|
+
import type { VueDevToolsSys } from "./index";
|
|
4
|
+
export declare function parseVueRegistryFromFile(sys: VueDevToolsSys): Promise<{
|
|
5
|
+
sourceFile: ts.SourceFile;
|
|
6
|
+
components: ComponentInfo[];
|
|
7
|
+
}>;
|
|
8
|
+
export declare function parseVueRegistryFromCode(sys: VueDevToolsSys, code: string): Promise<{
|
|
9
|
+
sourceFile: ts.SourceFile;
|
|
10
|
+
components: ComponentInfo[];
|
|
11
|
+
}>;
|
|
12
|
+
export declare function parseRegistryFromSource(sys: VueDevToolsSys, sourceFile: ts.SourceFile): Promise<{
|
|
13
|
+
sourceFile: ts.SourceFile;
|
|
14
|
+
components: ComponentInfo[];
|
|
15
|
+
}>;
|
|
16
|
+
export declare function parseVueRegisteredComponent(sys: VueDevToolsSys, sourceFile: ts.SourceFile, cmpObjLit: ts.Node): Promise<ComponentInfo | null>;
|