@oriro/orirocli 0.3.1 → 0.3.2
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 +58 -2
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -6363,6 +6363,46 @@ function handleArtifactSlash(raw) {
|
|
|
6363
6363
|
return lines;
|
|
6364
6364
|
}
|
|
6365
6365
|
|
|
6366
|
+
// src/repl-ui/slash-compact.ts
|
|
6367
|
+
function isCompactSlash(cmd) {
|
|
6368
|
+
return /^\/compact(\s|$)/i.test(cmd.trim());
|
|
6369
|
+
}
|
|
6370
|
+
function compactInstructions(cmd) {
|
|
6371
|
+
const rest = cmd.trim().replace(/^\/compact\s*/i, "").trim();
|
|
6372
|
+
return rest.length ? rest : void 0;
|
|
6373
|
+
}
|
|
6374
|
+
function formatCompactionResult(result) {
|
|
6375
|
+
const before = result.tokensBefore;
|
|
6376
|
+
const after = result.estimatedTokensAfter;
|
|
6377
|
+
const lines = [];
|
|
6378
|
+
if (typeof after === "number" && before > 0) {
|
|
6379
|
+
const freed = Math.max(0, before - after);
|
|
6380
|
+
const pct = Math.round(freed / before * 100);
|
|
6381
|
+
lines.push(
|
|
6382
|
+
` ${fgHex(PALETTE.success, "\u2713 compacted")} ${dim(`${before.toLocaleString()} \u2192 ${after.toLocaleString()} tokens`)} ${accent(`(${pct}% freed)`)}`
|
|
6383
|
+
);
|
|
6384
|
+
} else {
|
|
6385
|
+
lines.push(` ${fgHex(PALETTE.success, "\u2713 compacted")} ${dim(`${before.toLocaleString()} tokens summarized`)}`);
|
|
6386
|
+
}
|
|
6387
|
+
lines.push(dim(" history summarized; the summary is kept, raw turns dropped. Keep going."));
|
|
6388
|
+
return lines;
|
|
6389
|
+
}
|
|
6390
|
+
async function handleCompact(session, cmd) {
|
|
6391
|
+
if (session.isCompacting) {
|
|
6392
|
+
return [dim(" compaction already in progress \u2014 hold on\u2026")];
|
|
6393
|
+
}
|
|
6394
|
+
if (session.messages.length < 4) {
|
|
6395
|
+
return [dim(" not much to compact yet \u2014 keep chatting, then /compact frees context.")];
|
|
6396
|
+
}
|
|
6397
|
+
try {
|
|
6398
|
+
const result = await session.compact(compactInstructions(cmd));
|
|
6399
|
+
if (!result) return [dim(" nothing to compact right now.")];
|
|
6400
|
+
return formatCompactionResult(result);
|
|
6401
|
+
} catch (e) {
|
|
6402
|
+
return [` ${fgHex(PALETTE.error, "compaction failed")}: ${dim(e instanceof Error ? e.message : String(e))}`];
|
|
6403
|
+
}
|
|
6404
|
+
}
|
|
6405
|
+
|
|
6366
6406
|
// src/repl-ui/tui-repl.ts
|
|
6367
6407
|
var editorTheme = {
|
|
6368
6408
|
borderColor: (s) => dim(s),
|
|
@@ -6444,7 +6484,7 @@ async function runTuiRepl(session) {
|
|
|
6444
6484
|
if (slash === "/help" || slash === "/?") {
|
|
6445
6485
|
const help = [
|
|
6446
6486
|
" Just type to chat \u2014 ORIRO writes and runs code for you (keyless, free).",
|
|
6447
|
-
` ${accent("/routers")} pool add\xB7rotate ${accent("/model")} <id\u2026> switch ${accent("/usage")} health ${accent("/trace")} tool+router activity`,
|
|
6487
|
+
` ${accent("/routers")} pool add\xB7rotate ${accent("/model")} <id\u2026> switch ${accent("/usage")} health ${accent("/trace")} tool+router activity ${accent("/compact")} free context`,
|
|
6448
6488
|
` ${accent("/review")} artifacts from the last reply ${accent("/save")} <n> [path] ${accent("/skills")} ${accent("/connectors")} ${accent("/voice")}`,
|
|
6449
6489
|
` ${dim("Shift+Tab")} posture ${dim("Alt+Shift+T")} thinking ${accent("/help")} ${accent("/exit")}`
|
|
6450
6490
|
].join("\n");
|
|
@@ -6496,6 +6536,18 @@ async function runTuiRepl(session) {
|
|
|
6496
6536
|
tui.requestRender();
|
|
6497
6537
|
return;
|
|
6498
6538
|
}
|
|
6539
|
+
if (isCompactSlash(slash)) {
|
|
6540
|
+
editor.setText("");
|
|
6541
|
+
const pending = new Text(dim(" compacting\u2026"), 0, 0);
|
|
6542
|
+
chat.addChild(pending);
|
|
6543
|
+
tui.requestRender();
|
|
6544
|
+
void (async () => {
|
|
6545
|
+
const lines = await handleCompact(session, text);
|
|
6546
|
+
pending.setText(lines.join("\n"));
|
|
6547
|
+
tui.requestRender();
|
|
6548
|
+
})();
|
|
6549
|
+
return;
|
|
6550
|
+
}
|
|
6499
6551
|
if (slash === "/voice") {
|
|
6500
6552
|
editor.setText("");
|
|
6501
6553
|
const status = new Text(dim(" \u{1F399} listening\u2026 (needs ffmpeg + the transformers voice peer)"), 0, 0);
|
|
@@ -6679,7 +6731,7 @@ function replHelp() {
|
|
|
6679
6731
|
${dim("Just type to chat; ORIRO writes and runs code for you (keyless, free).")}
|
|
6680
6732
|
|
|
6681
6733
|
${dim("Models & routers")} ${accent("/routers")} list\xB7add\xB7rotate the racing pool ${accent("/model")} <id\u2026> switch
|
|
6682
|
-
${dim("This session")} ${accent("/usage")} pool health & turns ${accent("/trace")} show tool + router activity
|
|
6734
|
+
${dim("This session")} ${accent("/usage")} pool health & turns ${accent("/trace")} show tool + router activity ${accent("/compact")} free context
|
|
6683
6735
|
${dim("Artifacts")} ${accent("/review")} code/SVG from the last reply ${accent("/save")} <n> [path] write one
|
|
6684
6736
|
${dim("Capabilities")} ${accent("/skills")} ${accent("/connectors")} ${accent("/voice")} speak a turn
|
|
6685
6737
|
${dim("General")} ${accent("/help")} this ${accent("/exit")} / ${accent("/quit")} leave ${dim("(Ctrl-D / Ctrl-C also exit)")}
|
|
@@ -6756,6 +6808,10 @@ async function runReadlineRepl(session) {
|
|
|
6756
6808
|
`);
|
|
6757
6809
|
continue;
|
|
6758
6810
|
}
|
|
6811
|
+
if (isCompactSlash(slash)) {
|
|
6812
|
+
stdout7.write((await handleCompact(session, line)).join("\n") + "\n");
|
|
6813
|
+
continue;
|
|
6814
|
+
}
|
|
6759
6815
|
if (isArtifactSlash(slash)) {
|
|
6760
6816
|
stdout7.write(handleArtifactSlash(line).join("\n") + "\n");
|
|
6761
6817
|
continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oriro/orirocli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "ORIRO — a free, on-device-friendly terminal AI agent. Built on the Pi agent harness (used as a library).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dev": "tsx src/cli.ts",
|
|
24
24
|
"build": "tsup",
|
|
25
25
|
"typecheck": "tsc --noEmit",
|
|
26
|
-
"test:unit": "tsx scripts/test-tool-sanitize.ts && tsx scripts/test-guardian.ts && tsx scripts/test-scribe.ts && tsx scripts/test-race.ts && tsx scripts/test-weights.ts && tsx scripts/test-output.ts && tsx scripts/test-connectors.ts && tsx scripts/test-artifacts.ts && tsx scripts/test-project-md.ts",
|
|
26
|
+
"test:unit": "tsx scripts/test-tool-sanitize.ts && tsx scripts/test-guardian.ts && tsx scripts/test-scribe.ts && tsx scripts/test-race.ts && tsx scripts/test-weights.ts && tsx scripts/test-output.ts && tsx scripts/test-connectors.ts && tsx scripts/test-artifacts.ts && tsx scripts/test-project-md.ts && tsx scripts/test-compact.ts",
|
|
27
27
|
"smoke": "npm run build && node scripts/smoke.mjs",
|
|
28
28
|
"prepublishOnly": "npm run build && npm run test:unit && node scripts/smoke.mjs && node scripts/prepublish-check.mjs",
|
|
29
29
|
"start": "node dist/cli.js"
|