@thegitai/cli 1.0.0-preview.61 → 1.0.0-preview.63
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 +13 -0
- package/dist/bin/ai.js +1 -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 +57 -12
- package/dist/src/ui/tui/build-frame.js +29 -9
- 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,10 @@ 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.
|
|
91
|
+
On Plus or Pro, the footer names the plan after **TheGitAI**.
|
|
79
92
|
The picker shows a model's effort beside its name when it is not Default, and
|
|
80
93
|
the footer always shows it, except on Auto, which sets its own. The footer labels
|
|
81
94
|
agent mode separately as `Mode: ...`; narrow terminals place it on the next
|
package/dist/bin/ai.js
CHANGED
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);
|
|
@@ -1403,7 +1431,7 @@ async function saveSessionBoth({ serverSessionClient, session, }) {
|
|
|
1403
1431
|
saveSessionState(session);
|
|
1404
1432
|
await serverSessionClient.save(session);
|
|
1405
1433
|
}
|
|
1406
|
-
export async function runClientInteractive({ appendPromptHistory, authConfig, debugUi, serverModels, serverSessionClient, session, usageText, initialPrompt, }) {
|
|
1434
|
+
export async function runClientInteractive({ appendPromptHistory, authConfig, debugUi, plan, serverModels, serverSessionClient, session, usageText, initialPrompt, }) {
|
|
1407
1435
|
if (process.stdin.isTTY !== true) {
|
|
1408
1436
|
throw new Error('stdin is not a terminal');
|
|
1409
1437
|
}
|
|
@@ -1417,7 +1445,10 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
|
|
|
1417
1445
|
setScratchSession(session.sessionId);
|
|
1418
1446
|
setImageStoreSession(session.sessionId);
|
|
1419
1447
|
setTodoSession(session.sessionId);
|
|
1420
|
-
const store = createShellStore(
|
|
1448
|
+
const store = createShellStore({
|
|
1449
|
+
...createInitialShellState(session, serverModels, debugUi, authConfig.serverUrl),
|
|
1450
|
+
plan,
|
|
1451
|
+
});
|
|
1421
1452
|
store.replaceTranscript(createSessionTranscript(session));
|
|
1422
1453
|
let currentServerModels = serverModels;
|
|
1423
1454
|
let sessionAutoYes = session.autoYes;
|
|
@@ -2090,11 +2121,11 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
|
|
|
2090
2121
|
}));
|
|
2091
2122
|
};
|
|
2092
2123
|
const switchToModel = async (modelId, effort) => {
|
|
2093
|
-
const
|
|
2094
|
-
const fresh = currentServerModels.models.some((model) => model.id === requested)
|
|
2095
|
-
? currentServerModels
|
|
2096
|
-
: await refreshServerModels();
|
|
2124
|
+
const fresh = await modelsForSwitch(Number(modelId), currentServerModels, refreshServerModels);
|
|
2097
2125
|
const selected = models.validateServerModel(modelId, fresh);
|
|
2126
|
+
const lockedModel = fresh.models.find((model) => model.id === selected && model.locked);
|
|
2127
|
+
if (lockedModel)
|
|
2128
|
+
throw new Error(modelLockMessage(lockedModel));
|
|
2098
2129
|
if (effort !== undefined) {
|
|
2099
2130
|
saveProjectModelEffort(session.rootDir, selected, effort, authConfig.serverUrl, session.env);
|
|
2100
2131
|
}
|
|
@@ -2231,6 +2262,13 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
|
|
|
2231
2262
|
const options = buildModelPickerOptions(current.currentModelId, current.serverModels);
|
|
2232
2263
|
const selectedIndex = Math.min(current.modelPickerIndex, Math.max(options.length - 1, 0));
|
|
2233
2264
|
const selected = options[selectedIndex];
|
|
2265
|
+
const lockedModel = selected?.disabled
|
|
2266
|
+
? current.serverModels.find((model) => model.id === selected.id)
|
|
2267
|
+
: undefined;
|
|
2268
|
+
if (lockedModel) {
|
|
2269
|
+
showTransientStatus(modelLockMessage(lockedModel));
|
|
2270
|
+
return;
|
|
2271
|
+
}
|
|
2234
2272
|
store.update((next) => ({
|
|
2235
2273
|
...next,
|
|
2236
2274
|
modelPickerOpen: false,
|
|
@@ -2967,9 +3005,13 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
|
|
|
2967
3005
|
dismissPendingUserInput();
|
|
2968
3006
|
const failedTurnAttachments = activeTurnImageAttachments;
|
|
2969
3007
|
activeTurnImageAttachments = [];
|
|
2970
|
-
const quotaNotice = cancelled ? null :
|
|
3008
|
+
const quotaNotice = cancelled ? null : buildRefusalNotice(error);
|
|
3009
|
+
const restoresPrompt = quotaNotice !== null && !jobFollowUp && !store.getState().input && !store.getState().queuedMessage;
|
|
2971
3010
|
store.update((current) => ({
|
|
2972
3011
|
...current,
|
|
3012
|
+
...(restoresPrompt
|
|
3013
|
+
? { cursor: String(rawInput ?? '').length, input: String(rawInput ?? ''), pastedChunks: chunks }
|
|
3014
|
+
: {}),
|
|
2973
3015
|
activeTurnInput: '',
|
|
2974
3016
|
activeTurnInputPreformatted: false,
|
|
2975
3017
|
busy: false,
|
|
@@ -3038,6 +3080,9 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
|
|
|
3038
3080
|
}
|
|
3039
3081
|
};
|
|
3040
3082
|
session.onAccountUsage = (usage) => {
|
|
3083
|
+
if (usage?.plan && usage.plan !== store.getState().plan) {
|
|
3084
|
+
store.update((current) => ({ ...current, plan: usage.plan }));
|
|
3085
|
+
}
|
|
3041
3086
|
const notice = usageNotice(usage);
|
|
3042
3087
|
if (!notice)
|
|
3043
3088
|
return;
|
|
@@ -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';
|
|
@@ -486,11 +486,18 @@ export function fitComposerFooterRow({ modeLabels, modeLabelFallback, cycleHint,
|
|
|
486
486
|
: 0;
|
|
487
487
|
return { ...chosen, gap };
|
|
488
488
|
}
|
|
489
|
+
function planSpans(plan) {
|
|
490
|
+
if (plan === 'plus')
|
|
491
|
+
return [span(' Plus', { color: 'cyan', bold: true })];
|
|
492
|
+
if (plan === 'pro')
|
|
493
|
+
return [span(' Pro', { color: 'ansi256(178)', bold: true })];
|
|
494
|
+
return [];
|
|
495
|
+
}
|
|
489
496
|
function composerFooterLines(state, contentWidth) {
|
|
490
497
|
const visibleSessionId = formatPromptSessionIdLabel(state.showSessionId, state.sessionId);
|
|
491
498
|
const transientStatus = footerTransientStatus(state.transientStatus ?? null);
|
|
492
499
|
const lines = [
|
|
493
|
-
line(span('TheGitAI', { color: 'cyan', bold: true }), span(' • ', { color: 'gray', dim: true }), span(formatPromptDirectoryLabel(state.projectRoot), { color: 'cyan' }), ...(transientStatus
|
|
500
|
+
line(span('TheGitAI', { color: 'cyan', bold: true }), ...planSpans(state.plan), span(' • ', { color: 'gray', dim: true }), span(formatPromptDirectoryLabel(state.projectRoot), { color: 'cyan' }), ...(transientStatus
|
|
494
501
|
? [
|
|
495
502
|
span(' ', { color: 'gray', dim: true }),
|
|
496
503
|
span(transientStatus.text, {
|
|
@@ -932,7 +939,7 @@ function modelPickerHeadingLine(title, innerWidth, withColumns) {
|
|
|
932
939
|
const muted = { color: 'gray' };
|
|
933
940
|
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
941
|
}
|
|
935
|
-
function modelPickerDisplayRows(options) {
|
|
942
|
+
function modelPickerDisplayRows(options, pausedCount, innerWidth) {
|
|
936
943
|
const rows = [];
|
|
937
944
|
const autoIndexes = options.flatMap((option, index) => (option.group === 'auto' ? [index] : []));
|
|
938
945
|
const modelIndexes = options.flatMap((option, index) => (option.group === 'models' ? [index] : []));
|
|
@@ -940,18 +947,22 @@ function modelPickerDisplayRows(options) {
|
|
|
940
947
|
rows.push({ kind: 'heading', title: 'Auto', withColumns: true });
|
|
941
948
|
rows.push(...autoIndexes.map((index) => ({ kind: 'option', index })));
|
|
942
949
|
}
|
|
943
|
-
if (modelIndexes.length) {
|
|
950
|
+
if (modelIndexes.length || pausedCount > 0) {
|
|
944
951
|
if (rows.length)
|
|
945
952
|
rows.push({ kind: 'gap' });
|
|
946
953
|
rows.push({ kind: 'heading', title: 'Models', withColumns: rows.length === 0 });
|
|
947
954
|
rows.push(...modelIndexes.map((index) => ({ kind: 'option', index })));
|
|
955
|
+
if (pausedCount > 0) {
|
|
956
|
+
const lines = wrapText(PAUSED_MODELS_NOTE, Math.max(1, innerWidth - 2));
|
|
957
|
+
rows.push(...lines.map((text) => ({ kind: 'paused', text })));
|
|
958
|
+
}
|
|
948
959
|
}
|
|
949
960
|
return rows;
|
|
950
961
|
}
|
|
951
|
-
function buildModelPickerPanel(options, selectedIndex, width, availableHeight, efforts = {}) {
|
|
962
|
+
function buildModelPickerPanel(options, selectedIndex, width, availableHeight, efforts = {}, pausedCount = 0) {
|
|
952
963
|
const panelWidth = Math.max(28, Math.min(width, MODEL_PICKER_PANEL_MAX_WIDTH));
|
|
953
964
|
const innerWidth = Math.max(1, panelWidth - 4);
|
|
954
|
-
const rows = modelPickerDisplayRows(options);
|
|
965
|
+
const rows = modelPickerDisplayRows(options, pausedCount, innerWidth);
|
|
955
966
|
const showEffortDetails = rows.length + 8 <= availableHeight;
|
|
956
967
|
const fixedLineCount = showEffortDetails ? 8 : 5;
|
|
957
968
|
const visibleCount = Math.min(rows.length, Math.max(1, availableHeight - fixedLineCount));
|
|
@@ -969,12 +980,17 @@ function buildModelPickerPanel(options, selectedIndex, width, availableHeight, e
|
|
|
969
980
|
else if (row.kind === 'gap') {
|
|
970
981
|
body.push(modelPickerPanelSideLine(plainLine(''), innerWidth));
|
|
971
982
|
}
|
|
983
|
+
else if (row.kind === 'paused') {
|
|
984
|
+
body.push(modelPickerPanelSideLine(plainLine(fitLine(` ${row.text}`, innerWidth), { color: 'gray' }), innerWidth));
|
|
985
|
+
}
|
|
972
986
|
else {
|
|
973
987
|
const option = options[row.index];
|
|
974
988
|
body.push(...modelPickerItemLines(option, row.index === selectedIndex, projectModelEffort(efforts, option.publicId), innerWidth));
|
|
975
989
|
}
|
|
976
990
|
}
|
|
977
991
|
const selected = options[selectedIndex];
|
|
992
|
+
const lockedSelection = selected?.disabled ? selected : undefined;
|
|
993
|
+
const lockedLines = lockedSelection ? wrapText(lockedSelection.note, innerWidth) : [];
|
|
978
994
|
const selectedEffort = projectModelEffort(efforts, selected?.publicId ?? 0);
|
|
979
995
|
const autoSelected = selected?.group === 'auto';
|
|
980
996
|
const effortChoices = REASONING_EFFORTS.map((effort) => effort === selectedEffort ? `[${REASONING_EFFORT_LABELS[effort]}]` : REASONING_EFFORT_LABELS[effort]).join(' ');
|
|
@@ -992,9 +1008,13 @@ function buildModelPickerPanel(options, selectedIndex, width, availableHeight, e
|
|
|
992
1008
|
: '↑/↓ model • ←/→ effort • Enter select/save • Esc cancel';
|
|
993
1009
|
const compactHint = autoSelected ? '↑↓ · Enter · Esc' : '↑↓ · ←→ · Enter · Esc';
|
|
994
1010
|
const hint = [...fullHint].length <= innerWidth ? fullHint : compactHint;
|
|
995
|
-
body.push(modelPickerDivider(panelWidth),
|
|
1011
|
+
body.push(modelPickerDivider(panelWidth), lockedSelection
|
|
1012
|
+
? modelPickerPanelSideLine(plainLine(fitLine(showEffortDetails ? (lockedLines[0] ?? '') : lockedSelection.note, innerWidth), { color: 'yellow', bold: true }), innerWidth)
|
|
1013
|
+
: modelPickerPanelSideLine(plainLine(fitLine(effortText, innerWidth), { color: 'cyan', bold: true }), innerWidth), ...(showEffortDetails ? [
|
|
996
1014
|
modelPickerPanelSideLine(plainLine(''), innerWidth),
|
|
997
|
-
|
|
1015
|
+
lockedSelection
|
|
1016
|
+
? modelPickerPanelSideLine(plainLine(fitLine(lockedLines.slice(1).join(' '), innerWidth), { color: 'yellow', bold: true }), innerWidth)
|
|
1017
|
+
: modelPickerPanelSideLine(plainLine(fitLine(effortDescription, innerWidth), { color: 'gray' }), innerWidth),
|
|
998
1018
|
modelPickerPanelSideLine(plainLine(''), innerWidth),
|
|
999
1019
|
] : []), modelPickerPanelSideLine(plainLine(fitLine(hint, innerWidth), { color: 'gray' }), innerWidth), plainLine(`╰${'─'.repeat(panelWidth - 2)}╯`, { color: MODEL_PICKER_BORDER_COLOR }));
|
|
1000
1020
|
return [...margin, ...body, ...margin];
|
|
@@ -1317,7 +1337,7 @@ function buildOverlayLines(state, width, height, nowMs) {
|
|
|
1317
1337
|
}
|
|
1318
1338
|
if (state.modelPickerOpen) {
|
|
1319
1339
|
const options = buildModelPickerOptions(state.currentModelId, state.serverModels);
|
|
1320
|
-
lines.push(...buildModelPickerPanel(options, state.modelPickerIndex, width, height, state.modelPickerEfforts));
|
|
1340
|
+
lines.push(...buildModelPickerPanel(options, state.modelPickerIndex, width, height, state.modelPickerEfforts, pausedModelCount(state.serverModels)));
|
|
1321
1341
|
}
|
|
1322
1342
|
if (state.jobsPickerOpen) {
|
|
1323
1343
|
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.63",
|
|
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.63",
|
|
49
|
+
"@thegitai/tui-darwin-x64": "1.0.0-preview.63",
|
|
50
|
+
"@thegitai/tui-linux-arm64": "1.0.0-preview.63",
|
|
51
|
+
"@thegitai/tui-linux-x64": "1.0.0-preview.63",
|
|
52
|
+
"@thegitai/tui-win32-x64": "1.0.0-preview.63",
|
|
53
53
|
"@vscode/ripgrep": "1.18.0"
|
|
54
54
|
},
|
|
55
55
|
"repository": {
|