@orchagent/cli 0.3.89 → 0.3.91
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/dist/commands/completion.js +379 -0
- package/dist/commands/dag.js +16 -7
- package/dist/commands/delete.js +9 -4
- package/dist/commands/diff.js +10 -2
- package/dist/commands/estimate.js +5 -2
- package/dist/commands/fork.js +7 -1
- package/dist/commands/index.js +2 -0
- package/dist/commands/info.js +8 -1
- package/dist/commands/init-wizard.js +160 -0
- package/dist/commands/init.js +38 -2
- package/dist/commands/login.js +8 -0
- package/dist/commands/logs.js +17 -7
- package/dist/commands/metrics.js +16 -7
- package/dist/commands/replay.js +16 -7
- package/dist/commands/run.js +51 -4
- package/dist/commands/schedule.js +72 -8
- package/dist/commands/secrets.js +16 -7
- package/dist/commands/service.js +16 -7
- package/dist/commands/skill.js +84 -8
- package/dist/commands/trace.js +16 -7
- package/dist/commands/tree.js +7 -1
- package/dist/commands/workspace.js +16 -7
- package/dist/lib/agent-ref.js +4 -1
- package/dist/lib/api.js +2 -8
- package/dist/lib/browser-auth.js +1 -0
- package/dist/lib/doctor/checks/environment.js +44 -1
- package/package.json +1 -1
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractCommands = extractCommands;
|
|
4
|
+
exports.generateBash = generateBash;
|
|
5
|
+
exports.generateZsh = generateZsh;
|
|
6
|
+
exports.generateFish = generateFish;
|
|
7
|
+
exports.generateCompletion = generateCompletion;
|
|
8
|
+
exports.registerCompletionCommand = registerCompletionCommand;
|
|
9
|
+
// --- Extraction ---
|
|
10
|
+
function extractOptions(opts) {
|
|
11
|
+
return opts.map((o) => ({
|
|
12
|
+
long: o.long ?? null,
|
|
13
|
+
short: o.short ?? null,
|
|
14
|
+
description: o.description,
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
function extractCommands(program) {
|
|
18
|
+
return program.commands
|
|
19
|
+
.filter((cmd) => cmd.name() !== 'completion')
|
|
20
|
+
.map((cmd) => ({
|
|
21
|
+
name: cmd.name(),
|
|
22
|
+
description: cmd.description(),
|
|
23
|
+
options: extractOptions(cmd.options),
|
|
24
|
+
subcommands: cmd.commands.map((sub) => ({
|
|
25
|
+
name: sub.name(),
|
|
26
|
+
description: sub.description(),
|
|
27
|
+
options: extractOptions(sub.options),
|
|
28
|
+
})),
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
function extractGlobalOptions(program) {
|
|
32
|
+
return extractOptions(program.options);
|
|
33
|
+
}
|
|
34
|
+
// --- Helpers ---
|
|
35
|
+
function longFlags(opts) {
|
|
36
|
+
return opts.filter((o) => o.long).map((o) => o.long);
|
|
37
|
+
}
|
|
38
|
+
/** Escape single quotes for embedding in shell strings */
|
|
39
|
+
function esc(s) {
|
|
40
|
+
return s.replace(/'/g, "'\\''");
|
|
41
|
+
}
|
|
42
|
+
// --- Bash ---
|
|
43
|
+
function generateBash(commands, globalOptions) {
|
|
44
|
+
const allNames = commands.map((c) => c.name).join(' ');
|
|
45
|
+
const globalFlags = [...longFlags(globalOptions), '--help', '--version'].join(' ');
|
|
46
|
+
// Build option-completion case arms
|
|
47
|
+
const optionArms = [];
|
|
48
|
+
for (const cmd of commands) {
|
|
49
|
+
const flags = [...longFlags(cmd.options), '--help'].join(' ');
|
|
50
|
+
if (cmd.subcommands.length > 0) {
|
|
51
|
+
const subArms = [];
|
|
52
|
+
for (const sub of cmd.subcommands) {
|
|
53
|
+
const subFlags = [...longFlags(sub.options), '--help'].join(' ');
|
|
54
|
+
subArms.push(` ${sub.name}) opts="${subFlags}" ;;`);
|
|
55
|
+
}
|
|
56
|
+
subArms.push(' *) opts="--help" ;;');
|
|
57
|
+
optionArms.push([
|
|
58
|
+
` ${cmd.name})`,
|
|
59
|
+
' case "$subcmd" in',
|
|
60
|
+
...subArms,
|
|
61
|
+
' esac',
|
|
62
|
+
' ;;',
|
|
63
|
+
].join('\n'));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
optionArms.push(` ${cmd.name}) opts="${flags}" ;;`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Build subcommand-completion case arms
|
|
70
|
+
const subArms = [];
|
|
71
|
+
for (const cmd of commands) {
|
|
72
|
+
if (cmd.subcommands.length > 0) {
|
|
73
|
+
const names = cmd.subcommands.map((s) => s.name).join(' ');
|
|
74
|
+
subArms.push(` ${cmd.name}) COMPREPLY=($(compgen -W "${names}" -- "$cur")) ;;`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const lines = [
|
|
78
|
+
'# orch shell completions — generated by: orch completion bash',
|
|
79
|
+
'#',
|
|
80
|
+
'# Setup (pick one):',
|
|
81
|
+
'# eval "$(orch completion bash)" # add to ~/.bashrc',
|
|
82
|
+
'# orch completion bash > ~/.local/share/bash-completion/completions/orch # persistent',
|
|
83
|
+
'',
|
|
84
|
+
'_orch() {',
|
|
85
|
+
' local cur cmd subcmd i',
|
|
86
|
+
' COMPREPLY=()',
|
|
87
|
+
' cur="${COMP_WORDS[COMP_CWORD]}"',
|
|
88
|
+
'',
|
|
89
|
+
' cmd=""',
|
|
90
|
+
' subcmd=""',
|
|
91
|
+
' for ((i=1; i < COMP_CWORD; i++)); do',
|
|
92
|
+
' case "${COMP_WORDS[i]}" in',
|
|
93
|
+
' -*) ;;',
|
|
94
|
+
' *)',
|
|
95
|
+
' if [[ -z "$cmd" ]]; then',
|
|
96
|
+
' cmd="${COMP_WORDS[i]}"',
|
|
97
|
+
' elif [[ -z "$subcmd" ]]; then',
|
|
98
|
+
' subcmd="${COMP_WORDS[i]}"',
|
|
99
|
+
' fi',
|
|
100
|
+
' ;;',
|
|
101
|
+
' esac',
|
|
102
|
+
' done',
|
|
103
|
+
'',
|
|
104
|
+
' if [[ "$cur" == -* ]]; then',
|
|
105
|
+
' local opts=""',
|
|
106
|
+
' if [[ -z "$cmd" ]]; then',
|
|
107
|
+
` opts="${globalFlags}"`,
|
|
108
|
+
' else',
|
|
109
|
+
' case "$cmd" in',
|
|
110
|
+
...optionArms,
|
|
111
|
+
' *) opts="--help" ;;',
|
|
112
|
+
' esac',
|
|
113
|
+
' fi',
|
|
114
|
+
' COMPREPLY=($(compgen -W "$opts" -- "$cur"))',
|
|
115
|
+
' return 0',
|
|
116
|
+
' fi',
|
|
117
|
+
'',
|
|
118
|
+
' if [[ -z "$cmd" ]]; then',
|
|
119
|
+
` COMPREPLY=($(compgen -W "${allNames}" -- "$cur"))`,
|
|
120
|
+
' return 0',
|
|
121
|
+
' fi',
|
|
122
|
+
'',
|
|
123
|
+
' case "$cmd" in',
|
|
124
|
+
...subArms,
|
|
125
|
+
' esac',
|
|
126
|
+
'}',
|
|
127
|
+
'',
|
|
128
|
+
'complete -o default -F _orch orch',
|
|
129
|
+
'complete -o default -F _orch orchagent',
|
|
130
|
+
'',
|
|
131
|
+
];
|
|
132
|
+
return lines.join('\n');
|
|
133
|
+
}
|
|
134
|
+
// --- Zsh ---
|
|
135
|
+
function generateZsh(commands, globalOptions) {
|
|
136
|
+
// Build command descriptions for _describe
|
|
137
|
+
const cmdDescriptions = commands
|
|
138
|
+
.map((c) => ` '${esc(c.name)}:${esc(c.description)}'`)
|
|
139
|
+
.join('\n');
|
|
140
|
+
// Build global option specs for _arguments
|
|
141
|
+
const globalOptSpecs = [];
|
|
142
|
+
for (const opt of globalOptions) {
|
|
143
|
+
if (opt.long) {
|
|
144
|
+
globalOptSpecs.push(` '${esc(opt.long)}[${esc(opt.description)}]'`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
globalOptSpecs.push(" '(--help -h)'{--help,-h}'[Show help]'");
|
|
148
|
+
globalOptSpecs.push(" '(--version -V)'{--version,-V}'[Show version]'");
|
|
149
|
+
// Build per-command argument completions
|
|
150
|
+
const commandCases = [];
|
|
151
|
+
for (const cmd of commands) {
|
|
152
|
+
if (cmd.subcommands.length > 0) {
|
|
153
|
+
// Subcommand group
|
|
154
|
+
const subDescs = cmd.subcommands
|
|
155
|
+
.map((s) => ` '${esc(s.name)}:${esc(s.description)}'`)
|
|
156
|
+
.join('\n');
|
|
157
|
+
const subArgsCases = [];
|
|
158
|
+
for (const sub of cmd.subcommands) {
|
|
159
|
+
const subOpts = [];
|
|
160
|
+
for (const opt of sub.options) {
|
|
161
|
+
if (opt.long) {
|
|
162
|
+
subOpts.push(` '${esc(opt.long)}[${esc(opt.description)}]'`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
subOpts.push(" '(--help -h)'{--help,-h}'[Show help]'");
|
|
166
|
+
subArgsCases.push([
|
|
167
|
+
` ${sub.name})`,
|
|
168
|
+
' _arguments \\',
|
|
169
|
+
subOpts.join(' \\\n'),
|
|
170
|
+
' ;;',
|
|
171
|
+
].join('\n'));
|
|
172
|
+
}
|
|
173
|
+
commandCases.push([
|
|
174
|
+
` ${cmd.name})`,
|
|
175
|
+
' local -a subcmds=(',
|
|
176
|
+
subDescs,
|
|
177
|
+
' )',
|
|
178
|
+
' _arguments -C \\',
|
|
179
|
+
" '1:subcommand:->subcmd' \\",
|
|
180
|
+
" '*::subarg:->subargs'",
|
|
181
|
+
' case $state in',
|
|
182
|
+
' subcmd)',
|
|
183
|
+
" _describe -t subcommands 'subcommand' subcmds",
|
|
184
|
+
' ;;',
|
|
185
|
+
' subargs)',
|
|
186
|
+
' case $line[1] in',
|
|
187
|
+
...subArgsCases,
|
|
188
|
+
' *)',
|
|
189
|
+
' _arguments \\',
|
|
190
|
+
" '(--help -h)'{--help,-h}'[Show help]'",
|
|
191
|
+
' ;;',
|
|
192
|
+
' esac',
|
|
193
|
+
' ;;',
|
|
194
|
+
' esac',
|
|
195
|
+
' ;;',
|
|
196
|
+
].join('\n'));
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
// Simple command
|
|
200
|
+
const cmdOpts = [];
|
|
201
|
+
for (const opt of cmd.options) {
|
|
202
|
+
if (opt.long) {
|
|
203
|
+
cmdOpts.push(` '${esc(opt.long)}[${esc(opt.description)}]'`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
cmdOpts.push(" '(--help -h)'{--help,-h}'[Show help]'");
|
|
207
|
+
commandCases.push([
|
|
208
|
+
` ${cmd.name})`,
|
|
209
|
+
' _arguments \\',
|
|
210
|
+
cmdOpts.join(' \\\n'),
|
|
211
|
+
' ;;',
|
|
212
|
+
].join('\n'));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const lines = [
|
|
216
|
+
'#compdef orch orchagent',
|
|
217
|
+
'#',
|
|
218
|
+
'# orch shell completions — generated by: orch completion zsh',
|
|
219
|
+
'#',
|
|
220
|
+
'# Setup (pick one):',
|
|
221
|
+
'# eval "$(orch completion zsh)" # add to ~/.zshrc',
|
|
222
|
+
'# orch completion zsh > "${fpath[1]}/_orch" # persistent (then compinit)',
|
|
223
|
+
'',
|
|
224
|
+
'_orch() {',
|
|
225
|
+
' local context state state_descr line',
|
|
226
|
+
' typeset -A opt_args',
|
|
227
|
+
'',
|
|
228
|
+
' local -a commands=(',
|
|
229
|
+
cmdDescriptions,
|
|
230
|
+
' )',
|
|
231
|
+
'',
|
|
232
|
+
' _arguments -C \\',
|
|
233
|
+
globalOptSpecs.join(' \\\n'),
|
|
234
|
+
" \\",
|
|
235
|
+
" '1:command:->command' \\",
|
|
236
|
+
" '*::arg:->args'",
|
|
237
|
+
'',
|
|
238
|
+
' case $state in',
|
|
239
|
+
' command)',
|
|
240
|
+
" _describe -t commands 'orch command' commands",
|
|
241
|
+
' ;;',
|
|
242
|
+
' args)',
|
|
243
|
+
' case $line[1] in',
|
|
244
|
+
...commandCases,
|
|
245
|
+
' *)',
|
|
246
|
+
' _arguments \\',
|
|
247
|
+
" '(--help -h)'{--help,-h}'[Show help]'",
|
|
248
|
+
' ;;',
|
|
249
|
+
' esac',
|
|
250
|
+
' ;;',
|
|
251
|
+
' esac',
|
|
252
|
+
'}',
|
|
253
|
+
'',
|
|
254
|
+
'_orch "$@"',
|
|
255
|
+
'',
|
|
256
|
+
];
|
|
257
|
+
return lines.join('\n');
|
|
258
|
+
}
|
|
259
|
+
// --- Fish ---
|
|
260
|
+
function generateFish(commands, globalOptions) {
|
|
261
|
+
const lines = [
|
|
262
|
+
'# orch shell completions — generated by: orch completion fish',
|
|
263
|
+
'#',
|
|
264
|
+
'# Setup (pick one):',
|
|
265
|
+
'# orch completion fish | source # add to config.fish',
|
|
266
|
+
'# orch completion fish > ~/.config/fish/completions/orch.fish # persistent',
|
|
267
|
+
'',
|
|
268
|
+
'# Disable file completions by default',
|
|
269
|
+
'complete -c orch -f',
|
|
270
|
+
'complete -c orchagent -f',
|
|
271
|
+
'',
|
|
272
|
+
'# Global options',
|
|
273
|
+
];
|
|
274
|
+
for (const opt of globalOptions) {
|
|
275
|
+
if (opt.long) {
|
|
276
|
+
const flag = opt.long.replace(/^--/, '');
|
|
277
|
+
lines.push(`complete -c orch -l ${flag} -d '${esc(opt.description)}'`);
|
|
278
|
+
lines.push(`complete -c orchagent -l ${flag} -d '${esc(opt.description)}'`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
lines.push("complete -c orch -l help -d 'Show help'");
|
|
282
|
+
lines.push("complete -c orchagent -l help -d 'Show help'");
|
|
283
|
+
lines.push("complete -c orch -l version -d 'Show version'");
|
|
284
|
+
lines.push("complete -c orchagent -l version -d 'Show version'");
|
|
285
|
+
lines.push('');
|
|
286
|
+
lines.push('# Commands');
|
|
287
|
+
for (const cmd of commands) {
|
|
288
|
+
lines.push(`complete -c orch -n '__fish_use_subcommand' -a ${cmd.name} -d '${esc(cmd.description)}'`);
|
|
289
|
+
lines.push(`complete -c orchagent -n '__fish_use_subcommand' -a ${cmd.name} -d '${esc(cmd.description)}'`);
|
|
290
|
+
}
|
|
291
|
+
// Subcommands for command groups
|
|
292
|
+
const groups = commands.filter((c) => c.subcommands.length > 0);
|
|
293
|
+
if (groups.length > 0) {
|
|
294
|
+
lines.push('');
|
|
295
|
+
lines.push('# Subcommands');
|
|
296
|
+
for (const cmd of groups) {
|
|
297
|
+
const subNames = cmd.subcommands.map((s) => s.name);
|
|
298
|
+
const notSeen = subNames.join(' ');
|
|
299
|
+
for (const sub of cmd.subcommands) {
|
|
300
|
+
const cond = `__fish_seen_subcommand_from ${cmd.name}; and not __fish_seen_subcommand_from ${notSeen}`;
|
|
301
|
+
lines.push(`complete -c orch -n '${cond}' -a ${sub.name} -d '${esc(sub.description)}'`);
|
|
302
|
+
lines.push(`complete -c orchagent -n '${cond}' -a ${sub.name} -d '${esc(sub.description)}'`);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
// Options per command
|
|
307
|
+
const commandsWithOptions = commands.filter((c) => c.options.length > 0 && c.subcommands.length === 0);
|
|
308
|
+
if (commandsWithOptions.length > 0) {
|
|
309
|
+
lines.push('');
|
|
310
|
+
lines.push('# Command options');
|
|
311
|
+
for (const cmd of commandsWithOptions) {
|
|
312
|
+
for (const opt of cmd.options) {
|
|
313
|
+
if (opt.long) {
|
|
314
|
+
const flag = opt.long.replace(/^--/, '');
|
|
315
|
+
lines.push(`complete -c orch -n '__fish_seen_subcommand_from ${cmd.name}' -l ${flag} -d '${esc(opt.description)}'`);
|
|
316
|
+
lines.push(`complete -c orchagent -n '__fish_seen_subcommand_from ${cmd.name}' -l ${flag} -d '${esc(opt.description)}'`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
// Options for subcommand groups (on the group level)
|
|
322
|
+
const groupsWithOpts = commands.filter((c) => c.subcommands.length > 0);
|
|
323
|
+
const subOptsNeeded = groupsWithOpts.some((g) => g.subcommands.some((s) => s.options.length > 0));
|
|
324
|
+
if (subOptsNeeded) {
|
|
325
|
+
lines.push('');
|
|
326
|
+
lines.push('# Subcommand options');
|
|
327
|
+
for (const cmd of groupsWithOpts) {
|
|
328
|
+
for (const sub of cmd.subcommands) {
|
|
329
|
+
for (const opt of sub.options) {
|
|
330
|
+
if (opt.long) {
|
|
331
|
+
const flag = opt.long.replace(/^--/, '');
|
|
332
|
+
lines.push(`complete -c orch -n '__fish_seen_subcommand_from ${cmd.name}; and __fish_seen_subcommand_from ${sub.name}' -l ${flag} -d '${esc(opt.description)}'`);
|
|
333
|
+
lines.push(`complete -c orchagent -n '__fish_seen_subcommand_from ${cmd.name}; and __fish_seen_subcommand_from ${sub.name}' -l ${flag} -d '${esc(opt.description)}'`);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
lines.push('');
|
|
340
|
+
return lines.join('\n');
|
|
341
|
+
}
|
|
342
|
+
// --- Dispatcher ---
|
|
343
|
+
const SUPPORTED_SHELLS = ['bash', 'zsh', 'fish'];
|
|
344
|
+
function generateCompletion(shell, program) {
|
|
345
|
+
const commands = extractCommands(program);
|
|
346
|
+
const globalOptions = extractGlobalOptions(program);
|
|
347
|
+
switch (shell) {
|
|
348
|
+
case 'bash':
|
|
349
|
+
return generateBash(commands, globalOptions);
|
|
350
|
+
case 'zsh':
|
|
351
|
+
return generateZsh(commands, globalOptions);
|
|
352
|
+
case 'fish':
|
|
353
|
+
return generateFish(commands, globalOptions);
|
|
354
|
+
default:
|
|
355
|
+
throw new Error(`Unsupported shell: ${shell}. Supported shells: ${SUPPORTED_SHELLS.join(', ')}`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
// --- Command Registration ---
|
|
359
|
+
function registerCompletionCommand(program) {
|
|
360
|
+
program
|
|
361
|
+
.command('completion')
|
|
362
|
+
.argument('<shell>', `Shell type (${SUPPORTED_SHELLS.join(', ')})`)
|
|
363
|
+
.description('Generate shell completion script')
|
|
364
|
+
.addHelpText('after', `
|
|
365
|
+
Examples:
|
|
366
|
+
orch completion bash Generate bash completions
|
|
367
|
+
orch completion zsh Generate zsh completions
|
|
368
|
+
orch completion fish Generate fish completions
|
|
369
|
+
|
|
370
|
+
Setup:
|
|
371
|
+
eval "$(orch completion bash)" # bash (add to ~/.bashrc)
|
|
372
|
+
eval "$(orch completion zsh)" # zsh (add to ~/.zshrc)
|
|
373
|
+
orch completion fish | source # fish (add to config.fish)
|
|
374
|
+
`)
|
|
375
|
+
.action((shell) => {
|
|
376
|
+
const script = generateCompletion(shell, program);
|
|
377
|
+
process.stdout.write(script);
|
|
378
|
+
});
|
|
379
|
+
}
|
package/dist/commands/dag.js
CHANGED
|
@@ -16,15 +16,24 @@ const spinner_1 = require("../lib/spinner");
|
|
|
16
16
|
async function resolveWorkspaceId(config, slug) {
|
|
17
17
|
const configFile = await (0, config_1.loadConfig)();
|
|
18
18
|
const targetSlug = slug ?? configFile.workspace;
|
|
19
|
-
if (!targetSlug) {
|
|
20
|
-
throw new errors_1.CliError('No workspace specified. Use --workspace <slug> or run `orch workspace use <slug>` first.');
|
|
21
|
-
}
|
|
22
19
|
const response = await (0, api_1.request)(config, 'GET', '/workspaces');
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
if (targetSlug) {
|
|
21
|
+
const workspace = response.workspaces.find((w) => w.slug === targetSlug);
|
|
22
|
+
if (!workspace) {
|
|
23
|
+
throw new errors_1.CliError(`Workspace '${targetSlug}' not found.`);
|
|
24
|
+
}
|
|
25
|
+
return workspace.id;
|
|
26
|
+
}
|
|
27
|
+
// No workspace specified — auto-select if user has exactly one
|
|
28
|
+
if (response.workspaces.length === 0) {
|
|
29
|
+
throw new errors_1.CliError('No workspaces found. Create one with `orch workspace create <name>`.');
|
|
30
|
+
}
|
|
31
|
+
if (response.workspaces.length === 1) {
|
|
32
|
+
return response.workspaces[0].id;
|
|
26
33
|
}
|
|
27
|
-
|
|
34
|
+
const slugs = response.workspaces.map((w) => w.slug).join(', ');
|
|
35
|
+
throw new errors_1.CliError(`Multiple workspaces available: ${slugs}\n` +
|
|
36
|
+
'Specify one with --workspace <slug> or run `orch workspace use <slug>`.');
|
|
28
37
|
}
|
|
29
38
|
function isUuid(value) {
|
|
30
39
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
package/dist/commands/delete.js
CHANGED
|
@@ -42,21 +42,26 @@ Examples:
|
|
|
42
42
|
if (!config.apiKey) {
|
|
43
43
|
throw new errors_1.CliError('Not logged in. Run `orchagent login` first.');
|
|
44
44
|
}
|
|
45
|
+
const configFile = await (0, config_1.loadConfig)();
|
|
46
|
+
const org = ref.org ?? configFile.workspace ?? config.defaultOrg;
|
|
47
|
+
if (!org) {
|
|
48
|
+
throw new errors_1.CliError('Missing org. Use org/agent format or set default org.');
|
|
49
|
+
}
|
|
45
50
|
// Resolve workspace context for the target org
|
|
46
|
-
const workspaceId = await (0, api_1.resolveWorkspaceIdForOrg)(config,
|
|
51
|
+
const workspaceId = await (0, api_1.resolveWorkspaceIdForOrg)(config, org);
|
|
47
52
|
process.stdout.write('Finding agent...\n');
|
|
48
53
|
// Find the agent by name, filtering by org if provided
|
|
49
54
|
const agents = await (0, api_1.listMyAgents)(config, workspaceId);
|
|
50
|
-
const matching = agents.filter(a => a.name === ref.agent && (!a.org_slug || a.org_slug ===
|
|
55
|
+
const matching = agents.filter(a => a.name === ref.agent && (!a.org_slug || a.org_slug === org));
|
|
51
56
|
if (matching.length === 0) {
|
|
52
|
-
throw new errors_1.CliError(`Agent '${
|
|
57
|
+
throw new errors_1.CliError(`Agent '${org}/${ref.agent}' not found`);
|
|
53
58
|
}
|
|
54
59
|
// Select version
|
|
55
60
|
let selectedAgent;
|
|
56
61
|
if (ref.version !== 'latest') {
|
|
57
62
|
selectedAgent = matching.find(a => a.version === ref.version);
|
|
58
63
|
if (!selectedAgent) {
|
|
59
|
-
throw new errors_1.CliError(`Version '${ref.version}' not found for agent '${
|
|
64
|
+
throw new errors_1.CliError(`Version '${ref.version}' not found for agent '${org}/${ref.agent}'`);
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
67
|
else {
|
package/dist/commands/diff.js
CHANGED
|
@@ -9,6 +9,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
9
9
|
const config_1 = require("../lib/config");
|
|
10
10
|
const api_1 = require("../lib/api");
|
|
11
11
|
const agent_ref_1 = require("../lib/agent-ref");
|
|
12
|
+
const errors_1 = require("../lib/errors");
|
|
12
13
|
const spinner_1 = require("../lib/spinner");
|
|
13
14
|
// ── Helpers ────────────────────────────────────────────────────
|
|
14
15
|
function extractDependencies(manifest) {
|
|
@@ -369,7 +370,8 @@ function printDiffs(refA, refB, diffs) {
|
|
|
369
370
|
function parseSecondRef(value, firstOrg, firstName) {
|
|
370
371
|
// If it contains '/', treat as full ref
|
|
371
372
|
if (value.includes('/')) {
|
|
372
|
-
|
|
373
|
+
const parsed = (0, agent_ref_1.parseAgentRef)(value);
|
|
374
|
+
return { org: parsed.org ?? firstOrg, agent: parsed.agent, version: parsed.version };
|
|
373
375
|
}
|
|
374
376
|
// Otherwise treat as a version shorthand for the same agent
|
|
375
377
|
return { org: firstOrg, agent: firstName, version: value };
|
|
@@ -382,7 +384,13 @@ function registerDiffCommand(program) {
|
|
|
382
384
|
.option('--json', 'Output as JSON')
|
|
383
385
|
.action(async (ref1Arg, ref2Arg, options) => {
|
|
384
386
|
const config = await (0, config_1.getResolvedConfig)();
|
|
385
|
-
const
|
|
387
|
+
const ref1Raw = (0, agent_ref_1.parseAgentRef)(ref1Arg);
|
|
388
|
+
const configFile = await (0, config_1.loadConfig)();
|
|
389
|
+
const ref1Org = ref1Raw.org ?? configFile.workspace ?? config.defaultOrg;
|
|
390
|
+
if (!ref1Org) {
|
|
391
|
+
throw new errors_1.CliError('Missing org. Use org/agent format or set default org.');
|
|
392
|
+
}
|
|
393
|
+
const ref1 = { org: ref1Org, agent: ref1Raw.agent, version: ref1Raw.version };
|
|
386
394
|
let ref2;
|
|
387
395
|
if (ref2Arg) {
|
|
388
396
|
ref2 = parseSecondRef(ref2Arg, ref1.org, ref1.agent);
|
|
@@ -35,11 +35,14 @@ function registerEstimateCommand(program) {
|
|
|
35
35
|
.option('--json', 'Output as JSON')
|
|
36
36
|
.action(async (agentArg, options) => {
|
|
37
37
|
const config = await (0, config_1.getResolvedConfig)();
|
|
38
|
-
const
|
|
38
|
+
const parsed = (0, agent_ref_1.parseAgentRef)(agentArg);
|
|
39
|
+
const configFile = await (0, config_1.loadConfig)();
|
|
40
|
+
const org = parsed.org ?? configFile.workspace ?? config.defaultOrg;
|
|
39
41
|
if (!org) {
|
|
40
|
-
process.stderr.write(chalk_1.default.red('Error: org/agent format
|
|
42
|
+
process.stderr.write(chalk_1.default.red('Error: Missing org. Use org/agent format or set default org.\n'));
|
|
41
43
|
process.exit(1);
|
|
42
44
|
}
|
|
45
|
+
const { agent, version } = parsed;
|
|
43
46
|
let data;
|
|
44
47
|
try {
|
|
45
48
|
data = await (0, api_1.getAgentCostEstimate)(config, org, agent, version);
|
package/dist/commands/fork.js
CHANGED
|
@@ -56,7 +56,13 @@ Examples:
|
|
|
56
56
|
if (!config.apiKey) {
|
|
57
57
|
throw new errors_1.CliError('Not logged in. Run `orchagent login` first.');
|
|
58
58
|
}
|
|
59
|
-
const
|
|
59
|
+
const parsed = (0, agent_ref_1.parseAgentRef)(agentRef);
|
|
60
|
+
const configFile = await (0, config_1.loadConfig)();
|
|
61
|
+
const org = parsed.org ?? configFile.workspace ?? config.defaultOrg;
|
|
62
|
+
if (!org) {
|
|
63
|
+
throw new errors_1.CliError('Missing org. Use org/agent format or set default org.');
|
|
64
|
+
}
|
|
65
|
+
const { agent, version } = parsed;
|
|
60
66
|
write('Resolving source agent...\n');
|
|
61
67
|
const source = await (0, api_1.getAgentWithFallback)(config, org, agent, version);
|
|
62
68
|
if (!source.id) {
|
package/dist/commands/index.js
CHANGED
|
@@ -42,6 +42,7 @@ const replay_1 = require("./replay");
|
|
|
42
42
|
const trace_1 = require("./trace");
|
|
43
43
|
const metrics_1 = require("./metrics");
|
|
44
44
|
const dag_1 = require("./dag");
|
|
45
|
+
const completion_1 = require("./completion");
|
|
45
46
|
function registerCommands(program) {
|
|
46
47
|
(0, login_1.registerLoginCommand)(program);
|
|
47
48
|
(0, logout_1.registerLogoutCommand)(program);
|
|
@@ -84,4 +85,5 @@ function registerCommands(program) {
|
|
|
84
85
|
(0, trace_1.registerTraceCommand)(program);
|
|
85
86
|
(0, metrics_1.registerMetricsCommand)(program);
|
|
86
87
|
(0, dag_1.registerDagCommand)(program);
|
|
88
|
+
(0, completion_1.registerCompletionCommand)(program);
|
|
87
89
|
}
|
package/dist/commands/info.js
CHANGED
|
@@ -8,6 +8,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
8
8
|
const config_1 = require("../lib/config");
|
|
9
9
|
const api_1 = require("../lib/api");
|
|
10
10
|
const agent_ref_1 = require("../lib/agent-ref");
|
|
11
|
+
const errors_1 = require("../lib/errors");
|
|
11
12
|
function formatSchema(schema, indent = ' ') {
|
|
12
13
|
const lines = [];
|
|
13
14
|
const props = schema.properties || {};
|
|
@@ -147,7 +148,13 @@ function registerInfoCommand(program) {
|
|
|
147
148
|
.option('--json', 'Output as JSON')
|
|
148
149
|
.action(async (agentArg, options) => {
|
|
149
150
|
const config = await (0, config_1.getResolvedConfig)();
|
|
150
|
-
const
|
|
151
|
+
const parsed = (0, agent_ref_1.parseAgentRef)(agentArg);
|
|
152
|
+
const configFile = await (0, config_1.loadConfig)();
|
|
153
|
+
const org = parsed.org ?? configFile.workspace ?? config.defaultOrg;
|
|
154
|
+
if (!org) {
|
|
155
|
+
throw new errors_1.CliError('Missing org. Use org/agent format or set default org.');
|
|
156
|
+
}
|
|
157
|
+
const { agent, version } = parsed;
|
|
151
158
|
// Resolve workspace context for the target org
|
|
152
159
|
const workspaceId = await (0, api_1.resolveWorkspaceIdForOrg)(config, org);
|
|
153
160
|
// Fetch agent metadata
|