@aexol/spectral 0.9.135 → 0.9.137
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/sdk/ai/utils/validation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/sdk/ai/utils/validation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAuRlD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAMvE;AAgCD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAkCzE"}
|
|
@@ -5,6 +5,16 @@ const TYPEBOX_KIND = Symbol.for("TypeBox.Kind");
|
|
|
5
5
|
function isRecord(value) {
|
|
6
6
|
return typeof value === "object" && value !== null;
|
|
7
7
|
}
|
|
8
|
+
function cloneToolArgumentsForValidation(args) {
|
|
9
|
+
const clone = {};
|
|
10
|
+
for (const [key, value] of Object.entries(args)) {
|
|
11
|
+
// Tool arguments are JSON-shaped. Primitive values are immutable, so keep
|
|
12
|
+
// large strings (for example write.content) out of structuredClone while
|
|
13
|
+
// still isolating nested objects that Value.Convert may mutate in place.
|
|
14
|
+
clone[key] = isRecord(value) ? structuredClone(value) : value;
|
|
15
|
+
}
|
|
16
|
+
return clone;
|
|
17
|
+
}
|
|
8
18
|
function isJsonSchemaObject(value) {
|
|
9
19
|
return isRecord(value);
|
|
10
20
|
}
|
|
@@ -269,7 +279,7 @@ function truncateForDisplay(value, maxLen = 200) {
|
|
|
269
279
|
return str.length > maxLen ? `${str.slice(0, maxLen)}...` : str;
|
|
270
280
|
}
|
|
271
281
|
export function validateToolArguments(tool, toolCall) {
|
|
272
|
-
const args =
|
|
282
|
+
const args = cloneToolArgumentsForValidation(toolCall.arguments);
|
|
273
283
|
Value.Convert(tool.parameters, args);
|
|
274
284
|
const validator = getValidator(tool.parameters);
|
|
275
285
|
if (!hasTypeBoxMetadata(tool.parameters) && isJsonSchemaObject(tool.parameters)) {
|
|
@@ -95,11 +95,11 @@ function formatReadResult(args, result, options, theme, showImages, cwd, isError
|
|
|
95
95
|
}
|
|
96
96
|
const rawPath = str(args?.file_path ?? args?.path);
|
|
97
97
|
const output = getTextOutput(result, showImages);
|
|
98
|
-
const
|
|
99
|
-
const renderedLines = lang ? highlightCode(replaceTabs(output), lang) : output.split("\n");
|
|
100
|
-
const lines = trimTrailingEmptyLines(renderedLines);
|
|
98
|
+
const lines = trimTrailingEmptyLines(output.split("\n"));
|
|
101
99
|
const maxLines = options.expanded ? lines.length : 10;
|
|
102
|
-
const
|
|
100
|
+
const preview = lines.slice(0, maxLines);
|
|
101
|
+
const lang = rawPath ? getLanguageFromPath(rawPath) : undefined;
|
|
102
|
+
const displayLines = lang ? highlightCode(replaceTabs(preview.join("\n")), lang) : preview;
|
|
103
103
|
const remaining = lines.length - maxLines;
|
|
104
104
|
let text = `\n${displayLines.map((line) => replaceTabs(line)).join("\n")}`;
|
|
105
105
|
if (remaining > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../../../src/sdk/coding-agent/core/tools/write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAe7D,QAAA,MAAM,WAAW;;;EAKf,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AM,EACX,OAAO,CAAC,EAAE,gBAAgB,GACzB,SAAS,CAAC,OAAO,WAAW,CAAC,CAE/B"}
|
|
@@ -33,15 +33,15 @@ function formatWriteCall(args, options, _theme) {
|
|
|
33
33
|
text += `\n\n[invalid content arg - expected string]`;
|
|
34
34
|
}
|
|
35
35
|
else if (fileContent) {
|
|
36
|
-
const
|
|
37
|
-
const renderedLines = lang
|
|
38
|
-
? highlightCode(replaceTabs(normalizeDisplayText(fileContent)), lang)
|
|
39
|
-
: normalizeDisplayText(fileContent).split("\n");
|
|
40
|
-
const lines = trimTrailingEmptyLines(renderedLines);
|
|
36
|
+
const lines = trimTrailingEmptyLines(normalizeDisplayText(fileContent).split("\n"));
|
|
41
37
|
const totalLines = lines.length;
|
|
42
|
-
const maxLines = options.expanded ?
|
|
43
|
-
const
|
|
44
|
-
const
|
|
38
|
+
const maxLines = options.expanded ? totalLines : 10;
|
|
39
|
+
const preview = lines.slice(0, maxLines);
|
|
40
|
+
const lang = rawPath ? getLanguageFromPath(rawPath) : undefined;
|
|
41
|
+
const displayLines = lang
|
|
42
|
+
? highlightCode(replaceTabs(preview.join("\n")), lang)
|
|
43
|
+
: preview;
|
|
44
|
+
const remaining = totalLines - maxLines;
|
|
45
45
|
text += `\n\n${displayLines.join("\n")}`;
|
|
46
46
|
if (remaining > 0) {
|
|
47
47
|
text += `\n... (${remaining} more lines, ${totalLines} total)`;
|