Description
packages/mcp-server/dist/workflow-tools.js contains 9 importLocalModule() calls that use relative paths pointing to ../../../src/resources/extensions/gsd/.... Since this file runs from its compiled location in dist/, these paths resolve to the src/ directory where only .ts source files exist — not the .js files the dynamic import() expects.
Result: Every MCP tool that calls importLocalModule() fails with:
Cannot find module '.../src/resources/extensions/gsd/db-writer.js'
Affected modules (all 9)
../../../src/resources/extensions/gsd/bootstrap/write-gate.js
../../../src/resources/extensions/gsd/db-writer.js
../../../src/resources/extensions/gsd/doctor.js
../../../src/resources/extensions/gsd/gsd-db.js
../../../src/resources/extensions/gsd/journal.js
../../../src/resources/extensions/gsd/milestone-ids.js
../../../src/resources/extensions/gsd/state.js
../../../src/resources/extensions/gsd/tools/plan-task.js
../../../src/resources/extensions/gsd/tools/workflow-tool-executors.js
Affected tools
gsd_decision_save, gsd_milestone operations, state writes, journal writes, doctor (via MCP), plan-task — any tool that routes through importLocalModule() in workflow-tools.js.
Root cause
packages/mcp-server/src/workflow-tools.ts hardcodes relative paths with src/ prefixes:
const { saveDecisionToDb } = await importLocalModule(
"../../../src/resources/extensions/gsd/db-writer.js"
);
TypeScript compiles this to dist/workflow-tools.js but string literals pass through unchanged. The importLocalModule() function resolves relative to import.meta.url (the file's own location), so:
- Expected resolution:
packages/mcp-server/dist/ + ../../../dist/resources/extensions/gsd/db-writer.js
- Actual resolution:
packages/mcp-server/dist/ + ../../../src/resources/extensions/gsd/db-writer.js
Reproduction
- Install
gsd-pi globally: npm i -g gsd-pi
- Run any project with MCP workflow server configured
- Call
gsd_decision_save (or any tool using importLocalModule)
- Observe:
Cannot find module '.../src/resources/extensions/gsd/db-writer.js'
Workaround
Create symlinks from dist/*.js to the src/ paths:
BASE="$(npm root -g)/gsd-pi"
for f in \
resources/extensions/gsd/bootstrap/write-gate.js \
resources/extensions/gsd/db-writer.js \
resources/extensions/gsd/doctor.js \
resources/extensions/gsd/gsd-db.js \
resources/extensions/gsd/journal.js \
resources/extensions/gsd/milestone-ids.js \
resources/extensions/gsd/state.js \
resources/extensions/gsd/tools/plan-task.js \
resources/extensions/gsd/tools/workflow-tool-executors.js; do
ln -sf "$BASE/dist/$f" "$BASE/src/$f"
done
Suggested fix
Change all importLocalModule() paths in packages/mcp-server/src/workflow-tools.ts from ../../../src/... to ../../../dist/..., or introduce a build-time path substitution that rewrites src/ to dist/ during compilation.
Environment
- gsd-pi: global install via npm
- Node: v22.22.0
- OS: Linux (WSL2)
Description
packages/mcp-server/dist/workflow-tools.jscontains 9importLocalModule()calls that use relative paths pointing to../../../src/resources/extensions/gsd/.... Since this file runs from its compiled location indist/, these paths resolve to thesrc/directory where only.tssource files exist — not the.jsfiles the dynamicimport()expects.Result: Every MCP tool that calls
importLocalModule()fails with:Affected modules (all 9)
Affected tools
gsd_decision_save,gsd_milestoneoperations, state writes, journal writes, doctor (via MCP), plan-task — any tool that routes throughimportLocalModule()inworkflow-tools.js.Root cause
packages/mcp-server/src/workflow-tools.tshardcodes relative paths withsrc/prefixes:TypeScript compiles this to
dist/workflow-tools.jsbut string literals pass through unchanged. TheimportLocalModule()function resolves relative toimport.meta.url(the file's own location), so:packages/mcp-server/dist/+../../../dist/resources/extensions/gsd/db-writer.jspackages/mcp-server/dist/+../../../src/resources/extensions/gsd/db-writer.jsReproduction
gsd-piglobally:npm i -g gsd-pigsd_decision_save(or any tool usingimportLocalModule)Cannot find module '.../src/resources/extensions/gsd/db-writer.js'Workaround
Create symlinks from
dist/*.jsto thesrc/paths:Suggested fix
Change all
importLocalModule()paths inpackages/mcp-server/src/workflow-tools.tsfrom../../../src/...to../../../dist/..., or introduce a build-time path substitution that rewritessrc/todist/during compilation.Environment