nexo-code 0.1.3 → 0.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/nexo.mjs +17 -13
- package/package.json +1 -1
package/nexo.mjs
CHANGED
|
@@ -14690,7 +14690,7 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
|
14690
14690
|
import { join } from "node:path";
|
|
14691
14691
|
|
|
14692
14692
|
// dist/version.js
|
|
14693
|
-
var VERSION = "0.1.
|
|
14693
|
+
var VERSION = "0.1.4";
|
|
14694
14694
|
|
|
14695
14695
|
// dist/update.js
|
|
14696
14696
|
var PACKAGE = "nexo-code";
|
|
@@ -35896,6 +35896,7 @@ function formatCost(micros2) {
|
|
|
35896
35896
|
const shown = micros2 === 0 ? "0%" : pct < 0.1 ? "under 0.1%" : pct < 10 ? `${pct.toFixed(1)}%` : `${Math.round(pct)}%`;
|
|
35897
35897
|
return `${shown} of your ${shareOf.label}`;
|
|
35898
35898
|
}
|
|
35899
|
+
var tierLabel = (tier) => tier === "strong" ? "Strong" : tier === "cheap" ? "Auto" : tier;
|
|
35899
35900
|
function formatUsd(micros2) {
|
|
35900
35901
|
const dollars = micros2 / 1e6;
|
|
35901
35902
|
return dollars !== 0 && Math.abs(dollars) < 0.01 ? `$${dollars.toFixed(4)}` : `$${dollars.toFixed(2)}`;
|
|
@@ -37271,7 +37272,7 @@ function summaryLine(s, r, opts = {}) {
|
|
|
37271
37272
|
const cached2 = r.tokens.cacheRead + r.tokens.cacheWrite;
|
|
37272
37273
|
const parts = [
|
|
37273
37274
|
...opts.quiet && r.outcome === "done" ? [] : [status],
|
|
37274
|
-
s.accent(r.tier),
|
|
37275
|
+
s.accent(tierLabel(r.tier)),
|
|
37275
37276
|
`${formatTokens(r.tokens.input + cached2)} in${cached2 ? ` (${formatTokens(cached2)} cached)` : ""} / ${formatTokens(r.tokens.output)} out`,
|
|
37276
37277
|
formatCost(r.costMicros),
|
|
37277
37278
|
`${(r.elapsedMs / 1e3).toFixed(1)}s`
|
|
@@ -37505,7 +37506,7 @@ async function runCascade(task2, deps, opts, state = newCascadeState()) {
|
|
|
37505
37506
|
}
|
|
37506
37507
|
const reason = stoppedEarly ? "retry_limit" : "checks_failed";
|
|
37507
37508
|
state.escalated = reason;
|
|
37508
|
-
deps.log(s.accent(`${s.sym.busy}
|
|
37509
|
+
deps.log(s.accent(`${s.sym.busy} switching to the Strong model (${stoppedEarly ? "the first try stopped early and checks fail" : "checks failed"})`));
|
|
37509
37510
|
let second;
|
|
37510
37511
|
try {
|
|
37511
37512
|
second = await attempt(escalationPrompt(task2, first, checks), "strong", reason);
|
|
@@ -37516,7 +37517,7 @@ async function runCascade(task2, deps, opts, state = newCascadeState()) {
|
|
|
37516
37517
|
throw err;
|
|
37517
37518
|
attempts.pop();
|
|
37518
37519
|
state.escalated = null;
|
|
37519
|
-
deps.log(s.warning(`${s.sym.warn} ${err.message} Trying again
|
|
37520
|
+
deps.log(s.warning(`${s.sym.warn} ${err.message} Trying again with Auto and the failure output.`));
|
|
37520
37521
|
second = await attempt(escalationPrompt(task2, first, checks), "cheap");
|
|
37521
37522
|
}
|
|
37522
37523
|
const secondStopped = stoppedAt(second.outcome);
|
|
@@ -37556,7 +37557,7 @@ function cascadeLine(s, r, state) {
|
|
|
37556
37557
|
const testFiles = files.filter((f) => TEST_FILE.test(f));
|
|
37557
37558
|
const label = LABEL[r.outcome];
|
|
37558
37559
|
const status = r.outcome === "passed" || r.outcome === "done_unchecked" ? s.success(`${s.sym.ok} ${label}`) : r.outcome === "failed" || r.outcome === "checks_failed" ? s.error(`${s.sym.fail} ${label}`) : s.warning(`${s.sym.warn} ${label}`);
|
|
37559
|
-
const tiers = ran.map((a) => a.tier).join("\u2192") || r.attempts[0]?.tier
|
|
37560
|
+
const tiers = ran.map((a) => tierLabel(a.tier)).join("\u2192") || tierLabel(r.attempts[0]?.tier ?? "cheap");
|
|
37560
37561
|
const why2 = r.escalated ? ` (escalated: ${r.escalated.replace("_", " ")})` : state?.firstReason ? ` (${state.firstReason.replace("_", " ")})` : "";
|
|
37561
37562
|
const parts = [
|
|
37562
37563
|
status,
|
|
@@ -44807,7 +44808,7 @@ function header(s, opts) {
|
|
|
44807
44808
|
const logo = logoRows(opts);
|
|
44808
44809
|
const text2 = [
|
|
44809
44810
|
`${s.bold("Nexo Code")} ${s.dim(`v${opts.version}`)}`,
|
|
44810
|
-
s.dim(`
|
|
44811
|
+
s.dim(`Auto picks the model ${s.sym.dot} /strong for hard problems ${s.sym.dot} /help`),
|
|
44811
44812
|
s.dim(opts.root),
|
|
44812
44813
|
""
|
|
44813
44814
|
];
|
|
@@ -45260,8 +45261,9 @@ function ttyLineReader(s, color, stdin = process.stdin, out = process.stderr, op
|
|
|
45260
45261
|
}
|
|
45261
45262
|
draw();
|
|
45262
45263
|
};
|
|
45264
|
+
const height = renderBox(s, state, columns(), status, "").lines.length;
|
|
45263
45265
|
out.write(`
|
|
45264
|
-
${CSI}?2004h`);
|
|
45266
|
+
${CSI}?2004h${CSI}999B${height > 1 ? `${CSI}${height - 1}A` : ""}\r`);
|
|
45265
45267
|
out.on?.("resize", draw);
|
|
45266
45268
|
stdin.setRawMode(true);
|
|
45267
45269
|
stdin.resume();
|
|
@@ -45478,7 +45480,7 @@ async function chat(io, opts) {
|
|
|
45478
45480
|
let team = null;
|
|
45479
45481
|
if (!checks.length)
|
|
45480
45482
|
io.err(s.dim(` Tip: add checks to ${PROJECT_FILE} so changes are tested.`));
|
|
45481
|
-
const modelName = () => pinned?.name ?? tier;
|
|
45483
|
+
const modelName = () => pinned?.name ?? tierLabel(tier);
|
|
45482
45484
|
let customStatus = null;
|
|
45483
45485
|
const refreshStatus = async () => {
|
|
45484
45486
|
const command = io.settings?.statusLine;
|
|
@@ -45543,7 +45545,7 @@ async function chat(io, opts) {
|
|
|
45543
45545
|
if (io.settings?.statusLine)
|
|
45544
45546
|
await refreshStatus();
|
|
45545
45547
|
for (; ; ) {
|
|
45546
|
-
const prefix = `${mode === "plan" ? s.warning("plan ") : ""}${pinned ? s.accent(`${pinned.name} `) : tier === "strong" ? s.accent("
|
|
45548
|
+
const prefix = `${mode === "plan" ? s.warning("plan ") : ""}${pinned ? s.accent(`${pinned.name} `) : tier === "strong" ? s.accent("Strong ") : ""}`;
|
|
45547
45549
|
const line2 = await io.readLine(`
|
|
45548
45550
|
${prefix}${s.primary("\u203A")} `, statusLine(), () => {
|
|
45549
45551
|
mode = nextMode(mode);
|
|
@@ -45585,7 +45587,7 @@ ${prefix}${s.primary("\u203A")} `, statusLine(), () => {
|
|
|
45585
45587
|
if (command === "/strong") {
|
|
45586
45588
|
pinned = null;
|
|
45587
45589
|
tier = tier === "strong" ? "cheap" : "strong";
|
|
45588
|
-
io.err(s.dim(`${s.sym.dot}
|
|
45590
|
+
io.err(s.dim(`${s.sym.dot} ${tier === "strong" ? "Using the Strong model (uses more of your plan; /strong again to go back to Auto)" : "Back to Auto: Nexo picks the model"}.`));
|
|
45589
45591
|
continue;
|
|
45590
45592
|
}
|
|
45591
45593
|
if (verb === "/theme" || command === "/vim" || verb === "/statusline") {
|
|
@@ -46153,7 +46155,7 @@ ${answer}` : ""}`
|
|
|
46153
46155
|
if (err instanceof NexoError && err.code === "RATE_LIMITED") {
|
|
46154
46156
|
const quota = (err.retryAfterMs ?? 0) > QUOTA_WAIT_MS;
|
|
46155
46157
|
const wait = err.retryAfterMs ? formatWait(err.retryAfterMs) : "a minute";
|
|
46156
|
-
io.err(s.dim(quota ? `
|
|
46158
|
+
io.err(s.dim(quota ? ` Your ${tier === "strong" ? "Strong model " : ""}limit is used up for ${wait}.${tier === "strong" ? " Type /strong to go back to Auto." : ""}` : ` Wait ${wait} and send your message again.`));
|
|
46157
46159
|
}
|
|
46158
46160
|
if (!(err instanceof NexoError))
|
|
46159
46161
|
throw err;
|
|
@@ -46721,7 +46723,7 @@ async function run2(argv, io) {
|
|
|
46721
46723
|
});
|
|
46722
46724
|
}
|
|
46723
46725
|
if (cmd === "update") {
|
|
46724
|
-
const npm =
|
|
46726
|
+
const npm = process.platform === "win32" ? spawnSync2(`npm.cmd install -g --prefer-online ${PACKAGE}@latest`, { stdio: "inherit", shell: true }) : spawnSync2("npm", ["install", "-g", "--prefer-online", `${PACKAGE}@latest`], { stdio: "inherit" });
|
|
46725
46727
|
if (npm.error) {
|
|
46726
46728
|
io.err(`${io.style.error(io.style.sym.fail)} Could not run npm. Install the update yourself: npm install -g ${PACKAGE}@latest`);
|
|
46727
46729
|
return 1;
|
|
@@ -46742,6 +46744,8 @@ async function run2(argv, io) {
|
|
|
46742
46744
|
}
|
|
46743
46745
|
return remote(io, budget);
|
|
46744
46746
|
}
|
|
46747
|
+
if (cmd === "login" && process.platform === "win32" && true)
|
|
46748
|
+
dropBlockedLauncher();
|
|
46745
46749
|
if (cmd === "login")
|
|
46746
46750
|
return login(io, { ...values["api-url"] ? { apiUrl: values["api-url"] } : {}, ...values.token ? { token: true } : {}, ...values.email ? { email: true } : {} });
|
|
46747
46751
|
if (cmd === "models")
|
|
@@ -46825,7 +46829,7 @@ function dropBlockedLauncher() {
|
|
|
46825
46829
|
const policy = spawnSync2("powershell.exe", ["-NoProfile", "-Command", "Get-ExecutionPolicy"], { encoding: "utf8", windowsHide: true }).stdout.trim();
|
|
46826
46830
|
if (policy !== "Restricted" && policy !== "AllSigned")
|
|
46827
46831
|
return;
|
|
46828
|
-
const prefix = spawnSync2("npm.cmd
|
|
46832
|
+
const prefix = spawnSync2("npm.cmd prefix -g", { encoding: "utf8", shell: true, windowsHide: true }).stdout.trim();
|
|
46829
46833
|
if (prefix)
|
|
46830
46834
|
rmSync(join19(prefix, "nexo.ps1"), { force: true });
|
|
46831
46835
|
} catch {
|