Repository navigation
Expand file tree
/
Copy pathregistry.ts
More file actions
86 lines (82 loc) · 2.48 KB
/
Copy pathregistry.ts
File metadata and controls
86 lines (82 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import type { CommandSpec } from './types.js';
import { authCommands } from './auth.js';
import { doctorCommand } from './doctor.js';
import {
dataCommands,
discoverCommands,
executeCommand,
keysCommands,
projectsCommands,
} from './projects.js';
import { hostingCommands, storageCommands } from './hosting.js';
import { agentsCommands, generationCommands, ragCommands } from './ragAgents.js';
import { botsCommands, crmCommands } from './botsCrm.js';
import { metaCommands } from './meta.js';
import { CLI_VERSION } from '../runtime/cliVersion.js';
import { SDK_VERSION } from '@agentstack/sdk';
const versionCommand: CommandSpec = {
name: 'version',
description: 'Print CLI + linked SDK identity',
async run(rt) {
rt.print({
cli: CLI_VERSION,
sdk: SDK_VERSION.semantic,
sdkGeneration: SDK_VERSION.generation,
apiBase: rt.apiBase,
gene: 'repo.tooling.user_cli.gen1',
note: 'CLI semver is independent of AGENTSTACK_CORE_VERSION',
});
},
};
export const ALL_COMMANDS: CommandSpec[] = [
...metaCommands,
...authCommands,
doctorCommand,
versionCommand,
...discoverCommands,
executeCommand,
...projectsCommands,
...dataCommands,
...keysCommands,
...hostingCommands,
...storageCommands,
...ragCommands,
...agentsCommands,
...generationCommands,
...botsCommands,
...crmCommands,
];
export function findCommand(argv: string[]): {
cmd: CommandSpec | null;
rest: string[];
} {
const cleaned = argv.filter((a) => a !== '--');
// Match longest name first
const sorted = [...ALL_COMMANDS].sort(
(a, b) => b.name.split(' ').length - a.name.split(' ').length,
);
for (const cmd of sorted) {
const parts = cmd.name.split(' ');
if (parts.every((p, i) => cleaned[i] === p)) {
return { cmd, rest: cleaned.slice(parts.length) };
}
}
return { cmd: null, rest: cleaned };
}
export function helpText(): string {
const lines = [
'AgentStack CLI (@agentstack/cli) — repo.tooling.user_cli.gen1',
'',
'Usage: agentstack [--json] [--project N] [--profile name] <command>',
'',
'Commands:',
];
for (const c of ALL_COMMANDS) {
const tag = c.sdkPath ? ` [sdk:${c.sdkPath}]` : c.mcpAction ? ` [mcp:${c.mcpAction}]` : '';
lines.push(` ${c.name.padEnd(28)} ${c.description}${tag}`);
}
lines.push('');
lines.push('Escape hatch: agentstack execute --action <mcp.action> --params \'{…}\'');
lines.push('Docs: https://agentstack.tech — docs/CLI_QUICKSTART.md');
return lines.join('\n');
}