fix(plugins): enhance plugin installation and script handling

- Updated the `pnpm install` command in `plugin-install.js` to include the `--ignore-workspace` flag, ensuring proper installation of plugins within the app tree.
- Improved the `instantiateScriptSource` function in `script-sandbox.js` to resolve `pluginDir` more effectively, allowing for better package management.
- Added a new smoke test in `plugins-smoke.js` to validate the ability to require additional packages from plugin directories, enhancing testing coverage for plugin functionality.
- Updated documentation in `AGENTS.md` to reflect changes in the installation command.
This commit is contained in:
2026-09-08 22:00:26 +07:00
parent 67ed3eecca
commit 6c82ff20eb
4 changed files with 68 additions and 3 deletions
+8 -1
View File
@@ -557,16 +557,23 @@ function instantiateCompiled(
* $workflows?: { trigger: (name: string, data?: unknown) => Promise<unknown> },
* pluginDir?: string | null,
* }} [opts]
*
* When `pluginDir` is omitted, it is resolved from `script` so inspect/dry-run
* of `plugin/<id>` can `require()` extra packages from that plugin's node_modules.
*/
export function instantiateScriptSource(script, source, opts = {}) {
const compiled = compileScriptSource(source, script);
const pluginDir =
"pluginDir" in opts
? opts.pluginDir ?? null
: (resolveScriptRef(script).pluginDir ?? null);
const fn = instantiateCompiled(compiled, {
log: opts.log ?? inspectLog,
script,
workflowName: opts.workflowName ?? "inspect",
owner: opts.owner ?? DEFAULT_OWNER,
$workflows: opts.$workflows,
pluginDir: opts.pluginDir ?? null,
pluginDir,
});
return { fn, ...extractScriptMeta(fn) };
}