@llmist/cli 12.0.0 → 12.0.2

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 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.0",
79
+ version: "12.0.2",
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",
@@ -1327,8 +1328,10 @@ async function readFileBuffer(filePath, options = {}) {
1327
1328
 
1328
1329
  // src/gadgets.ts
1329
1330
  import fs6 from "fs";
1331
+ import { createRequire } from "module";
1330
1332
  import path5 from "path";
1331
1333
  import { pathToFileURL as pathToFileURL2 } from "url";
1334
+ import { createJiti } from "jiti";
1332
1335
  import { AbstractGadget } from "llmist";
1333
1336
 
1334
1337
  // src/builtins/filesystem/edit-file.ts
@@ -2137,7 +2140,12 @@ async function loadExternalGadgets(specifier, forceInstall = false) {
2137
2140
  const moduleUrl = pathToFileURL(resolvedEntryPoint).href;
2138
2141
  let exports;
2139
2142
  try {
2140
- exports = await import(moduleUrl);
2143
+ if (isTypeScriptFile(resolvedEntryPoint)) {
2144
+ const importer = createTypeScriptImporter();
2145
+ exports = await importer(moduleUrl);
2146
+ } else {
2147
+ exports = await import(moduleUrl);
2148
+ }
2141
2149
  } catch (error) {
2142
2150
  const message = error instanceof Error ? error.message : String(error);
2143
2151
  throw new Error(`Failed to import '${specifier}': ${message}`);
@@ -2199,6 +2207,45 @@ async function loadExternalGadgets(specifier, forceInstall = false) {
2199
2207
  // src/gadgets.ts
2200
2208
  var PATH_PREFIXES = [".", "/", "~"];
2201
2209
  var BUILTIN_PREFIX = "builtin:";
2210
+ var TYPESCRIPT_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
2211
+ function isTypeScriptFile(specifier) {
2212
+ const pathToCheck = specifier.startsWith("file://") ? new URL(specifier).pathname : specifier;
2213
+ return TYPESCRIPT_EXTENSIONS.some((ext) => pathToCheck.endsWith(ext));
2214
+ }
2215
+ function resolvePackagePath(packageName) {
2216
+ const require2 = createRequire(import.meta.url);
2217
+ return require2.resolve(packageName);
2218
+ }
2219
+ var jitiInstance = null;
2220
+ function getJiti() {
2221
+ if (!jitiInstance) {
2222
+ jitiInstance = createJiti(import.meta.url, {
2223
+ // Enable filesystem cache for performance (default location)
2224
+ fsCache: true,
2225
+ // Enable module cache to integrate with Node.js cache
2226
+ moduleCache: true,
2227
+ // Enable interop for CJS/ESM compatibility
2228
+ interopDefault: true,
2229
+ // Map 'llmist' and 'zod' to CLI's installed versions
2230
+ // Allows TypeScript gadgets in ~/.llmist/gadgets/ to import
2231
+ // without needing their own node_modules
2232
+ alias: {
2233
+ llmist: resolvePackagePath("llmist"),
2234
+ zod: resolvePackagePath("zod")
2235
+ }
2236
+ });
2237
+ }
2238
+ return jitiInstance;
2239
+ }
2240
+ function createTypeScriptImporter() {
2241
+ return async (specifier) => {
2242
+ if (isTypeScriptFile(specifier)) {
2243
+ const jiti = getJiti();
2244
+ return await jiti.import(specifier);
2245
+ }
2246
+ return import(specifier);
2247
+ };
2248
+ }
2202
2249
  function isGadgetLike(value) {
2203
2250
  if (typeof value !== "object" || value === null) {
2204
2251
  return false;
@@ -2295,7 +2342,7 @@ function extractGadgetsFromModule(moduleExports) {
2295
2342
  visit(moduleExports);
2296
2343
  return results;
2297
2344
  }
2298
- async function loadGadgets(specifiers, cwd, importer = (specifier) => import(specifier)) {
2345
+ async function loadGadgets(specifiers, cwd, importer = createTypeScriptImporter()) {
2299
2346
  const gadgets = [];
2300
2347
  const usingDefaultImporter = importer.toString().includes("import(specifier)");
2301
2348
  for (const specifier of specifiers) {