codesavant 1.2.2 → 1.2.7
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 +68 -30
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5455,9 +5455,9 @@ var init_commands = __esm({
|
|
|
5455
5455
|
// src/cli.ts
|
|
5456
5456
|
import { Command } from "commander";
|
|
5457
5457
|
import chalk20 from "chalk";
|
|
5458
|
-
import { readFileSync as
|
|
5459
|
-
import { fileURLToPath } from "url";
|
|
5460
|
-
import { dirname, join as
|
|
5458
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
5459
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
5460
|
+
import { dirname as dirname4, join as join6 } from "path";
|
|
5461
5461
|
|
|
5462
5462
|
// src/config.ts
|
|
5463
5463
|
import fs from "fs-extra";
|
|
@@ -5795,6 +5795,9 @@ Use this context to provide more relevant and personalized assistance.`;
|
|
|
5795
5795
|
import readline from "readline";
|
|
5796
5796
|
import chalk17 from "chalk";
|
|
5797
5797
|
import ora from "ora";
|
|
5798
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
5799
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
5800
|
+
import { dirname as dirname2, join as join4 } from "path";
|
|
5798
5801
|
|
|
5799
5802
|
// src/providers/router.ts
|
|
5800
5803
|
import OpenAI from "openai";
|
|
@@ -23007,29 +23010,37 @@ function formatGlobResult(files, pattern, options = {}) {
|
|
|
23007
23010
|
}
|
|
23008
23011
|
function formatBashResult(result, command, options = {}) {
|
|
23009
23012
|
const { collapsed = true, maxCollapsedLines = 10, showExpandHint = true } = options;
|
|
23013
|
+
const isFailed = result.exitCode !== 0;
|
|
23010
23014
|
const lines = [];
|
|
23011
|
-
const displayCommand = command.length > 60 ? command.slice(0, 60) + "..." : command;
|
|
23012
|
-
const statusIcon =
|
|
23013
|
-
const statusText =
|
|
23014
|
-
lines.push(`${COLORS2.accent(ICONS.lightning)} ${COLORS2.accent(displayCommand)}`);
|
|
23015
|
-
lines.push(` ${statusIcon} ${
|
|
23015
|
+
const displayCommand = isFailed ? command : command.length > 60 ? command.slice(0, 60) + "..." : command;
|
|
23016
|
+
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)} ${isFailed ? COLORS2.error("bash") : COLORS2.accent("bash")} ${COLORS2.accent(displayCommand)}`);
|
|
23019
|
+
lines.push(` ${statusIcon} ${isFailed ? COLORS2.error(statusText) : COLORS2.success(statusText)}`);
|
|
23016
23020
|
const outputLines = result.output.split("\n").filter((l) => l.trim()).length;
|
|
23017
23021
|
if (outputLines > 0) {
|
|
23018
23022
|
lines.push(` ${COLORS2.muted(`${outputLines} lines of output`)}`);
|
|
23019
|
-
|
|
23023
|
+
const shouldShowOutput = isFailed || !collapsed;
|
|
23024
|
+
if (collapsed && showExpandHint && !isFailed) {
|
|
23020
23025
|
lines.push(COLORS2.muted(" (ctrl+o to expand)"));
|
|
23021
23026
|
}
|
|
23022
|
-
if (
|
|
23027
|
+
if (shouldShowOutput) {
|
|
23023
23028
|
const outputPreview = result.output.split("\n").slice(0, maxCollapsedLines);
|
|
23024
23029
|
lines.push(COLORS2.muted(" \u2500".repeat(30)));
|
|
23025
23030
|
for (const line of outputPreview) {
|
|
23026
|
-
|
|
23031
|
+
if (isFailed && (line.toLowerCase().includes("error") || line.toLowerCase().includes("failed"))) {
|
|
23032
|
+
lines.push(` ${COLORS2.muted("\u2502")} ${COLORS2.error(line)}`);
|
|
23033
|
+
} else {
|
|
23034
|
+
lines.push(` ${COLORS2.muted("\u2502")} ${line}`);
|
|
23035
|
+
}
|
|
23027
23036
|
}
|
|
23028
23037
|
if (result.truncated || outputLines > maxCollapsedLines) {
|
|
23029
23038
|
const remaining = (result.totalLines || outputLines) - maxCollapsedLines;
|
|
23030
23039
|
lines.push(` ${COLORS2.muted("\u2502")} ${COLORS2.muted(`... (${remaining} more lines)`)}`);
|
|
23031
23040
|
}
|
|
23032
23041
|
}
|
|
23042
|
+
} else if (isFailed) {
|
|
23043
|
+
lines.push(` ${COLORS2.error("No output (command failed silently)")}`);
|
|
23033
23044
|
}
|
|
23034
23045
|
return lines.join("\n");
|
|
23035
23046
|
}
|
|
@@ -25466,6 +25477,9 @@ init_commands();
|
|
|
25466
25477
|
import os18 from "os";
|
|
25467
25478
|
import path24 from "path";
|
|
25468
25479
|
import fs23 from "fs-extra";
|
|
25480
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
25481
|
+
import { fileURLToPath } from "url";
|
|
25482
|
+
import { dirname, join as join3 } from "path";
|
|
25469
25483
|
|
|
25470
25484
|
// src/commands/types.ts
|
|
25471
25485
|
var DEFAULT_BUG_REPORT_OPTIONS = {
|
|
@@ -25478,7 +25492,11 @@ var DEFAULT_BUG_REPORT_OPTIONS = {
|
|
|
25478
25492
|
};
|
|
25479
25493
|
|
|
25480
25494
|
// src/commands/bug.ts
|
|
25481
|
-
var
|
|
25495
|
+
var __bug_filename = fileURLToPath(import.meta.url);
|
|
25496
|
+
var __bug_dirname = dirname(__bug_filename);
|
|
25497
|
+
var bugPackageJsonPath = join3(__bug_dirname, "..", "package.json");
|
|
25498
|
+
var bugPackageJson = JSON.parse(readFileSync2(bugPackageJsonPath, "utf-8"));
|
|
25499
|
+
var CODESAVANT_VERSION = bugPackageJson.version;
|
|
25482
25500
|
var GITHUB_REPO_URL = "https://github.com/codesavant/codesavant";
|
|
25483
25501
|
function collectSystemInfo() {
|
|
25484
25502
|
return {
|
|
@@ -26508,6 +26526,11 @@ function stripAnsi2(str) {
|
|
|
26508
26526
|
}
|
|
26509
26527
|
|
|
26510
26528
|
// src/repl.ts
|
|
26529
|
+
var __classic_repl_filename = fileURLToPath2(import.meta.url);
|
|
26530
|
+
var __classic_repl_dirname = dirname2(__classic_repl_filename);
|
|
26531
|
+
var classicReplPackageJsonPath = join4(__classic_repl_dirname, "..", "package.json");
|
|
26532
|
+
var classicReplPackageJson = JSON.parse(readFileSync3(classicReplPackageJsonPath, "utf-8"));
|
|
26533
|
+
var CLASSIC_REPL_VERSION = classicReplPackageJson.version;
|
|
26511
26534
|
var PERMISSION_MODES = ["default", "plan", "acceptEdits", "strict", "yolo"];
|
|
26512
26535
|
function createREPL(replConfig) {
|
|
26513
26536
|
const agent = createAgent({
|
|
@@ -27094,7 +27117,7 @@ ${result.message}`));
|
|
|
27094
27117
|
});
|
|
27095
27118
|
const defaultProvider = replConfig.config.providers.find((p) => p.name === replConfig.config.defaultProvider) || replConfig.config.providers[0];
|
|
27096
27119
|
const welcomeScreen = createWelcomeScreen({
|
|
27097
|
-
version:
|
|
27120
|
+
version: CLASSIC_REPL_VERSION,
|
|
27098
27121
|
sessionId: sessionId2,
|
|
27099
27122
|
// Multi-provider info
|
|
27100
27123
|
providers: providerInfoList,
|
|
@@ -28802,6 +28825,11 @@ Undo complete: restored ${restoredCount} file(s)`));
|
|
|
28802
28825
|
};
|
|
28803
28826
|
}
|
|
28804
28827
|
|
|
28828
|
+
// src/repl-ink.ts
|
|
28829
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
28830
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
28831
|
+
import { dirname as dirname3, join as join5 } from "path";
|
|
28832
|
+
|
|
28805
28833
|
// src/ink/index.tsx
|
|
28806
28834
|
import { render } from "ink";
|
|
28807
28835
|
|
|
@@ -30072,7 +30100,7 @@ function InputBoxView({
|
|
|
30072
30100
|
}
|
|
30073
30101
|
),
|
|
30074
30102
|
/* @__PURE__ */ jsx4(Text4, { color: colors.muted, children: icons.horizontal.repeat(cols) }),
|
|
30075
|
-
/* @__PURE__ */
|
|
30103
|
+
/* @__PURE__ */ jsx4(Box4, { paddingLeft: 1, flexDirection: "column", children: /* @__PURE__ */ jsxs4(Box4, { flexDirection: "row", children: [
|
|
30076
30104
|
/* @__PURE__ */ jsxs4(Text4, { color: colors.primary, bold: true, children: [
|
|
30077
30105
|
isMultiline ? icons.boxV : icons.prompt,
|
|
30078
30106
|
" "
|
|
@@ -30083,11 +30111,11 @@ function InputBoxView({
|
|
|
30083
30111
|
" ",
|
|
30084
30112
|
statusText || "Processing..."
|
|
30085
30113
|
] })
|
|
30086
|
-
] }) : /* @__PURE__ */ jsxs4(Text4, { color: colors.text, children: [
|
|
30087
|
-
value,
|
|
30114
|
+
] }) : /* @__PURE__ */ jsx4(Box4, { flexGrow: 1, children: /* @__PURE__ */ jsxs4(Text4, { wrap: "truncate-end", color: colors.text, children: [
|
|
30115
|
+
value.length > cols - 5 ? value.slice(-(cols - 5)) : value,
|
|
30088
30116
|
/* @__PURE__ */ jsx4(Text4, { color: colors.muted, children: "_" })
|
|
30089
|
-
] })
|
|
30090
|
-
] }),
|
|
30117
|
+
] }) })
|
|
30118
|
+
] }) }),
|
|
30091
30119
|
/* @__PURE__ */ jsx4(Box4, { paddingLeft: 1, children: isMultiline ? /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
30092
30120
|
/* @__PURE__ */ jsx4(Text4, { color: colors.warning, children: "multiline" }),
|
|
30093
30121
|
/* @__PURE__ */ jsxs4(Text4, { color: colors.muted, children: [
|
|
@@ -30173,7 +30201,7 @@ function App({
|
|
|
30173
30201
|
const [autocompleteQuery, setAutocompleteQuery] = useState5("");
|
|
30174
30202
|
const lastEscapeRef = useRef(0);
|
|
30175
30203
|
const [renderedMessageCount, setRenderedMessageCount] = useState5(0);
|
|
30176
|
-
const permissionModes = ["
|
|
30204
|
+
const permissionModes = ["default", "plan", "acceptEdits", "strict", "yolo"];
|
|
30177
30205
|
const [currentPermissionMode, setCurrentPermissionMode] = useState5(permissionMode);
|
|
30178
30206
|
useEffect2(() => {
|
|
30179
30207
|
if (sessionId2) actions.setSessionId(sessionId2);
|
|
@@ -30390,10 +30418,14 @@ function App({
|
|
|
30390
30418
|
setAutocompleteQuery("");
|
|
30391
30419
|
}, []);
|
|
30392
30420
|
useEffect2(() => {
|
|
30393
|
-
|
|
30394
|
-
|
|
30395
|
-
|
|
30396
|
-
|
|
30421
|
+
const canMoveToStatic = !state.isProcessing && !state.streamingContent && (!state.todosVisible || state.todos.length === 0);
|
|
30422
|
+
if (canMoveToStatic && state.messages.length > renderedMessageCount) {
|
|
30423
|
+
const timer = setTimeout(() => {
|
|
30424
|
+
setRenderedMessageCount(state.messages.length);
|
|
30425
|
+
}, 100);
|
|
30426
|
+
return () => clearTimeout(timer);
|
|
30427
|
+
}
|
|
30428
|
+
}, [state.isProcessing, state.streamingContent, state.todosVisible, state.todos.length, state.messages.length, renderedMessageCount]);
|
|
30397
30429
|
const completedMessages = state.messages.slice(0, renderedMessageCount);
|
|
30398
30430
|
const activeMessages = state.messages.slice(renderedMessageCount);
|
|
30399
30431
|
const { colors } = theme;
|
|
@@ -30627,6 +30659,11 @@ async function waitForExit() {
|
|
|
30627
30659
|
// src/repl-ink.ts
|
|
30628
30660
|
init_errors();
|
|
30629
30661
|
init_commands();
|
|
30662
|
+
var __repl_filename = fileURLToPath3(import.meta.url);
|
|
30663
|
+
var __repl_dirname = dirname3(__repl_filename);
|
|
30664
|
+
var replPackageJsonPath = join5(__repl_dirname, "..", "package.json");
|
|
30665
|
+
var replPackageJson = JSON.parse(readFileSync4(replPackageJsonPath, "utf-8"));
|
|
30666
|
+
var REPL_VERSION = replPackageJson.version;
|
|
30630
30667
|
function createInkREPL(replConfig) {
|
|
30631
30668
|
const agent = createAgent({
|
|
30632
30669
|
config: replConfig.config,
|
|
@@ -30706,13 +30743,14 @@ function createInkREPL(replConfig) {
|
|
|
30706
30743
|
truncated: output.length > 500,
|
|
30707
30744
|
totalLines: lineCount
|
|
30708
30745
|
};
|
|
30709
|
-
return formatBashResult(result, command, { collapsed:
|
|
30746
|
+
return formatBashResult(result, command, { collapsed: success });
|
|
30710
30747
|
}
|
|
30711
30748
|
default:
|
|
30712
30749
|
if (success) {
|
|
30713
30750
|
return `${toolName} completed${lineCount > 0 ? ` (${lineCount} lines)` : ""}`;
|
|
30714
30751
|
} else {
|
|
30715
|
-
|
|
30752
|
+
const errorMsg = toolResult.error || output.slice(0, 200) || "Unknown error";
|
|
30753
|
+
return `${toolName} failed: ${errorMsg}`;
|
|
30716
30754
|
}
|
|
30717
30755
|
}
|
|
30718
30756
|
}
|
|
@@ -31980,7 +32018,7 @@ Type /help for available commands.`);
|
|
|
31980
32018
|
isAvailable: p.name === "ollama" || !!p.apiKey
|
|
31981
32019
|
}));
|
|
31982
32020
|
const welcomeMessage = createWelcomeScreen({
|
|
31983
|
-
version:
|
|
32021
|
+
version: REPL_VERSION,
|
|
31984
32022
|
sessionId: sessionId2,
|
|
31985
32023
|
providers: providerInfoList,
|
|
31986
32024
|
activeProvider: replConfig.config.defaultProvider,
|
|
@@ -32330,10 +32368,10 @@ Fix all the issues to make the CI pass. Use the available tools to read files, e
|
|
|
32330
32368
|
}
|
|
32331
32369
|
|
|
32332
32370
|
// src/cli.ts
|
|
32333
|
-
var __filename =
|
|
32334
|
-
var __dirname =
|
|
32335
|
-
var packageJsonPath =
|
|
32336
|
-
var packageJson = JSON.parse(
|
|
32371
|
+
var __filename = fileURLToPath4(import.meta.url);
|
|
32372
|
+
var __dirname = dirname4(__filename);
|
|
32373
|
+
var packageJsonPath = join6(__dirname, "..", "package.json");
|
|
32374
|
+
var packageJson = JSON.parse(readFileSync5(packageJsonPath, "utf-8"));
|
|
32337
32375
|
var VERSION = packageJson.version;
|
|
32338
32376
|
var MAX_STDIN_SIZE = 10 * 1024 * 1024;
|
|
32339
32377
|
var MAX_STDIN_LINES = 1e5;
|