Repository navigation
Closed
Description
Summary
The bundled helper script find-skill.js is CommonJS (require(...)), but it ships inside a package whose root package.json declares "type": "module". Node therefore treats the .js file as ESM and it dies on the first require before producing any output.
bundled/skill-digester/SKILL.md instructs the agent to run exactly this file when the skill is loaded from a non-standard path ("If this skill is loaded from a project-level or different user-level path, use the scripts/find-skill.js file next to this SKILL.md instead"), so the documented workflow fails there.
Environment
@vegamo/deepcode-cli0.4.3 (installed globally)- Node v22.23.2, npm 12.0.2
- Linux (Manjaro), x86_64
- Script:
bundled/skill-digester/scripts/find-skill.js - Upstream path:
packages/core/templates/skills/bundled/skill-digester/scripts/find-skill.js(still usesrequireonmain)
Reproduce
node /usr/lib/node_modules/@vegamo/deepcode-cli/bundled/skill-digester/scripts/find-skill.js "worklog" "$PWD"Actual
file:///usr/lib/node_modules/@vegamo/deepcode-cli/bundled/skill-digester/scripts/find-skill.js:4
const fs = require("fs");
^
ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/usr/lib/node_modules/@vegamo/deepcode-cli/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///usr/lib/node_modules/@vegamo/deepcode-cli/bundled/skill-digester/scripts/find-skill.js:4:12
at ModuleJob.run (node:internal/modules/esm/module_job:343:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:681:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)
Exit code 1, no JSON output.
Expected
The JSON listing the scanned roots and matches, as documented in SKILL.md (e.g. {"found": true, "activeMatches": [...]}).
Root cause
find-skill.jsis CommonJS:const fs = require("fs")on lines 4-6 andrequire(resolved)insideloadMatter(); the file even carries/* global __dirname, console, process, require */.- There is no local
package.jsonnext to the script, so the nearest ancestor is the package root, which sets"type": "module". - Node parses the
.jsfile as ESM andrequireis therefore undefined.
Impact
- The
skill-digesterworkflow is unusable when the skill is read from the bundled copy — the exact case its ownSKILL.mdtells the agent to use. - The same failure hits any project-level install at
./.agents/skills/skill-digester/inside a Node project whose rootpackage.jsonhas"type": "module", which is a common layout.
Suggested fix (any one)
- Rename the script to
find-skill.cjsand update the path referenced inSKILL.md; or - Convert it to ESM. Note that
loadMatter()needscreateRequire(import.meta.url)(or a dynamicimport()) for the optionalgray-matterlookup; the built-in fallback parser is unaffected; or - Add a
package.jsoncontaining{"type": "commonjs"}next to the script.
Workaround
cp /usr/lib/node_modules/@vegamo/deepcode-cli/bundled/skill-digester/scripts/find-skill.js /tmp/find-skill.cjs
node /tmp/find-skill.cjs "worklog" "$PWD"Reacted by null
Metadata
Metadata
Assignees
Labels
No labels
Activity
fix: run skill-digester helper as CommonJS