@thegitai/cli 1.0.0-preview.62 → 1.0.0-preview.64

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 CHANGED
@@ -88,6 +88,7 @@ Each model remembers its own choice across new and resumed sessions.
88
88
  A model your plan does not include stays in the list, grayed out with the
89
89
  reason, and **Enter** does not select it. While a paid account is on its extra
90
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**.
91
92
  The picker shows a model's effort beside its name when it is not Default, and
92
93
  the footer always shows it, except on Auto, which sets its own. The footer labels
93
94
  agent mode separately as `Mode: ...`; narrow terminals place it on the next
package/dist/bin/ai.js CHANGED
@@ -272,6 +272,7 @@ export async function main() {
272
272
  appendPromptHistory: (value) => appendPromptHistory(value, session.env),
273
273
  authConfig,
274
274
  debugUi: whoami.debugUi,
275
+ plan: whoami.usage?.plan,
275
276
  serverModels,
276
277
  serverSessionClient,
277
278
  session,
@@ -1,8 +1,10 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { DEFAULT_THEGITAI_HOST } from './default-host.js';
3
+ import { getInstallId } from '../install-id.js';
3
4
  export const TRACE_ID_HEADER = 'x-thegitai-trace-id';
4
5
  export const CLIENT_HEADER = 'x-thegitai-client';
5
6
  export const CLIENT_PLATFORM_HEADER = 'x-thegitai-client-platform';
7
+ export const INSTALL_ID_HEADER = 'x-thegitai-install-id';
6
8
  export class ServerApiError extends Error {
7
9
  status;
8
10
  traceId;
@@ -21,12 +23,14 @@ export function createTraceId() {
21
23
  return `tr_${randomUUID().replace(/-/g, '')}`;
22
24
  }
23
25
  export function createTraceContext(traceId = createTraceId()) {
26
+ const installId = getInstallId();
24
27
  return {
25
28
  traceId,
26
29
  headers: {
27
30
  [TRACE_ID_HEADER]: traceId,
28
31
  [CLIENT_HEADER]: 'cli',
29
32
  [CLIENT_PLATFORM_HEADER]: `${process.platform}/${process.arch}`,
33
+ ...(installId ? { [INSTALL_ID_HEADER]: installId } : {}),
30
34
  },
31
35
  };
32
36
  }
@@ -251,8 +255,11 @@ export const PLAN_REQUIRED_CODE = 'PLAN_REQUIRED';
251
255
  export function isPlanRequiredError(error) {
252
256
  return error instanceof ServerApiError && error.code === PLAN_REQUIRED_CODE;
253
257
  }
258
+ const ACCOUNT_REFUSAL_CODES = new Set(['ACCOUNT_ACTIVITY_REVIEW', 'PHONE_VERIFICATION_REQUIRED']);
254
259
  export function isTurnRefusal(error) {
255
- return isPlanRequiredError(error) || isQuotaExceededError(error);
260
+ return (isPlanRequiredError(error) ||
261
+ isQuotaExceededError(error) ||
262
+ (error instanceof ServerApiError && ACCOUNT_REFUSAL_CODES.has(error.code)));
256
263
  }
257
264
  export function isAuthenticationError(error) {
258
265
  return error instanceof ServerApiError && error.status === 401;
@@ -0,0 +1,32 @@
1
+ import { randomBytes } from 'node:crypto';
2
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
3
+ import path from 'node:path';
4
+ import { getClientStateDir } from './client-state.js';
5
+ const INSTALL_ID_PATTERN = /^[a-f0-9]{32}$/;
6
+ let cached;
7
+ function readInstallId(file) {
8
+ try {
9
+ const value = readFileSync(file, 'utf8').trim();
10
+ return INSTALL_ID_PATTERN.test(value) ? value : null;
11
+ }
12
+ catch {
13
+ return null;
14
+ }
15
+ }
16
+ export function getInstallId(env = process.env) {
17
+ if (cached !== undefined)
18
+ return cached;
19
+ const file = path.join(getClientStateDir(env), 'install-id');
20
+ const existing = readInstallId(file);
21
+ if (existing)
22
+ return (cached = existing);
23
+ try {
24
+ mkdirSync(path.dirname(file), { recursive: true });
25
+ const id = randomBytes(16).toString('hex');
26
+ writeFileSync(file, `${id}\n`, { mode: 0o600, flag: 'wx' });
27
+ return (cached = id);
28
+ }
29
+ catch {
30
+ return (cached = readInstallId(file));
31
+ }
32
+ }
@@ -1431,7 +1431,7 @@ async function saveSessionBoth({ serverSessionClient, session, }) {
1431
1431
  saveSessionState(session);
1432
1432
  await serverSessionClient.save(session);
1433
1433
  }
1434
- 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, }) {
1435
1435
  if (process.stdin.isTTY !== true) {
1436
1436
  throw new Error('stdin is not a terminal');
1437
1437
  }
@@ -1445,7 +1445,10 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
1445
1445
  setScratchSession(session.sessionId);
1446
1446
  setImageStoreSession(session.sessionId);
1447
1447
  setTodoSession(session.sessionId);
1448
- const store = createShellStore(createInitialShellState(session, serverModels, debugUi, authConfig.serverUrl));
1448
+ const store = createShellStore({
1449
+ ...createInitialShellState(session, serverModels, debugUi, authConfig.serverUrl),
1450
+ plan,
1451
+ });
1449
1452
  store.replaceTranscript(createSessionTranscript(session));
1450
1453
  let currentServerModels = serverModels;
1451
1454
  let sessionAutoYes = session.autoYes;
@@ -3077,6 +3080,9 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
3077
3080
  }
3078
3081
  };
3079
3082
  session.onAccountUsage = (usage) => {
3083
+ if (usage?.plan && usage.plan !== store.getState().plan) {
3084
+ store.update((current) => ({ ...current, plan: usage.plan }));
3085
+ }
3080
3086
  const notice = usageNotice(usage);
3081
3087
  if (!notice)
3082
3088
  return;
@@ -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, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thegitai/cli",
3
- "version": "1.0.0-preview.62",
3
+ "version": "1.0.0-preview.64",
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.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",
48
+ "@thegitai/tui-darwin-arm64": "1.0.0-preview.64",
49
+ "@thegitai/tui-darwin-x64": "1.0.0-preview.64",
50
+ "@thegitai/tui-linux-arm64": "1.0.0-preview.64",
51
+ "@thegitai/tui-linux-x64": "1.0.0-preview.64",
52
+ "@thegitai/tui-win32-x64": "1.0.0-preview.64",
53
53
  "@vscode/ripgrep": "1.18.0"
54
54
  },
55
55
  "repository": {