@inkeep/agents-cli 0.26.0 → 0.26.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 +465 -124
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -5122,7 +5122,7 @@ var require_util = __commonJS({
|
|
|
5122
5122
|
return path4;
|
|
5123
5123
|
}
|
|
5124
5124
|
exports.normalize = normalize;
|
|
5125
|
-
function
|
|
5125
|
+
function join15(aRoot, aPath) {
|
|
5126
5126
|
if (aRoot === "") {
|
|
5127
5127
|
aRoot = ".";
|
|
5128
5128
|
}
|
|
@@ -5154,7 +5154,7 @@ var require_util = __commonJS({
|
|
|
5154
5154
|
}
|
|
5155
5155
|
return joined;
|
|
5156
5156
|
}
|
|
5157
|
-
exports.join =
|
|
5157
|
+
exports.join = join15;
|
|
5158
5158
|
exports.isAbsolute = function(aPath) {
|
|
5159
5159
|
return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
|
|
5160
5160
|
};
|
|
@@ -5327,7 +5327,7 @@ var require_util = __commonJS({
|
|
|
5327
5327
|
parsed.path = parsed.path.substring(0, index2 + 1);
|
|
5328
5328
|
}
|
|
5329
5329
|
}
|
|
5330
|
-
sourceURL =
|
|
5330
|
+
sourceURL = join15(urlGenerate(parsed), sourceURL);
|
|
5331
5331
|
}
|
|
5332
5332
|
return normalize(sourceURL);
|
|
5333
5333
|
}
|
|
@@ -226950,11 +226950,11 @@ var init_tools = __esm({
|
|
|
226950
226950
|
"use strict";
|
|
226951
226951
|
init_esm_shims();
|
|
226952
226952
|
init_context5();
|
|
226953
|
-
init_conversations();
|
|
226954
226953
|
init_credential_stuffer();
|
|
226955
226954
|
init_schema();
|
|
226956
226955
|
init_types();
|
|
226957
226956
|
init_utils();
|
|
226957
|
+
init_conversations();
|
|
226958
226958
|
init_logger();
|
|
226959
226959
|
init_mcp_client();
|
|
226960
226960
|
init_credentialReferences();
|
|
@@ -234741,6 +234741,234 @@ var init_variable_name_registry = __esm({
|
|
|
234741
234741
|
}
|
|
234742
234742
|
});
|
|
234743
234743
|
|
|
234744
|
+
// src/utils/project-loader.ts
|
|
234745
|
+
var project_loader_exports = {};
|
|
234746
|
+
__export(project_loader_exports, {
|
|
234747
|
+
loadProject: () => loadProject
|
|
234748
|
+
});
|
|
234749
|
+
import { existsSync as existsSync7 } from "fs";
|
|
234750
|
+
import { join as join7 } from "path";
|
|
234751
|
+
async function loadProject(projectDir) {
|
|
234752
|
+
const indexPath = join7(projectDir, "index.ts");
|
|
234753
|
+
if (!existsSync7(indexPath)) {
|
|
234754
|
+
throw new Error(`index.ts not found in project directory: ${projectDir}`);
|
|
234755
|
+
}
|
|
234756
|
+
const module = await importWithTypeScriptSupport(indexPath);
|
|
234757
|
+
const exports = Object.keys(module);
|
|
234758
|
+
for (const exportKey of exports) {
|
|
234759
|
+
const value = module[exportKey];
|
|
234760
|
+
if (value && typeof value === "object" && value.__type === "project") {
|
|
234761
|
+
return value;
|
|
234762
|
+
}
|
|
234763
|
+
}
|
|
234764
|
+
throw new Error(
|
|
234765
|
+
'No project export found in index.ts. Expected an export with __type = "project"'
|
|
234766
|
+
);
|
|
234767
|
+
}
|
|
234768
|
+
var init_project_loader = __esm({
|
|
234769
|
+
"src/utils/project-loader.ts"() {
|
|
234770
|
+
"use strict";
|
|
234771
|
+
init_esm_shims();
|
|
234772
|
+
init_tsx_loader();
|
|
234773
|
+
}
|
|
234774
|
+
});
|
|
234775
|
+
|
|
234776
|
+
// src/utils/json-comparison.ts
|
|
234777
|
+
var json_comparison_exports = {};
|
|
234778
|
+
__export(json_comparison_exports, {
|
|
234779
|
+
compareProjectDefinitions: () => compareProjectDefinitions
|
|
234780
|
+
});
|
|
234781
|
+
function compareProjectDefinitions(original, generated) {
|
|
234782
|
+
const differences = [];
|
|
234783
|
+
const warnings = [];
|
|
234784
|
+
const comparePrimitive = (path4, a, b2) => {
|
|
234785
|
+
if (a === b2) return true;
|
|
234786
|
+
if (typeof a !== typeof b2) {
|
|
234787
|
+
differences.push(`Type mismatch at ${path4}: ${typeof a} vs ${typeof b2}`);
|
|
234788
|
+
return false;
|
|
234789
|
+
}
|
|
234790
|
+
if (a !== b2) {
|
|
234791
|
+
differences.push(`Value mismatch at ${path4}: "${a}" vs "${b2}"`);
|
|
234792
|
+
return false;
|
|
234793
|
+
}
|
|
234794
|
+
return true;
|
|
234795
|
+
};
|
|
234796
|
+
const compareArrays = (path4, a, b2) => {
|
|
234797
|
+
if (a.length !== b2.length) {
|
|
234798
|
+
differences.push(`Array length mismatch at ${path4}: ${a.length} vs ${b2.length}`);
|
|
234799
|
+
return false;
|
|
234800
|
+
}
|
|
234801
|
+
let allMatch = true;
|
|
234802
|
+
for (let i2 = 0; i2 < a.length; i2++) {
|
|
234803
|
+
if (!compareValues(`${path4}[${i2}]`, a[i2], b2[i2])) {
|
|
234804
|
+
allMatch = false;
|
|
234805
|
+
}
|
|
234806
|
+
}
|
|
234807
|
+
return allMatch;
|
|
234808
|
+
};
|
|
234809
|
+
const compareObjects = (path4, a, b2) => {
|
|
234810
|
+
const aKeys = Object.keys(a || {}).filter((k2) => !["createdAt", "updatedAt"].includes(k2));
|
|
234811
|
+
const bKeys = Object.keys(b2 || {}).filter((k2) => !["createdAt", "updatedAt"].includes(k2));
|
|
234812
|
+
const missingInB = aKeys.filter((k2) => !bKeys.includes(k2));
|
|
234813
|
+
const extraInB = bKeys.filter((k2) => !aKeys.includes(k2));
|
|
234814
|
+
if (missingInB.length > 0) {
|
|
234815
|
+
differences.push(`Missing keys in generated at ${path4}: ${missingInB.join(", ")}`);
|
|
234816
|
+
}
|
|
234817
|
+
if (extraInB.length > 0) {
|
|
234818
|
+
warnings.push(`Extra keys in generated at ${path4}: ${extraInB.join(", ")}`);
|
|
234819
|
+
}
|
|
234820
|
+
let allMatch = true;
|
|
234821
|
+
for (const key of aKeys) {
|
|
234822
|
+
if (bKeys.includes(key)) {
|
|
234823
|
+
if (!compareValues(`${path4}.${key}`, a[key], b2[key])) {
|
|
234824
|
+
allMatch = false;
|
|
234825
|
+
}
|
|
234826
|
+
}
|
|
234827
|
+
}
|
|
234828
|
+
return allMatch && missingInB.length === 0;
|
|
234829
|
+
};
|
|
234830
|
+
const compareValues = (path4, a, b2) => {
|
|
234831
|
+
if (a === null && b2 === null) return true;
|
|
234832
|
+
if (a === void 0 && b2 === void 0) return true;
|
|
234833
|
+
if ((a === null || a === void 0) !== (b2 === null || b2 === void 0)) {
|
|
234834
|
+
differences.push(`Null/undefined mismatch at ${path4}`);
|
|
234835
|
+
return false;
|
|
234836
|
+
}
|
|
234837
|
+
if (Array.isArray(a) && Array.isArray(b2)) {
|
|
234838
|
+
return compareArrays(path4, a, b2);
|
|
234839
|
+
}
|
|
234840
|
+
if (Array.isArray(a) !== Array.isArray(b2)) {
|
|
234841
|
+
differences.push(`Array type mismatch at ${path4}`);
|
|
234842
|
+
return false;
|
|
234843
|
+
}
|
|
234844
|
+
if (typeof a === "object" && typeof b2 === "object") {
|
|
234845
|
+
return compareObjects(path4, a, b2);
|
|
234846
|
+
}
|
|
234847
|
+
return comparePrimitive(path4, a, b2);
|
|
234848
|
+
};
|
|
234849
|
+
comparePrimitive("id", original.id, generated.id);
|
|
234850
|
+
comparePrimitive("name", original.name, generated.name);
|
|
234851
|
+
if (original.description || generated.description) {
|
|
234852
|
+
const origDesc = original.description || "";
|
|
234853
|
+
const genDesc = generated.description || "";
|
|
234854
|
+
if (origDesc !== genDesc) {
|
|
234855
|
+
comparePrimitive("description", origDesc, genDesc);
|
|
234856
|
+
}
|
|
234857
|
+
}
|
|
234858
|
+
if (original.models || generated.models) {
|
|
234859
|
+
compareValues("models", original.models, generated.models);
|
|
234860
|
+
}
|
|
234861
|
+
if (original.stopWhen || generated.stopWhen) {
|
|
234862
|
+
compareValues("stopWhen", original.stopWhen, generated.stopWhen);
|
|
234863
|
+
}
|
|
234864
|
+
const originalAgentIds = Object.keys(original.agents || {});
|
|
234865
|
+
const generatedAgentIds = Object.keys(generated.agents || {});
|
|
234866
|
+
if (originalAgentIds.length !== generatedAgentIds.length) {
|
|
234867
|
+
differences.push(
|
|
234868
|
+
`Agent count mismatch: ${originalAgentIds.length} vs ${generatedAgentIds.length}`
|
|
234869
|
+
);
|
|
234870
|
+
}
|
|
234871
|
+
for (const agentId of originalAgentIds) {
|
|
234872
|
+
if (!generatedAgentIds.includes(agentId)) {
|
|
234873
|
+
differences.push(`Missing agent in generated: ${agentId}`);
|
|
234874
|
+
} else {
|
|
234875
|
+
compareValues(
|
|
234876
|
+
`agents.${agentId}`,
|
|
234877
|
+
original.agents?.[agentId],
|
|
234878
|
+
generated.agents?.[agentId]
|
|
234879
|
+
);
|
|
234880
|
+
}
|
|
234881
|
+
}
|
|
234882
|
+
for (const agentId of generatedAgentIds) {
|
|
234883
|
+
if (!originalAgentIds.includes(agentId)) {
|
|
234884
|
+
warnings.push(`Extra agent in generated: ${agentId}`);
|
|
234885
|
+
}
|
|
234886
|
+
}
|
|
234887
|
+
const originalToolIds = Object.keys(original.tools || {});
|
|
234888
|
+
const generatedToolIds = Object.keys(generated.tools || {});
|
|
234889
|
+
if (originalToolIds.length !== generatedToolIds.length) {
|
|
234890
|
+
differences.push(`Tool count mismatch: ${originalToolIds.length} vs ${generatedToolIds.length}`);
|
|
234891
|
+
}
|
|
234892
|
+
for (const toolId of originalToolIds) {
|
|
234893
|
+
if (!generatedToolIds.includes(toolId)) {
|
|
234894
|
+
differences.push(`Missing tool in generated: ${toolId}`);
|
|
234895
|
+
} else {
|
|
234896
|
+
compareValues(`tools.${toolId}`, original.tools?.[toolId], generated.tools?.[toolId]);
|
|
234897
|
+
}
|
|
234898
|
+
}
|
|
234899
|
+
if (original.functions || generated.functions) {
|
|
234900
|
+
const originalFunctionIds = Object.keys(original.functions || {});
|
|
234901
|
+
const generatedFunctionIds = Object.keys(generated.functions || {});
|
|
234902
|
+
for (const functionId of originalFunctionIds) {
|
|
234903
|
+
if (!generatedFunctionIds.includes(functionId)) {
|
|
234904
|
+
differences.push(`Missing function in generated: ${functionId}`);
|
|
234905
|
+
} else {
|
|
234906
|
+
compareValues(
|
|
234907
|
+
`functions.${functionId}`,
|
|
234908
|
+
original.functions?.[functionId],
|
|
234909
|
+
generated.functions?.[functionId]
|
|
234910
|
+
);
|
|
234911
|
+
}
|
|
234912
|
+
}
|
|
234913
|
+
}
|
|
234914
|
+
if (original.dataComponents || generated.dataComponents) {
|
|
234915
|
+
const originalComponentIds = Object.keys(original.dataComponents || {});
|
|
234916
|
+
const generatedComponentIds = Object.keys(generated.dataComponents || {});
|
|
234917
|
+
for (const componentId of originalComponentIds) {
|
|
234918
|
+
if (!generatedComponentIds.includes(componentId)) {
|
|
234919
|
+
differences.push(`Missing data component in generated: ${componentId}`);
|
|
234920
|
+
} else {
|
|
234921
|
+
compareValues(
|
|
234922
|
+
`dataComponents.${componentId}`,
|
|
234923
|
+
original.dataComponents?.[componentId],
|
|
234924
|
+
generated.dataComponents?.[componentId]
|
|
234925
|
+
);
|
|
234926
|
+
}
|
|
234927
|
+
}
|
|
234928
|
+
}
|
|
234929
|
+
if (original.artifactComponents || generated.artifactComponents) {
|
|
234930
|
+
const originalArtifactIds = Object.keys(original.artifactComponents || {});
|
|
234931
|
+
const generatedArtifactIds = Object.keys(generated.artifactComponents || {});
|
|
234932
|
+
for (const artifactId of originalArtifactIds) {
|
|
234933
|
+
if (!generatedArtifactIds.includes(artifactId)) {
|
|
234934
|
+
differences.push(`Missing artifact component in generated: ${artifactId}`);
|
|
234935
|
+
} else {
|
|
234936
|
+
compareValues(
|
|
234937
|
+
`artifactComponents.${artifactId}`,
|
|
234938
|
+
original.artifactComponents?.[artifactId],
|
|
234939
|
+
generated.artifactComponents?.[artifactId]
|
|
234940
|
+
);
|
|
234941
|
+
}
|
|
234942
|
+
}
|
|
234943
|
+
}
|
|
234944
|
+
if (original.credentialReferences || generated.credentialReferences) {
|
|
234945
|
+
const originalCredIds = Object.keys(original.credentialReferences || {});
|
|
234946
|
+
const generatedCredIds = Object.keys(generated.credentialReferences || {});
|
|
234947
|
+
for (const credId of originalCredIds) {
|
|
234948
|
+
if (!generatedCredIds.includes(credId)) {
|
|
234949
|
+
differences.push(`Missing credential reference in generated: ${credId}`);
|
|
234950
|
+
} else {
|
|
234951
|
+
const origCred = { ...original.credentialReferences?.[credId] || {} };
|
|
234952
|
+
const genCred = { ...generated.credentialReferences?.[credId] || {} };
|
|
234953
|
+
delete origCred.usedBy;
|
|
234954
|
+
delete genCred.usedBy;
|
|
234955
|
+
compareValues(`credentialReferences.${credId}`, origCred, genCred);
|
|
234956
|
+
}
|
|
234957
|
+
}
|
|
234958
|
+
}
|
|
234959
|
+
return {
|
|
234960
|
+
matches: differences.length === 0,
|
|
234961
|
+
differences,
|
|
234962
|
+
warnings
|
|
234963
|
+
};
|
|
234964
|
+
}
|
|
234965
|
+
var init_json_comparison = __esm({
|
|
234966
|
+
"src/utils/json-comparison.ts"() {
|
|
234967
|
+
"use strict";
|
|
234968
|
+
init_esm_shims();
|
|
234969
|
+
}
|
|
234970
|
+
});
|
|
234971
|
+
|
|
234744
234972
|
// src/commands/pull.placeholder-system.ts
|
|
234745
234973
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
234746
234974
|
import { jsonSchemaToZod } from "json-schema-to-zod";
|
|
@@ -234955,7 +235183,7 @@ __export(pull_llm_generate_exports, {
|
|
|
234955
235183
|
});
|
|
234956
235184
|
import { readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
234957
235185
|
import { createRequire as createRequire2 } from "module";
|
|
234958
|
-
import { join as
|
|
235186
|
+
import { join as join8 } from "path";
|
|
234959
235187
|
import { anthropic, createAnthropic } from "@ai-sdk/anthropic";
|
|
234960
235188
|
import { google } from "@ai-sdk/google";
|
|
234961
235189
|
import { createOpenAI, openai } from "@ai-sdk/openai";
|
|
@@ -234963,8 +235191,8 @@ import { generateText } from "ai";
|
|
|
234963
235191
|
function getTypeDefinitions() {
|
|
234964
235192
|
try {
|
|
234965
235193
|
const sdkPackagePath = require3.resolve("@inkeep/agents-sdk/package.json");
|
|
234966
|
-
const sdkPackageDir =
|
|
234967
|
-
const sdkDtsPath =
|
|
235194
|
+
const sdkPackageDir = join8(sdkPackagePath, "..");
|
|
235195
|
+
const sdkDtsPath = join8(sdkPackageDir, "dist/index.d.ts");
|
|
234968
235196
|
const dtsContent = readFileSync3(sdkDtsPath, "utf-8");
|
|
234969
235197
|
return `
|
|
234970
235198
|
TYPESCRIPT TYPE DEFINITIONS (from @inkeep/agents-sdk):
|
|
@@ -235834,7 +236062,7 @@ Generate ONLY the TypeScript code without any markdown or explanations.`;
|
|
|
235834
236062
|
}
|
|
235835
236063
|
function generateEnvironmentFileTemplate(environmentsDir, environment, credentials) {
|
|
235836
236064
|
const { writeFileSync: writeFileSync7 } = require3("node:fs");
|
|
235837
|
-
const { join:
|
|
236065
|
+
const { join: join15 } = require3("node:path");
|
|
235838
236066
|
let credentialsCode = "";
|
|
235839
236067
|
const hasCredentials = credentials && Object.keys(credentials).length > 0;
|
|
235840
236068
|
if (hasCredentials) {
|
|
@@ -235871,15 +236099,15 @@ export const ${environment} = registerEnvironmentSettings({
|
|
|
235871
236099
|
credentials: {${credentialsCode}}
|
|
235872
236100
|
});
|
|
235873
236101
|
`;
|
|
235874
|
-
writeFileSync7(
|
|
236102
|
+
writeFileSync7(join15(environmentsDir, `${environment}.env.ts`), envContent);
|
|
235875
236103
|
updateEnvironmentIndexTemplate(environmentsDir, environment);
|
|
235876
236104
|
}
|
|
235877
236105
|
function updateEnvironmentIndexTemplate(environmentsDir, newEnvironment) {
|
|
235878
|
-
const { writeFileSync: writeFileSync7, existsSync:
|
|
235879
|
-
const { join:
|
|
235880
|
-
const indexPath =
|
|
236106
|
+
const { writeFileSync: writeFileSync7, existsSync: existsSync13, readFileSync: readFileSync8 } = require3("node:fs");
|
|
236107
|
+
const { join: join15 } = require3("node:path");
|
|
236108
|
+
const indexPath = join15(environmentsDir, "index.ts");
|
|
235881
236109
|
const existingEnvironments = [];
|
|
235882
|
-
if (
|
|
236110
|
+
if (existsSync13(indexPath)) {
|
|
235883
236111
|
const existingContent = readFileSync8(indexPath, "utf-8");
|
|
235884
236112
|
const importRegex = /import\s+{\s*(\w+)\s*}\s+from\s+['"]\.\/([\w-]+)\.env['"];?/g;
|
|
235885
236113
|
let match2;
|
|
@@ -235943,15 +236171,15 @@ export const ${environment} = registerEnvironmentSettings({
|
|
|
235943
236171
|
credentials: {${credentialsCode}}
|
|
235944
236172
|
});
|
|
235945
236173
|
`;
|
|
235946
|
-
writeFileSync3(
|
|
236174
|
+
writeFileSync3(join8(environmentsDir, `${environment}.env.ts`), envContent);
|
|
235947
236175
|
await updateEnvironmentIndex(environmentsDir, environment);
|
|
235948
236176
|
}
|
|
235949
236177
|
async function updateEnvironmentIndex(environmentsDir, environment) {
|
|
235950
|
-
const indexPath =
|
|
235951
|
-
const { readFileSync: readFileSync8, existsSync:
|
|
236178
|
+
const indexPath = join8(environmentsDir, "index.ts");
|
|
236179
|
+
const { readFileSync: readFileSync8, existsSync: existsSync13 } = await import("fs");
|
|
235952
236180
|
const existingEnvironments = [];
|
|
235953
236181
|
let existingContent = "";
|
|
235954
|
-
if (
|
|
236182
|
+
if (existsSync13(indexPath)) {
|
|
235955
236183
|
existingContent = readFileSync8(indexPath, "utf-8");
|
|
235956
236184
|
const importRegex = /import\s+{\s*(\w+)\s*}\s+from\s+['"]\.\/([\w-]+)\.env['"];?/g;
|
|
235957
236185
|
let match2;
|
|
@@ -236596,11 +236824,11 @@ var pattern_analyzer_exports = {};
|
|
|
236596
236824
|
__export(pattern_analyzer_exports, {
|
|
236597
236825
|
analyzeExistingPatterns: () => analyzeExistingPatterns
|
|
236598
236826
|
});
|
|
236599
|
-
import { existsSync as
|
|
236600
|
-
import { join as
|
|
236827
|
+
import { existsSync as existsSync8, readdirSync as readdirSync2, readFileSync as readFileSync4, statSync } from "fs";
|
|
236828
|
+
import { join as join9 } from "path";
|
|
236601
236829
|
async function analyzeExistingPatterns(projectDir) {
|
|
236602
|
-
const indexPath =
|
|
236603
|
-
if (!
|
|
236830
|
+
const indexPath = join9(projectDir, "index.ts");
|
|
236831
|
+
if (!existsSync8(indexPath)) {
|
|
236604
236832
|
return null;
|
|
236605
236833
|
}
|
|
236606
236834
|
const fileStructure = analyzeFileStructure(projectDir);
|
|
@@ -236622,17 +236850,17 @@ async function analyzeExistingPatterns(projectDir) {
|
|
|
236622
236850
|
};
|
|
236623
236851
|
}
|
|
236624
236852
|
function analyzeFileStructure(projectDir) {
|
|
236625
|
-
const hasAgentsDirectory =
|
|
236626
|
-
const hasToolsDirectory =
|
|
236627
|
-
const hasDataComponentsDirectory =
|
|
236628
|
-
const hasArtifactComponentsDirectory =
|
|
236629
|
-
const hasEnvironmentsDirectory =
|
|
236630
|
-
const hasExternalAgentsDirectory =
|
|
236853
|
+
const hasAgentsDirectory = existsSync8(join9(projectDir, "agents"));
|
|
236854
|
+
const hasToolsDirectory = existsSync8(join9(projectDir, "tools"));
|
|
236855
|
+
const hasDataComponentsDirectory = existsSync8(join9(projectDir, "data-components"));
|
|
236856
|
+
const hasArtifactComponentsDirectory = existsSync8(join9(projectDir, "artifact-components"));
|
|
236857
|
+
const hasEnvironmentsDirectory = existsSync8(join9(projectDir, "environments"));
|
|
236858
|
+
const hasExternalAgentsDirectory = existsSync8(join9(projectDir, "external-agents"));
|
|
236631
236859
|
let toolsLocation = "unknown";
|
|
236632
236860
|
if (hasToolsDirectory) {
|
|
236633
236861
|
toolsLocation = "separate";
|
|
236634
236862
|
} else if (hasAgentsDirectory) {
|
|
236635
|
-
const agentFiles = getFilesInDirectory(
|
|
236863
|
+
const agentFiles = getFilesInDirectory(join9(projectDir, "agents"), ".ts");
|
|
236636
236864
|
const hasInlineTools = agentFiles.some((file) => {
|
|
236637
236865
|
const content = readFileSync4(file, "utf-8");
|
|
236638
236866
|
return content.includes("functionTool(");
|
|
@@ -236642,8 +236870,8 @@ function analyzeFileStructure(projectDir) {
|
|
|
236642
236870
|
const agentsLocation = hasAgentsDirectory ? "flat" : "unknown";
|
|
236643
236871
|
const allFiles = [
|
|
236644
236872
|
...getFilesInDirectory(projectDir, ".ts"),
|
|
236645
|
-
...hasAgentsDirectory ? getFilesInDirectory(
|
|
236646
|
-
...hasToolsDirectory ? getFilesInDirectory(
|
|
236873
|
+
...hasAgentsDirectory ? getFilesInDirectory(join9(projectDir, "agents"), ".ts") : [],
|
|
236874
|
+
...hasToolsDirectory ? getFilesInDirectory(join9(projectDir, "tools"), ".ts") : []
|
|
236647
236875
|
];
|
|
236648
236876
|
const preferredFileNaming = detectFileNamingConvention(allFiles);
|
|
236649
236877
|
return {
|
|
@@ -236689,7 +236917,7 @@ function collectCodeExamples(projectDir, fileStructure) {
|
|
|
236689
236917
|
mappings: []
|
|
236690
236918
|
};
|
|
236691
236919
|
if (fileStructure.hasAgentsDirectory) {
|
|
236692
|
-
const agentDir =
|
|
236920
|
+
const agentDir = join9(projectDir, "agents");
|
|
236693
236921
|
const agentFiles = getFilesInDirectory(agentDir, ".ts");
|
|
236694
236922
|
for (const file of agentFiles.slice(0, 3)) {
|
|
236695
236923
|
const content = readFileSync4(file, "utf-8");
|
|
@@ -236701,7 +236929,7 @@ function collectCodeExamples(projectDir, fileStructure) {
|
|
|
236701
236929
|
}
|
|
236702
236930
|
}
|
|
236703
236931
|
if (fileStructure.hasToolsDirectory) {
|
|
236704
|
-
const toolsDir =
|
|
236932
|
+
const toolsDir = join9(projectDir, "tools");
|
|
236705
236933
|
const toolFiles = getFilesInDirectory(toolsDir, ".ts");
|
|
236706
236934
|
for (const file of toolFiles.slice(0, 3)) {
|
|
236707
236935
|
const content = readFileSync4(file, "utf-8");
|
|
@@ -236710,8 +236938,8 @@ function collectCodeExamples(projectDir, fileStructure) {
|
|
|
236710
236938
|
examples.mappings.push(...mappings);
|
|
236711
236939
|
}
|
|
236712
236940
|
}
|
|
236713
|
-
const indexPath =
|
|
236714
|
-
if (
|
|
236941
|
+
const indexPath = join9(projectDir, "index.ts");
|
|
236942
|
+
if (existsSync8(indexPath)) {
|
|
236715
236943
|
const content = readFileSync4(indexPath, "utf-8");
|
|
236716
236944
|
const imports = extractImports(content);
|
|
236717
236945
|
examples.imports.push(...imports);
|
|
@@ -236842,13 +237070,13 @@ function mostCommon(arr) {
|
|
|
236842
237070
|
return mostCommonItem;
|
|
236843
237071
|
}
|
|
236844
237072
|
function getFilesInDirectory(dir, extension) {
|
|
236845
|
-
if (!
|
|
237073
|
+
if (!existsSync8(dir)) {
|
|
236846
237074
|
return [];
|
|
236847
237075
|
}
|
|
236848
237076
|
const files = [];
|
|
236849
237077
|
const entries = readdirSync2(dir);
|
|
236850
237078
|
for (const entry of entries) {
|
|
236851
|
-
const fullPath =
|
|
237079
|
+
const fullPath = join9(dir, entry);
|
|
236852
237080
|
const stat = statSync(fullPath);
|
|
236853
237081
|
if (stat.isDirectory()) {
|
|
236854
237082
|
files.push(...getFilesInDirectory(fullPath, extension));
|
|
@@ -237898,11 +238126,11 @@ __export(plan_storage_exports, {
|
|
|
237898
238126
|
planExists: () => planExists,
|
|
237899
238127
|
savePlan: () => savePlan
|
|
237900
238128
|
});
|
|
237901
|
-
import { existsSync as
|
|
237902
|
-
import { join as
|
|
238129
|
+
import { existsSync as existsSync9, mkdirSync, readFileSync as readFileSync5, writeFileSync as writeFileSync5 } from "fs";
|
|
238130
|
+
import { join as join10 } from "path";
|
|
237903
238131
|
function savePlan(projectRoot, plan) {
|
|
237904
|
-
const inkeepDir =
|
|
237905
|
-
if (!
|
|
238132
|
+
const inkeepDir = join10(projectRoot, ".inkeep");
|
|
238133
|
+
if (!existsSync9(inkeepDir)) {
|
|
237906
238134
|
mkdirSync(inkeepDir, { recursive: true });
|
|
237907
238135
|
}
|
|
237908
238136
|
const gitCommit = getGitCommit(projectRoot);
|
|
@@ -237915,15 +238143,15 @@ function savePlan(projectRoot, plan) {
|
|
|
237915
238143
|
},
|
|
237916
238144
|
plan
|
|
237917
238145
|
};
|
|
237918
|
-
const planPath =
|
|
238146
|
+
const planPath = join10(inkeepDir, "generation-plan.json");
|
|
237919
238147
|
writeFileSync5(planPath, JSON.stringify(storedPlan, null, 2));
|
|
237920
|
-
const backupPath =
|
|
238148
|
+
const backupPath = join10(inkeepDir, `generation-plan-${Date.now()}.json`);
|
|
237921
238149
|
writeFileSync5(backupPath, JSON.stringify(storedPlan, null, 2));
|
|
237922
238150
|
cleanupOldBackups(inkeepDir);
|
|
237923
238151
|
}
|
|
237924
238152
|
function loadPlan(projectRoot) {
|
|
237925
|
-
const planPath =
|
|
237926
|
-
if (!
|
|
238153
|
+
const planPath = join10(projectRoot, ".inkeep", "generation-plan.json");
|
|
238154
|
+
if (!existsSync9(planPath)) {
|
|
237927
238155
|
return null;
|
|
237928
238156
|
}
|
|
237929
238157
|
try {
|
|
@@ -237935,8 +238163,8 @@ function loadPlan(projectRoot) {
|
|
|
237935
238163
|
}
|
|
237936
238164
|
}
|
|
237937
238165
|
function planExists(projectRoot) {
|
|
237938
|
-
const planPath =
|
|
237939
|
-
return
|
|
238166
|
+
const planPath = join10(projectRoot, ".inkeep", "generation-plan.json");
|
|
238167
|
+
return existsSync9(planPath);
|
|
237940
238168
|
}
|
|
237941
238169
|
function getGitCommit(projectRoot) {
|
|
237942
238170
|
try {
|
|
@@ -237955,8 +238183,8 @@ function cleanupOldBackups(inkeepDir) {
|
|
|
237955
238183
|
const { readdirSync: readdirSync3, unlinkSync, statSync: statSync2 } = __require("fs");
|
|
237956
238184
|
const files = readdirSync3(inkeepDir).filter((f) => f.startsWith("generation-plan-") && f.endsWith(".json")).map((f) => ({
|
|
237957
238185
|
name: f,
|
|
237958
|
-
path:
|
|
237959
|
-
mtime: statSync2(
|
|
238186
|
+
path: join10(inkeepDir, f),
|
|
238187
|
+
mtime: statSync2(join10(inkeepDir, f)).mtime.getTime()
|
|
237960
238188
|
})).sort((a, b2) => b2.mtime - a.mtime);
|
|
237961
238189
|
for (let i2 = 5; i2 < files.length; i2++) {
|
|
237962
238190
|
unlinkSync(files[i2].path);
|
|
@@ -238065,9 +238293,9 @@ function displayPlanDiff(diff) {
|
|
|
238065
238293
|
}
|
|
238066
238294
|
}
|
|
238067
238295
|
function ensureGitignore(projectRoot) {
|
|
238068
|
-
const gitignorePath =
|
|
238296
|
+
const gitignorePath = join10(projectRoot, ".gitignore");
|
|
238069
238297
|
let content = "";
|
|
238070
|
-
if (
|
|
238298
|
+
if (existsSync9(gitignorePath)) {
|
|
238071
238299
|
content = readFileSync5(gitignorePath, "utf-8");
|
|
238072
238300
|
}
|
|
238073
238301
|
if (content.includes(".inkeep")) {
|
|
@@ -238088,7 +238316,7 @@ init_esm_shims();
|
|
|
238088
238316
|
init_env2();
|
|
238089
238317
|
init_instrumentation();
|
|
238090
238318
|
import { readFileSync as readFileSync7 } from "fs";
|
|
238091
|
-
import { dirname as dirname6, join as
|
|
238319
|
+
import { dirname as dirname6, join as join14 } from "path";
|
|
238092
238320
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
238093
238321
|
import { Command } from "commander";
|
|
238094
238322
|
|
|
@@ -239202,8 +239430,8 @@ ${table.toString()}`);
|
|
|
239202
239430
|
|
|
239203
239431
|
// src/commands/pull.ts
|
|
239204
239432
|
init_esm_shims();
|
|
239205
|
-
import { existsSync as
|
|
239206
|
-
import { dirname as dirname5, join as
|
|
239433
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync2, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "fs";
|
|
239434
|
+
import { dirname as dirname5, join as join11, resolve as resolve4 } from "path";
|
|
239207
239435
|
import * as p7 from "@clack/prompts";
|
|
239208
239436
|
import chalk9 from "chalk";
|
|
239209
239437
|
init_variable_name_registry();
|
|
@@ -239333,14 +239561,14 @@ async function findProjectDirectory(projectId, configPath) {
|
|
|
239333
239561
|
// src/commands/pull.ts
|
|
239334
239562
|
init_tsx_loader();
|
|
239335
239563
|
async function detectCurrentProject(debug = false) {
|
|
239336
|
-
const indexPath =
|
|
239564
|
+
const indexPath = join11(process.cwd(), "index.ts");
|
|
239337
239565
|
if (debug) {
|
|
239338
239566
|
console.log(chalk9.gray(`
|
|
239339
239567
|
[DEBUG] Detecting project in current directory...`));
|
|
239340
239568
|
console.log(chalk9.gray(` \u2022 Current directory: ${process.cwd()}`));
|
|
239341
239569
|
console.log(chalk9.gray(` \u2022 Looking for: ${indexPath}`));
|
|
239342
239570
|
}
|
|
239343
|
-
if (!
|
|
239571
|
+
if (!existsSync10(indexPath)) {
|
|
239344
239572
|
if (debug) {
|
|
239345
239573
|
console.log(chalk9.gray(` \u2022 index.ts not found`));
|
|
239346
239574
|
}
|
|
@@ -239405,8 +239633,8 @@ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = fal
|
|
|
239405
239633
|
const errors = [];
|
|
239406
239634
|
const warnings = [];
|
|
239407
239635
|
try {
|
|
239408
|
-
const indexPath =
|
|
239409
|
-
if (!
|
|
239636
|
+
const indexPath = join11(projectDir, "index.ts");
|
|
239637
|
+
if (!existsSync10(indexPath)) {
|
|
239410
239638
|
errors.push("Generated index.ts file not found");
|
|
239411
239639
|
return { success: false, errors, warnings };
|
|
239412
239640
|
}
|
|
@@ -239429,35 +239657,35 @@ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = fal
|
|
|
239429
239657
|
} else {
|
|
239430
239658
|
warnings.push("Could not extract project ID from index.ts");
|
|
239431
239659
|
}
|
|
239432
|
-
const agentsDir =
|
|
239660
|
+
const agentsDir = join11(projectDir, "agents");
|
|
239433
239661
|
const expectedAgents = Object.keys(originalProjectData.agents || {});
|
|
239434
239662
|
for (const agentId of expectedAgents) {
|
|
239435
239663
|
const kebabCaseId = agentId.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
239436
|
-
const agentPath =
|
|
239437
|
-
if (!
|
|
239664
|
+
const agentPath = join11(agentsDir, `${kebabCaseId}.ts`);
|
|
239665
|
+
if (!existsSync10(agentPath)) {
|
|
239438
239666
|
errors.push(`Agent file not found: agents/${kebabCaseId}.ts`);
|
|
239439
239667
|
} else if (debug) {
|
|
239440
239668
|
console.log(chalk9.gray(` \u2713 Agent file exists: agents/${kebabCaseId}.ts`));
|
|
239441
239669
|
}
|
|
239442
239670
|
}
|
|
239443
|
-
const toolsDir =
|
|
239671
|
+
const toolsDir = join11(projectDir, "tools");
|
|
239444
239672
|
const expectedTools = Object.entries(originalProjectData.tools || {});
|
|
239445
239673
|
const filenameGenerator = new VariableNameGenerator(DEFAULT_NAMING_CONVENTIONS);
|
|
239446
239674
|
for (const [toolId, toolData] of expectedTools) {
|
|
239447
239675
|
const fileName = filenameGenerator.generateFileName(toolId, "tool", toolData);
|
|
239448
|
-
const toolPath =
|
|
239449
|
-
if (!
|
|
239676
|
+
const toolPath = join11(toolsDir, `${fileName}.ts`);
|
|
239677
|
+
if (!existsSync10(toolPath)) {
|
|
239450
239678
|
errors.push(`Tool file not found: tools/${fileName}.ts`);
|
|
239451
239679
|
} else if (debug) {
|
|
239452
239680
|
console.log(chalk9.gray(` \u2713 Tool file exists: tools/${fileName}.ts`));
|
|
239453
239681
|
}
|
|
239454
239682
|
}
|
|
239455
|
-
const dataComponentsDir =
|
|
239683
|
+
const dataComponentsDir = join11(projectDir, "data-components");
|
|
239456
239684
|
const expectedDataComponents = Object.keys(originalProjectData.dataComponents || {});
|
|
239457
239685
|
for (const componentId of expectedDataComponents) {
|
|
239458
239686
|
const kebabCaseId = componentId.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
239459
|
-
const componentPath =
|
|
239460
|
-
if (!
|
|
239687
|
+
const componentPath = join11(dataComponentsDir, `${kebabCaseId}.ts`);
|
|
239688
|
+
if (!existsSync10(componentPath)) {
|
|
239461
239689
|
errors.push(`Data component file not found: data-components/${kebabCaseId}.ts`);
|
|
239462
239690
|
} else if (debug) {
|
|
239463
239691
|
console.log(
|
|
@@ -239465,17 +239693,17 @@ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = fal
|
|
|
239465
239693
|
);
|
|
239466
239694
|
}
|
|
239467
239695
|
}
|
|
239468
|
-
const environmentsDir =
|
|
239696
|
+
const environmentsDir = join11(projectDir, "environments");
|
|
239469
239697
|
const hasCredentials = Object.keys(originalProjectData.credentialReferences || {}).length > 0;
|
|
239470
|
-
if (!
|
|
239698
|
+
if (!existsSync10(environmentsDir)) {
|
|
239471
239699
|
if (hasCredentials) {
|
|
239472
239700
|
errors.push("Environments directory not found (expected with credentials)");
|
|
239473
239701
|
} else {
|
|
239474
239702
|
warnings.push("Environments directory not found (no credentials defined)");
|
|
239475
239703
|
}
|
|
239476
239704
|
} else {
|
|
239477
|
-
const envIndexPath =
|
|
239478
|
-
if (!
|
|
239705
|
+
const envIndexPath = join11(environmentsDir, "index.ts");
|
|
239706
|
+
if (!existsSync10(envIndexPath)) {
|
|
239479
239707
|
if (hasCredentials) {
|
|
239480
239708
|
errors.push("Environment index.ts not found (expected with credentials)");
|
|
239481
239709
|
} else {
|
|
@@ -239487,7 +239715,7 @@ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = fal
|
|
|
239487
239715
|
}
|
|
239488
239716
|
if (debug) {
|
|
239489
239717
|
console.log(chalk9.gray("\n\u{1F50D} Verification Summary:"));
|
|
239490
|
-
console.log(chalk9.gray(` \u2022 index.ts: ${
|
|
239718
|
+
console.log(chalk9.gray(` \u2022 index.ts: ${existsSync10(indexPath) ? "\u2713" : "\u2717"}`));
|
|
239491
239719
|
console.log(
|
|
239492
239720
|
chalk9.gray(` \u2022 Agent files: ${expectedAgents.length}/${expectedAgents.length} found`)
|
|
239493
239721
|
);
|
|
@@ -239506,9 +239734,87 @@ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = fal
|
|
|
239506
239734
|
return { success: false, errors, warnings };
|
|
239507
239735
|
}
|
|
239508
239736
|
}
|
|
239737
|
+
async function roundTripValidation(projectDir, originalProjectData, config, debug = false) {
|
|
239738
|
+
const errors = [];
|
|
239739
|
+
const warnings = [];
|
|
239740
|
+
try {
|
|
239741
|
+
if (debug) {
|
|
239742
|
+
console.log(chalk9.gray("\n[DEBUG] Starting round-trip validation..."));
|
|
239743
|
+
console.log(chalk9.gray(` \u2022 Loading project from: ${projectDir}`));
|
|
239744
|
+
}
|
|
239745
|
+
const { loadProject: loadProject2 } = await Promise.resolve().then(() => (init_project_loader(), project_loader_exports));
|
|
239746
|
+
const { compareProjectDefinitions: compareProjectDefinitions2 } = await Promise.resolve().then(() => (init_json_comparison(), json_comparison_exports));
|
|
239747
|
+
const originalTenantId = process.env.INKEEP_TENANT_ID;
|
|
239748
|
+
const originalApiUrl = process.env.INKEEP_API_URL;
|
|
239749
|
+
process.env.INKEEP_TENANT_ID = config.tenantId;
|
|
239750
|
+
process.env.INKEEP_API_URL = config.agentsManageApiUrl;
|
|
239751
|
+
let project;
|
|
239752
|
+
try {
|
|
239753
|
+
project = await loadProject2(projectDir);
|
|
239754
|
+
if (debug) {
|
|
239755
|
+
console.log(chalk9.gray(` \u2022 Project loaded successfully: ${project.getId()}`));
|
|
239756
|
+
}
|
|
239757
|
+
} catch (loadError) {
|
|
239758
|
+
errors.push(`Failed to load generated project: ${loadError.message}`);
|
|
239759
|
+
return { success: false, errors, warnings };
|
|
239760
|
+
} finally {
|
|
239761
|
+
if (originalTenantId !== void 0) {
|
|
239762
|
+
process.env.INKEEP_TENANT_ID = originalTenantId;
|
|
239763
|
+
} else {
|
|
239764
|
+
delete process.env.INKEEP_TENANT_ID;
|
|
239765
|
+
}
|
|
239766
|
+
if (originalApiUrl !== void 0) {
|
|
239767
|
+
process.env.INKEEP_API_URL = originalApiUrl;
|
|
239768
|
+
} else {
|
|
239769
|
+
delete process.env.INKEEP_API_URL;
|
|
239770
|
+
}
|
|
239771
|
+
}
|
|
239772
|
+
if (typeof project.setConfig === "function") {
|
|
239773
|
+
project.setConfig(
|
|
239774
|
+
config.tenantId,
|
|
239775
|
+
config.agentsManageApiUrl,
|
|
239776
|
+
void 0,
|
|
239777
|
+
// models - come from project definition
|
|
239778
|
+
config.agentsManageApiKey
|
|
239779
|
+
);
|
|
239780
|
+
}
|
|
239781
|
+
let generatedDefinition;
|
|
239782
|
+
try {
|
|
239783
|
+
generatedDefinition = await project.getFullDefinition();
|
|
239784
|
+
if (debug) {
|
|
239785
|
+
console.log(chalk9.gray(` \u2022 Generated definition serialized successfully`));
|
|
239786
|
+
console.log(chalk9.gray(` - Agents: ${Object.keys(generatedDefinition.agents || {}).length}`));
|
|
239787
|
+
console.log(chalk9.gray(` - Tools: ${Object.keys(generatedDefinition.tools || {}).length}`));
|
|
239788
|
+
}
|
|
239789
|
+
} catch (serializeError) {
|
|
239790
|
+
errors.push(`Failed to serialize generated project: ${serializeError.message}`);
|
|
239791
|
+
return { success: false, errors, warnings };
|
|
239792
|
+
}
|
|
239793
|
+
const comparisonResult = compareProjectDefinitions2(originalProjectData, generatedDefinition);
|
|
239794
|
+
if (debug) {
|
|
239795
|
+
console.log(chalk9.gray(` \u2022 Comparison complete:`));
|
|
239796
|
+
console.log(chalk9.gray(` - Matches: ${comparisonResult.matches}`));
|
|
239797
|
+
console.log(chalk9.gray(` - Differences: ${comparisonResult.differences.length}`));
|
|
239798
|
+
console.log(chalk9.gray(` - Warnings: ${comparisonResult.warnings.length}`));
|
|
239799
|
+
}
|
|
239800
|
+
errors.push(...comparisonResult.differences);
|
|
239801
|
+
warnings.push(...comparisonResult.warnings);
|
|
239802
|
+
return {
|
|
239803
|
+
success: comparisonResult.matches && errors.length === 0,
|
|
239804
|
+
errors,
|
|
239805
|
+
warnings
|
|
239806
|
+
};
|
|
239807
|
+
} catch (error) {
|
|
239808
|
+
errors.push(`Round-trip validation failed: ${error.message}`);
|
|
239809
|
+
if (debug) {
|
|
239810
|
+
console.log(chalk9.red(`[DEBUG] Round-trip validation error: ${error.stack}`));
|
|
239811
|
+
}
|
|
239812
|
+
return { success: false, errors, warnings };
|
|
239813
|
+
}
|
|
239814
|
+
}
|
|
239509
239815
|
async function loadProjectConfig(projectDir, configPathOverride) {
|
|
239510
|
-
const configPath = configPathOverride ? resolve4(process.cwd(), configPathOverride) :
|
|
239511
|
-
if (!
|
|
239816
|
+
const configPath = configPathOverride ? resolve4(process.cwd(), configPathOverride) : join11(projectDir, "inkeep.config.ts");
|
|
239817
|
+
if (!existsSync10(configPath)) {
|
|
239512
239818
|
throw new Error(`Configuration file not found: ${configPath}`);
|
|
239513
239819
|
}
|
|
239514
239820
|
try {
|
|
@@ -239533,7 +239839,7 @@ async function loadProjectConfig(projectDir, configPathOverride) {
|
|
|
239533
239839
|
}
|
|
239534
239840
|
}
|
|
239535
239841
|
function ensureDirectoryExists(dirPath) {
|
|
239536
|
-
if (!
|
|
239842
|
+
if (!existsSync10(dirPath)) {
|
|
239537
239843
|
mkdirSync2(dirPath, { recursive: true });
|
|
239538
239844
|
}
|
|
239539
239845
|
}
|
|
@@ -239543,15 +239849,15 @@ function createProjectStructure(projectDir, projectId, useCurrentDirectory = fal
|
|
|
239543
239849
|
projectRoot = projectDir;
|
|
239544
239850
|
} else {
|
|
239545
239851
|
const dirName = projectDir.split("/").pop() || projectDir;
|
|
239546
|
-
projectRoot = dirName === projectId ? projectDir :
|
|
239547
|
-
}
|
|
239548
|
-
const agentsDir =
|
|
239549
|
-
const toolsDir =
|
|
239550
|
-
const dataComponentsDir =
|
|
239551
|
-
const artifactComponentsDir =
|
|
239552
|
-
const statusComponentsDir =
|
|
239553
|
-
const environmentsDir =
|
|
239554
|
-
const externalAgentsDir =
|
|
239852
|
+
projectRoot = dirName === projectId ? projectDir : join11(projectDir, projectId);
|
|
239853
|
+
}
|
|
239854
|
+
const agentsDir = join11(projectRoot, "agents");
|
|
239855
|
+
const toolsDir = join11(projectRoot, "tools");
|
|
239856
|
+
const dataComponentsDir = join11(projectRoot, "data-components");
|
|
239857
|
+
const artifactComponentsDir = join11(projectRoot, "artifact-components");
|
|
239858
|
+
const statusComponentsDir = join11(projectRoot, "status-components");
|
|
239859
|
+
const environmentsDir = join11(projectRoot, "environments");
|
|
239860
|
+
const externalAgentsDir = join11(projectRoot, "external-agents");
|
|
239555
239861
|
ensureDirectoryExists(projectRoot);
|
|
239556
239862
|
ensureDirectoryExists(agentsDir);
|
|
239557
239863
|
ensureDirectoryExists(toolsDir);
|
|
@@ -239610,7 +239916,7 @@ async function pullProjectCommand(options) {
|
|
|
239610
239916
|
const searchDir = process.cwd();
|
|
239611
239917
|
if (options.config) {
|
|
239612
239918
|
const configPath = resolve4(process.cwd(), options.config);
|
|
239613
|
-
if (
|
|
239919
|
+
if (existsSync10(configPath)) {
|
|
239614
239920
|
try {
|
|
239615
239921
|
config = await loadProjectConfig(dirname5(configPath), options.config);
|
|
239616
239922
|
configFound = true;
|
|
@@ -239628,8 +239934,8 @@ async function pullProjectCommand(options) {
|
|
|
239628
239934
|
}
|
|
239629
239935
|
}
|
|
239630
239936
|
if (!configFound) {
|
|
239631
|
-
const currentConfigPath =
|
|
239632
|
-
if (
|
|
239937
|
+
const currentConfigPath = join11(searchDir, "inkeep.config.ts");
|
|
239938
|
+
if (existsSync10(currentConfigPath)) {
|
|
239633
239939
|
try {
|
|
239634
239940
|
config = await loadProjectConfig(searchDir);
|
|
239635
239941
|
configFound = true;
|
|
@@ -239639,10 +239945,10 @@ async function pullProjectCommand(options) {
|
|
|
239639
239945
|
}
|
|
239640
239946
|
}
|
|
239641
239947
|
if (!configFound) {
|
|
239642
|
-
const parentConfigPath =
|
|
239643
|
-
if (
|
|
239948
|
+
const parentConfigPath = join11(searchDir, "..", "inkeep.config.ts");
|
|
239949
|
+
if (existsSync10(parentConfigPath)) {
|
|
239644
239950
|
try {
|
|
239645
|
-
config = await loadProjectConfig(
|
|
239951
|
+
config = await loadProjectConfig(join11(searchDir, ".."));
|
|
239646
239952
|
configFound = true;
|
|
239647
239953
|
configLocation = parentConfigPath;
|
|
239648
239954
|
} catch (_error) {
|
|
@@ -239672,7 +239978,7 @@ async function pullProjectCommand(options) {
|
|
|
239672
239978
|
);
|
|
239673
239979
|
console.log(chalk9.gray("Searched in:"));
|
|
239674
239980
|
console.log(chalk9.gray(` \u2022 Current directory: ${searchDir}`));
|
|
239675
|
-
console.log(chalk9.gray(` \u2022 Parent directory: ${
|
|
239981
|
+
console.log(chalk9.gray(` \u2022 Parent directory: ${join11(searchDir, "..")}`));
|
|
239676
239982
|
console.log(chalk9.gray(` \u2022 Parent directories up to root`));
|
|
239677
239983
|
process.exit(1);
|
|
239678
239984
|
}
|
|
@@ -239686,8 +239992,8 @@ async function pullProjectCommand(options) {
|
|
|
239686
239992
|
} else {
|
|
239687
239993
|
const projectRoot = await findProjectDirectory();
|
|
239688
239994
|
if (projectRoot) {
|
|
239689
|
-
const srcPath =
|
|
239690
|
-
baseDir =
|
|
239995
|
+
const srcPath = join11(projectRoot, "src");
|
|
239996
|
+
baseDir = existsSync10(srcPath) ? srcPath : projectRoot;
|
|
239691
239997
|
} else {
|
|
239692
239998
|
baseDir = process.cwd();
|
|
239693
239999
|
}
|
|
@@ -239822,7 +240128,7 @@ async function pullProjectCommand(options) {
|
|
|
239822
240128
|
const dirs = createProjectStructure(baseDir, finalConfig.projectId, useCurrentDirectory);
|
|
239823
240129
|
s2.stop("Project structure created");
|
|
239824
240130
|
if (options.json) {
|
|
239825
|
-
const jsonFilePath =
|
|
240131
|
+
const jsonFilePath = join11(dirs.projectRoot, `${finalConfig.projectId}.json`);
|
|
239826
240132
|
writeFileSync6(jsonFilePath, JSON.stringify(projectData, null, 2));
|
|
239827
240133
|
s2.stop(`Project data saved to ${jsonFilePath}`);
|
|
239828
240134
|
console.log(chalk9.green(`\u2705 JSON file created: ${jsonFilePath}`));
|
|
@@ -239943,11 +240249,63 @@ async function pullProjectCommand(options) {
|
|
|
239943
240249
|
if (verificationResult.success) {
|
|
239944
240250
|
s2.stop("Generated files verified successfully");
|
|
239945
240251
|
if (options.debug && verificationResult.warnings.length > 0) {
|
|
239946
|
-
console.log(chalk9.yellow("\n\u26A0\uFE0F
|
|
240252
|
+
console.log(chalk9.yellow("\n\u26A0\uFE0F File verification warnings:"));
|
|
239947
240253
|
verificationResult.warnings.forEach((warning) => {
|
|
239948
240254
|
console.log(chalk9.gray(` \u2022 ${warning}`));
|
|
239949
240255
|
});
|
|
239950
240256
|
}
|
|
240257
|
+
s2.start("Performing round-trip validation...");
|
|
240258
|
+
try {
|
|
240259
|
+
const roundTripResult = await roundTripValidation(
|
|
240260
|
+
dirs.projectRoot,
|
|
240261
|
+
projectData,
|
|
240262
|
+
{
|
|
240263
|
+
tenantId: finalConfig.tenantId,
|
|
240264
|
+
agentsManageApiUrl: finalConfig.agentsManageApiUrl,
|
|
240265
|
+
agentsManageApiKey: finalConfig.agentsManageApiKey
|
|
240266
|
+
},
|
|
240267
|
+
options.debug || false
|
|
240268
|
+
);
|
|
240269
|
+
if (roundTripResult.success) {
|
|
240270
|
+
s2.stop("Round-trip validation passed - generated TS matches backend data");
|
|
240271
|
+
if (options.debug && roundTripResult.warnings.length > 0) {
|
|
240272
|
+
console.log(chalk9.yellow("\n\u26A0\uFE0F Round-trip validation warnings:"));
|
|
240273
|
+
roundTripResult.warnings.forEach((warning) => {
|
|
240274
|
+
console.log(chalk9.gray(` \u2022 ${warning}`));
|
|
240275
|
+
});
|
|
240276
|
+
}
|
|
240277
|
+
} else {
|
|
240278
|
+
s2.stop("Round-trip validation failed");
|
|
240279
|
+
console.error(chalk9.red("\n\u274C Round-trip validation errors:"));
|
|
240280
|
+
console.error(
|
|
240281
|
+
chalk9.gray(
|
|
240282
|
+
" The generated TypeScript does not serialize back to match the original backend data."
|
|
240283
|
+
)
|
|
240284
|
+
);
|
|
240285
|
+
roundTripResult.errors.forEach((error) => {
|
|
240286
|
+
console.error(chalk9.red(` \u2022 ${error}`));
|
|
240287
|
+
});
|
|
240288
|
+
if (roundTripResult.warnings.length > 0) {
|
|
240289
|
+
console.log(chalk9.yellow("\n\u26A0\uFE0F Round-trip validation warnings:"));
|
|
240290
|
+
roundTripResult.warnings.forEach((warning) => {
|
|
240291
|
+
console.log(chalk9.gray(` \u2022 ${warning}`));
|
|
240292
|
+
});
|
|
240293
|
+
}
|
|
240294
|
+
console.log(
|
|
240295
|
+
chalk9.yellow(
|
|
240296
|
+
"\n\u26A0\uFE0F This indicates an issue with LLM generation or schema mappings."
|
|
240297
|
+
)
|
|
240298
|
+
);
|
|
240299
|
+
console.log(chalk9.gray("The generated files may not work correctly with `inkeep push`."));
|
|
240300
|
+
}
|
|
240301
|
+
} catch (roundTripError) {
|
|
240302
|
+
s2.stop("Round-trip validation could not be completed");
|
|
240303
|
+
console.error(chalk9.yellow(`
|
|
240304
|
+
Round-trip validation error: ${roundTripError.message}`));
|
|
240305
|
+
if (options.debug && roundTripError.stack) {
|
|
240306
|
+
console.error(chalk9.gray(roundTripError.stack));
|
|
240307
|
+
}
|
|
240308
|
+
}
|
|
239951
240309
|
} else {
|
|
239952
240310
|
s2.stop("Generated files verification failed");
|
|
239953
240311
|
console.error(chalk9.red("\n\u274C Verification errors:"));
|
|
@@ -239955,7 +240313,7 @@ async function pullProjectCommand(options) {
|
|
|
239955
240313
|
console.error(chalk9.red(` \u2022 ${error}`));
|
|
239956
240314
|
});
|
|
239957
240315
|
if (verificationResult.warnings.length > 0) {
|
|
239958
|
-
console.log(chalk9.yellow("\n\u26A0\uFE0F
|
|
240316
|
+
console.log(chalk9.yellow("\n\u26A0\uFE0F File verification warnings:"));
|
|
239959
240317
|
verificationResult.warnings.forEach((warning) => {
|
|
239960
240318
|
console.log(chalk9.gray(` \u2022 ${warning}`));
|
|
239961
240319
|
});
|
|
@@ -240012,20 +240370,20 @@ async function pullProjectCommand(options) {
|
|
|
240012
240370
|
// src/commands/push.ts
|
|
240013
240371
|
init_esm_shims();
|
|
240014
240372
|
init_env2();
|
|
240015
|
-
import { existsSync as
|
|
240016
|
-
import { join as
|
|
240373
|
+
import { existsSync as existsSync12 } from "fs";
|
|
240374
|
+
import { join as join13, resolve as resolve5 } from "path";
|
|
240017
240375
|
import chalk10 from "chalk";
|
|
240018
240376
|
import * as p8 from "@clack/prompts";
|
|
240019
240377
|
|
|
240020
240378
|
// src/utils/environment-loader.ts
|
|
240021
240379
|
init_esm_shims();
|
|
240022
240380
|
init_tsx_loader();
|
|
240023
|
-
import { existsSync as
|
|
240024
|
-
import { join as
|
|
240381
|
+
import { existsSync as existsSync11 } from "fs";
|
|
240382
|
+
import { join as join12 } from "path";
|
|
240025
240383
|
async function loadEnvironmentCredentials(projectDir, env3) {
|
|
240026
|
-
const environmentsDir =
|
|
240027
|
-
const envFilePath =
|
|
240028
|
-
if (!
|
|
240384
|
+
const environmentsDir = join12(projectDir, "environments");
|
|
240385
|
+
const envFilePath = join12(environmentsDir, `${env3}.env.ts`);
|
|
240386
|
+
if (!existsSync11(envFilePath)) {
|
|
240029
240387
|
throw new Error(
|
|
240030
240388
|
`Environment file not found: ${envFilePath}
|
|
240031
240389
|
Make sure you have a ${env3}.env.ts file in the environments directory.`
|
|
@@ -240051,24 +240409,7 @@ Make sure you have a ${env3}.env.ts file in the environments directory.`
|
|
|
240051
240409
|
}
|
|
240052
240410
|
|
|
240053
240411
|
// src/commands/push.ts
|
|
240054
|
-
|
|
240055
|
-
async function loadProject(projectDir) {
|
|
240056
|
-
const indexPath = join12(projectDir, "index.ts");
|
|
240057
|
-
if (!existsSync11(indexPath)) {
|
|
240058
|
-
throw new Error(`index.ts not found in project directory: ${projectDir}`);
|
|
240059
|
-
}
|
|
240060
|
-
const module = await importWithTypeScriptSupport(indexPath);
|
|
240061
|
-
const exports = Object.keys(module);
|
|
240062
|
-
for (const exportKey of exports) {
|
|
240063
|
-
const value = module[exportKey];
|
|
240064
|
-
if (value && typeof value === "object" && value.__type === "project") {
|
|
240065
|
-
return value;
|
|
240066
|
-
}
|
|
240067
|
-
}
|
|
240068
|
-
throw new Error(
|
|
240069
|
-
'No project export found in index.ts. Expected an export with __type = "project"'
|
|
240070
|
-
);
|
|
240071
|
-
}
|
|
240412
|
+
init_project_loader();
|
|
240072
240413
|
async function pushCommand(options) {
|
|
240073
240414
|
performBackgroundVersionCheck();
|
|
240074
240415
|
const { config } = await initializeCommand({
|
|
@@ -240083,13 +240424,13 @@ async function pushCommand(options) {
|
|
|
240083
240424
|
let projectDir;
|
|
240084
240425
|
if (options.project) {
|
|
240085
240426
|
projectDir = resolve5(process.cwd(), options.project);
|
|
240086
|
-
if (!
|
|
240427
|
+
if (!existsSync12(join13(projectDir, "index.ts"))) {
|
|
240087
240428
|
s2.stop(`No index.ts found in specified project directory: ${projectDir}`);
|
|
240088
240429
|
process.exit(1);
|
|
240089
240430
|
}
|
|
240090
240431
|
} else {
|
|
240091
240432
|
const currentDir = process.cwd();
|
|
240092
|
-
if (
|
|
240433
|
+
if (existsSync12(join13(currentDir, "index.ts"))) {
|
|
240093
240434
|
projectDir = currentDir;
|
|
240094
240435
|
} else {
|
|
240095
240436
|
s2.stop("No index.ts found in current directory");
|
|
@@ -240150,7 +240491,7 @@ async function pushCommand(options) {
|
|
|
240150
240491
|
s2.start("Generating project data JSON...");
|
|
240151
240492
|
try {
|
|
240152
240493
|
const projectDefinition = await project.getFullDefinition();
|
|
240153
|
-
const jsonFilePath =
|
|
240494
|
+
const jsonFilePath = join13(projectDir, `project.json`);
|
|
240154
240495
|
const fs5 = await import("fs/promises");
|
|
240155
240496
|
await fs5.writeFile(jsonFilePath, JSON.stringify(projectDefinition, null, 2));
|
|
240156
240497
|
s2.stop(`Project data saved to ${jsonFilePath}`);
|
|
@@ -240386,7 +240727,7 @@ async function updateCommand(options = {}) {
|
|
|
240386
240727
|
// src/index.ts
|
|
240387
240728
|
var __filename3 = fileURLToPath3(import.meta.url);
|
|
240388
240729
|
var __dirname3 = dirname6(__filename3);
|
|
240389
|
-
var packageJsonPath =
|
|
240730
|
+
var packageJsonPath = join14(__dirname3, "..", "package.json");
|
|
240390
240731
|
var packageJson = JSON.parse(readFileSync7(packageJsonPath, "utf-8"));
|
|
240391
240732
|
var program = new Command();
|
|
240392
240733
|
program.name("inkeep").description("CLI tool for Inkeep Agent Framework").version(packageJson.version);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-cli",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.2",
|
|
4
4
|
"description": "Inkeep CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"recast": "^0.23.0",
|
|
49
49
|
"ts-morph": "^26.0.0",
|
|
50
50
|
"tsx": "^4.20.5",
|
|
51
|
-
"@inkeep/agents-core": "^0.26.
|
|
52
|
-
"@inkeep/agents-sdk": "^0.26.
|
|
51
|
+
"@inkeep/agents-core": "^0.26.2",
|
|
52
|
+
"@inkeep/agents-sdk": "^0.26.2"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/degit": "^2.8.6",
|