fix(gsd): resolve resource-loader import for deployed extensions
The relative import `../../../resource-loader.js` in auto.ts works from
the source tree (src/resources/extensions/gsd/ → src/resource-loader.js)
but breaks when extensions are deployed to ~/.gsd/agent/extensions/gsd/
(resolves to ~/.gsd/resource-loader.js which doesn't exist).
Use createRequire to resolve the gsd-pi package root and import
dist/resource-loader.js from there, which works in both source and
deployed contexts.
Regression introduced in #3899 (9ed543f1c8).
This commit is contained in:
parent
804f1d4b94
commit
02b905f3f5
1 changed files with 8 additions and 2 deletions
|
|
@ -125,8 +125,9 @@ import {
|
|||
} from "./metrics.js";
|
||||
import { setLogBasePath, logWarning, logError } from "./workflow-logger.js";
|
||||
import { homedir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { join, dirname } from "node:path";
|
||||
import { readFileSync, existsSync, mkdirSync, writeFileSync, unlinkSync } from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import { atomicWriteSync } from "./atomic-write.js";
|
||||
import {
|
||||
autoCommitCurrentBranch,
|
||||
|
|
@ -1334,7 +1335,12 @@ export async function startAuto(
|
|||
// Re-sync managed resources on resume so long-lived auto sessions pick up
|
||||
// bundled extension updates before resume-time verification/state logic runs.
|
||||
const agentDir = process.env.GSD_CODING_AGENT_DIR || join(process.env.GSD_HOME || homedir(), ".gsd", "agent");
|
||||
const { initResources } = await import("../../../" + "resource-loader.js");
|
||||
// Resolve resource-loader from the gsd-pi package root — the relative
|
||||
// "../../../resource-loader.js" path only works from the source tree but
|
||||
// breaks when extensions are deployed to ~/.gsd/agent/extensions/gsd/.
|
||||
const _req = createRequire(import.meta.url);
|
||||
const pkgRoot = dirname(_req.resolve("gsd-pi/package.json"));
|
||||
const { initResources } = await import(join(pkgRoot, "dist", "resource-loader.js"));
|
||||
initResources(agentDir);
|
||||
// Open the project DB before rebuild/derive so resume uses DB-backed
|
||||
// state instead of falling back to stale markdown parsing (#2940).
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue