can1357/oh-my-pi · error · Error
Failed to parse extension source for dependency rewriting: $
Error message
Failed to parse extension source for dependency rewriting: ${importerPath}: ${error instanceof Error ? error.message : String(error)} What it means
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.
Source
Thrown at packages/coding-agent/src/extensibility/plugins/legacy-pi-compat.ts:85
}
if (extension === ".jsx" || extension === ".tsx") {
plugins.push("jsx");
}
try {
return parseBabel(source, {
sourceType: "unambiguous",
allowAwaitOutsideFunction: true,
allowReturnOutsideFunction: true,
allowImportExportEverywhere: true,
allowNewTargetOutsideFunction: true,
allowSuperOutsideMethod: true,
allowUndeclaredExports: true,
errorRecovery: true,
plugins,
});
} catch (error) {
throw new Error(
`Failed to parse extension source for dependency rewriting: ${importerPath}: ${error instanceof Error ? error.message : String(error)}`,
{ cause: error },
);
}
}
const REQUIRE_BINDING = 1 << 0;
const OBJECT_BINDING = 1 << 1;
const EXPORTS_BINDING = 1 << 2;
const MODULE_BINDING = 1 << 3;
interface StructuralAstNode {
readonly type: string;
readonly [key: string]: unknown;
}
interface BindingScope {
readonly parent: BindingScope | null;View on GitHub (pinned to 9690622007)
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
Example fix
// before: extension uses unsupported proposal syntax
const x = #privateCounter.value;
// after: supported private-field syntax
class Counter { #value = 0; get value() { return this.#value; } } Defensive patterns
Strategy: try-catch
Validate before calling
// best-effort pre-check that the source parses as plain JS/TS before feeding it to the extension loader
const src = await Bun.file(extPath).text();
if (/\u0000/.test(src)) throw new Error(`${extPath} looks binary`); Try / catch
try {
const refs = collectExtensionSpecifierReferences(extPath);
} catch (err) {
if (err instanceof Error && err.message.startsWith("Failed to parse extension source")) {
// the cause chain holds the parser line/column
console.error(err.cause);
}
throw err;
} Prevention
- 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)
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- transparent (brush_parser::BindingParseError)
- ${destination} returned invalid JSON
- No hashline sections found in input.
- Output {output_id} is not valid JSON: {e}
- Pending action store unavailable for custom tools in this ru
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/4e90a5863f52fa4c.
Report an issue: GitHub.