@inkeep/agents-cli 0.0.0-dev-20251015173613 → 0.0.0-dev-20251015192416
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/index.js +288 -72
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -5025,7 +5025,7 @@ var require_util = __commonJS({
|
|
|
5025
5025
|
return path4;
|
|
5026
5026
|
}
|
|
5027
5027
|
exports.normalize = normalize;
|
|
5028
|
-
function
|
|
5028
|
+
function join14(aRoot, aPath) {
|
|
5029
5029
|
if (aRoot === "") {
|
|
5030
5030
|
aRoot = ".";
|
|
5031
5031
|
}
|
|
@@ -5057,7 +5057,7 @@ var require_util = __commonJS({
|
|
|
5057
5057
|
}
|
|
5058
5058
|
return joined;
|
|
5059
5059
|
}
|
|
5060
|
-
exports.join =
|
|
5060
|
+
exports.join = join14;
|
|
5061
5061
|
exports.isAbsolute = function(aPath) {
|
|
5062
5062
|
return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
|
|
5063
5063
|
};
|
|
@@ -5230,7 +5230,7 @@ var require_util = __commonJS({
|
|
|
5230
5230
|
parsed.path = parsed.path.substring(0, index2 + 1);
|
|
5231
5231
|
}
|
|
5232
5232
|
}
|
|
5233
|
-
sourceURL =
|
|
5233
|
+
sourceURL = join14(urlGenerate(parsed), sourceURL);
|
|
5234
5234
|
}
|
|
5235
5235
|
return normalize(sourceURL);
|
|
5236
5236
|
}
|
|
@@ -235299,11 +235299,11 @@ export const ${environment} = registerEnvironmentSettings({
|
|
|
235299
235299
|
}
|
|
235300
235300
|
async function updateEnvironmentIndex(environmentsDir, environment) {
|
|
235301
235301
|
const indexPath = join6(environmentsDir, "index.ts");
|
|
235302
|
-
const { readFileSync:
|
|
235302
|
+
const { readFileSync: readFileSync8, existsSync: existsSync12 } = await import("fs");
|
|
235303
235303
|
const existingEnvironments = [];
|
|
235304
235304
|
let existingContent = "";
|
|
235305
|
-
if (
|
|
235306
|
-
existingContent =
|
|
235305
|
+
if (existsSync12(indexPath)) {
|
|
235306
|
+
existingContent = readFileSync8(indexPath, "utf-8");
|
|
235307
235307
|
const importRegex = /import\s+{\s*(\w+)\s*}\s+from\s+['"]\.\/([\w-]+)\.env['"];?/g;
|
|
235308
235308
|
let match;
|
|
235309
235309
|
while ((match = importRegex.exec(existingContent)) !== null) {
|
|
@@ -237393,36 +237393,36 @@ function comparePatterns(oldPatterns, newPatterns, diff) {
|
|
|
237393
237393
|
}
|
|
237394
237394
|
}
|
|
237395
237395
|
function displayPlanDiff(diff) {
|
|
237396
|
-
const
|
|
237396
|
+
const chalk12 = __require("chalk");
|
|
237397
237397
|
if (diff.filesAdded.length === 0 && diff.filesRemoved.length === 0 && diff.registryChanges.length === 0 && diff.patternChanges.length === 0) {
|
|
237398
|
-
console.log(
|
|
237398
|
+
console.log(chalk12.green("No changes detected"));
|
|
237399
237399
|
return;
|
|
237400
237400
|
}
|
|
237401
|
-
console.log(
|
|
237401
|
+
console.log(chalk12.cyan("\n\u{1F4DD} Changes since last pull:"));
|
|
237402
237402
|
if (diff.filesAdded.length > 0) {
|
|
237403
|
-
console.log(
|
|
237403
|
+
console.log(chalk12.green("\n Files added:"));
|
|
237404
237404
|
for (const file of diff.filesAdded) {
|
|
237405
|
-
console.log(
|
|
237405
|
+
console.log(chalk12.green(` + ${file}`));
|
|
237406
237406
|
}
|
|
237407
237407
|
}
|
|
237408
237408
|
if (diff.filesRemoved.length > 0) {
|
|
237409
|
-
console.log(
|
|
237409
|
+
console.log(chalk12.red("\n Files removed:"));
|
|
237410
237410
|
for (const file of diff.filesRemoved) {
|
|
237411
|
-
console.log(
|
|
237411
|
+
console.log(chalk12.red(` - ${file}`));
|
|
237412
237412
|
}
|
|
237413
237413
|
}
|
|
237414
237414
|
if (diff.registryChanges.length > 0) {
|
|
237415
|
-
console.log(
|
|
237415
|
+
console.log(chalk12.yellow("\n Variable name changes:"));
|
|
237416
237416
|
for (const change of diff.registryChanges) {
|
|
237417
|
-
console.log(
|
|
237418
|
-
console.log(
|
|
237417
|
+
console.log(chalk12.yellow(` \u2022 ${change.type}.${change.id}:`));
|
|
237418
|
+
console.log(chalk12.gray(` ${change.oldName} \u2192 ${change.newName}`));
|
|
237419
237419
|
}
|
|
237420
237420
|
}
|
|
237421
237421
|
if (diff.patternChanges.length > 0) {
|
|
237422
|
-
console.log(
|
|
237422
|
+
console.log(chalk12.yellow("\n Pattern changes:"));
|
|
237423
237423
|
for (const change of diff.patternChanges) {
|
|
237424
|
-
console.log(
|
|
237425
|
-
console.log(
|
|
237424
|
+
console.log(chalk12.yellow(` \u2022 ${change.field}:`));
|
|
237425
|
+
console.log(chalk12.gray(` ${change.oldValue} \u2192 ${change.newValue}`));
|
|
237426
237426
|
}
|
|
237427
237427
|
}
|
|
237428
237428
|
}
|
|
@@ -237451,11 +237451,11 @@ __export(chat_enhanced_exports, {
|
|
|
237451
237451
|
chatCommandEnhanced: () => chatCommandEnhanced
|
|
237452
237452
|
});
|
|
237453
237453
|
import * as readline from "readline";
|
|
237454
|
-
import
|
|
237454
|
+
import chalk11 from "chalk";
|
|
237455
237455
|
import inquirer2 from "inquirer";
|
|
237456
|
-
import
|
|
237456
|
+
import ora8 from "ora";
|
|
237457
237457
|
async function chatCommandEnhanced(agentIdInput, options) {
|
|
237458
|
-
console.log(
|
|
237458
|
+
console.log(chalk11.cyan("\u{1F916} Inkeep Chat Interface\n"));
|
|
237459
237459
|
const configPath = options?.config || options?.configFilePath;
|
|
237460
237460
|
const { config } = await initializeCommand({
|
|
237461
237461
|
configPath,
|
|
@@ -237475,18 +237475,18 @@ async function chatCommandEnhanced(agentIdInput, options) {
|
|
|
237475
237475
|
);
|
|
237476
237476
|
let agentId = agentIdInput;
|
|
237477
237477
|
if (!agentId) {
|
|
237478
|
-
const spinner2 =
|
|
237478
|
+
const spinner2 = ora8("Fetching available agent...").start();
|
|
237479
237479
|
try {
|
|
237480
237480
|
const agent = await managementApi.listAgents();
|
|
237481
237481
|
spinner2.stop();
|
|
237482
237482
|
if (agent.length === 0) {
|
|
237483
237483
|
console.error(
|
|
237484
|
-
|
|
237484
|
+
chalk11.red("No agent available. Define agent in your project and run: inkeep push")
|
|
237485
237485
|
);
|
|
237486
237486
|
process.exit(1);
|
|
237487
237487
|
}
|
|
237488
237488
|
const agentChoices = agent.map((g) => ({
|
|
237489
|
-
name: `${
|
|
237489
|
+
name: `${chalk11.cyan(g.id)} - ${g.name || "Unnamed Agent"}`,
|
|
237490
237490
|
value: g.id,
|
|
237491
237491
|
short: g.id,
|
|
237492
237492
|
searchText: `${g.id} ${g.name || ""}`.toLowerCase()
|
|
@@ -237503,11 +237503,11 @@ async function chatCommandEnhanced(agentIdInput, options) {
|
|
|
237503
237503
|
agentId = answer.agentId;
|
|
237504
237504
|
} catch (error) {
|
|
237505
237505
|
spinner2.fail("Failed to fetch agent");
|
|
237506
|
-
console.error(
|
|
237506
|
+
console.error(chalk11.red("Error:"), error instanceof Error ? error.message : error);
|
|
237507
237507
|
process.exit(1);
|
|
237508
237508
|
}
|
|
237509
237509
|
}
|
|
237510
|
-
const spinner =
|
|
237510
|
+
const spinner = ora8("Connecting to agent...").start();
|
|
237511
237511
|
try {
|
|
237512
237512
|
if (!agentId) {
|
|
237513
237513
|
throw new Error("No agent selected");
|
|
@@ -237517,38 +237517,38 @@ async function chatCommandEnhanced(agentIdInput, options) {
|
|
|
237517
237517
|
spinner.fail(`Agent "${agentId}" not found`);
|
|
237518
237518
|
const agent2 = await managementApi.listAgents();
|
|
237519
237519
|
if (agent2.length > 0) {
|
|
237520
|
-
console.log(
|
|
237520
|
+
console.log(chalk11.yellow("\nAvailable agent:"));
|
|
237521
237521
|
agent2.forEach((g) => {
|
|
237522
|
-
console.log(
|
|
237522
|
+
console.log(chalk11.gray(` \u2022 ${g.id} - ${g.name || "Unnamed"}`));
|
|
237523
237523
|
});
|
|
237524
|
-
console.log(
|
|
237524
|
+
console.log(chalk11.gray('\nRun "inkeep chat" without arguments for interactive selection'));
|
|
237525
237525
|
} else {
|
|
237526
|
-
console.log(
|
|
237526
|
+
console.log(chalk11.yellow("\nNo agent found. Please define agent and push your project."));
|
|
237527
237527
|
}
|
|
237528
237528
|
process.exit(1);
|
|
237529
237529
|
}
|
|
237530
|
-
spinner.succeed(`Connected to agent: ${
|
|
237530
|
+
spinner.succeed(`Connected to agent: ${chalk11.green(agent.name || agentId)}`);
|
|
237531
237531
|
if (agent.description) {
|
|
237532
|
-
console.log(
|
|
237532
|
+
console.log(chalk11.gray(`Description: ${agent.description}`));
|
|
237533
237533
|
}
|
|
237534
237534
|
if (agent.defaultSubAgentId) {
|
|
237535
|
-
console.log(
|
|
237535
|
+
console.log(chalk11.gray(`Default Agent: ${agent.defaultSubAgentId}`));
|
|
237536
237536
|
}
|
|
237537
237537
|
} catch (error) {
|
|
237538
237538
|
spinner.fail("Failed to connect to agent");
|
|
237539
|
-
console.error(
|
|
237539
|
+
console.error(chalk11.red("Error:"), error instanceof Error ? error.message : error);
|
|
237540
237540
|
process.exit(1);
|
|
237541
237541
|
}
|
|
237542
237542
|
const rl = readline.createInterface({
|
|
237543
237543
|
input: process.stdin,
|
|
237544
237544
|
output: process.stdout,
|
|
237545
|
-
prompt:
|
|
237545
|
+
prompt: chalk11.cyan("You> ")
|
|
237546
237546
|
});
|
|
237547
237547
|
const conversationId = `cli-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
237548
237548
|
const messages2 = [];
|
|
237549
237549
|
let emitOperations = false;
|
|
237550
|
-
console.log(
|
|
237551
|
-
console.log(
|
|
237550
|
+
console.log(chalk11.gray('\n\u{1F4AC} Chat session started. Type "exit" or press Ctrl+C to quit.'));
|
|
237551
|
+
console.log(chalk11.gray("Commands: help, clear, history, reset, operations\n"));
|
|
237552
237552
|
async function handleStreamingResponse(stream, showDebug = false) {
|
|
237553
237553
|
const decoder = new TextDecoder();
|
|
237554
237554
|
const reader = stream.getReader();
|
|
@@ -237615,12 +237615,12 @@ async function chatCommandEnhanced(agentIdInput, options) {
|
|
|
237615
237615
|
if (opType === "completion" && hasStartedResponse) {
|
|
237616
237616
|
console.log("");
|
|
237617
237617
|
}
|
|
237618
|
-
console.log(
|
|
237618
|
+
console.log(chalk11.gray(` [${opType}] ${displayText}`));
|
|
237619
237619
|
}
|
|
237620
237620
|
currentPos = jsonEnd;
|
|
237621
237621
|
} catch {
|
|
237622
237622
|
if (!hasStartedResponse) {
|
|
237623
|
-
process.stdout.write(
|
|
237623
|
+
process.stdout.write(chalk11.green("Assistant> "));
|
|
237624
237624
|
hasStartedResponse = true;
|
|
237625
237625
|
}
|
|
237626
237626
|
process.stdout.write(content[currentPos]);
|
|
@@ -237629,7 +237629,7 @@ async function chatCommandEnhanced(agentIdInput, options) {
|
|
|
237629
237629
|
}
|
|
237630
237630
|
} else {
|
|
237631
237631
|
if (!hasStartedResponse) {
|
|
237632
|
-
process.stdout.write(
|
|
237632
|
+
process.stdout.write(chalk11.green("Assistant> "));
|
|
237633
237633
|
hasStartedResponse = true;
|
|
237634
237634
|
}
|
|
237635
237635
|
process.stdout.write(content[currentPos]);
|
|
@@ -237649,7 +237649,7 @@ async function chatCommandEnhanced(agentIdInput, options) {
|
|
|
237649
237649
|
if (hasStartedResponse) {
|
|
237650
237650
|
console.log("\n");
|
|
237651
237651
|
} else {
|
|
237652
|
-
console.log(`${
|
|
237652
|
+
console.log(`${chalk11.green("Assistant> ") + chalk11.gray("(no response)")}
|
|
237653
237653
|
`);
|
|
237654
237654
|
}
|
|
237655
237655
|
return responseContent;
|
|
@@ -237658,49 +237658,49 @@ async function chatCommandEnhanced(agentIdInput, options) {
|
|
|
237658
237658
|
const trimmedInput = input.trim();
|
|
237659
237659
|
const command = trimmedInput.toLowerCase().replace(/^\//, "");
|
|
237660
237660
|
if (command === "exit") {
|
|
237661
|
-
console.log(
|
|
237661
|
+
console.log(chalk11.gray("Goodbye! \u{1F44B}"));
|
|
237662
237662
|
rl.close();
|
|
237663
237663
|
process.exit(0);
|
|
237664
237664
|
}
|
|
237665
237665
|
if (command === "clear") {
|
|
237666
237666
|
console.clear();
|
|
237667
|
-
console.log(
|
|
237667
|
+
console.log(chalk11.gray("Screen cleared. Conversation context preserved.\n"));
|
|
237668
237668
|
rl.prompt();
|
|
237669
237669
|
return;
|
|
237670
237670
|
}
|
|
237671
237671
|
if (command === "help") {
|
|
237672
|
-
console.log(
|
|
237673
|
-
console.log(
|
|
237674
|
-
console.log(
|
|
237675
|
-
console.log(
|
|
237676
|
-
console.log(
|
|
237672
|
+
console.log(chalk11.cyan("\n\u{1F4DA} Available commands:"));
|
|
237673
|
+
console.log(chalk11.gray(" \u2022 exit - End the chat session"));
|
|
237674
|
+
console.log(chalk11.gray(" \u2022 clear - Clear the screen (preserves context)"));
|
|
237675
|
+
console.log(chalk11.gray(" \u2022 history - Show conversation history"));
|
|
237676
|
+
console.log(chalk11.gray(" \u2022 reset - Reset conversation context"));
|
|
237677
237677
|
console.log(
|
|
237678
|
-
|
|
237678
|
+
chalk11.gray(" \u2022 operations - Toggle emit operations (show/hide data operations)")
|
|
237679
237679
|
);
|
|
237680
|
-
console.log(
|
|
237681
|
-
console.log(
|
|
237680
|
+
console.log(chalk11.gray(" \u2022 help - Show this help message"));
|
|
237681
|
+
console.log(chalk11.gray("\n Commands can be prefixed with / (e.g., /help)\n"));
|
|
237682
237682
|
rl.prompt();
|
|
237683
237683
|
return;
|
|
237684
237684
|
}
|
|
237685
237685
|
if (command === "operations") {
|
|
237686
237686
|
emitOperations = !emitOperations;
|
|
237687
|
-
console.log(
|
|
237687
|
+
console.log(chalk11.yellow(`
|
|
237688
237688
|
\u{1F527} Data operations: ${emitOperations ? "ON" : "OFF"}`));
|
|
237689
237689
|
if (emitOperations) {
|
|
237690
|
-
console.log(
|
|
237690
|
+
console.log(chalk11.gray("Data operations will be shown during responses.\n"));
|
|
237691
237691
|
} else {
|
|
237692
|
-
console.log(
|
|
237692
|
+
console.log(chalk11.gray("Data operations are hidden.\n"));
|
|
237693
237693
|
}
|
|
237694
237694
|
rl.prompt();
|
|
237695
237695
|
return;
|
|
237696
237696
|
}
|
|
237697
237697
|
if (command === "history") {
|
|
237698
|
-
console.log(
|
|
237698
|
+
console.log(chalk11.cyan("\n\u{1F4DC} Conversation History:"));
|
|
237699
237699
|
if (messages2.length === 0) {
|
|
237700
|
-
console.log(
|
|
237700
|
+
console.log(chalk11.gray(" (No messages yet)\n"));
|
|
237701
237701
|
} else {
|
|
237702
237702
|
messages2.forEach((msg, idx) => {
|
|
237703
|
-
const role = msg.role === "user" ?
|
|
237703
|
+
const role = msg.role === "user" ? chalk11.blue("You") : chalk11.green("Assistant");
|
|
237704
237704
|
const preview = msg.content.substring(0, 100);
|
|
237705
237705
|
const suffix = msg.content.length > 100 ? "..." : "";
|
|
237706
237706
|
console.log(` ${idx + 1}. ${role}: ${preview}${suffix}`);
|
|
@@ -237712,7 +237712,7 @@ async function chatCommandEnhanced(agentIdInput, options) {
|
|
|
237712
237712
|
}
|
|
237713
237713
|
if (command === "reset") {
|
|
237714
237714
|
messages2.length = 0;
|
|
237715
|
-
console.log(
|
|
237715
|
+
console.log(chalk11.yellow("\u26A0\uFE0F Conversation context has been reset.\n"));
|
|
237716
237716
|
rl.prompt();
|
|
237717
237717
|
return;
|
|
237718
237718
|
}
|
|
@@ -237731,23 +237731,23 @@ async function chatCommandEnhanced(agentIdInput, options) {
|
|
|
237731
237731
|
);
|
|
237732
237732
|
let assistantResponse;
|
|
237733
237733
|
if (typeof response === "string") {
|
|
237734
|
-
console.log(
|
|
237734
|
+
console.log(chalk11.green("Assistant>"), response);
|
|
237735
237735
|
assistantResponse = response;
|
|
237736
237736
|
} else {
|
|
237737
237737
|
assistantResponse = await handleStreamingResponse(response, emitOperations);
|
|
237738
237738
|
}
|
|
237739
237739
|
messages2.push({ role: "assistant", content: assistantResponse });
|
|
237740
237740
|
} catch (error) {
|
|
237741
|
-
console.error(
|
|
237741
|
+
console.error(chalk11.red("Error:"), error instanceof Error ? error.message : error);
|
|
237742
237742
|
}
|
|
237743
237743
|
rl.prompt();
|
|
237744
237744
|
});
|
|
237745
237745
|
rl.on("close", () => {
|
|
237746
|
-
console.log(
|
|
237747
|
-
console.log(
|
|
237748
|
-
console.log(
|
|
237749
|
-
console.log(
|
|
237750
|
-
console.log(
|
|
237746
|
+
console.log(chalk11.gray("\n\u{1F4CA} Session Summary:"));
|
|
237747
|
+
console.log(chalk11.gray(` \u2022 Agent: ${agentId}`));
|
|
237748
|
+
console.log(chalk11.gray(` \u2022 Messages: ${messages2.length}`));
|
|
237749
|
+
console.log(chalk11.gray(` \u2022 Duration: ${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`));
|
|
237750
|
+
console.log(chalk11.gray("\nChat session ended."));
|
|
237751
237751
|
process.exit(0);
|
|
237752
237752
|
});
|
|
237753
237753
|
rl.prompt();
|
|
@@ -237792,9 +237792,9 @@ ${error.message}`
|
|
|
237792
237792
|
var env2 = parseEnv2();
|
|
237793
237793
|
|
|
237794
237794
|
// src/index.ts
|
|
237795
|
-
import { readFileSync as
|
|
237796
|
-
import { dirname as
|
|
237797
|
-
import { fileURLToPath as
|
|
237795
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
237796
|
+
import { dirname as dirname6, join as join13 } from "path";
|
|
237797
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
237798
237798
|
import { Command } from "commander";
|
|
237799
237799
|
|
|
237800
237800
|
// src/commands/add.ts
|
|
@@ -239529,11 +239529,224 @@ async function pushCommand(options) {
|
|
|
239529
239529
|
}
|
|
239530
239530
|
}
|
|
239531
239531
|
|
|
239532
|
-
// src/
|
|
239532
|
+
// src/commands/update.ts
|
|
239533
|
+
init_esm_shims();
|
|
239534
|
+
import chalk10 from "chalk";
|
|
239535
|
+
import ora7 from "ora";
|
|
239536
|
+
import prompts2 from "prompts";
|
|
239537
|
+
|
|
239538
|
+
// src/utils/package-manager.ts
|
|
239539
|
+
init_esm_shims();
|
|
239540
|
+
import { exec } from "child_process";
|
|
239541
|
+
import { promisify as promisify2 } from "util";
|
|
239542
|
+
|
|
239543
|
+
// src/utils/version-check.ts
|
|
239544
|
+
init_esm_shims();
|
|
239545
|
+
import { existsSync as existsSync11, readFileSync as readFileSync6 } from "fs";
|
|
239546
|
+
import { dirname as dirname5, join as join12 } from "path";
|
|
239547
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
239533
239548
|
var __filename2 = fileURLToPath2(import.meta.url);
|
|
239534
239549
|
var __dirname2 = dirname5(__filename2);
|
|
239535
|
-
var
|
|
239536
|
-
|
|
239550
|
+
var DEFAULT_PACKAGE_NAME = "@inkeep/agents-cli";
|
|
239551
|
+
function getCurrentVersion() {
|
|
239552
|
+
let packageJsonPath2 = join12(__dirname2, "..", "package.json");
|
|
239553
|
+
if (!existsSync11(packageJsonPath2)) {
|
|
239554
|
+
packageJsonPath2 = join12(__dirname2, "..", "..", "package.json");
|
|
239555
|
+
}
|
|
239556
|
+
const packageJson2 = JSON.parse(readFileSync6(packageJsonPath2, "utf-8"));
|
|
239557
|
+
return packageJson2.version;
|
|
239558
|
+
}
|
|
239559
|
+
async function getLatestVersion(packageName = DEFAULT_PACKAGE_NAME) {
|
|
239560
|
+
const controller = new AbortController();
|
|
239561
|
+
const timeoutId = setTimeout(() => controller.abort(), 1e4);
|
|
239562
|
+
try {
|
|
239563
|
+
const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
|
|
239564
|
+
signal: controller.signal
|
|
239565
|
+
});
|
|
239566
|
+
if (!response.ok) {
|
|
239567
|
+
throw new Error(`Failed to fetch latest version: ${response.statusText}`);
|
|
239568
|
+
}
|
|
239569
|
+
const data = await response.json();
|
|
239570
|
+
return data.version;
|
|
239571
|
+
} catch (error) {
|
|
239572
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
239573
|
+
throw new Error("Unable to check for updates: Request timed out after 10 seconds");
|
|
239574
|
+
}
|
|
239575
|
+
throw new Error(
|
|
239576
|
+
`Unable to check for updates: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
239577
|
+
);
|
|
239578
|
+
} finally {
|
|
239579
|
+
clearTimeout(timeoutId);
|
|
239580
|
+
}
|
|
239581
|
+
}
|
|
239582
|
+
function compareVersions(v1, v2) {
|
|
239583
|
+
const cleanV1 = v1.split("-")[0].split("+")[0];
|
|
239584
|
+
const cleanV2 = v2.split("-")[0].split("+")[0];
|
|
239585
|
+
const parts1 = cleanV1.split(".").map(Number);
|
|
239586
|
+
const parts2 = cleanV2.split(".").map(Number);
|
|
239587
|
+
for (let i2 = 0; i2 < Math.max(parts1.length, parts2.length); i2++) {
|
|
239588
|
+
const part1 = parts1[i2] || 0;
|
|
239589
|
+
const part2 = parts2[i2] || 0;
|
|
239590
|
+
if (part1 < part2) return -1;
|
|
239591
|
+
if (part1 > part2) return 1;
|
|
239592
|
+
}
|
|
239593
|
+
return 0;
|
|
239594
|
+
}
|
|
239595
|
+
async function checkForUpdate() {
|
|
239596
|
+
const current = getCurrentVersion();
|
|
239597
|
+
const latest = await getLatestVersion();
|
|
239598
|
+
const needsUpdate = compareVersions(current, latest) < 0;
|
|
239599
|
+
return {
|
|
239600
|
+
current,
|
|
239601
|
+
latest,
|
|
239602
|
+
needsUpdate
|
|
239603
|
+
};
|
|
239604
|
+
}
|
|
239605
|
+
function getChangelogUrl() {
|
|
239606
|
+
return `https://github.com/inkeep/agents/blob/main/agents-cli/CHANGELOG.md`;
|
|
239607
|
+
}
|
|
239608
|
+
|
|
239609
|
+
// src/utils/package-manager.ts
|
|
239610
|
+
var execAsync = promisify2(exec);
|
|
239611
|
+
async function detectPackageManager() {
|
|
239612
|
+
const managers = ["pnpm", "bun", "npm", "yarn"];
|
|
239613
|
+
for (const manager of managers) {
|
|
239614
|
+
try {
|
|
239615
|
+
if (manager === "npm") {
|
|
239616
|
+
const { stdout } = await execAsync(`npm list -g ${DEFAULT_PACKAGE_NAME} --depth=0`);
|
|
239617
|
+
if (stdout.includes(DEFAULT_PACKAGE_NAME)) {
|
|
239618
|
+
return "npm";
|
|
239619
|
+
}
|
|
239620
|
+
} else if (manager === "pnpm") {
|
|
239621
|
+
const { stdout } = await execAsync(`pnpm list -g ${DEFAULT_PACKAGE_NAME} --depth=0`);
|
|
239622
|
+
if (stdout.includes(DEFAULT_PACKAGE_NAME)) {
|
|
239623
|
+
return "pnpm";
|
|
239624
|
+
}
|
|
239625
|
+
} else if (manager === "bun") {
|
|
239626
|
+
const { stdout } = await execAsync("bun pm ls -g");
|
|
239627
|
+
if (stdout.includes(DEFAULT_PACKAGE_NAME)) {
|
|
239628
|
+
return "bun";
|
|
239629
|
+
}
|
|
239630
|
+
} else if (manager === "yarn") {
|
|
239631
|
+
const { stdout } = await execAsync("yarn global list");
|
|
239632
|
+
if (stdout.includes(DEFAULT_PACKAGE_NAME)) {
|
|
239633
|
+
return "yarn";
|
|
239634
|
+
}
|
|
239635
|
+
}
|
|
239636
|
+
} catch {
|
|
239637
|
+
}
|
|
239638
|
+
}
|
|
239639
|
+
return null;
|
|
239640
|
+
}
|
|
239641
|
+
function getUpdateCommand(manager, packageName = DEFAULT_PACKAGE_NAME) {
|
|
239642
|
+
switch (manager) {
|
|
239643
|
+
case "npm":
|
|
239644
|
+
return `npm install -g ${packageName}@latest`;
|
|
239645
|
+
case "pnpm":
|
|
239646
|
+
return `pnpm add -g ${packageName}@latest`;
|
|
239647
|
+
case "bun":
|
|
239648
|
+
return `bun add -g ${packageName}@latest`;
|
|
239649
|
+
case "yarn":
|
|
239650
|
+
return `yarn global add ${packageName}@latest`;
|
|
239651
|
+
}
|
|
239652
|
+
}
|
|
239653
|
+
async function executeUpdate(manager) {
|
|
239654
|
+
const allowedManagers = ["npm", "pnpm", "bun", "yarn"];
|
|
239655
|
+
if (!allowedManagers.includes(manager)) {
|
|
239656
|
+
throw new Error(`Unsupported package manager: ${manager}`);
|
|
239657
|
+
}
|
|
239658
|
+
const command = getUpdateCommand(manager);
|
|
239659
|
+
await execAsync(command);
|
|
239660
|
+
}
|
|
239661
|
+
|
|
239662
|
+
// src/commands/update.ts
|
|
239663
|
+
async function updateCommand(options = {}) {
|
|
239664
|
+
const spinner = ora7("Checking for updates...").start();
|
|
239665
|
+
try {
|
|
239666
|
+
const versionInfo = await checkForUpdate();
|
|
239667
|
+
spinner.stop();
|
|
239668
|
+
console.log(chalk10.cyan("\n\u{1F4E6} Version Information:"));
|
|
239669
|
+
console.log(chalk10.gray(` \u2022 Current version: ${versionInfo.current}`));
|
|
239670
|
+
console.log(chalk10.gray(` \u2022 Latest version: ${versionInfo.latest}`));
|
|
239671
|
+
if (options.check) {
|
|
239672
|
+
if (versionInfo.needsUpdate) {
|
|
239673
|
+
console.log(chalk10.yellow("\n\u26A0\uFE0F An update is available!"));
|
|
239674
|
+
console.log(chalk10.gray(` \u2022 Run ${chalk10.cyan("inkeep update")} to update`));
|
|
239675
|
+
} else {
|
|
239676
|
+
console.log(chalk10.green("\n\u2705 You are on the latest version"));
|
|
239677
|
+
}
|
|
239678
|
+
return;
|
|
239679
|
+
}
|
|
239680
|
+
if (!versionInfo.needsUpdate && !options.force) {
|
|
239681
|
+
console.log(chalk10.green("\n\u2705 You are already on the latest version"));
|
|
239682
|
+
return;
|
|
239683
|
+
}
|
|
239684
|
+
if (!versionInfo.needsUpdate && options.force) {
|
|
239685
|
+
console.log(chalk10.yellow("\n\u26A0\uFE0F Forcing reinstall of current version..."));
|
|
239686
|
+
}
|
|
239687
|
+
console.log(chalk10.cyan("\n\u{1F4D6} Changelog:"));
|
|
239688
|
+
console.log(chalk10.gray(` \u2022 ${getChangelogUrl()}`));
|
|
239689
|
+
spinner.start("Detecting package manager...");
|
|
239690
|
+
const detectedManager = await detectPackageManager();
|
|
239691
|
+
spinner.stop();
|
|
239692
|
+
let packageManager;
|
|
239693
|
+
if (!detectedManager) {
|
|
239694
|
+
console.log(chalk10.yellow("\n\u26A0\uFE0F Could not auto-detect package manager"));
|
|
239695
|
+
const response = await prompts2({
|
|
239696
|
+
type: "select",
|
|
239697
|
+
name: "manager",
|
|
239698
|
+
message: "Which package manager did you use to install the CLI?",
|
|
239699
|
+
choices: [
|
|
239700
|
+
{ title: "npm", value: "npm" },
|
|
239701
|
+
{ title: "pnpm", value: "pnpm" },
|
|
239702
|
+
{ title: "bun", value: "bun" },
|
|
239703
|
+
{ title: "yarn", value: "yarn" }
|
|
239704
|
+
]
|
|
239705
|
+
});
|
|
239706
|
+
if (!response.manager) {
|
|
239707
|
+
console.log(chalk10.red("\n\u274C Update cancelled"));
|
|
239708
|
+
process.exit(1);
|
|
239709
|
+
}
|
|
239710
|
+
packageManager = response.manager;
|
|
239711
|
+
} else {
|
|
239712
|
+
packageManager = detectedManager;
|
|
239713
|
+
console.log(chalk10.gray(`
|
|
239714
|
+
\u{1F50D} Detected package manager: ${chalk10.cyan(packageManager)}`));
|
|
239715
|
+
}
|
|
239716
|
+
if (!options.force) {
|
|
239717
|
+
const response = await prompts2({
|
|
239718
|
+
type: "confirm",
|
|
239719
|
+
name: "confirm",
|
|
239720
|
+
message: `Update @inkeep/agents-cli from ${versionInfo.current} to ${versionInfo.latest}?`,
|
|
239721
|
+
initial: true
|
|
239722
|
+
});
|
|
239723
|
+
if (!response.confirm) {
|
|
239724
|
+
console.log(chalk10.red("\n\u274C Update cancelled"));
|
|
239725
|
+
process.exit(1);
|
|
239726
|
+
}
|
|
239727
|
+
}
|
|
239728
|
+
spinner.start(`Updating @inkeep/agents-cli to ${versionInfo.latest}...`);
|
|
239729
|
+
await executeUpdate(packageManager);
|
|
239730
|
+
spinner.succeed(`Updated to version ${versionInfo.latest}`);
|
|
239731
|
+
console.log(chalk10.green("\n\u2728 Update completed successfully!"));
|
|
239732
|
+
console.log(chalk10.gray(` \u2022 New version: ${versionInfo.latest}`));
|
|
239733
|
+
console.log(chalk10.gray(` \u2022 Package manager: ${packageManager}`));
|
|
239734
|
+
} catch (error) {
|
|
239735
|
+
spinner.fail("Update failed");
|
|
239736
|
+
console.error(chalk10.red("\n\u274C Error:"), error.message);
|
|
239737
|
+
if (error.message.includes("EACCES") || error.message.includes("permission")) {
|
|
239738
|
+
console.log(chalk10.yellow("\n\u{1F4A1} Tip: Try running the command with elevated permissions:"));
|
|
239739
|
+
console.log(chalk10.gray(" \u2022 sudo inkeep update"));
|
|
239740
|
+
}
|
|
239741
|
+
process.exit(1);
|
|
239742
|
+
}
|
|
239743
|
+
}
|
|
239744
|
+
|
|
239745
|
+
// src/index.ts
|
|
239746
|
+
var __filename3 = fileURLToPath3(import.meta.url);
|
|
239747
|
+
var __dirname3 = dirname6(__filename3);
|
|
239748
|
+
var packageJsonPath = join13(__dirname3, "..", "package.json");
|
|
239749
|
+
var packageJson = JSON.parse(readFileSync7(packageJsonPath, "utf-8"));
|
|
239537
239750
|
var program = new Command();
|
|
239538
239751
|
program.name("inkeep").description("CLI tool for Inkeep Agent Framework").version(packageJson.version);
|
|
239539
239752
|
program.command("add [template]").description("Add a new template to the project").option("--target-path <path>", "Target path to add the template to").option("--config <path>", "Path to configuration file").action(async (template, options) => {
|
|
@@ -239588,6 +239801,9 @@ program.command("dev").description("Start the Inkeep dashboard server").option("
|
|
|
239588
239801
|
export: options.export
|
|
239589
239802
|
});
|
|
239590
239803
|
});
|
|
239804
|
+
program.command("update").description("Update @inkeep/agents-cli to the latest version").option("--check", "Check for updates without installing").option("--force", "Force update even if already on latest version").action(async (options) => {
|
|
239805
|
+
await updateCommand(options);
|
|
239806
|
+
});
|
|
239591
239807
|
program.parse();
|
|
239592
239808
|
/*! Bundled license information:
|
|
239593
239809
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-cli",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20251015192416",
|
|
4
4
|
"description": "Inkeep CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"recast": "^0.23.0",
|
|
47
47
|
"ts-morph": "^26.0.0",
|
|
48
48
|
"tsx": "^4.20.5",
|
|
49
|
-
"@inkeep/agents-core": "^0.0.0-dev-
|
|
50
|
-
"@inkeep/agents-sdk": "^0.0.0-dev-
|
|
49
|
+
"@inkeep/agents-core": "^0.0.0-dev-20251015192416",
|
|
50
|
+
"@inkeep/agents-sdk": "^0.0.0-dev-20251015192416"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/degit": "^2.8.6",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"vitest": "^3.2.4"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@inkeep/agents-manage-ui": "0.0.0-dev-
|
|
65
|
+
"@inkeep/agents-manage-ui": "0.0.0-dev-20251015192416",
|
|
66
66
|
"zod": "^4.1.11"
|
|
67
67
|
},
|
|
68
68
|
"engines": {
|