{"record":{"id":"4e90a5863f52fa4c","repo":"can1357/oh-my-pi","slug":"failed-to-parse-extension-source-for-dependency-re","errorCode":null,"errorMessage":"Failed to parse extension source for dependency rewriting: ${importerPath}: ${error instanceof Error ? error.message : String(error)}","messagePattern":"Failed to parse extension source for dependency rewriting: (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/extensibility/plugins/legacy-pi-compat.ts","lineNumber":85,"sourceCode":"\t}\n\tif (extension === \".jsx\" || extension === \".tsx\") {\n\t\tplugins.push(\"jsx\");\n\t}\n\n\ttry {\n\t\treturn parseBabel(source, {\n\t\t\tsourceType: \"unambiguous\",\n\t\t\tallowAwaitOutsideFunction: true,\n\t\t\tallowReturnOutsideFunction: true,\n\t\t\tallowImportExportEverywhere: true,\n\t\t\tallowNewTargetOutsideFunction: true,\n\t\t\tallowSuperOutsideMethod: true,\n\t\t\tallowUndeclaredExports: true,\n\t\t\terrorRecovery: true,\n\t\t\tplugins,\n\t\t});\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to parse extension source for dependency rewriting: ${importerPath}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t{ cause: error },\n\t\t);\n\t}\n}\n\nconst REQUIRE_BINDING = 1 << 0;\nconst OBJECT_BINDING = 1 << 1;\nconst EXPORTS_BINDING = 1 << 2;\nconst MODULE_BINDING = 1 << 3;\n\ninterface StructuralAstNode {\n\treadonly type: string;\n\treadonly [key: string]: unknown;\n}\n\ninterface BindingScope {\n\treadonly parent: BindingScope | null;","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/extensibility/plugins/legacy-pi-compat.ts#L67-L103","documentation":"parseExtensionSource parses extension TypeScript/JavaScript with the TypeScript parser (with JSX and other plugins) to find imports for dependency rewriting. If the parser throws, the error is wrapped with the importer path and the original message, attached as `cause`. This converts raw parser diagnostics into a domain-labeled error.","triggerScenarios":"collectExtensionSpecifierReferences or the ast accessor reads an extension file whose source the configured parser plugins cannot parse: syntax errors in the extension, TS syntax not covered by the enabled plugins (e.g. experimental decorators, newer stage proposals), or non-UTF8/binary content passed as source.","commonSituations":"Users install extensions written for newer TypeScript/Bun syntax than the parser config supports; a hand-edited extension with a syntax error; an extension in JSX/TSX handled by a plugin set that mismatches its actual syntax.","solutions":["Read the wrapped cause message — it contains the parser's line/column and description","Fix the syntax error in the extension file at the reported location","If the file uses experimental syntax, check whether the CLI version supports it and update, or rewrite the extension with supported syntax","Report the file if the syntax is standard TS and still fails — the parser plugin list may need updating"],"exampleFix":"// before: extension uses unsupported proposal syntax\nconst x = #privateCounter.value;\n// after: supported private-field syntax\nclass Counter { #value = 0; get value() { return this.#value; } }","handlingStrategy":"try-catch","validationCode":"// best-effort pre-check that the source parses as plain JS/TS before feeding it to the extension loader\nconst src = await Bun.file(extPath).text();\nif (/\\u0000/.test(src)) throw new Error(`${extPath} looks binary`);","typeGuard":null,"tryCatchPattern":"try {\n\tconst refs = collectExtensionSpecifierReferences(extPath);\n} catch (err) {\n\tif (err instanceof Error && err.message.startsWith(\"Failed to parse extension source\")) {\n\t\t// the cause chain holds the parser line/column\n\t\tconsole.error(err.cause);\n\t}\n\tthrow err;\n}","preventionTips":["Check err.cause for the exact parser location when diagnosing","Keep extensions within the TypeScript/Bun syntax the CLI's parser supports","Lint extension files (tsc/eslint) before installing them","Avoid editing extensions while the CLI is loading them (partial reads)"],"tags":["parse-error","typescript-parser","extensions","syntax"],"backgroundTag":"extension-source-parse-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}