@tacitai/mcp-server 0.6.55 → 0.8.0

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 (59) hide show
  1. package/dist/api-errors.d.ts +102 -0
  2. package/dist/api-errors.js +165 -0
  3. package/dist/autonomy.d.ts +46 -0
  4. package/dist/autonomy.js +118 -0
  5. package/dist/claude-config.d.ts +139 -0
  6. package/dist/claude-config.js +339 -0
  7. package/dist/cli-launch.d.ts +33 -0
  8. package/dist/cli-launch.js +178 -0
  9. package/dist/cli-login.d.ts +34 -0
  10. package/dist/cli-login.js +200 -0
  11. package/dist/cli-mode.d.ts +47 -0
  12. package/dist/cli-mode.js +170 -0
  13. package/dist/cli-profiles.d.ts +37 -0
  14. package/dist/cli-profiles.js +344 -0
  15. package/dist/cli.d.ts +9 -0
  16. package/dist/cli.js +59 -458
  17. package/dist/client.d.ts +88 -52
  18. package/dist/client.js +195 -295
  19. package/dist/credentials.d.ts +81 -0
  20. package/dist/credentials.js +291 -0
  21. package/dist/index.d.ts +3 -3
  22. package/dist/index.js +37 -89
  23. package/dist/oauth.d.ts +1 -1
  24. package/dist/oauth.js +5 -5
  25. package/dist/profile-store.d.ts +96 -0
  26. package/dist/profile-store.js +382 -0
  27. package/dist/prompt.d.ts +32 -0
  28. package/dist/prompt.js +99 -0
  29. package/dist/prompts.d.ts +2 -2
  30. package/dist/prompts.js +3 -3
  31. package/dist/server-mode.d.ts +65 -0
  32. package/dist/server-mode.js +99 -0
  33. package/dist/setup-migrate.d.ts +35 -0
  34. package/dist/setup-migrate.js +204 -0
  35. package/dist/setup.d.ts +41 -66
  36. package/dist/setup.js +361 -531
  37. package/dist/signin.d.ts +108 -0
  38. package/dist/signin.js +595 -0
  39. package/dist/tools/agents.d.ts +4 -4
  40. package/dist/tools/artifacts.d.ts +2 -0
  41. package/dist/tools/artifacts.js +8 -1
  42. package/dist/tools/career.js +25 -1
  43. package/dist/tools/errors.d.ts +12 -0
  44. package/dist/tools/errors.js +65 -0
  45. package/dist/tools/exec-route.d.ts +34 -0
  46. package/dist/tools/exec-route.js +101 -27
  47. package/dist/tools/iam.js +2 -3
  48. package/dist/tools/secretary.d.ts +1 -0
  49. package/dist/tools/secretary.js +2 -1
  50. package/dist/tools/synthesize.d.ts +37 -0
  51. package/dist/tools/synthesize.js +126 -7
  52. package/dist/tools/voice.d.ts +3 -2
  53. package/dist/tools/voice.js +70 -18
  54. package/dist/tools/workspaces.js +7 -4
  55. package/dist/version.d.ts +6 -0
  56. package/dist/version.js +18 -0
  57. package/dist/workflow-registry.d.ts +1 -0
  58. package/dist/workflow-registry.js +21 -0
  59. package/package.json +4 -1
package/dist/cli.js CHANGED
@@ -1,470 +1,71 @@
1
1
  #!/usr/bin/env node
2
- import * as fs from 'fs';
3
- import * as path from 'path';
4
- import * as os from 'os';
5
- import * as readline from 'readline';
6
- import { spawn } from 'child_process';
7
- import { deviceAuthFlow, deriveAppUrl, workspaceNameToProfile } from './setup.js';
8
- const PROFILES_DIR = path.join(os.homedir(), '.tacit', 'profiles');
9
- const DEFAULT_FILE = path.join(os.homedir(), '.tacit', 'default');
10
- const PROFILE_REGEX = /^[a-z0-9][a-z0-9-]{0,63}$/;
11
- const RESERVED_NAMES = new Set(['login', 'ls', 'use', 'rm', 'status', 'install', 'help', 'setup', 'version']);
12
- const DEFAULT_API_URL = 'https://api-beta.tacitai.app';
13
- function listV2Profiles() {
14
- if (!fs.existsSync(PROFILES_DIR))
15
- return [];
16
- const files = fs.readdirSync(PROFILES_DIR).filter(f => f.endsWith('.json'));
17
- const profiles = [];
18
- for (const f of files) {
19
- try {
20
- const data = JSON.parse(fs.readFileSync(path.join(PROFILES_DIR, f), 'utf-8'));
21
- if (data.version === 2) {
22
- profiles.push({ name: f.replace(/\.json$/, ''), data: data });
23
- }
24
- }
25
- catch { /* skip corrupt */ }
26
- }
27
- return profiles;
28
- }
29
- function getDefault() {
30
- if (!fs.existsSync(DEFAULT_FILE))
31
- return null;
32
- try {
33
- const name = fs.readFileSync(DEFAULT_FILE, 'utf-8').trim();
34
- return name || null;
35
- }
36
- catch {
37
- return null;
38
- }
39
- }
40
- function setDefault(name) {
41
- const dir = path.dirname(DEFAULT_FILE);
42
- fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
43
- const tmp = DEFAULT_FILE + '.tmp';
44
- fs.writeFileSync(tmp, name + '\n', { mode: 0o600 });
45
- fs.renameSync(tmp, DEFAULT_FILE);
46
- }
47
- function loadProfile(name) {
48
- if (!PROFILE_REGEX.test(name)) {
49
- process.stderr.write(`Invalid profile name '${name}'. Names must match: ${PROFILE_REGEX}\n`);
50
- process.exit(1);
51
- }
52
- const filePath = path.join(PROFILES_DIR, `${name}.json`);
53
- if (!fs.existsSync(filePath)) {
54
- process.stderr.write(`Profile '${name}' not found. Run: npx -p @tacitai/mcp-server tacit ls\n`);
55
- process.exit(1);
56
- }
57
- let data;
58
- try {
59
- data = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
60
- }
61
- catch (err) {
62
- process.stderr.write(`Profile '${name}' is corrupted: ${err instanceof Error ? err.message : ''}. Re-run: tacit login\n`);
63
- process.exit(1);
64
- }
65
- if (data.version !== 2) {
66
- process.stderr.write(`Profile '${name}' was created by setup and lacks credentials. Re-run: npx -p @tacitai/mcp-server tacit login\n`);
67
- process.exit(1);
68
- }
69
- for (const field of ['workspace_id', 'token', 'api_url']) {
70
- if (!data[field] || typeof data[field] !== 'string') {
71
- process.stderr.write(`Profile '${name}' is missing required field '${field}'. Re-run: npx -p @tacitai/mcp-server tacit login\n`);
72
- process.exit(1);
73
- }
74
- }
75
- return data;
76
- }
77
- function writeProfile(name, data) {
78
- fs.mkdirSync(PROFILES_DIR, { recursive: true, mode: 0o700 });
79
- try {
80
- fs.chmodSync(PROFILES_DIR, 0o700);
81
- }
82
- catch { /* unsupported OS */ }
83
- const filePath = path.join(PROFILES_DIR, `${name}.json`);
84
- const tmp = filePath + '.tmp';
85
- fs.writeFileSync(tmp, JSON.stringify(data, null, 2) + '\n', { mode: 0o600 });
86
- fs.renameSync(tmp, filePath);
87
- }
88
- function validateProfileName(name) {
89
- return PROFILE_REGEX.test(name) && !RESERVED_NAMES.has(name);
90
- }
91
- function promptLine(question) {
92
- return new Promise((resolve) => {
93
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
94
- rl.question(question, (answer) => { rl.close(); resolve(answer.trim()); });
95
- });
96
- }
97
- function tryLoadProfile(name) {
98
- if (!PROFILE_REGEX.test(name))
99
- return null;
100
- const filePath = path.join(PROFILES_DIR, `${name}.json`);
101
- try {
102
- if (!fs.existsSync(filePath))
103
- return null;
104
- const data = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
105
- if (data.version !== 2)
106
- return null;
107
- for (const field of ['workspace_id', 'token', 'api_url']) {
108
- if (!data[field] || typeof data[field] !== 'string')
109
- return null;
110
- }
111
- return data;
112
- }
113
- catch {
114
- return null;
115
- }
116
- }
117
- // ─── Subcommands ─────────────────────────────────────────────────────────────
118
- async function cmdLaunch(name, extraArgs) {
119
- const profile = loadProfile(name);
120
- if (profile.expires_at) {
121
- const expiresMs = Date.parse(profile.expires_at);
122
- if (!Number.isNaN(expiresMs) && Date.now() > expiresMs) {
123
- process.stderr.write(`Profile '${name}' token expired ${profile.expires_at}. Re-run: tacit login\n`);
124
- process.exit(1);
125
- }
126
- const daysLeft = Math.floor((expiresMs - Date.now()) / 86400000);
127
- if (daysLeft < 14) {
128
- process.stderr.write(`[TACIT] Token expires in ${daysLeft} day${daysLeft === 1 ? '' : 's'}.\n`);
129
- }
130
- }
131
- const child = spawn('claude', extraArgs, {
132
- stdio: 'inherit',
133
- env: { ...process.env, TACIT_PROFILE: name },
134
- });
135
- const ignore = () => { };
136
- process.on('SIGINT', ignore);
137
- process.on('SIGTERM', ignore);
138
- child.on('error', (err) => {
139
- if (err.code === 'ENOENT') {
140
- process.stderr.write('Claude Code CLI not found. Install: npm i -g @anthropic-ai/claude-code\n');
141
- }
142
- else {
143
- process.stderr.write(`Failed to launch claude: ${err.message}\n`);
144
- }
145
- process.exit(1);
146
- });
147
- child.on('exit', (code) => {
148
- process.exit(code ?? 0);
149
- });
150
- }
151
- async function cmdLogin(args) {
152
- let apiUrl = DEFAULT_API_URL;
153
- let nameOverride = null;
154
- for (let i = 0; i < args.length; i++) {
155
- if (args[i] === '--api-url' && args[i + 1]) {
156
- apiUrl = args[++i];
157
- }
158
- else if (args[i] === '--name' && args[i + 1]) {
159
- nameOverride = args[++i];
160
- }
161
- }
162
- let result;
163
- try {
164
- result = await deviceAuthFlow(apiUrl);
165
- }
166
- catch (err) {
167
- const msg = err instanceof Error ? err.message : String(err);
168
- if (msg.includes('timed out')) {
169
- process.stderr.write('Authentication timed out (120s). Try again or check browser.\n');
170
- }
171
- else if (msg.includes('state mismatch')) {
172
- process.stderr.write('Authentication failed: state mismatch. Try again.\n');
173
- }
174
- else if (msg.includes('EADDRINUSE')) {
175
- process.stderr.write('Port 9123 busy (another login running?). Try again.\n');
176
- }
177
- else {
178
- process.stderr.write(`Authentication failed: ${msg}\n`);
179
- }
180
- process.exit(1);
181
- return;
182
- }
183
- let workspaceId;
184
- let displayName = result.workspaceName;
185
- try {
186
- const resp = await fetch(`${apiUrl}/api/v1/workspaces/mine`, {
187
- headers: { 'Authorization': `Bearer ${result.token}`, 'Accept': 'application/json' },
188
- });
189
- if (resp.status === 401) {
190
- process.stderr.write('Token lacks required claims. The TACIT server may need updating.\n');
191
- process.exit(1);
192
- }
193
- if (!resp.ok) {
194
- throw new Error(`HTTP ${resp.status}`);
195
- }
196
- const data = await resp.json();
197
- workspaceId = data.active_workspace_id;
198
- if (!workspaceId)
199
- throw new Error('No active_workspace_id in response');
200
- if (Array.isArray(data.workspaces)) {
201
- const match = data.workspaces.find(w => w.workspace_id === workspaceId || w.id === workspaceId);
202
- if (match) {
203
- const n = match.display_name ?? match.name;
204
- if (typeof n === 'string')
205
- displayName = n;
206
- }
207
- }
208
- }
209
- catch (err) {
210
- process.stderr.write(`Failed to resolve workspace: ${err instanceof Error ? err.message : String(err)}\n`);
211
- process.exit(1);
212
- return;
213
- }
214
- let profileName;
215
- if (nameOverride) {
216
- profileName = nameOverride;
217
- }
218
- else {
219
- profileName = workspaceNameToProfile(displayName);
220
- }
221
- if (!validateProfileName(profileName)) {
222
- process.stderr.write(`Derived name '${profileName}' is invalid or reserved.\n`);
223
- if (process.stdin.isTTY) {
224
- profileName = await promptLine('Profile name: ');
225
- if (!validateProfileName(profileName)) {
226
- process.stderr.write('Invalid profile name.\n');
227
- process.exit(1);
228
- }
229
- }
230
- else {
231
- process.exit(1);
232
- }
233
- }
234
- const existingPath = path.join(PROFILES_DIR, `${profileName}.json`);
235
- if (fs.existsSync(existingPath)) {
236
- if (process.stdin.isTTY) {
237
- const answer = await promptLine(`Profile '${profileName}' exists. Overwrite? [y/N] `);
238
- if (answer.toLowerCase() !== 'y') {
239
- process.stderr.write('Aborted.\n');
240
- process.exit(1);
241
- }
242
- }
243
- else {
244
- process.stderr.write(`Profile '${profileName}' already exists. Use --name to specify a different name.\n`);
245
- process.exit(1);
246
- }
247
- }
248
- const appUrl = deriveAppUrl(apiUrl);
249
- writeProfile(profileName, {
250
- version: 2,
251
- workspace_id: workspaceId,
252
- workspace_name: displayName,
253
- api_url: apiUrl,
254
- app_url: appUrl,
255
- token: result.token,
256
- created_at: new Date().toISOString(),
257
- expires_at: result.expiresAt,
258
- });
259
- if (!getDefault()) {
260
- setDefault(profileName);
261
- }
262
- process.stdout.write(`\n Profile '${profileName}' created (${displayName}).\n`);
263
- process.stdout.write(` Launch: tacit ${profileName}\n\n`);
264
- }
265
- function cmdLs() {
266
- const profiles = listV2Profiles();
267
- if (profiles.length === 0) {
268
- process.stdout.write('No profiles. Run: npx -p @tacitai/mcp-server tacit login\n');
269
- return;
270
- }
271
- const defaultName = getDefault();
272
- for (const p of profiles) {
273
- const marker = p.name === defaultName ? ' (default)' : '';
274
- const wsName = p.data.workspace_name ?? '';
275
- process.stdout.write(` ${p.name}${marker} — ${wsName} (${p.data.api_url})\n`);
276
- }
277
- }
278
- function cmdUse(name) {
279
- if (!name) {
280
- process.stderr.write('Usage: tacit use <name>\n');
281
- process.exit(1);
282
- }
283
- loadProfile(name);
284
- setDefault(name);
285
- process.stdout.write(`Default profile set to '${name}'.\n`);
286
- }
287
- function cmdRm(name) {
288
- if (!name) {
289
- process.stderr.write('Usage: tacit rm <name>\n');
290
- process.exit(1);
291
- }
292
- if (!PROFILE_REGEX.test(name)) {
293
- process.stderr.write(`Invalid profile name '${name}'.\n`);
294
- process.exit(1);
295
- }
296
- const filePath = path.join(PROFILES_DIR, `${name}.json`);
297
- if (!fs.existsSync(filePath)) {
298
- process.stderr.write(`Profile '${name}' not found.\n`);
299
- process.exit(1);
300
- }
301
- fs.unlinkSync(filePath);
302
- const defaultName = getDefault();
303
- if (defaultName === name) {
304
- try {
305
- fs.unlinkSync(DEFAULT_FILE);
306
- }
307
- catch { /* ok */ }
308
- process.stderr.write('Default profile cleared.\n');
309
- }
310
- process.stdout.write(`Profile '${name}' removed.\n`);
311
- }
312
- function cmdStatus() {
313
- const profileEnv = process.env['TACIT_PROFILE']?.trim();
314
- const wsId = process.env['TACIT_WORKSPACE_ID']?.trim();
315
- const token = process.env['TACIT_TOKEN']?.trim();
316
- const apiUrl = process.env['TACIT_API_URL']?.trim();
317
- const defaultName = getDefault();
318
- process.stdout.write('Resolution chain:\n');
319
- process.stdout.write(` 1. TACIT_PROFILE: ${profileEnv || '(unset)'}\n`);
320
- process.stdout.write(` 2. TACIT_WORKSPACE_ID: ${wsId || '(unset)'}\n`);
321
- process.stdout.write(` TACIT_TOKEN: ${token ? '(set)' : '(unset)'}\n`);
322
- process.stdout.write(` TACIT_API_URL: ${apiUrl || '(unset)'}\n`);
323
- process.stdout.write(` 3. sync.json: ${fs.existsSync('.tacit/sync.json') ? '(present)' : '(absent)'}\n`);
324
- process.stdout.write(` 4. Default profile: ${defaultName || '(unset)'}\n`);
325
- if (profileEnv) {
326
- try {
327
- const p = tryLoadProfile(profileEnv);
328
- if (p) {
329
- process.stdout.write(`\nResolved via TACIT_PROFILE → ${profileEnv}\n`);
330
- process.stdout.write(` Workspace: ${p.workspace_name ?? p.workspace_id}\n`);
331
- process.stdout.write(` API: ${p.api_url}\n`);
332
- }
333
- else {
334
- process.stdout.write(`\nTACIT_PROFILE='${profileEnv}' set but profile not loadable.\n`);
335
- }
336
- }
337
- catch { /* shown in chain */ }
338
- }
339
- else if (wsId && token) {
340
- process.stdout.write('\nResolved via env vars (TACIT_WORKSPACE_ID + TACIT_TOKEN)\n');
341
- }
342
- else if (token && !wsId) {
343
- process.stdout.write('\nTACIT_TOKEN is set but TACIT_WORKSPACE_ID is missing — workspace cannot be resolved.\n');
344
- }
345
- else if (wsId && !token) {
346
- process.stdout.write('\nTACIT_WORKSPACE_ID is set but TACIT_TOKEN is missing — authentication will fail.\n');
347
- }
348
- else if (defaultName) {
349
- const p = tryLoadProfile(defaultName);
350
- if (p) {
351
- process.stdout.write(`\nResolved via default profile → ${defaultName}\n`);
352
- process.stdout.write(` Workspace: ${p.workspace_name ?? p.workspace_id}\n`);
353
- process.stdout.write(` API: ${p.api_url}\n`);
354
- }
355
- else {
356
- process.stdout.write(`\nDefault profile '${defaultName}' not loadable.\n`);
357
- }
358
- }
359
- else {
360
- process.stdout.write('\nNo workspace configured. Run: npx -p @tacitai/mcp-server tacit login\n');
361
- }
362
- }
363
- function cmdInstall() {
364
- const mcpPath = path.join(process.cwd(), '.mcp.json');
365
- let config = {};
366
- if (fs.existsSync(mcpPath)) {
367
- try {
368
- config = JSON.parse(fs.readFileSync(mcpPath, 'utf-8'));
369
- }
370
- catch {
371
- process.stderr.write('Warning: .mcp.json could not be parsed. Creating new.\n');
372
- }
373
- }
374
- const servers = (config.mcpServers ?? {});
375
- servers['tacit'] = {
376
- type: 'stdio',
377
- command: 'npx',
378
- args: ['-y', '@tacitai/mcp-server'],
379
- env: {
380
- TACIT_PROFILE: '${TACIT_PROFILE:-}',
381
- TACIT_MCP_FILE_ROOTS: process.cwd(),
382
- },
383
- };
384
- config.mcpServers = servers;
385
- fs.writeFileSync(mcpPath, JSON.stringify(config, null, 2) + '\n');
386
- process.stdout.write(`Updated ${mcpPath} with generic 'tacit' entry.\n`);
387
- }
388
- async function cmdPicker() {
389
- if (!process.stdin.isTTY) {
390
- process.stderr.write('Usage: tacit <profile-name> | tacit login | tacit ls\n');
391
- process.exit(1);
392
- }
393
- const profiles = listV2Profiles();
394
- if (profiles.length === 0) {
395
- process.stderr.write('No profiles configured. Run: npx -p @tacitai/mcp-server tacit login\n');
396
- process.exit(1);
397
- }
398
- const defaultName = getDefault();
399
- process.stdout.write('\nWorkspaces:\n');
400
- for (let i = 0; i < profiles.length; i++) {
401
- const p = profiles[i];
402
- const marker = p.name === defaultName ? ' *' : '';
403
- process.stdout.write(` ${i + 1}. ${p.data.workspace_name ?? p.name}${marker} (${p.name})\n`);
404
- }
405
- const choice = await promptLine('\nSelect [1]: ');
406
- const idx = (choice ? parseInt(choice, 10) : 1) - 1;
407
- if (idx < 0 || idx >= profiles.length || Number.isNaN(idx)) {
408
- process.stderr.write('Invalid selection.\n');
409
- process.exit(1);
410
- }
411
- await cmdLaunch(profiles[idx].name, []);
412
- }
413
- // ─── Main ────────────────────────────────────────────────────────────────────
414
- async function main() {
415
- const args = process.argv.slice(2);
416
- const cmd = args[0] ?? '';
2
+ /**
3
+ * `tacit` — workspace launcher for Claude Code + TACIT. A thin dispatcher (MV-1542c step 1.6):
4
+ * every command lives in its own module and returns an exit code.
5
+ *
6
+ * cli-launch.ts tacit <name> [claude args...], bare tacit (picker)
7
+ * cli-login.ts tacit login
8
+ * cli-profiles.ts tacit ls | use | status | rm
9
+ * cli-mode.ts tacit mode | install
10
+ */
11
+ import { defaultContext } from './cli-mode.js';
12
+ import { runMode, runInstall } from './cli-mode.js';
13
+ import { launch, pickAndLaunch } from './cli-launch.js';
14
+ import { runLogin } from './cli-login.js';
15
+ import { runLs, runRm, runStatus, runUse } from './cli-profiles.js';
16
+ import { defaultIo } from './setup.js';
17
+ import { readPackageVersion } from './version.js';
18
+ const HELP = [
19
+ 'tacit — workspace launcher for Claude Code + TACIT',
20
+ '',
21
+ 'Commands:',
22
+ ' tacit Pick a workspace and start Claude Code',
23
+ ' tacit <name> [args...] Start Claude Code connected to <name> (args go to claude)',
24
+ ' tacit login Sign in and save a profile (--api-url --app-url --name --no-browser',
25
+ ' --device-label --claude-config-dir --revoke-old)',
26
+ ' tacit ls List saved logins',
27
+ ' tacit use <name> Set the default profile',
28
+ ' tacit status [--offline] Show which login is in use and what the server says about it',
29
+ ' tacit rm <name> [--local-only]',
30
+ ' Sign this login out on the server and remove the profile',
31
+ ' tacit mode [always|on-demand]',
32
+ ' Show or set whether TACIT loads in every Claude Code session',
33
+ ' tacit version Print the installed version',
34
+ ' tacit install Add the generic (token-free) entry to ./.mcp.json',
35
+ '',
36
+ ].join('\n');
37
+ async function main(argv) {
38
+ const ctx = defaultContext();
39
+ const cmd = argv[0] ?? '';
40
+ const rest = argv.slice(1);
417
41
  switch (cmd) {
418
- case 'login':
419
- await cmdLogin(args.slice(1));
420
- break;
421
- case 'ls':
422
- cmdLs();
423
- break;
424
- case 'use':
425
- cmdUse(args[1]);
426
- break;
427
- case 'rm':
428
- cmdRm(args[1]);
429
- break;
430
- case 'status':
431
- cmdStatus();
432
- break;
433
- case 'install':
434
- cmdInstall();
435
- break;
42
+ case 'login': return runLogin(rest, ctx);
43
+ case 'ls': return runLs(ctx);
44
+ case 'use': return runUse(rest, ctx);
45
+ case 'rm': return runRm(rest, ctx);
46
+ case 'status': return runStatus(rest, ctx);
47
+ case 'mode': return runMode(rest, ctx);
48
+ case 'install': return runInstall(ctx);
49
+ case 'version':
50
+ case '--version':
51
+ case '-v':
52
+ ctx.out(readPackageVersion());
53
+ return 0;
436
54
  case 'help':
437
55
  case '--help':
438
56
  case '-h':
439
- process.stdout.write([
440
- 'tacit — workspace launcher for Claude Code + TACIT',
441
- '',
442
- 'Commands:',
443
- ' tacit Interactive workspace picker',
444
- ' tacit <name> Launch Claude Code connected to <name>',
445
- ' tacit login Authenticate and create a profile',
446
- ' tacit ls List workspace profiles',
447
- ' tacit use <name> Set the default profile',
448
- ' tacit rm <name> Remove a profile',
449
- ' tacit status Show connection info',
450
- ' tacit install Add generic entry to .mcp.json',
451
- '',
452
- ].join('\n'));
453
- break;
454
- case '':
455
- await cmdPicker();
456
- break;
57
+ process.stdout.write(HELP);
58
+ return 0;
59
+ case '': return pickAndLaunch(ctx, defaultIo());
457
60
  default:
458
- if (!cmd.startsWith('-')) {
459
- await cmdLaunch(cmd, args.slice(1));
460
- }
461
- else {
462
- process.stderr.write(`Unknown command: ${cmd}\nRun: tacit help\n`);
463
- process.exit(1);
61
+ if (cmd.startsWith('-')) {
62
+ ctx.err(`Unknown command: ${cmd}\nRun: tacit help`);
63
+ return 1;
464
64
  }
65
+ return launch(cmd, rest, ctx);
465
66
  }
466
67
  }
467
- main().catch((err) => {
68
+ main(process.argv.slice(2)).then((code) => { process.exit(code); }, (err) => {
468
69
  process.stderr.write(`tacit: ${err instanceof Error ? err.message : String(err)}\n`);
469
70
  process.exit(1);
470
71
  });