From 0f94341b435654cfb0abfb2f7777b28eaa471b1a Mon Sep 17 00:00:00 2001 From: ace-pm Date: Tue, 21 Apr 2026 01:39:18 +0200 Subject: [PATCH] fix(loader): fall back to src/resources when SF-WORKFLOW.md missing from dist Build sometimes copies dist/resources/extensions/ without the top-level markdown files (observed: SF-WORKFLOW.md absent in dist/resources/ while extensions/ was present). existsSync(distRes) was true either way, so SF_WORKFLOW_PATH pointed at a non-existent path and /sf failed with ENOENT. Check for the specific file instead of the directory. --- src/loader.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/loader.ts b/src/loader.ts index 02570d62b..3b7640af2 100644 --- a/src/loader.ts +++ b/src/loader.ts @@ -145,9 +145,12 @@ process.env.SF_BIN_PATH = process.env.SF_BIN_PATH || process.argv[1] // SF_WORKFLOW_PATH — absolute path to bundled SF-WORKFLOW.md, used by patched sf extension // when dispatching workflow prompts. Prefers dist/resources/ (stable, set at build time) // over src/resources/ (live working tree) — see resource-loader.ts for rationale. +// Guard: the build sometimes copies dist/resources/extensions/ without the root-level +// markdown files, leaving existsSync(distRes)=true but SF-WORKFLOW.md missing. Fall +// back to src/resources/ when the file itself isn't present in dist. const distRes = join(sfRootDir, 'dist', 'resources') const srcRes = join(sfRootDir, 'src', 'resources') -const resourcesDir = existsSync(distRes) ? distRes : srcRes +const resourcesDir = existsSync(join(distRes, 'SF-WORKFLOW.md')) ? distRes : srcRes process.env.SF_WORKFLOW_PATH = join(resourcesDir, 'SF-WORKFLOW.md') // SF_BUNDLED_EXTENSION_PATHS — dynamically discovered bundled extension entry points.