Fixed
-
๐ฆ
patch-openclaw.jsnow findssources.jsin more locations (#35) โ when users copy justpatch-openclaw.jsto another directory (e.g.~/.free-coding-models/) and run it, the staticimport './sources.js'failed withERR_MODULE_NOT_FOUNDbecause ESM resolves imports relative to the importer file at parse time. Switched to a runtime search over multiple candidate paths:- Same directory as the script (primary โ FCM source / global install layout)
- Parent directory (covers
tools/-style subdirs) - Two levels up
- Three levels up
process.cwd()(last-resort fallback)
If none resolve, the script now prints a clear error pointing to the script's actual location and how to fix it, instead of a cryptic
ERR_MODULE_NOT_FOUND.
Maintenance
- ๐งช +1 unit test (
test/patch-openclaw.test.js) locking in the search order so any future reordering is caught. - ๐งช 592/592 tests pass (
pnpm test). - ๐งน
vite buildsucceeds.
Why a top-level await import()?
ESM import './sources.js' is resolved at parse-time relative to the importer file's directory. There's no way to fall back at parse time, so the only way to support multiple candidate paths is to compute the path at runtime and use dynamic import(pathToFileURL(sourcesPath).href). Top-level await keeps the rest of the script's top-level statements unchanged.