@tiny-fish/cli 0.41.2-next.328 → 0.41.2-next.329

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/README.md CHANGED
@@ -97,6 +97,18 @@ Hermes completes OAuth while adding the MCP server. `hermes mcp add` accepts no
97
97
  interactively. After setup, the command starts the walkthrough in a Hermes session and leaves that
98
98
  session open for your replies.
99
99
 
100
+ ### Connect Command Code
101
+
102
+ Register TinyFish user-wide with your API key:
103
+
104
+ ```bash
105
+ npx -y @tiny-fish/cli@latest connect command-code --api-key sk-tinyfish-...
106
+ ```
107
+
108
+ Command Code takes an API key only. `cmd mcp add` opens a browser sign-in even when a header is
109
+ passed, so TinyFish registers through `mcp add-json`, which writes `~/.commandcode/mcp.json`
110
+ without an auth probe. Without a key the command refuses rather than falling back to a sign-in.
111
+
100
112
  ### Connect OpenClaw
101
113
 
102
114
  Install the TinyFish skill, sign in with an API key, and start an interactive walkthrough with one
@@ -836,7 +836,7 @@ export function registerConnect(program) {
836
836
  program
837
837
  .command('connect')
838
838
  .description('Connect TinyFish to an AI agent')
839
- .argument('[client]', 'Agent client to connect (claude-code, codex, cursor, grok, hermes, omp, openclaw, or opencode); omit to pick from the agents detected on this machine')
839
+ .argument('[client]', `Agent client to connect (${ALL_HARNESSES.join(', ')}); omit to pick from the agents detected on this machine`)
840
840
  .option('--all', 'Detect and connect every supported harness found on this machine')
841
841
  .option('--dry-run', 'Print planned writes per harness without touching anything (--all only)')
842
842
  .option('--uninstall', 'Remove TinyFish entries written by connect --all')
@@ -0,0 +1,3 @@
1
+ import { type McpJsonServerEntry } from './mcp-json-config.js';
2
+ /** Reports the header's shape, never its value. */
3
+ export declare function readCommandCodeTinyfishEntry(): McpJsonServerEntry;
@@ -0,0 +1,14 @@
1
+ import * as os from 'os';
2
+ import * as path from 'path';
3
+ import { readTinyfishEntry, } from './mcp-json-config.js';
4
+ // Read-only: Command Code writes this file itself, through `cmd mcp add-json --scope user`.
5
+ const COMMAND_CODE_TARGET = {
6
+ serverKey: 'tinyfish',
7
+ dir: () => path.join(os.homedir(), '.commandcode'),
8
+ file: () => path.join(os.homedir(), '.commandcode', 'mcp.json'),
9
+ keyHeader: { name: 'Authorization', valuePrefix: 'Bearer ' },
10
+ };
11
+ /** Reports the header's shape, never its value. */
12
+ export function readCommandCodeTinyfishEntry() {
13
+ return readTinyfishEntry(COMMAND_CODE_TARGET);
14
+ }
@@ -99,7 +99,7 @@ export declare function hermesRegistrationEnabled(home: string): {
99
99
  };
100
100
  export declare const NATIVE_MCP_CLIENTS: readonly NativeMcpClient[];
101
101
  /** Native descriptor by harness id; Cursor and OpenClaw have none. */
102
- export declare const NATIVE_BY_HARNESS: Map<"openclaw" | "omp" | "grok" | "cursor" | "codex" | "hermes" | "opencode" | "pi" | "claude-code", NativeMcpClient>;
102
+ export declare const NATIVE_BY_HARNESS: Map<"openclaw" | "omp" | "grok" | "cursor" | "codex" | "hermes" | "command-code" | "opencode" | "pi" | "claude-code", NativeMcpClient>;
103
103
  export declare const OPENCLAW: SupportedCommand;
104
104
  /** "printed" = handed to the user to paste; the walkthrough was never started for them. */
105
105
  export type WalkthroughOutcome = 'launched' | 'printed';
@@ -206,8 +206,21 @@ function specAddArgs(spec, mcpUrl) {
206
206
  ? ['mcp', 'add', ...flags, 'tinyfish', mcpUrl]
207
207
  : ['mcp', 'add', 'tinyfish', '--url', mcpUrl, ...flags];
208
208
  }
209
+ /** `mcp add` probes the server and runs OAuth; add-json only writes config. */
210
+ function jsonAddArgs(spec, mcpUrl, apiKey) {
211
+ const { header } = spec;
212
+ const body = {
213
+ transport: 'http',
214
+ url: mcpUrl,
215
+ ...(header ? { headers: { [header.name]: `${header.valuePrefix ?? ''}${apiKey}` } } : {}),
216
+ };
217
+ return ['mcp', 'add-json', ...(spec.keyedAddJsonFlags ?? []), 'tinyfish', JSON.stringify(body)];
218
+ }
209
219
  function specKeyAuth(spec) {
210
220
  const { header, keyEnvFlag, keyAddFlags } = spec;
221
+ if (spec.keyedAddJsonFlags) {
222
+ return { addArgs: (mcpUrl, apiKey) => jsonAddArgs(spec, mcpUrl, apiKey) };
223
+ }
211
224
  if (keyEnvFlag) {
212
225
  return {
213
226
  envVar: TINYFISH_API_KEY_VAR,
@@ -30,6 +30,7 @@ declare const doctorCheckSchema: z.ZodObject<{
30
30
  cursor: "cursor";
31
31
  codex: "codex";
32
32
  hermes: "hermes";
33
+ "command-code": "command-code";
33
34
  opencode: "opencode";
34
35
  pi: "pi";
35
36
  "claude-code": "claude-code";
@@ -48,6 +49,7 @@ declare const doctorHarnessSchema: z.ZodObject<{
48
49
  cursor: "cursor";
49
50
  codex: "codex";
50
51
  hermes: "hermes";
52
+ "command-code": "command-code";
51
53
  opencode: "opencode";
52
54
  pi: "pi";
53
55
  "claude-code": "claude-code";
@@ -75,6 +77,7 @@ declare const doctorRepairSchema: z.ZodObject<{
75
77
  cursor: "cursor";
76
78
  codex: "codex";
77
79
  hermes: "hermes";
80
+ "command-code": "command-code";
78
81
  opencode: "opencode";
79
82
  pi: "pi";
80
83
  "claude-code": "claude-code";
@@ -104,6 +107,7 @@ export declare const doctorReportSchema: z.ZodObject<{
104
107
  cursor: "cursor";
105
108
  codex: "codex";
106
109
  hermes: "hermes";
110
+ "command-code": "command-code";
107
111
  opencode: "opencode";
108
112
  pi: "pi";
109
113
  "claude-code": "claude-code";
@@ -122,6 +126,7 @@ export declare const doctorReportSchema: z.ZodObject<{
122
126
  cursor: "cursor";
123
127
  codex: "codex";
124
128
  hermes: "hermes";
129
+ "command-code": "command-code";
125
130
  opencode: "opencode";
126
131
  pi: "pi";
127
132
  "claude-code": "claude-code";
@@ -149,6 +154,7 @@ export declare const doctorReportSchema: z.ZodObject<{
149
154
  cursor: "cursor";
150
155
  codex: "codex";
151
156
  hermes: "hermes";
157
+ "command-code": "command-code";
152
158
  opencode: "opencode";
153
159
  pi: "pi";
154
160
  "claude-code": "claude-code";
@@ -44,6 +44,8 @@ export interface HarnessSpec {
44
44
  keyEnvFlag?: string;
45
45
  /** Keyed adds append these flags; the key itself is seeded elsewhere (Hermes). */
46
46
  keyAddFlags?: string[];
47
+ /** Keyed adds go through `mcp add-json`, which takes the URL and header in its body. */
48
+ keyedAddJsonFlags?: string[];
47
49
  /** No sign-in exists here, so connect refuses a keyless install (Hermes). */
48
50
  keyRequired?: true;
49
51
  loginArgs?: string[];
@@ -133,6 +135,29 @@ export declare const HARNESS_SPECS: {
133
135
  loginArgs: string[];
134
136
  authDeferredAtInstall: true;
135
137
  };
138
+ 'command-code': {
139
+ command: string;
140
+ displayName: string;
141
+ configDir: string;
142
+ reloadAction: string;
143
+ supportCheck: {
144
+ args: string[];
145
+ patterns: RegExp[];
146
+ timeoutMs: number;
147
+ unavailableMessage: string;
148
+ };
149
+ keyRequired: true;
150
+ header: {
151
+ name: string;
152
+ sep: ": ";
153
+ valuePrefix: string;
154
+ };
155
+ keyedAddJsonFlags: string[];
156
+ removals: {
157
+ args: string[];
158
+ label: string;
159
+ }[];
160
+ };
136
161
  cursor: {
137
162
  command: string;
138
163
  displayName: string;
@@ -253,7 +278,7 @@ export declare const ALL_HARNESSES: readonly Harness[];
253
278
  export declare function harnessSpec(harness: Harness): HarnessSpec;
254
279
  /** The rest of the union: every one of these must supply a connect and launch override. */
255
280
  export type NonNativeHarness = {
256
- [K in Harness]: 'urlStyle' extends keyof (typeof HARNESS_SPECS)[K] ? never : K;
281
+ [K in Harness]: 'urlStyle' extends keyof (typeof HARNESS_SPECS)[K] ? never : 'keyRequired' extends keyof (typeof HARNESS_SPECS)[K] ? never : K;
257
282
  }[Harness];
258
- /** Native MCP harnesses carry add-generation fields; the rest override connect. */
259
- export declare const NATIVE_HARNESSES: ("openclaw" | "omp" | "grok" | "cursor" | "codex" | "hermes" | "opencode" | "pi" | "claude-code")[];
283
+ /** Native MCP harnesses generate an add; key-only ones generate only the keyed form. */
284
+ export declare const NATIVE_HARNESSES: ("openclaw" | "omp" | "grok" | "cursor" | "codex" | "hermes" | "command-code" | "opencode" | "pi" | "claude-code")[];
@@ -46,7 +46,11 @@ const OPENCODE_MODEL_NOTE = 'Note: TinyFish runs on tool calls, so OpenCode need
46
46
  'models (e.g. Nano Banana Pro) will show "No endpoints found that support tool use" — switch ' +
47
47
  "OpenCode's model if the walkthrough can't start.";
48
48
  const HERMES_RESTART_NOTE = 'Restart your Hermes session to pick up TinyFish — Hermes discovers MCP servers at startup.';
49
+ const COMMAND_CODE_ADD_JSON_UNAVAILABLE_MESSAGE = 'Could not confirm this Command Code installation supports keyed MCP setup: `commandcode mcp ' +
50
+ '--help` did not list `add-json`. Run `commandcode update` and retry.' +
51
+ SUPPORT_CHECK_DEBUG_HINT;
49
52
  const HEADER_FLAG = /(?:^|\s)--header(?:[\s<=]|$)/m;
53
+ const ADD_JSON_COMMAND = /^\s*add-json(?:\s|\[)/m;
50
54
  /** One entry per harness; every per-harness list derives from it. */
51
55
  export const HARNESS_SPECS = {
52
56
  'claude-code': {
@@ -108,6 +112,32 @@ export const HARNESS_SPECS = {
108
112
  // TODO(PF-3580): connect now probes Codex sign-in, so this over-warns a signed-in install.
109
113
  authDeferredAtInstall: true,
110
114
  },
115
+ 'command-code': {
116
+ // Same package ships `cmd`, but that is cmd.exe on Windows; this alias collides with nothing.
117
+ command: 'commandcode',
118
+ displayName: 'Command Code',
119
+ configDir: '.commandcode',
120
+ reloadAction: 'restart it',
121
+ // add-json is the only command this harness uses, so it is what must exist.
122
+ supportCheck: {
123
+ args: ['mcp', '--help'],
124
+ patterns: [ADD_JSON_COMMAND],
125
+ // Command Code self-updates inside the probe, which outlasts the default budget.
126
+ timeoutMs: 30_000,
127
+ unavailableMessage: COMMAND_CODE_ADD_JSON_UNAVAILABLE_MESSAGE,
128
+ },
129
+ // Key-only: `cmd mcp add` runs browser OAuth even when a header is supplied.
130
+ keyRequired: true,
131
+ header: { name: 'Authorization', sep: ': ', valuePrefix: 'Bearer ' },
132
+ // Default scope is `local`, which writes a per-project entry instead of the user's.
133
+ keyedAddJsonFlags: ['--scope', 'user'],
134
+ removals: [
135
+ {
136
+ args: ['mcp', 'remove', 'tinyfish', '--scope', 'user'],
137
+ label: 'user TinyFish registration',
138
+ },
139
+ ],
140
+ },
111
141
  cursor: {
112
142
  command: 'cursor-agent',
113
143
  displayName: 'Cursor',
@@ -228,5 +258,8 @@ export const ALL_HARNESSES = Object.keys(HARNESS_SPECS);
228
258
  export function harnessSpec(harness) {
229
259
  return HARNESS_SPECS[harness];
230
260
  }
231
- /** Native MCP harnesses carry add-generation fields; the rest override connect. */
232
- export const NATIVE_HARNESSES = ALL_HARNESSES.filter((harness) => harnessSpec(harness).urlStyle !== undefined);
261
+ /** Native MCP harnesses generate an add; key-only ones generate only the keyed form. */
262
+ export const NATIVE_HARNESSES = ALL_HARNESSES.filter((harness) => {
263
+ const spec = harnessSpec(harness);
264
+ return spec.urlStyle !== undefined || spec.keyRequired === true;
265
+ });
@@ -26,6 +26,8 @@ const HARNESS_FINGERPRINTS = [
26
26
  // prefix so we catch a Codex run regardless of which of its vars are set.
27
27
  { name: 'codex', matches: (env) => hasVarWithPrefix(env, 'CODEX_') },
28
28
  { name: 'hermes', matches: (env) => hasVarWithPrefix(env, 'HERMES_') },
29
+ // COMMANDCODE_SCRATCHPAD lands on every child; a disabled scratchpad leaves no marker.
30
+ { name: 'command-code', matches: (env) => hasVarWithPrefix(env, 'COMMANDCODE_') },
29
31
  // Exact key, not a prefix: opencode writes OPENCODE=1 at startup, reads every OPENCODE_* as config.
30
32
  { name: 'opencode', matches: (env) => Boolean(env['OPENCODE']) },
31
33
  // Observed: pi launched from Claude Code inherits CLAUDECODE=1.
@@ -3,6 +3,11 @@ export interface McpJsonTarget {
3
3
  /** Functions so paths resolve at call time. */
4
4
  dir(): string;
5
5
  file(): string;
6
+ /** Read-side only; defaults to what the write path emits (Command Code writes its own). */
7
+ keyHeader?: {
8
+ name: string;
9
+ valuePrefix?: string;
10
+ };
6
11
  }
7
12
  export interface McpJsonWriteResult {
8
13
  status: 'written' | 'unchanged' | 'corrupt_skip';
@@ -17,6 +22,8 @@ export declare function planWrite(target: McpJsonTarget, mcpUrl: string, apiKey?
17
22
  export interface McpJsonServerEntry {
18
23
  present: boolean;
19
24
  hasApiKeyHeader: boolean;
25
+ /** Only ever false: harnesses with a disable toggle write it, the rest omit it. */
26
+ enabled?: false;
20
27
  /** Registered endpoint, so a caller can tell "registered" from "registered at the right place". */
21
28
  url?: string;
22
29
  keyMatchesCliKey?: boolean;
@@ -67,21 +67,31 @@ export function readTinyfishEntry(target) {
67
67
  const entry = isPlainRecord(servers) ? servers[target.serverKey] : undefined;
68
68
  if (!isPlainRecord(entry))
69
69
  return { present: false, hasApiKeyHeader: false };
70
- const headers = entry.headers;
71
- // Header names are case-insensitive, and this file is hand-editable — matching only the
72
- // casing we write would understate auth mode for a user who typed it differently.
73
- const keyHeader = isPlainRecord(headers)
74
- ? Object.entries(headers).find((entry) => entry[0].toLowerCase() === 'x-api-key' && typeof entry[1] === 'string')
75
- : undefined;
76
- const templateVar = keyHeader ? ENV_TEMPLATE_VALUE.exec(keyHeader[1])?.[1] : undefined;
70
+ const key = readKeyHeader(entry.headers, target.keyHeader);
71
+ const templateVar = key ? ENV_TEMPLATE_VALUE.exec(key.value)?.[1] : undefined;
77
72
  return {
78
73
  present: true,
79
- hasApiKeyHeader: keyHeader !== undefined,
80
- ...(matchesCliKey(keyHeader?.[1]) ? { keyMatchesCliKey: true } : {}),
74
+ hasApiKeyHeader: key !== undefined,
75
+ ...(entry.enabled === false ? { enabled: false } : {}),
76
+ ...(matchesCliKey(key?.value) ? { keyMatchesCliKey: true } : {}),
81
77
  ...(templateVar ? { keyTemplateVar: templateVar } : {}),
82
78
  ...(typeof entry.url === 'string' ? { url: entry.url } : {}),
83
79
  };
84
80
  }
81
+ /** Reports the key header's shape, never its value. */
82
+ function readKeyHeader(headers, keyHeader) {
83
+ const { name = 'x-api-key', valuePrefix = '' } = keyHeader ?? {};
84
+ // Header names are case-insensitive, and this file is hand-editable — matching only the
85
+ // casing we write would understate auth mode for a user who typed it differently.
86
+ const found = isPlainRecord(headers)
87
+ ? Object.entries(headers).find((entry) => entry[0].toLowerCase() === name.toLowerCase() && typeof entry[1] === 'string')
88
+ : undefined;
89
+ if (!found)
90
+ return undefined;
91
+ // The scheme is case-insensitive too, and a hand-edited header may omit it entirely.
92
+ const hasPrefix = found[1].toLowerCase().startsWith(valuePrefix.toLowerCase());
93
+ return { value: hasPrefix ? found[1].slice(valuePrefix.length) : found[1] };
94
+ }
85
95
  // Backup, then atomic temp+rename; pid avoids same-millisecond backup collisions.
86
96
  function commitServers(target, existing, servers) {
87
97
  const filePath = target.file();
@@ -6,6 +6,7 @@ import { loadConfig, matchesCliKey } from './auth.js';
6
6
  import { NATIVE_BY_HARNESS } from './connect-clients.js';
7
7
  import { HARNESS_PROBE_TIMEOUT_MS } from './constants.js';
8
8
  import { errLine } from './output.js';
9
+ import { readCommandCodeTinyfishEntry } from './command-code-config.js';
9
10
  import { readCursorTinyfishEntry } from './cursor-config.js';
10
11
  import { readOmpTinyfishEntry } from './omp-config.js';
11
12
  import { readPiTinyfishEntry } from './pi-config.js';
@@ -278,6 +279,22 @@ function probeCodex() {
278
279
  ...(envVar ? envKeyVerdict(envVar) : {}),
279
280
  };
280
281
  }
282
+ function probeCommandCode() {
283
+ const entry = readCommandCodeTinyfishEntry();
284
+ if (entry.error)
285
+ return unverified('mcp.json exists but could not be read or parsed');
286
+ if (!entry.present)
287
+ return NOT_REGISTERED;
288
+ // The /mcp toggle disables an entry in place, and Command Code then ignores it.
289
+ return {
290
+ registered: Registered.Yes,
291
+ authMode: entry.hasApiKeyHeader ? AuthMode.ApiKey : AuthMode.Unknown,
292
+ // connect only ever writes a keyed entry here, so a headerless one was not written by us.
293
+ ...(entry.enabled === false ? { connected: false } : {}),
294
+ ...(entry.url ? { registeredUrl: entry.url } : {}),
295
+ ...(entry.keyMatchesCliKey ? { keyMatchesCliKey: true } : {}),
296
+ };
297
+ }
281
298
  function probeCursor() {
282
299
  const entry = readCursorTinyfishEntry();
283
300
  if (entry.error) {
@@ -499,6 +516,7 @@ function probeGrok() {
499
516
  const PROBES = {
500
517
  'claude-code': () => fromMcpGet('claude'),
501
518
  codex: probeCodex,
519
+ 'command-code': probeCommandCode,
502
520
  cursor: probeCursor,
503
521
  grok: probeGrok,
504
522
  hermes: probeHermes,
@@ -28,6 +28,7 @@ declare const harnessResultSchema: z.ZodObject<{
28
28
  cursor: "cursor";
29
29
  codex: "codex";
30
30
  hermes: "hermes";
31
+ "command-code": "command-code";
31
32
  opencode: "opencode";
32
33
  pi: "pi";
33
34
  "claude-code": "claude-code";
@@ -63,6 +64,7 @@ export declare const setupCompletedPayloadSchema: z.ZodObject<{
63
64
  cursor: "cursor";
64
65
  codex: "codex";
65
66
  hermes: "hermes";
67
+ "command-code": "command-code";
66
68
  opencode: "opencode";
67
69
  pi: "pi";
68
70
  "claude-code": "claude-code";
@@ -125,6 +127,7 @@ declare const doctorCompletedPayloadSchema: z.ZodObject<{
125
127
  cursor: "cursor";
126
128
  codex: "codex";
127
129
  hermes: "hermes";
130
+ "command-code": "command-code";
128
131
  opencode: "opencode";
129
132
  pi: "pi";
130
133
  "claude-code": "claude-code";
@@ -139,6 +142,7 @@ declare const doctorCompletedPayloadSchema: z.ZodObject<{
139
142
  cursor: "cursor";
140
143
  codex: "codex";
141
144
  hermes: "hermes";
145
+ "command-code": "command-code";
142
146
  opencode: "opencode";
143
147
  pi: "pi";
144
148
  "claude-code": "claude-code";
@@ -151,6 +155,7 @@ declare const doctorCompletedPayloadSchema: z.ZodObject<{
151
155
  cursor: "cursor";
152
156
  codex: "codex";
153
157
  hermes: "hermes";
158
+ "command-code": "command-code";
154
159
  opencode: "opencode";
155
160
  pi: "pi";
156
161
  "claude-code": "claude-code";
@@ -187,6 +192,7 @@ declare const doctorCouldNotRunPayloadSchema: z.ZodObject<{
187
192
  cursor: "cursor";
188
193
  codex: "codex";
189
194
  hermes: "hermes";
195
+ "command-code": "command-code";
190
196
  opencode: "opencode";
191
197
  pi: "pi";
192
198
  "claude-code": "claude-code";
@@ -224,6 +230,7 @@ declare const doctorPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
224
230
  cursor: "cursor";
225
231
  codex: "codex";
226
232
  hermes: "hermes";
233
+ "command-code": "command-code";
227
234
  opencode: "opencode";
228
235
  pi: "pi";
229
236
  "claude-code": "claude-code";
@@ -238,6 +245,7 @@ declare const doctorPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
238
245
  cursor: "cursor";
239
246
  codex: "codex";
240
247
  hermes: "hermes";
248
+ "command-code": "command-code";
241
249
  opencode: "opencode";
242
250
  pi: "pi";
243
251
  "claude-code": "claude-code";
@@ -250,6 +258,7 @@ declare const doctorPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
250
258
  cursor: "cursor";
251
259
  codex: "codex";
252
260
  hermes: "hermes";
261
+ "command-code": "command-code";
253
262
  opencode: "opencode";
254
263
  pi: "pi";
255
264
  "claude-code": "claude-code";
@@ -285,6 +294,7 @@ declare const doctorPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
285
294
  cursor: "cursor";
286
295
  codex: "codex";
287
296
  hermes: "hermes";
297
+ "command-code": "command-code";
288
298
  opencode: "opencode";
289
299
  pi: "pi";
290
300
  "claude-code": "claude-code";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiny-fish/cli",
3
- "version": "0.41.2-next.328",
3
+ "version": "0.41.2-next.329",
4
4
  "description": "TinyFish CLI — run web automations from your terminal",
5
5
  "type": "module",
6
6
  "bin": {