@nordsym/apiclaw 1.5.13 → 1.5.14

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 (68) hide show
  1. package/dist/bin.js +1 -1
  2. package/dist/cli/index.js +7 -0
  3. package/dist/convex/adminActivate.js +46 -0
  4. package/dist/convex/adminStats.js +41 -0
  5. package/dist/convex/agents.js +498 -0
  6. package/dist/convex/analytics.js +165 -0
  7. package/dist/convex/billing.js +654 -0
  8. package/dist/convex/capabilities.js +144 -0
  9. package/dist/convex/chains.js +1041 -0
  10. package/dist/convex/credits.js +185 -0
  11. package/dist/convex/crons.js +16 -0
  12. package/dist/convex/directCall.js +626 -0
  13. package/dist/convex/earnProgress.js +648 -0
  14. package/dist/convex/email.js +299 -0
  15. package/dist/convex/feedback.js +226 -0
  16. package/dist/convex/http.js +909 -0
  17. package/dist/convex/logs.js +486 -0
  18. package/dist/convex/mou.js +81 -0
  19. package/dist/convex/providerKeys.js +256 -0
  20. package/dist/convex/providers.js +755 -0
  21. package/dist/convex/purchases.js +156 -0
  22. package/dist/convex/ratelimit.js +90 -0
  23. package/dist/convex/schema.js +709 -0
  24. package/dist/convex/searchLogs.js +128 -0
  25. package/dist/convex/spendAlerts.js +379 -0
  26. package/dist/convex/stripeActions.js +410 -0
  27. package/dist/convex/teams.js +214 -0
  28. package/dist/convex/telemetry.js +73 -0
  29. package/dist/convex/usage.js +228 -0
  30. package/dist/convex/waitlist.js +48 -0
  31. package/dist/convex/webhooks.js +409 -0
  32. package/dist/convex/workspaces.js +879 -0
  33. package/dist/src/analytics.js +129 -0
  34. package/dist/src/bin.js +17 -0
  35. package/dist/src/capability-router.js +240 -0
  36. package/dist/src/chainExecutor.js +451 -0
  37. package/dist/src/chainResolver.js +518 -0
  38. package/dist/src/cli/commands/doctor.js +324 -0
  39. package/dist/src/cli/commands/mcp-install.js +255 -0
  40. package/dist/src/cli/commands/restore.js +259 -0
  41. package/dist/src/cli/commands/setup.js +205 -0
  42. package/dist/src/cli/commands/uninstall.js +188 -0
  43. package/dist/src/cli/index.js +111 -0
  44. package/dist/src/cli.js +302 -0
  45. package/dist/src/confirmation.js +240 -0
  46. package/dist/src/credentials.js +357 -0
  47. package/dist/src/credits.js +260 -0
  48. package/dist/src/crypto.js +66 -0
  49. package/dist/src/discovery.js +504 -0
  50. package/dist/src/enterprise/env.js +123 -0
  51. package/dist/src/enterprise/script-generator.js +460 -0
  52. package/dist/src/execute-dynamic.js +473 -0
  53. package/dist/src/execute.js +1727 -0
  54. package/dist/src/index.js +2062 -0
  55. package/dist/src/metered.js +80 -0
  56. package/dist/src/open-apis.js +276 -0
  57. package/dist/src/proxy.js +28 -0
  58. package/dist/src/session.js +86 -0
  59. package/dist/src/stripe.js +407 -0
  60. package/dist/src/telemetry.js +49 -0
  61. package/dist/src/types.js +2 -0
  62. package/dist/src/utils/backup.js +181 -0
  63. package/dist/src/utils/config.js +220 -0
  64. package/dist/src/utils/os.js +105 -0
  65. package/dist/src/utils/paths.js +159 -0
  66. package/package.json +1 -1
  67. package/src/bin.ts +1 -1
  68. package/src/cli/index.ts +8 -0
@@ -0,0 +1,259 @@
1
+ /**
2
+ * Restore Command
3
+ * Rollback MCP client configs from backups
4
+ */
5
+ import { existsSync } from 'fs';
6
+ import { listBackups, restoreBackup as doRestore, getLatestBackup, formatBackupInfo } from '../../utils/backup.js';
7
+ import { getAllClients, getClientConfig, parseClientArg } from '../../utils/paths.js';
8
+ /**
9
+ * List all available backups for a client
10
+ */
11
+ function listClientBackups(client) {
12
+ const config = getClientConfig(client);
13
+ return listBackups(config.configPath);
14
+ }
15
+ /**
16
+ * List all backups across all clients
17
+ */
18
+ export function listAllBackups() {
19
+ const results = new Map();
20
+ for (const client of getAllClients()) {
21
+ const backups = listClientBackups(client);
22
+ if (backups.length > 0) {
23
+ results.set(client, backups);
24
+ }
25
+ }
26
+ return results;
27
+ }
28
+ /**
29
+ * Format backup list for display
30
+ */
31
+ export function formatBackupList(backups) {
32
+ const lines = [];
33
+ lines.push('');
34
+ lines.push('šŸ“¦ Available Backups');
35
+ lines.push('====================');
36
+ lines.push('');
37
+ if (backups.size === 0) {
38
+ lines.push('No backups found.');
39
+ lines.push('');
40
+ lines.push('Backups are created automatically when you run setup.');
41
+ lines.push('');
42
+ return lines.join('\n');
43
+ }
44
+ for (const [client, clientBackups] of backups) {
45
+ const config = getClientConfig(client);
46
+ lines.push(`${config.displayName}:`);
47
+ for (let i = 0; i < clientBackups.length; i++) {
48
+ const backup = clientBackups[i];
49
+ const marker = i === 0 ? ' (latest)' : '';
50
+ lines.push(` ${i + 1}. ${formatBackupInfo(backup)}${marker}`);
51
+ }
52
+ lines.push('');
53
+ }
54
+ lines.push('Usage:');
55
+ lines.push(' npx @nordsym/apiclaw restore # Restore latest for all');
56
+ lines.push(' npx @nordsym/apiclaw restore --client claude # Restore latest for Claude');
57
+ lines.push(' npx @nordsym/apiclaw restore --backup <path> # Restore specific backup');
58
+ lines.push('');
59
+ return lines.join('\n');
60
+ }
61
+ /**
62
+ * Restore a specific client to its latest backup
63
+ */
64
+ export function restoreClient(client) {
65
+ const config = getClientConfig(client);
66
+ const configPath = config.configPath;
67
+ // Check if config exists
68
+ if (!existsSync(configPath)) {
69
+ return {
70
+ success: false,
71
+ client: config.displayName,
72
+ message: 'No config file to restore',
73
+ };
74
+ }
75
+ // Get latest backup
76
+ const latest = getLatestBackup(configPath);
77
+ if (!latest) {
78
+ return {
79
+ success: false,
80
+ client: config.displayName,
81
+ message: 'No backups available',
82
+ };
83
+ }
84
+ // Perform restore
85
+ const result = doRestore(latest.path, configPath);
86
+ if (result.success) {
87
+ return {
88
+ success: true,
89
+ client: config.displayName,
90
+ message: 'Restored successfully',
91
+ backupUsed: latest.filename,
92
+ preRestoreBackup: result.backupPath || undefined,
93
+ };
94
+ }
95
+ return {
96
+ success: false,
97
+ client: config.displayName,
98
+ message: result.error || 'Unknown error',
99
+ };
100
+ }
101
+ /**
102
+ * Restore from a specific backup file
103
+ */
104
+ export function restoreFromFile(backupPath, client) {
105
+ // Validate backup exists
106
+ if (!existsSync(backupPath)) {
107
+ return {
108
+ success: false,
109
+ client: client ? getClientConfig(client).displayName : 'Unknown',
110
+ message: `Backup file not found: ${backupPath}`,
111
+ };
112
+ }
113
+ // If client not specified, try to detect from backup path
114
+ if (!client) {
115
+ for (const c of getAllClients()) {
116
+ const config = getClientConfig(c);
117
+ if (backupPath.includes(config.configDir)) {
118
+ client = c;
119
+ break;
120
+ }
121
+ }
122
+ }
123
+ if (!client) {
124
+ return {
125
+ success: false,
126
+ client: 'Unknown',
127
+ message: 'Could not determine target client. Use --client to specify.',
128
+ };
129
+ }
130
+ const config = getClientConfig(client);
131
+ const result = doRestore(backupPath, config.configPath);
132
+ if (result.success) {
133
+ return {
134
+ success: true,
135
+ client: config.displayName,
136
+ message: 'Restored successfully',
137
+ backupUsed: backupPath,
138
+ preRestoreBackup: result.backupPath || undefined,
139
+ };
140
+ }
141
+ return {
142
+ success: false,
143
+ client: config.displayName,
144
+ message: result.error || 'Unknown error',
145
+ };
146
+ }
147
+ /**
148
+ * Restore all clients to their latest backups
149
+ */
150
+ export function restoreAll() {
151
+ const results = [];
152
+ for (const client of getAllClients()) {
153
+ const config = getClientConfig(client);
154
+ // Skip clients without backups
155
+ const backups = listClientBackups(client);
156
+ if (backups.length === 0) {
157
+ continue;
158
+ }
159
+ results.push(restoreClient(client));
160
+ }
161
+ return results;
162
+ }
163
+ /**
164
+ * Format restore results for display
165
+ */
166
+ export function formatRestoreResults(results) {
167
+ const lines = [];
168
+ lines.push('');
169
+ lines.push('šŸ”„ Restore Results');
170
+ lines.push('==================');
171
+ lines.push('');
172
+ if (results.length === 0) {
173
+ lines.push('No clients had backups to restore.');
174
+ lines.push('');
175
+ return lines.join('\n');
176
+ }
177
+ for (const result of results) {
178
+ const icon = result.success ? 'āœ“' : 'āœ—';
179
+ lines.push(`${icon} ${result.client}: ${result.message}`);
180
+ if (result.backupUsed) {
181
+ lines.push(` Restored from: ${result.backupUsed}`);
182
+ }
183
+ if (result.preRestoreBackup) {
184
+ lines.push(` Pre-restore backup: ${result.preRestoreBackup}`);
185
+ }
186
+ }
187
+ lines.push('');
188
+ const successful = results.filter(r => r.success).length;
189
+ if (successful > 0) {
190
+ lines.push(`āœ“ Restored ${successful} client(s). Restart your MCP clients to apply changes.`);
191
+ }
192
+ lines.push('');
193
+ return lines.join('\n');
194
+ }
195
+ /**
196
+ * Restore command handler
197
+ */
198
+ export async function restoreCommand(options = {}) {
199
+ // List mode
200
+ if (options.list) {
201
+ const backups = listAllBackups();
202
+ console.log(formatBackupList(backups));
203
+ return;
204
+ }
205
+ // Dry run mode
206
+ if (options.dryRun) {
207
+ console.log('\nšŸ” Dry run - would restore:\n');
208
+ if (options.backup) {
209
+ console.log(` From file: ${options.backup}`);
210
+ }
211
+ else if (options.client) {
212
+ const client = parseClientArg(options.client);
213
+ if (client) {
214
+ const latest = getLatestBackup(getClientConfig(client).configPath);
215
+ console.log(` ${getClientConfig(client).displayName}: ${latest?.filename || 'No backup'}`);
216
+ }
217
+ }
218
+ else {
219
+ const backups = listAllBackups();
220
+ for (const [client, clientBackups] of backups) {
221
+ console.log(` ${getClientConfig(client).displayName}: ${clientBackups[0]?.filename || 'No backup'}`);
222
+ }
223
+ }
224
+ console.log('\nRun without --dry-run to perform restore.\n');
225
+ return;
226
+ }
227
+ // Restore from specific file
228
+ if (options.backup) {
229
+ const client = options.client ? parseClientArg(options.client) : undefined;
230
+ const result = restoreFromFile(options.backup, client || undefined);
231
+ console.log(formatRestoreResults([result]));
232
+ if (!result.success) {
233
+ process.exit(1);
234
+ }
235
+ return;
236
+ }
237
+ // Restore specific client
238
+ if (options.client) {
239
+ const client = parseClientArg(options.client);
240
+ if (!client) {
241
+ console.error(`\nāœ— Unknown client: ${options.client}\n`);
242
+ console.error('Valid clients: claude, cursor, windsurf, cline, continue\n');
243
+ process.exit(1);
244
+ }
245
+ const result = restoreClient(client);
246
+ console.log(formatRestoreResults([result]));
247
+ if (!result.success) {
248
+ process.exit(1);
249
+ }
250
+ return;
251
+ }
252
+ // Restore all clients with backups
253
+ const results = restoreAll();
254
+ console.log(formatRestoreResults(results));
255
+ const failures = results.filter(r => !r.success);
256
+ if (failures.length > 0) {
257
+ process.exit(1);
258
+ }
259
+ }
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Setup Command
3
+ * Configures APIClaw for MCP clients
4
+ */
5
+ import { existsSync } from 'fs';
6
+ import { detectOS, getOSDisplayName } from '../../utils/os.js';
7
+ import { getAllClients, getConfigPath, getClientConfig, parseClientArg } from '../../utils/paths.js';
8
+ import { readConfig, writeConfig, mergeApiclawConfig, mergeApiclawContinueConfig, hasApiclawConfig, isContinueFormat } from '../../utils/config.js';
9
+ /**
10
+ * Detect which MCP clients are installed
11
+ */
12
+ function detectInstalledClients() {
13
+ const clients = getAllClients();
14
+ const installed = [];
15
+ for (const client of clients) {
16
+ const configPath = getConfigPath(client);
17
+ // Check if config exists OR if parent directory exists (client might be installed but not configured)
18
+ if (existsSync(configPath)) {
19
+ installed.push(client);
20
+ }
21
+ }
22
+ return installed;
23
+ }
24
+ /**
25
+ * Check if a client's config directory structure exists (might not have config yet)
26
+ */
27
+ function clientMightBeInstalled(client) {
28
+ const config = getClientConfig(client);
29
+ const configDir = config.configDir;
30
+ // Check a few levels up to see if the app is installed
31
+ const pathParts = configDir.split('/').filter(Boolean);
32
+ for (let i = pathParts.length; i >= Math.max(0, pathParts.length - 3); i--) {
33
+ const checkPath = '/' + pathParts.slice(0, i).join('/');
34
+ if (existsSync(checkPath)) {
35
+ return true;
36
+ }
37
+ }
38
+ return false;
39
+ }
40
+ /**
41
+ * Setup a single client
42
+ */
43
+ async function setupClient(client, configPath, options) {
44
+ const displayName = client === 'custom' ? 'Custom' : getClientConfig(client).displayName;
45
+ if (options.verbose) {
46
+ console.log(`\nšŸ“ Configuring ${displayName}...`);
47
+ console.log(` Config path: ${configPath}`);
48
+ }
49
+ // Read existing config
50
+ const readResult = readConfig(configPath);
51
+ if (!readResult.success) {
52
+ return {
53
+ client: displayName,
54
+ success: false,
55
+ message: readResult.error || 'Failed to read config',
56
+ };
57
+ }
58
+ const existingConfig = readResult.config;
59
+ // Check if APIClaw is already configured
60
+ if (hasApiclawConfig(existingConfig) && !options.force) {
61
+ if (options.verbose) {
62
+ console.log(` ā­ļø APIClaw already configured (use --force to update)`);
63
+ }
64
+ return {
65
+ client: displayName,
66
+ success: true,
67
+ message: 'Already configured',
68
+ skipped: true,
69
+ };
70
+ }
71
+ // Merge APIClaw config
72
+ let newConfig;
73
+ if (client === 'continue' || isContinueFormat(existingConfig)) {
74
+ newConfig = mergeApiclawContinueConfig(existingConfig, {
75
+ workspace: options.workspace,
76
+ force: options.force,
77
+ });
78
+ }
79
+ else {
80
+ newConfig = mergeApiclawConfig(existingConfig, {
81
+ workspace: options.workspace,
82
+ force: options.force,
83
+ });
84
+ }
85
+ // Dry run - show what would happen
86
+ if (options.dryRun) {
87
+ console.log(`\nšŸ“‹ Would configure ${displayName}:`);
88
+ console.log(` Path: ${configPath}`);
89
+ console.log(` Changes:`);
90
+ if (isContinueFormat(newConfig)) {
91
+ const continueConfig = newConfig;
92
+ const apiclaw = continueConfig.mcpServers?.find(s => s.name === 'apiclaw');
93
+ console.log(JSON.stringify(apiclaw, null, 4).split('\n').map(l => ` ${l}`).join('\n'));
94
+ }
95
+ else {
96
+ const mcpConfig = newConfig;
97
+ console.log(JSON.stringify({ apiclaw: mcpConfig.mcpServers?.apiclaw }, null, 4).split('\n').map(l => ` ${l}`).join('\n'));
98
+ }
99
+ return {
100
+ client: displayName,
101
+ success: true,
102
+ message: 'Dry run - no changes made',
103
+ skipped: true,
104
+ };
105
+ }
106
+ // Write config
107
+ const writeResult = writeConfig(configPath, newConfig, true);
108
+ if (!writeResult.success) {
109
+ return {
110
+ client: displayName,
111
+ success: false,
112
+ message: writeResult.error || 'Failed to write config',
113
+ };
114
+ }
115
+ return {
116
+ client: displayName,
117
+ success: true,
118
+ message: readResult.isNew ? 'Created new config' : 'Updated existing config',
119
+ backupPath: writeResult.backupPath,
120
+ };
121
+ }
122
+ /**
123
+ * Main setup command handler
124
+ */
125
+ export async function setupCommand(options) {
126
+ const os = detectOS();
127
+ const osName = getOSDisplayName();
128
+ console.log('\nšŸš€ APIClaw MCP Auto-Setup\n');
129
+ console.log(`Platform: ${osName}\n`);
130
+ // Determine which clients to configure
131
+ let clientsToSetup = [];
132
+ if (options.config) {
133
+ // Custom config path
134
+ clientsToSetup.push({ client: 'custom', path: options.config });
135
+ }
136
+ else if (options.client) {
137
+ // Specific client
138
+ const client = parseClientArg(options.client);
139
+ if (!client) {
140
+ console.error(`āŒ Unknown client: ${options.client}`);
141
+ console.log(' Supported clients: claude-desktop, cursor, windsurf, cline, continue');
142
+ process.exit(1);
143
+ }
144
+ clientsToSetup.push({ client, path: getConfigPath(client) });
145
+ }
146
+ else {
147
+ // Auto-detect or all
148
+ console.log('šŸ” Detecting MCP clients...\n');
149
+ const allClients = getAllClients();
150
+ const detected = detectInstalledClients();
151
+ for (const client of allClients) {
152
+ const config = getClientConfig(client);
153
+ const isDetected = detected.includes(client);
154
+ const icon = isDetected ? 'āœ“' : 'āœ—';
155
+ const status = isDetected ? 'found' : 'not found';
156
+ console.log(` ${icon} ${config.displayName} ${status}`);
157
+ if (isDetected || options.all) {
158
+ clientsToSetup.push({ client, path: config.configPath });
159
+ }
160
+ }
161
+ console.log('');
162
+ if (clientsToSetup.length === 0) {
163
+ console.log('āš ļø No MCP clients detected. Use --client to specify manually.');
164
+ console.log(' Example: npx @nordsym/apiclaw setup --client claude-desktop');
165
+ process.exit(0);
166
+ }
167
+ }
168
+ // Setup each client
169
+ const results = [];
170
+ for (const { client, path } of clientsToSetup) {
171
+ const result = await setupClient(client, path, options);
172
+ results.push(result);
173
+ const icon = result.success ? (result.skipped ? 'ā­ļø' : 'āœ“') : 'āœ—';
174
+ console.log(`${icon} ${result.client}: ${result.message}`);
175
+ if (result.backupPath && options.verbose) {
176
+ console.log(` Backup: ${result.backupPath}`);
177
+ }
178
+ }
179
+ // Summary
180
+ const succeeded = results.filter(r => r.success && !r.skipped).length;
181
+ const skipped = results.filter(r => r.skipped).length;
182
+ const failed = results.filter(r => !r.success).length;
183
+ console.log('\n' + '═'.repeat(50));
184
+ if (failed === 0) {
185
+ if (options.dryRun) {
186
+ console.log('\nāœ… Dry run complete! Use without --dry-run to apply changes.\n');
187
+ }
188
+ else if (succeeded > 0) {
189
+ console.log('\nāœ… APIClaw configured successfully!\n');
190
+ console.log('Next steps:');
191
+ console.log(' 1. Restart your AI coding assistant');
192
+ console.log(' 2. Ask your agent: "List available APIs"\n');
193
+ console.log('Need help? https://apiclaw.nordsym.com/docs/setup\n');
194
+ }
195
+ else if (skipped === results.length) {
196
+ console.log('\nāœ… APIClaw already configured in all clients.\n');
197
+ console.log('Use --force to reconfigure.\n');
198
+ }
199
+ }
200
+ else {
201
+ console.log(`\nāš ļø Setup completed with ${failed} error(s).\n`);
202
+ console.log('For troubleshooting, visit: https://apiclaw.nordsym.com/docs/setup/troubleshooting\n');
203
+ process.exit(1);
204
+ }
205
+ }
@@ -0,0 +1,188 @@
1
+ /**
2
+ * Uninstall Command
3
+ * Remove APIClaw configuration from MCP clients
4
+ */
5
+ import { existsSync } from 'fs';
6
+ import { getAllClients, getClientConfig, parseClientArg } from '../../utils/paths.js';
7
+ import { readConfig, writeConfig, removeApiclawConfig, hasApiclawConfig } from '../../utils/config.js';
8
+ import { createBackup } from '../../utils/backup.js';
9
+ /**
10
+ * Remove APIClaw from a single client
11
+ */
12
+ export function uninstallFromClient(client, options = {}) {
13
+ const config = getClientConfig(client);
14
+ const configPath = config.configPath;
15
+ const serverName = options.serverName || 'apiclaw';
16
+ // Check if config file exists
17
+ if (!existsSync(configPath)) {
18
+ return {
19
+ success: true,
20
+ client: config.displayName,
21
+ action: 'not-found',
22
+ message: 'Config file not found (client not installed)',
23
+ };
24
+ }
25
+ // Read config
26
+ const readResult = readConfig(configPath);
27
+ if (!readResult.success || !readResult.config) {
28
+ return {
29
+ success: false,
30
+ client: config.displayName,
31
+ action: 'error',
32
+ message: readResult.error || 'Failed to read config',
33
+ };
34
+ }
35
+ // Check if APIClaw is configured
36
+ if (!hasApiclawConfig(readResult.config, serverName)) {
37
+ if (options.force) {
38
+ return {
39
+ success: true,
40
+ client: config.displayName,
41
+ action: 'skipped',
42
+ message: `${serverName} not configured (forced check)`,
43
+ };
44
+ }
45
+ return {
46
+ success: true,
47
+ client: config.displayName,
48
+ action: 'skipped',
49
+ message: `${serverName} not configured`,
50
+ };
51
+ }
52
+ // Dry run - just report what would happen
53
+ if (options.dryRun) {
54
+ return {
55
+ success: true,
56
+ client: config.displayName,
57
+ action: 'skipped',
58
+ message: `Would remove ${serverName} (dry run)`,
59
+ };
60
+ }
61
+ // Create backup before modifying
62
+ let backupPath;
63
+ if (!options.noBackup) {
64
+ const backupResult = createBackup(configPath);
65
+ if (backupResult.success) {
66
+ backupPath = backupResult.backupPath || undefined;
67
+ }
68
+ }
69
+ // Remove APIClaw from config
70
+ const updatedConfig = removeApiclawConfig(readResult.config, serverName);
71
+ // Write updated config (without creating another backup)
72
+ const writeResult = writeConfig(configPath, updatedConfig, false);
73
+ if (!writeResult.success) {
74
+ return {
75
+ success: false,
76
+ client: config.displayName,
77
+ action: 'error',
78
+ message: writeResult.error || 'Failed to write config',
79
+ backupPath,
80
+ };
81
+ }
82
+ return {
83
+ success: true,
84
+ client: config.displayName,
85
+ action: 'removed',
86
+ message: `${serverName} removed`,
87
+ backupPath,
88
+ };
89
+ }
90
+ /**
91
+ * Uninstall from all clients
92
+ */
93
+ export function uninstallFromAll(options = {}) {
94
+ const results = [];
95
+ for (const client of getAllClients()) {
96
+ results.push(uninstallFromClient(client, options));
97
+ }
98
+ return results;
99
+ }
100
+ /**
101
+ * Format uninstall results for display
102
+ */
103
+ export function formatUninstallResults(results) {
104
+ const lines = [];
105
+ lines.push('');
106
+ lines.push('šŸ—‘ļø Uninstall Results');
107
+ lines.push('====================');
108
+ lines.push('');
109
+ const removed = results.filter(r => r.action === 'removed');
110
+ const skipped = results.filter(r => r.action === 'skipped');
111
+ const notFound = results.filter(r => r.action === 'not-found');
112
+ const errors = results.filter(r => r.action === 'error');
113
+ // Show removed
114
+ if (removed.length > 0) {
115
+ lines.push('Removed:');
116
+ for (const result of removed) {
117
+ lines.push(` āœ“ ${result.client}`);
118
+ if (result.backupPath) {
119
+ lines.push(` Backup: ${result.backupPath}`);
120
+ }
121
+ }
122
+ lines.push('');
123
+ }
124
+ // Show skipped
125
+ if (skipped.length > 0) {
126
+ lines.push('Skipped (not configured):');
127
+ for (const result of skipped) {
128
+ lines.push(` ā—‹ ${result.client}`);
129
+ }
130
+ lines.push('');
131
+ }
132
+ // Show not found
133
+ if (notFound.length > 0) {
134
+ lines.push('Not installed:');
135
+ for (const result of notFound) {
136
+ lines.push(` ā—‹ ${result.client}`);
137
+ }
138
+ lines.push('');
139
+ }
140
+ // Show errors
141
+ if (errors.length > 0) {
142
+ lines.push('Errors:');
143
+ for (const result of errors) {
144
+ lines.push(` āœ— ${result.client}: ${result.message}`);
145
+ }
146
+ lines.push('');
147
+ }
148
+ // Summary
149
+ if (removed.length > 0) {
150
+ lines.push(`āœ“ APIClaw removed from ${removed.length} client(s).`);
151
+ lines.push(' Restart your MCP clients for changes to take effect.');
152
+ }
153
+ else if (errors.length === 0) {
154
+ lines.push('No changes made - APIClaw was not configured in any client.');
155
+ }
156
+ lines.push('');
157
+ return lines.join('\n');
158
+ }
159
+ /**
160
+ * Uninstall command handler
161
+ */
162
+ export async function uninstallCommand(options = {}) {
163
+ const serverName = options.serverName || 'apiclaw';
164
+ // Dry run notice
165
+ if (options.dryRun) {
166
+ console.log('\nšŸ” Dry run - no changes will be made\n');
167
+ }
168
+ let results;
169
+ // Uninstall from specific client
170
+ if (options.client) {
171
+ const client = parseClientArg(options.client);
172
+ if (!client) {
173
+ console.error(`\nāœ— Unknown client: ${options.client}\n`);
174
+ console.error('Valid clients: claude, cursor, windsurf, cline, continue\n');
175
+ process.exit(1);
176
+ }
177
+ results = [uninstallFromClient(client, options)];
178
+ }
179
+ else {
180
+ // Uninstall from all clients
181
+ results = uninstallFromAll(options);
182
+ }
183
+ console.log(formatUninstallResults(results));
184
+ const errors = results.filter(r => r.action === 'error');
185
+ if (errors.length > 0) {
186
+ process.exit(1);
187
+ }
188
+ }