builder.io 1.17.27 → 1.17.28
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 +785 -634
- package/cli/index.cjs.map +4 -4
- package/core/index.cjs +1 -1
- package/core/index.mjs +1 -1
- package/node/index.cjs +1 -1
- package/node/index.mjs +1 -1
- package/package.json +1 -1
- package/server/index.cjs +288 -284
- package/server/index.mjs +288 -284
- package/types/cli/code-tools.d.ts +4 -2
- package/types/cli/codegen.d.ts +43 -23
- package/types/cli/mcp-local.d.ts +2 -4
- package/types/cli/utils/agent-discovery.d.ts +22 -0
- package/types/cli/utils/agent-parser.d.ts +41 -0
- package/types/cli/utils/agent-parser.test.d.ts +1 -0
- package/types/cli/utils/browser-testing-agent.d.ts +2 -0
- package/types/cli/utils/codegen-utils.d.ts +70 -0
- package/types/cli/utils/rules-discovery.d.ts +26 -0
- package/types/cli/utils/rules-parser.d.ts +17 -0
- package/types/cli/utils/rules-parser.test.d.ts +1 -0
- package/types/cli/utils/yaml-frontmatter.d.ts +32 -0
- package/types/cli/utils/yaml-frontmatter.test.d.ts +1 -0
- package/types/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { AccessResult, CodeGenPosition, CodeGenTools, CodegenTurn, ContentMessageItemToolResult, FusionConfig, GenerateCompletionStep, Permission, ProjectFile, UserSource, WorkspaceFolder } from "$/ai-utils";
|
|
1
|
+
import type { AccessResult, CodeGenPosition, CodeGenTools, CodegenTurn, ContentMessageItemImage, ContentMessageItemText, ContentMessageItemToolResult, FusionConfig, GenerateCompletionStep, Permission, ProjectFile, UserSource, 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";
|
|
5
|
+
import { CodeGenSession } from "./codegen";
|
|
5
6
|
import type { Credentials } from "./credentials";
|
|
6
7
|
import type { LocalMCPClientManager } from "./mcp-local";
|
|
7
8
|
export interface LLMToolCalls {
|
|
@@ -11,7 +12,7 @@ export interface LLMToolCalls {
|
|
|
11
12
|
abortController: AbortController;
|
|
12
13
|
}
|
|
13
14
|
export interface ToolResolution {
|
|
14
|
-
toolResult: string;
|
|
15
|
+
toolResult: string | (ContentMessageItemText | ContentMessageItemImage)[];
|
|
15
16
|
isError: boolean;
|
|
16
17
|
title?: string;
|
|
17
18
|
}
|
|
@@ -34,6 +35,7 @@ export interface ToolContext extends Partial<FusionContext> {
|
|
|
34
35
|
workingDirectory: string;
|
|
35
36
|
allowedCommands: RegExp[];
|
|
36
37
|
localMCPManager: LocalMCPClientManager | undefined;
|
|
38
|
+
session: CodeGenSession;
|
|
37
39
|
getAllFiles: (options: {
|
|
38
40
|
getDotFiles?: boolean;
|
|
39
41
|
pattern?: string;
|
package/types/cli/codegen.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { DevToolsSys } from "../types";
|
|
2
2
|
import { type Credentials } from "./credentials";
|
|
3
|
-
import type { CodegenFeedback, CodeGenToolMap, CodegenTurn, CustomInstruction, FusionConfig, GenerateCompletionState, GenerateCompletionStep, GenerateCompletionStepGit, GenerateUserMessage, SessionMode, UserContext,
|
|
3
|
+
import type { CodegenFeedback, CodeGenToolMap, CodegenTurn, CustomInstruction, FusionConfig, GenerateCompletionState, GenerateCompletionStep, GenerateCompletionStepGit, GenerateUserMessage, SessionMode, UserContext, UserSource, WorkspaceFolder, LoadWholeSessionOptions, LoadWholeSessionResult, LoadHistoryResult, CodeGenMode, ApplyActionsResult, PrivacyMode, CodeGenPosition, BackupGitRepoResult, PushChangesArgs, CodegenApiResult, CodegenApiTerminal, ConfigureDevOrchestratorOpts, ConfigureDevOrchestratorUpdates, RepoMetrics, SetImportantFilesToolInput, MCPServerConfig, CodegenApiCreateTerminal } from "$/ai-utils";
|
|
4
4
|
import prettier from "prettier";
|
|
5
5
|
import { type FusionContext, type ToolResolution } from "./code-tools";
|
|
6
|
+
import { type SubAgent } from "./utils/agent-discovery";
|
|
6
7
|
import EventEmitter from "node:events";
|
|
7
8
|
import { type RunCommandOptions } from "./utils/git";
|
|
8
9
|
export interface SessionContext {
|
|
9
10
|
sessionId: string;
|
|
10
11
|
turns: CodegenTurn[];
|
|
11
12
|
customInstructions: CustomInstruction[];
|
|
13
|
+
customAgents: SubAgent[];
|
|
12
14
|
userContext: UserContext;
|
|
13
15
|
prettierConfig: prettier.Config | null;
|
|
14
16
|
state: GenerateCompletionState;
|
|
@@ -27,6 +29,10 @@ export interface CodeGenSessionOptionsBase {
|
|
|
27
29
|
mode: CodeGenMode;
|
|
28
30
|
privacyMode?: PrivacyMode;
|
|
29
31
|
builtInCustomInstructions?: CustomInstruction[];
|
|
32
|
+
builtInCustomAgents?: SubAgent[];
|
|
33
|
+
builtInMCPServerConfig?: MCPServerConfig;
|
|
34
|
+
autoImportLocalMCPs?: boolean;
|
|
35
|
+
systemPromptOverride?: string;
|
|
30
36
|
fusionContext?: FusionContext;
|
|
31
37
|
fusionConfig?: FusionConfig;
|
|
32
38
|
workingDirectory?: string;
|
|
@@ -41,6 +47,15 @@ export interface CodeGenSessionOptionsInitialUrl extends CodeGenSessionOptionsBa
|
|
|
41
47
|
initialUrl: string;
|
|
42
48
|
}
|
|
43
49
|
export type CodeGenSessionOptions = CodeGenSessionOptionsSession | CodeGenSessionOptionsInitialUrl;
|
|
50
|
+
export interface SpawnAgentResult {
|
|
51
|
+
success: boolean;
|
|
52
|
+
response: string;
|
|
53
|
+
importantFiles: SetImportantFilesToolInput;
|
|
54
|
+
lastTurn?: CodegenTurn;
|
|
55
|
+
}
|
|
56
|
+
export { type SubAgent } from "./utils/agent-discovery";
|
|
57
|
+
export { resolveModelShortcut } from "./utils/agent-parser";
|
|
58
|
+
export { getCustomAgents } from "./utils/agent-discovery";
|
|
44
59
|
export type CodeGenEventEmitter = EventEmitter<{
|
|
45
60
|
step: [GenerateCompletionStep];
|
|
46
61
|
idle: [];
|
|
@@ -61,6 +76,21 @@ export declare class CodeGenSession {
|
|
|
61
76
|
loadWholeSession(opts?: LoadWholeSessionOptions): Promise<LoadWholeSessionResult>;
|
|
62
77
|
loadMoreTurns(): Promise<CodegenTurn[]>;
|
|
63
78
|
setCustomInstructions(instructions: CustomInstruction[]): Promise<void>;
|
|
79
|
+
setCustomAgents(agents: SubAgent[]): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Spawn a named custom agent by ID or name
|
|
82
|
+
* @param agentNameOrId - The agent's name or ID
|
|
83
|
+
* @param options - Additional spawning options
|
|
84
|
+
* @returns SpawnAgentResult
|
|
85
|
+
*/
|
|
86
|
+
spawnNamedAgent(agentName: string | undefined, options: {
|
|
87
|
+
prompt: string;
|
|
88
|
+
user: UserSource;
|
|
89
|
+
onStep?: (step: GenerateCompletionStep) => void;
|
|
90
|
+
signal?: AbortSignal;
|
|
91
|
+
maxCompletions?: number;
|
|
92
|
+
sessionId?: string;
|
|
93
|
+
}): Promise<SpawnAgentResult>;
|
|
64
94
|
pushRepoV2(repoInfo: {
|
|
65
95
|
repoFullName: string;
|
|
66
96
|
repoUrl: string;
|
|
@@ -198,6 +228,18 @@ export declare class CodeGenSession {
|
|
|
198
228
|
waitUntilState(state: GenerateCompletionState, timeout?: number): Promise<void>;
|
|
199
229
|
clearSession(): Promise<void>;
|
|
200
230
|
sendMessage(message: GenerateUserMessage): Promise<void>;
|
|
231
|
+
spawnAgent(options: {
|
|
232
|
+
prompt: string;
|
|
233
|
+
user: UserSource;
|
|
234
|
+
onStep?: (step: GenerateCompletionStep) => void;
|
|
235
|
+
signal?: AbortSignal;
|
|
236
|
+
maxCompletions?: number;
|
|
237
|
+
sessionId?: string;
|
|
238
|
+
tools?: string[];
|
|
239
|
+
model?: string;
|
|
240
|
+
mode?: CodeGenMode;
|
|
241
|
+
systemPrompt?: string;
|
|
242
|
+
}): Promise<SpawnAgentResult>;
|
|
201
243
|
getTurns(): CodegenTurn[];
|
|
202
244
|
getSessionContext(): SessionContext;
|
|
203
245
|
runSetupCommand(): Promise<import("$/ai-utils").SetupCommandResult | undefined>;
|
|
@@ -363,25 +405,3 @@ export declare class CodeGenSession {
|
|
|
363
405
|
*/
|
|
364
406
|
private getDiffFromParentBranch;
|
|
365
407
|
}
|
|
366
|
-
export declare function getUserContext(sys: DevToolsSys, gitWorkingDirectory?: string): Promise<UserContext>;
|
|
367
|
-
export declare function makeAsyncIterator<T>(): readonly [AsyncGenerator<T, void, void>, (event: T) => void, () => void];
|
|
368
|
-
/**
|
|
369
|
-
* Loads a workspace configuration from a JSON file
|
|
370
|
-
* @param sys DevToolsSys instance
|
|
371
|
-
* @param workspaceFile Path to the workspace JSON file
|
|
372
|
-
* @returns The workspace configuration and working directory
|
|
373
|
-
*/
|
|
374
|
-
export declare function loadWorkspace(sys: DevToolsSys, workspaceFile: string): Promise<{
|
|
375
|
-
workspace: WorkspaceConfiguration;
|
|
376
|
-
workingDirectory: string;
|
|
377
|
-
}>;
|
|
378
|
-
export declare function keepAlive(): () => void;
|
|
379
|
-
export declare class BashError extends Error {
|
|
380
|
-
readonly code: number | string | undefined;
|
|
381
|
-
readonly stdout: string;
|
|
382
|
-
readonly stderr: string;
|
|
383
|
-
readonly command: string;
|
|
384
|
-
constructor(command: string, code: number | string | undefined, stdout: string, stderr: string, opts?: {
|
|
385
|
-
cause?: Error;
|
|
386
|
-
});
|
|
387
|
-
}
|
package/types/cli/mcp-local.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - Tools are prefixed with server name: `mcp__servername__toolname`
|
|
9
9
|
* - This prevents conflicts with built-in tools and other MCP tools
|
|
10
10
|
*/
|
|
11
|
-
import type { MCPClientStatus } from "$/ai-utils";
|
|
11
|
+
import type { MCPClientStatus, MCPServerConfig } from "$/ai-utils";
|
|
12
12
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
13
13
|
import type { DevToolsSys } from "../core";
|
|
14
14
|
import { type ChildProcess } from "child_process";
|
|
@@ -76,6 +76,4 @@ export declare function applyEnvSubstitution(serverConfig: Omit<MCPServerStdioDe
|
|
|
76
76
|
* Servers from fusionConfig will be merged with servers from mcp.json
|
|
77
77
|
* If a server with the same name exists in both, fusionConfig takes precedence
|
|
78
78
|
*/
|
|
79
|
-
export declare function loadMCPConfig(sys: DevToolsSys, workingDirectory: string,
|
|
80
|
-
mcpServers?: Record<string, Omit<MCPServerStdioDefinition, "name">>;
|
|
81
|
-
}): Promise<MCPServerStdioDefinition[]>;
|
|
79
|
+
export declare function loadMCPConfig(sys: DevToolsSys, workingDirectory: string, serverConfigs: MCPServerConfig, autoImportLocalMCPs: boolean): Promise<MCPServerStdioDefinition[]>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent discovery utilities
|
|
3
|
+
* Handles finding and loading custom agent definitions from the filesystem
|
|
4
|
+
*/
|
|
5
|
+
import type { DevToolsSys } from "../../types";
|
|
6
|
+
import { type SubAgent } from "./agent-parser";
|
|
7
|
+
export type { SubAgent };
|
|
8
|
+
/**
|
|
9
|
+
* Get custom agents from the filesystem
|
|
10
|
+
* Searches for agent definitions in .claude/agents, .builder/agents, and .cursor/agents
|
|
11
|
+
* @param sys - System utilities
|
|
12
|
+
* @param projectDir - Project directory (used for relative paths)
|
|
13
|
+
* @param currentDir - Starting directory for search
|
|
14
|
+
* @param rootDir - Root directory to stop search
|
|
15
|
+
* @returns Array of discovered agents
|
|
16
|
+
*/
|
|
17
|
+
export declare function getCustomAgents({ sys, projectDir, currentDir, rootDir, }: {
|
|
18
|
+
sys: DevToolsSys;
|
|
19
|
+
projectDir: string;
|
|
20
|
+
currentDir: string;
|
|
21
|
+
rootDir: string;
|
|
22
|
+
}): Promise<SubAgent[]>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent definition parsing utilities
|
|
3
|
+
* Handles parsing of custom agent definition files
|
|
4
|
+
*/
|
|
5
|
+
import type { CodeGenMode } from "$/ai-utils";
|
|
6
|
+
export interface SubAgent {
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
systemPrompt?: string;
|
|
10
|
+
tools?: string[];
|
|
11
|
+
model?: string;
|
|
12
|
+
mode?: CodeGenMode;
|
|
13
|
+
filePath?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolves model shortcut to full model name
|
|
17
|
+
* @param modelOrShortcut - Model name or shortcut
|
|
18
|
+
* @returns Resolved model name or undefined
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveModelShortcut(modelOrShortcut?: string): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Parses an agent definition file (Markdown with YAML frontmatter)
|
|
23
|
+
* Expected format (following Claude Code sub-agents format):
|
|
24
|
+
* ```yaml
|
|
25
|
+
* ---
|
|
26
|
+
* name: Agent Name
|
|
27
|
+
* description: Description of what the agent does
|
|
28
|
+
* model: sonnet # Optional: supports shortcuts like sonnet, opus, haiku, mini
|
|
29
|
+
* tools: # Optional: list of tools to enable
|
|
30
|
+
* - Read
|
|
31
|
+
* - Grep
|
|
32
|
+
* - WebSearch
|
|
33
|
+
* mode: quality-v4-agent # Optional: agent mode
|
|
34
|
+
* ---
|
|
35
|
+
* System prompt content here (Markdown)
|
|
36
|
+
* ```
|
|
37
|
+
* @param fileContent - The raw file content
|
|
38
|
+
* @param filePath - The file path (used for fallback name)
|
|
39
|
+
* @returns Parsed SubAgent or null if parsing fails
|
|
40
|
+
*/
|
|
41
|
+
export declare function parseAgentFile(fileContent: string, filePath: string): SubAgent | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { DevToolsSys } from "../../core";
|
|
2
|
+
import { type Credentials } from "../credentials";
|
|
3
|
+
export { getCustomInstructions } from "./rules-discovery";
|
|
4
|
+
import type { CodeGenInputOptions, CodegenSetLastCompletion, CodegenTurn, GenerateCodeEvent, GenerateUserMessage, GetSessionTurnsResult, UserContext, WorkspaceConfiguration, EnvironmentVariable, PushChangesArgs } from "$/ai-utils";
|
|
5
|
+
import type { SessionContext } from "../codegen";
|
|
6
|
+
export declare const DEFAULT_MAX_COMPLETIONS = 30;
|
|
7
|
+
/**
|
|
8
|
+
* Merges and deduplicates items by name.
|
|
9
|
+
* Built-in items come first, discovered items can override them by name.
|
|
10
|
+
* @param builtIn - Built-in items
|
|
11
|
+
* @param discovered - Discovered items from project
|
|
12
|
+
* @returns Deduplicated array with discovered overriding built-in
|
|
13
|
+
*/
|
|
14
|
+
export declare function mergeByName<T extends {
|
|
15
|
+
name: string;
|
|
16
|
+
}>(builtIn: T[], discovered: T[]): T[];
|
|
17
|
+
export declare function getLastGoodTurn(sessionContext: SessionContext): CodegenTurn | undefined;
|
|
18
|
+
export declare function getLastUserTurn(sessionContext: SessionContext): CodegenTurn | undefined;
|
|
19
|
+
export declare function getLastApplyResultsTurn(sessionContext: SessionContext): CodegenTurn | undefined;
|
|
20
|
+
export declare function getLastOne<T>(array: T[]): T | undefined;
|
|
21
|
+
export declare function inPlaceRemovePendingTurns(turns: CodegenTurn[]): void;
|
|
22
|
+
export declare function restoreConsumedCredit(sys: DevToolsSys, credentials: Credentials, sessionId: string, restoreCredits: number): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Analyzes the payload to identify what's making it large
|
|
25
|
+
*/
|
|
26
|
+
export declare function analyzePayloadBreakdown(body: CodeGenInputOptions, jsonString: string): Record<string, any>;
|
|
27
|
+
export declare function completionStream(sys: DevToolsSys, credentials: Credentials, body: CodeGenInputOptions, signal: AbortSignal): AsyncGenerator<GenerateCodeEvent, void, unknown>;
|
|
28
|
+
export declare function codegenEndpoint(sys: DevToolsSys, credentials: Credentials, endpoint: string, body: Record<string, any>): Promise<boolean>;
|
|
29
|
+
export declare function setLastCompletionOfSession(sys: DevToolsSys, credentials: Credentials, data: CodegenSetLastCompletion, _verbose: boolean): Promise<boolean>;
|
|
30
|
+
export declare function getTurnsBySessionId(sys: DevToolsSys, credentials: Credentials, sessionId: string, linear: boolean, completionIdCursor?: string): Promise<GetSessionTurnsResult>;
|
|
31
|
+
export declare const parseCLIURL: (url: string | undefined) => {
|
|
32
|
+
id: undefined;
|
|
33
|
+
isInitial: boolean;
|
|
34
|
+
} | {
|
|
35
|
+
isInitial: boolean;
|
|
36
|
+
id: string;
|
|
37
|
+
};
|
|
38
|
+
export declare function getUserContext(sys: DevToolsSys, gitWorkingDirectory?: string): Promise<UserContext>;
|
|
39
|
+
export declare function makeAsyncIterator<T>(): readonly [AsyncGenerator<T, void, void>, (event: T) => void, () => void];
|
|
40
|
+
export declare function isAGENTSFile(filePath: string): boolean;
|
|
41
|
+
export declare function isBaseImportantFile(filePath: string): boolean;
|
|
42
|
+
export declare function hasBuildError(text: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Loads a workspace configuration from a JSON file
|
|
45
|
+
* @param sys DevToolsSys instance
|
|
46
|
+
* @param workspaceFile Path to the workspace JSON file
|
|
47
|
+
* @returns The workspace configuration and working directory
|
|
48
|
+
*/
|
|
49
|
+
export declare function loadWorkspace(sys: DevToolsSys, workspaceFile: string): Promise<{
|
|
50
|
+
workspace: WorkspaceConfiguration;
|
|
51
|
+
workingDirectory: string;
|
|
52
|
+
}>;
|
|
53
|
+
export declare function mergeUserMessages(currentMessage: GenerateUserMessage, newMessage: GenerateUserMessage): GenerateUserMessage;
|
|
54
|
+
export declare function keepAlive(): () => void;
|
|
55
|
+
export declare function parseAheadBehind(line: string): {
|
|
56
|
+
ahead: number;
|
|
57
|
+
behind: number;
|
|
58
|
+
};
|
|
59
|
+
export declare class BashError extends Error {
|
|
60
|
+
readonly code: number | string | undefined;
|
|
61
|
+
readonly stdout: string;
|
|
62
|
+
readonly stderr: string;
|
|
63
|
+
readonly command: string;
|
|
64
|
+
constructor(command: string, code: number | string | undefined, stdout: string, stderr: string, opts?: {
|
|
65
|
+
cause?: Error;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export declare function mergeEnvironmentVariables(envVariables: EnvironmentVariable[], extraEnvVariables: EnvironmentVariable[]): EnvironmentVariable[];
|
|
69
|
+
export declare function processPushChangesArgs(opts: PushChangesArgs): import("$/ai-utils").PushChangesOptions;
|
|
70
|
+
export declare function getErrorMessage(err: unknown): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom instruction/rules discovery utilities
|
|
3
|
+
* Handles finding and loading custom instructions from the filesystem
|
|
4
|
+
*/
|
|
5
|
+
import type { DevToolsSys } from "../../types";
|
|
6
|
+
import type { CustomInstruction } from "$/ai-utils";
|
|
7
|
+
/**
|
|
8
|
+
* Get custom instructions from the filesystem
|
|
9
|
+
* Searches for instruction files in:
|
|
10
|
+
* - .cursor/rules/
|
|
11
|
+
* - .builder/rules/
|
|
12
|
+
* - .cursorrules, .builderrules, .windsurfrules
|
|
13
|
+
* - .github/copilot-instructions.md
|
|
14
|
+
*
|
|
15
|
+
* @param sys - System utilities
|
|
16
|
+
* @param projectDir - Project directory (used for relative paths)
|
|
17
|
+
* @param currentDir - Starting directory for search
|
|
18
|
+
* @param rootDir - Root directory to stop search
|
|
19
|
+
* @returns Array of discovered custom instructions
|
|
20
|
+
*/
|
|
21
|
+
export declare function getCustomInstructions({ sys, projectDir, currentDir, rootDir, }: {
|
|
22
|
+
sys: DevToolsSys;
|
|
23
|
+
projectDir: string;
|
|
24
|
+
currentDir: string;
|
|
25
|
+
rootDir: string;
|
|
26
|
+
}): Promise<CustomInstruction[]>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom instruction/rules parsing utilities
|
|
3
|
+
* Handles parsing of custom instruction files (.mdc, .cursorrules, etc.)
|
|
4
|
+
*/
|
|
5
|
+
import type { CustomInstruction } from "$/ai-utils";
|
|
6
|
+
/**
|
|
7
|
+
* Parse a custom instruction file
|
|
8
|
+
* Supports both:
|
|
9
|
+
* - .mdc files with YAML frontmatter
|
|
10
|
+
* - Plain text files (.cursorrules, .builderrules, etc.)
|
|
11
|
+
*
|
|
12
|
+
* @param fileContent - Raw file content
|
|
13
|
+
* @param filePath - File path (for generating name and id)
|
|
14
|
+
* @param hashFunction - Optional hash function for generating unique IDs
|
|
15
|
+
* @returns Parsed CustomInstruction or null
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseCustomInstructionFile(fileContent: string, filePath: string, hashFunction?: (content: string) => string): CustomInstruction | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic YAML frontmatter parser for Markdown files
|
|
3
|
+
* Supports both simple key-value pairs and arrays
|
|
4
|
+
*/
|
|
5
|
+
export interface YamlFrontmatterResult<T = Record<string, any>> {
|
|
6
|
+
frontmatter: T;
|
|
7
|
+
body: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Checks if content has YAML frontmatter
|
|
11
|
+
*/
|
|
12
|
+
export declare function hasYamlFrontmatter(content: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Parses YAML frontmatter from a string
|
|
15
|
+
* Handles simple YAML: key-value pairs, arrays, and comments
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseYamlFrontmatter(yamlContent: string): Record<string, any>;
|
|
18
|
+
/**
|
|
19
|
+
* Extracts YAML frontmatter and body from Markdown content
|
|
20
|
+
* @param content - The raw Markdown content with frontmatter
|
|
21
|
+
* @returns Object with frontmatter and body, or null if no frontmatter found
|
|
22
|
+
*/
|
|
23
|
+
export declare function extractYamlFrontmatter(content: string): {
|
|
24
|
+
frontmatterContent: string;
|
|
25
|
+
body: string;
|
|
26
|
+
} | null;
|
|
27
|
+
/**
|
|
28
|
+
* Parse Markdown file with YAML frontmatter
|
|
29
|
+
* @param content - The raw file content
|
|
30
|
+
* @returns Parsed frontmatter and body
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseMarkdownWithYaml<T = Record<string, any>>(content: string): YamlFrontmatterResult<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|