@agentuity/cli 0.0.48 → 0.0.49
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/bin/cli.ts +26 -5
- package/dist/banner.d.ts +1 -1
- package/dist/banner.d.ts.map +1 -1
- package/dist/cli-logger.d.ts +27 -0
- package/dist/cli-logger.d.ts.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cmd/auth/index.d.ts.map +1 -1
- package/dist/cmd/auth/login.d.ts.map +1 -1
- package/dist/cmd/auth/logout.d.ts.map +1 -1
- package/dist/cmd/auth/signup.d.ts.map +1 -1
- package/dist/cmd/auth/ssh/add.d.ts.map +1 -1
- package/dist/cmd/auth/ssh/delete.d.ts.map +1 -1
- package/dist/cmd/auth/ssh/index.d.ts +1 -2
- package/dist/cmd/auth/ssh/index.d.ts.map +1 -1
- package/dist/cmd/auth/ssh/list.d.ts.map +1 -1
- package/dist/cmd/auth/whoami.d.ts.map +1 -1
- package/dist/cmd/bundle/ast.d.ts.map +1 -1
- package/dist/cmd/bundle/index.d.ts.map +1 -1
- package/dist/cmd/bundle/plugin.d.ts.map +1 -1
- package/dist/cmd/capabilities/index.d.ts +4 -0
- package/dist/cmd/capabilities/index.d.ts.map +1 -0
- package/dist/cmd/capabilities/show.d.ts +20 -0
- package/dist/cmd/capabilities/show.d.ts.map +1 -0
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/index.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/list.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/remove.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/rollback.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/show.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/undeploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/utils.d.ts +4 -2
- package/dist/cmd/cloud/deployment/utils.d.ts.map +1 -1
- package/dist/cmd/cloud/domain.d.ts.map +1 -1
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/resource/add.d.ts.map +1 -1
- package/dist/cmd/cloud/resource/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/resource/index.d.ts +1 -2
- package/dist/cmd/cloud/resource/index.d.ts.map +1 -1
- package/dist/cmd/cloud/resource/list.d.ts.map +1 -1
- package/dist/cmd/cloud/scp/download.d.ts.map +1 -1
- package/dist/cmd/cloud/scp/index.d.ts +1 -2
- package/dist/cmd/cloud/scp/index.d.ts.map +1 -1
- package/dist/cmd/cloud/scp/upload.d.ts.map +1 -1
- package/dist/cmd/cloud/ssh.d.ts.map +1 -1
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/env/delete.d.ts.map +1 -1
- package/dist/cmd/env/get.d.ts.map +1 -1
- package/dist/cmd/env/import.d.ts.map +1 -1
- package/dist/cmd/env/index.d.ts.map +1 -1
- package/dist/cmd/env/list.d.ts.map +1 -1
- package/dist/cmd/env/pull.d.ts.map +1 -1
- package/dist/cmd/env/push.d.ts.map +1 -1
- package/dist/cmd/env/set.d.ts.map +1 -1
- package/dist/cmd/index.d.ts.map +1 -1
- package/dist/cmd/kv/create-namespace.d.ts +3 -0
- package/dist/cmd/kv/create-namespace.d.ts.map +1 -0
- package/dist/cmd/kv/delete-namespace.d.ts +3 -0
- package/dist/cmd/kv/delete-namespace.d.ts.map +1 -0
- package/dist/cmd/kv/delete.d.ts +3 -0
- package/dist/cmd/kv/delete.d.ts.map +1 -0
- package/dist/cmd/kv/get.d.ts +3 -0
- package/dist/cmd/kv/get.d.ts.map +1 -0
- package/dist/cmd/kv/index.d.ts +2 -0
- package/dist/cmd/kv/index.d.ts.map +1 -0
- package/dist/cmd/kv/keys.d.ts +3 -0
- package/dist/cmd/kv/keys.d.ts.map +1 -0
- package/dist/cmd/kv/list-namespaces.d.ts +3 -0
- package/dist/cmd/kv/list-namespaces.d.ts.map +1 -0
- package/dist/cmd/kv/repl.d.ts +3 -0
- package/dist/cmd/kv/repl.d.ts.map +1 -0
- package/dist/cmd/kv/search.d.ts +3 -0
- package/dist/cmd/kv/search.d.ts.map +1 -0
- package/dist/cmd/kv/set.d.ts +3 -0
- package/dist/cmd/kv/set.d.ts.map +1 -0
- package/dist/cmd/kv/stats.d.ts +3 -0
- package/dist/cmd/kv/stats.d.ts.map +1 -0
- package/dist/cmd/kv/util.d.ts +8 -0
- package/dist/cmd/kv/util.d.ts.map +1 -0
- package/dist/cmd/objectstore/delete-bucket.d.ts +3 -0
- package/dist/cmd/objectstore/delete-bucket.d.ts.map +1 -0
- package/dist/cmd/objectstore/delete.d.ts +3 -0
- package/dist/cmd/objectstore/delete.d.ts.map +1 -0
- package/dist/cmd/objectstore/get.d.ts +3 -0
- package/dist/cmd/objectstore/get.d.ts.map +1 -0
- package/dist/cmd/objectstore/index.d.ts +2 -0
- package/dist/cmd/objectstore/index.d.ts.map +1 -0
- package/dist/cmd/objectstore/list-buckets.d.ts +3 -0
- package/dist/cmd/objectstore/list-buckets.d.ts.map +1 -0
- package/dist/cmd/objectstore/list-keys.d.ts +3 -0
- package/dist/cmd/objectstore/list-keys.d.ts.map +1 -0
- package/dist/cmd/objectstore/put.d.ts +3 -0
- package/dist/cmd/objectstore/put.d.ts.map +1 -0
- package/dist/cmd/objectstore/repl.d.ts +3 -0
- package/dist/cmd/objectstore/repl.d.ts.map +1 -0
- package/dist/cmd/objectstore/url.d.ts +3 -0
- package/dist/cmd/objectstore/url.d.ts.map +1 -0
- package/dist/cmd/objectstore/util.d.ts +8 -0
- package/dist/cmd/objectstore/util.d.ts.map +1 -0
- package/dist/cmd/profile/create.d.ts.map +1 -1
- package/dist/cmd/profile/delete.d.ts.map +1 -1
- package/dist/cmd/profile/index.d.ts.map +1 -1
- package/dist/cmd/profile/list.d.ts +1 -2
- package/dist/cmd/profile/list.d.ts.map +1 -1
- package/dist/cmd/profile/show.d.ts.map +1 -1
- package/dist/cmd/profile/use.d.ts.map +1 -1
- package/dist/cmd/project/create.d.ts.map +1 -1
- package/dist/cmd/project/delete.d.ts.map +1 -1
- package/dist/cmd/project/index.d.ts.map +1 -1
- package/dist/cmd/project/list.d.ts.map +1 -1
- package/dist/cmd/project/show.d.ts.map +1 -1
- package/dist/cmd/project/template-flow.d.ts +1 -1
- package/dist/cmd/project/template-flow.d.ts.map +1 -1
- package/dist/cmd/prompt/index.d.ts +4 -0
- package/dist/cmd/prompt/index.d.ts.map +1 -0
- package/dist/cmd/prompt/llm.d.ts +3 -0
- package/dist/cmd/prompt/llm.d.ts.map +1 -0
- package/dist/cmd/repl/index.d.ts +3 -0
- package/dist/cmd/repl/index.d.ts.map +1 -0
- package/dist/cmd/schema/index.d.ts +4 -0
- package/dist/cmd/schema/index.d.ts.map +1 -0
- package/dist/cmd/schema/show.d.ts +3 -0
- package/dist/cmd/schema/show.d.ts.map +1 -0
- package/dist/cmd/secret/delete.d.ts.map +1 -1
- package/dist/cmd/secret/get.d.ts.map +1 -1
- package/dist/cmd/secret/import.d.ts.map +1 -1
- package/dist/cmd/secret/index.d.ts.map +1 -1
- package/dist/cmd/secret/list.d.ts.map +1 -1
- package/dist/cmd/secret/pull.d.ts.map +1 -1
- package/dist/cmd/secret/push.d.ts.map +1 -1
- package/dist/cmd/secret/set.d.ts.map +1 -1
- package/dist/cmd/version/index.d.ts.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/errors.d.ts +83 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/explain.d.ts +47 -0
- package/dist/explain.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/json.d.ts +3 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/output.d.ts +136 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/repl.d.ts +124 -0
- package/dist/repl.d.ts.map +1 -0
- package/dist/schema-generator.d.ts +67 -0
- package/dist/schema-generator.d.ts.map +1 -0
- package/dist/tui.d.ts +11 -1
- package/dist/tui.d.ts.map +1 -1
- package/dist/types.d.ts +65 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -4
- package/src/banner.ts +7 -7
- package/src/cli-logger.ts +80 -0
- package/src/cli.ts +186 -54
- package/src/cmd/auth/index.ts +1 -0
- package/src/cmd/auth/login.ts +7 -2
- package/src/cmd/auth/logout.ts +4 -0
- package/src/cmd/auth/signup.ts +7 -2
- package/src/cmd/auth/ssh/add.ts +20 -3
- package/src/cmd/auth/ssh/delete.ts +57 -4
- package/src/cmd/auth/ssh/index.ts +4 -3
- package/src/cmd/auth/ssh/list.ts +29 -12
- package/src/cmd/auth/whoami.ts +32 -21
- package/src/cmd/bundle/ast.ts +27 -5
- package/src/cmd/bundle/index.ts +20 -0
- package/src/cmd/bundle/plugin.ts +36 -12
- package/src/cmd/capabilities/index.ts +12 -0
- package/src/cmd/capabilities/show.ts +256 -0
- package/src/cmd/cloud/deploy.ts +54 -0
- package/src/cmd/cloud/deployment/index.ts +1 -0
- package/src/cmd/cloud/deployment/list.ts +50 -3
- package/src/cmd/cloud/deployment/remove.ts +26 -2
- package/src/cmd/cloud/deployment/rollback.ts +35 -4
- package/src/cmd/cloud/deployment/show.ts +37 -2
- package/src/cmd/cloud/deployment/undeploy.ts +12 -1
- package/src/cmd/cloud/deployment/utils.ts +5 -2
- package/src/cmd/cloud/domain.ts +3 -2
- package/src/cmd/cloud/index.ts +8 -1
- package/src/cmd/cloud/resource/add.ts +19 -0
- package/src/cmd/cloud/resource/delete.ts +24 -3
- package/src/cmd/cloud/resource/index.ts +4 -3
- package/src/cmd/cloud/resource/list.ts +36 -10
- package/src/cmd/cloud/scp/download.ts +27 -1
- package/src/cmd/cloud/scp/index.ts +4 -3
- package/src/cmd/cloud/scp/upload.ts +27 -1
- package/src/cmd/cloud/ssh.ts +12 -0
- package/src/cmd/dev/index.ts +11 -7
- package/src/cmd/dev/templates.ts +1 -1
- package/src/cmd/env/delete.ts +17 -0
- package/src/cmd/env/get.ts +17 -1
- package/src/cmd/env/import.ts +47 -3
- package/src/cmd/env/index.ts +1 -0
- package/src/cmd/env/list.ts +13 -1
- package/src/cmd/env/pull.ts +20 -0
- package/src/cmd/env/push.ts +33 -1
- package/src/cmd/env/set.ts +25 -1
- package/src/cmd/index.ts +9 -2
- package/src/cmd/kv/create-namespace.ts +45 -0
- package/src/cmd/kv/delete-namespace.ts +73 -0
- package/src/cmd/kv/delete.ts +51 -0
- package/src/cmd/kv/get.ts +65 -0
- package/src/cmd/kv/index.ts +31 -0
- package/src/cmd/kv/keys.ts +57 -0
- package/src/cmd/kv/list-namespaces.ts +43 -0
- package/src/cmd/kv/repl.ts +284 -0
- package/src/cmd/kv/search.ts +80 -0
- package/src/cmd/kv/set.ts +63 -0
- package/src/cmd/kv/stats.ts +96 -0
- package/src/cmd/kv/util.ts +32 -0
- package/src/cmd/objectstore/delete-bucket.ts +72 -0
- package/src/cmd/objectstore/delete.ts +59 -0
- package/src/cmd/objectstore/get.ts +64 -0
- package/src/cmd/objectstore/index.ts +27 -0
- package/src/cmd/objectstore/list-buckets.ts +45 -0
- package/src/cmd/objectstore/list-keys.ts +60 -0
- package/src/cmd/objectstore/put.ts +62 -0
- package/src/cmd/objectstore/repl.ts +235 -0
- package/src/cmd/objectstore/url.ts +59 -0
- package/src/cmd/objectstore/util.ts +28 -0
- package/src/cmd/profile/create.ts +28 -2
- package/src/cmd/profile/delete.ts +17 -2
- package/src/cmd/profile/index.ts +1 -0
- package/src/cmd/profile/list.ts +7 -3
- package/src/cmd/profile/show.ts +20 -5
- package/src/cmd/profile/use.ts +8 -0
- package/src/cmd/project/create.ts +31 -0
- package/src/cmd/project/delete.ts +24 -2
- package/src/cmd/project/index.ts +1 -0
- package/src/cmd/project/list.ts +23 -9
- package/src/cmd/project/show.ts +27 -8
- package/src/cmd/project/template-flow.ts +10 -6
- package/src/cmd/prompt/index.ts +12 -0
- package/src/cmd/prompt/llm.ts +368 -0
- package/src/cmd/repl/index.ts +477 -0
- package/src/cmd/schema/index.ts +12 -0
- package/src/cmd/schema/show.ts +27 -0
- package/src/cmd/secret/delete.ts +17 -0
- package/src/cmd/secret/get.ts +20 -1
- package/src/cmd/secret/import.ts +45 -2
- package/src/cmd/secret/index.ts +1 -0
- package/src/cmd/secret/list.ts +10 -1
- package/src/cmd/secret/pull.ts +20 -0
- package/src/cmd/secret/push.ts +33 -1
- package/src/cmd/secret/set.ts +20 -0
- package/src/cmd/version/index.ts +15 -2
- package/src/config.ts +17 -4
- package/src/errors.ts +222 -0
- package/src/explain.ts +126 -0
- package/src/index.ts +51 -0
- package/src/json.ts +28 -0
- package/src/output.ts +307 -0
- package/src/repl.ts +1517 -0
- package/src/schema-generator.ts +389 -0
- package/src/tui.ts +84 -13
- package/src/types.ts +62 -12
|
@@ -2,6 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { createSubcommand } from '../../../types';
|
|
3
3
|
import * as tui from '../../../tui';
|
|
4
4
|
import { getIONHost } from '../../../config';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
5
6
|
|
|
6
7
|
const args = z.object({
|
|
7
8
|
source: z.string().describe('the source file'),
|
|
@@ -16,9 +17,27 @@ export const downloadCommand = createSubcommand({
|
|
|
16
17
|
name: 'download',
|
|
17
18
|
aliases: ['get'],
|
|
18
19
|
description: 'Download a file using security copy',
|
|
20
|
+
tags: ['read-only', 'slow', 'requires-auth', 'requires-deployment'],
|
|
21
|
+
idempotent: true,
|
|
22
|
+
examples: [
|
|
23
|
+
`${getCommand('cloud scp download')} /var/log/app.log # Download to current directory`,
|
|
24
|
+
`${getCommand('cloud scp download')} /var/log/app.log ./logs/ # Download to specific path`,
|
|
25
|
+
`${getCommand('cloud scp download')} /app/config.json --identifier=proj_abc123xyz`,
|
|
26
|
+
`${getCommand('cloud scp download')} ~/logs/*.log ./logs/ # Download multiple files`,
|
|
27
|
+
],
|
|
19
28
|
requires: { apiClient: true, auth: true },
|
|
20
29
|
optional: { project: true },
|
|
21
|
-
|
|
30
|
+
prerequisites: ['cloud deploy'],
|
|
31
|
+
schema: {
|
|
32
|
+
args,
|
|
33
|
+
options,
|
|
34
|
+
response: z.object({
|
|
35
|
+
success: z.boolean().describe('Whether download succeeded'),
|
|
36
|
+
source: z.string().describe('Remote source path'),
|
|
37
|
+
destination: z.string().describe('Local destination path'),
|
|
38
|
+
identifier: z.string().describe('Project or deployment identifier'),
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
22
41
|
|
|
23
42
|
async handler(ctx) {
|
|
24
43
|
const { apiClient, args, opts, project, projectDir, config } = ctx;
|
|
@@ -49,6 +68,13 @@ export const downloadCommand = createSubcommand({
|
|
|
49
68
|
);
|
|
50
69
|
process.exit(spawn.exitCode ?? 1);
|
|
51
70
|
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
success: true,
|
|
74
|
+
source: args.source,
|
|
75
|
+
destination,
|
|
76
|
+
identifier,
|
|
77
|
+
};
|
|
52
78
|
} catch (error) {
|
|
53
79
|
tui.error(
|
|
54
80
|
`SCP download error: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createCommand } from '../../../types';
|
|
2
2
|
import { downloadCommand } from './download';
|
|
3
3
|
import { uploadCommand } from './upload';
|
|
4
4
|
|
|
5
|
-
export const scpSubcommand
|
|
5
|
+
export const scpSubcommand = createCommand({
|
|
6
6
|
name: 'scp',
|
|
7
7
|
description: 'Secure Copy commands',
|
|
8
|
+
tags: ['slow', 'requires-auth', 'requires-deployment'],
|
|
8
9
|
subcommands: [downloadCommand, uploadCommand],
|
|
9
|
-
};
|
|
10
|
+
});
|
|
@@ -2,6 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { createSubcommand } from '../../../types';
|
|
3
3
|
import * as tui from '../../../tui';
|
|
4
4
|
import { getIONHost } from '../../../config';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
5
6
|
|
|
6
7
|
const args = z.object({
|
|
7
8
|
source: z.string().describe('the source file'),
|
|
@@ -19,9 +20,27 @@ export const uploadCommand = createSubcommand({
|
|
|
19
20
|
name: 'upload',
|
|
20
21
|
aliases: ['cp', 'put'],
|
|
21
22
|
description: 'Upload a file using security copy',
|
|
23
|
+
tags: ['mutating', 'updates-resource', 'slow', 'requires-auth', 'requires-deployment'],
|
|
24
|
+
idempotent: false,
|
|
25
|
+
examples: [
|
|
26
|
+
`${getCommand('cloud scp upload')} ./config.json # Upload to remote home directory`,
|
|
27
|
+
`${getCommand('cloud scp upload')} ./config.json /app/config.json # Upload to specific path`,
|
|
28
|
+
`${getCommand('cloud scp upload')} ./config.json --identifier=proj_abc123xyz`,
|
|
29
|
+
`${getCommand('cloud scp upload')} ./logs/*.log ~/logs/ # Upload multiple files`,
|
|
30
|
+
],
|
|
22
31
|
requires: { apiClient: true, auth: true },
|
|
23
|
-
schema: {
|
|
32
|
+
schema: {
|
|
33
|
+
args,
|
|
34
|
+
options,
|
|
35
|
+
response: z.object({
|
|
36
|
+
success: z.boolean().describe('Whether upload succeeded'),
|
|
37
|
+
source: z.string().describe('Local source path'),
|
|
38
|
+
destination: z.string().describe('Remote destination path'),
|
|
39
|
+
identifier: z.string().describe('Project or deployment identifier'),
|
|
40
|
+
}),
|
|
41
|
+
},
|
|
24
42
|
optional: { project: true },
|
|
43
|
+
prerequisites: ['cloud deploy'],
|
|
25
44
|
|
|
26
45
|
async handler(ctx) {
|
|
27
46
|
const { apiClient, args, opts, project, projectDir, config } = ctx;
|
|
@@ -52,6 +71,13 @@ export const uploadCommand = createSubcommand({
|
|
|
52
71
|
);
|
|
53
72
|
process.exit(spawn.exitCode ?? 1);
|
|
54
73
|
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
success: true,
|
|
77
|
+
source: args.source,
|
|
78
|
+
destination,
|
|
79
|
+
identifier,
|
|
80
|
+
};
|
|
55
81
|
} catch (error) {
|
|
56
82
|
tui.error(`SCP upload error: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
57
83
|
process.exit(1);
|
package/src/cmd/cloud/ssh.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { createSubcommand } from '../../types';
|
|
3
3
|
import * as tui from '../../tui';
|
|
4
4
|
import { getIONHost } from '../../config';
|
|
5
|
+
import { getCommand } from '../../command-prefix';
|
|
5
6
|
|
|
6
7
|
const args = z.object({
|
|
7
8
|
identifier: z.string().optional().describe('The project or deployment id to use'),
|
|
@@ -15,9 +16,20 @@ const options = z.object({
|
|
|
15
16
|
export const sshSubcommand = createSubcommand({
|
|
16
17
|
name: 'ssh',
|
|
17
18
|
description: 'SSH into a cloud project',
|
|
19
|
+
tags: ['read-only', 'slow', 'requires-auth', 'requires-deployment'],
|
|
20
|
+
idempotent: true,
|
|
21
|
+
examples: [
|
|
22
|
+
`${getCommand('cloud ssh')} # SSH into current project`,
|
|
23
|
+
`${getCommand('cloud ssh')} proj_abc123xyz # SSH into specific project`,
|
|
24
|
+
`${getCommand('cloud ssh')} deploy_abc123xyz # SSH into specific deployment`,
|
|
25
|
+
`${getCommand('cloud ssh')} 'ps aux' # Run command and exit`,
|
|
26
|
+
`${getCommand('cloud ssh')} proj_abc123xyz 'tail -f /var/log/app.log'`,
|
|
27
|
+
`${getCommand('cloud ssh')} --show # Show SSH command without executing`,
|
|
28
|
+
],
|
|
18
29
|
toplevel: true,
|
|
19
30
|
requires: { auth: true, apiClient: true },
|
|
20
31
|
optional: { project: true },
|
|
32
|
+
prerequisites: ['cloud deploy'],
|
|
21
33
|
schema: { args, options },
|
|
22
34
|
|
|
23
35
|
async handler(ctx) {
|
package/src/cmd/dev/index.ts
CHANGED
|
@@ -5,22 +5,26 @@ import { resolve, join } from 'node:path';
|
|
|
5
5
|
import { bundle } from '../bundle/bundler';
|
|
6
6
|
import { getBuildMetadata } from '../bundle/plugin';
|
|
7
7
|
import { existsSync, type FSWatcher, watch, statSync, readdirSync } from 'node:fs';
|
|
8
|
-
import {
|
|
9
|
-
getDefaultConfigDir,
|
|
10
|
-
loadDevelopmentProjectSDKKey,
|
|
11
|
-
saveProjectDir,
|
|
12
|
-
saveConfig,
|
|
13
|
-
} from '../../config';
|
|
8
|
+
import { getDefaultConfigDir, loadProjectSDKKey, saveProjectDir, saveConfig } from '../../config';
|
|
14
9
|
import { type Config, createCommand } from '../../types';
|
|
15
10
|
import * as tui from '../../tui';
|
|
16
11
|
import { createAgentTemplates, createAPITemplates } from './templates';
|
|
17
12
|
import { generateEndpoint, type DevmodeResponse } from './api';
|
|
18
13
|
import { APIClient, getAPIBaseURL } from '../../api';
|
|
19
14
|
import { download } from './download';
|
|
15
|
+
import { getCommand } from '../../command-prefix';
|
|
20
16
|
|
|
21
17
|
export const command = createCommand({
|
|
22
18
|
name: 'dev',
|
|
23
19
|
description: 'Build and run the development server',
|
|
20
|
+
tags: ['mutating', 'slow', 'requires-project'],
|
|
21
|
+
idempotent: true,
|
|
22
|
+
examples: [
|
|
23
|
+
getCommand('dev'),
|
|
24
|
+
getCommand('dev --port 8080'),
|
|
25
|
+
getCommand('dev --local'),
|
|
26
|
+
getCommand('dev --no-public'),
|
|
27
|
+
],
|
|
24
28
|
schema: {
|
|
25
29
|
options: z.object({
|
|
26
30
|
local: z.boolean().optional().describe('Turn on local services (instead of cloud)'),
|
|
@@ -200,7 +204,7 @@ export const command = createCommand({
|
|
|
200
204
|
let gravityClient: Bun.Subprocess | undefined;
|
|
201
205
|
|
|
202
206
|
if (gravityBin && devmode && project) {
|
|
203
|
-
const sdkKey = await
|
|
207
|
+
const sdkKey = await loadProjectSDKKey(rootDir);
|
|
204
208
|
if (!sdkKey) {
|
|
205
209
|
tui.warning(`Couldn't find the AGENTUITY_SDK_KEY in ${rootDir} .env file`);
|
|
206
210
|
} else {
|
package/src/cmd/dev/templates.ts
CHANGED
package/src/cmd/env/delete.ts
CHANGED
|
@@ -8,16 +8,27 @@ import {
|
|
|
8
8
|
writeEnvFile,
|
|
9
9
|
filterAgentuitySdkKeys,
|
|
10
10
|
} from '../../env-util';
|
|
11
|
+
import { getCommand } from '../../command-prefix';
|
|
12
|
+
|
|
13
|
+
const EnvDeleteResponseSchema = z.object({
|
|
14
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
15
|
+
key: z.string().describe('Environment variable key that was deleted'),
|
|
16
|
+
path: z.string().describe('Local file path where env var was removed'),
|
|
17
|
+
});
|
|
11
18
|
|
|
12
19
|
export const deleteSubcommand = createSubcommand({
|
|
13
20
|
name: 'delete',
|
|
14
21
|
aliases: ['del', 'remove', 'rm'],
|
|
15
22
|
description: 'Delete an environment variable',
|
|
23
|
+
tags: ['destructive', 'deletes-resource', 'slow', 'requires-auth', 'requires-project'],
|
|
24
|
+
idempotent: true,
|
|
25
|
+
examples: [getCommand('env delete OLD_FEATURE_FLAG'), getCommand('env rm PORT')],
|
|
16
26
|
requires: { auth: true, project: true, apiClient: true },
|
|
17
27
|
schema: {
|
|
18
28
|
args: z.object({
|
|
19
29
|
key: z.string().describe('the environment variable key to delete'),
|
|
20
30
|
}),
|
|
31
|
+
response: EnvDeleteResponseSchema,
|
|
21
32
|
},
|
|
22
33
|
|
|
23
34
|
async handler(ctx) {
|
|
@@ -43,5 +54,11 @@ export const deleteSubcommand = createSubcommand({
|
|
|
43
54
|
tui.success(
|
|
44
55
|
`Environment variable '${args.key}' deleted successfully (cloud + ${envFilePath})`
|
|
45
56
|
);
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
success: true,
|
|
60
|
+
key: args.key,
|
|
61
|
+
path: envFilePath,
|
|
62
|
+
};
|
|
46
63
|
},
|
|
47
64
|
});
|
package/src/cmd/env/get.ts
CHANGED
|
@@ -3,10 +3,19 @@ import { createSubcommand } from '../../types';
|
|
|
3
3
|
import * as tui from '../../tui';
|
|
4
4
|
import { projectGet } from '@agentuity/server';
|
|
5
5
|
import { maskSecret } from '../../env-util';
|
|
6
|
+
import { getCommand } from '../../command-prefix';
|
|
7
|
+
import { ErrorCode } from '../../errors';
|
|
8
|
+
|
|
9
|
+
const EnvGetResponseSchema = z.object({
|
|
10
|
+
key: z.string().describe('Environment variable key name'),
|
|
11
|
+
value: z.string().describe('Environment variable value'),
|
|
12
|
+
});
|
|
6
13
|
|
|
7
14
|
export const getSubcommand = createSubcommand({
|
|
8
15
|
name: 'get',
|
|
9
16
|
description: 'Get an environment variable value',
|
|
17
|
+
tags: ['read-only', 'fast', 'requires-auth', 'requires-project'],
|
|
18
|
+
examples: [getCommand('env get NODE_ENV'), getCommand('env get LOG_LEVEL')],
|
|
10
19
|
requires: { auth: true, project: true, apiClient: true },
|
|
11
20
|
schema: {
|
|
12
21
|
args: z.object({
|
|
@@ -18,7 +27,9 @@ export const getSubcommand = createSubcommand({
|
|
|
18
27
|
.default(false)
|
|
19
28
|
.describe('mask the value in output (default: true in TTY, false otherwise)'),
|
|
20
29
|
}),
|
|
30
|
+
response: EnvGetResponseSchema,
|
|
21
31
|
},
|
|
32
|
+
idempotent: true,
|
|
22
33
|
|
|
23
34
|
async handler(ctx) {
|
|
24
35
|
const { args, opts, apiClient, project } = ctx;
|
|
@@ -32,7 +43,7 @@ export const getSubcommand = createSubcommand({
|
|
|
32
43
|
const value = projectData.env?.[args.key];
|
|
33
44
|
|
|
34
45
|
if (value === undefined) {
|
|
35
|
-
tui.fatal(`Environment variable '${args.key}' not found
|
|
46
|
+
tui.fatal(`Environment variable '${args.key}' not found`, ErrorCode.RESOURCE_NOT_FOUND);
|
|
36
47
|
}
|
|
37
48
|
|
|
38
49
|
// Display the value, masked if requested
|
|
@@ -49,5 +60,10 @@ export const getSubcommand = createSubcommand({
|
|
|
49
60
|
console.log(`${args.key}=${value}`);
|
|
50
61
|
}
|
|
51
62
|
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
key: args.key,
|
|
66
|
+
value,
|
|
67
|
+
};
|
|
52
68
|
},
|
|
53
69
|
});
|
package/src/cmd/env/import.ts
CHANGED
|
@@ -13,14 +13,32 @@ import {
|
|
|
13
13
|
} from '../../env-util';
|
|
14
14
|
import { getCommand } from '../../command-prefix';
|
|
15
15
|
|
|
16
|
+
const EnvImportResponseSchema = z.object({
|
|
17
|
+
success: z.boolean().describe('Whether import succeeded'),
|
|
18
|
+
imported: z.number().describe('Number of items imported'),
|
|
19
|
+
skipped: z.number().describe('Number of items skipped'),
|
|
20
|
+
path: z.string().describe('Local file path where variables were saved'),
|
|
21
|
+
file: z.string().describe('Source file path'),
|
|
22
|
+
});
|
|
23
|
+
|
|
16
24
|
export const importSubcommand = createSubcommand({
|
|
17
25
|
name: 'import',
|
|
18
26
|
description: 'Import environment variables from a file to cloud and local .env.production',
|
|
27
|
+
tags: [
|
|
28
|
+
'mutating',
|
|
29
|
+
'creates-resource',
|
|
30
|
+
'slow',
|
|
31
|
+
'api-intensive',
|
|
32
|
+
'requires-auth',
|
|
33
|
+
'requires-project',
|
|
34
|
+
],
|
|
35
|
+
idempotent: false,
|
|
19
36
|
requires: { auth: true, project: true, apiClient: true },
|
|
20
37
|
schema: {
|
|
21
38
|
args: z.object({
|
|
22
39
|
file: z.string().describe('path to the .env file to import'),
|
|
23
40
|
}),
|
|
41
|
+
response: EnvImportResponseSchema,
|
|
24
42
|
},
|
|
25
43
|
|
|
26
44
|
async handler(ctx) {
|
|
@@ -31,7 +49,13 @@ export const importSubcommand = createSubcommand({
|
|
|
31
49
|
|
|
32
50
|
if (Object.keys(importedEnv).length === 0) {
|
|
33
51
|
tui.warning(`No environment variables found in ${args.file}`);
|
|
34
|
-
return
|
|
52
|
+
return {
|
|
53
|
+
success: false,
|
|
54
|
+
imported: 0,
|
|
55
|
+
skipped: 0,
|
|
56
|
+
path: '',
|
|
57
|
+
file: args.file,
|
|
58
|
+
};
|
|
35
59
|
}
|
|
36
60
|
|
|
37
61
|
// Filter out AGENTUITY_ prefixed keys
|
|
@@ -39,7 +63,13 @@ export const importSubcommand = createSubcommand({
|
|
|
39
63
|
|
|
40
64
|
if (Object.keys(filteredEnv).length === 0) {
|
|
41
65
|
tui.warning('No valid environment variables to import (all were AGENTUITY_ prefixed)');
|
|
42
|
-
return
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
imported: 0,
|
|
69
|
+
skipped: Object.keys(importedEnv).length,
|
|
70
|
+
path: '',
|
|
71
|
+
file: args.file,
|
|
72
|
+
};
|
|
43
73
|
}
|
|
44
74
|
|
|
45
75
|
// Check for potential secrets in the imported variables
|
|
@@ -69,7 +99,13 @@ export const importSubcommand = createSubcommand({
|
|
|
69
99
|
tui.info(
|
|
70
100
|
`Cancelled. Use "${getCommand('secret import')}" to store these as secrets instead.`
|
|
71
101
|
);
|
|
72
|
-
return
|
|
102
|
+
return {
|
|
103
|
+
success: false,
|
|
104
|
+
imported: 0,
|
|
105
|
+
skipped: Object.keys(filteredEnv).length,
|
|
106
|
+
path: '',
|
|
107
|
+
file: args.file,
|
|
108
|
+
};
|
|
73
109
|
}
|
|
74
110
|
}
|
|
75
111
|
|
|
@@ -98,5 +134,13 @@ export const importSubcommand = createSubcommand({
|
|
|
98
134
|
tui.success(
|
|
99
135
|
`Imported ${count} environment variable${count !== 1 ? 's' : ''} from ${args.file} to cloud and ${localEnvPath}`
|
|
100
136
|
);
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
success: true,
|
|
140
|
+
imported: count,
|
|
141
|
+
skipped: Object.keys(importedEnv).length - count,
|
|
142
|
+
path: localEnvPath,
|
|
143
|
+
file: args.file,
|
|
144
|
+
};
|
|
101
145
|
},
|
|
102
146
|
});
|
package/src/cmd/env/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { listSubcommand } from './list';
|
|
|
10
10
|
export const command = createCommand({
|
|
11
11
|
name: 'env',
|
|
12
12
|
description: 'Manage environment variables for your project',
|
|
13
|
+
tags: ['fast', 'requires-auth', 'requires-project'],
|
|
13
14
|
subcommands: [
|
|
14
15
|
listSubcommand,
|
|
15
16
|
pullSubcommand,
|
package/src/cmd/env/list.ts
CHANGED
|
@@ -3,12 +3,21 @@ import { createSubcommand } from '../../types';
|
|
|
3
3
|
import * as tui from '../../tui';
|
|
4
4
|
import { projectGet } from '@agentuity/server';
|
|
5
5
|
import { maskSecret } from '../../env-util';
|
|
6
|
+
import { getCommand } from '../../command-prefix';
|
|
7
|
+
|
|
8
|
+
const EnvListResponseSchema = z.record(
|
|
9
|
+
z.string(),
|
|
10
|
+
z.string().describe('Environment variable value')
|
|
11
|
+
);
|
|
6
12
|
|
|
7
13
|
export const listSubcommand = createSubcommand({
|
|
8
14
|
name: 'list',
|
|
9
15
|
aliases: ['ls'],
|
|
10
16
|
description: 'List all environment variables',
|
|
17
|
+
tags: ['read-only', 'fast', 'requires-auth', 'requires-project'],
|
|
18
|
+
examples: [getCommand('env list'), getCommand('env list --mask')],
|
|
11
19
|
requires: { auth: true, project: true, apiClient: true },
|
|
20
|
+
idempotent: true,
|
|
12
21
|
schema: {
|
|
13
22
|
options: z.object({
|
|
14
23
|
mask: z
|
|
@@ -16,6 +25,7 @@ export const listSubcommand = createSubcommand({
|
|
|
16
25
|
.default(false)
|
|
17
26
|
.describe('mask the values in output (default: false for env vars)'),
|
|
18
27
|
}),
|
|
28
|
+
response: EnvListResponseSchema,
|
|
19
29
|
},
|
|
20
30
|
|
|
21
31
|
async handler(ctx) {
|
|
@@ -30,7 +40,7 @@ export const listSubcommand = createSubcommand({
|
|
|
30
40
|
|
|
31
41
|
if (Object.keys(env).length === 0) {
|
|
32
42
|
tui.info('No environment variables found');
|
|
33
|
-
return;
|
|
43
|
+
return {};
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
// Display the variables
|
|
@@ -52,5 +62,7 @@ export const listSubcommand = createSubcommand({
|
|
|
52
62
|
console.log(`${key}=${displayValue}`);
|
|
53
63
|
}
|
|
54
64
|
}
|
|
65
|
+
|
|
66
|
+
return env;
|
|
55
67
|
},
|
|
56
68
|
});
|
package/src/cmd/env/pull.ts
CHANGED
|
@@ -10,15 +10,28 @@ import {
|
|
|
10
10
|
writeEnvFile,
|
|
11
11
|
mergeEnvVars,
|
|
12
12
|
} from '../../env-util';
|
|
13
|
+
import { getCommand } from '../../command-prefix';
|
|
14
|
+
|
|
15
|
+
const EnvPullResponseSchema = z.object({
|
|
16
|
+
success: z.boolean().describe('Whether pull succeeded'),
|
|
17
|
+
pulled: z.number().describe('Number of items pulled'),
|
|
18
|
+
path: z.string().describe('Local file path where variables were saved'),
|
|
19
|
+
force: z.boolean().describe('Whether force mode was used'),
|
|
20
|
+
});
|
|
13
21
|
|
|
14
22
|
export const pullSubcommand = createSubcommand({
|
|
15
23
|
name: 'pull',
|
|
16
24
|
description: 'Pull environment variables from cloud to local .env.production file',
|
|
25
|
+
tags: ['slow', 'requires-auth', 'requires-project'],
|
|
26
|
+
idempotent: true,
|
|
27
|
+
examples: [getCommand('env pull'), getCommand('env pull --force')],
|
|
17
28
|
requires: { auth: true, project: true, apiClient: true },
|
|
29
|
+
prerequisites: ['cloud deploy'],
|
|
18
30
|
schema: {
|
|
19
31
|
options: z.object({
|
|
20
32
|
force: z.boolean().default(false).describe('overwrite local values with cloud values'),
|
|
21
33
|
}),
|
|
34
|
+
response: EnvPullResponseSchema,
|
|
22
35
|
},
|
|
23
36
|
|
|
24
37
|
async handler(ctx) {
|
|
@@ -76,5 +89,12 @@ export const pullSubcommand = createSubcommand({
|
|
|
76
89
|
tui.success(
|
|
77
90
|
`Pulled ${count} environment variable${count !== 1 ? 's' : ''} to ${targetEnvPath}`
|
|
78
91
|
);
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
success: true,
|
|
95
|
+
pulled: count,
|
|
96
|
+
path: targetEnvPath,
|
|
97
|
+
force: opts?.force ?? false,
|
|
98
|
+
};
|
|
79
99
|
},
|
|
80
100
|
});
|
package/src/cmd/env/push.ts
CHANGED
|
@@ -1,12 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { createSubcommand } from '../../types';
|
|
2
3
|
import * as tui from '../../tui';
|
|
3
4
|
import { projectEnvUpdate } from '@agentuity/server';
|
|
4
5
|
import { findExistingEnvFile, readEnvFile, filterAgentuitySdkKeys } from '../../env-util';
|
|
6
|
+
import { getCommand } from '../../command-prefix';
|
|
7
|
+
|
|
8
|
+
const EnvPushResponseSchema = z.object({
|
|
9
|
+
success: z.boolean().describe('Whether push succeeded'),
|
|
10
|
+
pushed: z.number().describe('Number of items pushed'),
|
|
11
|
+
source: z.string().describe('Source file path'),
|
|
12
|
+
});
|
|
5
13
|
|
|
6
14
|
export const pushSubcommand = createSubcommand({
|
|
7
15
|
name: 'push',
|
|
8
16
|
description: 'Push environment variables from local .env.production file to cloud',
|
|
17
|
+
tags: [
|
|
18
|
+
'mutating',
|
|
19
|
+
'updates-resource',
|
|
20
|
+
'slow',
|
|
21
|
+
'api-intensive',
|
|
22
|
+
'requires-auth',
|
|
23
|
+
'requires-project',
|
|
24
|
+
],
|
|
25
|
+
idempotent: true,
|
|
26
|
+
examples: [getCommand('env push')],
|
|
9
27
|
requires: { auth: true, project: true, apiClient: true },
|
|
28
|
+
prerequisites: ['env set'],
|
|
29
|
+
schema: {
|
|
30
|
+
response: EnvPushResponseSchema,
|
|
31
|
+
},
|
|
10
32
|
|
|
11
33
|
async handler(ctx) {
|
|
12
34
|
const { apiClient, project, projectDir } = ctx;
|
|
@@ -20,7 +42,11 @@ export const pushSubcommand = createSubcommand({
|
|
|
20
42
|
|
|
21
43
|
if (Object.keys(filteredEnv).length === 0) {
|
|
22
44
|
tui.warning('No environment variables to push');
|
|
23
|
-
return
|
|
45
|
+
return {
|
|
46
|
+
success: false,
|
|
47
|
+
pushed: 0,
|
|
48
|
+
source: envFilePath,
|
|
49
|
+
};
|
|
24
50
|
}
|
|
25
51
|
|
|
26
52
|
// Push to cloud
|
|
@@ -33,5 +59,11 @@ export const pushSubcommand = createSubcommand({
|
|
|
33
59
|
|
|
34
60
|
const count = Object.keys(filteredEnv).length;
|
|
35
61
|
tui.success(`Pushed ${count} environment variable${count !== 1 ? 's' : ''} to cloud`);
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
success: true,
|
|
65
|
+
pushed: count,
|
|
66
|
+
source: envFilePath,
|
|
67
|
+
};
|
|
36
68
|
},
|
|
37
69
|
});
|
package/src/cmd/env/set.ts
CHANGED
|
@@ -11,15 +11,29 @@ import {
|
|
|
11
11
|
} from '../../env-util';
|
|
12
12
|
import { getCommand } from '../../command-prefix';
|
|
13
13
|
|
|
14
|
+
const EnvSetResponseSchema = z.object({
|
|
15
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
16
|
+
key: z.string().describe('Environment variable key'),
|
|
17
|
+
path: z.string().describe('Local file path where env var was saved'),
|
|
18
|
+
});
|
|
19
|
+
|
|
14
20
|
export const setSubcommand = createSubcommand({
|
|
15
21
|
name: 'set',
|
|
16
22
|
description: 'Set an environment variable',
|
|
23
|
+
tags: ['mutating', 'updates-resource', 'slow', 'requires-auth', 'requires-project'],
|
|
24
|
+
idempotent: true,
|
|
17
25
|
requires: { auth: true, project: true, apiClient: true },
|
|
26
|
+
examples: [
|
|
27
|
+
getCommand('env set NODE_ENV production'),
|
|
28
|
+
getCommand('env set PORT 3000'),
|
|
29
|
+
getCommand('env set LOG_LEVEL debug'),
|
|
30
|
+
],
|
|
18
31
|
schema: {
|
|
19
32
|
args: z.object({
|
|
20
33
|
key: z.string().describe('the environment variable key'),
|
|
21
34
|
value: z.string().describe('the environment variable value'),
|
|
22
35
|
}),
|
|
36
|
+
response: EnvSetResponseSchema,
|
|
23
37
|
},
|
|
24
38
|
|
|
25
39
|
async handler(ctx) {
|
|
@@ -45,7 +59,11 @@ export const setSubcommand = createSubcommand({
|
|
|
45
59
|
tui.info(
|
|
46
60
|
`Cancelled. Use "${getCommand('secret set')}" to store this as a secret instead.`
|
|
47
61
|
);
|
|
48
|
-
return
|
|
62
|
+
return {
|
|
63
|
+
success: false,
|
|
64
|
+
key: args.key,
|
|
65
|
+
path: '',
|
|
66
|
+
};
|
|
49
67
|
}
|
|
50
68
|
}
|
|
51
69
|
|
|
@@ -67,5 +85,11 @@ export const setSubcommand = createSubcommand({
|
|
|
67
85
|
await writeEnvFile(envFilePath, filteredEnv);
|
|
68
86
|
|
|
69
87
|
tui.success(`Environment variable '${args.key}' set successfully (cloud + ${envFilePath})`);
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
success: true,
|
|
91
|
+
key: args.key,
|
|
92
|
+
path: envFilePath,
|
|
93
|
+
};
|
|
70
94
|
},
|
|
71
95
|
});
|
package/src/cmd/index.ts
CHANGED
|
@@ -22,7 +22,8 @@ export async function discoverCommands(): Promise<CommandDefinition[]> {
|
|
|
22
22
|
if (cmd.subcommands) {
|
|
23
23
|
for (const subcommand of cmd.subcommands) {
|
|
24
24
|
if (subcommand.toplevel) {
|
|
25
|
-
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
const alias: any = {
|
|
26
27
|
name: subcommand.name,
|
|
27
28
|
description: subcommand.description,
|
|
28
29
|
aliases: subcommand.aliases,
|
|
@@ -31,8 +32,14 @@ export async function discoverCommands(): Promise<CommandDefinition[]> {
|
|
|
31
32
|
optional: subcommand.optional,
|
|
32
33
|
schema: subcommand.schema,
|
|
33
34
|
handler: subcommand.handler,
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
idempotent: (subcommand as any).idempotent,
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
prerequisites: (subcommand as any).prerequisites,
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
tags: (subcommand as any).tags,
|
|
34
41
|
};
|
|
35
|
-
commands.push(alias);
|
|
42
|
+
commands.push(alias as CommandDefinition);
|
|
36
43
|
}
|
|
37
44
|
}
|
|
38
45
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../types';
|
|
3
|
+
import * as tui from '../../tui';
|
|
4
|
+
import { createStorageAdapter } from './util';
|
|
5
|
+
import { getCommand } from '../../command-prefix';
|
|
6
|
+
|
|
7
|
+
export const createNamespaceSubcommand = createCommand({
|
|
8
|
+
name: 'create-namespace',
|
|
9
|
+
aliases: ['create'],
|
|
10
|
+
description: 'Create a new keyvalue namespace',
|
|
11
|
+
tags: ['mutating', 'creates-resource', 'slow', 'requires-auth'],
|
|
12
|
+
idempotent: false,
|
|
13
|
+
requires: { auth: true, project: true },
|
|
14
|
+
examples: [
|
|
15
|
+
`${getCommand('kv create-namespace production')} - Create production namespace`,
|
|
16
|
+
`${getCommand('kv create staging')} - Create staging namespace (using alias)`,
|
|
17
|
+
`${getCommand('kv create cache')} - Create cache namespace`,
|
|
18
|
+
],
|
|
19
|
+
schema: {
|
|
20
|
+
args: z.object({
|
|
21
|
+
name: z.string().min(1).max(64).describe('the namespace name'),
|
|
22
|
+
}),
|
|
23
|
+
response: z.object({
|
|
24
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
25
|
+
namespace: z.string().describe('Namespace name'),
|
|
26
|
+
message: z.string().optional().describe('Success message'),
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
async handler(ctx) {
|
|
31
|
+
const { args } = ctx;
|
|
32
|
+
const kv = await createStorageAdapter(ctx);
|
|
33
|
+
|
|
34
|
+
await kv.createNamespace(args.name);
|
|
35
|
+
tui.success(`Namespace ${tui.bold(args.name)} created`);
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
success: true,
|
|
39
|
+
namespace: args.name,
|
|
40
|
+
message: `Namespace ${args.name} created`,
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export default createNamespaceSubcommand;
|