pantheon-opencode 1.6.2-beta.1 → 1.6.2-beta.10
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/CHANGELOG.md +163 -0
- package/README.md +236 -60
- package/README.pt-BR.md +19 -1
- package/bin/pantheon-init.mjs +195 -13
- package/package.json +11 -3
- package/plugin.json +1 -1
- package/prompts/README.md +58 -0
- package/prompts/debug-issue.prompt.md +46 -0
- package/prompts/dynamic/agora-generated.txt +38 -0
- package/prompts/dynamic/orchestrate-generated.txt +51 -0
- package/prompts/focus.prompt.md +42 -0
- package/prompts/implement-feature.prompt.md +39 -0
- package/prompts/optimize-database.prompt.md +58 -0
- package/prompts/orchestrate-with-zeus.prompt.md +441 -0
- package/prompts/plan-architecture.prompt.md +59 -0
- package/prompts/quick-discovery-large-codebase.prompt.md +294 -0
- package/prompts/quick-plan-large-feature.prompt.md +197 -0
- package/prompts/semantic-summarize.md +50 -0
- package/prompts/sketch.prompt.md +91 -0
- package/prompts/subtask.prompt.md +131 -0
- package/pyproject.toml +1 -1
- package/scripts/decision-router-budget.mjs +780 -0
- package/scripts/decision-router-v2-budget.mjs +218 -0
- package/scripts/decision-router-v2-egress.mjs +272 -0
- package/scripts/decision-router.mjs +758 -0
- package/scripts/docs-check-changelog.mjs +5 -3
- package/scripts/install/component-selection.mjs +9 -4
- package/scripts/install/decision-layer-preview.mjs +376 -0
- package/scripts/install/decision-router-config.mjs +560 -0
- package/scripts/install/health-check.mjs +20 -11
- package/scripts/install/interactive.mjs +103 -14
- package/scripts/install/interrupt.mjs +4 -3
- package/scripts/install/migrate.mjs +123 -72
- package/scripts/install/opencode.mjs +178 -122
- package/scripts/install/plan.mjs +8 -1
- package/scripts/install/plugin.mjs +4 -3
- package/scripts/install/state.mjs +12 -0
- package/scripts/install/strings.mjs +22 -0
- package/scripts/install/venv.mjs +34 -17
- package/scripts/mcp_resources.py +11 -9
- package/scripts/release-notes.mjs +30 -7
- package/scripts/restore.mjs +22 -10
- package/scripts/sync-tui.mjs +3 -3
- package/scripts/test-opencode-v2-sandbox.sh +10 -6
- package/scripts/versioning.mjs +41 -5
- package/src/agents/aphrodite.md +6 -1
- package/src/agents/apollo.md +1 -0
- package/src/agents/athena.md +1 -0
- package/src/agents/demeter.md +1 -1
- package/src/agents/gaia.md +1 -0
- package/src/agents/hephaestus.md +1 -1
- package/src/agents/hermes.md +8 -10
- package/src/agents/iris.md +1 -1
- package/src/agents/mnemosyne.md +1 -0
- package/src/agents/nyx.md +1 -1
- package/src/agents/prometheus.md +1 -1
- package/src/agents/talos.md +6 -1
- package/src/agents/themis.md +1 -1
- package/src/agents/zeus.md +52 -62
- package/src/mcp/eval_store.py +11 -4
- package/src/mcp/mcp_resources.py +11 -9
- package/src/mcp/memory_mcp.py +293 -150
- package/src/pantheon/cost-command.ts +30 -133
- package/src/pantheon/jev-decision-tool.ts +347 -0
- package/src/pantheon/jev-decisions.ts +625 -0
- package/src/pantheon/local-decision-agents.ts +170 -0
- package/src/pantheon/local-decision-budget.ts +1046 -0
- package/src/pantheon/local-decision-egress-gate.ts +144 -0
- package/src/pantheon/local-decision-prompt.ts +256 -0
- package/src/pantheon/local-decision-provider-matrix.ts +44 -0
- package/src/pantheon/local-decision-router.ts +225 -0
- package/src/pantheon/local-decision-skills.ts +281 -0
- package/src/pantheon/local-decision-tool.ts +160 -0
- package/src/pantheon/local-decision-turn.ts +101 -0
- package/src/pantheon/local-decision-usage-evidence.internal.ts +168 -0
- package/src/pantheon/local-orchestration.ts +322 -0
- package/src/pantheon/model-pricing.ts +1 -536
- package/src/pantheon/pantheon-decision-catalog.ts +101 -0
- package/src/pantheon/v2-decision-budget.ts +456 -0
- package/src/pantheon/v2-decision-contracts.ts +300 -0
- package/src/pantheon/v2-decision-egress.ts +203 -0
- package/src/pantheon/v2-decision-events.ts +180 -0
- package/src/pantheon/v2-decision-heuristic.ts +121 -0
- package/src/pantheon/v2-decision-points/p1-agent.ts +91 -0
- package/src/pantheon/v2-decision-points/p10-claims.ts +243 -0
- package/src/pantheon/v2-decision-points/p11-catalog.ts +220 -0
- package/src/pantheon/v2-decision-points/p2-skill.ts +83 -0
- package/src/pantheon/v2-decision-points/p3-complexity.ts +108 -0
- package/src/pantheon/v2-decision-points/p4-memory.ts +137 -0
- package/src/pantheon/v2-decision-points/p5-themis-verify.ts +190 -0
- package/src/pantheon/v2-decision-points/p6-council.ts +161 -0
- package/src/pantheon/v2-decision-points/p7-loop.ts +263 -0
- package/src/pantheon/v2-decision-points/p8-guardrail.ts +367 -0
- package/src/pantheon/v2-decision-points/p9-memory-compaction.ts +304 -0
- package/src/pantheon/v2-decision-points.ts +242 -0
- package/src/pantheon/v2-decision-policy.ts +166 -0
- package/src/pantheon/v2-decision-premises.ts +146 -0
- package/src/pantheon/v2-decision-prompt-surface.ts +115 -0
- package/src/pantheon/v2-decision-rank.ts +91 -0
- package/src/pantheon/v2-decision-registry.ts +391 -0
- package/src/pantheon/v2-decision-resource-ids.ts +127 -0
- package/src/pantheon/v2-decision-shadow.ts +123 -0
- package/src/pantheon/v2-decision-telemetry.ts +214 -0
- package/src/pantheon/v2-decision-verify.ts +51 -0
- package/src/pantheon/v2-hook-engine.ts +307 -0
- package/src/pantheon/v2-native-decisions.ts +365 -0
- package/src/pantheon/v2-shell-hooks.ts +66 -2
- package/src/pantheon/v2-tools.ts +38 -15
- package/src/plugin-v2.ts +419 -26
- package/src/plugin.ts +4 -0
- package/src/plugins/tui/THIRD_PARTY_NOTICES.md +24 -0
- package/src/plugins/tui/dist/server-v2.d.ts +19 -11
- package/src/plugins/tui/dist/server-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/server-v2.js +19 -666
- package/src/plugins/tui/dist/server-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui-v2.d.ts +11 -203
- package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui-v2.js +187 -1917
- package/src/plugins/tui/dist/tui-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui.js +1 -1
- package/src/plugins/tui/package-lock.json +17 -2
- package/src/plugins/tui/package.json +4 -2
- package/src/plugins/tui/src/cost-data.ts +607 -0
- package/src/plugins/tui/src/index-v2.tsx +213 -54
- package/src/plugins/tui/src/model-pricing.ts +536 -0
- package/src/plugins/tui/src/server-v2.ts +18 -838
- package/src/plugins/tui/tsdown.config.ts +28 -6
- package/src/plugins/tui/dist/quota-adapters.d.ts +0 -89
- package/src/plugins/tui/dist/quota-adapters.d.ts.map +0 -1
- package/src/plugins/tui/dist/quota-adapters.js +0 -1142
- package/src/plugins/tui/dist/quota-adapters.js.map +0 -1
- package/src/plugins/tui/dist/quota-cli.d.ts +0 -17
- package/src/plugins/tui/dist/quota-cli.d.ts.map +0 -1
- package/src/plugins/tui/dist/quota-cli.js +0 -184
- package/src/plugins/tui/dist/quota-cli.js.map +0 -1
- package/src/plugins/tui/dist/quota-rpc-UL2HuFRJ.js +0 -390
- package/src/plugins/tui/dist/quota-rpc-UL2HuFRJ.js.map +0 -1
- package/src/plugins/tui/src/go-key-diagnostic-ui.ts +0 -100
- package/src/plugins/tui/src/go-key-diagnostic.ts +0 -125
- package/src/plugins/tui/src/quota-adapters.ts +0 -1598
- package/src/plugins/tui/src/quota-cli.ts +0 -237
- package/src/plugins/tui/src/quota-rpc.ts +0 -209
- package/src/plugins/tui/src/quota-v2-model.ts +0 -1032
- package/src/plugins/tui/src/quota-v2.tsx +0 -986
|
@@ -23,13 +23,6 @@ import {
|
|
|
23
23
|
MODEL_USAGE_SESSION_LIMIT,
|
|
24
24
|
MODEL_USAGE_VISIBLE_CEILING,
|
|
25
25
|
} from './model-usage-limits'
|
|
26
|
-
import { QuotaSidebarSummary, quotaTextLines, registerQuotaTui } from './quota-v2'
|
|
27
|
-
import {
|
|
28
|
-
createQuotaRuntime,
|
|
29
|
-
type QuotaRuntime,
|
|
30
|
-
resolveActiveModelRef,
|
|
31
|
-
resolveModelContextSnapshot,
|
|
32
|
-
} from './quota-v2-model'
|
|
33
26
|
import { cellWidth, GRAPHEMES, SIDEBAR_CONTENT_WIDTH } from './sidebar-width'
|
|
34
27
|
|
|
35
28
|
export type { ContextProgressTone } from './context-gauge'
|
|
@@ -44,48 +37,12 @@ export {
|
|
|
44
37
|
formatSpent,
|
|
45
38
|
formatTokenCount,
|
|
46
39
|
} from './context-gauge'
|
|
47
|
-
export { quotaGoCheckCommand } from './go-key-diagnostic-ui'
|
|
48
40
|
export {
|
|
49
41
|
MODEL_USAGE_MESSAGE_LIMIT,
|
|
50
42
|
MODEL_USAGE_SESSION_LIMIT,
|
|
51
43
|
MODEL_USAGE_VISIBLE_CEILING,
|
|
52
44
|
} from './model-usage-limits'
|
|
53
|
-
export {
|
|
54
|
-
financeMetricLines,
|
|
55
|
-
openQuotaPanel,
|
|
56
|
-
QUOTA_ICON,
|
|
57
|
-
QUOTA_OPEN_COMMAND_ID,
|
|
58
|
-
QUOTA_PANEL_COMMANDS,
|
|
59
|
-
QUOTA_PANEL_NAME,
|
|
60
|
-
quotaMetricLines,
|
|
61
|
-
quotaOpenCommand,
|
|
62
|
-
quotaPanelKeymapLayer,
|
|
63
|
-
quotaTextLines,
|
|
64
|
-
quotaUsageTone,
|
|
65
|
-
quotaWindowLines,
|
|
66
|
-
runQuotaPanelCommand,
|
|
67
|
-
sidebarFinanceEntries,
|
|
68
|
-
snapshotSummary,
|
|
69
|
-
} from './quota-v2'
|
|
70
|
-
export type { QuotaSidebarEntry } from './quota-v2-model'
|
|
71
|
-
export {
|
|
72
|
-
collectRecentModelUsageRows,
|
|
73
|
-
compactQuotaMetric,
|
|
74
|
-
createQuotaClock,
|
|
75
|
-
createQuotaRuntime,
|
|
76
|
-
DEFAULT_QUOTA_PREFERENCES,
|
|
77
|
-
formatQuotaCountdown,
|
|
78
|
-
formatQuotaMetric,
|
|
79
|
-
normalizeQuotaPreferences,
|
|
80
|
-
QUOTA_CLOCK_INTERVAL_MS,
|
|
81
|
-
quotaClock,
|
|
82
|
-
quotaProgress,
|
|
83
|
-
quotaSidebarEntries,
|
|
84
|
-
quotaSnapshotFromStatus,
|
|
85
|
-
quotaSnapshotStatusLabel,
|
|
86
|
-
} from './quota-v2-model'
|
|
87
45
|
export { cellWidth } from './sidebar-width'
|
|
88
|
-
export { resolveActiveModelRef, resolveModelContextSnapshot }
|
|
89
46
|
|
|
90
47
|
const SINGLETON = Symbol.for('pantheon.tui.v2.loaded')
|
|
91
48
|
|
|
@@ -330,6 +287,184 @@ export function resolveContextLimit(models: readonly any[], ref: unknown): numbe
|
|
|
330
287
|
return null
|
|
331
288
|
}
|
|
332
289
|
|
|
290
|
+
/* ─── Active model & context snapshot ─────────────────────
|
|
291
|
+
* `resolveActiveModelRef` and `resolveModelContextSnapshot` (and the private
|
|
292
|
+
* helpers below them) moved here verbatim from the removed `quota-v2-model.ts`
|
|
293
|
+
* when the native quota surface was deleted: the sidebar's Context gauge is
|
|
294
|
+
* their only remaining consumer. They read only host-published transcript and
|
|
295
|
+
* model-catalog data — no RPC and no provider call. They are deliberately
|
|
296
|
+
* distinct from the looser helpers above (`modelRefID`, `resolveContextLimit`,
|
|
297
|
+
* `transcriptWindow`): identity matching here is provider-qualified and the
|
|
298
|
+
* context window excludes messages with no reported usage. */
|
|
299
|
+
|
|
300
|
+
export type ModelContextSnapshot = { tokens: number; percent: number; limit: number }
|
|
301
|
+
|
|
302
|
+
function asRecord(value: unknown): Record<string, unknown> | undefined {
|
|
303
|
+
return typeof value === 'object' && value !== null
|
|
304
|
+
? (value as Record<string, unknown>)
|
|
305
|
+
: undefined
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function modelID(ref: unknown): string | null {
|
|
309
|
+
const record = asRecord(ref)
|
|
310
|
+
const id = typeof ref === 'string' ? ref : (record?.id ?? record?.modelID)
|
|
311
|
+
return typeof id === 'string' && id.trim() !== '' ? id : null
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function messageModelRef(message: Record<string, unknown>): unknown {
|
|
315
|
+
return message.model ?? message
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function modelProvider(ref: unknown, models: readonly unknown[]): string | null {
|
|
319
|
+
const direct = asRecord(ref)?.providerID
|
|
320
|
+
if (typeof direct === 'string' && direct.trim() !== '') return direct.trim()
|
|
321
|
+
const id = modelID(ref)
|
|
322
|
+
if (id === null) return null
|
|
323
|
+
const segment = id.slice(id.lastIndexOf('/') + 1)
|
|
324
|
+
const providers = new Set<string>()
|
|
325
|
+
for (const candidate of models) {
|
|
326
|
+
const item = asRecord(candidate)
|
|
327
|
+
if (!item) continue
|
|
328
|
+
if (item.id !== id && item.modelID !== id && item.id !== segment && item.modelID !== segment)
|
|
329
|
+
continue
|
|
330
|
+
if (typeof item.providerID === 'string' && item.providerID.trim() !== '') {
|
|
331
|
+
providers.add(item.providerID.trim())
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const explicitProvider = id.includes('/') ? id.slice(0, id.indexOf('/')) : null
|
|
335
|
+
if (explicitProvider && providers.has(explicitProvider)) return explicitProvider
|
|
336
|
+
return providers.size === 1 ? ([...providers][0] ?? null) : null
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function modelIdentity(
|
|
340
|
+
ref: unknown,
|
|
341
|
+
models: readonly unknown[],
|
|
342
|
+
): {
|
|
343
|
+
key: string
|
|
344
|
+
id: string
|
|
345
|
+
providerID: string | null
|
|
346
|
+
label: string
|
|
347
|
+
} | null {
|
|
348
|
+
const id = modelID(ref)
|
|
349
|
+
if (id === null) return null
|
|
350
|
+
const providerID = modelProvider(ref, models)
|
|
351
|
+
const segment = id.slice(id.lastIndexOf('/') + 1)
|
|
352
|
+
return {
|
|
353
|
+
key: `${providerID ?? ''}\u0000${id}`,
|
|
354
|
+
id,
|
|
355
|
+
providerID,
|
|
356
|
+
label: segment || id,
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function tokenCount(message: Record<string, unknown>): number | null {
|
|
361
|
+
const tokens = asRecord(message.tokens)
|
|
362
|
+
if (!tokens) return null
|
|
363
|
+
const cache = asRecord(tokens.cache)
|
|
364
|
+
const values = [tokens.input, tokens.output, tokens.reasoning, cache?.read, cache?.write]
|
|
365
|
+
const reported = values.filter(
|
|
366
|
+
(value): value is number => typeof value === 'number' && Number.isFinite(value) && value >= 0,
|
|
367
|
+
)
|
|
368
|
+
return reported.length === 0 ? null : reported.reduce((sum, value) => sum + value, 0)
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function contextLimit(ref: unknown, models: readonly unknown[]): number | null {
|
|
372
|
+
const id = modelID(ref)
|
|
373
|
+
if (id === null) return null
|
|
374
|
+
const providerID = modelProvider(ref, models)
|
|
375
|
+
if (providerID === null) return null
|
|
376
|
+
const segment = id.slice(id.lastIndexOf('/') + 1)
|
|
377
|
+
const matches = models.filter((value) => {
|
|
378
|
+
const model = asRecord(value)
|
|
379
|
+
if (!model) return false
|
|
380
|
+
const idMatches =
|
|
381
|
+
model.id === id || model.modelID === id || model.id === segment || model.modelID === segment
|
|
382
|
+
return idMatches && model.providerID === providerID
|
|
383
|
+
})
|
|
384
|
+
const limits = new Set<number>()
|
|
385
|
+
for (const candidate of matches) {
|
|
386
|
+
const limit = asRecord(asRecord(candidate)?.limit)?.context
|
|
387
|
+
if (typeof limit === 'number' && Number.isFinite(limit) && limit > 0) limits.add(limit)
|
|
388
|
+
}
|
|
389
|
+
return limits.size === 1 ? ([...limits][0] ?? null) : null
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function liveTranscriptWindow(
|
|
393
|
+
messages: readonly unknown[],
|
|
394
|
+
revertMessageID: string | null | undefined,
|
|
395
|
+
): { start: number; end: number } {
|
|
396
|
+
let end = messages.length
|
|
397
|
+
if (revertMessageID) {
|
|
398
|
+
const boundary = messages.findIndex((message) => asRecord(message)?.id === revertMessageID)
|
|
399
|
+
if (boundary >= 0) end = boundary
|
|
400
|
+
}
|
|
401
|
+
let start = 0
|
|
402
|
+
for (let index = end - 1; index >= 0; index -= 1) {
|
|
403
|
+
if (asRecord(messages[index])?.type === 'compaction') {
|
|
404
|
+
start = index + 1
|
|
405
|
+
break
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return { start, end }
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function latestContext(
|
|
412
|
+
messages: readonly unknown[],
|
|
413
|
+
modelRef: unknown,
|
|
414
|
+
models: readonly unknown[],
|
|
415
|
+
revertMessageID?: string | null,
|
|
416
|
+
): ModelContextSnapshot | null {
|
|
417
|
+
const target = modelIdentity(modelRef, models)
|
|
418
|
+
if (target === null || target.providerID === null) return null
|
|
419
|
+
const limit = contextLimit(modelRef, models)
|
|
420
|
+
if (limit === null || limit <= 0) return null
|
|
421
|
+
const { start, end } = liveTranscriptWindow(messages, revertMessageID)
|
|
422
|
+
for (let index = end - 1; index >= start; index -= 1) {
|
|
423
|
+
const message = asRecord(messages[index])
|
|
424
|
+
if (message?.type !== 'assistant') continue
|
|
425
|
+
const identity = modelIdentity(messageModelRef(message), models)
|
|
426
|
+
if (identity?.id !== target.id || identity.providerID !== target.providerID) continue
|
|
427
|
+
const tokens = tokenCount(message)
|
|
428
|
+
if (tokens === null || tokens <= 0) continue
|
|
429
|
+
return { tokens, percent: Math.round((tokens / limit) * 100), limit }
|
|
430
|
+
}
|
|
431
|
+
return null
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/** Snapshot for one exact model identity in the bounded active transcript. */
|
|
435
|
+
export function resolveModelContextSnapshot(
|
|
436
|
+
messages: readonly unknown[],
|
|
437
|
+
modelRef: unknown,
|
|
438
|
+
models: readonly unknown[],
|
|
439
|
+
revertMessageID?: string | null,
|
|
440
|
+
): ModelContextSnapshot | null {
|
|
441
|
+
return latestContext(
|
|
442
|
+
messages.slice(-MODEL_USAGE_MESSAGE_LIMIT),
|
|
443
|
+
modelRef,
|
|
444
|
+
models,
|
|
445
|
+
revertMessageID,
|
|
446
|
+
)
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/** Select the pinned chat model before transcript or configured-agent fallbacks. */
|
|
450
|
+
export function resolveActiveModelRef(
|
|
451
|
+
sessionModel: unknown,
|
|
452
|
+
activeMessages: readonly unknown[],
|
|
453
|
+
fallbackModel: unknown = null,
|
|
454
|
+
): unknown {
|
|
455
|
+
if (modelID(sessionModel) !== null) return sessionModel
|
|
456
|
+
|
|
457
|
+
const firstMessage = Math.max(0, activeMessages.length - MODEL_USAGE_MESSAGE_LIMIT)
|
|
458
|
+
for (let index = activeMessages.length - 1; index >= firstMessage; index -= 1) {
|
|
459
|
+
const message = asRecord(activeMessages[index])
|
|
460
|
+
if (message?.type !== 'assistant') continue
|
|
461
|
+
const ref = messageModelRef(message)
|
|
462
|
+
if (modelID(ref) !== null) return ref
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
return modelID(fallbackModel) === null ? null : fallbackModel
|
|
466
|
+
}
|
|
467
|
+
|
|
333
468
|
/** Native token total: input + output + reasoning + cache read + cache write. */
|
|
334
469
|
export function messageTokensTotal(tokens: any): number {
|
|
335
470
|
const cacheRead = numberOrNull(tokens?.cache?.read) ?? 0
|
|
@@ -612,14 +747,14 @@ export function collectModelUsage(messages: readonly any[]): ModelUsage[] {
|
|
|
612
747
|
if (id === null || model === null) continue
|
|
613
748
|
const providerID = typeof message.model?.providerID === 'string' ? message.model.providerID : ''
|
|
614
749
|
const key = `${providerID}\u0000${id}`
|
|
615
|
-
const
|
|
750
|
+
const tokensTotal = message.tokens ? messageTokensTotal(message.tokens) : 0
|
|
616
751
|
const cost = numberOrNull(message.cost) ?? 0
|
|
617
752
|
const current = totals.get(key)
|
|
618
753
|
if (current) {
|
|
619
|
-
current.tokens += Math.max(0,
|
|
754
|
+
current.tokens += Math.max(0, tokensTotal)
|
|
620
755
|
current.cost += Math.max(0, cost)
|
|
621
756
|
} else {
|
|
622
|
-
totals.set(key, { model, tokens: Math.max(0,
|
|
757
|
+
totals.set(key, { model, tokens: Math.max(0, tokensTotal), cost: Math.max(0, cost) })
|
|
623
758
|
}
|
|
624
759
|
}
|
|
625
760
|
return [...totals.values()]
|
|
@@ -692,9 +827,39 @@ export function modelUsageRowText(row: ModelUsageRow): string {
|
|
|
692
827
|
return `${row.model.padEnd(MODEL_USAGE_MODEL_WIDTH)} ${row.tokens.padStart(MODEL_USAGE_TOKEN_WIDTH)} ${row.cost.padStart(MODEL_USAGE_COST_WIDTH)}`
|
|
693
828
|
}
|
|
694
829
|
|
|
830
|
+
/** Wrap on grapheme boundaries, measuring terminal cells rather than code units.
|
|
831
|
+
* (Body moved verbatim from the removed quota module's `quotaTextLines`.) */
|
|
832
|
+
function wrapTextLines(text: string, width: number, indent: number): string[] {
|
|
833
|
+
const max = Number.isFinite(width) ? Math.max(0, Math.floor(width)) : 0
|
|
834
|
+
if (max < 1) return []
|
|
835
|
+
const padding = ' '.repeat(Math.min(Math.max(0, indent), Math.max(0, max - 2)))
|
|
836
|
+
const lines: string[] = []
|
|
837
|
+
let line = padding
|
|
838
|
+
const segmenter = new Intl.Segmenter()
|
|
839
|
+
for (const word of text.trim().split(/\s+/)) {
|
|
840
|
+
if (!word) continue
|
|
841
|
+
if (line.trim() && cellWidth(line) + 1 + cellWidth(word) > max) {
|
|
842
|
+
lines.push(line.trimEnd())
|
|
843
|
+
line = padding
|
|
844
|
+
}
|
|
845
|
+
if (line.trim()) line += ' '
|
|
846
|
+
for (const { segment } of segmenter.segment(word)) {
|
|
847
|
+
const glyphWidth = cellWidth(segment)
|
|
848
|
+
if (glyphWidth > max) continue
|
|
849
|
+
if (cellWidth(line) + glyphWidth > max) {
|
|
850
|
+
if (line.trim()) lines.push(line.trimEnd())
|
|
851
|
+
line = glyphWidth + cellWidth(padding) <= max ? padding : ''
|
|
852
|
+
}
|
|
853
|
+
line += segment
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
if (line.trim()) lines.push(line.trimEnd())
|
|
857
|
+
return lines
|
|
858
|
+
}
|
|
859
|
+
|
|
695
860
|
/** Wrap sidebar text by terminal cells, preserving the complete values. */
|
|
696
861
|
export function sidebarTextLines(value: string): string[] {
|
|
697
|
-
return
|
|
862
|
+
return wrapTextLines(value, SIDEBAR_CONTENT_WIDTH, 0)
|
|
698
863
|
}
|
|
699
864
|
|
|
700
865
|
/** Align a monetary value when it fits, otherwise preserve it on a new line. */
|
|
@@ -3760,7 +3925,6 @@ function BlockHeader(props: {
|
|
|
3760
3925
|
interface SidebarProps {
|
|
3761
3926
|
context: Context
|
|
3762
3927
|
sessionID?: string
|
|
3763
|
-
quotaRuntime: QuotaRuntime
|
|
3764
3928
|
}
|
|
3765
3929
|
|
|
3766
3930
|
function Sidebar(props: SidebarProps): JSX.Element {
|
|
@@ -4002,8 +4166,6 @@ function Sidebar(props: SidebarProps): JSX.Element {
|
|
|
4002
4166
|
</Show>
|
|
4003
4167
|
</box>
|
|
4004
4168
|
</Show>
|
|
4005
|
-
{/* Keep quota inside this composition: host slots order claims, not our blocks. */}
|
|
4006
|
-
<QuotaSidebarSummary context={context} runtime={props.quotaRuntime} />
|
|
4007
4169
|
</box>
|
|
4008
4170
|
)
|
|
4009
4171
|
}
|
|
@@ -4278,13 +4440,11 @@ const plugin = Plugin.define({
|
|
|
4278
4440
|
// Eager load/sync at setup so the cache is warm before the slot's first
|
|
4279
4441
|
// render (Known Issue: empty sidebar before the first prompt).
|
|
4280
4442
|
warmUpSidebarData(context, location)
|
|
4281
|
-
const quotaRuntime = createQuotaRuntime(context)
|
|
4282
|
-
const unregisterQuotaTui = registerQuotaTui(context, quotaRuntime)
|
|
4283
4443
|
|
|
4284
4444
|
const unregisterSidebar = context.ui.slot({
|
|
4285
4445
|
append: 'sidebar.content',
|
|
4286
4446
|
render: ({ sessionID }: { sessionID: string }) => (
|
|
4287
|
-
<Sidebar context={context} sessionID={sessionID}
|
|
4447
|
+
<Sidebar context={context} sessionID={sessionID} />
|
|
4288
4448
|
),
|
|
4289
4449
|
})
|
|
4290
4450
|
const unregisterHome = context.ui.slot({
|
|
@@ -4322,7 +4482,6 @@ const plugin = Plugin.define({
|
|
|
4322
4482
|
if (typeof unregisterPromptFooter === 'function') unregisterPromptFooter()
|
|
4323
4483
|
if (typeof unregisterPanel === 'function') unregisterPanel()
|
|
4324
4484
|
if (typeof unregisterCommands === 'function') unregisterCommands()
|
|
4325
|
-
unregisterQuotaTui()
|
|
4326
4485
|
delete globalState[SINGLETON]
|
|
4327
4486
|
}
|
|
4328
4487
|
},
|