@llmist/cli 12.0.0 → 12.0.1
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.
- package/dist/cli.js +38 -3
- package/dist/cli.js.map +1 -1
- package/package.json +2 -1
package/dist/cli.js
CHANGED
|
@@ -76,7 +76,7 @@ import { Command, InvalidArgumentError as InvalidArgumentError2 } from "commande
|
|
|
76
76
|
// package.json
|
|
77
77
|
var package_default = {
|
|
78
78
|
name: "@llmist/cli",
|
|
79
|
-
version: "12.0.
|
|
79
|
+
version: "12.0.1",
|
|
80
80
|
description: "CLI for llmist - run LLM agents from the command line",
|
|
81
81
|
type: "module",
|
|
82
82
|
main: "dist/cli.js",
|
|
@@ -135,6 +135,7 @@ var package_default = {
|
|
|
135
135
|
commander: "^12.1.0",
|
|
136
136
|
diff: "^8.0.2",
|
|
137
137
|
eta: "^4.4.1",
|
|
138
|
+
jiti: "^2.6.1",
|
|
138
139
|
"js-toml": "^1.0.2",
|
|
139
140
|
"js-yaml": "^4.1.0",
|
|
140
141
|
marked: "^15.0.12",
|
|
@@ -1329,6 +1330,7 @@ async function readFileBuffer(filePath, options = {}) {
|
|
|
1329
1330
|
import fs6 from "fs";
|
|
1330
1331
|
import path5 from "path";
|
|
1331
1332
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
1333
|
+
import { createJiti } from "jiti";
|
|
1332
1334
|
import { AbstractGadget } from "llmist";
|
|
1333
1335
|
|
|
1334
1336
|
// src/builtins/filesystem/edit-file.ts
|
|
@@ -2137,7 +2139,12 @@ async function loadExternalGadgets(specifier, forceInstall = false) {
|
|
|
2137
2139
|
const moduleUrl = pathToFileURL(resolvedEntryPoint).href;
|
|
2138
2140
|
let exports;
|
|
2139
2141
|
try {
|
|
2140
|
-
|
|
2142
|
+
if (isTypeScriptFile(resolvedEntryPoint)) {
|
|
2143
|
+
const importer = createTypeScriptImporter();
|
|
2144
|
+
exports = await importer(moduleUrl);
|
|
2145
|
+
} else {
|
|
2146
|
+
exports = await import(moduleUrl);
|
|
2147
|
+
}
|
|
2141
2148
|
} catch (error) {
|
|
2142
2149
|
const message = error instanceof Error ? error.message : String(error);
|
|
2143
2150
|
throw new Error(`Failed to import '${specifier}': ${message}`);
|
|
@@ -2199,6 +2206,34 @@ async function loadExternalGadgets(specifier, forceInstall = false) {
|
|
|
2199
2206
|
// src/gadgets.ts
|
|
2200
2207
|
var PATH_PREFIXES = [".", "/", "~"];
|
|
2201
2208
|
var BUILTIN_PREFIX = "builtin:";
|
|
2209
|
+
var TYPESCRIPT_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
|
|
2210
|
+
function isTypeScriptFile(specifier) {
|
|
2211
|
+
const pathToCheck = specifier.startsWith("file://") ? new URL(specifier).pathname : specifier;
|
|
2212
|
+
return TYPESCRIPT_EXTENSIONS.some((ext) => pathToCheck.endsWith(ext));
|
|
2213
|
+
}
|
|
2214
|
+
var jitiInstance = null;
|
|
2215
|
+
function getJiti() {
|
|
2216
|
+
if (!jitiInstance) {
|
|
2217
|
+
jitiInstance = createJiti(import.meta.url, {
|
|
2218
|
+
// Enable filesystem cache for performance (default location)
|
|
2219
|
+
fsCache: true,
|
|
2220
|
+
// Enable module cache to integrate with Node.js cache
|
|
2221
|
+
moduleCache: true,
|
|
2222
|
+
// Enable interop for CJS/ESM compatibility
|
|
2223
|
+
interopDefault: true
|
|
2224
|
+
});
|
|
2225
|
+
}
|
|
2226
|
+
return jitiInstance;
|
|
2227
|
+
}
|
|
2228
|
+
function createTypeScriptImporter() {
|
|
2229
|
+
return async (specifier) => {
|
|
2230
|
+
if (isTypeScriptFile(specifier)) {
|
|
2231
|
+
const jiti = getJiti();
|
|
2232
|
+
return await jiti.import(specifier);
|
|
2233
|
+
}
|
|
2234
|
+
return import(specifier);
|
|
2235
|
+
};
|
|
2236
|
+
}
|
|
2202
2237
|
function isGadgetLike(value) {
|
|
2203
2238
|
if (typeof value !== "object" || value === null) {
|
|
2204
2239
|
return false;
|
|
@@ -2295,7 +2330,7 @@ function extractGadgetsFromModule(moduleExports) {
|
|
|
2295
2330
|
visit(moduleExports);
|
|
2296
2331
|
return results;
|
|
2297
2332
|
}
|
|
2298
|
-
async function loadGadgets(specifiers, cwd, importer = (
|
|
2333
|
+
async function loadGadgets(specifiers, cwd, importer = createTypeScriptImporter()) {
|
|
2299
2334
|
const gadgets = [];
|
|
2300
2335
|
const usingDefaultImporter = importer.toString().includes("import(specifier)");
|
|
2301
2336
|
for (const specifier of specifiers) {
|