@looplia/looplia-cli 0.6.9 → 0.6.10
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 +100 -133
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -243,12 +243,22 @@ async function getPluginPaths() {
|
|
|
243
243
|
return await getProdPluginPaths();
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
// ../../packages/provider/dist/chunk-
|
|
246
|
+
// ../../packages/provider/dist/chunk-L5AQO6ZO.js
|
|
247
247
|
import { execSync } from "child_process";
|
|
248
248
|
import { existsSync as existsSync3 } from "fs";
|
|
249
249
|
import { createRequire } from "module";
|
|
250
250
|
import { homedir as homedir3 } from "os";
|
|
251
251
|
import { dirname as dirname3, join as join4 } from "path";
|
|
252
|
+
import {
|
|
253
|
+
chmod,
|
|
254
|
+
mkdir as mkdir2,
|
|
255
|
+
readFile as readFile2,
|
|
256
|
+
rename,
|
|
257
|
+
rm as rm2,
|
|
258
|
+
writeFile as writeFile2
|
|
259
|
+
} from "fs/promises";
|
|
260
|
+
import { homedir as homedir22 } from "os";
|
|
261
|
+
import { join as join23 } from "path";
|
|
252
262
|
|
|
253
263
|
// ../../node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
254
264
|
var ignoreOverride = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
@@ -27370,18 +27380,8 @@ function query({
|
|
|
27370
27380
|
return queryInstance;
|
|
27371
27381
|
}
|
|
27372
27382
|
|
|
27373
|
-
// ../../packages/provider/dist/chunk-
|
|
27383
|
+
// ../../packages/provider/dist/chunk-L5AQO6ZO.js
|
|
27374
27384
|
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
27375
|
-
import { join as join23 } from "path";
|
|
27376
|
-
import {
|
|
27377
|
-
chmod,
|
|
27378
|
-
mkdir as mkdir2,
|
|
27379
|
-
readFile as readFile2,
|
|
27380
|
-
rename,
|
|
27381
|
-
rm as rm2,
|
|
27382
|
-
writeFile as writeFile2
|
|
27383
|
-
} from "fs/promises";
|
|
27384
|
-
import { homedir as homedir22 } from "os";
|
|
27385
27385
|
import { join as join32 } from "path";
|
|
27386
27386
|
import { cp as cp2, mkdir as mkdir22, readFile as readFile22, rm as rm22, stat as stat2, writeFile as writeFile22 } from "fs/promises";
|
|
27387
27387
|
import { homedir as homedir32 } from "os";
|
|
@@ -27449,62 +27449,6 @@ function findClaudeCodePath() {
|
|
|
27449
27449
|
cachedClaudeCodePath = null;
|
|
27450
27450
|
return;
|
|
27451
27451
|
}
|
|
27452
|
-
var DEFAULT_CONFIG = {
|
|
27453
|
-
model: "claude-haiku-4-5-20251001",
|
|
27454
|
-
workspace: "~/.looplia",
|
|
27455
|
-
useFilesystemExtensions: true,
|
|
27456
|
-
maxRetries: 3,
|
|
27457
|
-
timeout: 6e4
|
|
27458
|
-
};
|
|
27459
|
-
function resolveConfig(config2) {
|
|
27460
|
-
return {
|
|
27461
|
-
...config2,
|
|
27462
|
-
model: config2?.model ?? DEFAULT_CONFIG.model,
|
|
27463
|
-
workspace: config2?.workspace ?? DEFAULT_CONFIG.workspace,
|
|
27464
|
-
useFilesystemExtensions: config2?.useFilesystemExtensions ?? DEFAULT_CONFIG.useFilesystemExtensions,
|
|
27465
|
-
maxRetries: config2?.maxRetries ?? DEFAULT_CONFIG.maxRetries,
|
|
27466
|
-
timeout: config2?.timeout ?? DEFAULT_CONFIG.timeout
|
|
27467
|
-
};
|
|
27468
|
-
}
|
|
27469
|
-
function generateLogFilename() {
|
|
27470
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
27471
|
-
return `query-${timestamp}.log`;
|
|
27472
|
-
}
|
|
27473
|
-
function createQueryLogger(workspace) {
|
|
27474
|
-
let logPath = null;
|
|
27475
|
-
return {
|
|
27476
|
-
init(sandboxId) {
|
|
27477
|
-
const logsDir = join23(workspace, "sandbox", sandboxId, "logs");
|
|
27478
|
-
mkdirSync3(logsDir, { recursive: true });
|
|
27479
|
-
const filename = generateLogFilename();
|
|
27480
|
-
logPath = join23(logsDir, filename);
|
|
27481
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
27482
|
-
writeFileSync2(
|
|
27483
|
-
logPath,
|
|
27484
|
-
`Agent SDK Execution Log - ${timestamp}
|
|
27485
|
-
${"=".repeat(60)}
|
|
27486
|
-
|
|
27487
|
-
`
|
|
27488
|
-
);
|
|
27489
|
-
return logPath;
|
|
27490
|
-
},
|
|
27491
|
-
log(message) {
|
|
27492
|
-
if (!logPath) {
|
|
27493
|
-
return;
|
|
27494
|
-
}
|
|
27495
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
27496
|
-
const logEntry = `[${timestamp}] ${JSON.stringify(message, null, 2)}
|
|
27497
|
-
|
|
27498
|
-
`;
|
|
27499
|
-
appendFileSync3(logPath, logEntry);
|
|
27500
|
-
},
|
|
27501
|
-
close() {
|
|
27502
|
-
},
|
|
27503
|
-
getLogPath() {
|
|
27504
|
-
return logPath;
|
|
27505
|
-
}
|
|
27506
|
-
};
|
|
27507
|
-
}
|
|
27508
27452
|
var DEFAULT_SETTINGS = {
|
|
27509
27453
|
version: "1.0",
|
|
27510
27454
|
apiProvider: {
|
|
@@ -27679,10 +27623,10 @@ var PRESETS = {
|
|
|
27679
27623
|
};
|
|
27680
27624
|
var CONFIG_FILE = "looplia.setting.json";
|
|
27681
27625
|
function getLoopliaHome() {
|
|
27682
|
-
return
|
|
27626
|
+
return join23(homedir22(), ".looplia");
|
|
27683
27627
|
}
|
|
27684
27628
|
function getConfigPath() {
|
|
27685
|
-
return
|
|
27629
|
+
return join23(getLoopliaHome(), CONFIG_FILE);
|
|
27686
27630
|
}
|
|
27687
27631
|
async function readLoopliaSettings() {
|
|
27688
27632
|
const configPath = getConfigPath();
|
|
@@ -27790,6 +27734,87 @@ function applyPreset(presetName, existingSettings) {
|
|
|
27790
27734
|
}
|
|
27791
27735
|
};
|
|
27792
27736
|
}
|
|
27737
|
+
async function initializeCommandEnvironment(options = {}) {
|
|
27738
|
+
const settings = await readLoopliaSettings();
|
|
27739
|
+
if (settings) {
|
|
27740
|
+
injectLoopliaSettingsEnv(settings);
|
|
27741
|
+
}
|
|
27742
|
+
if (!options.mock) {
|
|
27743
|
+
validateApiKeyPresence();
|
|
27744
|
+
}
|
|
27745
|
+
return { settings };
|
|
27746
|
+
}
|
|
27747
|
+
function validateApiKeyPresence() {
|
|
27748
|
+
if (!(process.env.ANTHROPIC_API_KEY || process.env.CLAUDE_CODE_OAUTH_TOKEN)) {
|
|
27749
|
+
console.error("Error: API key required");
|
|
27750
|
+
console.error("");
|
|
27751
|
+
console.error("Options:");
|
|
27752
|
+
console.error(" 1. Set ANTHROPIC_API_KEY environment variable");
|
|
27753
|
+
console.error(" 2. Set ZENMUX_API_KEY with a ZenMux preset");
|
|
27754
|
+
console.error(" 3. Configure via: looplia config provider preset <name>");
|
|
27755
|
+
console.error(" 4. Use --mock flag for testing without API");
|
|
27756
|
+
console.error("");
|
|
27757
|
+
console.error("Get your API key from: https://console.anthropic.com");
|
|
27758
|
+
console.error("Or use ZenMux at: https://zenmux.ai");
|
|
27759
|
+
process.exit(1);
|
|
27760
|
+
}
|
|
27761
|
+
}
|
|
27762
|
+
var DEFAULT_CONFIG = {
|
|
27763
|
+
model: "claude-haiku-4-5-20251001",
|
|
27764
|
+
workspace: "~/.looplia",
|
|
27765
|
+
useFilesystemExtensions: true,
|
|
27766
|
+
maxRetries: 3,
|
|
27767
|
+
timeout: 6e4
|
|
27768
|
+
};
|
|
27769
|
+
function resolveConfig(config2) {
|
|
27770
|
+
return {
|
|
27771
|
+
...config2,
|
|
27772
|
+
model: config2?.model ?? DEFAULT_CONFIG.model,
|
|
27773
|
+
workspace: config2?.workspace ?? DEFAULT_CONFIG.workspace,
|
|
27774
|
+
useFilesystemExtensions: config2?.useFilesystemExtensions ?? DEFAULT_CONFIG.useFilesystemExtensions,
|
|
27775
|
+
maxRetries: config2?.maxRetries ?? DEFAULT_CONFIG.maxRetries,
|
|
27776
|
+
timeout: config2?.timeout ?? DEFAULT_CONFIG.timeout
|
|
27777
|
+
};
|
|
27778
|
+
}
|
|
27779
|
+
function generateLogFilename() {
|
|
27780
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
27781
|
+
return `query-${timestamp}.log`;
|
|
27782
|
+
}
|
|
27783
|
+
function createQueryLogger(workspace) {
|
|
27784
|
+
let logPath = null;
|
|
27785
|
+
return {
|
|
27786
|
+
init(sandboxId) {
|
|
27787
|
+
const logsDir = join32(workspace, "sandbox", sandboxId, "logs");
|
|
27788
|
+
mkdirSync3(logsDir, { recursive: true });
|
|
27789
|
+
const filename = generateLogFilename();
|
|
27790
|
+
logPath = join32(logsDir, filename);
|
|
27791
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
27792
|
+
writeFileSync2(
|
|
27793
|
+
logPath,
|
|
27794
|
+
`Agent SDK Execution Log - ${timestamp}
|
|
27795
|
+
${"=".repeat(60)}
|
|
27796
|
+
|
|
27797
|
+
`
|
|
27798
|
+
);
|
|
27799
|
+
return logPath;
|
|
27800
|
+
},
|
|
27801
|
+
log(message) {
|
|
27802
|
+
if (!logPath) {
|
|
27803
|
+
return;
|
|
27804
|
+
}
|
|
27805
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
27806
|
+
const logEntry = `[${timestamp}] ${JSON.stringify(message, null, 2)}
|
|
27807
|
+
|
|
27808
|
+
`;
|
|
27809
|
+
appendFileSync3(logPath, logEntry);
|
|
27810
|
+
},
|
|
27811
|
+
close() {
|
|
27812
|
+
},
|
|
27813
|
+
getLogPath() {
|
|
27814
|
+
return logPath;
|
|
27815
|
+
}
|
|
27816
|
+
};
|
|
27817
|
+
}
|
|
27793
27818
|
var DEFAULT_RATE_LIMIT_RETRY_MS = 6e4;
|
|
27794
27819
|
function mapException(error2) {
|
|
27795
27820
|
if (error2 instanceof Error) {
|
|
@@ -28624,18 +28649,9 @@ async function* executeAgenticQueryStreaming(prompt, jsonSchema, config2) {
|
|
|
28624
28649
|
const context = createTransformContext(
|
|
28625
28650
|
resolvedConfig.model
|
|
28626
28651
|
);
|
|
28627
|
-
const pluginPaths =
|
|
28628
|
-
if (process.env.LOOPLIA_DEBUG === "true") {
|
|
28629
|
-
console.error(
|
|
28630
|
-
"[LOOPLIA_DEBUG] Plugin paths:",
|
|
28631
|
-
JSON.stringify(pluginPaths)
|
|
28632
|
-
);
|
|
28633
|
-
}
|
|
28652
|
+
const pluginPaths = await getPluginPaths();
|
|
28634
28653
|
const userCwd = process.cwd();
|
|
28635
|
-
const loopliaHome =
|
|
28636
|
-
if (process.env.LOOPLIA_DEBUG === "true") {
|
|
28637
|
-
console.error("[LOOPLIA_DEBUG] loopliaHome:", loopliaHome);
|
|
28638
|
-
}
|
|
28654
|
+
const loopliaHome = getLoopliaPluginPath();
|
|
28639
28655
|
const claudeCodePath = findClaudeCodePath();
|
|
28640
28656
|
const result = query({
|
|
28641
28657
|
prompt,
|
|
@@ -28704,25 +28720,6 @@ When processing --file arguments or user file paths, resolve them against the Us
|
|
|
28704
28720
|
error: { type: "unknown", message: "No result received" }
|
|
28705
28721
|
};
|
|
28706
28722
|
} catch (error2) {
|
|
28707
|
-
if (process.env.LOOPLIA_DEBUG === "true") {
|
|
28708
|
-
const debugInfo = {
|
|
28709
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
28710
|
-
errorType: error2 instanceof Error ? error2.constructor.name : typeof error2,
|
|
28711
|
-
errorMessage: error2 instanceof Error ? error2.message : String(error2),
|
|
28712
|
-
errorStack: error2 instanceof Error ? error2.stack : void 0,
|
|
28713
|
-
cwd: process.cwd(),
|
|
28714
|
-
loopliaHome: getLoopliaPluginPath(),
|
|
28715
|
-
env: {
|
|
28716
|
-
LOOPLIA_DEBUG: process.env.LOOPLIA_DEBUG,
|
|
28717
|
-
NODE_ENV: process.env.NODE_ENV,
|
|
28718
|
-
HOME: process.env.HOME
|
|
28719
|
-
}
|
|
28720
|
-
};
|
|
28721
|
-
console.error(
|
|
28722
|
-
"[LOOPLIA_DEBUG] SDK Error:",
|
|
28723
|
-
JSON.stringify(debugInfo, null, 2)
|
|
28724
|
-
);
|
|
28725
|
-
}
|
|
28726
28723
|
return mapException(error2);
|
|
28727
28724
|
}
|
|
28728
28725
|
}
|
|
@@ -31465,19 +31462,6 @@ function ensureWorkspace2(mock) {
|
|
|
31465
31462
|
}
|
|
31466
31463
|
return workspace;
|
|
31467
31464
|
}
|
|
31468
|
-
function validateEnvironment(mock) {
|
|
31469
|
-
if (mock) {
|
|
31470
|
-
return;
|
|
31471
|
-
}
|
|
31472
|
-
if (!(process.env.ANTHROPIC_API_KEY || process.env.CLAUDE_CODE_OAUTH_TOKEN)) {
|
|
31473
|
-
console.error(
|
|
31474
|
-
"Error: ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN required"
|
|
31475
|
-
);
|
|
31476
|
-
console.error("Get your API key from: https://console.anthropic.com");
|
|
31477
|
-
console.error("Or use --mock flag to run without API key");
|
|
31478
|
-
process.exit(1);
|
|
31479
|
-
}
|
|
31480
|
-
}
|
|
31481
31465
|
function buildPrompt(args) {
|
|
31482
31466
|
let prompt = BUILD_COMMAND;
|
|
31483
31467
|
if (args.name) {
|
|
@@ -31668,8 +31652,8 @@ async function runBuildCommand(args) {
|
|
|
31668
31652
|
return;
|
|
31669
31653
|
}
|
|
31670
31654
|
try {
|
|
31671
|
-
validateEnvironment(parsed.mock);
|
|
31672
31655
|
const workspace = ensureWorkspace2(parsed.mock);
|
|
31656
|
+
await initializeCommandEnvironment({ mock: parsed.mock });
|
|
31673
31657
|
const prompt = buildPrompt(parsed);
|
|
31674
31658
|
const result = await executeBuild(prompt, workspace, parsed);
|
|
31675
31659
|
renderResult(result);
|
|
@@ -33083,19 +33067,6 @@ function ensureWorkspace3(mock) {
|
|
|
33083
33067
|
}
|
|
33084
33068
|
return workspace;
|
|
33085
33069
|
}
|
|
33086
|
-
function validateEnvironment2(mock) {
|
|
33087
|
-
if (mock) {
|
|
33088
|
-
return;
|
|
33089
|
-
}
|
|
33090
|
-
if (!(process.env.ANTHROPIC_API_KEY || process.env.CLAUDE_CODE_OAUTH_TOKEN)) {
|
|
33091
|
-
console.error(
|
|
33092
|
-
"Error: ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN required"
|
|
33093
|
-
);
|
|
33094
|
-
console.error("Get your API key from: https://console.anthropic.com");
|
|
33095
|
-
console.error("Or use --mock flag to run without API key");
|
|
33096
|
-
process.exit(1);
|
|
33097
|
-
}
|
|
33098
|
-
}
|
|
33099
33070
|
function buildRunPrompt(workflowId, sandboxId) {
|
|
33100
33071
|
return `${RUN_COMMAND} ${workflowId} --sandbox-id ${sandboxId}`;
|
|
33101
33072
|
}
|
|
@@ -33243,11 +33214,7 @@ async function runRunCommand(args) {
|
|
|
33243
33214
|
const workspace = ensureWorkspace3(parsed.mock);
|
|
33244
33215
|
const allowInputless = checkWorkflowInputless(workspace, parsed.workflowId);
|
|
33245
33216
|
const sandboxId = resolveSandboxId(workspace, parsed, allowInputless);
|
|
33246
|
-
|
|
33247
|
-
if (settings) {
|
|
33248
|
-
injectLoopliaSettingsEnv(settings);
|
|
33249
|
-
}
|
|
33250
|
-
validateEnvironment2(parsed.mock);
|
|
33217
|
+
await initializeCommandEnvironment({ mock: parsed.mock });
|
|
33251
33218
|
const prompt = buildRunPrompt(parsed.workflowId, sandboxId);
|
|
33252
33219
|
const result = await executeWorkflow(
|
|
33253
33220
|
prompt,
|
|
@@ -33267,7 +33234,7 @@ async function runRunCommand(args) {
|
|
|
33267
33234
|
}
|
|
33268
33235
|
|
|
33269
33236
|
// src/index.ts
|
|
33270
|
-
var VERSION = "0.6.
|
|
33237
|
+
var VERSION = "0.6.10";
|
|
33271
33238
|
function printHelp3() {
|
|
33272
33239
|
console.log(`
|
|
33273
33240
|
looplia - Content intelligence CLI (v${VERSION})
|