@agentuity/cli 1.0.0 → 1.0.2
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/AGENTS.md +40 -24
- package/bin/cli.ts +47 -22
- package/dist/agent-detection.d.ts +23 -38
- package/dist/agent-detection.d.ts.map +1 -1
- package/dist/agent-detection.js +412 -153
- package/dist/agent-detection.js.map +1 -1
- package/dist/ai-help.d.ts +23 -0
- package/dist/ai-help.d.ts.map +1 -0
- package/dist/ai-help.js +328 -0
- package/dist/ai-help.js.map +1 -0
- package/dist/api.js +1 -1
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts +10 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +176 -16
- package/dist/auth.js.map +1 -1
- package/dist/banner.d.ts.map +1 -1
- package/dist/banner.js +5 -0
- package/dist/banner.js.map +1 -1
- package/dist/cache/agent-intro.d.ts +13 -0
- package/dist/cache/agent-intro.d.ts.map +1 -0
- package/dist/cache/agent-intro.js +54 -0
- package/dist/cache/agent-intro.js.map +1 -0
- package/dist/cache/index.d.ts +1 -0
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +1 -0
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/resource-region.d.ts +3 -2
- package/dist/cache/resource-region.d.ts.map +1 -1
- package/dist/cache/resource-region.js +13 -4
- package/dist/cache/resource-region.js.map +1 -1
- package/dist/catalyst.d.ts +7 -0
- package/dist/catalyst.d.ts.map +1 -0
- package/dist/catalyst.js +15 -0
- package/dist/catalyst.js.map +1 -0
- package/dist/cli.d.ts +12 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +290 -67
- package/dist/cli.js.map +1 -1
- package/dist/cmd/ai/detect.d.ts +3 -0
- package/dist/cmd/ai/detect.d.ts.map +1 -0
- package/dist/cmd/ai/detect.js +49 -0
- package/dist/cmd/ai/detect.js.map +1 -0
- package/dist/cmd/ai/index.d.ts.map +1 -1
- package/dist/cmd/ai/index.js +11 -1
- package/dist/cmd/ai/index.js.map +1 -1
- package/dist/cmd/ai/intro.d.ts +7 -0
- package/dist/cmd/ai/intro.d.ts.map +1 -0
- package/dist/cmd/ai/intro.js +141 -0
- package/dist/cmd/ai/intro.js.map +1 -0
- package/dist/cmd/ai/opencode/run.d.ts.map +1 -1
- package/dist/cmd/ai/opencode/run.js +5 -0
- package/dist/cmd/ai/opencode/run.js.map +1 -1
- package/dist/cmd/build/ast.d.ts.map +1 -1
- package/dist/cmd/build/ast.js +79 -0
- package/dist/cmd/build/ast.js.map +1 -1
- package/dist/cmd/build/vite/bun-dev-server.d.ts.map +1 -1
- package/dist/cmd/build/vite/bun-dev-server.js +2 -0
- package/dist/cmd/build/vite/bun-dev-server.js.map +1 -1
- package/dist/cmd/build/vite/docs-generator.d.ts.map +1 -1
- package/dist/cmd/build/vite/docs-generator.js +15 -1
- package/dist/cmd/build/vite/docs-generator.js.map +1 -1
- package/dist/cmd/build/vite/env-types-generator.d.ts +26 -0
- package/dist/cmd/build/vite/env-types-generator.d.ts.map +1 -0
- package/dist/cmd/build/vite/env-types-generator.js +110 -0
- package/dist/cmd/build/vite/env-types-generator.js.map +1 -0
- package/dist/cmd/build/vite/index.d.ts +2 -0
- package/dist/cmd/build/vite/index.d.ts.map +1 -1
- package/dist/cmd/build/vite/index.js +12 -1
- package/dist/cmd/build/vite/index.js.map +1 -1
- package/dist/cmd/build/vite/public-asset-path-plugin.d.ts.map +1 -1
- package/dist/cmd/build/vite/public-asset-path-plugin.js.map +1 -1
- 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 +10 -1
- package/dist/cmd/build/vite/vite-builder.js.map +1 -1
- package/dist/cmd/cloud/db/create.js.map +1 -1
- package/dist/cmd/cloud/db/delete.js.map +1 -1
- package/dist/cmd/cloud/db/get.d.ts.map +1 -1
- package/dist/cmd/cloud/db/get.js +27 -12
- package/dist/cmd/cloud/db/get.js.map +1 -1
- package/dist/cmd/cloud/deploy-fork.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy-fork.js +2 -0
- package/dist/cmd/cloud/deploy-fork.js.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +17 -0
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/cloud/env/import.js.map +1 -1
- package/dist/cmd/cloud/env/list.js.map +1 -1
- package/dist/cmd/cloud/env/push.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/util.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/util.js +3 -3
- package/dist/cmd/cloud/keyvalue/util.js.map +1 -1
- package/dist/cmd/cloud/machine/list.js +3 -3
- package/dist/cmd/cloud/machine/list.js.map +1 -1
- package/dist/cmd/cloud/region/index.js.map +1 -1
- package/dist/cmd/cloud/region-lookup.d.ts +7 -4
- package/dist/cmd/cloud/region-lookup.d.ts.map +1 -1
- package/dist/cmd/cloud/region-lookup.js +59 -14
- package/dist/cmd/cloud/region-lookup.js.map +1 -1
- package/dist/cmd/cloud/sandbox/cp.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/cp.js +7 -5
- package/dist/cmd/cloud/sandbox/cp.js.map +1 -1
- package/dist/cmd/cloud/sandbox/create.js +1 -1
- package/dist/cmd/cloud/sandbox/create.js.map +1 -1
- package/dist/cmd/cloud/sandbox/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/delete.js +8 -7
- package/dist/cmd/cloud/sandbox/delete.js.map +1 -1
- package/dist/cmd/cloud/sandbox/download.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/download.js +7 -5
- package/dist/cmd/cloud/sandbox/download.js.map +1 -1
- package/dist/cmd/cloud/sandbox/env.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/env.js +7 -5
- package/dist/cmd/cloud/sandbox/env.js.map +1 -1
- package/dist/cmd/cloud/sandbox/exec.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/exec.js +7 -5
- package/dist/cmd/cloud/sandbox/exec.js.map +1 -1
- package/dist/cmd/cloud/sandbox/get.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/get.js +12 -7
- package/dist/cmd/cloud/sandbox/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/list.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/list.js +40 -63
- package/dist/cmd/cloud/sandbox/list.js.map +1 -1
- package/dist/cmd/cloud/sandbox/ls.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/ls.js +7 -5
- package/dist/cmd/cloud/sandbox/ls.js.map +1 -1
- package/dist/cmd/cloud/sandbox/mkdir.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/mkdir.js +7 -5
- package/dist/cmd/cloud/sandbox/mkdir.js.map +1 -1
- package/dist/cmd/cloud/sandbox/rm.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/rm.js +7 -5
- package/dist/cmd/cloud/sandbox/rm.js.map +1 -1
- package/dist/cmd/cloud/sandbox/rmdir.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/rmdir.js +7 -5
- package/dist/cmd/cloud/sandbox/rmdir.js.map +1 -1
- package/dist/cmd/cloud/sandbox/run.js +1 -1
- package/dist/cmd/cloud/sandbox/run.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/build.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/upload.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/upload.js +7 -5
- package/dist/cmd/cloud/sandbox/upload.js.map +1 -1
- package/dist/cmd/cloud/sandbox/util.d.ts +2 -2
- package/dist/cmd/cloud/sandbox/util.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/util.js +14 -13
- package/dist/cmd/cloud/sandbox/util.js.map +1 -1
- package/dist/cmd/cloud/ssh.d.ts.map +1 -1
- package/dist/cmd/cloud/ssh.js +3 -3
- package/dist/cmd/cloud/ssh.js.map +1 -1
- package/dist/cmd/cloud/storage/create.js.map +1 -1
- package/dist/cmd/cloud/storage/delete.js.map +1 -1
- package/dist/cmd/cloud/storage/get.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/get.js +5 -11
- 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 +6 -6
- package/dist/cmd/cloud/storage/list.js.map +1 -1
- package/dist/cmd/cloud/stream/create.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/create.js +7 -4
- package/dist/cmd/cloud/stream/create.js.map +1 -1
- package/dist/cmd/cloud/stream/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/delete.js +25 -4
- package/dist/cmd/cloud/stream/delete.js.map +1 -1
- package/dist/cmd/cloud/stream/get.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/get.js +91 -62
- package/dist/cmd/cloud/stream/get.js.map +1 -1
- package/dist/cmd/cloud/stream/list.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/list.js +66 -38
- package/dist/cmd/cloud/stream/list.js.map +1 -1
- package/dist/cmd/cloud/stream/util.d.ts +20 -0
- package/dist/cmd/cloud/stream/util.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/util.js +27 -3
- package/dist/cmd/cloud/stream/util.js.map +1 -1
- package/dist/cmd/cloud/vector/util.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/util.js +3 -3
- package/dist/cmd/cloud/vector/util.js.map +1 -1
- package/dist/cmd/dev/index.js.map +1 -1
- package/dist/cmd/git/account/add.js.map +1 -1
- package/dist/cmd/git/list.js.map +1 -1
- package/dist/cmd/project/add/database.d.ts +2 -0
- package/dist/cmd/project/add/database.d.ts.map +1 -0
- package/dist/cmd/project/add/database.js +123 -0
- package/dist/cmd/project/add/database.js.map +1 -0
- package/dist/cmd/project/add/domain.d.ts +2 -0
- package/dist/cmd/project/add/domain.d.ts.map +1 -0
- package/dist/cmd/project/add/domain.js +152 -0
- package/dist/cmd/project/add/domain.js.map +1 -0
- package/dist/cmd/project/add/index.d.ts +2 -0
- package/dist/cmd/project/add/index.d.ts.map +1 -0
- package/dist/cmd/project/add/index.js +35 -0
- package/dist/cmd/project/add/index.js.map +1 -0
- package/dist/cmd/project/add/storage.d.ts +2 -0
- package/dist/cmd/project/add/storage.d.ts.map +1 -0
- package/dist/cmd/project/add/storage.js +123 -0
- package/dist/cmd/project/add/storage.js.map +1 -0
- package/dist/cmd/project/auth/init.js.map +1 -1
- package/dist/cmd/project/index.d.ts.map +1 -1
- package/dist/cmd/project/index.js +7 -0
- package/dist/cmd/project/index.js.map +1 -1
- package/dist/cmd/project/reconcile.d.ts.map +1 -1
- package/dist/cmd/project/reconcile.js +32 -0
- package/dist/cmd/project/reconcile.js.map +1 -1
- package/dist/cmd/support/report.js.map +1 -1
- package/dist/cmd/support/system.js +2 -2
- package/dist/cmd/support/system.js.map +1 -1
- package/dist/config.d.ts +6 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +31 -7
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts +2 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +5 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/repl.js +2 -1
- package/dist/repl.js.map +1 -1
- package/dist/tui/box.d.ts +3 -1
- package/dist/tui/box.d.ts.map +1 -1
- package/dist/tui/box.js +22 -7
- package/dist/tui/box.js.map +1 -1
- package/dist/tui/colors.d.ts +0 -3
- package/dist/tui/colors.d.ts.map +1 -1
- package/dist/tui/colors.js +76 -23
- package/dist/tui/colors.js.map +1 -1
- package/dist/tui/prompt.d.ts +2 -0
- package/dist/tui/prompt.d.ts.map +1 -1
- package/dist/tui/prompt.js +44 -3
- package/dist/tui/prompt.js.map +1 -1
- package/dist/tui/symbols.d.ts +0 -4
- package/dist/tui/symbols.d.ts.map +1 -1
- package/dist/tui/symbols.js +5 -0
- package/dist/tui/symbols.js.map +1 -1
- package/dist/tui.d.ts +8 -0
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +54 -9
- package/dist/tui.js.map +1 -1
- package/dist/types.d.ts +37 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/dist/version-check.d.ts.map +1 -1
- package/dist/version-check.js +5 -0
- package/dist/version-check.js.map +1 -1
- package/package.json +6 -6
- package/src/agent-detection.ts +457 -160
- package/src/ai-help.ts +391 -0
- package/src/api.ts +1 -1
- package/src/auth.ts +226 -17
- package/src/banner.ts +5 -0
- package/src/cache/agent-intro.ts +61 -0
- package/src/cache/index.ts +2 -0
- package/src/cache/resource-region.ts +28 -7
- package/src/catalyst.ts +16 -0
- package/src/cli.ts +375 -93
- package/src/cmd/ai/detect.ts +52 -0
- package/src/cmd/ai/index.ts +11 -1
- package/src/cmd/ai/intro.ts +154 -0
- package/src/cmd/ai/opencode/run.ts +5 -0
- package/src/cmd/build/ast.ts +97 -0
- package/src/cmd/build/vite/bun-dev-server.ts +2 -0
- package/src/cmd/build/vite/docs-generator.ts +15 -1
- package/src/cmd/build/vite/env-types-generator.ts +145 -0
- package/src/cmd/build/vite/index.ts +15 -0
- package/src/cmd/build/vite/public-asset-path-plugin.ts +8 -2
- package/src/cmd/build/vite/vite-builder.ts +31 -11
- package/src/cmd/cloud/db/create.ts +16 -16
- package/src/cmd/cloud/db/delete.ts +19 -19
- package/src/cmd/cloud/db/get.ts +32 -17
- package/src/cmd/cloud/deploy-fork.ts +2 -0
- package/src/cmd/cloud/deploy.ts +17 -0
- package/src/cmd/cloud/env/import.ts +6 -6
- package/src/cmd/cloud/env/list.ts +11 -11
- package/src/cmd/cloud/env/push.ts +6 -6
- package/src/cmd/cloud/keyvalue/util.ts +3 -3
- package/src/cmd/cloud/machine/list.ts +3 -3
- package/src/cmd/cloud/region/index.ts +3 -3
- package/src/cmd/cloud/region-lookup.ts +82 -22
- package/src/cmd/cloud/sandbox/cp.ts +9 -4
- package/src/cmd/cloud/sandbox/create.ts +1 -1
- package/src/cmd/cloud/sandbox/delete.ts +10 -7
- package/src/cmd/cloud/sandbox/download.ts +8 -5
- package/src/cmd/cloud/sandbox/env.ts +8 -5
- package/src/cmd/cloud/sandbox/exec.ts +10 -5
- package/src/cmd/cloud/sandbox/get.ts +13 -7
- package/src/cmd/cloud/sandbox/list.ts +47 -73
- package/src/cmd/cloud/sandbox/ls.ts +9 -5
- package/src/cmd/cloud/sandbox/mkdir.ts +9 -5
- package/src/cmd/cloud/sandbox/rm.ts +9 -5
- package/src/cmd/cloud/sandbox/rmdir.ts +9 -5
- package/src/cmd/cloud/sandbox/run.ts +1 -1
- package/src/cmd/cloud/sandbox/snapshot/build.ts +31 -31
- package/src/cmd/cloud/sandbox/snapshot/get.ts +17 -17
- package/src/cmd/cloud/sandbox/upload.ts +8 -5
- package/src/cmd/cloud/sandbox/util.ts +15 -14
- package/src/cmd/cloud/ssh.ts +2 -4
- package/src/cmd/cloud/storage/create.ts +16 -16
- package/src/cmd/cloud/storage/delete.ts +19 -19
- package/src/cmd/cloud/storage/get.ts +5 -16
- package/src/cmd/cloud/storage/list.ts +12 -6
- package/src/cmd/cloud/stream/create.ts +8 -4
- package/src/cmd/cloud/stream/delete.ts +28 -4
- package/src/cmd/cloud/stream/get.ts +102 -64
- package/src/cmd/cloud/stream/list.ts +76 -44
- package/src/cmd/cloud/stream/util.ts +39 -3
- package/src/cmd/cloud/vector/util.ts +3 -3
- package/src/cmd/dev/index.ts +4 -4
- package/src/cmd/git/account/add.ts +5 -5
- package/src/cmd/git/list.ts +7 -7
- package/src/cmd/project/add/database.ts +145 -0
- package/src/cmd/project/add/domain.ts +181 -0
- package/src/cmd/project/add/index.ts +35 -0
- package/src/cmd/project/add/storage.ts +147 -0
- package/src/cmd/project/auth/init.ts +6 -6
- package/src/cmd/project/index.ts +7 -0
- package/src/cmd/project/reconcile.ts +40 -0
- package/src/cmd/support/report.ts +5 -5
- package/src/cmd/support/system.ts +2 -2
- package/src/config.ts +40 -12
- package/src/errors.ts +7 -0
- package/src/index.ts +11 -0
- package/src/repl.ts +4 -1
- package/src/tui/box.ts +24 -9
- package/src/tui/colors.ts +83 -26
- package/src/tui/prompt.ts +55 -3
- package/src/tui/symbols.ts +6 -0
- package/src/tui.ts +55 -9
- package/src/types.ts +46 -2
- package/src/version-check.ts +6 -0
package/dist/cli.js
CHANGED
|
@@ -2,20 +2,22 @@ import { homedir } from 'node:os';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import { showBanner, generateBanner } from './banner';
|
|
5
|
-
import {
|
|
5
|
+
import { getExecutingAgent } from './agent-detection';
|
|
6
|
+
import { requireAuth, optionalAuth, requireOrg, optionalOrg as selectOptionalOrg, hasPrefixedResourceId, resolveOrgIdWithoutPrompt, } from './auth';
|
|
6
7
|
import { ValidationOutputError } from '@agentuity/server';
|
|
7
8
|
import { fetchRegionsWithCache } from './regions';
|
|
8
9
|
import enquirer from 'enquirer';
|
|
9
10
|
import * as tui from './tui';
|
|
10
11
|
import { parseArgsSchema, parseOptionsSchema, buildValidationInputAsync } from './schema-parser';
|
|
11
|
-
import { defaultProfileName, loadProjectConfig } from './config';
|
|
12
|
+
import { defaultProfileName, loadProjectConfig, saveProjectId, saveRegion } from './config';
|
|
12
13
|
import { APIClient, getAPIBaseURL, getAppBaseURL } from './api';
|
|
13
14
|
import { ErrorCode, ExitCode, createError, exitWithError } from './errors';
|
|
14
15
|
import { getCommand } from './command-prefix';
|
|
15
16
|
import { isValidateMode, outputValidation } from './output';
|
|
16
17
|
import { StructuredError } from '@agentuity/core';
|
|
17
18
|
import { setProgram } from './program-ref';
|
|
18
|
-
import {
|
|
19
|
+
import { generateIntroPrompt } from './cmd/ai/intro';
|
|
20
|
+
import { getCachedProject, getResourceInfo, setCachedProject, hasAgentSeenIntro, markAgentIntroSeen, } from './cache';
|
|
19
21
|
/**
|
|
20
22
|
* Check if an error is a CLI input validation error (Zod error from schema parsing),
|
|
21
23
|
* and not an API response validation error (ValidationOutputError).
|
|
@@ -98,10 +100,10 @@ async function executeOrValidate(ctx, commandName, handler, hasResponseSchema, w
|
|
|
98
100
|
outputValidation(result, ctx.options);
|
|
99
101
|
}
|
|
100
102
|
else if (handler) {
|
|
101
|
-
// Render "View on the web" link before normal execution
|
|
102
|
-
maybeRenderWebLink(ctx, webUrl);
|
|
103
103
|
// Normal execution
|
|
104
104
|
const result = await handler(ctx);
|
|
105
|
+
// Render "View on the web" link after successful execution (not shown on errors)
|
|
106
|
+
maybeRenderWebLink(ctx, webUrl);
|
|
105
107
|
// If --json flag is set
|
|
106
108
|
if (ctx.options.json) {
|
|
107
109
|
// If command has a response schema but returned nothing, that's an error
|
|
@@ -352,6 +354,9 @@ async function promptProjectSelection(baseCtx) {
|
|
|
352
354
|
if (!selectedProject) {
|
|
353
355
|
return null;
|
|
354
356
|
}
|
|
357
|
+
if (selectedProject.id !== config?.preferences?.projectId) {
|
|
358
|
+
await saveProjectId(selectedProject.id);
|
|
359
|
+
}
|
|
355
360
|
// Convert to ProjectConfig format
|
|
356
361
|
return {
|
|
357
362
|
projectId: selectedProject.id,
|
|
@@ -375,6 +380,7 @@ export async function createCLI(version) {
|
|
|
375
380
|
.option('--log-timestamp', 'Show timestamps in log output', false)
|
|
376
381
|
.option('--no-log-prefix', 'Hide log level prefixes', true)
|
|
377
382
|
.option('--org-id <id>', 'Use a specific organization when performing operations', process.env.AGENTUITY_CLOUD_ORG_ID)
|
|
383
|
+
.option('--project-id <id>', 'Use a specific project when performing operations (AGENTUITY_CLOUD_PROJECT_ID)', process.env.AGENTUITY_CLOUD_PROJECT_ID)
|
|
378
384
|
.option('--color-scheme <scheme>', 'Color scheme: light or dark')
|
|
379
385
|
.option('--color <mode>', 'Color output: auto, always, never', 'auto')
|
|
380
386
|
.option('--error-format <format>', 'Error output format: json or text', 'text')
|
|
@@ -383,10 +389,14 @@ export async function createCLI(version) {
|
|
|
383
389
|
.option('--no-progress', 'Disable progress indicators', false)
|
|
384
390
|
.option('--explain', 'Show what the command would do without executing', false)
|
|
385
391
|
.option('--dry-run', 'Execute command without making changes', false)
|
|
386
|
-
.option('--validate', 'Validate arguments and options without executing', false)
|
|
392
|
+
.option('--validate', 'Validate arguments and options without executing', false)
|
|
393
|
+
.option('--ai-help', 'Show AI-optimized help in dashdash format', false);
|
|
387
394
|
const skipVersionCheckOption = program.createOption('--skip-version-check', 'Skip version compatibility check (dev only)');
|
|
388
395
|
skipVersionCheckOption.hideHelp();
|
|
389
396
|
program.addOption(skipVersionCheckOption);
|
|
397
|
+
const profileOption = program.createOption('--profile <name>', 'Override the default profile (takes precedence over AGENTUITY_PROFILE env var)');
|
|
398
|
+
profileOption.hideHelp();
|
|
399
|
+
program.addOption(profileOption);
|
|
390
400
|
program.action(() => {
|
|
391
401
|
program.help();
|
|
392
402
|
});
|
|
@@ -485,14 +495,32 @@ export async function createCLI(version) {
|
|
|
485
495
|
}
|
|
486
496
|
// Format each section (show banner for root command)
|
|
487
497
|
let output = '';
|
|
498
|
+
// Show intro for first-time agents (before normal help output)
|
|
499
|
+
// AGENTUITY_SHOW_INTRO=1 forces showing the intro (useful for testing)
|
|
500
|
+
const agent = getExecutingAgent();
|
|
501
|
+
const forceShowIntro = process.env.AGENTUITY_SHOW_INTRO === '1';
|
|
502
|
+
const hasSeenIntro = agent ? hasAgentSeenIntro(agent) : true;
|
|
503
|
+
if (agent && (forceShowIntro || !hasSeenIntro)) {
|
|
504
|
+
// Only mark as seen if this is their first time (not on forced re-shows)
|
|
505
|
+
if (!hasSeenIntro) {
|
|
506
|
+
markAgentIntroSeen(agent);
|
|
507
|
+
}
|
|
508
|
+
const separator = '='.repeat(79);
|
|
509
|
+
output += `${separator}\n\n`;
|
|
510
|
+
output += generateIntroPrompt(agent);
|
|
511
|
+
output += `\n${separator}\n\n`;
|
|
512
|
+
}
|
|
488
513
|
// Show banner (full for root, compact for subcommands)
|
|
514
|
+
// Skip banner when running from an AI coding agent
|
|
489
515
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
490
516
|
const isRootCommand = !cmd.parent;
|
|
491
|
-
if (
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
517
|
+
if (!agent) {
|
|
518
|
+
if (isRootCommand) {
|
|
519
|
+
output += `${generateBanner(version)}\n\n`;
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
output += `${generateBanner(version, true)}\n`;
|
|
523
|
+
}
|
|
496
524
|
}
|
|
497
525
|
// Description
|
|
498
526
|
const description = helper.commandDescription(cmd);
|
|
@@ -537,16 +565,20 @@ export async function createCLI(version) {
|
|
|
537
565
|
});
|
|
538
566
|
return program;
|
|
539
567
|
}
|
|
540
|
-
async function getRegion(regions) {
|
|
568
|
+
async function getRegion(regions, preferredRegion) {
|
|
541
569
|
const firstRegion = regions[0];
|
|
542
570
|
if (regions.length === 1 && firstRegion) {
|
|
543
571
|
return firstRegion.region;
|
|
544
572
|
}
|
|
545
573
|
else {
|
|
574
|
+
const preferredIndex = preferredRegion
|
|
575
|
+
? regions.findIndex((region) => region.region === preferredRegion)
|
|
576
|
+
: -1;
|
|
546
577
|
const response = await enquirer.prompt({
|
|
547
578
|
type: 'select',
|
|
548
579
|
name: 'region',
|
|
549
580
|
message: 'Select a cloud region:',
|
|
581
|
+
...(preferredIndex >= 0 && { initial: preferredIndex }),
|
|
550
582
|
choices: regions.map((r) => ({
|
|
551
583
|
name: r.region,
|
|
552
584
|
message: `${r.description.padEnd(15, ' ')} ${tui.muted(r.region)}`,
|
|
@@ -555,8 +587,58 @@ async function getRegion(regions) {
|
|
|
555
587
|
return response.region;
|
|
556
588
|
}
|
|
557
589
|
}
|
|
558
|
-
|
|
559
|
-
|
|
590
|
+
const RESOURCE_PREFIXES = [
|
|
591
|
+
{ prefix: 'sbx_', type: 'sandbox' },
|
|
592
|
+
{ prefix: 'proj_', type: 'project' },
|
|
593
|
+
{ prefix: 'db_', type: 'db' },
|
|
594
|
+
{ prefix: 'deploy_', type: 'deployment' },
|
|
595
|
+
{ prefix: 'machine_', type: 'machine' },
|
|
596
|
+
{ prefix: 'que_', type: 'queue' },
|
|
597
|
+
{ prefix: 'vec_', type: 'vector' },
|
|
598
|
+
{ prefix: 'kv_', type: 'kv' },
|
|
599
|
+
{ prefix: 'stream_', type: 'stream' },
|
|
600
|
+
];
|
|
601
|
+
function getResourceTypeFromId(id) {
|
|
602
|
+
for (const entry of RESOURCE_PREFIXES) {
|
|
603
|
+
if (id.startsWith(entry.prefix)) {
|
|
604
|
+
return entry.type;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
return undefined;
|
|
608
|
+
}
|
|
609
|
+
function collectPrefixedResources(values) {
|
|
610
|
+
if (!values) {
|
|
611
|
+
return [];
|
|
612
|
+
}
|
|
613
|
+
const results = new Map();
|
|
614
|
+
const addValue = (value) => {
|
|
615
|
+
if (typeof value === 'string') {
|
|
616
|
+
const resourceType = getResourceTypeFromId(value);
|
|
617
|
+
if (resourceType) {
|
|
618
|
+
results.set(value, resourceType);
|
|
619
|
+
}
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
if (Array.isArray(value)) {
|
|
623
|
+
for (const entry of value) {
|
|
624
|
+
addValue(entry);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
if (Array.isArray(values)) {
|
|
629
|
+
for (const entry of values) {
|
|
630
|
+
addValue(entry);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
for (const value of Object.values(values)) {
|
|
635
|
+
addValue(value);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return Array.from(results.entries()).map(([id, type]) => ({ id, type }));
|
|
639
|
+
}
|
|
640
|
+
export async function resolveRegion(opts) {
|
|
641
|
+
const { options, regions, logger, required, config, args } = opts;
|
|
560
642
|
// No regions available
|
|
561
643
|
if (regions.length === 0) {
|
|
562
644
|
if (required) {
|
|
@@ -568,7 +650,7 @@ async function resolveRegion(opts) {
|
|
|
568
650
|
return undefined;
|
|
569
651
|
}
|
|
570
652
|
// Check if region was provided via flag
|
|
571
|
-
let region =
|
|
653
|
+
let region = options.region;
|
|
572
654
|
// Validate --region flag if provided
|
|
573
655
|
if (region) {
|
|
574
656
|
const found = regions.find((r) => r.region === region);
|
|
@@ -578,6 +660,21 @@ async function resolveRegion(opts) {
|
|
|
578
660
|
}
|
|
579
661
|
return region;
|
|
580
662
|
}
|
|
663
|
+
const profileName = config?.name ?? defaultProfileName;
|
|
664
|
+
const candidateResources = new Map();
|
|
665
|
+
for (const resource of collectPrefixedResources(args)) {
|
|
666
|
+
candidateResources.set(resource.id, resource.type);
|
|
667
|
+
}
|
|
668
|
+
for (const resource of collectPrefixedResources(options)) {
|
|
669
|
+
candidateResources.set(resource.id, resource.type);
|
|
670
|
+
}
|
|
671
|
+
for (const [id, type] of candidateResources.entries()) {
|
|
672
|
+
const cachedInfo = await getResourceInfo(type, profileName, id);
|
|
673
|
+
if (cachedInfo?.region) {
|
|
674
|
+
logger.trace('resolved region from cache for %s (%s): %s', id, type, cachedInfo.region);
|
|
675
|
+
return cachedInfo.region;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
581
678
|
// Auto-select if only one region available
|
|
582
679
|
const singleRegion = regions[0];
|
|
583
680
|
if (regions.length === 1 && singleRegion) {
|
|
@@ -597,6 +694,27 @@ async function resolveRegion(opts) {
|
|
|
597
694
|
}
|
|
598
695
|
// If not valid, fall through to error/prompt
|
|
599
696
|
}
|
|
697
|
+
// Check for preferred region in config
|
|
698
|
+
const preferredRegion = config?.preferences?.region;
|
|
699
|
+
if (preferredRegion) {
|
|
700
|
+
const matchingRegion = regions.find((r) => r.region === preferredRegion);
|
|
701
|
+
if (matchingRegion) {
|
|
702
|
+
if (process.stdin.isTTY) {
|
|
703
|
+
region = await getRegion(regions, matchingRegion.region);
|
|
704
|
+
return region;
|
|
705
|
+
}
|
|
706
|
+
logger.trace('selected preferred region (non-TTY): %s', matchingRegion.region);
|
|
707
|
+
return matchingRegion.region;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
// Check for project region fallback
|
|
711
|
+
const projectRegion = opts.region;
|
|
712
|
+
if (projectRegion) {
|
|
713
|
+
const matchingRegion = regions.find((r) => r.region === projectRegion);
|
|
714
|
+
if (matchingRegion) {
|
|
715
|
+
return matchingRegion.region;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
600
718
|
// No flag provided - handle TTY vs non-TTY
|
|
601
719
|
if (required && !process.stdin.isTTY) {
|
|
602
720
|
const errorFormat = options.errorFormat;
|
|
@@ -608,6 +726,19 @@ async function resolveRegion(opts) {
|
|
|
608
726
|
if (process.stdin.isTTY) {
|
|
609
727
|
// Interactive mode - prompt user
|
|
610
728
|
region = await getRegion(regions);
|
|
729
|
+
const hasSavedPreference = !!config?.preferences?.region;
|
|
730
|
+
const hasEnvRegion = !!process.env.AGENTUITY_REGION;
|
|
731
|
+
const hasTTY = process.stdin.isTTY && process.stdout.isTTY;
|
|
732
|
+
if (region && hasTTY && !hasSavedPreference && !hasEnvRegion) {
|
|
733
|
+
const selectedRegionInfo = regions.find((r) => r.region === region);
|
|
734
|
+
const regionLabel = selectedRegionInfo
|
|
735
|
+
? `${selectedRegionInfo.description} (${selectedRegionInfo.region})`
|
|
736
|
+
: region;
|
|
737
|
+
const shouldSave = await tui.confirm(`Would you like to set "${regionLabel}" as your default region?`, true);
|
|
738
|
+
if (shouldSave) {
|
|
739
|
+
await saveRegion(region);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
611
742
|
return region;
|
|
612
743
|
}
|
|
613
744
|
// Non-interactive, optional region - return undefined
|
|
@@ -824,41 +955,51 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
824
955
|
let projectDir;
|
|
825
956
|
const dirNeeded = normalized.requiresProject || normalized.optionalProject;
|
|
826
957
|
if (dirNeeded) {
|
|
827
|
-
const
|
|
828
|
-
//
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
setCachedProject(profile, projectId, projectDetails);
|
|
851
|
-
}
|
|
852
|
-
project = {
|
|
853
|
-
projectId: projectDetails.id,
|
|
854
|
-
orgId: projectDetails.orgId,
|
|
855
|
-
region: projectDetails.cloudRegion || '',
|
|
856
|
-
};
|
|
958
|
+
const optionsProjectId = options.projectId;
|
|
959
|
+
// Helper to fetch project from API by ID
|
|
960
|
+
const fetchProjectFromAPI = async (projectId) => {
|
|
961
|
+
const auth = await requireAuth(baseCtx);
|
|
962
|
+
if (auth) {
|
|
963
|
+
// Create config with auth credentials for API client
|
|
964
|
+
const configWithAuth = {
|
|
965
|
+
...baseCtx.config,
|
|
966
|
+
auth: {
|
|
967
|
+
api_key: auth.apiKey,
|
|
968
|
+
user_id: auth.userId,
|
|
969
|
+
expires: auth.expires.getTime(),
|
|
970
|
+
},
|
|
971
|
+
};
|
|
972
|
+
const apiClient = createAPIClient(baseCtx, configWithAuth);
|
|
973
|
+
// Check cache first to avoid duplicate API calls
|
|
974
|
+
const profile = baseCtx.config?.name ?? 'default';
|
|
975
|
+
let projectDetails = getCachedProject(profile, projectId);
|
|
976
|
+
if (!projectDetails) {
|
|
977
|
+
const { projectGet } = await import('@agentuity/server');
|
|
978
|
+
// Use keys: false to match other callers and ensure cache consistency
|
|
979
|
+
projectDetails = await projectGet(apiClient, { id: projectId, keys: false });
|
|
980
|
+
setCachedProject(profile, projectId, projectDetails);
|
|
857
981
|
}
|
|
982
|
+
return {
|
|
983
|
+
projectId: projectDetails.id,
|
|
984
|
+
orgId: projectDetails.orgId,
|
|
985
|
+
region: projectDetails.cloudRegion || '',
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
return undefined;
|
|
989
|
+
};
|
|
990
|
+
// Resolution precedence:
|
|
991
|
+
// 1. --project-id flag (or AGENTUITY_CLOUD_PROJECT_ID env var)
|
|
992
|
+
// 2. agentuity.json in project directory
|
|
993
|
+
// 3. config.preferences.projectId (global preference) - fallback only
|
|
994
|
+
// 4. Interactive selection (if TTY)
|
|
995
|
+
if (optionsProjectId) {
|
|
996
|
+
// Priority 1: Explicit flag/env var provided
|
|
997
|
+
try {
|
|
998
|
+
project = await fetchProjectFromAPI(optionsProjectId);
|
|
858
999
|
}
|
|
859
1000
|
catch (_error) {
|
|
860
1001
|
if (normalized.requiresProject) {
|
|
861
|
-
exitWithError(createError(ErrorCode.PROJECT_NOT_FOUND, `Project not found: ${
|
|
1002
|
+
exitWithError(createError(ErrorCode.PROJECT_NOT_FOUND, `Project not found: ${optionsProjectId}`, undefined, [
|
|
862
1003
|
'Verify the project ID is correct',
|
|
863
1004
|
`Run "${getCommand('project list')}" to see available projects`,
|
|
864
1005
|
]), baseCtx.logger, baseCtx.options.errorFormat);
|
|
@@ -866,7 +1007,7 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
866
1007
|
}
|
|
867
1008
|
}
|
|
868
1009
|
else {
|
|
869
|
-
// Try to load from directory
|
|
1010
|
+
// Priority 2: Try to load from agentuity.json in directory
|
|
870
1011
|
const dir = options.dir ?? process.cwd();
|
|
871
1012
|
projectDir = dir;
|
|
872
1013
|
if (projectDir.startsWith('~/')) {
|
|
@@ -877,12 +1018,28 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
877
1018
|
project = await loadProjectConfig(dir, baseCtx.config);
|
|
878
1019
|
}
|
|
879
1020
|
catch (error) {
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
1021
|
+
const isConfigNotFound = error &&
|
|
1022
|
+
typeof error === 'object' &&
|
|
1023
|
+
'name' in error &&
|
|
1024
|
+
error.name === 'ProjectConfigNotFoundException';
|
|
1025
|
+
if (isConfigNotFound) {
|
|
1026
|
+
// Priority 3: Try global preference (only when no agentuity.json found)
|
|
1027
|
+
const projectIdFromPreference = baseCtx.config?.preferences?.projectId;
|
|
1028
|
+
if (projectIdFromPreference) {
|
|
1029
|
+
try {
|
|
1030
|
+
project = await fetchProjectFromAPI(projectIdFromPreference);
|
|
1031
|
+
if (project) {
|
|
1032
|
+
// Set the project ID in options so it can be used by the command
|
|
1033
|
+
options.projectId = projectIdFromPreference;
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
catch (_preferenceError) {
|
|
1037
|
+
// Preference project not found, fall through to interactive selection
|
|
1038
|
+
baseCtx.logger.trace('Preference project not found: %s', projectIdFromPreference);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
// Priority 4: Interactive selection (if TTY and still no project)
|
|
1042
|
+
if (!project && normalized.requiresProject) {
|
|
886
1043
|
const hasTTY = process.stdin.isTTY && process.stdout.isTTY;
|
|
887
1044
|
if (hasTTY) {
|
|
888
1045
|
// Try to prompt for project selection
|
|
@@ -909,9 +1066,9 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
909
1066
|
]), baseCtx.logger, baseCtx.options.errorFormat);
|
|
910
1067
|
}
|
|
911
1068
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
1069
|
+
}
|
|
1070
|
+
else if (normalized.requiresProject) {
|
|
1071
|
+
throw error;
|
|
915
1072
|
}
|
|
916
1073
|
// For optional projects, silently continue without project config
|
|
917
1074
|
}
|
|
@@ -960,8 +1117,19 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
960
1117
|
}
|
|
961
1118
|
// Auto-select org when --confirm flag is used
|
|
962
1119
|
const autoSelectOrg = options.confirm === true;
|
|
1120
|
+
const hasPrefixedId = hasPrefixedResourceId(ctx.args, ctx.opts);
|
|
1121
|
+
const prefixedOrgId = hasPrefixedId
|
|
1122
|
+
? await resolveOrgIdWithoutPrompt({
|
|
1123
|
+
options,
|
|
1124
|
+
config: ctx.config ?? null,
|
|
1125
|
+
args: ctx.args,
|
|
1126
|
+
opts: ctx.opts,
|
|
1127
|
+
})
|
|
1128
|
+
: undefined;
|
|
963
1129
|
if (normalized.requiresOrg) {
|
|
964
|
-
ctx.orgId =
|
|
1130
|
+
ctx.orgId = hasPrefixedId
|
|
1131
|
+
? prefixedOrgId
|
|
1132
|
+
: await requireOrg(ctx, autoSelectOrg);
|
|
965
1133
|
}
|
|
966
1134
|
// Skip org handling if --no-register is set (org only needed for registration)
|
|
967
1135
|
const skipOrg = normalized.optionalOrg &&
|
|
@@ -969,7 +1137,9 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
969
1137
|
ctx.opts &&
|
|
970
1138
|
ctx.opts.register === false;
|
|
971
1139
|
if (normalized.optionalOrg && ctx.auth && !skipOrg) {
|
|
972
|
-
ctx.orgId =
|
|
1140
|
+
ctx.orgId = hasPrefixedId
|
|
1141
|
+
? prefixedOrgId
|
|
1142
|
+
: await selectOptionalOrg(ctx, autoSelectOrg);
|
|
973
1143
|
}
|
|
974
1144
|
// Skip region handling if --no-register is set (region only needed for registration)
|
|
975
1145
|
const skipRegion = normalized.optionalRegion &&
|
|
@@ -996,10 +1166,12 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
996
1166
|
if (normalized.requiresRegion || normalized.optionalRegion) {
|
|
997
1167
|
const region = await resolveRegion({
|
|
998
1168
|
options: options,
|
|
1169
|
+
args: ctx.args,
|
|
999
1170
|
regions,
|
|
1000
1171
|
logger: baseCtx.logger,
|
|
1001
1172
|
required: !!normalized.requiresRegion,
|
|
1002
1173
|
region: project?.region,
|
|
1174
|
+
config: baseCtx.config ?? null,
|
|
1003
1175
|
});
|
|
1004
1176
|
if (region) {
|
|
1005
1177
|
ctx.region = region;
|
|
@@ -1043,8 +1215,18 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
1043
1215
|
}
|
|
1044
1216
|
// Auto-select org when --confirm flag is used
|
|
1045
1217
|
const autoSelectOrg2 = options.confirm === true;
|
|
1218
|
+
const hasPrefixedId = hasPrefixedResourceId(args);
|
|
1219
|
+
const prefixedOrgId = hasPrefixedId
|
|
1220
|
+
? await resolveOrgIdWithoutPrompt({
|
|
1221
|
+
options,
|
|
1222
|
+
config: ctx.config ?? null,
|
|
1223
|
+
args: args,
|
|
1224
|
+
})
|
|
1225
|
+
: undefined;
|
|
1046
1226
|
if (normalized.requiresOrg) {
|
|
1047
|
-
ctx.orgId =
|
|
1227
|
+
ctx.orgId = hasPrefixedId
|
|
1228
|
+
? prefixedOrgId
|
|
1229
|
+
: await requireOrg(ctx, autoSelectOrg2);
|
|
1048
1230
|
}
|
|
1049
1231
|
// Skip org handling if --no-register is set (org only needed for registration)
|
|
1050
1232
|
const skipOrg = normalized.optionalOrg &&
|
|
@@ -1052,7 +1234,9 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
1052
1234
|
ctx.opts &&
|
|
1053
1235
|
ctx.opts.register === false;
|
|
1054
1236
|
if (normalized.optionalOrg && ctx.auth && !skipOrg) {
|
|
1055
|
-
ctx.orgId =
|
|
1237
|
+
ctx.orgId = hasPrefixedId
|
|
1238
|
+
? prefixedOrgId
|
|
1239
|
+
: await selectOptionalOrg(ctx, autoSelectOrg2);
|
|
1056
1240
|
}
|
|
1057
1241
|
// Skip region handling if --no-register is set (region only needed for registration)
|
|
1058
1242
|
const skipRegion = normalized.optionalRegion &&
|
|
@@ -1079,10 +1263,12 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
1079
1263
|
if (normalized.requiresRegion || normalized.optionalRegion) {
|
|
1080
1264
|
const region = await resolveRegion({
|
|
1081
1265
|
options: options,
|
|
1266
|
+
args: args,
|
|
1082
1267
|
regions,
|
|
1083
1268
|
logger: baseCtx.logger,
|
|
1084
1269
|
required: !!normalized.requiresRegion,
|
|
1085
1270
|
region: project?.region,
|
|
1271
|
+
config: baseCtx.config ?? null,
|
|
1086
1272
|
});
|
|
1087
1273
|
if (region) {
|
|
1088
1274
|
ctx.region = region;
|
|
@@ -1090,8 +1276,9 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
1090
1276
|
}
|
|
1091
1277
|
}
|
|
1092
1278
|
if (subcommand.handler) {
|
|
1093
|
-
maybeRenderWebLink(ctx, subcommand.webUrl);
|
|
1094
1279
|
const result = await subcommand.handler(ctx);
|
|
1280
|
+
// Render "View on the web" link after successful execution (not shown on errors)
|
|
1281
|
+
maybeRenderWebLink(ctx, subcommand.webUrl);
|
|
1095
1282
|
// If --json flag is set
|
|
1096
1283
|
if (baseCtx.options.json) {
|
|
1097
1284
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1159,8 +1346,19 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
1159
1346
|
baseCtx.logger.trace('optionalAuth path: org=%s, region=%s, hasApiClient=%s, hasAuth=%s', normalized.optionalOrg, normalized.optionalRegion, !!ctx.apiClient, !!auth);
|
|
1160
1347
|
// Auto-select org when --confirm flag is used
|
|
1161
1348
|
const autoSelectOrg3 = options.confirm === true;
|
|
1349
|
+
const hasPrefixedId3 = hasPrefixedResourceId(ctx.args, ctx.opts);
|
|
1350
|
+
const prefixedOrgId3 = hasPrefixedId3
|
|
1351
|
+
? await resolveOrgIdWithoutPrompt({
|
|
1352
|
+
options,
|
|
1353
|
+
config: ctx.config ?? null,
|
|
1354
|
+
args: ctx.args,
|
|
1355
|
+
opts: ctx.opts,
|
|
1356
|
+
})
|
|
1357
|
+
: undefined;
|
|
1162
1358
|
if (normalized.requiresOrg && ctx.apiClient) {
|
|
1163
|
-
ctx.orgId =
|
|
1359
|
+
ctx.orgId = hasPrefixedId3
|
|
1360
|
+
? prefixedOrgId3
|
|
1361
|
+
: await requireOrg(ctx, autoSelectOrg3);
|
|
1164
1362
|
}
|
|
1165
1363
|
// Skip org handling if --no-register is set (org only needed for registration)
|
|
1166
1364
|
const skipOrg = normalized.optionalOrg &&
|
|
@@ -1168,7 +1366,9 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
1168
1366
|
ctx.opts &&
|
|
1169
1367
|
ctx.opts.register === false;
|
|
1170
1368
|
if (normalized.optionalOrg && ctx.apiClient && auth && !skipOrg) {
|
|
1171
|
-
ctx.orgId =
|
|
1369
|
+
ctx.orgId = hasPrefixedId3
|
|
1370
|
+
? prefixedOrgId3
|
|
1371
|
+
: await selectOptionalOrg(ctx, autoSelectOrg3);
|
|
1172
1372
|
baseCtx.logger.trace('selected orgId: %s', ctx.orgId);
|
|
1173
1373
|
}
|
|
1174
1374
|
// Skip region handling if --no-register is set (region only needed for registration)
|
|
@@ -1190,10 +1390,12 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
1190
1390
|
});
|
|
1191
1391
|
const region = await resolveRegion({
|
|
1192
1392
|
options: options,
|
|
1393
|
+
args: ctx.args,
|
|
1193
1394
|
regions,
|
|
1194
1395
|
logger: baseCtx.logger,
|
|
1195
1396
|
required: !!normalized.requiresRegion,
|
|
1196
1397
|
region: project?.region,
|
|
1398
|
+
config: baseCtx.config ?? null,
|
|
1197
1399
|
});
|
|
1198
1400
|
if (region) {
|
|
1199
1401
|
ctx.region = region;
|
|
@@ -1235,8 +1437,18 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
1235
1437
|
}
|
|
1236
1438
|
// Auto-select org when --confirm flag is used
|
|
1237
1439
|
const autoSelectOrg4 = options.confirm === true;
|
|
1440
|
+
const hasPrefixedId4 = hasPrefixedResourceId(args);
|
|
1441
|
+
const prefixedOrgId4 = hasPrefixedId4
|
|
1442
|
+
? await resolveOrgIdWithoutPrompt({
|
|
1443
|
+
options,
|
|
1444
|
+
config: ctx.config ?? null,
|
|
1445
|
+
args: args,
|
|
1446
|
+
})
|
|
1447
|
+
: undefined;
|
|
1238
1448
|
if (normalized.requiresOrg && ctx.apiClient) {
|
|
1239
|
-
ctx.orgId =
|
|
1449
|
+
ctx.orgId = hasPrefixedId4
|
|
1450
|
+
? prefixedOrgId4
|
|
1451
|
+
: await requireOrg(ctx, autoSelectOrg4);
|
|
1240
1452
|
}
|
|
1241
1453
|
// Skip org handling if --no-register is set (org only needed for registration)
|
|
1242
1454
|
// For non-schema commands, check options directly (Commander passes all options)
|
|
@@ -1244,7 +1456,9 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
1244
1456
|
!normalized.requiresOrg &&
|
|
1245
1457
|
options.register === false;
|
|
1246
1458
|
if (normalized.optionalOrg && ctx.apiClient && !skipOrg) {
|
|
1247
|
-
ctx.orgId =
|
|
1459
|
+
ctx.orgId = hasPrefixedId4
|
|
1460
|
+
? prefixedOrgId4
|
|
1461
|
+
: await selectOptionalOrg(ctx, autoSelectOrg4);
|
|
1248
1462
|
}
|
|
1249
1463
|
// Skip region handling if --no-register is set (region only needed for registration)
|
|
1250
1464
|
const skipRegion = normalized.optionalRegion &&
|
|
@@ -1263,18 +1477,21 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
1263
1477
|
});
|
|
1264
1478
|
const region = await resolveRegion({
|
|
1265
1479
|
options: options,
|
|
1480
|
+
args: args,
|
|
1266
1481
|
regions,
|
|
1267
1482
|
logger: baseCtx.logger,
|
|
1268
1483
|
required: !!normalized.requiresRegion,
|
|
1269
1484
|
region: project?.region,
|
|
1485
|
+
config: baseCtx.config ?? null,
|
|
1270
1486
|
});
|
|
1271
1487
|
if (region) {
|
|
1272
1488
|
ctx.region = region;
|
|
1273
1489
|
}
|
|
1274
1490
|
}
|
|
1275
1491
|
if (subcommand.handler) {
|
|
1276
|
-
maybeRenderWebLink(ctx, subcommand.webUrl);
|
|
1277
1492
|
const result = await subcommand.handler(ctx);
|
|
1493
|
+
// Render "View on the web" link after successful execution (not shown on errors)
|
|
1494
|
+
maybeRenderWebLink(ctx, subcommand.webUrl);
|
|
1278
1495
|
// If --json flag is set
|
|
1279
1496
|
if (baseCtx.options.json) {
|
|
1280
1497
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1368,18 +1585,21 @@ async function registerSubcommand(parent, subcommand, baseCtx, hidden) {
|
|
|
1368
1585
|
});
|
|
1369
1586
|
const region = await resolveRegion({
|
|
1370
1587
|
options: options,
|
|
1588
|
+
args: args,
|
|
1371
1589
|
regions,
|
|
1372
1590
|
logger: baseCtx.logger,
|
|
1373
1591
|
required: !!normalized.requiresRegion,
|
|
1374
1592
|
region: project?.region,
|
|
1593
|
+
config: baseCtx.config ?? null,
|
|
1375
1594
|
});
|
|
1376
1595
|
if (region) {
|
|
1377
1596
|
ctx.region = region;
|
|
1378
1597
|
}
|
|
1379
1598
|
}
|
|
1380
1599
|
if (subcommand.handler) {
|
|
1381
|
-
maybeRenderWebLink(ctx, subcommand.webUrl);
|
|
1382
1600
|
const result = await subcommand.handler(ctx);
|
|
1601
|
+
// Render "View on the web" link after successful execution (not shown on errors)
|
|
1602
|
+
maybeRenderWebLink(ctx, subcommand.webUrl);
|
|
1383
1603
|
// If --json flag is set
|
|
1384
1604
|
if (baseCtx.options.json) {
|
|
1385
1605
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1478,6 +1698,7 @@ export async function registerCommands(program, commands, baseCtx) {
|
|
|
1478
1698
|
regions,
|
|
1479
1699
|
logger: baseCtx.logger,
|
|
1480
1700
|
required: !!normalized.requiresRegion,
|
|
1701
|
+
config: baseCtx.config ?? null,
|
|
1481
1702
|
});
|
|
1482
1703
|
if (region) {
|
|
1483
1704
|
ctx.region = region;
|
|
@@ -1534,6 +1755,7 @@ export async function registerCommands(program, commands, baseCtx) {
|
|
|
1534
1755
|
regions,
|
|
1535
1756
|
logger: baseCtx.logger,
|
|
1536
1757
|
required: !!normalized.requiresRegion,
|
|
1758
|
+
config: baseCtx.config ?? null,
|
|
1537
1759
|
});
|
|
1538
1760
|
if (region) {
|
|
1539
1761
|
ctx.region = region;
|
|
@@ -1562,6 +1784,7 @@ export async function registerCommands(program, commands, baseCtx) {
|
|
|
1562
1784
|
regions,
|
|
1563
1785
|
logger: baseCtx.logger,
|
|
1564
1786
|
required: !!normalized.requiresRegion,
|
|
1787
|
+
config: baseCtx.config ?? null,
|
|
1565
1788
|
});
|
|
1566
1789
|
if (region) {
|
|
1567
1790
|
ctx.region = region;
|