@agentuity/cli 1.0.8 → 1.0.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.
Files changed (67) hide show
  1. package/dist/cmd/ai/claude-code/constants.d.ts +13 -0
  2. package/dist/cmd/ai/claude-code/constants.d.ts.map +1 -0
  3. package/dist/cmd/ai/claude-code/constants.js +16 -0
  4. package/dist/cmd/ai/claude-code/constants.js.map +1 -0
  5. package/dist/cmd/ai/claude-code/index.d.ts +3 -0
  6. package/dist/cmd/ai/claude-code/index.d.ts.map +1 -0
  7. package/dist/cmd/ai/claude-code/index.js +22 -0
  8. package/dist/cmd/ai/claude-code/index.js.map +1 -0
  9. package/dist/cmd/ai/claude-code/install.d.ts +3 -0
  10. package/dist/cmd/ai/claude-code/install.d.ts.map +1 -0
  11. package/dist/cmd/ai/claude-code/install.js +133 -0
  12. package/dist/cmd/ai/claude-code/install.js.map +1 -0
  13. package/dist/cmd/ai/claude-code/uninstall.d.ts +3 -0
  14. package/dist/cmd/ai/claude-code/uninstall.d.ts.map +1 -0
  15. package/dist/cmd/ai/claude-code/uninstall.js +105 -0
  16. package/dist/cmd/ai/claude-code/uninstall.js.map +1 -0
  17. package/dist/cmd/ai/index.d.ts.map +1 -1
  18. package/dist/cmd/ai/index.js +6 -0
  19. package/dist/cmd/ai/index.js.map +1 -1
  20. package/dist/cmd/build/entry-generator.d.ts.map +1 -1
  21. package/dist/cmd/build/entry-generator.js +1 -8
  22. package/dist/cmd/build/entry-generator.js.map +1 -1
  23. package/dist/cmd/build/vite/config-loader.d.ts +9 -0
  24. package/dist/cmd/build/vite/config-loader.d.ts.map +1 -1
  25. package/dist/cmd/build/vite/config-loader.js +30 -0
  26. package/dist/cmd/build/vite/config-loader.js.map +1 -1
  27. package/dist/cmd/build/vite/server-bundler.d.ts.map +1 -1
  28. package/dist/cmd/build/vite/server-bundler.js +22 -1
  29. package/dist/cmd/build/vite/server-bundler.js.map +1 -1
  30. package/dist/cmd/build/vite/vite-asset-server-config.d.ts.map +1 -1
  31. package/dist/cmd/build/vite/vite-asset-server-config.js +19 -14
  32. package/dist/cmd/build/vite/vite-asset-server-config.js.map +1 -1
  33. package/dist/cmd/build/vite/vite-builder.d.ts.map +1 -1
  34. package/dist/cmd/build/vite/vite-builder.js +12 -8
  35. package/dist/cmd/build/vite/vite-builder.js.map +1 -1
  36. package/dist/cmd/dev/download.d.ts.map +1 -1
  37. package/dist/cmd/dev/download.js +63 -53
  38. package/dist/cmd/dev/download.js.map +1 -1
  39. package/dist/cmd/upgrade/index.d.ts.map +1 -1
  40. package/dist/cmd/upgrade/index.js +24 -11
  41. package/dist/cmd/upgrade/index.js.map +1 -1
  42. package/dist/cmd/upgrade/npm-availability.d.ts +45 -12
  43. package/dist/cmd/upgrade/npm-availability.d.ts.map +1 -1
  44. package/dist/cmd/upgrade/npm-availability.js +73 -26
  45. package/dist/cmd/upgrade/npm-availability.js.map +1 -1
  46. package/dist/types.d.ts +4 -2
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/types.js.map +1 -1
  49. package/dist/version-check.d.ts.map +1 -1
  50. package/dist/version-check.js +13 -2
  51. package/dist/version-check.js.map +1 -1
  52. package/package.json +6 -7
  53. package/src/cmd/ai/claude-code/constants.ts +26 -0
  54. package/src/cmd/ai/claude-code/index.ts +23 -0
  55. package/src/cmd/ai/claude-code/install.ts +181 -0
  56. package/src/cmd/ai/claude-code/uninstall.ts +122 -0
  57. package/src/cmd/ai/index.ts +6 -0
  58. package/src/cmd/build/entry-generator.ts +1 -8
  59. package/src/cmd/build/vite/config-loader.ts +37 -0
  60. package/src/cmd/build/vite/server-bundler.ts +28 -1
  61. package/src/cmd/build/vite/vite-asset-server-config.ts +22 -13
  62. package/src/cmd/build/vite/vite-builder.ts +17 -8
  63. package/src/cmd/dev/download.ts +76 -78
  64. package/src/cmd/upgrade/index.ts +35 -12
  65. package/src/cmd/upgrade/npm-availability.ts +106 -36
  66. package/src/types.ts +4 -2
  67. package/src/version-check.ts +20 -2
@@ -1,62 +1,51 @@
1
1
  /**
2
2
  * npm registry availability checking utilities.
3
- * Used to verify a version is available on npm before attempting upgrade.
3
+ * Used to verify a version is available via bun's resolver before attempting upgrade.
4
4
  */
5
5
 
6
- const NPM_REGISTRY_URL = 'https://registry.npmjs.org';
7
- const PACKAGE_NAME = '@agentuity/cli';
6
+ import { $ } from 'bun';
7
+ import { tmpdir } from 'node:os';
8
8
 
9
- /** Default timeout for quick checks (implicit version check) */
10
- const QUICK_CHECK_TIMEOUT_MS = 1000;
11
-
12
- /** Default timeout for explicit upgrade command */
13
- const EXPLICIT_CHECK_TIMEOUT_MS = 5000;
14
-
15
- export interface CheckNpmOptions {
16
- /** Timeout in milliseconds (default: 5000 for explicit, 1000 for quick) */
17
- timeoutMs?: number;
18
- }
9
+ const PACKAGE_SPEC = '@agentuity/cli';
19
10
 
20
11
  /**
21
- * Check if a specific version of @agentuity/cli is available on npm registry.
22
- * Uses the npm registry API directly for faster response than `npm view`.
12
+ * Check if a specific version of @agentuity/cli is resolvable by bun.
13
+ * Uses `bun info` to verify bun's own resolver/CDN can see the version,
14
+ * which avoids the race where npm registry returns 200 but bun's CDN
15
+ * has not yet propagated the version.
23
16
  *
24
17
  * @param version - Version to check (with or without 'v' prefix)
25
- * @param options - Optional configuration
26
18
  * @returns true if version is available, false otherwise
27
19
  */
28
- export async function isVersionAvailableOnNpm(
29
- version: string,
30
- options: CheckNpmOptions = {}
31
- ): Promise<boolean> {
32
- const { timeoutMs = EXPLICIT_CHECK_TIMEOUT_MS } = options;
20
+ export async function isVersionAvailableOnNpm(version: string): Promise<boolean> {
33
21
  const normalizedVersion = version.replace(/^v/, '');
34
- const url = `${NPM_REGISTRY_URL}/${encodeURIComponent(PACKAGE_NAME)}/${normalizedVersion}`;
35
-
36
22
  try {
37
- const response = await fetch(url, {
38
- method: 'HEAD', // Only need to check existence, not full metadata
39
- signal: AbortSignal.timeout(timeoutMs),
40
- headers: {
41
- Accept: 'application/json',
42
- },
43
- });
44
- return response.ok;
23
+ const result = await $`bun info ${PACKAGE_SPEC}@${normalizedVersion} --json`
24
+ .cwd(tmpdir())
25
+ .quiet()
26
+ .nothrow();
27
+ if (result.exitCode !== 0) {
28
+ return false;
29
+ }
30
+ const info = JSON.parse(result.stdout.toString());
31
+ if (info.error) {
32
+ return false;
33
+ }
34
+ return info.version === normalizedVersion;
45
35
  } catch {
46
- // Network error or timeout - assume not available
47
36
  return false;
48
37
  }
49
38
  }
50
39
 
51
40
  /**
52
- * Quick check if a version is available on npm with a short timeout.
53
- * Used for implicit version checks (auto-upgrade flow) to avoid blocking the user's command.
41
+ * Quick check if a version is available via bun's resolver.
42
+ * Used for implicit version checks (auto-upgrade flow).
54
43
  *
55
44
  * @param version - Version to check (with or without 'v' prefix)
56
- * @returns true if version is available, false if unavailable or timeout
45
+ * @returns true if version is available, false if unavailable or error
57
46
  */
58
47
  export async function isVersionAvailableOnNpmQuick(version: string): Promise<boolean> {
59
- return isVersionAvailableOnNpm(version, { timeoutMs: QUICK_CHECK_TIMEOUT_MS });
48
+ return isVersionAvailableOnNpm(version);
60
49
  }
61
50
 
62
51
  export interface WaitForNpmOptions {
@@ -103,3 +92,84 @@ export async function waitForNpmAvailability(
103
92
 
104
93
  return false;
105
94
  }
95
+
96
+ /**
97
+ * Patterns in bun's stderr that indicate a resolution/CDN propagation failure
98
+ * (as opposed to a permanent install error like permissions or disk space).
99
+ */
100
+ const RESOLUTION_ERROR_PATTERNS = [/failed to resolve/i, /no version matching/i];
101
+
102
+ /**
103
+ * Check whether a bun install failure is a transient resolution error
104
+ * caused by npm CDN propagation delays.
105
+ */
106
+ export function isResolutionError(stderr: string): boolean {
107
+ return RESOLUTION_ERROR_PATTERNS.some((pattern) => pattern.test(stderr));
108
+ }
109
+
110
+ export interface InstallWithRetryOptions {
111
+ /** Maximum number of attempts including the first (default: 7 → 1 initial + 6 retries) */
112
+ maxAttempts?: number;
113
+ /** Initial delay in ms before the first retry (default: 5000) */
114
+ initialDelayMs?: number;
115
+ /** Maximum delay cap in ms (default: 30000) */
116
+ maxDelayMs?: number;
117
+ /** Multiplier applied to the delay after each retry (default: 2) */
118
+ multiplier?: number;
119
+ /** Callback invoked before each retry with the attempt number and upcoming delay */
120
+ onRetry?: (attempt: number, delayMs: number) => void;
121
+ }
122
+
123
+ /**
124
+ * Run an install function and retry on transient resolution errors with
125
+ * exponential backoff. This covers the window (~2 min) where npm CDN nodes
126
+ * have not yet propagated a newly-published version.
127
+ *
128
+ * Total wait with defaults: 5 + 10 + 20 + 30 + 30 + 30 = 125 s ≈ 2 min
129
+ *
130
+ * @param installFn - Async function that performs the install and returns exitCode + stderr
131
+ * @param options - Retry configuration
132
+ * @returns The successful result (exitCode 0)
133
+ * @throws Error if all retries are exhausted or a non-resolution error occurs
134
+ */
135
+ export async function installWithRetry(
136
+ installFn: () => Promise<{ exitCode: number; stderr: Buffer }>,
137
+ options: InstallWithRetryOptions = {}
138
+ ): Promise<{ exitCode: number; stderr: Buffer }> {
139
+ const {
140
+ maxAttempts = 7,
141
+ initialDelayMs = 5000,
142
+ maxDelayMs = 30000,
143
+ multiplier = 2,
144
+ onRetry,
145
+ } = options;
146
+
147
+ let delay = initialDelayMs;
148
+
149
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
150
+ const result = await installFn();
151
+
152
+ if (result.exitCode === 0) {
153
+ return result;
154
+ }
155
+
156
+ const stderr = result.stderr.toString();
157
+
158
+ // Only retry on resolution/propagation errors — bail immediately for anything else
159
+ if (!isResolutionError(stderr)) {
160
+ throw new Error(stderr);
161
+ }
162
+
163
+ // Last attempt exhausted — throw
164
+ if (attempt === maxAttempts) {
165
+ throw new Error(stderr);
166
+ }
167
+
168
+ onRetry?.(attempt, delay);
169
+ await new Promise((resolve) => setTimeout(resolve, delay));
170
+ delay = Math.min(Math.round(delay * multiplier), maxDelayMs);
171
+ }
172
+
173
+ // Unreachable, but satisfies TypeScript
174
+ throw new Error('Install failed after retries');
175
+ }
package/src/types.ts CHANGED
@@ -228,8 +228,10 @@ export interface AgentuityConfig {
228
228
  analytics?: boolean | AnalyticsConfig;
229
229
 
230
230
  /**
231
- * Vite plugins to add to the client build
232
- * These are added AFTER Agentuity's built-in plugins
231
+ * Vite plugins for the client build (src/web/).
232
+ * Should include your framework plugin (e.g., @vitejs/plugin-react).
233
+ * If no framework plugin is detected, React is added automatically
234
+ * for backwards compatibility.
233
235
  */
234
236
  plugins?: import('vite').PluginOption[];
235
237
  /**
@@ -172,9 +172,27 @@ async function performUpgrade(logger: Logger, targetVersion: string): Promise<vo
172
172
 
173
173
  logger.info('Upgrading to version %s...', npmVersion);
174
174
 
175
- // Use bun to install the specific version globally
175
+ // Use bun to install the specific version globally with retry for CDN propagation delays
176
176
  // Run from tmpdir to avoid interference from any local package.json/node_modules
177
- await $`bun add -g @agentuity/cli@${npmVersion}`.cwd(tmpdir()).quiet();
177
+ const { installWithRetry } = await import('./cmd/upgrade/npm-availability');
178
+ await installWithRetry(
179
+ async () => {
180
+ const result = await $`bun add -g @agentuity/cli@${npmVersion}`
181
+ .cwd(tmpdir())
182
+ .quiet()
183
+ .nothrow();
184
+ return { exitCode: result.exitCode, stderr: result.stderr };
185
+ },
186
+ {
187
+ onRetry: (attempt, delayMs) => {
188
+ logger.info(
189
+ 'Package not yet available on CDN, retrying in %ds (attempt %d)...',
190
+ Math.round(delayMs / 1000),
191
+ attempt
192
+ );
193
+ },
194
+ }
195
+ );
178
196
 
179
197
  // If we got here, the upgrade succeeded
180
198
  // Re-run the original command with the new binary