1
import { Console, Effect } from 'effect';
2
import { bold, dim, gray } from 'src/ui/colors';
3
+import {
4
+ type CommandVisibility,
5
+ experimental,
6
+ tagged,
7
+ visibleValues,
8
+ type TaggedValue,
9
+} from './feature-tags';
10
11
type DetailedCommand = {
12
name: string;
22
23
// ── Core workflow commands ──────────────────────────────────────────────
24
18
-const CORE_COMMANDS: ReadonlyArray<DetailedCommand> = [
19
- {
25
+const CORE_COMMANDS: ReadonlyArray<TaggedValue<DetailedCommand>> = [
26
+ tagged({
27
name: 'search',
28
description: 'Find tools by use case across all toolkits/apps.',
29
usage: 'search <query...> [--toolkits text] [--limit integer] [--human]',
36
{ name: '--limit', description: 'Maximum number of results (1-1000)' },
37
{ name: '--human', description: 'Show formatted output instead of default JSON' },
38
],
32
- },
33
- {
39
+ }),
40
+ tagged({
41
name: 'execute',
42
description:
43
'Execute a tool. Validates inputs and connections automatically; use it aggressively.',
61
{ name: '--dry-run', description: 'Validate and preview the tool call without executing it' },
62
{ name: '--get-schema', description: 'Fetch and print the CLI-facing input schema' },
63
],
57
- },
58
- {
64
+ }),
65
+ tagged({
66
name: 'link',
67
description: 'Connect your account for a toolkit/app.',
68
usage: 'link [<toolkit>]',
69
options: [{ name: '<toolkit>', description: 'Toolkit slug to link (e.g. "github", "gmail")' }],
63
- },
64
- {
70
+ }),
71
+ tagged({
72
name: 'run',
73
description:
74
'Run inline TS/JS code with shimmed CLI commands; injected execute(), search(), proxy(), experimental_subAgent(), and z (zod).',
78
{ name: '-f, --file', description: 'Run a TS/JS file instead of inline code' },
79
{ name: '--dry-run', description: 'Preview execute() calls without running remote actions' },
80
],
74
- },
75
- {
81
+ }),
82
+ experimental('listen', {
83
name: 'listen',
84
description:
85
'Create a temporary subscription for consumer-project events and persist each payload into the session artifact folder.',
107
'Also print each payload inline as a single-line stream value. Optionally pass a jq-like path such as ".thread.id".',
108
},
109
],
103
- },
104
- {
110
+ }),
111
+ tagged({
112
name: 'proxy',
113
description:
114
'curl-like access to any toolkit API through Composio using your connected account.',
120
{ name: '-H, --header', description: 'Header in "Name: value" format. Repeat for multiple.' },
121
{ name: '-d, --data', description: 'Request body as raw text, JSON, @file, or - for stdin' },
122
],
116
- },
123
+ }),
124
];
125
126
// ── Developer commands ─────────────────────────────────────────────────
127
121
-const OTHER_COMMANDS: ReadonlyArray<CompactCommand> = [
122
- { name: 'composio tools info <slug>', description: 'Print tool summary and cache its schema' },
123
- { name: 'composio tools list <toolkit>', description: 'List tools available in a toolkit' },
124
- {
128
+const OTHER_COMMANDS: ReadonlyArray<TaggedValue<CompactCommand>> = [
129
+ tagged({
130
+ name: 'composio tools info <slug>',
131
+ description: 'Print tool summary and cache its schema',
132
+ }),
133
+ tagged({
134
+ name: 'composio tools list <toolkit>',
135
+ description: 'List tools available in a toolkit',
136
+ }),
137
+ tagged({
138
name: 'composio triggers info <slug>',
139
description: 'Print trigger type details and schema summaries',
127
- },
128
- {
140
+ }),
141
+ tagged({
142
name: 'composio triggers list <toolkit>',
143
description: 'List available trigger types in a toolkit',
131
- },
132
- {
144
+ }),
145
+ tagged({
146
name: 'composio artifacts cwd',
147
description: 'Print the cwd-scoped session artifact directory',
135
- },
148
+ }),
149
];
150
138
-const DEVELOPER_COMMANDS: ReadonlyArray<CompactCommand> = [
139
- {
151
+const DEVELOPER_COMMANDS: ReadonlyArray<TaggedValue<CompactCommand>> = [
152
+ tagged({
153
name: 'dev',
154
description:
155
'Developer workflows and management: init, logs, projects, toolkits, accounts, and triggers.',
143
- },
144
- {
156
+ }),
157
+ tagged({
158
name: 'generate',
159
description: 'Generate type stubs for toolkits, tools, and triggers (TypeScript | Python).',
147
- },
160
+ }),
161
];
162
163
// ── Account commands ───────────────────────────────────────────────────
164
152
-const ACCOUNT_COMMANDS: ReadonlyArray<CompactCommand> = [
153
- { name: 'login', description: 'Log in to Composio' },
154
- { name: 'logout', description: 'Log out from Composio' },
155
- { name: 'whoami', description: 'Show current account info' },
156
- { name: 'orgs', description: 'Manage default organization context (list, switch)' },
157
- { name: 'version', description: 'Display CLI version' },
158
- { name: 'upgrade', description: 'Upgrade CLI to the latest version' },
165
+const ACCOUNT_COMMANDS: ReadonlyArray<TaggedValue<CompactCommand>> = [
166
+ tagged({ name: 'login', description: 'Log in to Composio' }),
167
+ tagged({ name: 'logout', description: 'Log out from Composio' }),
168
+ tagged({ name: 'whoami', description: 'Show current account info' }),
169
+ tagged({ name: 'orgs', description: 'Manage default organization context (list, switch)' }),
170
+ tagged({ name: 'version', description: 'Display CLI version' }),
171
+ tagged({ name: 'upgrade', description: 'Upgrade CLI to the latest version' }),
172
];
173
174
// ── Render helpers ─────────────────────────────────────────────────────
1003
* Check if argv is `composio <subcommand> --help` for a command we have custom help for.
1004
* Returns the command name if matched, undefined otherwise.
1005
*/
993
-export function matchSubcommandHelp(argv: ReadonlyArray<string>): string | undefined {
1006
+export function matchSubcommandHelp(
1007
+ argv: ReadonlyArray<string>,
1008
+ _visibility: CommandVisibility
1009
+): string | undefined {
1010
const args = argv.slice(2);
1011
if (args.length < 2) return undefined;
1012
const last = args[args.length - 1];
1021
return undefined;
1022
}
1023
1008
-export function printSubcommandHelp(cmd: string): Effect.Effect<void> {
1024
+export function printSubcommandHelp(
1025
+ cmd: string,
1026
+ _visibility: CommandVisibility
1027
+): Effect.Effect<void> {
1028
const help = SUBCOMMAND_HELP[cmd];
1029
if (!help) return Console.log(`Unknown command: ${cmd}`);
1030
return Console.log(renderSubcommandHelp(help));
1034
* Match the command name from argv without requiring --help at the end.
1035
* Used to print contextual help alongside error messages.
1036
*/
1018
-export function matchCommandFromArgv(argv: ReadonlyArray<string>): string | undefined {
1037
+export function matchCommandFromArgv(
1038
+ argv: ReadonlyArray<string>,
1039
+ _visibility: CommandVisibility
1040
+): string | undefined {
1041
const args = argv.slice(2).filter(a => a !== '--help' && a !== '-h' && !a.startsWith('--'));
1042
// Try longest match first: "dev toolkits list" → "dev toolkits" → "dev"
1043
for (let len = Math.min(args.length, 3); len > 0; len--) {
1050
/**
1051
* Get rendered help text for a command, or undefined if not found.
1052
*/
1031
-export function getCommandHelpText(cmd: string): string | undefined {
1053
+export function getCommandHelpText(
1054
+ cmd: string,
1055
+ _visibility: CommandVisibility
1056
+): string | undefined {
1057
const help = SUBCOMMAND_HELP[cmd];
1058
if (!help) return undefined;
1059
return renderSubcommandHelp(help);
1066
* Core workflow commands are shown first with full usage/options.
1067
* Housekeeping and developer commands are shown compactly at the bottom.
1068
*/
1044
-export function printRootHelp(): Effect.Effect<void> {
1069
+export function printRootHelp(visibility: CommandVisibility): Effect.Effect<void> {
1070
const name = 'composio';
1071
1072
const lines: string[] = [
1083
` ${name} <command> [options]`,
1084
'',
1085
bold('CORE COMMANDS'),
1061
- ...renderDetailedCommands(name, CORE_COMMANDS),
1086
+ ...renderDetailedCommands(name, visibleValues(CORE_COMMANDS, visibility)),
1087
gray(' Typical flow: search → execute (link and tools when needed)'),
1088
'',
1089
bold('TOOLS'),
1065
- ...renderCompactCommands(OTHER_COMMANDS),
1090
+ ...renderCompactCommands(visibleValues(OTHER_COMMANDS, visibility)),
1091
'',
1092
bold('EXAMPLES'),
1093
` ${dim('# Find tools — supports multiple queries at once')}`,
1121
` '`,
1122
'',
1123
bold('DEVELOPER COMMANDS'),
1099
- ...renderCompactCommands(DEVELOPER_COMMANDS),
1124
+ ...renderCompactCommands(visibleValues(DEVELOPER_COMMANDS, visibility)),
1125
'',
1126
bold('ACCOUNT'),
1102
- ...renderCompactCommands(ACCOUNT_COMMANDS),
1127
+ ...renderCompactCommands(visibleValues(ACCOUNT_COMMANDS, visibility)),
1128
'',
1129
bold('FILES') + dim(' (composio files --help)'),
1130
` ${bold('~/.composio/')}`,
1131
` CLI configuration and cache directory. Contains your auth state`,
1107
- ` (user_data.json), cached tool definitions (tools.json, toolkits.json),`,
1132
+ ` (user_data.json), runtime settings (config.json), cached tool definitions`,
1133
+ ` (tools.json, toolkits.json),`,
1134
` trigger types, and per-org consumer caches. These caches speed up`,
1135
` repeated commands — safe to delete, they will be re-fetched on next use.`,
1136
'',