codesavant 1.2.8 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +110 -37
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -22886,10 +22886,11 @@ function highlightCode(content, filePath, options = {}) {
|
|
|
22886
22886
|
function formatReadResult(result, options = {}) {
|
|
22887
22887
|
const { collapsed = true, maxCollapsedLines = 5, showExpandHint = true } = options;
|
|
22888
22888
|
const lines = [];
|
|
22889
|
-
|
|
22890
|
-
lines.push(
|
|
22891
|
-
|
|
22892
|
-
|
|
22889
|
+
lines.push(`${COLORS2.file(ICONS.read)} ${COLORS2.info("Reading file:")}`);
|
|
22890
|
+
lines.push(` ${COLORS2.file(result.path)}`);
|
|
22891
|
+
lines.push(` ${COLORS2.success(ICONS.success)} Read ${COLORS2.success(result.lineCount.toString())} lines successfully`);
|
|
22892
|
+
if (collapsed && showExpandHint && result.preview) {
|
|
22893
|
+
lines.push(COLORS2.muted(" (ctrl+o to expand preview)"));
|
|
22893
22894
|
}
|
|
22894
22895
|
if (result.preview && !collapsed) {
|
|
22895
22896
|
const highlightedPreview = highlightCode(result.preview, result.path, {
|
|
@@ -22897,6 +22898,8 @@ function formatReadResult(result, options = {}) {
|
|
|
22897
22898
|
showLineNumbers: false
|
|
22898
22899
|
});
|
|
22899
22900
|
const displayLines = highlightedPreview.split("\n").slice(0, maxCollapsedLines);
|
|
22901
|
+
lines.push("");
|
|
22902
|
+
lines.push(` ${COLORS2.muted("Preview:")}`);
|
|
22900
22903
|
lines.push(COLORS2.muted(" \u2500".repeat(30)));
|
|
22901
22904
|
for (const line of displayLines) {
|
|
22902
22905
|
lines.push(` ${COLORS2.muted("\u2502")} ${line}`);
|
|
@@ -22905,12 +22908,16 @@ function formatReadResult(result, options = {}) {
|
|
|
22905
22908
|
const remaining = result.lineCount - maxCollapsedLines;
|
|
22906
22909
|
lines.push(` ${COLORS2.muted("\u2502")} ${COLORS2.muted(`... (${remaining} more lines)`)}`);
|
|
22907
22910
|
}
|
|
22911
|
+
lines.push(COLORS2.muted(" \u2500".repeat(30)));
|
|
22908
22912
|
}
|
|
22909
22913
|
return lines.join("\n");
|
|
22910
22914
|
}
|
|
22911
22915
|
function formatWriteResult(result, options = {}) {
|
|
22912
22916
|
const { tokensUsed, durationMs } = options;
|
|
22913
|
-
|
|
22917
|
+
const lines = [];
|
|
22918
|
+
lines.push(`${COLORS2.success(ICONS.success)} ${COLORS2.info("Writing file:")}`);
|
|
22919
|
+
lines.push(` ${COLORS2.file(result.path)}`);
|
|
22920
|
+
lines.push(` ${COLORS2.success(ICONS.success)} Wrote ${COLORS2.success(result.lineCount.toString())} lines successfully`);
|
|
22914
22921
|
const meta = [];
|
|
22915
22922
|
if (tokensUsed) {
|
|
22916
22923
|
meta.push(`${formatTokens(tokensUsed)}`);
|
|
@@ -22919,26 +22926,33 @@ function formatWriteResult(result, options = {}) {
|
|
|
22919
22926
|
meta.push(formatDuration(durationMs));
|
|
22920
22927
|
}
|
|
22921
22928
|
if (meta.length > 0) {
|
|
22922
|
-
|
|
22929
|
+
lines.push(` ${COLORS2.muted(`(${meta.join(" \xB7 ")})`)}`);
|
|
22923
22930
|
}
|
|
22924
|
-
return
|
|
22931
|
+
return lines.join("\n");
|
|
22925
22932
|
}
|
|
22926
22933
|
function formatEditResult(result, options = {}) {
|
|
22927
22934
|
const { collapsed = true, maxCollapsedLines = 10, showExpandHint = true } = options;
|
|
22928
22935
|
const lines = [];
|
|
22936
|
+
lines.push(`${COLORS2.warning(ICONS.edit)} ${COLORS2.info("Editing file:")}`);
|
|
22937
|
+
lines.push(` ${COLORS2.file(result.path)}`);
|
|
22929
22938
|
const changes = [];
|
|
22930
22939
|
if (result.linesAdded > 0) {
|
|
22931
|
-
changes.push(COLORS2.success(`+${result.linesAdded}`));
|
|
22940
|
+
changes.push(`${COLORS2.success(`+${result.linesAdded} lines added`)}`);
|
|
22932
22941
|
}
|
|
22933
22942
|
if (result.linesRemoved > 0) {
|
|
22934
|
-
changes.push(COLORS2.error(`-${result.linesRemoved}`));
|
|
22943
|
+
changes.push(`${COLORS2.error(`-${result.linesRemoved} lines removed`)}`);
|
|
22944
|
+
}
|
|
22945
|
+
if (changes.length > 0) {
|
|
22946
|
+
lines.push(` ${COLORS2.success(ICONS.success)} ${changes.join(", ")}`);
|
|
22947
|
+
} else {
|
|
22948
|
+
lines.push(` ${COLORS2.success(ICONS.success)} Edit applied (no net line change)`);
|
|
22935
22949
|
}
|
|
22936
|
-
const changeText = changes.length > 0 ? changes.join(" ") : "no changes";
|
|
22937
|
-
lines.push(`${COLORS2.warning(ICONS.edit)} Edited ${COLORS2.file(result.path)} ${COLORS2.muted("(")}${changeText}${COLORS2.muted(")")}`);
|
|
22938
22950
|
if (collapsed && showExpandHint && result.diffChunks && result.diffChunks.length > 0) {
|
|
22939
|
-
lines.push(COLORS2.muted(" (ctrl+o to expand)"));
|
|
22951
|
+
lines.push(COLORS2.muted(" (ctrl+o to expand diff)"));
|
|
22940
22952
|
}
|
|
22941
22953
|
if (!collapsed && result.diffChunks) {
|
|
22954
|
+
lines.push("");
|
|
22955
|
+
lines.push(` ${COLORS2.muted("Diff:")}`);
|
|
22942
22956
|
lines.push(COLORS2.muted(" \u2500".repeat(30)));
|
|
22943
22957
|
let displayedLines = 0;
|
|
22944
22958
|
for (const chunk of result.diffChunks) {
|
|
@@ -22958,25 +22972,29 @@ function formatEditResult(result, options = {}) {
|
|
|
22958
22972
|
displayedLines++;
|
|
22959
22973
|
}
|
|
22960
22974
|
}
|
|
22975
|
+
lines.push(COLORS2.muted(" \u2500".repeat(30)));
|
|
22961
22976
|
}
|
|
22962
22977
|
return lines.join("\n");
|
|
22963
22978
|
}
|
|
22964
22979
|
function formatSearchResult(result, options = {}) {
|
|
22965
22980
|
const { collapsed = true, maxCollapsedLines = 5, showExpandHint = true } = options;
|
|
22966
22981
|
const lines = [];
|
|
22967
|
-
|
|
22968
|
-
|
|
22982
|
+
lines.push(`${COLORS2.info(ICONS.grep)} ${COLORS2.info("Searching for pattern:")}`);
|
|
22983
|
+
lines.push(` ${COLORS2.accent(`"${result.pattern}"`)}`);
|
|
22984
|
+
let resultSummary = ` ${COLORS2.success(ICONS.success)} Found ${COLORS2.success(result.matchCount.toString())} `;
|
|
22985
|
+
resultSummary += result.matchCount === 1 ? "match" : "matches";
|
|
22969
22986
|
if (result.fileCount && result.fileCount > 1) {
|
|
22970
|
-
|
|
22987
|
+
resultSummary += ` across ${COLORS2.file(result.fileCount.toString())} files`;
|
|
22971
22988
|
}
|
|
22972
|
-
|
|
22973
|
-
lines.push(header);
|
|
22989
|
+
lines.push(resultSummary);
|
|
22974
22990
|
if (collapsed && showExpandHint && result.preview) {
|
|
22975
|
-
lines.push(COLORS2.muted(" (ctrl+o to expand)"));
|
|
22991
|
+
lines.push(COLORS2.muted(" (ctrl+o to expand results)"));
|
|
22976
22992
|
}
|
|
22977
22993
|
if (!collapsed && result.preview) {
|
|
22978
22994
|
const previewLines = result.preview.split("\n");
|
|
22979
22995
|
const displayLines = previewLines.slice(0, maxCollapsedLines);
|
|
22996
|
+
lines.push("");
|
|
22997
|
+
lines.push(` ${COLORS2.muted("Results:")}`);
|
|
22980
22998
|
lines.push(COLORS2.muted(" \u2500".repeat(30)));
|
|
22981
22999
|
for (const line of displayLines) {
|
|
22982
23000
|
lines.push(` ${COLORS2.muted("\u2502")} ${line}`);
|
|
@@ -22985,62 +23003,85 @@ function formatSearchResult(result, options = {}) {
|
|
|
22985
23003
|
const remaining = previewLines.length - maxCollapsedLines;
|
|
22986
23004
|
lines.push(` ${COLORS2.muted("\u2502")} ${COLORS2.muted(`... (${remaining} more results)`)}`);
|
|
22987
23005
|
}
|
|
23006
|
+
lines.push(COLORS2.muted(" \u2500".repeat(30)));
|
|
22988
23007
|
}
|
|
22989
23008
|
return lines.join("\n");
|
|
22990
23009
|
}
|
|
22991
23010
|
function formatGlobResult(files, pattern, options = {}) {
|
|
22992
23011
|
const { collapsed = true, maxCollapsedLines = 10, showExpandHint = true } = options;
|
|
22993
23012
|
const lines = [];
|
|
22994
|
-
lines.push(`${COLORS2.info(ICONS.glob)}
|
|
23013
|
+
lines.push(`${COLORS2.info(ICONS.glob)} ${COLORS2.info("Finding files matching:")}`);
|
|
23014
|
+
lines.push(` ${COLORS2.accent(`"${pattern}"`)}`);
|
|
23015
|
+
lines.push(` ${COLORS2.success(ICONS.success)} Found ${COLORS2.success(files.length.toString())} matching file${files.length !== 1 ? "s" : ""}`);
|
|
22995
23016
|
if (collapsed && showExpandHint && files.length > 0) {
|
|
22996
|
-
lines.push(COLORS2.muted(" (ctrl+o to expand)"));
|
|
23017
|
+
lines.push(COLORS2.muted(" (ctrl+o to expand file list)"));
|
|
22997
23018
|
}
|
|
22998
23019
|
if (!collapsed && files.length > 0) {
|
|
23020
|
+
lines.push("");
|
|
23021
|
+
lines.push(` ${COLORS2.muted("Files:")}`);
|
|
22999
23022
|
lines.push(COLORS2.muted(" \u2500".repeat(30)));
|
|
23000
23023
|
const displayFiles = files.slice(0, maxCollapsedLines);
|
|
23001
23024
|
for (const file of displayFiles) {
|
|
23002
|
-
lines.push(` ${COLORS2.file(ICONS.folder)} ${COLORS2.file(file)}`);
|
|
23025
|
+
lines.push(` ${COLORS2.muted("\u2502")} ${COLORS2.file(ICONS.folder)} ${COLORS2.file(file)}`);
|
|
23003
23026
|
}
|
|
23004
23027
|
if (files.length > maxCollapsedLines) {
|
|
23005
23028
|
const remaining = files.length - maxCollapsedLines;
|
|
23006
|
-
lines.push(` ${COLORS2.muted(`... and ${remaining} more files`)}`);
|
|
23029
|
+
lines.push(` ${COLORS2.muted("\u2502")} ${COLORS2.muted(`... and ${remaining} more files`)}`);
|
|
23007
23030
|
}
|
|
23031
|
+
lines.push(COLORS2.muted(" \u2500".repeat(30)));
|
|
23008
23032
|
}
|
|
23009
23033
|
return lines.join("\n");
|
|
23010
23034
|
}
|
|
23011
23035
|
function formatBashResult(result, command, options = {}) {
|
|
23012
|
-
const { collapsed = true, maxCollapsedLines =
|
|
23036
|
+
const { collapsed = true, maxCollapsedLines = 15, showExpandHint = true } = options;
|
|
23013
23037
|
const isFailed = result.exitCode !== 0;
|
|
23014
23038
|
const lines = [];
|
|
23015
|
-
const displayCommand = isFailed ? command : command.length > 60 ? command.slice(0, 60) + "..." : command;
|
|
23016
23039
|
const statusIcon = isFailed ? COLORS2.error(ICONS.error) : COLORS2.success(ICONS.success);
|
|
23017
|
-
const statusText = isFailed ? `failed (exit ${result.exitCode})` : "completed";
|
|
23018
|
-
lines.push(`${COLORS2.accent(ICONS.lightning)} ${
|
|
23040
|
+
const statusText = isFailed ? `failed (exit code ${result.exitCode})` : "completed successfully";
|
|
23041
|
+
lines.push(`${COLORS2.accent(ICONS.lightning)} ${COLORS2.accent("Executing bash command:")}`);
|
|
23042
|
+
lines.push(` ${COLORS2.muted("$")} ${COLORS2.text(command)}`);
|
|
23043
|
+
lines.push("");
|
|
23019
23044
|
lines.push(` ${statusIcon} ${isFailed ? COLORS2.error(statusText) : COLORS2.success(statusText)}`);
|
|
23020
23045
|
const outputLines = result.output.split("\n").filter((l) => l.trim()).length;
|
|
23021
23046
|
if (outputLines > 0) {
|
|
23022
|
-
|
|
23047
|
+
const effectiveMaxLines = isFailed ? Math.max(maxCollapsedLines, 25) : maxCollapsedLines;
|
|
23023
23048
|
const shouldShowOutput = isFailed || !collapsed;
|
|
23024
|
-
if (collapsed && showExpandHint && !isFailed) {
|
|
23025
|
-
lines.push(COLORS2.muted(" (ctrl+o to expand)"));
|
|
23026
|
-
}
|
|
23027
23049
|
if (shouldShowOutput) {
|
|
23028
|
-
|
|
23029
|
-
lines.push(COLORS2.muted("
|
|
23050
|
+
lines.push("");
|
|
23051
|
+
lines.push(` ${COLORS2.muted("Output:")}`);
|
|
23052
|
+
lines.push(COLORS2.muted(" \u2500".repeat(35)));
|
|
23053
|
+
const allLines = result.output.split("\n");
|
|
23054
|
+
const outputPreview = allLines.slice(0, effectiveMaxLines);
|
|
23030
23055
|
for (const line of outputPreview) {
|
|
23031
|
-
if (isFailed && (line.toLowerCase().includes("error") || line.toLowerCase().includes("failed"))) {
|
|
23056
|
+
if (isFailed && (line.toLowerCase().includes("error") || line.toLowerCase().includes("failed") || line.toLowerCase().includes("cannot") || line.toLowerCase().includes("not found") || line.toLowerCase().includes("permission denied") || line.toLowerCase().includes("no such file") || line.toLowerCase().includes("command not found"))) {
|
|
23032
23057
|
lines.push(` ${COLORS2.muted("\u2502")} ${COLORS2.error(line)}`);
|
|
23058
|
+
} else if (isFailed && (line.toLowerCase().includes("warn") || line.toLowerCase().includes("warning"))) {
|
|
23059
|
+
lines.push(` ${COLORS2.muted("\u2502")} ${COLORS2.warning(line)}`);
|
|
23033
23060
|
} else {
|
|
23034
23061
|
lines.push(` ${COLORS2.muted("\u2502")} ${line}`);
|
|
23035
23062
|
}
|
|
23036
23063
|
}
|
|
23037
|
-
if (
|
|
23038
|
-
const remaining =
|
|
23064
|
+
if (allLines.length > effectiveMaxLines) {
|
|
23065
|
+
const remaining = allLines.length - effectiveMaxLines;
|
|
23039
23066
|
lines.push(` ${COLORS2.muted("\u2502")} ${COLORS2.muted(`... (${remaining} more lines)`)}`);
|
|
23040
23067
|
}
|
|
23068
|
+
lines.push(COLORS2.muted(" \u2500".repeat(35)));
|
|
23069
|
+
} else {
|
|
23070
|
+
lines.push(` ${COLORS2.muted(`${outputLines} lines of output`)}`);
|
|
23071
|
+
if (showExpandHint) {
|
|
23072
|
+
lines.push(COLORS2.muted(" (ctrl+o to expand)"));
|
|
23073
|
+
}
|
|
23041
23074
|
}
|
|
23042
23075
|
} else if (isFailed) {
|
|
23043
|
-
lines.push(
|
|
23076
|
+
lines.push("");
|
|
23077
|
+
lines.push(` ${COLORS2.error("The command produced no output but exited with an error.")}`);
|
|
23078
|
+
lines.push(` ${COLORS2.muted("This often means:")}`);
|
|
23079
|
+
lines.push(` ${COLORS2.muted(" \u2022 The command or program was not found")}`);
|
|
23080
|
+
lines.push(` ${COLORS2.muted(" \u2022 Required dependencies are missing")}`);
|
|
23081
|
+
lines.push(` ${COLORS2.muted(" \u2022 The current directory may be incorrect")}`);
|
|
23082
|
+
lines.push(` ${COLORS2.muted(" \u2022 Permission was denied")}`);
|
|
23083
|
+
} else {
|
|
23084
|
+
lines.push(` ${COLORS2.muted("(no output)")}`);
|
|
23044
23085
|
}
|
|
23045
23086
|
return lines.join("\n");
|
|
23046
23087
|
}
|
|
@@ -30850,8 +30891,40 @@ User request: `;
|
|
|
30850
30891
|
}
|
|
30851
30892
|
appController.setStatus(`Running ${message.toolName}...`);
|
|
30852
30893
|
} else {
|
|
30894
|
+
let toolDisplayContent = message.toolName || "tool";
|
|
30895
|
+
if (message.toolName === "bash" && message.toolInput) {
|
|
30896
|
+
const command = message.toolInput.command;
|
|
30897
|
+
if (command) {
|
|
30898
|
+
toolDisplayContent = `bash: ${command}`;
|
|
30899
|
+
}
|
|
30900
|
+
} else if (message.toolName === "read_file" && message.toolInput) {
|
|
30901
|
+
const path27 = message.toolInput.path;
|
|
30902
|
+
if (path27) {
|
|
30903
|
+
toolDisplayContent = `Reading ${path27}`;
|
|
30904
|
+
}
|
|
30905
|
+
} else if (message.toolName === "write_file" && message.toolInput) {
|
|
30906
|
+
const path27 = message.toolInput.file_path || message.toolInput.path;
|
|
30907
|
+
if (path27) {
|
|
30908
|
+
toolDisplayContent = `Writing ${path27}`;
|
|
30909
|
+
}
|
|
30910
|
+
} else if (message.toolName === "edit_file" && message.toolInput) {
|
|
30911
|
+
const path27 = message.toolInput.file_path || message.toolInput.path;
|
|
30912
|
+
if (path27) {
|
|
30913
|
+
toolDisplayContent = `Editing ${path27}`;
|
|
30914
|
+
}
|
|
30915
|
+
} else if (message.toolName === "glob" && message.toolInput) {
|
|
30916
|
+
const pattern = message.toolInput.pattern;
|
|
30917
|
+
if (pattern) {
|
|
30918
|
+
toolDisplayContent = `Finding files: ${pattern}`;
|
|
30919
|
+
}
|
|
30920
|
+
} else if (message.toolName === "grep" && message.toolInput) {
|
|
30921
|
+
const pattern = message.toolInput.pattern;
|
|
30922
|
+
if (pattern) {
|
|
30923
|
+
toolDisplayContent = `Searching for: ${pattern}`;
|
|
30924
|
+
}
|
|
30925
|
+
}
|
|
30853
30926
|
appController.setStatus(`Running ${message.toolName}...`);
|
|
30854
|
-
appController.addMessage("tool",
|
|
30927
|
+
appController.addMessage("tool", toolDisplayContent, {
|
|
30855
30928
|
toolName: message.toolName
|
|
30856
30929
|
});
|
|
30857
30930
|
}
|