@agentuity/cli 0.0.47 → 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 +2 -0
- package/dist/cmd/cloud/deployment/index.d.ts.map +1 -0
- package/dist/cmd/cloud/deployment/list.d.ts +2 -0
- package/dist/cmd/cloud/deployment/list.d.ts.map +1 -0
- package/dist/cmd/cloud/deployment/remove.d.ts +2 -0
- package/dist/cmd/cloud/deployment/remove.d.ts.map +1 -0
- package/dist/cmd/cloud/deployment/rollback.d.ts +2 -0
- package/dist/cmd/cloud/deployment/rollback.d.ts.map +1 -0
- package/dist/cmd/cloud/deployment/show.d.ts +2 -0
- package/dist/cmd/cloud/deployment/show.d.ts.map +1 -0
- package/dist/cmd/cloud/deployment/undeploy.d.ts +2 -0
- package/dist/cmd/cloud/deployment/undeploy.d.ts.map +1 -0
- package/dist/cmd/cloud/deployment/utils.d.ts +7 -0
- package/dist/cmd/cloud/deployment/utils.d.ts.map +1 -0
- 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 +20 -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 +10 -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 +44 -32
- 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 +60 -0
- package/src/cmd/cloud/deployment/index.ts +20 -0
- package/src/cmd/cloud/deployment/list.ts +105 -0
- package/src/cmd/cloud/deployment/remove.ts +65 -0
- package/src/cmd/cloud/deployment/rollback.ts +87 -0
- package/src/cmd/cloud/deployment/show.ts +107 -0
- package/src/cmd/cloud/deployment/undeploy.ts +48 -0
- package/src/cmd/cloud/deployment/utils.ts +14 -0
- package/src/cmd/cloud/domain.ts +3 -2
- package/src/cmd/cloud/index.ts +9 -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 +61 -6
- package/src/cmd/profile/delete.ts +25 -5
- package/src/cmd/profile/index.ts +1 -0
- package/src/cmd/profile/list.ts +7 -3
- package/src/cmd/profile/show.ts +33 -19
- package/src/cmd/profile/use.ts +17 -4
- 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 +18 -5
- 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 +136 -13
- package/src/types.ts +62 -12
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import type { CommandDefinition, SubcommandDefinition, CommandSchemas } from './types';
|
|
3
|
+
import { parseArgsSchema, parseOptionsSchema } from './schema-parser';
|
|
4
|
+
import * as z from 'zod';
|
|
5
|
+
|
|
6
|
+
export interface SchemaArgument {
|
|
7
|
+
name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
required: boolean;
|
|
10
|
+
variadic: boolean;
|
|
11
|
+
description?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SchemaOption {
|
|
15
|
+
name: string;
|
|
16
|
+
type: 'string' | 'number' | 'boolean';
|
|
17
|
+
required: boolean;
|
|
18
|
+
default?: unknown;
|
|
19
|
+
description?: string;
|
|
20
|
+
enum?: string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface SchemaPagination {
|
|
24
|
+
supported: boolean;
|
|
25
|
+
defaultLimit?: number;
|
|
26
|
+
maxLimit?: number;
|
|
27
|
+
parameters?: {
|
|
28
|
+
limit?: string;
|
|
29
|
+
offset?: string;
|
|
30
|
+
cursor?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface SchemaCommand {
|
|
35
|
+
name: string;
|
|
36
|
+
description: string;
|
|
37
|
+
aliases?: string[];
|
|
38
|
+
arguments?: SchemaArgument[];
|
|
39
|
+
options?: SchemaOption[];
|
|
40
|
+
examples?: string[];
|
|
41
|
+
response?: unknown;
|
|
42
|
+
idempotent?: boolean;
|
|
43
|
+
prerequisites?: string[];
|
|
44
|
+
pagination?: SchemaPagination;
|
|
45
|
+
tags?: string[];
|
|
46
|
+
subcommands?: SchemaCommand[];
|
|
47
|
+
requires?: {
|
|
48
|
+
auth?: boolean;
|
|
49
|
+
project?: boolean;
|
|
50
|
+
org?: boolean;
|
|
51
|
+
region?: boolean;
|
|
52
|
+
regions?: boolean;
|
|
53
|
+
};
|
|
54
|
+
optional?: {
|
|
55
|
+
auth?: boolean | string;
|
|
56
|
+
project?: boolean;
|
|
57
|
+
org?: boolean;
|
|
58
|
+
region?: boolean;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface CLISchema {
|
|
63
|
+
name: string;
|
|
64
|
+
version: string;
|
|
65
|
+
description: string;
|
|
66
|
+
exitCodes: Record<number, string>;
|
|
67
|
+
globalOptions: SchemaOption[];
|
|
68
|
+
commands: SchemaCommand[];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Extract schema information from a CommandDefinition
|
|
73
|
+
*/
|
|
74
|
+
function extractCommandSchema(def: CommandDefinition): SchemaCommand {
|
|
75
|
+
const schema: SchemaCommand = {
|
|
76
|
+
name: def.name,
|
|
77
|
+
description: def.description,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
if (def.aliases) {
|
|
81
|
+
schema.aliases = def.aliases;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Extract examples if available
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
if ((def as any).examples) {
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
88
|
+
schema.examples = (def as any).examples;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Extract idempotent marker
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
93
|
+
if ((def as any).idempotent !== undefined) {
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
|
+
schema.idempotent = (def as any).idempotent;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Extract prerequisites
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
100
|
+
if ((def as any).prerequisites) {
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
|
+
schema.prerequisites = (def as any).prerequisites;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Extract pagination
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
107
|
+
if ((def as any).pagination) {
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
109
|
+
schema.pagination = (def as any).pagination;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Extract tags
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
|
+
if ((def as any).tags) {
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
116
|
+
schema.tags = (def as any).tags;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Extract requires/optional
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
121
|
+
const d = def as any;
|
|
122
|
+
if (d.requires) {
|
|
123
|
+
schema.requires = {
|
|
124
|
+
auth: d.requires.auth === true,
|
|
125
|
+
project: d.requires.project === true,
|
|
126
|
+
org: d.requires.org === true,
|
|
127
|
+
region: d.requires.region === true,
|
|
128
|
+
regions: d.requires.regions === true,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
if (d.optional) {
|
|
132
|
+
schema.optional = {
|
|
133
|
+
auth: d.optional.auth === true || typeof d.optional.auth === 'string',
|
|
134
|
+
project: d.optional.project === true,
|
|
135
|
+
org: d.optional.org === true,
|
|
136
|
+
region: d.optional.region === true,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Extract subcommands recursively
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
+
if ((def as any).subcommands) {
|
|
143
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
144
|
+
schema.subcommands = ((def as any).subcommands as SubcommandDefinition[]).map((sub) =>
|
|
145
|
+
extractSubcommandSchema(sub)
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return schema;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Extract schema information from a SubcommandDefinition
|
|
154
|
+
*/
|
|
155
|
+
function extractSubcommandSchema(def: SubcommandDefinition): SchemaCommand {
|
|
156
|
+
const schema: SchemaCommand = {
|
|
157
|
+
name: def.name,
|
|
158
|
+
description: def.description,
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
if (def.aliases) {
|
|
162
|
+
schema.aliases = def.aliases;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Extract examples if available
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
167
|
+
if ((def as any).examples) {
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
169
|
+
schema.examples = (def as any).examples;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Extract idempotent marker
|
|
173
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
174
|
+
if ((def as any).idempotent !== undefined) {
|
|
175
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
176
|
+
schema.idempotent = (def as any).idempotent;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Extract prerequisites
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
181
|
+
if ((def as any).prerequisites) {
|
|
182
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
|
+
schema.prerequisites = (def as any).prerequisites;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Extract pagination
|
|
187
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
188
|
+
if ((def as any).pagination) {
|
|
189
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
190
|
+
schema.pagination = (def as any).pagination;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Extract tags
|
|
194
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
195
|
+
if ((def as any).tags) {
|
|
196
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
197
|
+
schema.tags = (def as any).tags;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Extract requires/optional
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
202
|
+
const d = def as any;
|
|
203
|
+
if (d.requires) {
|
|
204
|
+
schema.requires = {
|
|
205
|
+
auth: d.requires.auth === true,
|
|
206
|
+
project: d.requires.project === true,
|
|
207
|
+
org: d.requires.org === true,
|
|
208
|
+
region: d.requires.region === true,
|
|
209
|
+
regions: d.requires.regions === true,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
if (d.optional) {
|
|
213
|
+
schema.optional = {
|
|
214
|
+
auth: d.optional.auth === true || typeof d.optional.auth === 'string',
|
|
215
|
+
project: d.optional.project === true,
|
|
216
|
+
org: d.optional.org === true,
|
|
217
|
+
region: d.optional.region === true,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Extract args and options from schema if available
|
|
222
|
+
if (d.schema) {
|
|
223
|
+
const schemas = d.schema as CommandSchemas;
|
|
224
|
+
|
|
225
|
+
if (schemas.args) {
|
|
226
|
+
const parsedArgs = parseArgsSchema(schemas.args);
|
|
227
|
+
schema.arguments = parsedArgs.metadata.map((arg) => ({
|
|
228
|
+
name: arg.name,
|
|
229
|
+
type: arg.variadic ? 'array' : 'string',
|
|
230
|
+
required: !arg.optional,
|
|
231
|
+
variadic: arg.variadic,
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (schemas.options) {
|
|
236
|
+
const parsedOptions = parseOptionsSchema(schemas.options);
|
|
237
|
+
schema.options = parsedOptions.map((opt) => ({
|
|
238
|
+
name: opt.name,
|
|
239
|
+
type: opt.type,
|
|
240
|
+
required: !opt.hasDefault,
|
|
241
|
+
default: opt.defaultValue,
|
|
242
|
+
description: opt.description,
|
|
243
|
+
}));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (schemas.response) {
|
|
247
|
+
schema.response = z.toJSONSchema(schemas.response);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Extract nested subcommands recursively
|
|
252
|
+
if (d.subcommands) {
|
|
253
|
+
schema.subcommands = (d.subcommands as SubcommandDefinition[]).map((sub) =>
|
|
254
|
+
extractSubcommandSchema(sub)
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return schema;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Generate JSON schema for the entire CLI
|
|
263
|
+
*/
|
|
264
|
+
export function generateCLISchema(
|
|
265
|
+
program: Command,
|
|
266
|
+
commands: CommandDefinition[],
|
|
267
|
+
version: string
|
|
268
|
+
): CLISchema {
|
|
269
|
+
const schema: CLISchema = {
|
|
270
|
+
name: 'agentuity',
|
|
271
|
+
version,
|
|
272
|
+
description: 'Agentuity CLI',
|
|
273
|
+
exitCodes: {
|
|
274
|
+
0: 'Success',
|
|
275
|
+
1: 'General error',
|
|
276
|
+
2: 'Validation error (invalid arguments or options)',
|
|
277
|
+
3: 'Authentication error (login required or credentials invalid)',
|
|
278
|
+
4: 'Resource not found (project, file, deployment, etc.)',
|
|
279
|
+
5: 'Permission denied (insufficient access rights)',
|
|
280
|
+
6: 'Network error (API unreachable or timeout)',
|
|
281
|
+
7: 'File system error (file read/write failed)',
|
|
282
|
+
8: 'User cancelled (operation aborted by user)',
|
|
283
|
+
},
|
|
284
|
+
globalOptions: [
|
|
285
|
+
{
|
|
286
|
+
name: 'config',
|
|
287
|
+
type: 'string',
|
|
288
|
+
required: false,
|
|
289
|
+
description: 'Config file path',
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
name: 'log-level',
|
|
293
|
+
type: 'string',
|
|
294
|
+
required: false,
|
|
295
|
+
default: 'info',
|
|
296
|
+
description: 'Log level',
|
|
297
|
+
enum: ['debug', 'trace', 'info', 'warn', 'error'],
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: 'log-timestamp',
|
|
301
|
+
type: 'boolean',
|
|
302
|
+
required: false,
|
|
303
|
+
default: false,
|
|
304
|
+
description: 'Show timestamps in log output',
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
name: 'log-prefix',
|
|
308
|
+
type: 'boolean',
|
|
309
|
+
required: false,
|
|
310
|
+
default: true,
|
|
311
|
+
description: 'Show log level prefixes',
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
name: 'org-id',
|
|
315
|
+
type: 'string',
|
|
316
|
+
required: false,
|
|
317
|
+
description: 'Use a specific organization when performing operations',
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
name: 'color-scheme',
|
|
321
|
+
type: 'string',
|
|
322
|
+
required: false,
|
|
323
|
+
description: 'Color scheme: light or dark',
|
|
324
|
+
enum: ['light', 'dark'],
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
name: 'color',
|
|
328
|
+
type: 'string',
|
|
329
|
+
required: false,
|
|
330
|
+
default: 'auto',
|
|
331
|
+
description: 'Color output: auto, always, never',
|
|
332
|
+
enum: ['auto', 'always', 'never'],
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: 'error-format',
|
|
336
|
+
type: 'string',
|
|
337
|
+
required: false,
|
|
338
|
+
default: 'text',
|
|
339
|
+
description: 'Error output format: json or text',
|
|
340
|
+
enum: ['json', 'text'],
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
name: 'json',
|
|
344
|
+
type: 'boolean',
|
|
345
|
+
required: false,
|
|
346
|
+
default: false,
|
|
347
|
+
description: 'Output in JSON format (machine-readable)',
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
name: 'quiet',
|
|
351
|
+
type: 'boolean',
|
|
352
|
+
required: false,
|
|
353
|
+
default: false,
|
|
354
|
+
description: 'Suppress non-essential output',
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
name: 'no-progress',
|
|
358
|
+
type: 'boolean',
|
|
359
|
+
required: false,
|
|
360
|
+
default: false,
|
|
361
|
+
description: 'Disable progress indicators',
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: 'explain',
|
|
365
|
+
type: 'boolean',
|
|
366
|
+
required: false,
|
|
367
|
+
default: false,
|
|
368
|
+
description: 'Show what the command would do without executing',
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
name: 'dry-run',
|
|
372
|
+
type: 'boolean',
|
|
373
|
+
required: false,
|
|
374
|
+
default: false,
|
|
375
|
+
description: 'Execute command without making changes',
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
name: 'validate',
|
|
379
|
+
type: 'boolean',
|
|
380
|
+
required: false,
|
|
381
|
+
default: false,
|
|
382
|
+
description: 'Validate arguments and options without executing',
|
|
383
|
+
},
|
|
384
|
+
],
|
|
385
|
+
commands: commands.map(extractCommandSchema),
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
return schema;
|
|
389
|
+
}
|
package/src/tui.ts
CHANGED
|
@@ -5,11 +5,14 @@
|
|
|
5
5
|
* Uses Bun's built-in color support and ANSI escape codes.
|
|
6
6
|
*/
|
|
7
7
|
import { stringWidth } from 'bun';
|
|
8
|
+
import { colorize } from 'json-colorizer';
|
|
8
9
|
import enquirer from 'enquirer';
|
|
9
10
|
import { type OrganizationList, projectList } from '@agentuity/server';
|
|
11
|
+
import * as readline from 'readline';
|
|
10
12
|
import type { ColorScheme } from './terminal';
|
|
13
|
+
import type { Profile } from './types';
|
|
11
14
|
import { type APIClient as APIClientType } from './api';
|
|
12
|
-
import
|
|
15
|
+
import { getExitCode } from './errors';
|
|
13
16
|
|
|
14
17
|
// Icons
|
|
15
18
|
const ICONS = {
|
|
@@ -99,13 +102,46 @@ function getColor(colorKey: keyof ReturnType<typeof getColors>): string {
|
|
|
99
102
|
return color[currentColorScheme];
|
|
100
103
|
}
|
|
101
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Color helpers that return colored strings (for inline use, no icons)
|
|
107
|
+
*/
|
|
108
|
+
export function colorSuccess(text: string): string {
|
|
109
|
+
const color = getColor('success');
|
|
110
|
+
const reset = getColor('reset');
|
|
111
|
+
return `${color}${text}${reset}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function colorError(text: string): string {
|
|
115
|
+
const color = getColor('error');
|
|
116
|
+
const reset = getColor('reset');
|
|
117
|
+
return `${color}${text}${reset}`;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function colorWarning(text: string): string {
|
|
121
|
+
const color = getColor('warning');
|
|
122
|
+
const reset = getColor('reset');
|
|
123
|
+
return `${color}${text}${reset}`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function colorInfo(text: string): string {
|
|
127
|
+
const color = getColor('info');
|
|
128
|
+
const reset = getColor('reset');
|
|
129
|
+
return `${color}${text}${reset}`;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function colorMuted(text: string): string {
|
|
133
|
+
const color = getColor('muted');
|
|
134
|
+
const reset = getColor('reset');
|
|
135
|
+
return `${color}${text}${reset}`;
|
|
136
|
+
}
|
|
137
|
+
|
|
102
138
|
/**
|
|
103
139
|
* Print a success message with a green checkmark
|
|
104
140
|
*/
|
|
105
141
|
export function success(message: string): void {
|
|
106
142
|
const color = getColor('success');
|
|
107
143
|
const reset = getColor('reset');
|
|
108
|
-
|
|
144
|
+
process.stderr.write(`${color}${ICONS.success} ${message}${reset}\n`);
|
|
109
145
|
}
|
|
110
146
|
|
|
111
147
|
/**
|
|
@@ -114,17 +150,23 @@ export function success(message: string): void {
|
|
|
114
150
|
export function error(message: string): void {
|
|
115
151
|
const color = getColor('error');
|
|
116
152
|
const reset = getColor('reset');
|
|
117
|
-
|
|
153
|
+
process.stderr.write(`${color}${ICONS.error} ${message}${reset}\n`);
|
|
118
154
|
}
|
|
119
155
|
|
|
120
156
|
/**
|
|
121
157
|
* Print an error message with a red X and then exit
|
|
122
158
|
*/
|
|
123
|
-
export function fatal(message: string): never {
|
|
159
|
+
export function fatal(message: string, errorCode?: import('./errors').ErrorCode): never {
|
|
124
160
|
const color = getColor('error');
|
|
125
161
|
const reset = getColor('reset');
|
|
126
|
-
|
|
127
|
-
|
|
162
|
+
process.stderr.write(`${color}${ICONS.error} ${message}${reset}\n`);
|
|
163
|
+
|
|
164
|
+
if (errorCode) {
|
|
165
|
+
const exitCode = getExitCode(errorCode);
|
|
166
|
+
process.exit(exitCode);
|
|
167
|
+
} else {
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
128
170
|
}
|
|
129
171
|
|
|
130
172
|
/**
|
|
@@ -133,7 +175,7 @@ export function fatal(message: string): never {
|
|
|
133
175
|
export function warning(message: string, asError = false): void {
|
|
134
176
|
const color = asError ? getColor('error') : getColor('warning');
|
|
135
177
|
const reset = getColor('reset');
|
|
136
|
-
|
|
178
|
+
process.stderr.write(`${color}${ICONS.warning} ${message}${reset}\n`);
|
|
137
179
|
}
|
|
138
180
|
|
|
139
181
|
/**
|
|
@@ -142,7 +184,7 @@ export function warning(message: string, asError = false): void {
|
|
|
142
184
|
export function info(message: string): void {
|
|
143
185
|
const color = getColor('info');
|
|
144
186
|
const reset = getColor('reset');
|
|
145
|
-
|
|
187
|
+
process.stderr.write(`${color}${ICONS.info} ${message}${reset}\n`);
|
|
146
188
|
}
|
|
147
189
|
|
|
148
190
|
/**
|
|
@@ -212,21 +254,21 @@ function supportsHyperlinks(): boolean {
|
|
|
212
254
|
* Print a bulleted list item
|
|
213
255
|
*/
|
|
214
256
|
export function bullet(message: string): void {
|
|
215
|
-
|
|
257
|
+
process.stderr.write(`${ICONS.bullet} ${message}\n`);
|
|
216
258
|
}
|
|
217
259
|
|
|
218
260
|
/**
|
|
219
261
|
* Print an arrow item (for showing next steps)
|
|
220
262
|
*/
|
|
221
263
|
export function arrow(message: string): void {
|
|
222
|
-
|
|
264
|
+
process.stderr.write(`${ICONS.arrow} ${message}\n`);
|
|
223
265
|
}
|
|
224
266
|
|
|
225
267
|
/**
|
|
226
268
|
* Print a blank line
|
|
227
269
|
*/
|
|
228
270
|
export function newline(): void {
|
|
229
|
-
|
|
271
|
+
process.stderr.write('\n');
|
|
230
272
|
}
|
|
231
273
|
|
|
232
274
|
/**
|
|
@@ -773,8 +815,13 @@ export async function spinner<T>(
|
|
|
773
815
|
const message = options.message;
|
|
774
816
|
const reset = getColor('reset');
|
|
775
817
|
|
|
776
|
-
//
|
|
777
|
-
|
|
818
|
+
// Check if progress should be disabled (from global options)
|
|
819
|
+
const { getOutputOptions, shouldDisableProgress } = await import('./output');
|
|
820
|
+
const outputOptions = getOutputOptions();
|
|
821
|
+
const noProgress = outputOptions ? shouldDisableProgress(outputOptions) : false;
|
|
822
|
+
|
|
823
|
+
// If no TTY or progress disabled, just execute the callback without animation
|
|
824
|
+
if (!process.stderr.isTTY || noProgress) {
|
|
778
825
|
try {
|
|
779
826
|
const result =
|
|
780
827
|
options.type === 'progress'
|
|
@@ -1241,3 +1288,79 @@ export async function showProjectList(
|
|
|
1241
1288
|
|
|
1242
1289
|
return response.id;
|
|
1243
1290
|
}
|
|
1291
|
+
|
|
1292
|
+
/**
|
|
1293
|
+
* Show a profile list picker
|
|
1294
|
+
*
|
|
1295
|
+
* @param profiles List of profiles to choose from
|
|
1296
|
+
* @param message Prompt message
|
|
1297
|
+
* @returns The name of the selected profile
|
|
1298
|
+
*/
|
|
1299
|
+
export async function showProfileList(
|
|
1300
|
+
profiles: Profile[],
|
|
1301
|
+
message = 'Select a profile:'
|
|
1302
|
+
): Promise<string> {
|
|
1303
|
+
if (profiles.length === 0) {
|
|
1304
|
+
warning('No profiles found');
|
|
1305
|
+
process.exit(0);
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
// If only one profile, just return it? No, let them confirm/see it if they asked to pick?
|
|
1309
|
+
// But for "use" it implies switching. If only one, you are already on it or it's the only choice.
|
|
1310
|
+
// But for delete, you might want to delete the only one.
|
|
1311
|
+
// So always show list.
|
|
1312
|
+
|
|
1313
|
+
// Find currently selected profile for initial selection
|
|
1314
|
+
const selectedProfile = profiles.find((p) => p.selected);
|
|
1315
|
+
const initial = selectedProfile ? selectedProfile.name : undefined;
|
|
1316
|
+
|
|
1317
|
+
// If non-interactive, return initial or first
|
|
1318
|
+
if (!process.stdin.isTTY) {
|
|
1319
|
+
if (initial) return initial;
|
|
1320
|
+
if (profiles.length === 1) {
|
|
1321
|
+
return profiles[0].name;
|
|
1322
|
+
}
|
|
1323
|
+
fatal(
|
|
1324
|
+
'Profile selection required but cannot prompt in non-interactive environment. ' +
|
|
1325
|
+
'Pass a profile name explicitly when running non-interactively.'
|
|
1326
|
+
);
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
const response = await enquirer.prompt<{ name: string }>({
|
|
1330
|
+
type: 'select',
|
|
1331
|
+
name: 'name',
|
|
1332
|
+
message: message,
|
|
1333
|
+
initial: initial,
|
|
1334
|
+
choices: profiles.map((p) => ({
|
|
1335
|
+
name: p.name,
|
|
1336
|
+
message: p.selected ? `${p.name.padEnd(15, ' ')} ${muted('(current)')}` : p.name,
|
|
1337
|
+
})),
|
|
1338
|
+
});
|
|
1339
|
+
|
|
1340
|
+
return response.name;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
export function json(value: unknown) {
|
|
1344
|
+
const stringValue = typeof value === 'string' ? value : JSON.stringify(value, null, 2);
|
|
1345
|
+
|
|
1346
|
+
if (shouldUseColors() && process.stdout.isTTY) {
|
|
1347
|
+
try {
|
|
1348
|
+
console.log(colorize(stringValue));
|
|
1349
|
+
return;
|
|
1350
|
+
} catch {
|
|
1351
|
+
/* */
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
console.log(stringValue);
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
export function plural(count: number, singular: string, plural: string): string {
|
|
1358
|
+
switch (count) {
|
|
1359
|
+
case 0:
|
|
1360
|
+
return plural;
|
|
1361
|
+
case 1:
|
|
1362
|
+
return singular;
|
|
1363
|
+
default:
|
|
1364
|
+
return plural;
|
|
1365
|
+
}
|
|
1366
|
+
}
|