@builder.io/dev-tools 1.32.1-dev.202603131244.00dcaa12e → 1.32.1-dev.202603131340.b521e1bad

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.
Files changed (40) hide show
  1. package/cli/index.cjs +1166 -1233
  2. package/cli/index.cjs.map +4 -4
  3. package/core/index.cjs +1 -1
  4. package/core/index.mjs +1 -1
  5. package/node/index.cjs +1 -1
  6. package/node/index.mjs +1 -1
  7. package/package.json +1 -1
  8. package/server/index.cjs +241 -70
  9. package/server/index.mjs +241 -70
  10. package/types/cli/code-tools.d.ts +2 -0
  11. package/types/cli/codegen.d.ts +0 -3
  12. package/types/cli/launch/InitStateMachine.d.ts +0 -2
  13. package/types/cli/mcp-local.d.ts +2 -2
  14. package/types/cli/utils/codegen-utils.d.ts +0 -1
  15. package/types/cli/utils/git.d.ts +0 -1
  16. package/types/common/logger.d.ts +97 -0
  17. package/types/core/component-map-builder.d.ts +42 -0
  18. package/types/server/source-map-resolver/cache.d.ts +36 -0
  19. package/types/server/source-map-resolver/indexed-map-resolver.d.ts +10 -0
  20. package/types/server/source-map-resolver/loader.d.ts +16 -0
  21. package/types/server/source-map-resolver/security.d.ts +21 -0
  22. package/types/server/source-map-resolver/types.d.ts +41 -0
  23. package/types/server/source-map-resolver/validation.d.ts +16 -0
  24. package/types/server/source-map-resolver.d.ts +25 -0
  25. package/types/tsconfig.tsbuildinfo +1 -1
  26. package/types/_tests_/per-repo-gh-token.test.d.ts +0 -1
  27. package/types/cli/codegen-git-snapshot.test.d.ts +0 -1
  28. package/types/cli/repo-indexing.d.ts +0 -17
  29. package/types/cli/repo-indexing.mock.d.ts +0 -5
  30. package/types/cli/utils/git-snapshot.d.ts +0 -17
  31. package/types/cli/utils/git-snapshot.test.d.ts +0 -1
  32. package/types/cli/utils/repo-indexing-group-prompts.d.ts +0 -1
  33. package/types/scripts/analyze-projects.d.ts +0 -18
  34. package/types/scripts/call-ensure-container.d.ts +0 -4
  35. package/types/scripts/check-backup.d.ts +0 -1
  36. package/types/scripts/cli.d.ts +0 -1
  37. package/types/scripts/download-projects.d.ts +0 -12
  38. package/types/scripts/utils/db.d.ts +0 -3
  39. package/types/scripts/utils/ensure-container.d.ts +0 -7
  40. package/types/scripts/utils/remove-machine-and-volume.d.ts +0 -5
@@ -4,6 +4,7 @@ import { type DevServerOrchestrator } from "./launch/dev-server-orchestrator";
4
4
  import type { CodeGenEventEmitter } from "./codegen";
5
5
  import { CodeGenSession } from "./codegen";
6
6
  import type { Credentials } from "./credentials";
7
+ import type { Logger } from "../common/logger";
7
8
  import type { LocalMCPClientManager } from "./mcp-local";
8
9
  import type { createFusionStatusMonitor } from "./launch/machine-health";
9
10
  export interface LLMToolCalls {
@@ -20,6 +21,7 @@ export interface ToolResolution {
20
21
  }
21
22
  export interface ToolContext {
22
23
  debug: boolean;
24
+ logger: Logger;
23
25
  sys: DevToolsSys;
24
26
  credentials: Credentials;
25
27
  asyncSubAgents: boolean;
@@ -62,8 +62,6 @@ export interface CodeGenSessionOptionsBase {
62
62
  includeMemories?: boolean;
63
63
  fusionStatusMonitor?: FusionStatusMonitor;
64
64
  asyncSubAgents?: boolean;
65
- /** Per-repo GitHub tokens from init phase (relative repo path → token) */
66
- initialRepoTokens?: ReadonlyMap<string, string>;
67
65
  }
68
66
  export interface CodeGenSessionOptionsSession extends CodeGenSessionOptionsBase {
69
67
  sessionOrCompletionId?: string;
@@ -98,7 +96,6 @@ export declare class CodeGenSession {
98
96
  get gitEnabledFolders(): WorkspaceFolder[];
99
97
  /** Returns runtime git repo contexts for all enabled repos */
100
98
  get gitRepoContexts(): readonly GitRepoContext[];
101
- getGhTokenForPath(workingDir: string): string | undefined;
102
99
  get workingDirectory(): string;
103
100
  get bashWorkingDirectory(): string;
104
101
  getSessionMode(): SessionMode;
@@ -88,8 +88,6 @@ export declare class InitStateMachine {
88
88
  private initializeGitRepo;
89
89
  private fetchGitConfigsOnce;
90
90
  private applyGitConfig;
91
- /** Returns a read-only view of the per-repo token map (path → token). */
92
- get repoTokenMap(): ReadonlyMap<string, string>;
93
91
  runInitializationCommand({ repo, tempCloningDir, repoPath, initCommand, }: {
94
92
  repo: ValidatedWorkspaceFolder;
95
93
  tempCloningDir: string;
@@ -74,7 +74,7 @@ export interface LocalMCPClientManager {
74
74
  /**
75
75
  * Create a local MCP client manager from server definitions
76
76
  */
77
- export declare function createLocalMCPClientManager(servers: MCPServerDefinition[], sys: DevToolsSys, workingDirectory: string, debug: boolean, signal?: AbortSignal): Promise<LocalMCPClientManager>;
77
+ export declare function createLocalMCPClientManager(servers: MCPServerDefinition[], sys: DevToolsSys, workingDirectory: string, signal?: AbortSignal): Promise<LocalMCPClientManager>;
78
78
  /**
79
79
  * Apply environment variable substitution to MCP server configuration
80
80
  * This is separated from loadMCPConfig to allow easy unit testing
@@ -91,4 +91,4 @@ export declare function applyEnvSubstitutionRemote(serverConfig: Omit<MCPServerR
91
91
  * If a server with the same name exists in both, fusionConfig takes precedence
92
92
  * Supports both stdio (command-based) and remote (http/sse) server definitions
93
93
  */
94
- export declare function loadMCPConfig(sys: DevToolsSys, workingDirectory: string, serverConfigs: MCPServerConfig, autoImportLocalMCPs: boolean, debug?: boolean, signal?: AbortSignal): Promise<MCPServerDefinition[]>;
94
+ export declare function loadMCPConfig(sys: DevToolsSys, workingDirectory: string, serverConfigs: MCPServerConfig, autoImportLocalMCPs: boolean, signal?: AbortSignal): Promise<MCPServerDefinition[]>;
@@ -95,5 +95,4 @@ export declare function generateGitStatusReminder(gitStatus: GenerateCompletionS
95
95
  trigger: "session-start" | "sync-success" | "push-success" | "pull-success";
96
96
  syncedBranches?: string[];
97
97
  pushedToRemote?: boolean;
98
- hasGhToken?: boolean;
99
98
  }): string;
@@ -3,7 +3,6 @@ import type { Credentials } from "../credentials";
3
3
  import type { GitConfigs, GitDiagnostics } from "$/ai-utils";
4
4
  export interface RunCommandOptions {
5
5
  cwd?: string;
6
- debug?: boolean;
7
6
  sys: DevToolsSys;
8
7
  timeout?: number;
9
8
  skipLogging?: boolean;
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Structured logger for dev-tools.
3
+ *
4
+ * ## Enabling debug logs
5
+ *
6
+ * Debug output is **off by default**. Two ways to turn it on:
7
+ *
8
+ * ### 1. `DEBUG` environment variable
9
+ *
10
+ * Set to any truthy value to enable debug output for all loggers:
11
+ *
12
+ * ```sh
13
+ * DEBUG=1 npx @builder.io/dev-tools ...
14
+ * ```
15
+ *
16
+ * ### 2. `--debug` CLI flag
17
+ *
18
+ * Sets `process.env.DEBUG = "1"` early in the CLI entry point, enabling
19
+ * debug output for all loggers (including module-level ones created at
20
+ * import time, since `DEBUG` is checked lazily at call time).
21
+ *
22
+ * ```sh
23
+ * npx @builder.io/dev-tools --debug ...
24
+ * ```
25
+ *
26
+ * ### `LOG_LEVEL` environment variable
27
+ *
28
+ * Controls the minimum severity for `info`, `warn`, and `error` messages.
29
+ * Accepted values: `debug`, `info` (default), `warn`, `error`.
30
+ *
31
+ * `LOG_LEVEL` does **not** affect `debug()` output — debug messages are
32
+ * controlled exclusively by the `DEBUG` env var / `--debug` CLI flag.
33
+ * This is intentional: debug is an explicit opt-in, and the default
34
+ * `LOG_LEVEL=info` must not silently suppress explicitly requested output.
35
+ *
36
+ * ```sh
37
+ * DEBUG=1 npx @builder.io/dev-tools ... # debug + info/warn/error
38
+ * LOG_LEVEL=error npx @builder.io/dev-tools ... # errors only (no debug)
39
+ * LOG_LEVEL=warn DEBUG=1 npx @builder.io/dev-tools ... # debug + warn/error
40
+ * ```
41
+ *
42
+ * ### Per-call options (`loggerOptions`)
43
+ *
44
+ * Any log method accepts an optional trailing `{ loggerOptions: { ... } }`
45
+ * argument with:
46
+ *
47
+ * - `debug: true` — only emit this call when debug mode is enabled.
48
+ * Useful for error/warn/info calls that should only appear during
49
+ * debugging (e.g. stack traces, verbose diagnostics).
50
+ * - `stderr: true` — force output to stderr even for methods that
51
+ * normally write to stdout (debug, info). Useful when stdout is
52
+ * reserved for a protocol (e.g. MCP stdio JSON-RPC).
53
+ *
54
+ * ```ts
55
+ * logger.error("Stack trace:", err.stack, { loggerOptions: { debug: true } });
56
+ * logger.info("Server running on stdio", { loggerOptions: { stderr: true } });
57
+ * ```
58
+ *
59
+ * ### Cloud environments
60
+ *
61
+ * When `FUSION_ENVIRONMENT` is `cloud` or `cloud-v2`, all output is emitted
62
+ * as newline-delimited JSON (GCP Cloud Logging compatible) with `severity`,
63
+ * `message`, `timestamp`, and optional `context` fields. The `stderr` option
64
+ * controls which stream is used but does not affect the `severity` field —
65
+ * GCP reads severity from the JSON payload, not from the stream.
66
+ */
67
+ type LogLevel = "debug" | "info" | "warn" | "error";
68
+ export interface LogCallOptions {
69
+ /** Force output to stderr (useful when stdout is reserved, e.g. MCP stdio). */
70
+ stderr?: boolean;
71
+ /** Only emit this call when debug mode is enabled on the logger. */
72
+ debug?: boolean;
73
+ }
74
+ interface LogCallOptionsWrapper {
75
+ loggerOptions: LogCallOptions;
76
+ }
77
+ export interface Logger {
78
+ debug(...args: [...any[], LogCallOptionsWrapper]): void;
79
+ debug(...args: any[]): void;
80
+ info(...args: [...any[], LogCallOptionsWrapper]): void;
81
+ info(...args: any[]): void;
82
+ warn(...args: [...any[], LogCallOptionsWrapper]): void;
83
+ warn(...args: any[]): void;
84
+ error(...args: [...any[], LogCallOptionsWrapper]): void;
85
+ error(...args: any[]): void;
86
+ }
87
+ export interface CreateLoggerOptions {
88
+ /**
89
+ * Enable debug output. Accepts a static boolean or a lazy `() => boolean`
90
+ * for runtime checks (e.g. checking multiple env vars). When omitted,
91
+ * defaults to checking `process.env.DEBUG` lazily at call time.
92
+ */
93
+ debug?: boolean | (() => boolean);
94
+ level?: LogLevel;
95
+ }
96
+ export declare function createLogger(context?: string, options?: CreateLoggerOptions): Logger;
97
+ export {};
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Component Map Builder
3
+ *
4
+ * Builds a map of component names to their source file locations for the Design tab.
5
+ * This allows the Design tab to work without requiring React's _debugSource or customer plugins.
6
+ */
7
+ import type { DevToolsSys } from "../types";
8
+ export interface ComponentLocation {
9
+ file: string;
10
+ line: number;
11
+ column: number;
12
+ displayName: string;
13
+ }
14
+ export type ComponentMap = Record<string, ComponentLocation[]>;
15
+ /**
16
+ * Build a map of component names to their source locations
17
+ */
18
+ export declare function buildComponentMap(sys: DevToolsSys, rootDir?: string): Promise<ComponentMap>;
19
+ /**
20
+ * Cache for component map with file watching
21
+ */
22
+ export declare class ComponentMapCache {
23
+ private cache;
24
+ private lastBuilt;
25
+ private building;
26
+ private readonly ttl;
27
+ private sys;
28
+ private rootDir;
29
+ constructor(sys: DevToolsSys, rootDir?: string);
30
+ /**
31
+ * Get the component map, building it if necessary
32
+ */
33
+ get(): Promise<ComponentMap>;
34
+ /**
35
+ * Invalidate the cache
36
+ */
37
+ invalidate(): void;
38
+ /**
39
+ * Force rebuild of the component map
40
+ */
41
+ rebuild(): Promise<ComponentMap>;
42
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * LRU cache for source maps and TraceMap instances
3
+ */
4
+ import { TraceMap } from "@jridgewell/trace-mapping";
5
+ import type { SourceMapV3 } from "./types";
6
+ interface CachedSourceMap {
7
+ json: SourceMapV3;
8
+ /** TraceMap instances keyed by section index (-1 for non-indexed maps) */
9
+ tracers: Map<number, TraceMap>;
10
+ }
11
+ /**
12
+ * Get or create cache key from bundled path and source mapping URL
13
+ */
14
+ export declare function getCacheKey(bundledPath: string, sourceMappingURL: string): string;
15
+ /**
16
+ * Get cached source map data
17
+ * Returns undefined if not cached, null if cached as failed
18
+ */
19
+ export declare function getCached(key: string): CachedSourceMap | null | undefined;
20
+ /**
21
+ * Cache a successfully loaded source map
22
+ */
23
+ export declare function setCached(key: string, json: SourceMapV3): CachedSourceMap;
24
+ /**
25
+ * Cache a failed load attempt (negative caching)
26
+ */
27
+ export declare function setCachedFailure(key: string): void;
28
+ /**
29
+ * Get or create a TraceMap for a specific section (or -1 for non-indexed)
30
+ */
31
+ export declare function getOrCreateTracer(entry: CachedSourceMap, sectionIndex: number, mapJson: SourceMapV3): TraceMap;
32
+ /**
33
+ * Clear all cached data
34
+ */
35
+ export declare function clearCache(): void;
36
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Utilities for handling indexed source maps (section maps)
3
+ */
4
+ import type { SourceMapSection, SectionMatch } from "./types";
5
+ /**
6
+ * Find the section containing a given position in an indexed source map.
7
+ * Sections are ordered by offset, so we find the last one that starts
8
+ * at or before the target position.
9
+ */
10
+ export declare function findMatchingSection(sections: SourceMapSection[], line: number, column: number): SectionMatch | null;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * File and source map loading utilities
3
+ */
4
+ import type { ResolveContext } from "./types";
5
+ /**
6
+ * Extract sourceMappingURL from JS file content
7
+ */
8
+ export declare function extractSourceMappingURL(content: string): string | null;
9
+ /**
10
+ * Load JS file content from dev server or filesystem
11
+ */
12
+ export declare function loadJSContent(ctx: ResolveContext, bundledPath: string, isServerChunk: boolean): Promise<string | null>;
13
+ /**
14
+ * Load source map content from various sources
15
+ */
16
+ export declare function loadSourceMapContent(ctx: ResolveContext, bundledPath: string, sourceMappingURL: string): Promise<string | null>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Security utilities for path validation and sanitization
3
+ */
4
+ /**
5
+ * Check if a resolved path is safely within the project root.
6
+ * Prevents sibling directory access (e.g., /project-sensitive when root is /project)
7
+ */
8
+ export declare function isPathWithinRoot(filePath: string, rootPath: string): boolean;
9
+ /**
10
+ * Sanitize and validate a bundled path input.
11
+ * Returns decoded path or null if invalid.
12
+ */
13
+ export declare function sanitizeBundledPath(bundledPath: string): string | null;
14
+ /**
15
+ * Check if a chunk filename is definitely internal (not user code)
16
+ */
17
+ export declare function isDefinitelyInternalChunk(filename: string): boolean;
18
+ /**
19
+ * Check if a resolved source path is framework code
20
+ */
21
+ export declare function isFrameworkCode(sourcePath: string): boolean;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Shared types for source map resolution
3
+ */
4
+ export interface OriginalPosition {
5
+ source: string;
6
+ line: number;
7
+ column: number;
8
+ name?: string;
9
+ }
10
+ /**
11
+ * Source Map v3 JSON structure
12
+ * Based on: https://sourcemaps.info/spec.html
13
+ */
14
+ export interface SourceMapV3 {
15
+ version: number;
16
+ file?: string;
17
+ sourceRoot?: string;
18
+ sources?: string[];
19
+ sourcesContent?: (string | null)[];
20
+ names?: string[];
21
+ mappings?: string;
22
+ sections?: SourceMapSection[];
23
+ }
24
+ export interface SourceMapSection {
25
+ offset: {
26
+ line: number;
27
+ column: number;
28
+ };
29
+ map?: SourceMapV3;
30
+ url?: string;
31
+ }
32
+ export interface ResolveContext {
33
+ projectRoot: string;
34
+ devServerUrl: string;
35
+ }
36
+ export interface SectionMatch {
37
+ section: SourceMapSection;
38
+ index: number;
39
+ relativeLine: number;
40
+ relativeColumn: number;
41
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Source map validation utilities
3
+ */
4
+ import type { SourceMapV3 } from "./types";
5
+ export interface ValidationResult {
6
+ valid: boolean;
7
+ error?: string;
8
+ }
9
+ /**
10
+ * Validate a source map v3 structure
11
+ */
12
+ export declare function validateSourceMap(json: unknown): ValidationResult;
13
+ /**
14
+ * Clean up source map structure before processing
15
+ */
16
+ export declare function prepareSourceMap(json: SourceMapV3): SourceMapV3;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Server-side source map resolution using @jridgewell/trace-mapping
3
+ * Fetches bundled files from dev server and resolves to original source locations
4
+ */
5
+ import type { OriginalPosition } from "./source-map-resolver/types";
6
+ import { clearCache } from "./source-map-resolver/cache";
7
+ export type { OriginalPosition };
8
+ export { clearCache as clearSourceMapCache };
9
+ /**
10
+ * Resolve a bundled file location to its original source location
11
+ * @param projectRoot Root directory of the project (for file fallback)
12
+ * @param devServerUrl Base URL of the dev server (e.g., http://localhost:3000)
13
+ * @param bundledPath Path to the bundled file (e.g., /_next/static/chunks/app/page.js)
14
+ * @param line Line number in bundled file (1-indexed)
15
+ * @param column Column number in bundled file (0-indexed)
16
+ */
17
+ export declare function resolveSourceLocation(projectRoot: string, devServerUrl: string, bundledPath: string, line: number, column: number): Promise<OriginalPosition | null>;
18
+ /**
19
+ * Batch resolve multiple source locations with deduplication
20
+ */
21
+ export declare function batchResolveSourceLocations(projectRoot: string, devServerUrl: string, locations: Array<{
22
+ bundledPath: string;
23
+ line: number;
24
+ column: number;
25
+ }>): Promise<Array<OriginalPosition | null>>;