@tiens.nguyen/gu-cli 1.0.782 → 1.0.784
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/client-expert-run.mjs +2 -2
- package/gu-cli.mjs +9 -3
- package/gu-repl.mjs +504 -250
- package/model-prices.mjs +484 -0
- package/package.json +2 -1
- package/preset-apply.mjs +2 -2
- package/preset-editor.mjs +90 -12
- package/presets-transfer.mjs +5 -5
- package/step-tokens.mjs +45 -0
- package/terminal-layout.mjs +14 -0
- package/terminal-viewport.mjs +65 -0
- package/turn-stop.mjs +17 -0
package/client-expert-run.mjs
CHANGED
|
@@ -1111,7 +1111,7 @@ export async function runClientExpertSetup({
|
|
|
1111
1111
|
console.log("");
|
|
1112
1112
|
console.log(" " + cyan("✓ Model setup skipped") + dim(loadPreset
|
|
1113
1113
|
? " — the preset picker opens as soon as gu starts"
|
|
1114
|
-
: " — set them any time with /model (or /
|
|
1114
|
+
: " — set them any time with /model (or /use-presets)"));
|
|
1115
1115
|
} else if (Object.keys(written).length === 0) {
|
|
1116
1116
|
console.log(" " + cyan("✓ Models and RAG") + dim(" — already configured, left alone"));
|
|
1117
1117
|
} else {
|
|
@@ -1159,7 +1159,7 @@ export async function runClientExpertSetup({
|
|
|
1159
1159
|
dim("\n machine. The API restarts with `gu-cli api start`; its log is") +
|
|
1160
1160
|
dim(`\n ${API_LOG_FILE}\n`)
|
|
1161
1161
|
);
|
|
1162
|
-
// #301: the caller opens /
|
|
1162
|
+
// #301: the caller opens /use-presets once the terminal exists — the picker, the plan and the
|
|
1163
1163
|
// confirmation are that command's, not rebuilt here.
|
|
1164
1164
|
return { complete: true, stoppedAt: null, ...(loadPreset ? { loadPreset: true } : {}) };
|
|
1165
1165
|
}
|
package/gu-cli.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import { execFile as execFileCallback, spawn } from "node:child_process";
|
|
|
20
20
|
import { createHash, randomUUID } from "node:crypto";
|
|
21
21
|
import { writeFileSync, unlinkSync } from "node:fs";
|
|
22
22
|
import { createTaskPool, createFolderQueue } from "./job-pools.mjs";
|
|
23
|
-
import { NO_STEP, foldStepTokens, withStepTokens } from "./step-tokens.mjs";
|
|
23
|
+
import { NO_STEP, foldStepTokens, withStepTokens, NO_CACHE, foldTurnCache, withTurnCache } from "./step-tokens.mjs";
|
|
24
24
|
import { agentStoppedLine, jobEnded, jobStatusFrom409, stopGracefully } from "./agent-stop.mjs";
|
|
25
25
|
import { ragJobConfig } from "./rag-job-config.mjs";
|
|
26
26
|
import { codingKeyFallbackLine, isOllamaCloudUrl } from "./coding-key-prompt.mjs";
|
|
@@ -4138,6 +4138,9 @@ async function runAgentChatJob(job) {
|
|
|
4138
4138
|
// Task #298: the CURRENT model call's own ↑ in / ↓ out, for the thinking line (the bar
|
|
4139
4139
|
// already shows the totals). Rides on the breakdown — see step-tokens.mjs.
|
|
4140
4140
|
let stepTokens = NO_STEP;
|
|
4141
|
+
// #323: the turn's cached prompt tokens (when the provider reports them) and its first step's
|
|
4142
|
+
// prompt — what the terminal needs to say what the turn COST. Rides on the breakdown too.
|
|
4143
|
+
let turnCache = NO_CACHE;
|
|
4141
4144
|
// Raw model-stream tokens (event.type === "stream") are Python code + `Thought:`
|
|
4142
4145
|
// prose + <code>/<|"|> fragments. The web Thought panel renders reasoning as
|
|
4143
4146
|
// markdown, which turns `#`-prefixed code comments into <h1> headings and
|
|
@@ -4305,17 +4308,20 @@ async function runAgentChatJob(job) {
|
|
|
4305
4308
|
if (breakdown) latestPromptBreakdown = breakdown;
|
|
4306
4309
|
const prevStep = stepTokens;
|
|
4307
4310
|
stepTokens = foldStepTokens(stepTokens, event);
|
|
4311
|
+
const prevCache = turnCache;
|
|
4312
|
+
turnCache = foldTurnCache(turnCache, event);
|
|
4313
|
+
const cacheChanged = turnCache.cached !== prevCache.cached || turnCache.firstIn !== prevCache.firstIn || turnCache.cacheReported !== prevCache.cacheReported;
|
|
4308
4314
|
const stepChanged =
|
|
4309
4315
|
stepTokens.step !== prevStep.step ||
|
|
4310
4316
|
stepTokens.stepIn !== prevStep.stepIn ||
|
|
4311
4317
|
stepTokens.stepOut !== prevStep.stepOut;
|
|
4312
|
-
if (latestPromptBreakdown) latestPromptBreakdown = withStepTokens(latestPromptBreakdown, stepTokens);
|
|
4318
|
+
if (latestPromptBreakdown) latestPromptBreakdown = withTurnCache(withStepTokens(latestPromptBreakdown, stepTokens), turnCache);
|
|
4313
4319
|
if (
|
|
4314
4320
|
nextTotal !== latestCodeTokens ||
|
|
4315
4321
|
nextMax !== latestMaxCodeTokens ||
|
|
4316
4322
|
nextOut !== latestCodeOutputTokens ||
|
|
4317
4323
|
breakdown ||
|
|
4318
|
-
(stepChanged && latestPromptBreakdown)
|
|
4324
|
+
((stepChanged || cacheChanged) && latestPromptBreakdown)
|
|
4319
4325
|
) {
|
|
4320
4326
|
latestCodeTokens = nextTotal;
|
|
4321
4327
|
latestMaxCodeTokens = nextMax;
|