@thegitai/cli 1.0.0-preview.61 → 1.0.0-preview.62
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/README.md +12 -0
- package/dist/src/api/chat.js +12 -3
- package/dist/src/api/http.js +22 -0
- package/dist/src/api/models.js +13 -0
- package/dist/src/quota-notice.js +31 -4
- package/dist/src/ui/repl.js +49 -10
- package/dist/src/ui/tui/build-frame.js +21 -8
- package/dist/src/ui/tui/shell-input.js +1 -1
- package/dist/src/usage.js +20 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -52,6 +52,15 @@ remain in the transcript. Usage updates arrive when a turn starts and after
|
|
|
52
52
|
usage is saved during and at the end of the turn. An exhausted allowance still
|
|
53
53
|
shows `Usage limit reached`.
|
|
54
54
|
|
|
55
|
+
A request your account cannot run right now, such as one for a model your plan
|
|
56
|
+
does not include or one sent after an allowance is used up, is refused before
|
|
57
|
+
it starts. The CLI shows why, with the reset time and, where an upgrade would
|
|
58
|
+
help, a link to the plans page. The refused request is put back in the input
|
|
59
|
+
box so you can switch models and send it again, and it is not saved to the
|
|
60
|
+
session. When your monthly allowance is used up and extra Auto usage is left,
|
|
61
|
+
the Auto options in `/model` keep working on it until it runs out or your plan
|
|
62
|
+
renews; `/usage` shows how much of the extra is left as a percentage.
|
|
63
|
+
|
|
55
64
|
Coding sessions require an interactive terminal on stdin and stdout. Piped
|
|
56
65
|
one-shot prompts are not supported. Saved history is local to the repo and can
|
|
57
66
|
always be viewed or resumed from that computer. Continuing it through the
|
|
@@ -76,6 +85,9 @@ named models follow under **Models**; for one of them, adjust its reasoning
|
|
|
76
85
|
effort with **← / →** in the same panel: **Default / Low / Balanced / Deep**.
|
|
77
86
|
**Enter** saves the selected model's choice for this project; **Esc** cancels.
|
|
78
87
|
Each model remembers its own choice across new and resumed sessions.
|
|
88
|
+
A model your plan does not include stays in the list, grayed out with the
|
|
89
|
+
reason, and **Enter** does not select it. While a paid account is on its extra
|
|
90
|
+
Auto usage, the named models fold into one line until the plan renews.
|
|
79
91
|
The picker shows a model's effort beside its name when it is not Default, and
|
|
80
92
|
the footer always shows it, except on Auto, which sets its own. The footer labels
|
|
81
93
|
agent mode separately as `Mode: ...`; narrow terminals place it on the next
|
package/dist/src/api/chat.js
CHANGED
|
@@ -8,7 +8,7 @@ import { applySessionSnapshot, saveSessionState, snapshotFromSession, } from '..
|
|
|
8
8
|
import { executeLocalToolCall } from '../tool-executor.js';
|
|
9
9
|
import { saveGeneratedImage } from '../tools/save-generated-image.js';
|
|
10
10
|
import { isUserInputQuestionArray } from './contracts.js';
|
|
11
|
-
import { createTraceContext, gatewayFailureCategory, normalizeServerUrl, QUOTA_EXCEEDED_CODE, readErrorResponse, ServerApiError, transportFailureDetail, } from './http.js';
|
|
11
|
+
import { createTraceContext, gatewayFailureCategory, normalizeServerUrl, QUOTA_EXCEEDED_CODE, PLAN_REQUIRED_CODE, failureDetails, isTurnRefusal, readErrorResponse, ServerApiError, transportFailureDetail, } from './http.js';
|
|
12
12
|
import { createTurnRecovery, fetchTurnAttempt, interruptedStream, isRetryableTurnStatus, isTurnRecoveryExhausted, readTurnChunk, } from './turn-recovery.js';
|
|
13
13
|
import { collectClientEnvironment } from '../client-environment.js';
|
|
14
14
|
import { collectProjectOrientation } from '../project-orientation.js';
|
|
@@ -483,7 +483,10 @@ function terminalFailure(event, traceId) {
|
|
|
483
483
|
return new TurnCancelledError(message);
|
|
484
484
|
}
|
|
485
485
|
if (data.code === QUOTA_EXCEEDED_CODE) {
|
|
486
|
-
return new ServerApiError(message, 429, eventTraceId, QUOTA_EXCEEDED_CODE, data.details
|
|
486
|
+
return new ServerApiError(message, 429, eventTraceId, QUOTA_EXCEEDED_CODE, failureDetails({ error: data.details }));
|
|
487
|
+
}
|
|
488
|
+
if (data.code === PLAN_REQUIRED_CODE) {
|
|
489
|
+
return new ServerApiError(message, 402, eventTraceId, PLAN_REQUIRED_CODE, failureDetails({ error: data.details }));
|
|
487
490
|
}
|
|
488
491
|
return new ChatTurnFailedError(message, typeof data.category === 'string' ? data.category : 'unknown_error', Boolean(data.retryable), eventTraceId, data.snapshot);
|
|
489
492
|
}
|
|
@@ -874,6 +877,9 @@ export async function sendServerUserMessage({ config, session, input, jobFollowU
|
|
|
874
877
|
:
|
|
875
878
|
(gatewayFailureCategory(error) ?? 'unknown_error');
|
|
876
879
|
const partial = error instanceof ChatTurnFailedError ? error.partialSnapshot : undefined;
|
|
880
|
+
const refusedUntouched = !partial && session.history.length === preTurnHistoryLength && isTurnRefusal(error);
|
|
881
|
+
if (refusedUntouched)
|
|
882
|
+
throw error;
|
|
877
883
|
if (partial) {
|
|
878
884
|
applySessionSnapshot(session, partial, { preserveAgentMode: true });
|
|
879
885
|
}
|
|
@@ -964,7 +970,10 @@ function startTurnAttempt({ config, session, turnRequest, input, trace, fetchImp
|
|
|
964
970
|
body: requestBody,
|
|
965
971
|
}, turnSignal);
|
|
966
972
|
if (!response.ok) {
|
|
967
|
-
|
|
973
|
+
const error = await readErrorResponse(response, trace.traceId);
|
|
974
|
+
if (!lastEventId && isTurnRefusal(error))
|
|
975
|
+
serverSettled = true;
|
|
976
|
+
throw error;
|
|
968
977
|
}
|
|
969
978
|
return response;
|
|
970
979
|
};
|
package/dist/src/api/http.js
CHANGED
|
@@ -191,6 +191,8 @@ export function gatewayFailureCategory(error) {
|
|
|
191
191
|
return null;
|
|
192
192
|
if (isQuotaExceededError(error))
|
|
193
193
|
return 'quota_exceeded';
|
|
194
|
+
if (isPlanRequiredError(error))
|
|
195
|
+
return 'plan_required';
|
|
194
196
|
return error.status in GATEWAY_STATUS_MESSAGES ? 'gateway_error' : null;
|
|
195
197
|
}
|
|
196
198
|
export async function readJsonResponse(response) {
|
|
@@ -222,8 +224,21 @@ export function failureDetails(data) {
|
|
|
222
224
|
...(typeof error.percentLeft === 'number'
|
|
223
225
|
? { percentLeft: error.percentLeft }
|
|
224
226
|
: {}),
|
|
227
|
+
...(error.autoAvailable === true ? { autoAvailable: true } : {}),
|
|
228
|
+
...(isWebUrl(error.upgradeUrl) ? { upgradeUrl: error.upgradeUrl } : {}),
|
|
225
229
|
};
|
|
226
230
|
}
|
|
231
|
+
function isWebUrl(value) {
|
|
232
|
+
if (typeof value !== 'string')
|
|
233
|
+
return false;
|
|
234
|
+
try {
|
|
235
|
+
const url = new URL(value);
|
|
236
|
+
return url.protocol === 'https:' || url.protocol === 'http:';
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
227
242
|
export const QUOTA_EXCEEDED_CODE = 'QUOTA_EXCEEDED';
|
|
228
243
|
export function isQuotaExceededError(error) {
|
|
229
244
|
if (!(error instanceof ServerApiError))
|
|
@@ -232,6 +247,13 @@ export function isQuotaExceededError(error) {
|
|
|
232
247
|
return true;
|
|
233
248
|
return error.status === 429 && !error.code;
|
|
234
249
|
}
|
|
250
|
+
export const PLAN_REQUIRED_CODE = 'PLAN_REQUIRED';
|
|
251
|
+
export function isPlanRequiredError(error) {
|
|
252
|
+
return error instanceof ServerApiError && error.code === PLAN_REQUIRED_CODE;
|
|
253
|
+
}
|
|
254
|
+
export function isTurnRefusal(error) {
|
|
255
|
+
return isPlanRequiredError(error) || isQuotaExceededError(error);
|
|
256
|
+
}
|
|
235
257
|
export function isAuthenticationError(error) {
|
|
236
258
|
return error instanceof ServerApiError && error.status === 401;
|
|
237
259
|
}
|
package/dist/src/api/models.js
CHANGED
|
@@ -14,14 +14,19 @@ function sanitizeModelInfo(raw) {
|
|
|
14
14
|
if (!Number.isInteger(id) || id <= 0 || !label || !isCostRating(costRating)) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
|
+
const locked = isModelLock(value.locked) ? value.locked : undefined;
|
|
17
18
|
return {
|
|
18
19
|
id,
|
|
19
20
|
label,
|
|
20
21
|
costRating,
|
|
21
22
|
description,
|
|
23
|
+
...(locked ? { locked } : {}),
|
|
22
24
|
...(value.auto === true ? { auto: true } : {}),
|
|
23
25
|
};
|
|
24
26
|
}
|
|
27
|
+
function isModelLock(value) {
|
|
28
|
+
return value === 'plan' || value === 'auto-only';
|
|
29
|
+
}
|
|
25
30
|
function isCostRating(value) {
|
|
26
31
|
return Number.isInteger(value) && value >= 1 && value <= 3;
|
|
27
32
|
}
|
|
@@ -110,6 +115,14 @@ export function selectServerModel({ requestedModelId, cached, serverModels, }) {
|
|
|
110
115
|
}
|
|
111
116
|
throw new Error(`Server does not support model "${requested}".`);
|
|
112
117
|
}
|
|
118
|
+
const unlockedIds = new Set(serverModels.models.filter((model) => !model.locked).map((model) => model.id));
|
|
119
|
+
const firstUnlocked = serverModels.models.find((model) => !model.locked)?.id;
|
|
120
|
+
for (const candidate of [cached?.selectedModelId, serverModels.models[0]?.id, firstUnlocked]) {
|
|
121
|
+
const id = Number(candidate);
|
|
122
|
+
if (Number.isInteger(id) && unlockedIds.has(id)) {
|
|
123
|
+
return id;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
113
126
|
for (const candidate of [cached?.selectedModelId, serverModels.models[0]?.id]) {
|
|
114
127
|
const id = Number(candidate);
|
|
115
128
|
if (Number.isInteger(id) && supportedIds.has(id)) {
|
package/dist/src/quota-notice.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isQuotaExceededError, ServerApiError } from './api/http.js';
|
|
1
|
+
import { isPlanRequiredError, isQuotaExceededError, ServerApiError } from './api/http.js';
|
|
2
2
|
import { USAGE_WINDOWS, formatUtcMinute, usageWindowLabel } from './usage.js';
|
|
3
3
|
export function buildQuotaNotice(error) {
|
|
4
4
|
if (!(error instanceof ServerApiError) || !isQuotaExceededError(error)) {
|
|
@@ -7,21 +7,48 @@ export function buildQuotaNotice(error) {
|
|
|
7
7
|
const label = usageWindowLabel(String(error.details.window ?? ''));
|
|
8
8
|
const inSentence = label.toLowerCase();
|
|
9
9
|
const resetsAt = error.details.resetsAt ?? null;
|
|
10
|
+
const reset = resetsAt ? formatUtcMinute(resetsAt) : '';
|
|
11
|
+
const knownReset = reset && reset !== 'unknown' ? reset : '';
|
|
12
|
+
if (error.details.autoAvailable) {
|
|
13
|
+
return {
|
|
14
|
+
title: 'Usage limit reached',
|
|
15
|
+
body: [
|
|
16
|
+
knownReset
|
|
17
|
+
? `You've used your monthly allowance. Auto options in /model still work on a limited extra allowance until it runs out or your plan renews at ${knownReset}.`
|
|
18
|
+
: "You've used your monthly allowance. Auto options in /model still work on a limited extra allowance until it runs out or your plan renews.",
|
|
19
|
+
'Run /usage for details.',
|
|
20
|
+
].join('\n'),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
10
23
|
const lines = [];
|
|
11
24
|
if (label) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
? `You've used your ${inSentence} limit. It resets at ${reset}.`
|
|
25
|
+
lines.push(knownReset
|
|
26
|
+
? `You've used your ${inSentence} limit. It resets at ${knownReset}.`
|
|
15
27
|
: `You've used your ${inSentence} limit.`);
|
|
16
28
|
}
|
|
17
29
|
else {
|
|
18
30
|
lines.push(firstMessageLine(error));
|
|
19
31
|
}
|
|
32
|
+
if (error.details.upgradeUrl) {
|
|
33
|
+
lines.push(`Upgrade for more usage at ${error.details.upgradeUrl}`);
|
|
34
|
+
}
|
|
20
35
|
lines.push(label
|
|
21
36
|
? `Run /usage to see your ${otherWindowNames(label)} windows.`
|
|
22
37
|
: 'Run /usage to see your remaining usage.');
|
|
23
38
|
return { title: 'Usage limit reached', body: lines.join('\n') };
|
|
24
39
|
}
|
|
40
|
+
export function buildPlanRequiredNotice(error) {
|
|
41
|
+
if (!(error instanceof ServerApiError) || !isPlanRequiredError(error)) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
title: 'Plus or Pro model',
|
|
46
|
+
body: firstMessageLine(error).replace(/\.\s+(?=Upgrade at )/, '.\n'),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function buildRefusalNotice(error) {
|
|
50
|
+
return buildPlanRequiredNotice(error) ?? buildQuotaNotice(error);
|
|
51
|
+
}
|
|
25
52
|
function otherWindowNames(usedLabel) {
|
|
26
53
|
const names = USAGE_WINDOWS.map(([name]) => name)
|
|
27
54
|
.filter((name) => name !== usedLabel)
|
package/dist/src/ui/repl.js
CHANGED
|
@@ -26,7 +26,7 @@ import { cancelActiveCommand } from '../executor.js';
|
|
|
26
26
|
import { isTurnFailureMarker } from '../turn-failure-marker.js';
|
|
27
27
|
import { clearCliAuthConfig, logoutFromServer, } from '../api/auth.js';
|
|
28
28
|
import { authenticationErrorMessage, isAuthenticationError, } from '../api/http.js';
|
|
29
|
-
import {
|
|
29
|
+
import { buildRefusalNotice } from '../quota-notice.js';
|
|
30
30
|
import { createUsageNoticeTracker } from '../usage-notice.js';
|
|
31
31
|
import { createUserInputPromptState, formatUserInputTranscript, } from './tui/user-input.js';
|
|
32
32
|
import { setCommandOutputHook, withTuiMode } from '../runtime-mode.js';
|
|
@@ -1356,23 +1356,51 @@ export function busyElapsedSeconds(state, nowMs) {
|
|
|
1356
1356
|
return Math.floor((busyElapsedMs(state, nowMs) ?? 0) / 1000);
|
|
1357
1357
|
}
|
|
1358
1358
|
export function buildModelPickerOptions(currentModelId, serverModels) {
|
|
1359
|
+
const listed = serverModels.filter((model) => model.locked !== 'auto-only');
|
|
1359
1360
|
return [
|
|
1360
|
-
...
|
|
1361
|
-
...
|
|
1361
|
+
...listed.filter((model) => model.auto),
|
|
1362
|
+
...listed.filter((model) => !model.auto),
|
|
1362
1363
|
].map((model) => ({
|
|
1363
1364
|
id: model.id,
|
|
1364
1365
|
label: model.auto ? autoOptionLabel(model.label) : model.label,
|
|
1365
1366
|
publicId: model.id,
|
|
1366
1367
|
costRating: model.costRating,
|
|
1367
1368
|
current: model.id === currentModelId,
|
|
1368
|
-
disabled:
|
|
1369
|
+
disabled: Boolean(model.locked),
|
|
1369
1370
|
group: model.auto ? 'auto' : 'models',
|
|
1370
|
-
note: model.description,
|
|
1371
|
+
note: model.locked ? MODEL_LOCK_NOTES[model.locked] : model.description,
|
|
1371
1372
|
}));
|
|
1372
1373
|
}
|
|
1374
|
+
export function pausedModelCount(serverModels) {
|
|
1375
|
+
return serverModels.filter((model) => model.locked === 'auto-only').length;
|
|
1376
|
+
}
|
|
1377
|
+
export async function modelsForSwitch(requestedModelId, cached, refresh) {
|
|
1378
|
+
try {
|
|
1379
|
+
return await refresh();
|
|
1380
|
+
}
|
|
1381
|
+
catch (error) {
|
|
1382
|
+
if (cached.models.some((model) => model.id === requestedModelId))
|
|
1383
|
+
return cached;
|
|
1384
|
+
throw error;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
export const PAUSED_MODELS_NOTE = 'Named models return when your plan renews.';
|
|
1373
1388
|
function autoOptionLabel(label) {
|
|
1374
1389
|
return /^Auto \((.+)\)$/.exec(label)?.[1] ?? label;
|
|
1375
1390
|
}
|
|
1391
|
+
const MODEL_LOCK_NOTES = {
|
|
1392
|
+
plan: 'Needs a Plus or Pro plan',
|
|
1393
|
+
'auto-only': 'Auto options only until your plan renews',
|
|
1394
|
+
};
|
|
1395
|
+
export function modelLockMessage(model) {
|
|
1396
|
+
if (model.locked === 'auto-only') {
|
|
1397
|
+
return `Only Auto options run until your plan renews. Pick one of them instead of ${pickerLabel(model.label)}.`;
|
|
1398
|
+
}
|
|
1399
|
+
return `${pickerLabel(model.label)} needs a Plus or Pro plan.`;
|
|
1400
|
+
}
|
|
1401
|
+
function pickerLabel(label) {
|
|
1402
|
+
return label.replace(/\s*\([^)]*\)\s*$/, '');
|
|
1403
|
+
}
|
|
1376
1404
|
function getDefaultModelPickerIndex(currentModelId, serverModels) {
|
|
1377
1405
|
const options = buildModelPickerOptions(currentModelId, serverModels);
|
|
1378
1406
|
const currentIndex = options.findIndex((option) => option.id === currentModelId);
|
|
@@ -2090,11 +2118,11 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
|
|
|
2090
2118
|
}));
|
|
2091
2119
|
};
|
|
2092
2120
|
const switchToModel = async (modelId, effort) => {
|
|
2093
|
-
const
|
|
2094
|
-
const fresh = currentServerModels.models.some((model) => model.id === requested)
|
|
2095
|
-
? currentServerModels
|
|
2096
|
-
: await refreshServerModels();
|
|
2121
|
+
const fresh = await modelsForSwitch(Number(modelId), currentServerModels, refreshServerModels);
|
|
2097
2122
|
const selected = models.validateServerModel(modelId, fresh);
|
|
2123
|
+
const lockedModel = fresh.models.find((model) => model.id === selected && model.locked);
|
|
2124
|
+
if (lockedModel)
|
|
2125
|
+
throw new Error(modelLockMessage(lockedModel));
|
|
2098
2126
|
if (effort !== undefined) {
|
|
2099
2127
|
saveProjectModelEffort(session.rootDir, selected, effort, authConfig.serverUrl, session.env);
|
|
2100
2128
|
}
|
|
@@ -2231,6 +2259,13 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
|
|
|
2231
2259
|
const options = buildModelPickerOptions(current.currentModelId, current.serverModels);
|
|
2232
2260
|
const selectedIndex = Math.min(current.modelPickerIndex, Math.max(options.length - 1, 0));
|
|
2233
2261
|
const selected = options[selectedIndex];
|
|
2262
|
+
const lockedModel = selected?.disabled
|
|
2263
|
+
? current.serverModels.find((model) => model.id === selected.id)
|
|
2264
|
+
: undefined;
|
|
2265
|
+
if (lockedModel) {
|
|
2266
|
+
showTransientStatus(modelLockMessage(lockedModel));
|
|
2267
|
+
return;
|
|
2268
|
+
}
|
|
2234
2269
|
store.update((next) => ({
|
|
2235
2270
|
...next,
|
|
2236
2271
|
modelPickerOpen: false,
|
|
@@ -2967,9 +3002,13 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
|
|
|
2967
3002
|
dismissPendingUserInput();
|
|
2968
3003
|
const failedTurnAttachments = activeTurnImageAttachments;
|
|
2969
3004
|
activeTurnImageAttachments = [];
|
|
2970
|
-
const quotaNotice = cancelled ? null :
|
|
3005
|
+
const quotaNotice = cancelled ? null : buildRefusalNotice(error);
|
|
3006
|
+
const restoresPrompt = quotaNotice !== null && !jobFollowUp && !store.getState().input && !store.getState().queuedMessage;
|
|
2971
3007
|
store.update((current) => ({
|
|
2972
3008
|
...current,
|
|
3009
|
+
...(restoresPrompt
|
|
3010
|
+
? { cursor: String(rawInput ?? '').length, input: String(rawInput ?? ''), pastedChunks: chunks }
|
|
3011
|
+
: {}),
|
|
2973
3012
|
activeTurnInput: '',
|
|
2974
3013
|
activeTurnInputPreformatted: false,
|
|
2975
3014
|
busy: false,
|
|
@@ -3,7 +3,7 @@ import { projectModelEffort } from '../../project-model-preferences.js';
|
|
|
3
3
|
import { REASONING_EFFORTS, REASONING_EFFORT_LABELS, REASONING_EFFORT_DESCRIPTIONS } from '../../reasoning-effort.js';
|
|
4
4
|
import { agentModeColor, agentModeLabelTiers, agentModeShortLabel, } from '../../agent-mode.js';
|
|
5
5
|
import { singleLinePreview, truncate } from '../../utils.js';
|
|
6
|
-
import { buildModelPickerOptions, formatClientTokenUsage } from '../repl.js';
|
|
6
|
+
import { buildModelPickerOptions, formatClientTokenUsage, PAUSED_MODELS_NOTE, pausedModelCount, } from '../repl.js';
|
|
7
7
|
import { getHiddenSlashCommandCount, getSlashCommandSuggestions, } from '../slash-commands.js';
|
|
8
8
|
import { renderFormattedBodyLines, renderPreformattedBodyLines, } from './markdown-render.js';
|
|
9
9
|
import { displayWidth, line, padToWidth, plainLine, sliceToWidth, span, wrapText, } from './text.js';
|
|
@@ -932,7 +932,7 @@ function modelPickerHeadingLine(title, innerWidth, withColumns) {
|
|
|
932
932
|
const muted = { color: 'gray' };
|
|
933
933
|
return line(modelPickerCell(title, modelPickerModelWidth(innerWidth), heading), span(MODEL_PICKER_COLUMN_GAP), modelPickerCell('Cost', MODEL_PICKER_COST_WIDTH, muted), span(MODEL_PICKER_COLUMN_GAP), modelPickerCell('Notes', modelPickerNotesWidth(innerWidth), muted));
|
|
934
934
|
}
|
|
935
|
-
function modelPickerDisplayRows(options) {
|
|
935
|
+
function modelPickerDisplayRows(options, pausedCount, innerWidth) {
|
|
936
936
|
const rows = [];
|
|
937
937
|
const autoIndexes = options.flatMap((option, index) => (option.group === 'auto' ? [index] : []));
|
|
938
938
|
const modelIndexes = options.flatMap((option, index) => (option.group === 'models' ? [index] : []));
|
|
@@ -940,18 +940,22 @@ function modelPickerDisplayRows(options) {
|
|
|
940
940
|
rows.push({ kind: 'heading', title: 'Auto', withColumns: true });
|
|
941
941
|
rows.push(...autoIndexes.map((index) => ({ kind: 'option', index })));
|
|
942
942
|
}
|
|
943
|
-
if (modelIndexes.length) {
|
|
943
|
+
if (modelIndexes.length || pausedCount > 0) {
|
|
944
944
|
if (rows.length)
|
|
945
945
|
rows.push({ kind: 'gap' });
|
|
946
946
|
rows.push({ kind: 'heading', title: 'Models', withColumns: rows.length === 0 });
|
|
947
947
|
rows.push(...modelIndexes.map((index) => ({ kind: 'option', index })));
|
|
948
|
+
if (pausedCount > 0) {
|
|
949
|
+
const lines = wrapText(PAUSED_MODELS_NOTE, Math.max(1, innerWidth - 2));
|
|
950
|
+
rows.push(...lines.map((text) => ({ kind: 'paused', text })));
|
|
951
|
+
}
|
|
948
952
|
}
|
|
949
953
|
return rows;
|
|
950
954
|
}
|
|
951
|
-
function buildModelPickerPanel(options, selectedIndex, width, availableHeight, efforts = {}) {
|
|
955
|
+
function buildModelPickerPanel(options, selectedIndex, width, availableHeight, efforts = {}, pausedCount = 0) {
|
|
952
956
|
const panelWidth = Math.max(28, Math.min(width, MODEL_PICKER_PANEL_MAX_WIDTH));
|
|
953
957
|
const innerWidth = Math.max(1, panelWidth - 4);
|
|
954
|
-
const rows = modelPickerDisplayRows(options);
|
|
958
|
+
const rows = modelPickerDisplayRows(options, pausedCount, innerWidth);
|
|
955
959
|
const showEffortDetails = rows.length + 8 <= availableHeight;
|
|
956
960
|
const fixedLineCount = showEffortDetails ? 8 : 5;
|
|
957
961
|
const visibleCount = Math.min(rows.length, Math.max(1, availableHeight - fixedLineCount));
|
|
@@ -969,12 +973,17 @@ function buildModelPickerPanel(options, selectedIndex, width, availableHeight, e
|
|
|
969
973
|
else if (row.kind === 'gap') {
|
|
970
974
|
body.push(modelPickerPanelSideLine(plainLine(''), innerWidth));
|
|
971
975
|
}
|
|
976
|
+
else if (row.kind === 'paused') {
|
|
977
|
+
body.push(modelPickerPanelSideLine(plainLine(fitLine(` ${row.text}`, innerWidth), { color: 'gray' }), innerWidth));
|
|
978
|
+
}
|
|
972
979
|
else {
|
|
973
980
|
const option = options[row.index];
|
|
974
981
|
body.push(...modelPickerItemLines(option, row.index === selectedIndex, projectModelEffort(efforts, option.publicId), innerWidth));
|
|
975
982
|
}
|
|
976
983
|
}
|
|
977
984
|
const selected = options[selectedIndex];
|
|
985
|
+
const lockedSelection = selected?.disabled ? selected : undefined;
|
|
986
|
+
const lockedLines = lockedSelection ? wrapText(lockedSelection.note, innerWidth) : [];
|
|
978
987
|
const selectedEffort = projectModelEffort(efforts, selected?.publicId ?? 0);
|
|
979
988
|
const autoSelected = selected?.group === 'auto';
|
|
980
989
|
const effortChoices = REASONING_EFFORTS.map((effort) => effort === selectedEffort ? `[${REASONING_EFFORT_LABELS[effort]}]` : REASONING_EFFORT_LABELS[effort]).join(' ');
|
|
@@ -992,9 +1001,13 @@ function buildModelPickerPanel(options, selectedIndex, width, availableHeight, e
|
|
|
992
1001
|
: '↑/↓ model • ←/→ effort • Enter select/save • Esc cancel';
|
|
993
1002
|
const compactHint = autoSelected ? '↑↓ · Enter · Esc' : '↑↓ · ←→ · Enter · Esc';
|
|
994
1003
|
const hint = [...fullHint].length <= innerWidth ? fullHint : compactHint;
|
|
995
|
-
body.push(modelPickerDivider(panelWidth),
|
|
1004
|
+
body.push(modelPickerDivider(panelWidth), lockedSelection
|
|
1005
|
+
? modelPickerPanelSideLine(plainLine(fitLine(showEffortDetails ? (lockedLines[0] ?? '') : lockedSelection.note, innerWidth), { color: 'yellow', bold: true }), innerWidth)
|
|
1006
|
+
: modelPickerPanelSideLine(plainLine(fitLine(effortText, innerWidth), { color: 'cyan', bold: true }), innerWidth), ...(showEffortDetails ? [
|
|
996
1007
|
modelPickerPanelSideLine(plainLine(''), innerWidth),
|
|
997
|
-
|
|
1008
|
+
lockedSelection
|
|
1009
|
+
? modelPickerPanelSideLine(plainLine(fitLine(lockedLines.slice(1).join(' '), innerWidth), { color: 'yellow', bold: true }), innerWidth)
|
|
1010
|
+
: modelPickerPanelSideLine(plainLine(fitLine(effortDescription, innerWidth), { color: 'gray' }), innerWidth),
|
|
998
1011
|
modelPickerPanelSideLine(plainLine(''), innerWidth),
|
|
999
1012
|
] : []), modelPickerPanelSideLine(plainLine(fitLine(hint, innerWidth), { color: 'gray' }), innerWidth), plainLine(`╰${'─'.repeat(panelWidth - 2)}╯`, { color: MODEL_PICKER_BORDER_COLOR }));
|
|
1000
1013
|
return [...margin, ...body, ...margin];
|
|
@@ -1317,7 +1330,7 @@ function buildOverlayLines(state, width, height, nowMs) {
|
|
|
1317
1330
|
}
|
|
1318
1331
|
if (state.modelPickerOpen) {
|
|
1319
1332
|
const options = buildModelPickerOptions(state.currentModelId, state.serverModels);
|
|
1320
|
-
lines.push(...buildModelPickerPanel(options, state.modelPickerIndex, width, height, state.modelPickerEfforts));
|
|
1333
|
+
lines.push(...buildModelPickerPanel(options, state.modelPickerIndex, width, height, state.modelPickerEfforts, pausedModelCount(state.serverModels)));
|
|
1321
1334
|
}
|
|
1322
1335
|
if (state.jobsPickerOpen) {
|
|
1323
1336
|
lines.push(...buildJobsPickerLines(state, width, height, nowMs));
|
|
@@ -376,7 +376,7 @@ export function handleShellKeyEvent(store, handlers, event) {
|
|
|
376
376
|
store.update((current) => {
|
|
377
377
|
const options = buildModelPickerOptions(Number(current.currentModelId ?? 0), current.serverModels ?? []);
|
|
378
378
|
const model = options[current.modelPickerIndex];
|
|
379
|
-
if (!model || model.group === 'auto')
|
|
379
|
+
if (!model || model.disabled || model.group === 'auto')
|
|
380
380
|
return current;
|
|
381
381
|
const efforts = current.modelPickerEfforts ?? {};
|
|
382
382
|
return {
|
package/dist/src/usage.js
CHANGED
|
@@ -34,6 +34,11 @@ function formatPercentLeft(value) {
|
|
|
34
34
|
maximumFractionDigits: 1,
|
|
35
35
|
}).format(percent)}% left`;
|
|
36
36
|
}
|
|
37
|
+
const PLAN_NAMES = {
|
|
38
|
+
free: 'Free',
|
|
39
|
+
plus: 'Plus',
|
|
40
|
+
pro: 'Pro',
|
|
41
|
+
};
|
|
37
42
|
export function formatUsageText(response) {
|
|
38
43
|
const { customer, usage } = response;
|
|
39
44
|
const lines = [`Usage for ${customer.email}`, ''];
|
|
@@ -41,10 +46,25 @@ export function formatUsageText(response) {
|
|
|
41
46
|
lines.push('Usage is not available for this account yet.');
|
|
42
47
|
return lines.join('\n');
|
|
43
48
|
}
|
|
49
|
+
if (usage.plan) {
|
|
50
|
+
lines.push(`Plan: ${PLAN_NAMES[usage.plan] ?? usage.plan}`, '');
|
|
51
|
+
}
|
|
44
52
|
lines.push('Window Left Resets');
|
|
45
53
|
for (const [label, key] of USAGE_WINDOWS) {
|
|
46
54
|
const value = formatPercentLeft(Number(usage.percentLeft[key] ?? 0));
|
|
47
55
|
lines.push(`${label.padEnd(10)} ${value.padEnd(11)} ${formatUtcMinute(usage.resetsAt[key])}`);
|
|
48
56
|
}
|
|
57
|
+
if (usage.autoOnly) {
|
|
58
|
+
const value = formatPercentLeft(Number(usage.autoPercentLeft ?? 0));
|
|
59
|
+
lines.push(`${'Auto extra'.padEnd(10)} ${value.padEnd(11)} ${formatUtcMinute(usage.resetsAt.monthly)}`, '', ...(usage.autoExtraSpent
|
|
60
|
+
? [
|
|
61
|
+
'Your monthly allowance and extra Auto usage are used up. Usage',
|
|
62
|
+
'resumes when your plan renews.',
|
|
63
|
+
]
|
|
64
|
+
: [
|
|
65
|
+
'Your monthly allowance is used up. Auto options in /model still work',
|
|
66
|
+
'on extra usage until it runs out or your plan renews.',
|
|
67
|
+
]));
|
|
68
|
+
}
|
|
49
69
|
return lines.join('\n');
|
|
50
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thegitai/cli",
|
|
3
|
-
"version": "1.0.0-preview.
|
|
3
|
+
"version": "1.0.0-preview.62",
|
|
4
4
|
"description": "TheGitAI is an agentic AI coding tool for your terminal. It reads and searches your repository, writes and edits files, runs your tests, and verifies the change before handing it back.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentic-ai",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"@lydell/node-pty-linux-x64": "1.1.0",
|
|
46
46
|
"@lydell/node-pty-win32-arm64": "1.1.0",
|
|
47
47
|
"@lydell/node-pty-win32-x64": "1.1.0",
|
|
48
|
-
"@thegitai/tui-darwin-arm64": "1.0.0-preview.
|
|
49
|
-
"@thegitai/tui-darwin-x64": "1.0.0-preview.
|
|
50
|
-
"@thegitai/tui-linux-arm64": "1.0.0-preview.
|
|
51
|
-
"@thegitai/tui-linux-x64": "1.0.0-preview.
|
|
52
|
-
"@thegitai/tui-win32-x64": "1.0.0-preview.
|
|
48
|
+
"@thegitai/tui-darwin-arm64": "1.0.0-preview.62",
|
|
49
|
+
"@thegitai/tui-darwin-x64": "1.0.0-preview.62",
|
|
50
|
+
"@thegitai/tui-linux-arm64": "1.0.0-preview.62",
|
|
51
|
+
"@thegitai/tui-linux-x64": "1.0.0-preview.62",
|
|
52
|
+
"@thegitai/tui-win32-x64": "1.0.0-preview.62",
|
|
53
53
|
"@vscode/ripgrep": "1.18.0"
|
|
54
54
|
},
|
|
55
55
|
"repository": {
|