runline 0.7.4 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,21 @@
1
1
  import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { dirname, join, resolve } from "node:path";
4
- import { fileURLToPath, pathToFileURL } from "node:url";
4
+ import { fileURLToPath } from "node:url";
5
+ import { createJiti } from "jiti";
5
6
  import { findConfigDir } from "../config/loader.js";
6
7
  import { resolvePluginExport } from "./api.js";
7
8
  import { registry } from "./registry.js";
8
9
  const __dirname = dirname(fileURLToPath(import.meta.url));
10
+ const jiti = createJiti(import.meta.url, {
11
+ moduleCache: false,
12
+ interopDefault: true,
13
+ tryNative: false,
14
+ alias: {
15
+ runline: new URL("../index.js", import.meta.url).pathname,
16
+ "runline/utils/cli": new URL("../utils/cli.js", import.meta.url).pathname,
17
+ },
18
+ });
9
19
  export async function loadPluginFromPath(path) {
10
20
  let absPath = resolve(path);
11
21
  if (existsSync(absPath) && statSync(absPath).isDirectory()) {
@@ -34,9 +44,16 @@ export async function loadPluginFromPath(path) {
34
44
  throw new Error(`No entry point found in ${absPath}`);
35
45
  }
36
46
  }
37
- const mod = await import(pathToFileURL(absPath).href);
47
+ // Plugins may live outside the project/package tree. Load them
48
+ // through Runline's module context so documented imports like
49
+ // `from "runline"` work without requiring a node_modules folder next
50
+ // to the plugin file.
51
+ const mod = (await jiti.import(absPath));
38
52
  const pluginId = absPath.replace(/.*\//, "").replace(/\.(ts|js)$/, "");
39
- return resolvePluginExport(mod.default, pluginId);
53
+ const pluginExport = typeof mod === "object" && mod !== null && "default" in mod
54
+ ? mod.default
55
+ : mod;
56
+ return resolvePluginExport(pluginExport, pluginId);
40
57
  }
41
58
  async function loadFromDirectory(dir) {
42
59
  const plugins = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runline",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "Code mode for agents — turn any API or command into a callable action",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -65,6 +65,7 @@
65
65
  "dependencies": {
66
66
  "chalk": "^5.6.2",
67
67
  "commander": "^14.0.3",
68
+ "jiti": "^2.7.0",
68
69
  "proper-lockfile": "^4.1.2",
69
70
  "quickjs-emscripten": "^0.32.0",
70
71
  "rrule": "^2.8.1"