@tiny-fish/cli 0.18.1-next.170 → 0.18.1-next.172
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/dist/commands/upgrade.js +3 -0
- package/dist/index.js +2 -51
- package/dist/lib/client.js +3 -3
- package/dist/lib/notice.d.ts +5 -2
- package/dist/lib/notice.js +13 -7
- package/dist/lib/output.d.ts +2 -0
- package/dist/lib/output.js +8 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.js +57 -0
- package/package.json +1 -1
package/dist/commands/upgrade.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import spawn from "cross-spawn";
|
|
2
2
|
import { resolvedApiKey } from "../lib/auth.js";
|
|
3
3
|
import { CLI_VERSION, TINYFISH_CLI_PACKAGE } from "../lib/constants.js";
|
|
4
|
+
import { suppressNotice } from "../lib/notice.js";
|
|
4
5
|
import { errLine } from "../lib/output.js";
|
|
5
6
|
import { sendUpgradeCompleted, telemetryDisabled, } from "../lib/setup-telemetry.js";
|
|
6
7
|
import { installSignalGuard, SIGNAL_EXIT_CODES } from "../lib/signals.js";
|
|
@@ -55,6 +56,8 @@ function installedCliVersion() {
|
|
|
55
56
|
}
|
|
56
57
|
/** `runUpgrade` plus its outcome telemetry, which must never change what the upgrade does. */
|
|
57
58
|
export async function runUpgradeCommand() {
|
|
59
|
+
// This command is the upgrade, so a trailing "an update is available" would be noise.
|
|
60
|
+
suppressNotice();
|
|
58
61
|
let reported = false;
|
|
59
62
|
// Read on the failed path too: a failed skill refresh still leaves an upgraded CLI, so
|
|
60
63
|
// `outcome` reports whether every step ran and `to_version` whether the binary moved.
|
package/dist/index.js
CHANGED
|
@@ -1,55 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { registerAuth } from "./commands/auth.js";
|
|
5
|
-
import { registerBatch } from "./commands/batch.js";
|
|
6
|
-
import { registerFetch } from "./commands/fetch.js";
|
|
7
|
-
import { registerBrowser } from "./commands/browser.js";
|
|
8
|
-
import { registerProfile } from "./commands/profile.js";
|
|
9
|
-
import { registerVault } from "./commands/vault.js";
|
|
10
|
-
import { registerWallet } from "./commands/wallet.js";
|
|
11
|
-
import { registerRun } from "./commands/run.js";
|
|
12
|
-
import { registerRuns } from "./commands/runs.js";
|
|
13
|
-
import { registerConfigureClaude } from "./commands/config-claude.js";
|
|
14
|
-
import { registerSearch } from "./commands/search.js";
|
|
15
|
-
import { registerConnect } from "./commands/connect.js";
|
|
16
|
-
import { registerDoctor } from "./commands/doctor.js";
|
|
17
|
-
import { registerUpgrade } from "./commands/upgrade.js";
|
|
18
|
-
import { registerOnboard } from "./commands/onboard.js";
|
|
19
|
-
const { version } = createRequire(import.meta.url)("../package.json");
|
|
20
|
-
const program = new Command();
|
|
21
|
-
program
|
|
22
|
-
.name("tinyfish")
|
|
23
|
-
.description("TinyFish CLI — run web automations from your terminal or agent.")
|
|
24
|
-
.version(version, "-V, --version", "Show version")
|
|
25
|
-
.helpOption("-h, --help", "Show help")
|
|
26
|
-
.addHelpCommand(false)
|
|
27
|
-
.enablePositionalOptions()
|
|
28
|
-
.option("--debug", "Print HTTP requests and responses to stderr (or set TINYFISH_DEBUG=1)")
|
|
29
|
-
.hook("preAction", (cmd) => {
|
|
30
|
-
if (cmd.opts().debug) {
|
|
31
|
-
process.env["TINYFISH_DEBUG"] = "1";
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
registerAuth(program);
|
|
35
|
-
registerOnboard(program);
|
|
36
|
-
registerConnect(program);
|
|
37
|
-
registerDoctor(program);
|
|
38
|
-
registerUpgrade(program);
|
|
39
|
-
registerConfigureClaude(program);
|
|
40
|
-
registerBrowser(program);
|
|
41
|
-
registerProfile(program);
|
|
42
|
-
registerVault(program);
|
|
43
|
-
registerWallet(program);
|
|
44
|
-
const agentCmd = program
|
|
45
|
-
.command("agent")
|
|
46
|
-
.description("Agent automation commands")
|
|
47
|
-
.enablePositionalOptions();
|
|
48
|
-
const runCmd = registerRun(agentCmd);
|
|
49
|
-
registerRuns(runCmd);
|
|
50
|
-
registerBatch(agentCmd);
|
|
51
|
-
registerSearch(program);
|
|
52
|
-
registerFetch(program);
|
|
2
|
+
import { buildProgram } from "./program.js";
|
|
3
|
+
const { program } = buildProgram();
|
|
53
4
|
// Await parseAsync so async command handlers complete before the process exits
|
|
54
5
|
program.parseAsync(process.argv).catch((e) => {
|
|
55
6
|
process.stderr.write(JSON.stringify({ error: e instanceof Error ? e.message : String(e) }) + "\n");
|
package/dist/lib/client.js
CHANGED
|
@@ -2,7 +2,7 @@ import { APIStatusError, agentRunAsyncResponseSchema, agentRunResponseSchema, ag
|
|
|
2
2
|
import { CONNECT_SOURCE, loadConfig } from "./auth.js";
|
|
3
3
|
import { API_URL_OVERRIDE, CLI_VERSION } from "./constants.js";
|
|
4
4
|
import { detectHarness, detectHumanInitiated } from "./harness.js";
|
|
5
|
-
import {
|
|
5
|
+
import { captureNotice } from "./notice.js";
|
|
6
6
|
import { ApiError } from "./output.js";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
// Install-level connect context (PF-3169). A known caller is credited only to its own
|
|
@@ -73,7 +73,7 @@ class TinyFishCliClient extends TinyFish {
|
|
|
73
73
|
method: "DELETE",
|
|
74
74
|
headers: this._buildHeaders(),
|
|
75
75
|
});
|
|
76
|
-
|
|
76
|
+
captureNotice(response.headers);
|
|
77
77
|
if (!response.ok) {
|
|
78
78
|
let message = response.statusText;
|
|
79
79
|
try {
|
|
@@ -96,7 +96,7 @@ function createSdkClient(apiKey, timeout) {
|
|
|
96
96
|
...(API_URL_OVERRIDE !== undefined ? { baseURL: API_URL_OVERRIDE } : {}),
|
|
97
97
|
maxRetries: 0,
|
|
98
98
|
// Fires per HTTP attempt, but maxRetries is 0 and the notice latches once per invocation.
|
|
99
|
-
onResponse: ({ headers }) =>
|
|
99
|
+
onResponse: ({ headers }) => captureNotice(headers),
|
|
100
100
|
...(timeout !== undefined ? { timeout } : {}),
|
|
101
101
|
});
|
|
102
102
|
}
|
package/dist/lib/notice.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
1
2
|
/** Test-only: the capture slot and the once-per-invocation latch are module state. */
|
|
2
3
|
export declare function resetNoticeState(): void;
|
|
3
4
|
/** Records the first notice seen; printing is deferred so it lands at the end of a command. */
|
|
4
5
|
export declare function captureNotice(headers: Headers): void;
|
|
5
6
|
/** Advisory only, never changes stdout, the exit code, or control flow. */
|
|
6
7
|
export declare function emitNotice(): void;
|
|
7
|
-
/** For
|
|
8
|
-
export declare function
|
|
8
|
+
/** For commands that are the fix themselves, such as `upgrade`, where the nudge is noise. */
|
|
9
|
+
export declare function suppressNotice(): void;
|
|
10
|
+
/** postAction covers clean completions, the exit hook covers the process.exit and rejection paths, the latch keeps it to one. */
|
|
11
|
+
export declare function installNoticeEmit(program: Command): () => void;
|
package/dist/lib/notice.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// Surfaces the advisory X-TF-Notice header the server attaches to outdated clients (PF-3301).
|
|
2
1
|
import { CLI_VERSION } from "./constants.js";
|
|
3
2
|
import { detectHumanInitiated } from "./harness.js";
|
|
4
|
-
import { err,
|
|
3
|
+
import { err, sanitizeLine, warnLine } from "./output.js";
|
|
5
4
|
const NOTICE_HEADER = "x-tf-notice";
|
|
6
5
|
const LEVEL_HEADER = "x-tf-notice-level";
|
|
7
6
|
const MAX_LENGTH = 300;
|
|
@@ -41,13 +40,20 @@ export function emitNotice() {
|
|
|
41
40
|
printed = true;
|
|
42
41
|
const { message, level } = captured;
|
|
43
42
|
if (detectHumanInitiated()) {
|
|
44
|
-
|
|
43
|
+
warnLine(message);
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
47
46
|
err({ notice: agentMessage(level), ...(level ? { level } : {}) });
|
|
48
47
|
}
|
|
49
|
-
/** For
|
|
50
|
-
export function
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
/** For commands that are the fix themselves, such as `upgrade`, where the nudge is noise. */
|
|
49
|
+
export function suppressNotice() {
|
|
50
|
+
captured = undefined;
|
|
51
|
+
printed = true;
|
|
52
|
+
}
|
|
53
|
+
/** postAction covers clean completions, the exit hook covers the process.exit and rejection paths, the latch keeps it to one. */
|
|
54
|
+
export function installNoticeEmit(program) {
|
|
55
|
+
const backstop = () => emitNotice();
|
|
56
|
+
program.hook("postAction", () => emitNotice());
|
|
57
|
+
process.once("exit", backstop);
|
|
58
|
+
return () => process.removeListener("exit", backstop);
|
|
53
59
|
}
|
package/dist/lib/output.d.ts
CHANGED
|
@@ -8,5 +8,7 @@ export declare function out(data: unknown): void;
|
|
|
8
8
|
export declare function sanitizeLine(text: string): string;
|
|
9
9
|
export declare function outLine(line: string): void;
|
|
10
10
|
export declare function errLine(line: string): void;
|
|
11
|
+
/** Advisory stderr line, yellow on a terminal and plain everywhere else so piped output stays clean. */
|
|
12
|
+
export declare function warnLine(line: string): void;
|
|
11
13
|
export declare function err(data: unknown): void;
|
|
12
14
|
export declare function handleApiError(e: unknown): never;
|
package/dist/lib/output.js
CHANGED
|
@@ -23,6 +23,14 @@ export function outLine(line) {
|
|
|
23
23
|
export function errLine(line) {
|
|
24
24
|
process.stderr.write(sanitizeLine(line) + "\n");
|
|
25
25
|
}
|
|
26
|
+
const WARN_ON = "\x1b[33m";
|
|
27
|
+
const WARN_OFF = "\x1b[39m";
|
|
28
|
+
/** Advisory stderr line, yellow on a terminal and plain everywhere else so piped output stays clean. */
|
|
29
|
+
export function warnLine(line) {
|
|
30
|
+
const text = sanitizeLine(line);
|
|
31
|
+
const colour = Boolean(process.stderr.isTTY) && !process.env["NO_COLOR"];
|
|
32
|
+
process.stderr.write(colour ? `${WARN_ON}${text}${WARN_OFF}\n` : `${text}\n`);
|
|
33
|
+
}
|
|
26
34
|
export function err(data) {
|
|
27
35
|
const payload = typeof data === "string" ? { error: data } : data;
|
|
28
36
|
const serialized = JSON.stringify(payload) ?? "undefined";
|
package/dist/program.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createRequire } from "module";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { registerAuth } from "./commands/auth.js";
|
|
4
|
+
import { registerBatch } from "./commands/batch.js";
|
|
5
|
+
import { registerFetch } from "./commands/fetch.js";
|
|
6
|
+
import { registerBrowser } from "./commands/browser.js";
|
|
7
|
+
import { registerProfile } from "./commands/profile.js";
|
|
8
|
+
import { registerVault } from "./commands/vault.js";
|
|
9
|
+
import { registerWallet } from "./commands/wallet.js";
|
|
10
|
+
import { registerRun } from "./commands/run.js";
|
|
11
|
+
import { registerRuns } from "./commands/runs.js";
|
|
12
|
+
import { registerConfigureClaude } from "./commands/config-claude.js";
|
|
13
|
+
import { registerSearch } from "./commands/search.js";
|
|
14
|
+
import { registerConnect } from "./commands/connect.js";
|
|
15
|
+
import { registerDoctor } from "./commands/doctor.js";
|
|
16
|
+
import { registerUpgrade } from "./commands/upgrade.js";
|
|
17
|
+
import { registerOnboard } from "./commands/onboard.js";
|
|
18
|
+
import { installNoticeEmit } from "./lib/notice.js";
|
|
19
|
+
/** Split from index.ts so tests can drive the real program instead of hand-assembling one. */
|
|
20
|
+
export function buildProgram() {
|
|
21
|
+
const { version } = createRequire(import.meta.url)("../package.json");
|
|
22
|
+
const program = new Command();
|
|
23
|
+
program
|
|
24
|
+
.name("tinyfish")
|
|
25
|
+
.description("TinyFish CLI — run web automations from your terminal or agent.")
|
|
26
|
+
.version(version, "-V, --version", "Show version")
|
|
27
|
+
.helpOption("-h, --help", "Show help")
|
|
28
|
+
.addHelpCommand(false)
|
|
29
|
+
.enablePositionalOptions()
|
|
30
|
+
.option("--debug", "Print HTTP requests and responses to stderr (or set TINYFISH_DEBUG=1)")
|
|
31
|
+
.hook("preAction", (cmd) => {
|
|
32
|
+
if (cmd.opts().debug) {
|
|
33
|
+
process.env["TINYFISH_DEBUG"] = "1";
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
registerAuth(program);
|
|
37
|
+
registerOnboard(program);
|
|
38
|
+
registerConnect(program);
|
|
39
|
+
registerDoctor(program);
|
|
40
|
+
registerUpgrade(program);
|
|
41
|
+
registerConfigureClaude(program);
|
|
42
|
+
registerBrowser(program);
|
|
43
|
+
registerProfile(program);
|
|
44
|
+
registerVault(program);
|
|
45
|
+
registerWallet(program);
|
|
46
|
+
const agentCmd = program
|
|
47
|
+
.command("agent")
|
|
48
|
+
.description("Agent automation commands")
|
|
49
|
+
.enablePositionalOptions();
|
|
50
|
+
const runCmd = registerRun(agentCmd);
|
|
51
|
+
registerRuns(runCmd);
|
|
52
|
+
registerBatch(agentCmd);
|
|
53
|
+
registerSearch(program);
|
|
54
|
+
registerFetch(program);
|
|
55
|
+
const uninstallNotice = installNoticeEmit(program);
|
|
56
|
+
return { program, uninstallNotice };
|
|
57
|
+
}
|