@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.
Files changed (262) hide show
  1. package/bin/cli.ts +26 -5
  2. package/dist/banner.d.ts +1 -1
  3. package/dist/banner.d.ts.map +1 -1
  4. package/dist/cli-logger.d.ts +27 -0
  5. package/dist/cli-logger.d.ts.map +1 -0
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cmd/auth/index.d.ts.map +1 -1
  8. package/dist/cmd/auth/login.d.ts.map +1 -1
  9. package/dist/cmd/auth/logout.d.ts.map +1 -1
  10. package/dist/cmd/auth/signup.d.ts.map +1 -1
  11. package/dist/cmd/auth/ssh/add.d.ts.map +1 -1
  12. package/dist/cmd/auth/ssh/delete.d.ts.map +1 -1
  13. package/dist/cmd/auth/ssh/index.d.ts +1 -2
  14. package/dist/cmd/auth/ssh/index.d.ts.map +1 -1
  15. package/dist/cmd/auth/ssh/list.d.ts.map +1 -1
  16. package/dist/cmd/auth/whoami.d.ts.map +1 -1
  17. package/dist/cmd/bundle/ast.d.ts.map +1 -1
  18. package/dist/cmd/bundle/index.d.ts.map +1 -1
  19. package/dist/cmd/bundle/plugin.d.ts.map +1 -1
  20. package/dist/cmd/capabilities/index.d.ts +4 -0
  21. package/dist/cmd/capabilities/index.d.ts.map +1 -0
  22. package/dist/cmd/capabilities/show.d.ts +20 -0
  23. package/dist/cmd/capabilities/show.d.ts.map +1 -0
  24. package/dist/cmd/cloud/deploy.d.ts.map +1 -1
  25. package/dist/cmd/cloud/deployment/index.d.ts +2 -0
  26. package/dist/cmd/cloud/deployment/index.d.ts.map +1 -0
  27. package/dist/cmd/cloud/deployment/list.d.ts +2 -0
  28. package/dist/cmd/cloud/deployment/list.d.ts.map +1 -0
  29. package/dist/cmd/cloud/deployment/remove.d.ts +2 -0
  30. package/dist/cmd/cloud/deployment/remove.d.ts.map +1 -0
  31. package/dist/cmd/cloud/deployment/rollback.d.ts +2 -0
  32. package/dist/cmd/cloud/deployment/rollback.d.ts.map +1 -0
  33. package/dist/cmd/cloud/deployment/show.d.ts +2 -0
  34. package/dist/cmd/cloud/deployment/show.d.ts.map +1 -0
  35. package/dist/cmd/cloud/deployment/undeploy.d.ts +2 -0
  36. package/dist/cmd/cloud/deployment/undeploy.d.ts.map +1 -0
  37. package/dist/cmd/cloud/deployment/utils.d.ts +7 -0
  38. package/dist/cmd/cloud/deployment/utils.d.ts.map +1 -0
  39. package/dist/cmd/cloud/domain.d.ts.map +1 -1
  40. package/dist/cmd/cloud/index.d.ts.map +1 -1
  41. package/dist/cmd/cloud/resource/add.d.ts.map +1 -1
  42. package/dist/cmd/cloud/resource/delete.d.ts.map +1 -1
  43. package/dist/cmd/cloud/resource/index.d.ts +1 -2
  44. package/dist/cmd/cloud/resource/index.d.ts.map +1 -1
  45. package/dist/cmd/cloud/resource/list.d.ts.map +1 -1
  46. package/dist/cmd/cloud/scp/download.d.ts.map +1 -1
  47. package/dist/cmd/cloud/scp/index.d.ts +1 -2
  48. package/dist/cmd/cloud/scp/index.d.ts.map +1 -1
  49. package/dist/cmd/cloud/scp/upload.d.ts.map +1 -1
  50. package/dist/cmd/cloud/ssh.d.ts.map +1 -1
  51. package/dist/cmd/dev/index.d.ts.map +1 -1
  52. package/dist/cmd/env/delete.d.ts.map +1 -1
  53. package/dist/cmd/env/get.d.ts.map +1 -1
  54. package/dist/cmd/env/import.d.ts.map +1 -1
  55. package/dist/cmd/env/index.d.ts.map +1 -1
  56. package/dist/cmd/env/list.d.ts.map +1 -1
  57. package/dist/cmd/env/pull.d.ts.map +1 -1
  58. package/dist/cmd/env/push.d.ts.map +1 -1
  59. package/dist/cmd/env/set.d.ts.map +1 -1
  60. package/dist/cmd/index.d.ts.map +1 -1
  61. package/dist/cmd/kv/create-namespace.d.ts +3 -0
  62. package/dist/cmd/kv/create-namespace.d.ts.map +1 -0
  63. package/dist/cmd/kv/delete-namespace.d.ts +3 -0
  64. package/dist/cmd/kv/delete-namespace.d.ts.map +1 -0
  65. package/dist/cmd/kv/delete.d.ts +3 -0
  66. package/dist/cmd/kv/delete.d.ts.map +1 -0
  67. package/dist/cmd/kv/get.d.ts +3 -0
  68. package/dist/cmd/kv/get.d.ts.map +1 -0
  69. package/dist/cmd/kv/index.d.ts +2 -0
  70. package/dist/cmd/kv/index.d.ts.map +1 -0
  71. package/dist/cmd/kv/keys.d.ts +3 -0
  72. package/dist/cmd/kv/keys.d.ts.map +1 -0
  73. package/dist/cmd/kv/list-namespaces.d.ts +3 -0
  74. package/dist/cmd/kv/list-namespaces.d.ts.map +1 -0
  75. package/dist/cmd/kv/repl.d.ts +3 -0
  76. package/dist/cmd/kv/repl.d.ts.map +1 -0
  77. package/dist/cmd/kv/search.d.ts +3 -0
  78. package/dist/cmd/kv/search.d.ts.map +1 -0
  79. package/dist/cmd/kv/set.d.ts +3 -0
  80. package/dist/cmd/kv/set.d.ts.map +1 -0
  81. package/dist/cmd/kv/stats.d.ts +3 -0
  82. package/dist/cmd/kv/stats.d.ts.map +1 -0
  83. package/dist/cmd/kv/util.d.ts +8 -0
  84. package/dist/cmd/kv/util.d.ts.map +1 -0
  85. package/dist/cmd/objectstore/delete-bucket.d.ts +3 -0
  86. package/dist/cmd/objectstore/delete-bucket.d.ts.map +1 -0
  87. package/dist/cmd/objectstore/delete.d.ts +3 -0
  88. package/dist/cmd/objectstore/delete.d.ts.map +1 -0
  89. package/dist/cmd/objectstore/get.d.ts +3 -0
  90. package/dist/cmd/objectstore/get.d.ts.map +1 -0
  91. package/dist/cmd/objectstore/index.d.ts +2 -0
  92. package/dist/cmd/objectstore/index.d.ts.map +1 -0
  93. package/dist/cmd/objectstore/list-buckets.d.ts +3 -0
  94. package/dist/cmd/objectstore/list-buckets.d.ts.map +1 -0
  95. package/dist/cmd/objectstore/list-keys.d.ts +3 -0
  96. package/dist/cmd/objectstore/list-keys.d.ts.map +1 -0
  97. package/dist/cmd/objectstore/put.d.ts +3 -0
  98. package/dist/cmd/objectstore/put.d.ts.map +1 -0
  99. package/dist/cmd/objectstore/repl.d.ts +3 -0
  100. package/dist/cmd/objectstore/repl.d.ts.map +1 -0
  101. package/dist/cmd/objectstore/url.d.ts +3 -0
  102. package/dist/cmd/objectstore/url.d.ts.map +1 -0
  103. package/dist/cmd/objectstore/util.d.ts +8 -0
  104. package/dist/cmd/objectstore/util.d.ts.map +1 -0
  105. package/dist/cmd/profile/create.d.ts.map +1 -1
  106. package/dist/cmd/profile/delete.d.ts.map +1 -1
  107. package/dist/cmd/profile/index.d.ts.map +1 -1
  108. package/dist/cmd/profile/list.d.ts +1 -2
  109. package/dist/cmd/profile/list.d.ts.map +1 -1
  110. package/dist/cmd/profile/show.d.ts.map +1 -1
  111. package/dist/cmd/profile/use.d.ts.map +1 -1
  112. package/dist/cmd/project/create.d.ts.map +1 -1
  113. package/dist/cmd/project/delete.d.ts.map +1 -1
  114. package/dist/cmd/project/index.d.ts.map +1 -1
  115. package/dist/cmd/project/list.d.ts.map +1 -1
  116. package/dist/cmd/project/show.d.ts.map +1 -1
  117. package/dist/cmd/project/template-flow.d.ts +1 -1
  118. package/dist/cmd/project/template-flow.d.ts.map +1 -1
  119. package/dist/cmd/prompt/index.d.ts +4 -0
  120. package/dist/cmd/prompt/index.d.ts.map +1 -0
  121. package/dist/cmd/prompt/llm.d.ts +3 -0
  122. package/dist/cmd/prompt/llm.d.ts.map +1 -0
  123. package/dist/cmd/repl/index.d.ts +3 -0
  124. package/dist/cmd/repl/index.d.ts.map +1 -0
  125. package/dist/cmd/schema/index.d.ts +4 -0
  126. package/dist/cmd/schema/index.d.ts.map +1 -0
  127. package/dist/cmd/schema/show.d.ts +3 -0
  128. package/dist/cmd/schema/show.d.ts.map +1 -0
  129. package/dist/cmd/secret/delete.d.ts.map +1 -1
  130. package/dist/cmd/secret/get.d.ts.map +1 -1
  131. package/dist/cmd/secret/import.d.ts.map +1 -1
  132. package/dist/cmd/secret/index.d.ts.map +1 -1
  133. package/dist/cmd/secret/list.d.ts.map +1 -1
  134. package/dist/cmd/secret/pull.d.ts.map +1 -1
  135. package/dist/cmd/secret/push.d.ts.map +1 -1
  136. package/dist/cmd/secret/set.d.ts.map +1 -1
  137. package/dist/cmd/version/index.d.ts.map +1 -1
  138. package/dist/config.d.ts +1 -1
  139. package/dist/config.d.ts.map +1 -1
  140. package/dist/errors.d.ts +83 -0
  141. package/dist/errors.d.ts.map +1 -0
  142. package/dist/explain.d.ts +47 -0
  143. package/dist/explain.d.ts.map +1 -0
  144. package/dist/index.d.ts +6 -0
  145. package/dist/index.d.ts.map +1 -1
  146. package/dist/json.d.ts +3 -0
  147. package/dist/json.d.ts.map +1 -0
  148. package/dist/output.d.ts +136 -0
  149. package/dist/output.d.ts.map +1 -0
  150. package/dist/repl.d.ts +124 -0
  151. package/dist/repl.d.ts.map +1 -0
  152. package/dist/schema-generator.d.ts +67 -0
  153. package/dist/schema-generator.d.ts.map +1 -0
  154. package/dist/tui.d.ts +20 -1
  155. package/dist/tui.d.ts.map +1 -1
  156. package/dist/types.d.ts +65 -6
  157. package/dist/types.d.ts.map +1 -1
  158. package/package.json +10 -4
  159. package/src/banner.ts +7 -7
  160. package/src/cli-logger.ts +80 -0
  161. package/src/cli.ts +186 -54
  162. package/src/cmd/auth/index.ts +1 -0
  163. package/src/cmd/auth/login.ts +7 -2
  164. package/src/cmd/auth/logout.ts +4 -0
  165. package/src/cmd/auth/signup.ts +7 -2
  166. package/src/cmd/auth/ssh/add.ts +20 -3
  167. package/src/cmd/auth/ssh/delete.ts +57 -4
  168. package/src/cmd/auth/ssh/index.ts +4 -3
  169. package/src/cmd/auth/ssh/list.ts +44 -32
  170. package/src/cmd/auth/whoami.ts +32 -21
  171. package/src/cmd/bundle/ast.ts +27 -5
  172. package/src/cmd/bundle/index.ts +20 -0
  173. package/src/cmd/bundle/plugin.ts +36 -12
  174. package/src/cmd/capabilities/index.ts +12 -0
  175. package/src/cmd/capabilities/show.ts +256 -0
  176. package/src/cmd/cloud/deploy.ts +60 -0
  177. package/src/cmd/cloud/deployment/index.ts +20 -0
  178. package/src/cmd/cloud/deployment/list.ts +105 -0
  179. package/src/cmd/cloud/deployment/remove.ts +65 -0
  180. package/src/cmd/cloud/deployment/rollback.ts +87 -0
  181. package/src/cmd/cloud/deployment/show.ts +107 -0
  182. package/src/cmd/cloud/deployment/undeploy.ts +48 -0
  183. package/src/cmd/cloud/deployment/utils.ts +14 -0
  184. package/src/cmd/cloud/domain.ts +3 -2
  185. package/src/cmd/cloud/index.ts +9 -1
  186. package/src/cmd/cloud/resource/add.ts +19 -0
  187. package/src/cmd/cloud/resource/delete.ts +24 -3
  188. package/src/cmd/cloud/resource/index.ts +4 -3
  189. package/src/cmd/cloud/resource/list.ts +36 -10
  190. package/src/cmd/cloud/scp/download.ts +27 -1
  191. package/src/cmd/cloud/scp/index.ts +4 -3
  192. package/src/cmd/cloud/scp/upload.ts +27 -1
  193. package/src/cmd/cloud/ssh.ts +12 -0
  194. package/src/cmd/dev/index.ts +11 -7
  195. package/src/cmd/dev/templates.ts +1 -1
  196. package/src/cmd/env/delete.ts +17 -0
  197. package/src/cmd/env/get.ts +17 -1
  198. package/src/cmd/env/import.ts +47 -3
  199. package/src/cmd/env/index.ts +1 -0
  200. package/src/cmd/env/list.ts +13 -1
  201. package/src/cmd/env/pull.ts +20 -0
  202. package/src/cmd/env/push.ts +33 -1
  203. package/src/cmd/env/set.ts +25 -1
  204. package/src/cmd/index.ts +9 -2
  205. package/src/cmd/kv/create-namespace.ts +45 -0
  206. package/src/cmd/kv/delete-namespace.ts +73 -0
  207. package/src/cmd/kv/delete.ts +51 -0
  208. package/src/cmd/kv/get.ts +65 -0
  209. package/src/cmd/kv/index.ts +31 -0
  210. package/src/cmd/kv/keys.ts +57 -0
  211. package/src/cmd/kv/list-namespaces.ts +43 -0
  212. package/src/cmd/kv/repl.ts +284 -0
  213. package/src/cmd/kv/search.ts +80 -0
  214. package/src/cmd/kv/set.ts +63 -0
  215. package/src/cmd/kv/stats.ts +96 -0
  216. package/src/cmd/kv/util.ts +32 -0
  217. package/src/cmd/objectstore/delete-bucket.ts +72 -0
  218. package/src/cmd/objectstore/delete.ts +59 -0
  219. package/src/cmd/objectstore/get.ts +64 -0
  220. package/src/cmd/objectstore/index.ts +27 -0
  221. package/src/cmd/objectstore/list-buckets.ts +45 -0
  222. package/src/cmd/objectstore/list-keys.ts +60 -0
  223. package/src/cmd/objectstore/put.ts +62 -0
  224. package/src/cmd/objectstore/repl.ts +235 -0
  225. package/src/cmd/objectstore/url.ts +59 -0
  226. package/src/cmd/objectstore/util.ts +28 -0
  227. package/src/cmd/profile/create.ts +61 -6
  228. package/src/cmd/profile/delete.ts +25 -5
  229. package/src/cmd/profile/index.ts +1 -0
  230. package/src/cmd/profile/list.ts +7 -3
  231. package/src/cmd/profile/show.ts +33 -19
  232. package/src/cmd/profile/use.ts +17 -4
  233. package/src/cmd/project/create.ts +31 -0
  234. package/src/cmd/project/delete.ts +24 -2
  235. package/src/cmd/project/index.ts +1 -0
  236. package/src/cmd/project/list.ts +23 -9
  237. package/src/cmd/project/show.ts +27 -8
  238. package/src/cmd/project/template-flow.ts +10 -6
  239. package/src/cmd/prompt/index.ts +12 -0
  240. package/src/cmd/prompt/llm.ts +368 -0
  241. package/src/cmd/repl/index.ts +477 -0
  242. package/src/cmd/schema/index.ts +12 -0
  243. package/src/cmd/schema/show.ts +27 -0
  244. package/src/cmd/secret/delete.ts +17 -0
  245. package/src/cmd/secret/get.ts +20 -1
  246. package/src/cmd/secret/import.ts +45 -2
  247. package/src/cmd/secret/index.ts +1 -0
  248. package/src/cmd/secret/list.ts +10 -1
  249. package/src/cmd/secret/pull.ts +20 -0
  250. package/src/cmd/secret/push.ts +33 -1
  251. package/src/cmd/secret/set.ts +20 -0
  252. package/src/cmd/version/index.ts +15 -2
  253. package/src/config.ts +18 -5
  254. package/src/errors.ts +222 -0
  255. package/src/explain.ts +126 -0
  256. package/src/index.ts +51 -0
  257. package/src/json.ts +28 -0
  258. package/src/output.ts +307 -0
  259. package/src/repl.ts +1517 -0
  260. package/src/schema-generator.ts +389 -0
  261. package/src/tui.ts +136 -13
  262. 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 * as readline from 'readline';
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
- console.log(`${color}${ICONS.success} ${message}${reset}`);
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
- console.error(`${color}${ICONS.error} ${message}${reset}`);
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
- console.error(`${color}${ICONS.error} ${message}${reset}`);
127
- process.exit(1);
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
- console.log(`${color}${ICONS.warning} ${message}${reset}`);
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
- console.log(`${color}${ICONS.info} ${message}${reset}`);
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
- console.log(`${ICONS.bullet} ${message}`);
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
- console.log(`${ICONS.arrow} ${message}`);
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
- console.log('');
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
- // If no TTY, just execute the callback without animation
777
- if (!process.stderr.isTTY) {
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
+ }