aether-code 0.22.0 → 0.24.0
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/bin/aether-code.js +1 -1
- package/package.json +1 -1
- package/src/agent.js +40 -5
- package/src/box-input.js +132 -0
- package/src/render.js +27 -0
- package/src/repl.js +8 -66
- package/src/tools.js +6 -1
package/bin/aether-code.js
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import readline from "node:readline";
|
|
27
27
|
import { c, errorLine, divider, setTerminalTitle } from "../src/render.js";
|
|
28
28
|
|
|
29
|
-
const VERSION = "0.
|
|
29
|
+
const VERSION = "0.24.0";
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Try to start MCP servers from ~/.aether/mcp.json. Returns a started
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aether-code",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Uncensored AI coding agent for your terminal — Claude Code alternative with MCP support. Reads code, writes files, runs commands. Drives IDA Pro, Roblox Studio, Wireshark, Blender, and any MCP server. No refusal layer.",
|
|
5
5
|
"homepage": "https://trynoguard.com",
|
|
6
6
|
"repository": {
|
package/src/agent.js
CHANGED
|
@@ -8,7 +8,7 @@ import { agentTurnStream, AetherError } from "./api.js";
|
|
|
8
8
|
import { TOOL_DEFINITIONS, executeTool } from "./tools.js";
|
|
9
9
|
import { unnamespaceToolName } from "./mcp.js";
|
|
10
10
|
import { loadAllSkills, selectSkills, renderSkillsBlock } from "./skills.js";
|
|
11
|
-
import { c, divider, turn, toolLabel, toolSummary, makeTokenStripper, errorLine } from "./render.js";
|
|
11
|
+
import { c, divider, turn, toolLabel, toolSummary, makeTokenStripper, errorLine, startSpinner } from "./render.js";
|
|
12
12
|
|
|
13
13
|
const DEFAULT_MAX_TURNS = 25;
|
|
14
14
|
|
|
@@ -77,6 +77,9 @@ export async function runAgent({
|
|
|
77
77
|
let totalIn = 0;
|
|
78
78
|
let totalOut = 0;
|
|
79
79
|
let lastBalance = null;
|
|
80
|
+
// Loop guard: count identical (name+args) tool calls across the whole run so a
|
|
81
|
+
// confused model can't burn turns re-running the same call (e.g. glob *.md x9).
|
|
82
|
+
const callCounts = new Map();
|
|
80
83
|
|
|
81
84
|
for (let i = 0; i < maxTurns; i++) {
|
|
82
85
|
// No turn header and no leading blank here — each step (assistant text and
|
|
@@ -98,6 +101,11 @@ export async function runAgent({
|
|
|
98
101
|
const turnMessages = buildTurnMessages(messages, allSkills, referencedPaths);
|
|
99
102
|
|
|
100
103
|
let res;
|
|
104
|
+
// "Thinking" spinner: shown from request-send until the first token or tool
|
|
105
|
+
// call arrives, so the wait doesn't look dead. Stopped exactly once.
|
|
106
|
+
const spinner = startSpinner("thinking");
|
|
107
|
+
let spinStopped = false;
|
|
108
|
+
const stopSpin = () => { if (!spinStopped) { spinStopped = true; spinner.stop(); } };
|
|
101
109
|
try {
|
|
102
110
|
res = await agentTurnStream({
|
|
103
111
|
messages: turnMessages,
|
|
@@ -107,6 +115,7 @@ export async function runAgent({
|
|
|
107
115
|
// be split across stream chunks) before display.
|
|
108
116
|
const clean = stripper.push(text);
|
|
109
117
|
if (!clean) return;
|
|
118
|
+
stopSpin();
|
|
110
119
|
if (!lastWasText) {
|
|
111
120
|
process.stdout.write("\n" + c.cyan("● "));
|
|
112
121
|
lastWasText = true;
|
|
@@ -118,6 +127,7 @@ export async function runAgent({
|
|
|
118
127
|
// call — the clean label is printed at execution time, so no noisy
|
|
119
128
|
// "preparing args" placeholder here.
|
|
120
129
|
if (delta.name && !announced.has(delta.index)) {
|
|
130
|
+
stopSpin();
|
|
121
131
|
announced.add(delta.index);
|
|
122
132
|
if (lastWasText) process.stdout.write("\n");
|
|
123
133
|
lastWasText = false;
|
|
@@ -125,11 +135,13 @@ export async function runAgent({
|
|
|
125
135
|
},
|
|
126
136
|
});
|
|
127
137
|
} catch (err) {
|
|
138
|
+
stopSpin();
|
|
128
139
|
if (err instanceof AetherError) {
|
|
129
140
|
return { ok: false, error: err, totalCredits, totalIn, totalOut, balance: lastBalance, messages };
|
|
130
141
|
}
|
|
131
142
|
throw err;
|
|
132
143
|
}
|
|
144
|
+
stopSpin(); // ensure it's cleared even if the turn produced no output
|
|
133
145
|
|
|
134
146
|
// Flush any held-back partial token, then close the line.
|
|
135
147
|
const tail = stripper.flush();
|
|
@@ -167,14 +179,37 @@ export async function runAgent({
|
|
|
167
179
|
const label = toolLabel(call.function.name, args);
|
|
168
180
|
if (label) console.log("\n" + c.cyan("●") + " " + label);
|
|
169
181
|
|
|
182
|
+
// Loop guard — short-circuit a tool call we've already run 3+ times with
|
|
183
|
+
// the same args, and tell the model to change approach instead of looping.
|
|
184
|
+
const sig = `${call.function.name}:${call.function.arguments || ""}`;
|
|
185
|
+
const seen = (callCounts.get(sig) || 0) + 1;
|
|
186
|
+
callCounts.set(sig, seen);
|
|
187
|
+
if (seen > 3) {
|
|
188
|
+
console.log(" " + c.red("└─") + " " + c.gray("skipped (repeated call)"));
|
|
189
|
+
messages.push({
|
|
190
|
+
role: "tool",
|
|
191
|
+
tool_call_id: call.id,
|
|
192
|
+
content:
|
|
193
|
+
"STOP: you have already run this exact tool call 3 times and the result will not change. Do NOT call it again. " +
|
|
194
|
+
"If you were looking for a file that doesn't exist, create it with write_file. Otherwise change approach or finish and summarize.",
|
|
195
|
+
});
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
|
|
170
199
|
// Route to MCP if the tool name is namespaced (mcp__server__tool);
|
|
171
200
|
// otherwise execute the built-in tool. unnamespaceToolName returns
|
|
172
201
|
// null for non-MCP names, which is our cheap dispatch test.
|
|
202
|
+
const slow = call.function.name === "web_search" || call.function.name === "web_fetch";
|
|
203
|
+
const tspin = slow ? startSpinner(call.function.name === "web_search" ? "searching the web" : "fetching page") : null;
|
|
173
204
|
let result;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
205
|
+
try {
|
|
206
|
+
if (mcpManager && unnamespaceToolName(call.function.name)) {
|
|
207
|
+
result = await mcpManager.callTool(call.function.name, args);
|
|
208
|
+
} else {
|
|
209
|
+
result = await executeTool(call, { cwd, autoYes, unsafePaths });
|
|
210
|
+
}
|
|
211
|
+
} finally {
|
|
212
|
+
if (tspin) tspin.stop();
|
|
178
213
|
}
|
|
179
214
|
|
|
180
215
|
// Track paths the model has touched. Skills with path-pattern triggers
|
package/src/box-input.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Bordered single-line text input — raw-mode, cmd.exe-safe.
|
|
2
|
+
//
|
|
3
|
+
// Like the ask_user menu, this is NOT Ink (which ghosts in the legacy Windows
|
|
4
|
+
// console). It draws a 3-line box + hint, and on every keystroke moves the
|
|
5
|
+
// cursor back up (ESC[nA), clears (ESC[J), and reprints. The caret is a FAKE
|
|
6
|
+
// cursor (inverse-video cell) and the real terminal cursor is hidden, so there
|
|
7
|
+
// is no cursor-column math to get wrong. Long input scrolls horizontally under
|
|
8
|
+
// a fixed right border.
|
|
9
|
+
//
|
|
10
|
+
// Returns the typed string, or EXIT_SIGNAL on Ctrl+C / Ctrl+D.
|
|
11
|
+
|
|
12
|
+
import readline from "node:readline";
|
|
13
|
+
import { c } from "./render.js";
|
|
14
|
+
|
|
15
|
+
export const EXIT_SIGNAL = "<<aether-exit>>";
|
|
16
|
+
|
|
17
|
+
const HIDE = "\x1b[?25l";
|
|
18
|
+
const SHOW = "\x1b[?25h";
|
|
19
|
+
const INV = (s) => `\x1b[7m${s}\x1b[27m`;
|
|
20
|
+
|
|
21
|
+
export function promptBox({ history = [], placeholder = "type a message… /help for commands" } = {}) {
|
|
22
|
+
return new Promise((resolve) => {
|
|
23
|
+
// Non-interactive (piped / tests): plain readline, no box.
|
|
24
|
+
if (!process.stdin.isTTY) {
|
|
25
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
26
|
+
rl.question(c.magenta("› "), (a) => { rl.close(); resolve(a); });
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let buf = "";
|
|
31
|
+
let pos = 0; // caret index within buf
|
|
32
|
+
const hist = history.slice();
|
|
33
|
+
let histIdx = hist.length; // points one past the end (current draft)
|
|
34
|
+
let draft = "";
|
|
35
|
+
let drawn = 0;
|
|
36
|
+
let lastSigint = 0;
|
|
37
|
+
|
|
38
|
+
const innerW = () => Math.max(24, Math.min(process.stdout.columns || 80, 100) - 6);
|
|
39
|
+
|
|
40
|
+
const draw = (first) => {
|
|
41
|
+
const W = innerW();
|
|
42
|
+
if (!first) process.stdout.write(`\x1b[${drawn}A`);
|
|
43
|
+
process.stdout.write("\x1b[J");
|
|
44
|
+
|
|
45
|
+
// Horizontal scroll: keep the caret within the visible window.
|
|
46
|
+
const maxVisible = W - 1;
|
|
47
|
+
const start = pos > maxVisible ? pos - maxVisible : 0;
|
|
48
|
+
const view = buf.slice(start, start + W);
|
|
49
|
+
const rel = pos - start;
|
|
50
|
+
|
|
51
|
+
let content;
|
|
52
|
+
if (buf.length === 0) {
|
|
53
|
+
const ph = placeholder.slice(0, W - 1);
|
|
54
|
+
content = INV(" ") + c.dim(ph) + " ".repeat(Math.max(0, W - 1 - ph.length));
|
|
55
|
+
} else {
|
|
56
|
+
let s = "";
|
|
57
|
+
for (let i = 0; i < W; i++) {
|
|
58
|
+
const ch = view[i] ?? " ";
|
|
59
|
+
s += i === rel ? INV(ch) : ch;
|
|
60
|
+
}
|
|
61
|
+
content = s;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const top = c.magenta("╭" + "─".repeat(W + 4) + "╮");
|
|
65
|
+
const mid = c.magenta("│") + " " + c.magenta("›") + " " + content + " " + c.magenta("│");
|
|
66
|
+
const bot = c.magenta("╰" + "─".repeat(W + 4) + "╯");
|
|
67
|
+
const hint = c.dim(" Enter send · ↑↓ history · /help · /exit");
|
|
68
|
+
|
|
69
|
+
process.stdout.write(top + "\n" + mid + "\n" + bot + "\n" + hint + "\n");
|
|
70
|
+
drawn = 4;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const finish = (result) => {
|
|
74
|
+
process.stdin.removeListener("keypress", onKey);
|
|
75
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(false);
|
|
76
|
+
process.stdin.pause();
|
|
77
|
+
process.stdout.write(`\x1b[${drawn}A\x1b[J` + SHOW);
|
|
78
|
+
// Echo the submitted line so it persists in scrollback.
|
|
79
|
+
if (result && result !== EXIT_SIGNAL && result.trim()) {
|
|
80
|
+
process.stdout.write(c.magenta("› ") + result + "\n");
|
|
81
|
+
}
|
|
82
|
+
resolve(result);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const onKey = (str, key) => {
|
|
86
|
+
if (!key) return;
|
|
87
|
+
const k = key.name;
|
|
88
|
+
|
|
89
|
+
if (k === "return" || k === "enter") return finish(buf);
|
|
90
|
+
if (key.ctrl && k === "c") {
|
|
91
|
+
const now = Date.now();
|
|
92
|
+
if (now - lastSigint < 1500 || buf.length === 0) return finish(EXIT_SIGNAL);
|
|
93
|
+
lastSigint = now;
|
|
94
|
+
buf = ""; pos = 0; draw(false);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (key.ctrl && k === "d") return finish(buf.length === 0 ? EXIT_SIGNAL : buf);
|
|
98
|
+
|
|
99
|
+
if (k === "backspace") { if (pos > 0) { buf = buf.slice(0, pos - 1) + buf.slice(pos); pos--; } }
|
|
100
|
+
else if (k === "delete") { buf = buf.slice(0, pos) + buf.slice(pos + 1); }
|
|
101
|
+
else if (k === "left") { if (pos > 0) pos--; }
|
|
102
|
+
else if (k === "right") { if (pos < buf.length) pos++; }
|
|
103
|
+
else if (k === "home" || (key.ctrl && k === "a")) pos = 0;
|
|
104
|
+
else if (k === "end" || (key.ctrl && k === "e")) pos = buf.length;
|
|
105
|
+
else if (key.ctrl && k === "u") { buf = ""; pos = 0; }
|
|
106
|
+
else if (k === "up") {
|
|
107
|
+
if (histIdx === hist.length) draft = buf;
|
|
108
|
+
if (histIdx > 0) { histIdx--; buf = hist[histIdx] ?? ""; pos = buf.length; }
|
|
109
|
+
}
|
|
110
|
+
else if (k === "down") {
|
|
111
|
+
if (histIdx < hist.length) {
|
|
112
|
+
histIdx++;
|
|
113
|
+
buf = histIdx === hist.length ? draft : (hist[histIdx] ?? "");
|
|
114
|
+
pos = buf.length;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else if (str && !key.ctrl && !key.meta && str >= " " && str !== "\x7f") {
|
|
118
|
+
buf = buf.slice(0, pos) + str + buf.slice(pos);
|
|
119
|
+
pos += str.length;
|
|
120
|
+
}
|
|
121
|
+
else return; // ignore unhandled keys without a redraw
|
|
122
|
+
draw(false);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
process.stdout.write(HIDE);
|
|
126
|
+
readline.emitKeypressEvents(process.stdin);
|
|
127
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
128
|
+
process.stdin.resume();
|
|
129
|
+
process.stdin.on("keypress", onKey);
|
|
130
|
+
draw(true);
|
|
131
|
+
});
|
|
132
|
+
}
|
package/src/render.js
CHANGED
|
@@ -80,6 +80,33 @@ export function setTerminalTitle(title) {
|
|
|
80
80
|
if (process.stdout.isTTY) process.stdout.write(`\x1b]0;${title}\x07`);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
// Live "working…" spinner. Rewrites a single line in place (\r) with a rotating
|
|
84
|
+
// half-circle (Geometric Shapes — same block as ●, so cmd.exe-safe) + elapsed
|
|
85
|
+
// seconds, so the user sees the agent is alive while the model thinks or a slow
|
|
86
|
+
// tool runs. stop() clears the line and restores the cursor. No-op in non-TTY.
|
|
87
|
+
export function startSpinner(label) {
|
|
88
|
+
if (!process.stdout.isTTY) return { stop: () => {} };
|
|
89
|
+
const frames = ["◐", "◓", "◑", "◒"];
|
|
90
|
+
const t0 = Date.now();
|
|
91
|
+
let i = 0;
|
|
92
|
+
process.stdout.write("\x1b[?25l"); // hide cursor
|
|
93
|
+
const render = () => {
|
|
94
|
+
const s = Math.floor((Date.now() - t0) / 1000);
|
|
95
|
+
const tail = s > 0 ? c.gray(` ${s}s`) : "";
|
|
96
|
+
process.stdout.write(`\r\x1b[K${c.cyan(frames[i % frames.length])} ${c.gray(label + "…")}${tail}`);
|
|
97
|
+
i++;
|
|
98
|
+
};
|
|
99
|
+
render();
|
|
100
|
+
const timer = setInterval(render, 120);
|
|
101
|
+
if (typeof timer.unref === "function") timer.unref(); // don't keep the process alive
|
|
102
|
+
return {
|
|
103
|
+
stop: () => {
|
|
104
|
+
clearInterval(timer);
|
|
105
|
+
process.stdout.write("\r\x1b[K\x1b[?25h"); // clear line + show cursor
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
83
110
|
// Terse one-line result summary instead of dumping raw JSON / file contents.
|
|
84
111
|
// Tools whose handlers already render rich output (diffs, the shell stream, the
|
|
85
112
|
// plan) just get a check — the detail was already printed.
|
package/src/repl.js
CHANGED
|
@@ -8,16 +8,15 @@
|
|
|
8
8
|
// - Bottom status line is rendered after each turn
|
|
9
9
|
// - Ctrl+C: first press cancels in-progress turn, second press exits
|
|
10
10
|
|
|
11
|
-
import readline from "node:readline";
|
|
12
11
|
import path from "node:path";
|
|
13
12
|
import { runAgent } from "./agent.js";
|
|
14
13
|
import { fetchBalance, AetherError } from "./api.js";
|
|
15
14
|
import { runSetup } from "./setup.js";
|
|
16
15
|
import { c, errorLine, box } from "./render.js";
|
|
17
16
|
import { checkForUpdate } from "./update-check.js";
|
|
18
|
-
import {
|
|
17
|
+
import { promptBox, EXIT_SIGNAL } from "./box-input.js";
|
|
19
18
|
|
|
20
|
-
const VERSION = "0.
|
|
19
|
+
const VERSION = "0.24.0";
|
|
21
20
|
const MODEL_NAME = "Aether Core";
|
|
22
21
|
|
|
23
22
|
const SHORTCUTS = `
|
|
@@ -85,76 +84,19 @@ export async function runRepl({ cwd: initialCwd, autoYes: initialAutoYes, unsafe
|
|
|
85
84
|
const updateNudge = await updatePromise;
|
|
86
85
|
if (updateNudge) console.log(updateNudge + "\n");
|
|
87
86
|
|
|
88
|
-
// Input:
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
// redraw + raw-mode: typed characters ghost (the console echoes what Ink
|
|
93
|
-
// already drew) and the box border tears on each keystroke. Windows Terminal
|
|
94
|
-
// (sets WT_SESSION) and non-Windows render Ink correctly. So we default to
|
|
95
|
-
// the clean prompt on legacy Windows console; AETHER_INK=1 forces Ink there
|
|
96
|
-
// for anyone who wants to try it, AETHER_NO_INK=1 forces the plain prompt.
|
|
87
|
+
// Input: a bordered raw-mode box (box-input.js) — cmd.exe-safe and identical
|
|
88
|
+
// everywhere. (Ink's live redraw ghosts in the legacy Windows console, so we
|
|
89
|
+
// don't use it.) Each prompt is independent; the tool y/N prompts and the
|
|
90
|
+
// ask_user menu run BETWEEN prompts in raw mode too, so nothing overlaps.
|
|
97
91
|
const inputHistory = [];
|
|
98
|
-
const legacyWinConsole = process.platform === "win32" && !process.env.WT_SESSION;
|
|
99
|
-
const useInk =
|
|
100
|
-
!!process.stdin.isTTY &&
|
|
101
|
-
process.env.AETHER_NO_INK !== "1" &&
|
|
102
|
-
(process.env.AETHER_INK === "1" || !legacyWinConsole);
|
|
103
|
-
let inkBroken = false;
|
|
104
|
-
|
|
105
|
-
// The Ink box carries its own status bar; the plain prompt doesn't, so show a
|
|
106
|
-
// one-line hint up front when we won't be using Ink.
|
|
107
|
-
if (!useInk) console.log(` ${c.cyan("/help")}${c.dim(" shortcuts")} ${c.cyan("/exit")}${c.dim(" quit")}\n`);
|
|
108
|
-
|
|
109
|
-
// Fresh readline interface PER PROMPT. A single persistent interface
|
|
110
|
-
// conflicted with the per-confirmation readline interfaces the tools open
|
|
111
|
-
// during a turn (each [y/N] prompt). When a tool's interface closed it left
|
|
112
|
-
// the REPL's stdin dead — so after finishing a request aether printed the
|
|
113
|
-
// prompt and immediately EXITED instead of waiting for the next message.
|
|
114
|
-
// Opening a fresh one each prompt guarantees only one interface exists at a
|
|
115
|
-
// time, so the REPL keeps running until the user /exits. Returns EXIT_SIGNAL
|
|
116
|
-
// on a double Ctrl+C.
|
|
117
|
-
function readlineQuestion() {
|
|
118
|
-
return new Promise((resolve) => {
|
|
119
|
-
const r = readline.createInterface({ input: process.stdin, output: process.stdout, historySize: 200 });
|
|
120
|
-
let lastSigint = 0;
|
|
121
|
-
r.on("SIGINT", () => {
|
|
122
|
-
const now = Date.now();
|
|
123
|
-
if (now - lastSigint < 1500) { r.close(); resolve(EXIT_SIGNAL); return; }
|
|
124
|
-
lastSigint = now;
|
|
125
|
-
process.stdout.write(c.gray(`\n(Press Ctrl+C again within 1.5s to exit, or type ${c.cyan("/exit")})\n`));
|
|
126
|
-
r.prompt();
|
|
127
|
-
});
|
|
128
|
-
r.question(c.magenta("> "), (ans) => { r.close(); resolve(ans); });
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Returns the next raw input line, or EXIT_SIGNAL to quit.
|
|
133
|
-
async function nextLine() {
|
|
134
|
-
if (useInk && !inkBroken) {
|
|
135
|
-
try {
|
|
136
|
-
return await promptBoxed({
|
|
137
|
-
statusLeft: ` ${c.cyan("/help")}${c.dim(" shortcuts")} ${c.cyan("/exit")}${c.dim(" quit")}`,
|
|
138
|
-
statusRight: `${state.autoYes ? "auto-yes" : "review"} · ${MODEL_NAME}`,
|
|
139
|
-
history: inputHistory,
|
|
140
|
-
});
|
|
141
|
-
} catch {
|
|
142
|
-
inkBroken = true;
|
|
143
|
-
console.log(c.gray("(rich input unavailable here — using the basic prompt)"));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return readlineQuestion();
|
|
147
|
-
}
|
|
148
92
|
|
|
149
93
|
while (true) {
|
|
150
|
-
const raw = await
|
|
94
|
+
const raw = await promptBox({ history: inputHistory });
|
|
151
95
|
if (raw === EXIT_SIGNAL) { console.log(c.gray("bye.")); return; }
|
|
152
96
|
const line = (raw ?? "").trim();
|
|
153
97
|
if (!line) continue;
|
|
154
98
|
|
|
155
|
-
//
|
|
156
|
-
// region on unmount). Skip in readline mode — the terminal already echoed it.
|
|
157
|
-
if (useInk && !inkBroken) console.log(c.magenta("> ") + line);
|
|
99
|
+
// promptBox already echoes "› <line>" on submit, so no echo needed here.
|
|
158
100
|
inputHistory.push(line);
|
|
159
101
|
|
|
160
102
|
// Slash command?
|
package/src/tools.js
CHANGED
|
@@ -574,7 +574,12 @@ async function editFile(args, opts) {
|
|
|
574
574
|
return { ok: false, output: "path, find, replace are required" };
|
|
575
575
|
}
|
|
576
576
|
const abs = resolveSafe(args.path, opts);
|
|
577
|
-
if (!fs.existsSync(abs))
|
|
577
|
+
if (!fs.existsSync(abs)) {
|
|
578
|
+
return {
|
|
579
|
+
ok: false,
|
|
580
|
+
output: `File not found: ${args.path}. It doesn't exist yet — use write_file to CREATE it (edit_file only modifies existing files). Do not retry edit_file on this path.`,
|
|
581
|
+
};
|
|
582
|
+
}
|
|
578
583
|
const oldContent = fs.readFileSync(abs, "utf8");
|
|
579
584
|
const occurrences = oldContent.split(args.find).length - 1;
|
|
580
585
|
if (occurrences === 0) {
|