@agentuity/cli 0.0.48 → 0.0.50
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/agents/index.d.ts +2 -0
- package/dist/cmd/agents/index.d.ts.map +1 -0
- 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 +3 -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/session/get.d.ts +2 -0
- package/dist/cmd/cloud/session/get.d.ts.map +1 -0
- package/dist/cmd/cloud/session/index.d.ts +2 -0
- package/dist/cmd/cloud/session/index.d.ts.map +1 -0
- package/dist/cmd/cloud/session/list.d.ts +2 -0
- package/dist/cmd/cloud/session/list.d.ts.map +1 -0
- package/dist/cmd/cloud/session/logs.d.ts +2 -0
- package/dist/cmd/cloud/session/logs.d.ts.map +1 -0
- package/dist/cmd/cloud/ssh.d.ts.map +1 -1
- package/dist/cmd/dev/agents.d.ts +2 -0
- package/dist/cmd/dev/agents.d.ts.map +1 -0
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/dev/sync.d.ts +12 -0
- package/dist/cmd/dev/sync.d.ts.map +1 -0
- 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 +120 -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 +35 -1
- package/dist/tui.d.ts.map +1 -1
- package/dist/types.d.ts +77 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/format.d.ts +9 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/package.json +12 -4
- package/src/banner.ts +7 -7
- package/src/cli-logger.ts +80 -0
- package/src/cli.ts +192 -58
- package/src/cmd/agents/index.ts +147 -0
- 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 +38 -27
- package/src/cmd/auth/whoami.ts +32 -21
- package/src/cmd/bundle/ast.test.ts +2 -2
- package/src/cmd/bundle/ast.ts +112 -22
- package/src/cmd/bundle/index.ts +20 -0
- package/src/cmd/bundle/plugin.ts +60 -14
- 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 +66 -25
- 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 +10 -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/session/get.ts +164 -0
- package/src/cmd/cloud/session/index.ts +11 -0
- package/src/cmd/cloud/session/list.ts +145 -0
- package/src/cmd/cloud/session/logs.ts +68 -0
- package/src/cmd/cloud/ssh.ts +12 -0
- package/src/cmd/dev/agents.ts +122 -0
- package/src/cmd/dev/index.ts +106 -8
- package/src/cmd/dev/sync.ts +414 -0
- 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 +24 -10
- package/src/cmd/project/show.ts +28 -9
- 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 +1507 -0
- package/src/schema-generator.ts +389 -0
- package/src/tui.ts +178 -13
- package/src/types.ts +75 -22
- package/src/utils/format.ts +17 -0
|
@@ -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,12 +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';
|
|
11
13
|
import type { Profile } from './types';
|
|
12
14
|
import { type APIClient as APIClientType } from './api';
|
|
13
|
-
import
|
|
15
|
+
import { getExitCode } from './errors';
|
|
14
16
|
|
|
15
17
|
// Icons
|
|
16
18
|
const ICONS = {
|
|
@@ -100,13 +102,46 @@ function getColor(colorKey: keyof ReturnType<typeof getColors>): string {
|
|
|
100
102
|
return color[currentColorScheme];
|
|
101
103
|
}
|
|
102
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
|
+
|
|
103
138
|
/**
|
|
104
139
|
* Print a success message with a green checkmark
|
|
105
140
|
*/
|
|
106
141
|
export function success(message: string): void {
|
|
107
142
|
const color = getColor('success');
|
|
108
143
|
const reset = getColor('reset');
|
|
109
|
-
|
|
144
|
+
process.stderr.write(`${color}${ICONS.success} ${message}${reset}\n`);
|
|
110
145
|
}
|
|
111
146
|
|
|
112
147
|
/**
|
|
@@ -115,17 +150,23 @@ export function success(message: string): void {
|
|
|
115
150
|
export function error(message: string): void {
|
|
116
151
|
const color = getColor('error');
|
|
117
152
|
const reset = getColor('reset');
|
|
118
|
-
|
|
153
|
+
process.stderr.write(`${color}${ICONS.error} ${message}${reset}\n`);
|
|
119
154
|
}
|
|
120
155
|
|
|
121
156
|
/**
|
|
122
157
|
* Print an error message with a red X and then exit
|
|
123
158
|
*/
|
|
124
|
-
export function fatal(message: string): never {
|
|
159
|
+
export function fatal(message: string, errorCode?: import('./errors').ErrorCode): never {
|
|
125
160
|
const color = getColor('error');
|
|
126
161
|
const reset = getColor('reset');
|
|
127
|
-
|
|
128
|
-
|
|
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
|
+
}
|
|
129
170
|
}
|
|
130
171
|
|
|
131
172
|
/**
|
|
@@ -134,7 +175,7 @@ export function fatal(message: string): never {
|
|
|
134
175
|
export function warning(message: string, asError = false): void {
|
|
135
176
|
const color = asError ? getColor('error') : getColor('warning');
|
|
136
177
|
const reset = getColor('reset');
|
|
137
|
-
|
|
178
|
+
process.stderr.write(`${color}${ICONS.warning} ${message}${reset}\n`);
|
|
138
179
|
}
|
|
139
180
|
|
|
140
181
|
/**
|
|
@@ -143,7 +184,7 @@ export function warning(message: string, asError = false): void {
|
|
|
143
184
|
export function info(message: string): void {
|
|
144
185
|
const color = getColor('info');
|
|
145
186
|
const reset = getColor('reset');
|
|
146
|
-
|
|
187
|
+
process.stderr.write(`${color}${ICONS.info} ${message}${reset}\n`);
|
|
147
188
|
}
|
|
148
189
|
|
|
149
190
|
/**
|
|
@@ -213,21 +254,21 @@ function supportsHyperlinks(): boolean {
|
|
|
213
254
|
* Print a bulleted list item
|
|
214
255
|
*/
|
|
215
256
|
export function bullet(message: string): void {
|
|
216
|
-
|
|
257
|
+
process.stderr.write(`${ICONS.bullet} ${message}\n`);
|
|
217
258
|
}
|
|
218
259
|
|
|
219
260
|
/**
|
|
220
261
|
* Print an arrow item (for showing next steps)
|
|
221
262
|
*/
|
|
222
263
|
export function arrow(message: string): void {
|
|
223
|
-
|
|
264
|
+
process.stderr.write(`${ICONS.arrow} ${message}\n`);
|
|
224
265
|
}
|
|
225
266
|
|
|
226
267
|
/**
|
|
227
268
|
* Print a blank line
|
|
228
269
|
*/
|
|
229
270
|
export function newline(): void {
|
|
230
|
-
|
|
271
|
+
process.stderr.write('\n');
|
|
231
272
|
}
|
|
232
273
|
|
|
233
274
|
/**
|
|
@@ -774,8 +815,13 @@ export async function spinner<T>(
|
|
|
774
815
|
const message = options.message;
|
|
775
816
|
const reset = getColor('reset');
|
|
776
817
|
|
|
777
|
-
//
|
|
778
|
-
|
|
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) {
|
|
779
825
|
try {
|
|
780
826
|
const result =
|
|
781
827
|
options.type === 'progress'
|
|
@@ -1293,3 +1339,122 @@ export async function showProfileList(
|
|
|
1293
1339
|
|
|
1294
1340
|
return response.name;
|
|
1295
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
|
+
}
|
|
1367
|
+
|
|
1368
|
+
/**
|
|
1369
|
+
* Table column definition
|
|
1370
|
+
*/
|
|
1371
|
+
export interface TableColumn {
|
|
1372
|
+
/** Column name */
|
|
1373
|
+
name: string;
|
|
1374
|
+
/** Column alignment */
|
|
1375
|
+
alignment?: 'left' | 'right' | 'center';
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
/**
|
|
1379
|
+
* Display data in a formatted table using console-table-printer
|
|
1380
|
+
*
|
|
1381
|
+
* Supports two modes:
|
|
1382
|
+
* 1. Simple mode: Pass data array and optional column names
|
|
1383
|
+
* 2. Advanced mode: Pass column configurations with custom names and alignment
|
|
1384
|
+
*
|
|
1385
|
+
* @param data - Array of data objects to display
|
|
1386
|
+
* @param columns - Column names or column configurations
|
|
1387
|
+
* @param options - Additional options
|
|
1388
|
+
* @returns If render=true, returns the table as a string, otherwise prints to stdout
|
|
1389
|
+
*/
|
|
1390
|
+
export function table<T extends Record<string, unknown>>(
|
|
1391
|
+
data: T[],
|
|
1392
|
+
columns?: (keyof T)[] | TableColumn[],
|
|
1393
|
+
options?: { render?: boolean }
|
|
1394
|
+
): string | void {
|
|
1395
|
+
// Dynamic import to avoid type errors (console-table-printer has poor typings)
|
|
1396
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
1397
|
+
const { Table } = require('console-table-printer') as {
|
|
1398
|
+
Table: new (options?: { columns?: Array<{ name: string; alignment: string }> }) => {
|
|
1399
|
+
addRow(row: Record<string, unknown>): void;
|
|
1400
|
+
printTable(): void;
|
|
1401
|
+
render(): string;
|
|
1402
|
+
};
|
|
1403
|
+
};
|
|
1404
|
+
|
|
1405
|
+
if (!data || data.length === 0) {
|
|
1406
|
+
return options?.render ? '' : undefined;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
// Determine if we're using advanced column config or simple column names
|
|
1410
|
+
const isAdvancedMode = columns && columns.length > 0 && typeof columns[0] === 'object';
|
|
1411
|
+
|
|
1412
|
+
let tableConfig: { columns: Array<{ name: string; alignment: string }> };
|
|
1413
|
+
|
|
1414
|
+
if (isAdvancedMode) {
|
|
1415
|
+
// Advanced mode: use provided column configurations
|
|
1416
|
+
tableConfig = {
|
|
1417
|
+
columns: (columns as TableColumn[]).map((col) => ({
|
|
1418
|
+
name: col.name,
|
|
1419
|
+
alignment: col.alignment || 'left',
|
|
1420
|
+
})),
|
|
1421
|
+
};
|
|
1422
|
+
} else {
|
|
1423
|
+
// Simple mode: determine column names from data or columns parameter
|
|
1424
|
+
const columnNames = columns
|
|
1425
|
+
? (columns as (keyof T)[]).map((c) => String(c))
|
|
1426
|
+
: data.length > 0
|
|
1427
|
+
? Object.keys(data[0])
|
|
1428
|
+
: [];
|
|
1429
|
+
|
|
1430
|
+
tableConfig = {
|
|
1431
|
+
columns: columnNames.map((name) => ({
|
|
1432
|
+
name,
|
|
1433
|
+
alignment: 'left',
|
|
1434
|
+
})),
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
const t = new Table(tableConfig);
|
|
1439
|
+
|
|
1440
|
+
// Add rows to table
|
|
1441
|
+
for (const row of data) {
|
|
1442
|
+
if (columns && !isAdvancedMode) {
|
|
1443
|
+
// Simple mode with column filtering
|
|
1444
|
+
const filtered: Record<string, unknown> = {};
|
|
1445
|
+
for (const col of columns as (keyof T)[]) {
|
|
1446
|
+
filtered[String(col)] = row[col];
|
|
1447
|
+
}
|
|
1448
|
+
t.addRow(filtered);
|
|
1449
|
+
} else {
|
|
1450
|
+
// Advanced mode or no column filtering
|
|
1451
|
+
t.addRow(row);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
if (options?.render) {
|
|
1456
|
+
return t.render();
|
|
1457
|
+
} else {
|
|
1458
|
+
t.printTable();
|
|
1459
|
+
}
|
|
1460
|
+
}
|