@agentuity/cli 0.1.13 → 0.1.15
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/dist/auth.d.ts +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +12 -7
- package/dist/auth.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +94 -97
- package/dist/cli.js.map +1 -1
- package/dist/cmd/ai/index.d.ts.map +1 -1
- package/dist/cmd/ai/index.js +6 -1
- package/dist/cmd/ai/index.js.map +1 -1
- package/dist/cmd/ai/opencode/index.d.ts +3 -0
- package/dist/cmd/ai/opencode/index.d.ts.map +1 -0
- package/dist/cmd/ai/opencode/index.js +27 -0
- package/dist/cmd/ai/opencode/index.js.map +1 -0
- package/dist/cmd/ai/opencode/install.d.ts +3 -0
- package/dist/cmd/ai/opencode/install.d.ts.map +1 -0
- package/dist/cmd/ai/opencode/install.js +102 -0
- package/dist/cmd/ai/opencode/install.js.map +1 -0
- package/dist/cmd/ai/opencode/run.d.ts +3 -0
- package/dist/cmd/ai/opencode/run.d.ts.map +1 -0
- package/dist/cmd/ai/opencode/run.js +88 -0
- package/dist/cmd/ai/opencode/run.js.map +1 -0
- package/dist/cmd/ai/opencode/uninstall.d.ts +3 -0
- package/dist/cmd/ai/opencode/uninstall.d.ts.map +1 -0
- package/dist/cmd/ai/opencode/uninstall.js +82 -0
- package/dist/cmd/ai/opencode/uninstall.js.map +1 -0
- package/dist/cmd/auth/index.d.ts.map +1 -1
- package/dist/cmd/auth/index.js +3 -0
- package/dist/cmd/auth/index.js.map +1 -1
- package/dist/cmd/auth/org/index.d.ts +2 -0
- package/dist/cmd/auth/org/index.d.ts.map +1 -0
- package/dist/cmd/auth/org/index.js +121 -0
- package/dist/cmd/auth/org/index.js.map +1 -0
- package/dist/cmd/build/vite/beacon-plugin.d.ts +19 -0
- package/dist/cmd/build/vite/beacon-plugin.d.ts.map +1 -0
- package/dist/cmd/build/vite/beacon-plugin.js +137 -0
- package/dist/cmd/build/vite/beacon-plugin.js.map +1 -0
- package/dist/cmd/build/vite/vite-builder.d.ts +2 -0
- package/dist/cmd/build/vite/vite-builder.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-builder.js +12 -2
- package/dist/cmd/build/vite/vite-builder.js.map +1 -1
- package/dist/cmd/build/webanalytics-generator.js +25 -9
- package/dist/cmd/build/webanalytics-generator.js.map +1 -1
- package/dist/cmd/cloud/db/get.d.ts.map +1 -1
- package/dist/cmd/cloud/db/get.js +7 -0
- package/dist/cmd/cloud/db/get.js.map +1 -1
- package/dist/cmd/cloud/db/list.d.ts.map +1 -1
- package/dist/cmd/cloud/db/list.js +19 -6
- package/dist/cmd/cloud/db/list.js.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +24 -1
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/cloud/deployment/show.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/show.js +5 -0
- package/dist/cmd/cloud/deployment/show.js.map +1 -1
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/index.js +3 -0
- package/dist/cmd/cloud/index.js.map +1 -1
- package/dist/cmd/cloud/region/index.d.ts +2 -0
- package/dist/cmd/cloud/region/index.d.ts.map +1 -0
- package/dist/cmd/cloud/region/index.js +136 -0
- package/dist/cmd/cloud/region/index.js.map +1 -0
- package/dist/cmd/cloud/sandbox/snapshot/build.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/build.js +35 -5
- package/dist/cmd/cloud/sandbox/snapshot/build.js.map +1 -1
- package/dist/cmd/cloud/scp/download.d.ts.map +1 -1
- package/dist/cmd/cloud/scp/download.js +4 -2
- package/dist/cmd/cloud/scp/download.js.map +1 -1
- package/dist/cmd/cloud/scp/upload.d.ts.map +1 -1
- package/dist/cmd/cloud/scp/upload.js +4 -2
- package/dist/cmd/cloud/scp/upload.js.map +1 -1
- package/dist/cmd/cloud/ssh.d.ts.map +1 -1
- package/dist/cmd/cloud/ssh.js +3 -1
- package/dist/cmd/cloud/ssh.js.map +1 -1
- package/dist/cmd/cloud/storage/get.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/get.js +12 -5
- package/dist/cmd/cloud/storage/get.js.map +1 -1
- package/dist/cmd/cloud/storage/list.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/list.js +10 -0
- package/dist/cmd/cloud/storage/list.js.map +1 -1
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/dev/index.js +62 -5
- package/dist/cmd/dev/index.js.map +1 -1
- package/dist/cmd/help/index.d.ts.map +1 -1
- package/dist/cmd/help/index.js +8 -18
- package/dist/cmd/help/index.js.map +1 -1
- package/dist/cmd/project/create.d.ts.map +1 -1
- package/dist/cmd/project/create.js +18 -9
- package/dist/cmd/project/create.js.map +1 -1
- package/dist/cmd/project/download.d.ts +3 -1
- package/dist/cmd/project/download.d.ts.map +1 -1
- package/dist/cmd/project/download.js +5 -0
- package/dist/cmd/project/download.js.map +1 -1
- package/dist/cmd/project/import.d.ts +2 -0
- package/dist/cmd/project/import.d.ts.map +1 -0
- package/dist/cmd/project/import.js +88 -0
- package/dist/cmd/project/import.js.map +1 -0
- package/dist/cmd/project/index.d.ts.map +1 -1
- package/dist/cmd/project/index.js +3 -0
- package/dist/cmd/project/index.js.map +1 -1
- package/dist/cmd/project/reconcile.d.ts +67 -0
- package/dist/cmd/project/reconcile.d.ts.map +1 -0
- package/dist/cmd/project/reconcile.js +458 -0
- package/dist/cmd/project/reconcile.js.map +1 -0
- package/dist/cmd/project/template-flow.d.ts +13 -1
- package/dist/cmd/project/template-flow.d.ts.map +1 -1
- package/dist/cmd/project/template-flow.js +56 -18
- package/dist/cmd/project/template-flow.js.map +1 -1
- package/dist/config.d.ts +8 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +50 -21
- package/dist/config.js.map +1 -1
- package/dist/legacy-check.d.ts.map +1 -1
- package/dist/legacy-check.js +8 -0
- package/dist/legacy-check.js.map +1 -1
- package/dist/program-ref.d.ts +4 -0
- package/dist/program-ref.d.ts.map +1 -0
- package/dist/program-ref.js +8 -0
- package/dist/program-ref.js.map +1 -0
- package/dist/regions.d.ts +8 -0
- package/dist/regions.d.ts.map +1 -0
- package/dist/regions.js +77 -0
- package/dist/regions.js.map +1 -0
- package/dist/tui/prompt.d.ts.map +1 -1
- package/dist/tui/prompt.js +7 -1
- package/dist/tui/prompt.js.map +1 -1
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +79 -25
- package/dist/tui.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/package.json +7 -7
- package/src/auth.ts +14 -13
- package/src/cli.ts +118 -114
- package/src/cmd/ai/index.ts +6 -1
- package/src/cmd/ai/opencode/index.ts +28 -0
- package/src/cmd/ai/opencode/install.ts +120 -0
- package/src/cmd/ai/opencode/run.ts +103 -0
- package/src/cmd/ai/opencode/uninstall.ts +90 -0
- package/src/cmd/auth/index.ts +3 -0
- package/src/cmd/auth/org/index.ts +142 -0
- package/src/cmd/build/vite/beacon-plugin.ts +164 -0
- package/src/cmd/build/vite/vite-builder.ts +19 -2
- package/src/cmd/build/webanalytics-generator.ts +25 -9
- package/src/cmd/cloud/db/get.ts +7 -0
- package/src/cmd/cloud/db/list.ts +20 -6
- package/src/cmd/cloud/deploy.ts +32 -1
- package/src/cmd/cloud/deployment/show.ts +5 -0
- package/src/cmd/cloud/index.ts +3 -0
- package/src/cmd/cloud/region/index.ts +157 -0
- package/src/cmd/cloud/sandbox/snapshot/build.ts +42 -5
- package/src/cmd/cloud/scp/download.ts +6 -2
- package/src/cmd/cloud/scp/upload.ts +6 -2
- package/src/cmd/cloud/ssh.ts +5 -1
- package/src/cmd/cloud/storage/get.ts +12 -5
- package/src/cmd/cloud/storage/list.ts +11 -0
- package/src/cmd/dev/index.ts +62 -5
- package/src/cmd/help/index.ts +8 -22
- package/src/cmd/project/create.ts +19 -9
- package/src/cmd/project/download.ts +7 -1
- package/src/cmd/project/import.ts +98 -0
- package/src/cmd/project/index.ts +3 -0
- package/src/cmd/project/reconcile.ts +606 -0
- package/src/cmd/project/template-flow.ts +69 -18
- package/src/config.ts +58 -22
- package/src/legacy-check.ts +10 -0
- package/src/program-ref.ts +11 -0
- package/src/regions.ts +95 -0
- package/src/tui/prompt.ts +10 -3
- package/src/tui.ts +82 -26
- package/src/types.ts +2 -0
package/src/cmd/dev/index.ts
CHANGED
|
@@ -175,8 +175,8 @@ export const command = createCommand({
|
|
|
175
175
|
optional: { project: true },
|
|
176
176
|
|
|
177
177
|
async handler(ctx) {
|
|
178
|
-
const { opts, logger,
|
|
179
|
-
let { config } = ctx;
|
|
178
|
+
const { opts, logger, projectDir } = ctx;
|
|
179
|
+
let { config, project } = ctx;
|
|
180
180
|
|
|
181
181
|
// Get auth state - we handle auth ourselves based on project state
|
|
182
182
|
let auth = await getAuth();
|
|
@@ -227,7 +227,9 @@ export const command = createCommand({
|
|
|
227
227
|
tui.newline();
|
|
228
228
|
|
|
229
229
|
const shouldLogin = await tui.confirm(
|
|
230
|
-
hasProfile
|
|
230
|
+
hasProfile
|
|
231
|
+
? 'Would you like to login now?'
|
|
232
|
+
: 'Would you like to login or create an account?',
|
|
231
233
|
true
|
|
232
234
|
);
|
|
233
235
|
|
|
@@ -272,9 +274,63 @@ export const command = createCommand({
|
|
|
272
274
|
);
|
|
273
275
|
}
|
|
274
276
|
}
|
|
277
|
+
|
|
278
|
+
// After auth is established, verify project access
|
|
279
|
+
if (auth && config) {
|
|
280
|
+
const { reconcileProject } = await import('../project/reconcile');
|
|
281
|
+
const apiClient = new APIClient(getAPIBaseURL(config), logger, auth.apiKey, config);
|
|
282
|
+
|
|
283
|
+
const result = await reconcileProject({
|
|
284
|
+
dir: rootDir,
|
|
285
|
+
auth,
|
|
286
|
+
apiClient,
|
|
287
|
+
config,
|
|
288
|
+
logger,
|
|
289
|
+
interactive: isTTY(),
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
if (result.status === 'error') {
|
|
293
|
+
tui.fatal(result.message!, ErrorCode.PROJECT_NOT_FOUND);
|
|
294
|
+
} else if (result.status === 'imported' && result.project) {
|
|
295
|
+
// Project was re-imported to user's org
|
|
296
|
+
project = result.project;
|
|
297
|
+
tui.newline();
|
|
298
|
+
} else if (result.status === 'skipped') {
|
|
299
|
+
// User declined import - can't continue with cloud features
|
|
300
|
+
tui.warning('Continuing in local-only mode.');
|
|
301
|
+
project = undefined;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
275
304
|
} else {
|
|
276
|
-
// No agentuity.json -
|
|
277
|
-
|
|
305
|
+
// No agentuity.json - check if this is a valid project that needs importing
|
|
306
|
+
if (auth && config) {
|
|
307
|
+
const { reconcileProject } = await import('../project/reconcile');
|
|
308
|
+
const apiClient = new APIClient(getAPIBaseURL(config), logger, auth.apiKey, config);
|
|
309
|
+
|
|
310
|
+
const result = await reconcileProject({
|
|
311
|
+
dir: rootDir,
|
|
312
|
+
auth,
|
|
313
|
+
apiClient,
|
|
314
|
+
config,
|
|
315
|
+
logger,
|
|
316
|
+
interactive: isTTY(),
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
if (result.status === 'error') {
|
|
320
|
+
// Not a valid project - show local-only warning
|
|
321
|
+
tui.showLocalOnlyWarning();
|
|
322
|
+
} else if (result.status === 'imported' && result.project) {
|
|
323
|
+
// Project was imported - reload project config
|
|
324
|
+
project = result.project;
|
|
325
|
+
tui.newline();
|
|
326
|
+
} else if (result.status === 'skipped') {
|
|
327
|
+
// User declined import - continue in local-only mode
|
|
328
|
+
tui.showLocalOnlyWarning();
|
|
329
|
+
}
|
|
330
|
+
} else {
|
|
331
|
+
// Not authenticated - local-only mode
|
|
332
|
+
tui.showLocalOnlyWarning();
|
|
333
|
+
}
|
|
278
334
|
}
|
|
279
335
|
|
|
280
336
|
// Prepare dev lock: cleans up stale processes from previous sessions
|
|
@@ -924,6 +980,7 @@ export const command = createCommand({
|
|
|
924
980
|
}
|
|
925
981
|
|
|
926
982
|
process.env.AGENTUITY_SDK_DEV_MODE = 'true';
|
|
983
|
+
process.env.AGENTUITY_RUNTIME = 'yes';
|
|
927
984
|
process.env.AGENTUITY_ENV = 'development';
|
|
928
985
|
process.env.NODE_ENV = 'development';
|
|
929
986
|
process.env.AGENTUITY_PROJECT_DIR = rootDir;
|
package/src/cmd/help/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createCommand } from '../../types';
|
|
2
2
|
import { getCommand } from '../../command-prefix';
|
|
3
|
+
import { getProgram } from '../../program-ref';
|
|
3
4
|
|
|
4
5
|
export const command = createCommand({
|
|
5
6
|
name: 'help',
|
|
@@ -13,28 +14,13 @@ export const command = createCommand({
|
|
|
13
14
|
idempotent: true,
|
|
14
15
|
|
|
15
16
|
async handler() {
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} else {
|
|
23
|
-
// Script mode: spawn runtime and script, omitting the 'help' argument
|
|
24
|
-
spawnArgs = [process.argv[0], ...(process.argv.length > 1 ? [process.argv[1]] : [])];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const proc = Bun.spawn(spawnArgs, {
|
|
28
|
-
stdio: ['inherit', 'inherit', 'inherit'],
|
|
29
|
-
env: process.env,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const exitCode = await proc.exited;
|
|
33
|
-
|
|
34
|
-
if (exitCode !== 0) {
|
|
35
|
-
throw new Error(`Help command exited with code ${exitCode}`);
|
|
17
|
+
// Get the root program and display its help
|
|
18
|
+
// This avoids spawning a subprocess which doesn't work reliably
|
|
19
|
+
// with Bun compiled binaries
|
|
20
|
+
const program = getProgram();
|
|
21
|
+
if (program) {
|
|
22
|
+
program.outputHelp();
|
|
36
23
|
}
|
|
37
|
-
|
|
38
|
-
return undefined;
|
|
24
|
+
process.exit(0);
|
|
39
25
|
},
|
|
40
26
|
});
|
|
@@ -6,9 +6,11 @@ import type { APIClient as APIClientType } from '../../api';
|
|
|
6
6
|
|
|
7
7
|
const ProjectCreateResponseSchema = z.object({
|
|
8
8
|
success: z.boolean().describe('Whether the operation succeeded'),
|
|
9
|
+
error: z.string().optional().describe('Error message if setup failed'),
|
|
9
10
|
name: z.string().describe('Project name'),
|
|
10
11
|
path: z.string().describe('Project directory path'),
|
|
11
12
|
projectId: z.string().optional().describe('Project ID if registered'),
|
|
13
|
+
orgId: z.string().optional().describe('Organization ID if registered'),
|
|
12
14
|
template: z.string().describe('Template used'),
|
|
13
15
|
installed: z.boolean().describe('Whether dependencies were installed'),
|
|
14
16
|
built: z.boolean().describe('Whether the project was built'),
|
|
@@ -72,7 +74,7 @@ export const createProjectSubcommand = createSubcommand({
|
|
|
72
74
|
},
|
|
73
75
|
|
|
74
76
|
async handler(ctx) {
|
|
75
|
-
const { logger, opts, auth, config, apiClient, region } = ctx;
|
|
77
|
+
const { logger, opts, auth, config, apiClient, region, options } = ctx;
|
|
76
78
|
|
|
77
79
|
// Only get org if registering
|
|
78
80
|
let orgId: string | undefined;
|
|
@@ -83,7 +85,7 @@ export const createProjectSubcommand = createSubcommand({
|
|
|
83
85
|
);
|
|
84
86
|
}
|
|
85
87
|
|
|
86
|
-
await runCreateFlow({
|
|
88
|
+
const result = await runCreateFlow({
|
|
87
89
|
projectName: opts.name,
|
|
88
90
|
dir: opts.dir,
|
|
89
91
|
domains: opts.domains,
|
|
@@ -101,14 +103,22 @@ export const createProjectSubcommand = createSubcommand({
|
|
|
101
103
|
region,
|
|
102
104
|
});
|
|
103
105
|
|
|
104
|
-
//
|
|
106
|
+
// Exit with error code if setup failed and not in JSON mode
|
|
107
|
+
if (!result.success && !options.json) {
|
|
108
|
+
process.exitCode = 1;
|
|
109
|
+
}
|
|
110
|
+
|
|
105
111
|
return {
|
|
106
|
-
success:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
success: result.success,
|
|
113
|
+
error: result.error,
|
|
114
|
+
name: result.name,
|
|
115
|
+
path: result.path,
|
|
116
|
+
projectId: result.projectId,
|
|
117
|
+
orgId: result.orgId,
|
|
118
|
+
template: result.template,
|
|
119
|
+
installed: result.installed,
|
|
120
|
+
built: result.built,
|
|
121
|
+
domains: result.domains,
|
|
112
122
|
};
|
|
113
123
|
},
|
|
114
124
|
});
|
|
@@ -328,8 +328,9 @@ export async function downloadTemplate(options: DownloadOptions): Promise<void>
|
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
export async function setupProject(options: SetupOptions): Promise<
|
|
331
|
+
export async function setupProject(options: SetupOptions): Promise<{ success: boolean }> {
|
|
332
332
|
const { dest, projectName, dirName, noInstall, noBuild, logger } = options;
|
|
333
|
+
let hasError = false;
|
|
333
334
|
|
|
334
335
|
// Replace {{PROJECT_NAME}} in files
|
|
335
336
|
tui.info(`🔧 Setting up ${projectName}...`);
|
|
@@ -345,6 +346,7 @@ export async function setupProject(options: SetupOptions): Promise<void> {
|
|
|
345
346
|
});
|
|
346
347
|
if (exitCode !== 0) {
|
|
347
348
|
logger.error('Failed to install dependencies');
|
|
349
|
+
hasError = true;
|
|
348
350
|
}
|
|
349
351
|
}
|
|
350
352
|
|
|
@@ -361,6 +363,7 @@ export async function setupProject(options: SetupOptions): Promise<void> {
|
|
|
361
363
|
});
|
|
362
364
|
if (exitCode !== 0) {
|
|
363
365
|
logger.error('Template setup script failed');
|
|
366
|
+
hasError = true;
|
|
364
367
|
}
|
|
365
368
|
} finally {
|
|
366
369
|
// Always delete the setup script after running (or attempting to run)
|
|
@@ -382,12 +385,15 @@ export async function setupProject(options: SetupOptions): Promise<void> {
|
|
|
382
385
|
});
|
|
383
386
|
if (exitCode !== 0) {
|
|
384
387
|
logger.error('Failed to build project');
|
|
388
|
+
hasError = true;
|
|
385
389
|
}
|
|
386
390
|
}
|
|
387
391
|
|
|
388
392
|
// Generate and write AGENTS.md files for the CLI and source folders
|
|
389
393
|
// Always overwrite during project setup to ensure fresh content
|
|
390
394
|
await writeAgentsDocs(dest);
|
|
395
|
+
|
|
396
|
+
return { success: !hasError };
|
|
391
397
|
}
|
|
392
398
|
|
|
393
399
|
export async function initGitRepo(dest: string): Promise<void> {
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { createSubcommand } from '../../types';
|
|
4
|
+
import { getCommand } from '../../command-prefix';
|
|
5
|
+
import { runProjectImport } from './reconcile';
|
|
6
|
+
import * as tui from '../../tui';
|
|
7
|
+
import { ErrorCode } from '../../errors';
|
|
8
|
+
import { isTTY } from '../../auth';
|
|
9
|
+
|
|
10
|
+
const ProjectImportResponseSchema = z.object({
|
|
11
|
+
success: z.boolean().describe('Whether the import succeeded'),
|
|
12
|
+
projectId: z.string().optional().describe('Project ID if imported'),
|
|
13
|
+
orgId: z.string().optional().describe('Organization ID'),
|
|
14
|
+
region: z.string().optional().describe('Region'),
|
|
15
|
+
status: z
|
|
16
|
+
.enum(['valid', 'imported', 'skipped', 'error'])
|
|
17
|
+
.describe('The result status of the import'),
|
|
18
|
+
message: z.string().optional().describe('Status message'),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const importSubcommand = createSubcommand({
|
|
22
|
+
name: 'import',
|
|
23
|
+
description: 'Import or register a local project with Agentuity Cloud',
|
|
24
|
+
tags: ['mutating', 'creates-resource', 'requires-auth'],
|
|
25
|
+
examples: [
|
|
26
|
+
{ command: getCommand('project import'), description: 'Import project in current directory' },
|
|
27
|
+
{
|
|
28
|
+
command: getCommand('project import --dir ./my-agent'),
|
|
29
|
+
description: 'Import project from specified directory',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
requires: { auth: true, apiClient: true },
|
|
33
|
+
optional: { region: true },
|
|
34
|
+
schema: {
|
|
35
|
+
options: z.object({
|
|
36
|
+
dir: z
|
|
37
|
+
.string()
|
|
38
|
+
.optional()
|
|
39
|
+
.describe('Directory containing the project (default: current directory)'),
|
|
40
|
+
validateOnly: z
|
|
41
|
+
.boolean()
|
|
42
|
+
.optional()
|
|
43
|
+
.describe('Only validate the project structure without prompting'),
|
|
44
|
+
}),
|
|
45
|
+
response: ProjectImportResponseSchema,
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
async handler(ctx) {
|
|
49
|
+
const { opts, auth, apiClient, config, logger } = ctx;
|
|
50
|
+
|
|
51
|
+
if (!config) {
|
|
52
|
+
tui.fatal('Configuration not loaded. Please try again.', ErrorCode.CONFIG_INVALID);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const dir = opts.dir ? resolve(opts.dir) : process.cwd();
|
|
56
|
+
const validateOnly = opts.validateOnly ?? false;
|
|
57
|
+
|
|
58
|
+
const result = await runProjectImport({
|
|
59
|
+
dir,
|
|
60
|
+
auth,
|
|
61
|
+
apiClient,
|
|
62
|
+
config,
|
|
63
|
+
logger,
|
|
64
|
+
interactive: validateOnly ? false : isTTY(),
|
|
65
|
+
validateOnly,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (result.status === 'error') {
|
|
69
|
+
tui.fatal(result.message ?? 'Failed to import project', ErrorCode.PROJECT_NOT_FOUND);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (result.status === 'skipped') {
|
|
73
|
+
tui.info(result.message || 'Import cancelled.');
|
|
74
|
+
return {
|
|
75
|
+
success: false,
|
|
76
|
+
status: result.status,
|
|
77
|
+
message: result.message,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Show success message for validateOnly mode
|
|
82
|
+
if (validateOnly && result.status === 'valid' && !result.project) {
|
|
83
|
+
tui.success(result.message || 'Project structure is valid.');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
success: result.status === 'valid' || result.status === 'imported',
|
|
88
|
+
projectId: result.project?.projectId,
|
|
89
|
+
orgId: result.project?.orgId,
|
|
90
|
+
region: result.project?.region,
|
|
91
|
+
status: result.status,
|
|
92
|
+
message:
|
|
93
|
+
result.status === 'imported'
|
|
94
|
+
? 'Project imported successfully'
|
|
95
|
+
: result.message || 'Project is already registered',
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
});
|
package/src/cmd/project/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createCommand } from '../../types';
|
|
2
2
|
import { createProjectSubcommand } from './create';
|
|
3
|
+
import { importSubcommand } from './import';
|
|
3
4
|
import { listSubcommand } from './list';
|
|
4
5
|
import { deleteSubcommand } from './delete';
|
|
5
6
|
import { showSubcommand } from './show';
|
|
@@ -12,11 +13,13 @@ export const command = createCommand({
|
|
|
12
13
|
tags: ['fast', 'requires-auth'],
|
|
13
14
|
examples: [
|
|
14
15
|
{ command: getCommand('project create my-agent'), description: 'Create a new project' },
|
|
16
|
+
{ command: getCommand('project import'), description: 'Import an existing project' },
|
|
15
17
|
{ command: getCommand('project list'), description: 'List all projects' },
|
|
16
18
|
{ command: getCommand('project auth init'), description: 'Set up Agentuity Auth' },
|
|
17
19
|
],
|
|
18
20
|
subcommands: [
|
|
19
21
|
createProjectSubcommand,
|
|
22
|
+
importSubcommand,
|
|
20
23
|
listSubcommand,
|
|
21
24
|
deleteSubcommand,
|
|
22
25
|
showSubcommand,
|