pal-code 0.0.22 → 0.0.23
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/package.json +2 -2
- package/packages/cli/src/index.ts +37 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pal-code",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"description": "A terminal coding agent with BYOK, tool use, and extensions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"gemini"
|
|
67
67
|
],
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@pal-code/core": "0.0.
|
|
69
|
+
"@pal-code/core": "0.0.23",
|
|
70
70
|
"@earendil-works/pi-tui": "^0.85.1",
|
|
71
71
|
"get-east-asian-width": "1.6.0",
|
|
72
72
|
"marked": "^18.1.3"
|
|
@@ -87,6 +87,7 @@ import {
|
|
|
87
87
|
registerModelPricing,
|
|
88
88
|
resolveTurnCost,
|
|
89
89
|
} from './utils/cost.js';
|
|
90
|
+
import {resetProviderSession, DEFAULT_REASONING_EFFORT} from '@pal-code/core';
|
|
90
91
|
import {
|
|
91
92
|
buildOsc22Pointer,
|
|
92
93
|
buildOsc52Sequence,
|
|
@@ -128,6 +129,8 @@ import {
|
|
|
128
129
|
pickCheapModel,
|
|
129
130
|
deriveMessageMeta,
|
|
130
131
|
estimateMessagesTokens,
|
|
132
|
+
fixedPromptTokens,
|
|
133
|
+
estimateToolSchemaTokens,
|
|
131
134
|
restoreSnapshot,
|
|
132
135
|
listSnapshots,
|
|
133
136
|
onAgentEvent,
|
|
@@ -155,7 +158,7 @@ import type {SessionStore as SessionStoreType} from '@pal-code/core';
|
|
|
155
158
|
// (see buildModelOptions). Static curated lists live in @pal-code/core PROVIDERS as fallback.
|
|
156
159
|
|
|
157
160
|
// Version synced from version.json via `node scripts/sync-version.js`.
|
|
158
|
-
const VERSION = '0.0.
|
|
161
|
+
const VERSION = '0.0.23';
|
|
159
162
|
|
|
160
163
|
// ── Canvas sync (OSC 10/11) ──
|
|
161
164
|
// Raw reply payloads captured after a successful startup query + set, or null
|
|
@@ -1367,12 +1370,36 @@ async function main() {
|
|
|
1367
1370
|
// it without hitting the temporal dead zone.
|
|
1368
1371
|
const messages: Message[] = [];
|
|
1369
1372
|
|
|
1373
|
+
/**
|
|
1374
|
+
* Memoised tool-schema token cost. Null until first measured; cleared when the
|
|
1375
|
+
* tool set can change (extension load/reload), since that is what moves it.
|
|
1376
|
+
*/
|
|
1377
|
+
let toolTokensCache: number | null = null;
|
|
1378
|
+
|
|
1379
|
+
/** Invalidate the memoised tool-schema cost after the tool set changes. */
|
|
1380
|
+
function refreshToolTokenEstimate(): void {
|
|
1381
|
+
toolTokensCache = null;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1370
1384
|
function updateStatusLine() {
|
|
1371
|
-
const modelShort = config.model.split('/').pop()?.split(':')[0] ?? config.model;
|
|
1372
|
-
|
|
1385
|
+
const modelShort = config.model.split('/').pop()?.split(':')[0] ?? config.model; const providerName = providerForModel(config.model, Object.keys(allKeys)).provider.name;
|
|
1386
|
+
// Thinking mode sits between the model and the provider: the identity of the
|
|
1387
|
+
// turn is "which model, thinking how hard, on whose endpoint". Shown always
|
|
1388
|
+
// (not only for reasoning models) so the setting is never a guess — that is
|
|
1389
|
+
// the whole point of surfacing it.
|
|
1390
|
+
const effortStr = `${surface.statusLine.dim}·${c.reset}${surface.statusLine.info}${config.reasoningEffort}${c.reset}`;
|
|
1373
1391
|
// Context fill = the CURRENT conversation vs the configured window — not
|
|
1374
1392
|
// lifetime tokens (which never drop after /compact or /new).
|
|
1375
|
-
|
|
1393
|
+
// Charges the FULL prompt: composeSystemPrompt's roles/skills/extension
|
|
1394
|
+
// blocks plus the tool schemas are re-sent every request but were never
|
|
1395
|
+
// counted here, so this was a material undercount (see fixedPromptTokens).
|
|
1396
|
+
// Tool schemas don't change between extension loads, and this runs on every
|
|
1397
|
+
// streaming repaint — so measure once rather than re-serializing ~2k tokens
|
|
1398
|
+
// of JSON per frame. `refreshToolTokenEstimate()` is the invalidation point.
|
|
1399
|
+
toolTokensCache ??= estimateToolSchemaTokens();
|
|
1400
|
+
const ctxTokens =
|
|
1401
|
+
estimateMessagesTokens(messages) +
|
|
1402
|
+
fixedPromptTokens(config.systemPrompt, toolTokensCache);
|
|
1376
1403
|
const contextPct = Math.min(100, Math.round((ctxTokens / config.contextLimit) * 100));
|
|
1377
1404
|
// Background sub-agents (ctrl+b opens the panel).
|
|
1378
1405
|
const running = state.backgroundAgents.filter((a) => a.status === 'running').length;
|
|
@@ -1422,7 +1449,7 @@ async function main() {
|
|
|
1422
1449
|
? ` ${surface.statusLine.warn}Ctrl+C again to quit${c.reset}`
|
|
1423
1450
|
: '';
|
|
1424
1451
|
statusLine.setText(
|
|
1425
|
-
`${modelShort} ${surface.statusLine.dim}${providerName}${agentStr}${subStr}${queuedStr}${abortStr}${exitStr}${c.reset} ${surface.statusLine.dim}/help${c.reset}`,
|
|
1452
|
+
`${modelShort} ${effortStr} ${surface.statusLine.dim}${providerName}${agentStr}${subStr}${queuedStr}${abortStr}${exitStr}${c.reset} ${surface.statusLine.dim}/help${c.reset}`,
|
|
1426
1453
|
);
|
|
1427
1454
|
}
|
|
1428
1455
|
// A copy flash outranks every other status for its 1500ms window, so a
|
|
@@ -2250,6 +2277,7 @@ async function main() {
|
|
|
2250
2277
|
messagesContainer.addChild(
|
|
2251
2278
|
new Text(`${c.green} Extensions reloaded (${toolCount} tools)${c.reset}`, 1, 0),
|
|
2252
2279
|
);
|
|
2280
|
+
refreshToolTokenEstimate();
|
|
2253
2281
|
} else {
|
|
2254
2282
|
// Save session, then spawn a fresh process and exit.
|
|
2255
2283
|
saveSession();
|
|
@@ -2276,6 +2304,9 @@ async function main() {
|
|
|
2276
2304
|
state.currentTodos = [];
|
|
2277
2305
|
state.permissionWhitelist = [];
|
|
2278
2306
|
resetSessionTokenomics();
|
|
2307
|
+
// A new conversation gets a new provider session id, so prompt caching
|
|
2308
|
+
// starts from a clean shard instead of extending the previous one.
|
|
2309
|
+
resetProviderSession();
|
|
2279
2310
|
refreshSidebar();
|
|
2280
2311
|
updateStatusLine();
|
|
2281
2312
|
messagesContainer.addChild(new Text(`${c.yellow}New session started.${c.reset}`, 1, 0));
|
|
@@ -2367,7 +2398,7 @@ async function main() {
|
|
|
2367
2398
|
if (!level || !['low', 'medium', 'high'].includes(level)) {
|
|
2368
2399
|
messagesContainer.addChild(
|
|
2369
2400
|
new Text(
|
|
2370
|
-
`${c.dim}Current reasoning effort: ${c.reset}${c.bold}${config.reasoningEffort}${c.reset}${c.dim}\nUsage: /effort low|medium|high${c.reset}`,
|
|
2401
|
+
`${c.dim}Current reasoning effort: ${c.reset}${c.bold}${config.reasoningEffort}${c.reset}${c.dim}\nUsage: /effort low|medium|high (default: ${DEFAULT_REASONING_EFFORT})${c.reset}`,
|
|
2371
2402
|
1,
|
|
2372
2403
|
0,
|
|
2373
2404
|
),
|