@agentuity/cli 1.0.32 → 1.0.33

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 (257) hide show
  1. package/dist/catalyst.d.ts +3 -1
  2. package/dist/catalyst.d.ts.map +1 -1
  3. package/dist/catalyst.js +5 -1
  4. package/dist/catalyst.js.map +1 -1
  5. package/dist/cmd/cloud/db/create.d.ts.map +1 -1
  6. package/dist/cmd/cloud/db/create.js +8 -10
  7. package/dist/cmd/cloud/db/create.js.map +1 -1
  8. package/dist/cmd/cloud/db/delete.d.ts.map +1 -1
  9. package/dist/cmd/cloud/db/delete.js +12 -14
  10. package/dist/cmd/cloud/db/delete.js.map +1 -1
  11. package/dist/cmd/cloud/db/get.d.ts.map +1 -1
  12. package/dist/cmd/cloud/db/get.js +7 -7
  13. package/dist/cmd/cloud/db/get.js.map +1 -1
  14. package/dist/cmd/cloud/db/list.d.ts.map +1 -1
  15. package/dist/cmd/cloud/db/list.js +5 -5
  16. package/dist/cmd/cloud/db/list.js.map +1 -1
  17. package/dist/cmd/cloud/db/logs.d.ts.map +1 -1
  18. package/dist/cmd/cloud/db/logs.js +7 -7
  19. package/dist/cmd/cloud/db/logs.js.map +1 -1
  20. package/dist/cmd/cloud/db/sql.js +5 -5
  21. package/dist/cmd/cloud/db/sql.js.map +1 -1
  22. package/dist/cmd/cloud/db/stats.d.ts.map +1 -1
  23. package/dist/cmd/cloud/db/stats.js +5 -5
  24. package/dist/cmd/cloud/db/stats.js.map +1 -1
  25. package/dist/cmd/cloud/deploy.d.ts.map +1 -1
  26. package/dist/cmd/cloud/deploy.js +1 -1
  27. package/dist/cmd/cloud/deploy.js.map +1 -1
  28. package/dist/cmd/cloud/email/stats.d.ts.map +1 -1
  29. package/dist/cmd/cloud/email/stats.js +5 -5
  30. package/dist/cmd/cloud/email/stats.js.map +1 -1
  31. package/dist/cmd/cloud/email/util.d.ts +2 -2
  32. package/dist/cmd/cloud/email/util.d.ts.map +1 -1
  33. package/dist/cmd/cloud/email/util.js +2 -2
  34. package/dist/cmd/cloud/email/util.js.map +1 -1
  35. package/dist/cmd/cloud/keyvalue/util.d.ts.map +1 -1
  36. package/dist/cmd/cloud/keyvalue/util.js +1 -1
  37. package/dist/cmd/cloud/keyvalue/util.js.map +1 -1
  38. package/dist/cmd/cloud/machine/delete.d.ts.map +1 -1
  39. package/dist/cmd/cloud/machine/delete.js +6 -6
  40. package/dist/cmd/cloud/machine/delete.js.map +1 -1
  41. package/dist/cmd/cloud/machine/deployments.d.ts.map +1 -1
  42. package/dist/cmd/cloud/machine/deployments.js +5 -5
  43. package/dist/cmd/cloud/machine/deployments.js.map +1 -1
  44. package/dist/cmd/cloud/machine/get.d.ts.map +1 -1
  45. package/dist/cmd/cloud/machine/get.js +5 -5
  46. package/dist/cmd/cloud/machine/get.js.map +1 -1
  47. package/dist/cmd/cloud/machine/list.d.ts.map +1 -1
  48. package/dist/cmd/cloud/machine/list.js +5 -5
  49. package/dist/cmd/cloud/machine/list.js.map +1 -1
  50. package/dist/cmd/cloud/queue/util.d.ts +1 -1
  51. package/dist/cmd/cloud/queue/util.d.ts.map +1 -1
  52. package/dist/cmd/cloud/queue/util.js +1 -1
  53. package/dist/cmd/cloud/queue/util.js.map +1 -1
  54. package/dist/cmd/cloud/redis/get.js +5 -5
  55. package/dist/cmd/cloud/redis/get.js.map +1 -1
  56. package/dist/cmd/cloud/sandbox/execution/get.d.ts.map +1 -1
  57. package/dist/cmd/cloud/sandbox/execution/get.js +4 -4
  58. package/dist/cmd/cloud/sandbox/execution/get.js.map +1 -1
  59. package/dist/cmd/cloud/sandbox/execution/list.d.ts.map +1 -1
  60. package/dist/cmd/cloud/sandbox/execution/list.js +5 -5
  61. package/dist/cmd/cloud/sandbox/execution/list.js.map +1 -1
  62. package/dist/cmd/cloud/sandbox/runtime/list.d.ts.map +1 -1
  63. package/dist/cmd/cloud/sandbox/runtime/list.js +4 -4
  64. package/dist/cmd/cloud/sandbox/runtime/list.js.map +1 -1
  65. package/dist/cmd/cloud/sandbox/snapshot/build.js +1 -1
  66. package/dist/cmd/cloud/sandbox/snapshot/build.js.map +1 -1
  67. package/dist/cmd/cloud/sandbox/snapshot/create.d.ts.map +1 -1
  68. package/dist/cmd/cloud/sandbox/snapshot/create.js +5 -5
  69. package/dist/cmd/cloud/sandbox/snapshot/create.js.map +1 -1
  70. package/dist/cmd/cloud/sandbox/snapshot/delete.d.ts.map +1 -1
  71. package/dist/cmd/cloud/sandbox/snapshot/delete.js +4 -4
  72. package/dist/cmd/cloud/sandbox/snapshot/delete.js.map +1 -1
  73. package/dist/cmd/cloud/sandbox/snapshot/get.d.ts.map +1 -1
  74. package/dist/cmd/cloud/sandbox/snapshot/get.js +4 -4
  75. package/dist/cmd/cloud/sandbox/snapshot/get.js.map +1 -1
  76. package/dist/cmd/cloud/sandbox/snapshot/list.d.ts.map +1 -1
  77. package/dist/cmd/cloud/sandbox/snapshot/list.js +4 -4
  78. package/dist/cmd/cloud/sandbox/snapshot/list.js.map +1 -1
  79. package/dist/cmd/cloud/sandbox/snapshot/tag.d.ts.map +1 -1
  80. package/dist/cmd/cloud/sandbox/snapshot/tag.js +4 -4
  81. package/dist/cmd/cloud/sandbox/snapshot/tag.js.map +1 -1
  82. package/dist/cmd/cloud/sandbox/stats.d.ts.map +1 -1
  83. package/dist/cmd/cloud/sandbox/stats.js +5 -5
  84. package/dist/cmd/cloud/sandbox/stats.js.map +1 -1
  85. package/dist/cmd/cloud/sandbox/util.d.ts +3 -3
  86. package/dist/cmd/cloud/sandbox/util.d.ts.map +1 -1
  87. package/dist/cmd/cloud/sandbox/util.js +5 -5
  88. package/dist/cmd/cloud/sandbox/util.js.map +1 -1
  89. package/dist/cmd/cloud/schedule/stats.d.ts.map +1 -1
  90. package/dist/cmd/cloud/schedule/stats.js +5 -5
  91. package/dist/cmd/cloud/schedule/stats.js.map +1 -1
  92. package/dist/cmd/cloud/schedule/util.d.ts +1 -1
  93. package/dist/cmd/cloud/schedule/util.d.ts.map +1 -1
  94. package/dist/cmd/cloud/schedule/util.js +1 -1
  95. package/dist/cmd/cloud/schedule/util.js.map +1 -1
  96. package/dist/cmd/cloud/services/stats.d.ts.map +1 -1
  97. package/dist/cmd/cloud/services/stats.js +5 -5
  98. package/dist/cmd/cloud/services/stats.js.map +1 -1
  99. package/dist/cmd/cloud/session/get.d.ts.map +1 -1
  100. package/dist/cmd/cloud/session/get.js +5 -5
  101. package/dist/cmd/cloud/session/get.js.map +1 -1
  102. package/dist/cmd/cloud/session/list.d.ts.map +1 -1
  103. package/dist/cmd/cloud/session/list.js +5 -5
  104. package/dist/cmd/cloud/session/list.js.map +1 -1
  105. package/dist/cmd/cloud/storage/config.d.ts.map +1 -1
  106. package/dist/cmd/cloud/storage/config.js +7 -7
  107. package/dist/cmd/cloud/storage/config.js.map +1 -1
  108. package/dist/cmd/cloud/storage/create.d.ts.map +1 -1
  109. package/dist/cmd/cloud/storage/create.js +8 -10
  110. package/dist/cmd/cloud/storage/create.js.map +1 -1
  111. package/dist/cmd/cloud/storage/delete.d.ts.map +1 -1
  112. package/dist/cmd/cloud/storage/delete.js +12 -14
  113. package/dist/cmd/cloud/storage/delete.js.map +1 -1
  114. package/dist/cmd/cloud/storage/download.d.ts.map +1 -1
  115. package/dist/cmd/cloud/storage/download.js +6 -6
  116. package/dist/cmd/cloud/storage/download.js.map +1 -1
  117. package/dist/cmd/cloud/storage/get.d.ts.map +1 -1
  118. package/dist/cmd/cloud/storage/get.js +6 -6
  119. package/dist/cmd/cloud/storage/get.js.map +1 -1
  120. package/dist/cmd/cloud/storage/list.d.ts.map +1 -1
  121. package/dist/cmd/cloud/storage/list.js +6 -6
  122. package/dist/cmd/cloud/storage/list.js.map +1 -1
  123. package/dist/cmd/cloud/storage/upload.d.ts.map +1 -1
  124. package/dist/cmd/cloud/storage/upload.js +7 -7
  125. package/dist/cmd/cloud/storage/upload.js.map +1 -1
  126. package/dist/cmd/cloud/stream/create.js +1 -1
  127. package/dist/cmd/cloud/stream/create.js.map +1 -1
  128. package/dist/cmd/cloud/stream/stats.d.ts.map +1 -1
  129. package/dist/cmd/cloud/stream/stats.js +5 -5
  130. package/dist/cmd/cloud/stream/stats.js.map +1 -1
  131. package/dist/cmd/cloud/task/stats.d.ts.map +1 -1
  132. package/dist/cmd/cloud/task/stats.js +5 -5
  133. package/dist/cmd/cloud/task/stats.js.map +1 -1
  134. package/dist/cmd/cloud/task/util.d.ts +1 -1
  135. package/dist/cmd/cloud/task/util.d.ts.map +1 -1
  136. package/dist/cmd/cloud/task/util.js +2 -2
  137. package/dist/cmd/cloud/task/util.js.map +1 -1
  138. package/dist/cmd/cloud/thread/delete.d.ts.map +1 -1
  139. package/dist/cmd/cloud/thread/delete.js +5 -5
  140. package/dist/cmd/cloud/thread/delete.js.map +1 -1
  141. package/dist/cmd/cloud/thread/get.d.ts.map +1 -1
  142. package/dist/cmd/cloud/thread/get.js +5 -5
  143. package/dist/cmd/cloud/thread/get.js.map +1 -1
  144. package/dist/cmd/cloud/thread/list.d.ts.map +1 -1
  145. package/dist/cmd/cloud/thread/list.js +5 -5
  146. package/dist/cmd/cloud/thread/list.js.map +1 -1
  147. package/dist/cmd/cloud/vector/util.d.ts.map +1 -1
  148. package/dist/cmd/cloud/vector/util.js +1 -1
  149. package/dist/cmd/cloud/vector/util.js.map +1 -1
  150. package/dist/cmd/cloud/webhook/util.d.ts +1 -1
  151. package/dist/cmd/cloud/webhook/util.d.ts.map +1 -1
  152. package/dist/cmd/cloud/webhook/util.js +1 -1
  153. package/dist/cmd/cloud/webhook/util.js.map +1 -1
  154. package/dist/cmd/git/api.d.ts +38 -0
  155. package/dist/cmd/git/api.d.ts.map +1 -1
  156. package/dist/cmd/git/api.js +55 -0
  157. package/dist/cmd/git/api.js.map +1 -1
  158. package/dist/cmd/project/add/database.js +8 -8
  159. package/dist/cmd/project/add/database.js.map +1 -1
  160. package/dist/cmd/project/add/storage.js +8 -8
  161. package/dist/cmd/project/add/storage.js.map +1 -1
  162. package/dist/cmd/project/auth/init.d.ts.map +1 -1
  163. package/dist/cmd/project/auth/init.js +7 -6
  164. package/dist/cmd/project/auth/init.js.map +1 -1
  165. package/dist/cmd/project/auth/shared.d.ts +2 -3
  166. package/dist/cmd/project/auth/shared.d.ts.map +1 -1
  167. package/dist/cmd/project/auth/shared.js +7 -7
  168. package/dist/cmd/project/auth/shared.js.map +1 -1
  169. package/dist/cmd/project/download.d.ts +12 -1
  170. package/dist/cmd/project/download.d.ts.map +1 -1
  171. package/dist/cmd/project/download.js +37 -14
  172. package/dist/cmd/project/download.js.map +1 -1
  173. package/dist/cmd/project/import.d.ts.map +1 -1
  174. package/dist/cmd/project/import.js +67 -9
  175. package/dist/cmd/project/import.js.map +1 -1
  176. package/dist/cmd/project/remote-import.d.ts +41 -0
  177. package/dist/cmd/project/remote-import.d.ts.map +1 -0
  178. package/dist/cmd/project/remote-import.js +1074 -0
  179. package/dist/cmd/project/remote-import.js.map +1 -0
  180. package/dist/cmd/project/template-flow.d.ts +1 -1
  181. package/dist/cmd/project/template-flow.d.ts.map +1 -1
  182. package/dist/cmd/project/template-flow.js +27 -11
  183. package/dist/cmd/project/template-flow.js.map +1 -1
  184. package/dist/config.d.ts +29 -5
  185. package/dist/config.d.ts.map +1 -1
  186. package/dist/config.js +13 -14
  187. package/dist/config.js.map +1 -1
  188. package/dist/schema-parser.d.ts.map +1 -1
  189. package/dist/schema-parser.js +47 -5
  190. package/dist/schema-parser.js.map +1 -1
  191. package/dist/types.d.ts +28 -3
  192. package/dist/types.d.ts.map +1 -1
  193. package/dist/types.js +42 -0
  194. package/dist/types.js.map +1 -1
  195. package/package.json +6 -6
  196. package/src/catalyst.ts +9 -1
  197. package/src/cmd/cloud/db/create.ts +8 -9
  198. package/src/cmd/cloud/db/delete.ts +18 -13
  199. package/src/cmd/cloud/db/get.ts +13 -7
  200. package/src/cmd/cloud/db/list.ts +11 -5
  201. package/src/cmd/cloud/db/logs.ts +13 -7
  202. package/src/cmd/cloud/db/sql.ts +5 -5
  203. package/src/cmd/cloud/db/stats.ts +11 -5
  204. package/src/cmd/cloud/deploy.ts +7 -1
  205. package/src/cmd/cloud/email/stats.ts +11 -5
  206. package/src/cmd/cloud/email/util.ts +4 -4
  207. package/src/cmd/cloud/keyvalue/util.ts +2 -2
  208. package/src/cmd/cloud/machine/delete.ts +12 -6
  209. package/src/cmd/cloud/machine/deployments.ts +11 -5
  210. package/src/cmd/cloud/machine/get.ts +11 -5
  211. package/src/cmd/cloud/machine/list.ts +11 -5
  212. package/src/cmd/cloud/queue/util.ts +2 -2
  213. package/src/cmd/cloud/redis/get.ts +5 -5
  214. package/src/cmd/cloud/sandbox/execution/get.ts +10 -4
  215. package/src/cmd/cloud/sandbox/execution/list.ts +6 -5
  216. package/src/cmd/cloud/sandbox/runtime/list.ts +10 -4
  217. package/src/cmd/cloud/sandbox/snapshot/build.ts +1 -1
  218. package/src/cmd/cloud/sandbox/snapshot/create.ts +12 -5
  219. package/src/cmd/cloud/sandbox/snapshot/delete.ts +10 -4
  220. package/src/cmd/cloud/sandbox/snapshot/get.ts +12 -6
  221. package/src/cmd/cloud/sandbox/snapshot/list.ts +10 -4
  222. package/src/cmd/cloud/sandbox/snapshot/tag.ts +10 -4
  223. package/src/cmd/cloud/sandbox/stats.ts +11 -5
  224. package/src/cmd/cloud/sandbox/util.ts +14 -7
  225. package/src/cmd/cloud/schedule/stats.ts +11 -5
  226. package/src/cmd/cloud/schedule/util.ts +3 -3
  227. package/src/cmd/cloud/services/stats.ts +13 -7
  228. package/src/cmd/cloud/session/get.ts +14 -8
  229. package/src/cmd/cloud/session/list.ts +11 -5
  230. package/src/cmd/cloud/storage/config.ts +24 -12
  231. package/src/cmd/cloud/storage/create.ts +8 -9
  232. package/src/cmd/cloud/storage/delete.ts +18 -13
  233. package/src/cmd/cloud/storage/download.ts +12 -6
  234. package/src/cmd/cloud/storage/get.ts +12 -6
  235. package/src/cmd/cloud/storage/list.ts +12 -6
  236. package/src/cmd/cloud/storage/upload.ts +13 -7
  237. package/src/cmd/cloud/stream/create.ts +1 -1
  238. package/src/cmd/cloud/stream/stats.ts +11 -5
  239. package/src/cmd/cloud/task/stats.ts +11 -5
  240. package/src/cmd/cloud/task/util.ts +4 -4
  241. package/src/cmd/cloud/thread/delete.ts +11 -5
  242. package/src/cmd/cloud/thread/get.ts +11 -5
  243. package/src/cmd/cloud/thread/list.ts +11 -5
  244. package/src/cmd/cloud/vector/util.ts +2 -2
  245. package/src/cmd/cloud/webhook/util.ts +2 -2
  246. package/src/cmd/git/api.ts +127 -0
  247. package/src/cmd/project/add/database.ts +9 -9
  248. package/src/cmd/project/add/storage.ts +9 -9
  249. package/src/cmd/project/auth/init.ts +11 -10
  250. package/src/cmd/project/auth/shared.ts +15 -10
  251. package/src/cmd/project/download.ts +52 -16
  252. package/src/cmd/project/import.ts +71 -9
  253. package/src/cmd/project/remote-import.ts +1347 -0
  254. package/src/cmd/project/template-flow.ts +38 -22
  255. package/src/config.ts +23 -18
  256. package/src/schema-parser.ts +48 -5
  257. package/src/types.ts +45 -0
@@ -315,3 +315,130 @@ export async function getProjectGithubStatus(
315
315
 
316
316
  return resp.data;
317
317
  }
318
+
319
+ // ─── GitHub Token ───
320
+
321
+ const GithubTokenDataSchema = z.object({
322
+ token: z.string(),
323
+ username: z.string(),
324
+ });
325
+
326
+ export type GithubTokenResult = z.infer<typeof GithubTokenDataSchema>;
327
+
328
+ const GithubTokenError = StructuredError(
329
+ 'GithubTokenError',
330
+ 'Failed to retrieve GitHub token from Agentuity'
331
+ );
332
+
333
+ export async function getGithubToken(apiClient: APIClient): Promise<GithubTokenResult> {
334
+ const resp = await apiClient.get('/cli/github/token', APIResponseSchema(GithubTokenDataSchema));
335
+
336
+ if (!resp.success || !resp.data) {
337
+ throw new GithubTokenError();
338
+ }
339
+
340
+ return resp.data;
341
+ }
342
+
343
+ const GithubRepoCheckDataSchema = z.object({
344
+ available: z.boolean(),
345
+ exists: z.boolean(),
346
+ error: z.string().optional(),
347
+ });
348
+
349
+ export type GithubRepoCheckResult = z.infer<typeof GithubRepoCheckDataSchema>;
350
+
351
+ const GithubRepoCheckError = StructuredError(
352
+ 'GithubRepoCheckError',
353
+ 'Error checking GitHub repository availability'
354
+ );
355
+
356
+ export async function checkGithubRepo(
357
+ apiClient: APIClient,
358
+ params: { owner: string; name: string }
359
+ ): Promise<GithubRepoCheckResult> {
360
+ const resp = await apiClient.get(
361
+ `/cli/github/repo/check?owner=${encodeURIComponent(params.owner)}&name=${encodeURIComponent(params.name)}`,
362
+ APIResponseSchema(GithubRepoCheckDataSchema)
363
+ );
364
+
365
+ if (!resp.success || !resp.data) {
366
+ throw new GithubRepoCheckError();
367
+ }
368
+
369
+ return resp.data;
370
+ }
371
+
372
+ // Repo creation
373
+
374
+ const GithubRepoCreateDataSchema = z.object({
375
+ url: z.string(),
376
+ cloneUrl: z.string(),
377
+ fullName: z.string(),
378
+ private: z.boolean(),
379
+ created: z.boolean(),
380
+ });
381
+
382
+ export interface GithubRepoCreateResult {
383
+ url: string;
384
+ cloneUrl: string;
385
+ fullName: string;
386
+ private: boolean;
387
+ created: boolean;
388
+ }
389
+
390
+ export interface GithubRepoCreateOptions {
391
+ name: string;
392
+ owner: string;
393
+ private: boolean;
394
+ description?: string;
395
+ }
396
+
397
+ const GithubRepoCreateError = StructuredError(
398
+ 'GithubRepoCreateError',
399
+ 'Error creating GitHub repository'
400
+ );
401
+
402
+ export async function createGithubRepo(
403
+ apiClient: APIClient,
404
+ params: GithubRepoCreateOptions
405
+ ): Promise<GithubRepoCreateResult> {
406
+ const resp = await apiClient.post(
407
+ '/cli/github/repo',
408
+ params,
409
+ APIResponseSchema(GithubRepoCreateDataSchema)
410
+ );
411
+
412
+ if (!resp.success || !resp.data) {
413
+ throw new GithubRepoCreateError();
414
+ }
415
+
416
+ return resp.data;
417
+ }
418
+
419
+ // ─── Bot Identity ───
420
+
421
+ const GithubBotIdentityDataSchema = z.object({
422
+ name: z.string(),
423
+ email: z.string(),
424
+ });
425
+
426
+ export type GithubBotIdentity = z.infer<typeof GithubBotIdentityDataSchema>;
427
+
428
+ const GithubBotIdentityError = StructuredError(
429
+ 'GithubBotIdentityError',
430
+ 'Error fetching GitHub App bot identity'
431
+ );
432
+
433
+ export async function getGithubBotIdentity(apiClient: APIClient): Promise<GithubBotIdentity> {
434
+ const resp = await apiClient.get(
435
+ '/cli/github/bot-identity',
436
+ APIResponseSchema(GithubBotIdentityDataSchema)
437
+ );
438
+
439
+ if (!resp.success || !resp.data) {
440
+ throw new GithubBotIdentityError();
441
+ }
442
+
443
+ return resp.data;
444
+ }
@@ -1,19 +1,19 @@
1
- import { z } from 'zod';
2
1
  import { listResources, projectEnvUpdate } from '@agentuity/server';
3
- import { createSubcommand } from '../../../types';
4
- import * as tui from '../../../tui';
5
- import { createPrompt } from '../../../tui';
6
- import { getCatalystAPIClient } from '../../../config';
2
+ import { z } from 'zod';
7
3
  import { getCommand } from '../../../command-prefix';
8
- import { isDryRunMode, outputDryRun } from '../../../explain';
9
- import { ErrorCode } from '../../../errors';
4
+ import { getCatalystAPIClient } from '../../../config';
10
5
  import {
11
6
  addResourceEnvVars,
7
+ filterAgentuitySdkKeys,
12
8
  findExistingEnvFile,
13
9
  readEnvFile,
14
- filterAgentuitySdkKeys,
15
10
  splitEnvAndSecrets,
16
11
  } from '../../../env-util';
12
+ import { ErrorCode } from '../../../errors';
13
+ import { isDryRunMode, outputDryRun } from '../../../explain';
14
+ import * as tui from '../../../tui';
15
+ import { createPrompt } from '../../../tui';
16
+ import { createSubcommand } from '../../../types';
17
17
 
18
18
  export const databaseSubcommand = createSubcommand({
19
19
  name: 'database',
@@ -65,7 +65,7 @@ export const databaseSubcommand = createSubcommand({
65
65
  };
66
66
  }
67
67
 
68
- const catalystClient = getCatalystAPIClient(logger, auth, region);
68
+ const catalystClient = getCatalystAPIClient(logger, auth, region, undefined, ctx.config);
69
69
 
70
70
  const resources = await tui.spinner({
71
71
  message: 'Fetching databases',
@@ -1,19 +1,19 @@
1
- import { z } from 'zod';
2
1
  import { listResources, projectEnvUpdate } from '@agentuity/server';
3
- import { createSubcommand } from '../../../types';
4
- import * as tui from '../../../tui';
5
- import { createPrompt } from '../../../tui';
6
- import { getCatalystAPIClient } from '../../../config';
2
+ import { z } from 'zod';
7
3
  import { getCommand } from '../../../command-prefix';
8
- import { isDryRunMode, outputDryRun } from '../../../explain';
9
- import { ErrorCode } from '../../../errors';
4
+ import { getCatalystAPIClient } from '../../../config';
10
5
  import {
11
6
  addResourceEnvVars,
7
+ filterAgentuitySdkKeys,
12
8
  findExistingEnvFile,
13
9
  readEnvFile,
14
- filterAgentuitySdkKeys,
15
10
  splitEnvAndSecrets,
16
11
  } from '../../../env-util';
12
+ import { ErrorCode } from '../../../errors';
13
+ import { isDryRunMode, outputDryRun } from '../../../explain';
14
+ import * as tui from '../../../tui';
15
+ import { createPrompt } from '../../../tui';
16
+ import { createSubcommand } from '../../../types';
17
17
 
18
18
  export const storageSubcommand = createSubcommand({
19
19
  name: 'storage',
@@ -65,7 +65,7 @@ export const storageSubcommand = createSubcommand({
65
65
  };
66
66
  }
67
67
 
68
- const catalystClient = getCatalystAPIClient(logger, auth, region);
68
+ const catalystClient = getCatalystAPIClient(logger, auth, region, undefined, ctx.config);
69
69
 
70
70
  const resources = await tui.spinner({
71
71
  message: 'Fetching storage buckets',
@@ -1,21 +1,21 @@
1
+ import enquirer from 'enquirer';
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
1
4
  import { z } from 'zod';
2
- import { createSubcommand } from '../../../types';
3
- import * as tui from '../../../tui';
4
5
  import { getCommand } from '../../../command-prefix';
6
+ import { readEnvFile, writeEnvFile } from '../../../env-util';
7
+ import * as tui from '../../../tui';
8
+ import { createSubcommand } from '../../../types';
5
9
  import {
6
- selectOrCreateDatabase,
10
+ detectOrmSetup,
7
11
  ensureAuthDependencies,
8
- runAuthMigrations,
9
12
  generateAuthFileContent,
10
- printIntegrationExamples,
11
- detectOrmSetup,
12
13
  generateAuthSchemaSql,
13
14
  getGeneratedSqlDir,
15
+ printIntegrationExamples,
16
+ runAuthMigrations,
17
+ selectOrCreateDatabase,
14
18
  } from './shared';
15
- import { readEnvFile, writeEnvFile } from '../../../env-util';
16
- import enquirer from 'enquirer';
17
- import * as fs from 'fs';
18
- import * as path from 'path';
19
19
 
20
20
  export const initSubcommand = createSubcommand({
21
21
  name: 'init',
@@ -232,6 +232,7 @@ export const initSubcommand = createSubcommand({
232
232
  region,
233
233
  databaseName,
234
234
  sql,
235
+ config,
235
236
  });
236
237
  migrationsRun = true;
237
238
  }
@@ -3,18 +3,16 @@
3
3
  */
4
4
 
5
5
  import * as path from 'node:path';
6
- import { listOrgResources, createResources, dbQuery } from '@agentuity/server';
7
- import * as tui from '../../../tui';
6
+ import { createResources, dbQuery, listOrgResources } from '@agentuity/server';
7
+ import enquirer from 'enquirer';
8
8
  import {
9
9
  getCatalystAPIClient,
10
10
  getGlobalCatalystAPIClient,
11
11
  loadProjectConfig,
12
12
  ProjectConfigNotFoundException,
13
13
  } from '../../../config';
14
- import type { Logger } from '../../../types';
15
- import type { AuthData } from '../../../types';
16
- import type { Config } from '../../../types';
17
- import enquirer from 'enquirer';
14
+ import * as tui from '../../../tui';
15
+ import type { AuthData, Config, Logger } from '../../../types';
18
16
 
19
17
  /**
20
18
  * Database info returned from selection
@@ -39,7 +37,13 @@ export async function selectOrCreateDatabase(options: {
39
37
  }): Promise<DatabaseInfo> {
40
38
  const { logger, auth, orgId, config, existingUrl, projectDir } = options;
41
39
  const profileName = config?.name;
42
- const globalClient = await getGlobalCatalystAPIClient(logger, auth, profileName);
40
+ const globalClient = await getGlobalCatalystAPIClient(
41
+ logger,
42
+ auth,
43
+ profileName,
44
+ undefined,
45
+ config
46
+ );
43
47
 
44
48
  const resources = await tui.spinner({
45
49
  message: `Fetching databases for ${orgId}`,
@@ -122,7 +126,7 @@ export async function selectOrCreateDatabase(options: {
122
126
  logger.trace(`[auth init] Using fallback region: ${region}`);
123
127
  }
124
128
 
125
- const regionalClient = getCatalystAPIClient(logger, auth, region);
129
+ const regionalClient = getCatalystAPIClient(logger, auth, region, undefined, config);
126
130
 
127
131
  const created = await tui.spinner({
128
132
  message: `Creating database in ${region}`,
@@ -393,9 +397,10 @@ export async function runAuthMigrations(options: {
393
397
  region: string;
394
398
  databaseName: string;
395
399
  sql: string;
400
+ config?: Config | null;
396
401
  }): Promise<void> {
397
- const { logger, auth, orgId, region, databaseName, sql } = options;
398
- const catalystClient = getCatalystAPIClient(logger, auth, region);
402
+ const { logger, auth, orgId, region, databaseName, sql, config } = options;
403
+ const catalystClient = getCatalystAPIClient(logger, auth, region, undefined, config);
399
404
 
400
405
  const statements = splitSqlStatements(sql);
401
406
 
@@ -1,22 +1,22 @@
1
- import { join, resolve } from 'node:path';
2
1
  import {
2
+ cpSync,
3
+ createReadStream,
3
4
  existsSync,
4
5
  mkdirSync,
5
6
  mkdtempSync,
6
- renameSync,
7
7
  readdirSync,
8
- cpSync,
8
+ renameSync,
9
9
  rmSync,
10
- createReadStream,
11
10
  } from 'node:fs';
12
11
  import { tmpdir } from 'node:os';
12
+ import { join, resolve } from 'node:path';
13
13
  import { finished } from 'node:stream/promises';
14
14
  import { createGunzip } from 'node:zlib';
15
+ import { type Logger, StructuredError } from '@agentuity/core';
15
16
  import { extract, type Headers } from 'tar-fs';
16
- import { StructuredError, type Logger } from '@agentuity/core';
17
- import * as tui from '../../tui';
18
- import { downloadWithSpinner } from '../../download';
19
17
  import { writeAgentsDocs } from '../../agents-docs';
18
+ import { downloadWithSpinner } from '../../download';
19
+ import * as tui from '../../tui';
20
20
  import type { TemplateInfo } from './templates';
21
21
 
22
22
  const GITHUB_BRANCH = 'main';
@@ -122,7 +122,7 @@ async function _cleanup(sourceDir: string, dest: string) {
122
122
  });
123
123
  }
124
124
 
125
- await tui.spinner(`📦 Copying template files...`, async () => {
125
+ await tui.spinner('📦 Copying template files...', async () => {
126
126
  // Copy all files from source to dest
127
127
  const files = readdirSync(sourceDir);
128
128
  for (const file of files) {
@@ -396,7 +396,21 @@ export async function setupProject(options: SetupOptions): Promise<{ success: bo
396
396
  return { success: !hasError };
397
397
  }
398
398
 
399
- export async function initGitRepo(dest: string): Promise<void> {
399
+ interface InitGitRepoOptions {
400
+ /** Project name (e.g. "My Agent") */
401
+ projectName?: string;
402
+ /** Where the template came from (e.g. "github.com/owner/repo" or "TypeScript / Hello World") */
403
+ source?: string;
404
+ /** Git commit author (e.g. { name: "app-slug[bot]", email: "id+slug[bot]@users.noreply.github.com" }) */
405
+ author?: { name: string; email: string };
406
+ }
407
+
408
+ export async function initGitRepo(dest: string, options?: InitGitRepoOptions): Promise<void> {
409
+ // Safety: refuse to init if .git already exists (prevents clobbering existing repos)
410
+ if (existsSync(join(dest, '.git'))) {
411
+ throw new Error(`Refusing to initialize git: "${dest}" already contains a .git directory.`);
412
+ }
413
+
400
414
  // Initialize git repository if git is available
401
415
  // Check for real git (not macOS stub that triggers Xcode CLT popup)
402
416
  const { isGitAvailable, getDefaultBranch } = await import('../../git-helper');
@@ -414,19 +428,22 @@ export async function initGitRepo(dest: string): Promise<void> {
414
428
  clearOnSuccess: true,
415
429
  });
416
430
 
417
- // Configure git user in CI environments (where git config may not be set)
418
- if (process.env.CI) {
431
+ // Configure git user in CI/sandbox environments (where git config may not be set)
432
+ if (process.env.CI || process.env.AGENTUITY_SANDBOX_ID) {
433
+ const cfgEmail = options?.author?.email ?? 'bot@agentuity.com';
434
+ const cfgName = options?.author?.name ?? 'Agentuity';
435
+
419
436
  await tui.runCommand({
420
437
  command: 'git config user.email',
421
438
  cwd: dest,
422
- cmd: ['git', 'config', 'user.email', 'agentuity@example.com'],
439
+ cmd: ['git', 'config', 'user.email', cfgEmail],
423
440
  clearOnSuccess: true,
424
441
  });
425
442
 
426
443
  await tui.runCommand({
427
444
  command: 'git config user.name',
428
445
  cwd: dest,
429
- cmd: ['git', 'config', 'user.name', 'Agentuity'],
446
+ cmd: ['git', 'config', 'user.name', cfgName],
430
447
  clearOnSuccess: true,
431
448
  });
432
449
  }
@@ -439,11 +456,30 @@ export async function initGitRepo(dest: string): Promise<void> {
439
456
  clearOnSuccess: true,
440
457
  });
441
458
 
442
- // Create initial commit (disable GPG signing to avoid lock issues)
459
+ const commitMessage = 'Initial Setup';
460
+
461
+ // Create initial commit — authored by the GitHub App bot if available,
462
+ // otherwise fallback to generic Agentuity identity
463
+ const authorName = options?.author?.name ?? 'Agentuity';
464
+ const authorEmail = options?.author?.email ?? 'bot@agentuity.com';
465
+ const authorStr = `${authorName} <${authorEmail}>`;
466
+
443
467
  await tui.runCommand({
444
- command: 'git commit -m "Initial Setup"',
468
+ command: 'git commit',
445
469
  cwd: dest,
446
- cmd: ['git', '-c', 'commit.gpgsign=false', 'commit', '-m', 'Initial Setup'],
470
+ cmd: [
471
+ 'git',
472
+ '-c',
473
+ 'commit.gpgsign=false',
474
+ 'commit',
475
+ `--author=${authorStr}`,
476
+ '-m',
477
+ commitMessage,
478
+ ],
479
+ env: {
480
+ GIT_COMMITTER_NAME: authorName,
481
+ GIT_COMMITTER_EMAIL: authorEmail,
482
+ },
447
483
  clearOnSuccess: true,
448
484
  });
449
485
  }
@@ -1,11 +1,12 @@
1
- import { z } from 'zod';
2
1
  import { resolve } from 'node:path';
3
- import { createSubcommand } from '../../types';
2
+ import { z } from 'zod';
3
+ import { isTTY } from '../../auth';
4
4
  import { getCommand } from '../../command-prefix';
5
- import { runProjectImport } from './reconcile';
6
- import * as tui from '../../tui';
7
5
  import { ErrorCode } from '../../errors';
8
- import { isTTY } from '../../auth';
6
+ import * as tui from '../../tui';
7
+ import { createSubcommand } from '../../types';
8
+ import { runProjectImport } from './reconcile';
9
+ import { runRemoteImport } from './remote-import';
9
10
 
10
11
  const ProjectImportResponseSchema = z.object({
11
12
  success: z.boolean().describe('Whether the import succeeded'),
@@ -20,19 +21,37 @@ const ProjectImportResponseSchema = z.object({
20
21
 
21
22
  export const importSubcommand = createSubcommand({
22
23
  name: 'import',
23
- description: 'Import or register a local project with Agentuity Cloud',
24
+ description: 'Import or register a local or remote project with Agentuity Cloud',
24
25
  tags: ['mutating', 'creates-resource', 'requires-auth'],
25
26
  examples: [
26
- { command: getCommand('project import'), description: 'Import project in current directory' },
27
+ {
28
+ command: getCommand('project import'),
29
+ description: 'Import project in current directory',
30
+ },
27
31
  {
28
32
  command: getCommand('project import --dir ./my-agent'),
29
33
  description: 'Import project from specified directory',
30
34
  },
35
+ {
36
+ command: getCommand('project import --source owner/repo'),
37
+ description: 'Import a remote project from GitHub',
38
+ },
39
+ {
40
+ command: getCommand('project import --source owner/repo --deploy --name my-agent'),
41
+ description: 'Import remote project, name it, and deploy',
42
+ },
43
+ {
44
+ command: getCommand(
45
+ 'project import --source owner/repo --remote owner/new-repo --env DATABASE_URL:my_db --env TASK_QUEUE:my_queue'
46
+ ),
47
+ description: 'Import with resource provisioning and push to new repo',
48
+ },
31
49
  ],
32
50
  requires: { auth: true, apiClient: true },
33
- optional: { region: true },
51
+ optional: { region: true, org: true },
34
52
  schema: {
35
53
  options: z.object({
54
+ source: z.string().optional().describe('GitHub URL or owner/repo to import from'),
36
55
  dir: z
37
56
  .string()
38
57
  .optional()
@@ -41,17 +60,60 @@ export const importSubcommand = createSubcommand({
41
60
  .boolean()
42
61
  .optional()
43
62
  .describe('Only validate the project structure without prompting'),
63
+ deploy: z
64
+ .boolean()
65
+ .optional()
66
+ .default(false)
67
+ .describe('Deploy the project after importing'),
68
+ projectId: z.string().optional().describe('Use a pre-created project ID (skip creation)'),
69
+ remote: z
70
+ .string()
71
+ .optional()
72
+ .describe('Target GitHub repo (owner/repo) to push imported code to'),
73
+ name: z.string().optional().describe('Project name (for non-interactive mode)'),
74
+ env: z
75
+ .array(z.string())
76
+ .optional()
77
+ .describe('Set env vars or name resources (KEY:VALUE format, repeatable)'),
44
78
  }),
45
79
  response: ProjectImportResponseSchema,
46
80
  },
47
81
 
48
82
  async handler(ctx) {
49
- const { opts, auth, apiClient, config, logger } = ctx;
83
+ const { opts, auth, apiClient, config, logger, orgId, region } = ctx;
50
84
 
51
85
  if (!config) {
52
86
  tui.fatal('Configuration not loaded. Please try again.', ErrorCode.CONFIG_INVALID);
53
87
  }
54
88
 
89
+ // If --source is provided, run remote import flow
90
+ const source = opts.source;
91
+ if (source) {
92
+ // Normalize owner/repo shorthand to full GitHub URL
93
+ const url = source.includes('://') ? source : `https://github.com/${source}`;
94
+ await runRemoteImport({
95
+ url,
96
+ deploy: opts.deploy ?? false,
97
+ projectId: opts.projectId,
98
+ repo: opts.remote,
99
+ name: opts.name,
100
+ env: opts.env,
101
+ org: orgId,
102
+ region,
103
+ apiClient,
104
+ auth,
105
+ config,
106
+ logger,
107
+ });
108
+
109
+ return {
110
+ success: true,
111
+ status: 'imported' as const,
112
+ message: 'Remote project imported successfully',
113
+ };
114
+ }
115
+
116
+ // No URL — fall through to existing local import behavior
55
117
  const dir = opts.dir ? resolve(opts.dir) : process.cwd();
56
118
  const validateOnly = opts.validateOnly ?? false;
57
119