netheriteai-code 1.1.1 → 1.1.4
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/image.png +0 -0
- package/package.json +1 -7
- package/src/cli.js +12 -4
- package/src/tools.js +15 -47
- package/src/tui.js +5 -2
package/image.png
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netheriteai-code",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "NetheriteAI:Code by hurdacu. High-performance coding assistant.",
|
|
5
5
|
"author": "hurdacu",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"files": [
|
|
9
|
-
"bin",
|
|
10
|
-
"src",
|
|
11
|
-
"README.md",
|
|
12
|
-
"package.json"
|
|
13
|
-
],
|
|
14
8
|
"bin": {
|
|
15
9
|
"netheriteai-code": "bin/netheriteai-code.js",
|
|
16
10
|
"netheritecode": "bin/netheriteai-code.js",
|
package/src/cli.js
CHANGED
|
@@ -11,10 +11,19 @@ import { printTable, resolveWorkspaceRoot } from "./utils.js";
|
|
|
11
11
|
|
|
12
12
|
const execFileAsync = promisify(execFile);
|
|
13
13
|
|
|
14
|
-
const VERSION = "1.1.
|
|
14
|
+
const VERSION = "1.1.4";
|
|
15
|
+
|
|
16
|
+
function isNewer(latest, current) {
|
|
17
|
+
const l = String(latest || "0.0.0").split(".").map(Number);
|
|
18
|
+
const c = String(current || "0.0.0").split(".").map(Number);
|
|
19
|
+
for (let i = 0; i < 3; i++) {
|
|
20
|
+
if (l[i] > (c[i] || 0)) return true;
|
|
21
|
+
if (l[i] < (c[i] || 0)) return false;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
15
25
|
|
|
16
26
|
async function handleAutoUpdate() {
|
|
17
|
-
// If we were just restarted by an update, don't check again
|
|
18
27
|
if (process.argv.includes("--no-update")) return;
|
|
19
28
|
|
|
20
29
|
try {
|
|
@@ -24,7 +33,7 @@ async function handleAutoUpdate() {
|
|
|
24
33
|
timeout: 3000,
|
|
25
34
|
}).trim();
|
|
26
35
|
|
|
27
|
-
if (latest && latest
|
|
36
|
+
if (latest && isNewer(latest, VERSION)) {
|
|
28
37
|
const cols = process.stdout.columns || 80;
|
|
29
38
|
const rows = process.stdout.rows || 24;
|
|
30
39
|
const msg = "Updating NetheriteAI:Code...";
|
|
@@ -55,7 +64,6 @@ async function handleAutoUpdate() {
|
|
|
55
64
|
process.stdout.write(`\u001b[${y};${dx}H\u001b[1m${doneMsg}\u001b[0m`);
|
|
56
65
|
process.stdout.write("\u001b[?1049l");
|
|
57
66
|
|
|
58
|
-
// Pass the skip flag to the restarted process to prevent looping
|
|
59
67
|
spawn(process.argv[0], [...process.argv.slice(1), "--no-update"], { stdio: "inherit", detached: false });
|
|
60
68
|
process.exit(0);
|
|
61
69
|
}
|
package/src/tools.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from "./utils.js";
|
|
14
14
|
|
|
15
15
|
const activeProcesses = new Map();
|
|
16
|
+
const isWin = process.platform === "win32";
|
|
16
17
|
|
|
17
18
|
function todoFile(root) {
|
|
18
19
|
return path.join(root, ".netherite", "todos.json");
|
|
@@ -170,16 +171,20 @@ export function getToolDefinitions() {
|
|
|
170
171
|
|
|
171
172
|
function listRecursive(root, basePath) {
|
|
172
173
|
const entries = [];
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
174
|
+
try {
|
|
175
|
+
for (const entry of fs.readdirSync(basePath)) {
|
|
176
|
+
const absolute = path.join(basePath, entry);
|
|
177
|
+
const rel = relativeToRoot(root, absolute);
|
|
178
|
+
entries.push({
|
|
179
|
+
path: rel,
|
|
180
|
+
...statEntry(absolute),
|
|
181
|
+
});
|
|
182
|
+
if (fs.statSync(absolute).isDirectory()) {
|
|
183
|
+
entries.push(...listRecursive(root, absolute));
|
|
184
|
+
}
|
|
182
185
|
}
|
|
186
|
+
} catch {
|
|
187
|
+
// Ignore errors in list
|
|
183
188
|
}
|
|
184
189
|
return entries;
|
|
185
190
|
}
|
|
@@ -200,6 +205,7 @@ async function runSpawnedCommand(root, command, args = [], hooks = {}) {
|
|
|
200
205
|
const child = spawn(command, args, {
|
|
201
206
|
cwd: root,
|
|
202
207
|
stdio: ["pipe", "pipe", "pipe"],
|
|
208
|
+
shell: isWin,
|
|
203
209
|
});
|
|
204
210
|
|
|
205
211
|
const p = { child, stdout: "", stderr: "" };
|
|
@@ -293,17 +299,6 @@ export async function executeToolCall(root, toolCall, hooks = {}) {
|
|
|
293
299
|
const content = fs.readFileSync(target, "utf8");
|
|
294
300
|
return { path: args.path, content: clampText(content, 24000) };
|
|
295
301
|
}
|
|
296
|
-
case "create_file": {
|
|
297
|
-
const target = toAbsoluteInsideRoot(root, args.path);
|
|
298
|
-
if (fs.existsSync(target)) {
|
|
299
|
-
throw new Error(`File already exists: ${args.path}`);
|
|
300
|
-
}
|
|
301
|
-
ensureDir(path.dirname(target));
|
|
302
|
-
hooks.onProgress?.({ stream: "preview", text: `Creating ${args.path}\n` });
|
|
303
|
-
await streamFilePreview(args.content, hooks);
|
|
304
|
-
fs.writeFileSync(target, args.content, "utf8");
|
|
305
|
-
return { ok: true, path: args.path, bytesWritten: Buffer.byteLength(args.content, "utf8"), created: true };
|
|
306
|
-
}
|
|
307
302
|
case "write_file": {
|
|
308
303
|
const target = toAbsoluteInsideRoot(root, args.path);
|
|
309
304
|
ensureDir(path.dirname(target));
|
|
@@ -312,14 +307,6 @@ export async function executeToolCall(root, toolCall, hooks = {}) {
|
|
|
312
307
|
fs.writeFileSync(target, args.content, "utf8");
|
|
313
308
|
return { ok: true, path: args.path, bytesWritten: Buffer.byteLength(args.content, "utf8") };
|
|
314
309
|
}
|
|
315
|
-
case "append_file": {
|
|
316
|
-
const target = toAbsoluteInsideRoot(root, args.path);
|
|
317
|
-
ensureDir(path.dirname(target));
|
|
318
|
-
hooks.onProgress?.({ stream: "preview", text: `Appending ${args.path}\n` });
|
|
319
|
-
await streamFilePreview(args.content, hooks);
|
|
320
|
-
fs.appendFileSync(target, args.content, "utf8");
|
|
321
|
-
return { ok: true, path: args.path, bytesWritten: Buffer.byteLength(args.content, "utf8"), appended: true };
|
|
322
|
-
}
|
|
323
310
|
case "edit_file": {
|
|
324
311
|
const target = toAbsoluteInsideRoot(root, args.path);
|
|
325
312
|
const original = fs.readFileSync(target, "utf8");
|
|
@@ -396,19 +383,6 @@ export async function executeToolCall(root, toolCall, hooks = {}) {
|
|
|
396
383
|
}
|
|
397
384
|
return await runOneCommand(root, args.command, args.args || [], hooks);
|
|
398
385
|
}
|
|
399
|
-
case "batch_command": {
|
|
400
|
-
const results = [];
|
|
401
|
-
for (const command of args.commands || []) {
|
|
402
|
-
if (command.commandLine) {
|
|
403
|
-
hooks.onProgress?.({ stream: "stdout", text: `$ ${command.commandLine}\n` });
|
|
404
|
-
results.push(await runShellLine(root, command.commandLine, hooks));
|
|
405
|
-
} else {
|
|
406
|
-
hooks.onProgress?.({ stream: "stdout", text: `$ ${[command.command, ...(command.args || [])].filter(Boolean).join(" ")}\n` });
|
|
407
|
-
results.push(await runOneCommand(root, command.command, command.args || [], hooks));
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return { results };
|
|
411
|
-
}
|
|
412
386
|
case "todo_create": {
|
|
413
387
|
const todos = loadTodos(root);
|
|
414
388
|
const next = {
|
|
@@ -439,9 +413,3 @@ export async function executeToolCall(root, toolCall, hooks = {}) {
|
|
|
439
413
|
throw new Error(`Unknown tool: ${name}`);
|
|
440
414
|
}
|
|
441
415
|
}
|
|
442
|
-
odo;
|
|
443
|
-
}
|
|
444
|
-
default:
|
|
445
|
-
throw new Error(`Unknown tool: ${name}`);
|
|
446
|
-
}
|
|
447
|
-
}
|
package/src/tui.js
CHANGED
|
@@ -495,8 +495,11 @@ export function runTui({
|
|
|
495
495
|
onSubmit,
|
|
496
496
|
}) {
|
|
497
497
|
return new Promise((resolve) => {
|
|
498
|
-
|
|
499
|
-
|
|
498
|
+
try {
|
|
499
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
500
|
+
} catch {
|
|
501
|
+
// Ignore EIO or other TTY errors
|
|
502
|
+
}
|
|
500
503
|
process.stdout.write("\u001b[?1049h\u001b[?25l\u001b[?1000h\u001b[?1006h\u001b[?7l\u001b[2J");
|
|
501
504
|
setTerminalTitle("NetheriteAI:Code by hurdacu");
|
|
502
505
|
|