@agentuity/cli 0.0.73 → 0.0.75

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 (85) hide show
  1. package/dist/auth.d.ts.map +1 -1
  2. package/dist/auth.js +13 -9
  3. package/dist/auth.js.map +1 -1
  4. package/dist/banner.js +1 -1
  5. package/dist/banner.js.map +1 -1
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +2 -2
  8. package/dist/cli.js.map +1 -1
  9. package/dist/cmd/ai/prompt/api.d.ts.map +1 -1
  10. package/dist/cmd/ai/prompt/api.js +5 -4
  11. package/dist/cmd/ai/prompt/api.js.map +1 -1
  12. package/dist/cmd/auth/ssh/api.d.ts.map +1 -1
  13. package/dist/cmd/auth/ssh/api.js.map +1 -1
  14. package/dist/cmd/build/ast.d.ts.map +1 -1
  15. package/dist/cmd/build/ast.js +20 -6
  16. package/dist/cmd/build/ast.js.map +1 -1
  17. package/dist/cmd/build/bundler.d.ts +3 -1
  18. package/dist/cmd/build/bundler.d.ts.map +1 -1
  19. package/dist/cmd/build/bundler.js +19 -9
  20. package/dist/cmd/build/bundler.js.map +1 -1
  21. package/dist/cmd/build/plugin.d.ts.map +1 -1
  22. package/dist/cmd/build/plugin.js +87 -66
  23. package/dist/cmd/build/plugin.js.map +1 -1
  24. package/dist/cmd/build/route-discovery.d.ts +50 -0
  25. package/dist/cmd/build/route-discovery.d.ts.map +1 -0
  26. package/dist/cmd/build/route-discovery.js +143 -0
  27. package/dist/cmd/build/route-discovery.js.map +1 -0
  28. package/dist/cmd/build/route-registry.d.ts.map +1 -1
  29. package/dist/cmd/build/route-registry.js +25 -10
  30. package/dist/cmd/build/route-registry.js.map +1 -1
  31. package/dist/cmd/cloud/deploy.d.ts.map +1 -1
  32. package/dist/cmd/cloud/deploy.js +8 -6
  33. package/dist/cmd/cloud/deploy.js.map +1 -1
  34. package/dist/cmd/dev/agents.d.ts.map +1 -1
  35. package/dist/cmd/dev/agents.js.map +1 -1
  36. package/dist/cmd/dev/index.d.ts.map +1 -1
  37. package/dist/cmd/dev/index.js +21 -0
  38. package/dist/cmd/dev/index.js.map +1 -1
  39. package/dist/cmd/dev/sync.d.ts.map +1 -1
  40. package/dist/cmd/dev/sync.js.map +1 -1
  41. package/dist/cmd/project/download.d.ts.map +1 -1
  42. package/dist/cmd/project/download.js +16 -2
  43. package/dist/cmd/project/download.js.map +1 -1
  44. package/dist/cmd/project/list.d.ts.map +1 -1
  45. package/dist/cmd/project/list.js +2 -10
  46. package/dist/cmd/project/list.js.map +1 -1
  47. package/dist/index.d.ts +2 -2
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +1 -1
  50. package/dist/index.js.map +1 -1
  51. package/dist/steps.d.ts +20 -30
  52. package/dist/steps.d.ts.map +1 -1
  53. package/dist/steps.js +339 -184
  54. package/dist/steps.js.map +1 -1
  55. package/dist/tui/box.d.ts.map +1 -1
  56. package/dist/tui/box.js +8 -4
  57. package/dist/tui/box.js.map +1 -1
  58. package/dist/tui/prompt.d.ts.map +1 -1
  59. package/dist/tui/prompt.js +7 -2
  60. package/dist/tui/prompt.js.map +1 -1
  61. package/dist/tui.d.ts.map +1 -1
  62. package/dist/tui.js +5 -4
  63. package/dist/tui.js.map +1 -1
  64. package/package.json +3 -3
  65. package/src/auth.ts +13 -10
  66. package/src/banner.ts +1 -1
  67. package/src/cli.ts +4 -2
  68. package/src/cmd/ai/prompt/api.ts +5 -4
  69. package/src/cmd/auth/ssh/api.ts +1 -4
  70. package/src/cmd/build/ast.ts +21 -6
  71. package/src/cmd/build/bundler.ts +30 -11
  72. package/src/cmd/build/plugin.ts +108 -82
  73. package/src/cmd/build/route-discovery.ts +197 -0
  74. package/src/cmd/build/route-registry.ts +26 -10
  75. package/src/cmd/cloud/deploy.ts +19 -6
  76. package/src/cmd/dev/agents.ts +2 -8
  77. package/src/cmd/dev/index.ts +25 -0
  78. package/src/cmd/dev/sync.ts +2 -10
  79. package/src/cmd/project/download.ts +16 -2
  80. package/src/cmd/project/list.ts +2 -9
  81. package/src/index.ts +2 -2
  82. package/src/steps.ts +397 -229
  83. package/src/tui/box.ts +8 -4
  84. package/src/tui/prompt.ts +7 -4
  85. package/src/tui.ts +6 -4
@@ -6,7 +6,14 @@ import { tmpdir } from 'node:os';
6
6
  import { createSubcommand } from '../../types';
7
7
  import * as tui from '../../tui';
8
8
  import { saveProjectDir, getDefaultConfigDir } from '../../config';
9
- import { runSteps, stepSuccess, stepSkipped, stepError, Step, ProgressCallback } from '../../steps';
9
+ import {
10
+ runSteps,
11
+ stepSuccess,
12
+ stepSkipped,
13
+ stepError,
14
+ type Step,
15
+ type StepContext,
16
+ } from '../../steps';
10
17
  import { bundle } from '../build/bundler';
11
18
  import { loadBuildMetadata, getStreamURL } from '../../config';
12
19
  import {
@@ -179,8 +186,9 @@ export const deploySubcommand = createSubcommand({
179
186
  if (!deployment) {
180
187
  return stepError('deployment was null');
181
188
  }
189
+ let capturedOutput: string[] = [];
182
190
  try {
183
- await bundle({
191
+ const bundleResult = await bundle({
184
192
  rootDir: resolve(projectDir),
185
193
  dev: false,
186
194
  deploymentId: deployment.id,
@@ -195,23 +203,28 @@ export const deploySubcommand = createSubcommand({
195
203
  region: project.region,
196
204
  logger: ctx.logger,
197
205
  });
206
+ capturedOutput = bundleResult.output;
198
207
  build = await loadBuildMetadata(join(projectDir, '.agentuity'));
199
208
  instructions = await projectDeploymentUpdate(
200
209
  apiClient,
201
210
  deployment.id,
202
211
  build
203
212
  );
204
- return stepSuccess();
213
+ return stepSuccess(capturedOutput.length > 0 ? capturedOutput : undefined);
205
214
  } catch (ex) {
206
215
  const _ex = ex as Error;
207
- return stepError(_ex.message ?? 'Error building your project');
216
+ return stepError(
217
+ _ex.message ?? 'Error building your project',
218
+ _ex,
219
+ capturedOutput.length > 0 ? capturedOutput : undefined
220
+ );
208
221
  }
209
222
  },
210
223
  },
211
224
  {
212
- type: 'progress',
213
225
  label: 'Encrypt and Upload Deployment',
214
- run: async (progress: ProgressCallback) => {
226
+ run: async (stepCtx: StepContext) => {
227
+ const progress = stepCtx.progress;
215
228
  if (!deployment) {
216
229
  return stepError('deployment was null');
217
230
  }
@@ -63,15 +63,9 @@ export const agentsSubcommand = createSubcommand({
63
63
  const queryParams = deploymentId ? `?deploymentId=${deploymentId}` : '';
64
64
 
65
65
  const response = options.json
66
- ? await apiClient.get(
67
- `/cli/agent/${projectId}${queryParams}`,
68
- AgentsResponseSchema
69
- )
66
+ ? await apiClient.get(`/cli/agent/${projectId}${queryParams}`, AgentsResponseSchema)
70
67
  : await tui.spinner('Fetching agents', async () => {
71
- return apiClient.get(
72
- `/cli/agent/${projectId}${queryParams}`,
73
- AgentsResponseSchema
74
- );
68
+ return apiClient.get(`/cli/agent/${projectId}${queryParams}`, AgentsResponseSchema);
75
69
  });
76
70
 
77
71
  if (!response.success) {
@@ -256,6 +256,7 @@ export const command = createCommand({
256
256
  let building = false;
257
257
  let buildCompletedAt = 0;
258
258
  const BUILD_COOLDOWN_MS = 500; // Ignore file changes for 500ms after build completes
259
+ const templatedDirectories = new Map<string, number>(); // Track directories that just had templates created
259
260
  let metadata: Partial<BuildMetadata> | undefined;
260
261
  let showInitialReadyMessage = true;
261
262
  let serverStartTime = 0;
@@ -997,6 +998,7 @@ export const command = createCommand({
997
998
  }
998
999
  }
999
1000
 
1001
+ // Handle new empty directories in src/agent/ or src/api/ paths
1000
1002
  if (
1001
1003
  eventType === 'rename' &&
1002
1004
  existsSync(absPath) &&
@@ -1006,9 +1008,32 @@ export const command = createCommand({
1006
1008
  if (changedFile?.startsWith('src/agent/')) {
1007
1009
  logger.debug('agent directory created: %s', changedFile);
1008
1010
  createAgentTemplates(absPath);
1011
+ // Mark this directory as recently templated to avoid immediate rebuild
1012
+ templatedDirectories.set(absPath, Date.now());
1013
+ // Schedule cleanup of this marker after enough time for file events
1014
+ setTimeout(() => templatedDirectories.delete(absPath), 1000);
1015
+ // Don't restart - wait for the template files to trigger the rebuild
1016
+ return;
1009
1017
  } else if (changedFile?.startsWith('src/api/')) {
1010
1018
  logger.debug('api directory created: %s', changedFile);
1011
1019
  createAPITemplates(absPath);
1020
+ // Mark this directory as recently templated to avoid immediate rebuild
1021
+ templatedDirectories.set(absPath, Date.now());
1022
+ // Schedule cleanup of this marker after enough time for file events
1023
+ setTimeout(() => templatedDirectories.delete(absPath), 1000);
1024
+ // Don't restart - wait for the template files to trigger the rebuild
1025
+ return;
1026
+ }
1027
+ }
1028
+
1029
+ // Check if this file/directory was just templated - skip restart to avoid race condition
1030
+ for (const [templatedPath, timestamp] of templatedDirectories.entries()) {
1031
+ if (absPath.startsWith(templatedPath) && Date.now() - timestamp < 500) {
1032
+ logger.trace(
1033
+ 'Ignoring event in recently templated directory: %s',
1034
+ templatedPath
1035
+ );
1036
+ return;
1012
1037
  }
1013
1038
  }
1014
1039
 
@@ -253,11 +253,7 @@ class DevmodeSyncService implements IDevmodeSyncService {
253
253
  JSON.stringify(payload, null, 2)
254
254
  );
255
255
 
256
- await this.apiClient.post(
257
- '/cli/devmode/agent',
258
- payload,
259
- z.object({ success: z.boolean() })
260
- );
256
+ await this.apiClient.post('/cli/devmode/agent', payload, z.object({ success: z.boolean() }));
261
257
  }
262
258
 
263
259
  private async syncEvals(
@@ -279,11 +275,7 @@ class DevmodeSyncService implements IDevmodeSyncService {
279
275
  JSON.stringify(payload, null, 2)
280
276
  );
281
277
 
282
- await this.apiClient.post(
283
- '/cli/devmode/eval',
284
- payload,
285
- z.object({ success: z.boolean() })
286
- );
278
+ await this.apiClient.post('/cli/devmode/eval', payload, z.object({ success: z.boolean() }));
287
279
  }
288
280
  }
289
281
 
@@ -230,11 +230,25 @@ export async function setupProject(options: SetupOptions): Promise<void> {
230
230
  // Initialize git repository if git is available
231
231
  const gitPath = Bun.which('git');
232
232
  if (gitPath) {
233
+ // Get default branch from git config, fallback to 'main'
234
+ let defaultBranch = 'main';
235
+ try {
236
+ const result = Bun.spawnSync(['git', 'config', '--global', 'init.defaultBranch']);
237
+ if (result.exitCode === 0) {
238
+ const branch = result.stdout.toString().trim();
239
+ if (branch) {
240
+ defaultBranch = branch;
241
+ }
242
+ }
243
+ } catch {
244
+ // Ignore errors, use fallback
245
+ }
246
+
233
247
  // Git is available, initialize repository
234
248
  await tui.runCommand({
235
- command: 'git init',
249
+ command: `git init -b ${defaultBranch}`,
236
250
  cwd: dest,
237
- cmd: ['git', 'init'],
251
+ cmd: ['git', 'init', '-b', defaultBranch],
238
252
  clearOnSuccess: true,
239
253
  });
240
254
 
@@ -43,16 +43,9 @@ export const listSubcommand = createSubcommand({
43
43
  },
44
44
  });
45
45
 
46
- // TODO: might want to sort by the last org_id we used
47
- if (projects) {
48
- projects.sort((a, b) => {
49
- return a.name.localeCompare(b.name);
50
- });
51
- }
46
+ // Projects are sorted by createdAt (most recent first) from the API
52
47
 
53
- if (options.json) {
54
- console.log(JSON.stringify(projects, null, 2));
55
- } else {
48
+ if (!options.json) {
56
49
  tui.table(projects, ['id', 'name', 'orgName']);
57
50
  }
58
51
 
package/src/index.ts CHANGED
@@ -83,7 +83,7 @@ export {
83
83
  type CommandHandler,
84
84
  type TableColumn,
85
85
  } from './repl';
86
- export { runSteps, setStepsColorScheme, stepSuccess, stepSkipped, stepError } from './steps';
86
+ export { runSteps, stepSuccess, stepSkipped, stepError } from './steps';
87
87
  export { playSound } from './sound';
88
88
  export {
89
89
  downloadWithProgress,
@@ -105,4 +105,4 @@ export type {
105
105
  } from './types';
106
106
  export { createSubcommand, createCommand } from './types';
107
107
  export type { ColorScheme } from './terminal';
108
- export type { Step, SimpleStep, ProgressStep, StepOutcome, ProgressCallback } from './steps';
108
+ export type { Step, StepOutcome, StepContext } from './steps';