@inkeep/agents-cli 0.2.0 → 0.2.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/index.js +141 -60
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -440,9 +440,9 @@ __export(chat_enhanced_exports, {
|
|
|
440
440
|
chatCommandEnhanced: () => chatCommandEnhanced
|
|
441
441
|
});
|
|
442
442
|
import * as readline from "readline";
|
|
443
|
-
import
|
|
443
|
+
import chalk8 from "chalk";
|
|
444
444
|
import inquirer3 from "inquirer";
|
|
445
|
-
import
|
|
445
|
+
import ora6 from "ora";
|
|
446
446
|
async function chatCommandEnhanced(graphIdInput, options) {
|
|
447
447
|
let config;
|
|
448
448
|
try {
|
|
@@ -453,13 +453,13 @@ async function chatCommandEnhanced(graphIdInput, options) {
|
|
|
453
453
|
options?.configFilePath
|
|
454
454
|
);
|
|
455
455
|
} catch (error) {
|
|
456
|
-
console.error(
|
|
456
|
+
console.error(chalk8.red(error.message));
|
|
457
457
|
process.exit(1);
|
|
458
458
|
}
|
|
459
|
-
console.log(
|
|
460
|
-
console.log(
|
|
461
|
-
console.log(
|
|
462
|
-
console.log(
|
|
459
|
+
console.log(chalk8.gray("Using configuration:"));
|
|
460
|
+
console.log(chalk8.gray(` \u2022 Tenant ID: ${config.sources.tenantId}`));
|
|
461
|
+
console.log(chalk8.gray(` \u2022 Management API: ${config.sources.agentsManageApiUrl}`));
|
|
462
|
+
console.log(chalk8.gray(` \u2022 Execution API: ${config.sources.agentsRunApiUrl}`));
|
|
463
463
|
console.log();
|
|
464
464
|
const managementApi = await ManagementApiClient.create(
|
|
465
465
|
config.agentsManageApiUrl,
|
|
@@ -473,18 +473,18 @@ async function chatCommandEnhanced(graphIdInput, options) {
|
|
|
473
473
|
);
|
|
474
474
|
let graphId = graphIdInput;
|
|
475
475
|
if (!graphId) {
|
|
476
|
-
const spinner2 =
|
|
476
|
+
const spinner2 = ora6("Fetching available graphs...").start();
|
|
477
477
|
try {
|
|
478
478
|
const graphs = await managementApi.listGraphs();
|
|
479
479
|
spinner2.stop();
|
|
480
480
|
if (graphs.length === 0) {
|
|
481
481
|
console.error(
|
|
482
|
-
|
|
482
|
+
chalk8.red("No graphs available. Define graphs in your project and run: inkeep push")
|
|
483
483
|
);
|
|
484
484
|
process.exit(1);
|
|
485
485
|
}
|
|
486
486
|
const graphChoices = graphs.map((g) => ({
|
|
487
|
-
name: `${
|
|
487
|
+
name: `${chalk8.cyan(g.id)} - ${g.name || "Unnamed Graph"}`,
|
|
488
488
|
value: g.id,
|
|
489
489
|
short: g.id,
|
|
490
490
|
searchText: `${g.id} ${g.name || ""}`.toLowerCase()
|
|
@@ -501,11 +501,11 @@ async function chatCommandEnhanced(graphIdInput, options) {
|
|
|
501
501
|
graphId = answer.graphId;
|
|
502
502
|
} catch (error) {
|
|
503
503
|
spinner2.fail("Failed to fetch graphs");
|
|
504
|
-
console.error(
|
|
504
|
+
console.error(chalk8.red("Error:"), error instanceof Error ? error.message : error);
|
|
505
505
|
process.exit(1);
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
|
-
const spinner =
|
|
508
|
+
const spinner = ora6("Connecting to graph...").start();
|
|
509
509
|
try {
|
|
510
510
|
if (!graphId) {
|
|
511
511
|
throw new Error("No graph selected");
|
|
@@ -515,38 +515,38 @@ async function chatCommandEnhanced(graphIdInput, options) {
|
|
|
515
515
|
spinner.fail(`Graph "${graphId}" not found`);
|
|
516
516
|
const graphs = await managementApi.listGraphs();
|
|
517
517
|
if (graphs.length > 0) {
|
|
518
|
-
console.log(
|
|
518
|
+
console.log(chalk8.yellow("\nAvailable graphs:"));
|
|
519
519
|
graphs.forEach((g) => {
|
|
520
|
-
console.log(
|
|
520
|
+
console.log(chalk8.gray(` \u2022 ${g.id} - ${g.name || "Unnamed"}`));
|
|
521
521
|
});
|
|
522
|
-
console.log(
|
|
522
|
+
console.log(chalk8.gray('\nRun "inkeep chat" without arguments for interactive selection'));
|
|
523
523
|
} else {
|
|
524
|
-
console.log(
|
|
524
|
+
console.log(chalk8.yellow("\nNo graphs found. Please define graphs and push your project."));
|
|
525
525
|
}
|
|
526
526
|
process.exit(1);
|
|
527
527
|
}
|
|
528
|
-
spinner.succeed(`Connected to graph: ${
|
|
528
|
+
spinner.succeed(`Connected to graph: ${chalk8.green(graph.name || graphId)}`);
|
|
529
529
|
if (graph.description) {
|
|
530
|
-
console.log(
|
|
530
|
+
console.log(chalk8.gray(`Description: ${graph.description}`));
|
|
531
531
|
}
|
|
532
532
|
if (graph.defaultAgentId || graph.default_agent_id) {
|
|
533
|
-
console.log(
|
|
533
|
+
console.log(chalk8.gray(`Default Agent: ${graph.defaultAgentId || graph.default_agent_id}`));
|
|
534
534
|
}
|
|
535
535
|
} catch (error) {
|
|
536
536
|
spinner.fail("Failed to connect to graph");
|
|
537
|
-
console.error(
|
|
537
|
+
console.error(chalk8.red("Error:"), error instanceof Error ? error.message : error);
|
|
538
538
|
process.exit(1);
|
|
539
539
|
}
|
|
540
540
|
const rl = readline.createInterface({
|
|
541
541
|
input: process.stdin,
|
|
542
542
|
output: process.stdout,
|
|
543
|
-
prompt:
|
|
543
|
+
prompt: chalk8.cyan("You> ")
|
|
544
544
|
});
|
|
545
545
|
const conversationId = `cli-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
546
546
|
const messages = [];
|
|
547
547
|
let debugMode = false;
|
|
548
|
-
console.log(
|
|
549
|
-
console.log(
|
|
548
|
+
console.log(chalk8.gray('\n\u{1F4AC} Chat session started. Type "exit" or press Ctrl+C to quit.'));
|
|
549
|
+
console.log(chalk8.gray("Commands: help, clear, history, reset, debug\n"));
|
|
550
550
|
async function handleStreamingResponse(stream, showDebug = false) {
|
|
551
551
|
const decoder = new TextDecoder();
|
|
552
552
|
const reader = stream.getReader();
|
|
@@ -602,12 +602,12 @@ async function chatCommandEnhanced(graphIdInput, options) {
|
|
|
602
602
|
if (opType === "completion" && hasStartedResponse) {
|
|
603
603
|
console.log("");
|
|
604
604
|
}
|
|
605
|
-
console.log(
|
|
605
|
+
console.log(chalk8.gray(` [${opType}] ${ctxDisplay}`));
|
|
606
606
|
}
|
|
607
607
|
currentPos = jsonEnd;
|
|
608
608
|
} catch {
|
|
609
609
|
if (!hasStartedResponse) {
|
|
610
|
-
process.stdout.write(
|
|
610
|
+
process.stdout.write(chalk8.green("Assistant> "));
|
|
611
611
|
hasStartedResponse = true;
|
|
612
612
|
}
|
|
613
613
|
process.stdout.write(content[currentPos]);
|
|
@@ -616,7 +616,7 @@ async function chatCommandEnhanced(graphIdInput, options) {
|
|
|
616
616
|
}
|
|
617
617
|
} else {
|
|
618
618
|
if (!hasStartedResponse) {
|
|
619
|
-
process.stdout.write(
|
|
619
|
+
process.stdout.write(chalk8.green("Assistant> "));
|
|
620
620
|
hasStartedResponse = true;
|
|
621
621
|
}
|
|
622
622
|
process.stdout.write(content[currentPos]);
|
|
@@ -636,7 +636,7 @@ async function chatCommandEnhanced(graphIdInput, options) {
|
|
|
636
636
|
if (hasStartedResponse) {
|
|
637
637
|
console.log("\n");
|
|
638
638
|
} else {
|
|
639
|
-
console.log(`${
|
|
639
|
+
console.log(`${chalk8.green("Assistant> ") + chalk8.gray("(no response)")}
|
|
640
640
|
`);
|
|
641
641
|
}
|
|
642
642
|
return responseContent;
|
|
@@ -645,47 +645,47 @@ async function chatCommandEnhanced(graphIdInput, options) {
|
|
|
645
645
|
const trimmedInput = input.trim();
|
|
646
646
|
const command = trimmedInput.toLowerCase().replace(/^\//, "");
|
|
647
647
|
if (command === "exit") {
|
|
648
|
-
console.log(
|
|
648
|
+
console.log(chalk8.gray("Goodbye! \u{1F44B}"));
|
|
649
649
|
rl.close();
|
|
650
650
|
process.exit(0);
|
|
651
651
|
}
|
|
652
652
|
if (command === "clear") {
|
|
653
653
|
console.clear();
|
|
654
|
-
console.log(
|
|
654
|
+
console.log(chalk8.gray("Screen cleared. Conversation context preserved.\n"));
|
|
655
655
|
rl.prompt();
|
|
656
656
|
return;
|
|
657
657
|
}
|
|
658
658
|
if (command === "help") {
|
|
659
|
-
console.log(
|
|
660
|
-
console.log(
|
|
661
|
-
console.log(
|
|
662
|
-
console.log(
|
|
663
|
-
console.log(
|
|
664
|
-
console.log(
|
|
665
|
-
console.log(
|
|
666
|
-
console.log(
|
|
659
|
+
console.log(chalk8.cyan("\n\u{1F4DA} Available commands:"));
|
|
660
|
+
console.log(chalk8.gray(" \u2022 exit - End the chat session"));
|
|
661
|
+
console.log(chalk8.gray(" \u2022 clear - Clear the screen (preserves context)"));
|
|
662
|
+
console.log(chalk8.gray(" \u2022 history - Show conversation history"));
|
|
663
|
+
console.log(chalk8.gray(" \u2022 reset - Reset conversation context"));
|
|
664
|
+
console.log(chalk8.gray(" \u2022 debug - Toggle debug mode (show/hide data operations)"));
|
|
665
|
+
console.log(chalk8.gray(" \u2022 help - Show this help message"));
|
|
666
|
+
console.log(chalk8.gray("\n Commands can be prefixed with / (e.g., /help)\n"));
|
|
667
667
|
rl.prompt();
|
|
668
668
|
return;
|
|
669
669
|
}
|
|
670
670
|
if (command === "debug") {
|
|
671
671
|
debugMode = !debugMode;
|
|
672
|
-
console.log(
|
|
672
|
+
console.log(chalk8.yellow(`
|
|
673
673
|
\u{1F527} Debug mode: ${debugMode ? "ON" : "OFF"}`));
|
|
674
674
|
if (debugMode) {
|
|
675
|
-
console.log(
|
|
675
|
+
console.log(chalk8.gray("Data operations will be shown during responses.\n"));
|
|
676
676
|
} else {
|
|
677
|
-
console.log(
|
|
677
|
+
console.log(chalk8.gray("Data operations are hidden.\n"));
|
|
678
678
|
}
|
|
679
679
|
rl.prompt();
|
|
680
680
|
return;
|
|
681
681
|
}
|
|
682
682
|
if (command === "history") {
|
|
683
|
-
console.log(
|
|
683
|
+
console.log(chalk8.cyan("\n\u{1F4DC} Conversation History:"));
|
|
684
684
|
if (messages.length === 0) {
|
|
685
|
-
console.log(
|
|
685
|
+
console.log(chalk8.gray(" (No messages yet)\n"));
|
|
686
686
|
} else {
|
|
687
687
|
messages.forEach((msg, idx) => {
|
|
688
|
-
const role = msg.role === "user" ?
|
|
688
|
+
const role = msg.role === "user" ? chalk8.blue("You") : chalk8.green("Assistant");
|
|
689
689
|
const preview = msg.content.substring(0, 100);
|
|
690
690
|
const suffix = msg.content.length > 100 ? "..." : "";
|
|
691
691
|
console.log(` ${idx + 1}. ${role}: ${preview}${suffix}`);
|
|
@@ -697,7 +697,7 @@ async function chatCommandEnhanced(graphIdInput, options) {
|
|
|
697
697
|
}
|
|
698
698
|
if (command === "reset") {
|
|
699
699
|
messages.length = 0;
|
|
700
|
-
console.log(
|
|
700
|
+
console.log(chalk8.yellow("\u26A0\uFE0F Conversation context has been reset.\n"));
|
|
701
701
|
rl.prompt();
|
|
702
702
|
return;
|
|
703
703
|
}
|
|
@@ -711,23 +711,23 @@ async function chatCommandEnhanced(graphIdInput, options) {
|
|
|
711
711
|
const response = await executionApi.chatCompletion(graphId, messages, conversationId);
|
|
712
712
|
let assistantResponse;
|
|
713
713
|
if (typeof response === "string") {
|
|
714
|
-
console.log(
|
|
714
|
+
console.log(chalk8.green("Assistant>"), response);
|
|
715
715
|
assistantResponse = response;
|
|
716
716
|
} else {
|
|
717
717
|
assistantResponse = await handleStreamingResponse(response, debugMode);
|
|
718
718
|
}
|
|
719
719
|
messages.push({ role: "assistant", content: assistantResponse });
|
|
720
720
|
} catch (error) {
|
|
721
|
-
console.error(
|
|
721
|
+
console.error(chalk8.red("Error:"), error instanceof Error ? error.message : error);
|
|
722
722
|
}
|
|
723
723
|
rl.prompt();
|
|
724
724
|
});
|
|
725
725
|
rl.on("close", () => {
|
|
726
|
-
console.log(
|
|
727
|
-
console.log(
|
|
728
|
-
console.log(
|
|
729
|
-
console.log(
|
|
730
|
-
console.log(
|
|
726
|
+
console.log(chalk8.gray("\n\u{1F4CA} Session Summary:"));
|
|
727
|
+
console.log(chalk8.gray(` \u2022 Graph: ${graphId}`));
|
|
728
|
+
console.log(chalk8.gray(` \u2022 Messages: ${messages.length}`));
|
|
729
|
+
console.log(chalk8.gray(` \u2022 Duration: ${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`));
|
|
730
|
+
console.log(chalk8.gray("\nChat session ended."));
|
|
731
731
|
process.exit(0);
|
|
732
732
|
});
|
|
733
733
|
rl.prompt();
|
|
@@ -958,7 +958,8 @@ async function promptForModelConfiguration() {
|
|
|
958
958
|
message: "Which AI providers would you like to configure?",
|
|
959
959
|
choices: [
|
|
960
960
|
{ name: "Anthropic (Claude)", value: "anthropic" },
|
|
961
|
-
{ name: "OpenAI (GPT)", value: "openai" }
|
|
961
|
+
{ name: "OpenAI (GPT)", value: "openai" },
|
|
962
|
+
{ name: "Google (Gemini)", value: "google" }
|
|
962
963
|
],
|
|
963
964
|
validate: (input) => {
|
|
964
965
|
if (input.length === 0) {
|
|
@@ -970,7 +971,8 @@ async function promptForModelConfiguration() {
|
|
|
970
971
|
]);
|
|
971
972
|
const anthropicModels = [
|
|
972
973
|
{ name: "Claude Opus 4.1", value: "anthropic/claude-opus-4-1-20250805" },
|
|
973
|
-
{ name: "Claude Sonnet 4", value: "anthropic/claude-sonnet-4-20250514" }
|
|
974
|
+
{ name: "Claude Sonnet 4", value: "anthropic/claude-sonnet-4-20250514" },
|
|
975
|
+
{ name: "Claude Haiku 3.5", value: "anthropic/claude-3-5-haiku-20241022" }
|
|
974
976
|
];
|
|
975
977
|
const openaiModels = [
|
|
976
978
|
{ name: "GPT-5", value: "openai/gpt-5-2025-08-07" },
|
|
@@ -980,6 +982,11 @@ async function promptForModelConfiguration() {
|
|
|
980
982
|
{ name: "GPT-4.1 Mini", value: "openai/gpt-4.1-mini-2025-04-14" },
|
|
981
983
|
{ name: "GPT-4.1 Nano", value: "openai/gpt-4.1-nano-2025-04-14" }
|
|
982
984
|
];
|
|
985
|
+
const googleModels = [
|
|
986
|
+
{ name: "Gemini 2.5 Pro", value: "google/gemini-2.5-pro" },
|
|
987
|
+
{ name: "Gemini 2.5 Flash", value: "google/gemini-2.5-flash" },
|
|
988
|
+
{ name: "Gemini 2.5 Flash Lite", value: "google/gemini-2.5-flash-lite" }
|
|
989
|
+
];
|
|
983
990
|
const availableModels = [];
|
|
984
991
|
if (providers.includes("anthropic")) {
|
|
985
992
|
availableModels.push(...anthropicModels);
|
|
@@ -987,6 +994,9 @@ async function promptForModelConfiguration() {
|
|
|
987
994
|
if (providers.includes("openai")) {
|
|
988
995
|
availableModels.push(...openaiModels);
|
|
989
996
|
}
|
|
997
|
+
if (providers.includes("google")) {
|
|
998
|
+
availableModels.push(...googleModels);
|
|
999
|
+
}
|
|
990
1000
|
const modelAnswers = await inquirer.prompt([
|
|
991
1001
|
{
|
|
992
1002
|
type: "list",
|
|
@@ -1398,11 +1408,11 @@ function parseModelString(modelString) {
|
|
|
1398
1408
|
};
|
|
1399
1409
|
}
|
|
1400
1410
|
async function generateTypeScriptFileWithLLM(graphData, graphId, outputFilePath, modelSettings, retryContext) {
|
|
1401
|
-
const
|
|
1411
|
+
const fs3 = await import("fs");
|
|
1402
1412
|
let existingContent = "";
|
|
1403
1413
|
let fileExists = false;
|
|
1404
1414
|
try {
|
|
1405
|
-
existingContent =
|
|
1415
|
+
existingContent = fs3.readFileSync(outputFilePath, "utf-8");
|
|
1406
1416
|
fileExists = true;
|
|
1407
1417
|
} catch {
|
|
1408
1418
|
fileExists = false;
|
|
@@ -1418,7 +1428,7 @@ async function generateTypeScriptFileWithLLM(graphData, graphId, outputFilePath,
|
|
|
1418
1428
|
maxOutputTokens: 16e3
|
|
1419
1429
|
// Increased to handle large TypeScript files
|
|
1420
1430
|
});
|
|
1421
|
-
|
|
1431
|
+
fs3.writeFileSync(outputFilePath, text, "utf-8");
|
|
1422
1432
|
console.log(`\u2705 Successfully generated TypeScript file: ${outputFilePath}`);
|
|
1423
1433
|
} catch (error) {
|
|
1424
1434
|
console.error("\u274C Error generating TypeScript file with LLM:", error);
|
|
@@ -1689,7 +1699,6 @@ async function pullProjectCommand(options) {
|
|
|
1689
1699
|
|
|
1690
1700
|
// src/commands/push.ts
|
|
1691
1701
|
init_esm_shims();
|
|
1692
|
-
init_tsx_loader();
|
|
1693
1702
|
import { existsSync as existsSync9 } from "fs";
|
|
1694
1703
|
import { join as join9 } from "path";
|
|
1695
1704
|
import chalk6 from "chalk";
|
|
@@ -1729,6 +1738,7 @@ Make sure you have a ${env}.env.ts file in the environments directory.`
|
|
|
1729
1738
|
}
|
|
1730
1739
|
|
|
1731
1740
|
// src/commands/push.ts
|
|
1741
|
+
init_tsx_loader();
|
|
1732
1742
|
async function loadProject(projectDir) {
|
|
1733
1743
|
const indexPath = join9(projectDir, "index.ts");
|
|
1734
1744
|
if (!existsSync9(indexPath)) {
|
|
@@ -1795,7 +1805,11 @@ async function pushCommand(options) {
|
|
|
1795
1805
|
console.log(chalk6.gray(` \u2022 Project ID: ${finalConfig.projectId}`));
|
|
1796
1806
|
console.log(chalk6.gray(` \u2022 API URL: ${finalConfig.agentsManageApiUrl}`));
|
|
1797
1807
|
if (typeof project.setConfig === "function") {
|
|
1798
|
-
project.setConfig(
|
|
1808
|
+
project.setConfig(
|
|
1809
|
+
finalConfig.tenantId,
|
|
1810
|
+
finalConfig.agentsManageApiUrl,
|
|
1811
|
+
finalConfig.modelSettings
|
|
1812
|
+
);
|
|
1799
1813
|
}
|
|
1800
1814
|
if (options.env && typeof project.setCredentials === "function") {
|
|
1801
1815
|
spinner.text = `Loading credentials for environment '${options.env}'...`;
|
|
@@ -1816,8 +1830,8 @@ async function pushCommand(options) {
|
|
|
1816
1830
|
try {
|
|
1817
1831
|
const projectDefinition = await project.toFullProjectDefinition();
|
|
1818
1832
|
const jsonFilePath = join9(projectDir, `${finalConfig.projectId}.json`);
|
|
1819
|
-
const
|
|
1820
|
-
await
|
|
1833
|
+
const fs3 = await import("fs/promises");
|
|
1834
|
+
await fs3.writeFile(jsonFilePath, JSON.stringify(projectDefinition, null, 2));
|
|
1821
1835
|
spinner.succeed(`Project data saved to ${jsonFilePath}`);
|
|
1822
1836
|
console.log(chalk6.gray(` \u2022 File: ${jsonFilePath}`));
|
|
1823
1837
|
console.log(chalk6.gray(` \u2022 Size: ${JSON.stringify(projectDefinition).length} bytes`));
|
|
@@ -1878,6 +1892,70 @@ async function pushCommand(options) {
|
|
|
1878
1892
|
}
|
|
1879
1893
|
}
|
|
1880
1894
|
|
|
1895
|
+
// src/commands/add.ts
|
|
1896
|
+
init_esm_shims();
|
|
1897
|
+
import chalk7 from "chalk";
|
|
1898
|
+
import ora5 from "ora";
|
|
1899
|
+
|
|
1900
|
+
// src/utils/templates.ts
|
|
1901
|
+
init_esm_shims();
|
|
1902
|
+
import fs from "fs-extra";
|
|
1903
|
+
import degit from "degit";
|
|
1904
|
+
async function cloneTemplate(templatePath, targetPath) {
|
|
1905
|
+
await fs.mkdir(targetPath, { recursive: true });
|
|
1906
|
+
const templatePathSuffix = templatePath.replace("https://github.com/", "");
|
|
1907
|
+
const emitter = degit(templatePathSuffix);
|
|
1908
|
+
try {
|
|
1909
|
+
await emitter.clone(targetPath);
|
|
1910
|
+
} catch (error) {
|
|
1911
|
+
process.exit(1);
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
async function getAvailableTemplates() {
|
|
1915
|
+
const response = await fetch(
|
|
1916
|
+
"https://api.github.com/repos/inkeep/agents-cookbook/contents/templates"
|
|
1917
|
+
);
|
|
1918
|
+
const contents = await response.json();
|
|
1919
|
+
return contents.filter((item) => item.type === "dir").map((item) => item.name);
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
// src/commands/add.ts
|
|
1923
|
+
import fs2 from "fs-extra";
|
|
1924
|
+
async function addCommand(options) {
|
|
1925
|
+
const templates = await getAvailableTemplates();
|
|
1926
|
+
if (!options.template) {
|
|
1927
|
+
console.log(chalk7.yellow("Available templates:"));
|
|
1928
|
+
for (const template of templates) {
|
|
1929
|
+
console.log(chalk7.gray(` \u2022 ${template}`));
|
|
1930
|
+
}
|
|
1931
|
+
process.exit(0);
|
|
1932
|
+
} else {
|
|
1933
|
+
if (!templates.includes(options.template)) {
|
|
1934
|
+
console.error(`\u274C Template "${options.template}" not found`);
|
|
1935
|
+
process.exit(1);
|
|
1936
|
+
}
|
|
1937
|
+
const baseDir = options.targetPath || process.cwd();
|
|
1938
|
+
const templateDir = `${baseDir}/${options.template}`;
|
|
1939
|
+
if (await fs2.pathExists(templateDir)) {
|
|
1940
|
+
console.error(`\u274C Directory "${templateDir}" already exists`);
|
|
1941
|
+
process.exit(1);
|
|
1942
|
+
}
|
|
1943
|
+
if (options.targetPath && !await fs2.pathExists(baseDir)) {
|
|
1944
|
+
try {
|
|
1945
|
+
await fs2.mkdir(baseDir, { recursive: true });
|
|
1946
|
+
} catch (error) {
|
|
1947
|
+
console.error(`\u274C Failed to create target directory "${baseDir}": ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1948
|
+
process.exit(1);
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
const spinner = ora5("Adding template...").start();
|
|
1952
|
+
const fullTemplatePath = `https://github.com/inkeep/agents-cookbook/templates/${options.template}`;
|
|
1953
|
+
await cloneTemplate(fullTemplatePath, templateDir);
|
|
1954
|
+
spinner.succeed(`Template "${options.template}" added to ${templateDir}`);
|
|
1955
|
+
return;
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1881
1959
|
// src/index.ts
|
|
1882
1960
|
var __filename2 = fileURLToPath2(import.meta.url);
|
|
1883
1961
|
var __dirname2 = dirname4(__filename2);
|
|
@@ -1885,6 +1963,9 @@ var packageJsonPath = join10(__dirname2, "..", "package.json");
|
|
|
1885
1963
|
var packageJson = JSON.parse(readFileSync3(packageJsonPath, "utf-8"));
|
|
1886
1964
|
var program = new Command();
|
|
1887
1965
|
program.name("inkeep").description("CLI tool for Inkeep Agent Framework").version(packageJson.version);
|
|
1966
|
+
program.command("add [template]").description("Add a new template to the project").option("--target-path <path>", "Target path to add the template to").action(async (template, options) => {
|
|
1967
|
+
await addCommand({ template, ...options });
|
|
1968
|
+
});
|
|
1888
1969
|
program.command("init [path]").description("Initialize a new Inkeep configuration file").option("--no-interactive", "Skip interactive path selection").action(async (path2, options) => {
|
|
1889
1970
|
await initCommand({ path: path2, ...options });
|
|
1890
1971
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Inkeep CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"chalk": "^5.3.0",
|
|
32
32
|
"cli-table3": "^0.6.3",
|
|
33
33
|
"commander": "^14.0.0",
|
|
34
|
+
"degit": "^2.8.4",
|
|
34
35
|
"dotenv": "^17.2.1",
|
|
35
36
|
"drizzle-orm": "^0.44.5",
|
|
36
37
|
"find-up": "^7.0.0",
|
|
@@ -42,10 +43,11 @@
|
|
|
42
43
|
"recast": "^0.23.0",
|
|
43
44
|
"ts-morph": "^26.0.0",
|
|
44
45
|
"tsx": "^4.20.5",
|
|
45
|
-
"@inkeep/agents-core": "^0.2.
|
|
46
|
-
"@inkeep/agents-manage-ui": "^0.2.
|
|
46
|
+
"@inkeep/agents-core": "^0.2.2",
|
|
47
|
+
"@inkeep/agents-manage-ui": "^0.2.2"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
50
|
+
"@types/degit": "^2.8.6",
|
|
49
51
|
"@types/fs-extra": "^11.0.4",
|
|
50
52
|
"@types/inquirer": "^9.0.7",
|
|
51
53
|
"@types/node": "^20.10.0",
|