@llmist/cli 11.1.1 → 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/README.md +2 -2
- package/dist/cli.js +55 -64
- package/dist/cli.js.map +1 -1
- package/dist/index.js +0 -20
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/README.md
CHANGED
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: "
|
|
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",
|
|
@@ -101,7 +101,6 @@ var package_default = {
|
|
|
101
101
|
scripts: {
|
|
102
102
|
build: "tsup",
|
|
103
103
|
typecheck: "tsc --noEmit",
|
|
104
|
-
test: "bun test src",
|
|
105
104
|
clean: "rimraf dist",
|
|
106
105
|
postinstall: "node scripts/postinstall.js"
|
|
107
106
|
},
|
|
@@ -136,6 +135,7 @@ var package_default = {
|
|
|
136
135
|
commander: "^12.1.0",
|
|
137
136
|
diff: "^8.0.2",
|
|
138
137
|
eta: "^4.4.1",
|
|
138
|
+
jiti: "^2.6.1",
|
|
139
139
|
"js-toml": "^1.0.2",
|
|
140
140
|
"js-yaml": "^4.1.0",
|
|
141
141
|
marked: "^15.0.12",
|
|
@@ -148,7 +148,6 @@ var package_default = {
|
|
|
148
148
|
"@types/js-yaml": "^4.0.9",
|
|
149
149
|
"@types/marked-terminal": "^6.1.1",
|
|
150
150
|
"@types/node": "^20.12.7",
|
|
151
|
-
"bun-types": "^1.3.2",
|
|
152
151
|
rimraf: "^5.0.5",
|
|
153
152
|
tsup: "^8.3.5",
|
|
154
153
|
typescript: "^5.4.5"
|
|
@@ -1331,6 +1330,7 @@ async function readFileBuffer(filePath, options = {}) {
|
|
|
1331
1330
|
import fs6 from "fs";
|
|
1332
1331
|
import path5 from "path";
|
|
1333
1332
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
1333
|
+
import { createJiti } from "jiti";
|
|
1334
1334
|
import { AbstractGadget } from "llmist";
|
|
1335
1335
|
|
|
1336
1336
|
// src/builtins/filesystem/edit-file.ts
|
|
@@ -1339,23 +1339,6 @@ import { createGadget as createGadget2 } from "llmist";
|
|
|
1339
1339
|
|
|
1340
1340
|
// src/spawn.ts
|
|
1341
1341
|
import { spawn as nodeSpawn } from "child_process";
|
|
1342
|
-
var isBun = typeof Bun !== "undefined";
|
|
1343
|
-
function adaptBunProcess(proc) {
|
|
1344
|
-
return {
|
|
1345
|
-
exited: proc.exited,
|
|
1346
|
-
stdout: proc.stdout ?? null,
|
|
1347
|
-
stderr: proc.stderr ?? null,
|
|
1348
|
-
stdin: proc.stdin ? {
|
|
1349
|
-
write(data) {
|
|
1350
|
-
proc.stdin?.write(data);
|
|
1351
|
-
},
|
|
1352
|
-
end() {
|
|
1353
|
-
proc.stdin?.end();
|
|
1354
|
-
}
|
|
1355
|
-
} : null,
|
|
1356
|
-
kill: () => proc.kill()
|
|
1357
|
-
};
|
|
1358
|
-
}
|
|
1359
1342
|
function nodeStreamToReadableStream(nodeStream) {
|
|
1360
1343
|
if (!nodeStream) return null;
|
|
1361
1344
|
return new ReadableStream({
|
|
@@ -1376,9 +1359,6 @@ function nodeStreamToReadableStream(nodeStream) {
|
|
|
1376
1359
|
});
|
|
1377
1360
|
}
|
|
1378
1361
|
function spawn(argv, options = {}) {
|
|
1379
|
-
if (isBun) {
|
|
1380
|
-
return adaptBunProcess(Bun.spawn(argv, options));
|
|
1381
|
-
}
|
|
1382
1362
|
const [command, ...args] = argv;
|
|
1383
1363
|
const proc = nodeSpawn(command, args, {
|
|
1384
1364
|
cwd: options.cwd,
|
|
@@ -2023,36 +2003,19 @@ async function installNpmPackage(spec, cacheDir) {
|
|
|
2023
2003
|
fs5.writeFileSync(path4.join(cacheDir, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
2024
2004
|
const packageSpec = spec.version ? `${spec.package}@${spec.version}` : spec.package;
|
|
2025
2005
|
const quietEnv = { ...process.env, DISABLE_OPENCOLLECTIVE: "1", ADBLOCK: "1" };
|
|
2026
|
-
if (isCommandAvailable("npm")) {
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
return;
|
|
2031
|
-
} catch (error) {
|
|
2032
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
2033
|
-
throw new Error(`Failed to install npm package '${packageSpec}': ${message}`);
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
|
-
if (isCommandAvailable("bun")) {
|
|
2037
|
-
console.warn(
|
|
2038
|
-
"\u26A0\uFE0F npm not found, using bun. Postinstall scripts for subdependencies may not run.\n For best results, install npm: https://nodejs.org/"
|
|
2006
|
+
if (!isCommandAvailable("npm")) {
|
|
2007
|
+
throw new Error(
|
|
2008
|
+
`npm is not available to install '${packageSpec}'.
|
|
2009
|
+
Please install Node.js: https://nodejs.org/`
|
|
2039
2010
|
);
|
|
2040
|
-
const installCmd = `bun add --trust "${packageSpec}"`;
|
|
2041
|
-
try {
|
|
2042
|
-
execSync(installCmd, { stdio: "inherit", cwd: cacheDir, env: quietEnv });
|
|
2043
|
-
return;
|
|
2044
|
-
} catch (error) {
|
|
2045
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
2046
|
-
throw new Error(`Failed to install package '${packageSpec}' with bun: ${message}`);
|
|
2047
|
-
}
|
|
2048
2011
|
}
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2012
|
+
const installCmd = `npm install --foreground-scripts --loglevel=error "${packageSpec}"`;
|
|
2013
|
+
try {
|
|
2014
|
+
execSync(installCmd, { stdio: "inherit", cwd: cacheDir, env: quietEnv });
|
|
2015
|
+
} catch (error) {
|
|
2016
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2017
|
+
throw new Error(`Failed to install npm package '${packageSpec}': ${message}`);
|
|
2018
|
+
}
|
|
2056
2019
|
}
|
|
2057
2020
|
async function installGitPackage(spec, cacheDir) {
|
|
2058
2021
|
fs5.mkdirSync(path4.dirname(cacheDir), { recursive: true });
|
|
@@ -2076,25 +2039,20 @@ async function installGitPackage(spec, cacheDir) {
|
|
|
2076
2039
|
}
|
|
2077
2040
|
if (fs5.existsSync(path4.join(cacheDir, "package.json"))) {
|
|
2078
2041
|
const hasNpm = isCommandAvailable("npm");
|
|
2079
|
-
|
|
2080
|
-
if (!hasNpm && !hasBun) {
|
|
2042
|
+
if (!hasNpm) {
|
|
2081
2043
|
throw new Error(
|
|
2082
|
-
`
|
|
2083
|
-
Please install
|
|
2084
|
-
- npm: https://nodejs.org/
|
|
2085
|
-
- bun: https://bun.sh/`
|
|
2044
|
+
`npm is not available to install dependencies for '${spec.package}'.
|
|
2045
|
+
Please install Node.js: https://nodejs.org/`
|
|
2086
2046
|
);
|
|
2087
2047
|
}
|
|
2088
|
-
const
|
|
2089
|
-
const
|
|
2090
|
-
const runCmd = useBun ? "bun run" : "npm run";
|
|
2091
|
-
const pmName = useBun ? "bun" : "npm";
|
|
2048
|
+
const installCmd = "npm install --foreground-scripts --loglevel=error";
|
|
2049
|
+
const runCmd = "npm run";
|
|
2092
2050
|
const quietEnv = { ...process.env, DISABLE_OPENCOLLECTIVE: "1", ADBLOCK: "1" };
|
|
2093
2051
|
try {
|
|
2094
2052
|
execSync(installCmd, { cwd: cacheDir, stdio: "inherit", env: quietEnv });
|
|
2095
2053
|
} catch (error) {
|
|
2096
2054
|
const message = error instanceof Error ? error.message : String(error);
|
|
2097
|
-
throw new Error(`Failed to install dependencies for '${spec.package}' using
|
|
2055
|
+
throw new Error(`Failed to install dependencies for '${spec.package}' using npm: ${message}`);
|
|
2098
2056
|
}
|
|
2099
2057
|
const packageJson = JSON.parse(fs5.readFileSync(path4.join(cacheDir, "package.json"), "utf-8"));
|
|
2100
2058
|
if (packageJson.scripts?.build) {
|
|
@@ -2181,7 +2139,12 @@ async function loadExternalGadgets(specifier, forceInstall = false) {
|
|
|
2181
2139
|
const moduleUrl = pathToFileURL(resolvedEntryPoint).href;
|
|
2182
2140
|
let exports;
|
|
2183
2141
|
try {
|
|
2184
|
-
|
|
2142
|
+
if (isTypeScriptFile(resolvedEntryPoint)) {
|
|
2143
|
+
const importer = createTypeScriptImporter();
|
|
2144
|
+
exports = await importer(moduleUrl);
|
|
2145
|
+
} else {
|
|
2146
|
+
exports = await import(moduleUrl);
|
|
2147
|
+
}
|
|
2185
2148
|
} catch (error) {
|
|
2186
2149
|
const message = error instanceof Error ? error.message : String(error);
|
|
2187
2150
|
throw new Error(`Failed to import '${specifier}': ${message}`);
|
|
@@ -2243,6 +2206,34 @@ async function loadExternalGadgets(specifier, forceInstall = false) {
|
|
|
2243
2206
|
// src/gadgets.ts
|
|
2244
2207
|
var PATH_PREFIXES = [".", "/", "~"];
|
|
2245
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
|
+
}
|
|
2246
2237
|
function isGadgetLike(value) {
|
|
2247
2238
|
if (typeof value !== "object" || value === null) {
|
|
2248
2239
|
return false;
|
|
@@ -2339,7 +2330,7 @@ function extractGadgetsFromModule(moduleExports) {
|
|
|
2339
2330
|
visit(moduleExports);
|
|
2340
2331
|
return results;
|
|
2341
2332
|
}
|
|
2342
|
-
async function loadGadgets(specifiers, cwd, importer = (
|
|
2333
|
+
async function loadGadgets(specifiers, cwd, importer = createTypeScriptImporter()) {
|
|
2343
2334
|
const gadgets = [];
|
|
2344
2335
|
const usingDefaultImporter = importer.toString().includes("import(specifier)");
|
|
2345
2336
|
for (const specifier of specifiers) {
|