vigthoria-cli 1.11.45 → 1.11.46

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.
@@ -4,6 +4,7 @@ import { homedir } from 'os';
4
4
  import path from 'path';
5
5
  import readline from 'readline';
6
6
  import { Config } from '../utils/config.js';
7
+ import { clearGatewayPreflightCache } from '../utils/cli-state.js';
7
8
  const DEFAULT_API_URL = 'https://coder.vigthoria.io';
8
9
  const CONFIG_DIR = path.join(homedir(), '.vigthoria');
9
10
  const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
@@ -148,12 +149,16 @@ export function saveAuthConfig(config) {
148
149
  // Best-effort on non-POSIX filesystems.
149
150
  }
150
151
  syncSharedConfig(config);
152
+ // A fresh login must never be blocked by a stale cached gateway-preflight
153
+ // failure from a prior (invalid) session.
154
+ clearGatewayPreflightCache();
151
155
  }
152
156
  export function clearAuthConfig() {
153
157
  if (existsSync(CONFIG_FILE)) {
154
158
  rmSync(CONFIG_FILE, { force: true });
155
159
  }
156
160
  clearSharedConfigAuth();
161
+ clearGatewayPreflightCache();
157
162
  }
158
163
  export function getAuthToken() {
159
164
  return process.env.VIGTHORIA_TOKEN || loadAuthConfig().token;
@@ -51,4 +51,11 @@ export declare function readCachedLatestVersion(maxAgeMs?: number): string | nul
51
51
  export declare function writeCachedLatestVersion(latestVersion: string, notifiedFor?: string): void;
52
52
  export declare function readGatewayPreflightCache(maxAgeMs?: number): boolean | null;
53
53
  export declare function writeGatewayPreflightCache(valid: boolean): void;
54
+ /**
55
+ * Invalidate any cached gateway-preflight result. Must be called on
56
+ * every login/logout/token change so a stale cached `false` from a
57
+ * prior (invalid) session can never block the very next auth-protected
58
+ * command run right after a fresh, successful login.
59
+ */
60
+ export declare function clearGatewayPreflightCache(): void;
54
61
  export declare function isSafeNpmPackageSpec(spec: string): boolean;
@@ -163,6 +163,24 @@ export function writeGatewayPreflightCache(valid) {
163
163
  // Best-effort.
164
164
  }
165
165
  }
166
+ /**
167
+ * Invalidate any cached gateway-preflight result. Must be called on
168
+ * every login/logout/token change so a stale cached `false` from a
169
+ * prior (invalid) session can never block the very next auth-protected
170
+ * command run right after a fresh, successful login.
171
+ */
172
+ export function clearGatewayPreflightCache() {
173
+ try {
174
+ const state = readStateUnchecked();
175
+ if (state.gatewayPreflight) {
176
+ delete state.gatewayPreflight;
177
+ saveCliState(state);
178
+ }
179
+ }
180
+ catch {
181
+ // Best-effort.
182
+ }
183
+ }
166
184
  /**
167
185
  * Validate an npm package spec used by `vigthoria update --from <spec>`.
168
186
  * Returns `true` when the spec is acceptable. Rejects whitespace and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vigthoria-cli",
3
- "version": "1.11.45",
3
+ "version": "1.11.46",
4
4
  "description": "Vigthoria Coder CLI - AI-powered terminal coding assistant",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",