@crawl82/cli 0.0.0-stage → 0.5.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 (53) hide show
  1. package/AGENTS.md +257 -0
  2. package/README.md +120 -2
  3. package/dist/api-types.generated.js +12 -0
  4. package/dist/api-types.generated.js.map +1 -0
  5. package/dist/commands/api.js +111 -0
  6. package/dist/commands/api.js.map +1 -0
  7. package/dist/commands/auth.js +284 -0
  8. package/dist/commands/auth.js.map +1 -0
  9. package/dist/commands/completion.js +120 -0
  10. package/dist/commands/completion.js.map +1 -0
  11. package/dist/commands/doctor.js +141 -0
  12. package/dist/commands/doctor.js.map +1 -0
  13. package/dist/commands/feedback.js +39 -0
  14. package/dist/commands/feedback.js.map +1 -0
  15. package/dist/commands/help-json.js +144 -0
  16. package/dist/commands/help-json.js.map +1 -0
  17. package/dist/commands/mcp.js +129 -0
  18. package/dist/commands/mcp.js.map +1 -0
  19. package/dist/commands/read.js +107 -0
  20. package/dist/commands/read.js.map +1 -0
  21. package/dist/commands/sites.js +604 -0
  22. package/dist/commands/sites.js.map +1 -0
  23. package/dist/credentials.js +151 -0
  24. package/dist/credentials.js.map +1 -0
  25. package/dist/errors.js +150 -0
  26. package/dist/errors.js.map +1 -0
  27. package/dist/exit-codes.js +82 -0
  28. package/dist/exit-codes.js.map +1 -0
  29. package/dist/http.js +260 -0
  30. package/dist/http.js.map +1 -0
  31. package/dist/index.js +158 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/keychain.js +185 -0
  34. package/dist/keychain.js.map +1 -0
  35. package/dist/oauth/browser.js +33 -0
  36. package/dist/oauth/browser.js.map +1 -0
  37. package/dist/oauth/pkce.js +118 -0
  38. package/dist/oauth/pkce.js.map +1 -0
  39. package/dist/oauth/server.js +281 -0
  40. package/dist/oauth/server.js.map +1 -0
  41. package/dist/operations.generated.js +6290 -0
  42. package/dist/operations.generated.js.map +1 -0
  43. package/dist/output.js +161 -0
  44. package/dist/output.js.map +1 -0
  45. package/dist/refresh-lock.js +84 -0
  46. package/dist/refresh-lock.js.map +1 -0
  47. package/dist/run.js +186 -0
  48. package/dist/run.js.map +1 -0
  49. package/dist/session.js +147 -0
  50. package/dist/session.js.map +1 -0
  51. package/dist/version.js +34 -0
  52. package/dist/version.js.map +1 -0
  53. package/package.json +47 -4
@@ -0,0 +1,144 @@
1
+ /**
2
+ * `crawl82 help --json` — the whole command surface as machine-readable JSON.
3
+ *
4
+ * `AGENTS.md` is prose an agent has to be given; this is discoverable at
5
+ * runtime and cannot go stale, because it is generated from the same commander
6
+ * tree that actually runs.
7
+ */
8
+ import { API_OPERATIONS, API_COMPONENTS } from "../operations.generated.js";
9
+ import { usageError } from "../errors.js";
10
+ import { EXIT } from "../exit-codes.js";
11
+ import { VERSION } from "../version.js";
12
+ export function registerHelpJson(program) {
13
+ program
14
+ .command("help")
15
+ .argument("[command...]", "Show help for a specific command")
16
+ .description("Show help; --json dumps every command, flag and exit code")
17
+ .option("--json", "Emit the command surface as JSON")
18
+ .option("--operation <id>", "Exact REST contract and surface mapping for an operation")
19
+ .action((commandPath, options, command) => {
20
+ const root = command.parent ?? program;
21
+ if (options.operation) {
22
+ const operation = API_OPERATIONS.find((entry) => entry.operation_id === options.operation);
23
+ if (!operation)
24
+ throw usageError("Unknown operation. Run help --json for the operation index.", "operation");
25
+ process.stdout.write(JSON.stringify({ schema_version: 1, operation, components: API_COMPONENTS }) + "\n");
26
+ return;
27
+ }
28
+ if (commandPath?.length && !findCommand(root, commandPath))
29
+ throw usageError("Unknown command.", "command");
30
+ if (options.json && commandPath?.length) {
31
+ const target = findCommand(root, commandPath);
32
+ process.stdout.write(JSON.stringify({ schema_version: 1, command: describeCommand(target, [root.name(), ...commandPath.slice(0, -1)].join(" ")) }) + "\n");
33
+ return;
34
+ }
35
+ if (!options.json) {
36
+ const target = findCommand(root, commandPath ?? []);
37
+ process.stdout.write(`${(target ?? root).helpInformation()}\n`);
38
+ return;
39
+ }
40
+ process.stdout.write(`${JSON.stringify(buildHelpDocument(root), null, 2)}\n`);
41
+ });
42
+ }
43
+ export function buildHelpDocument(root) {
44
+ return {
45
+ name: "crawl82",
46
+ version: VERSION,
47
+ schema_version: 1,
48
+ operations: API_OPERATIONS.map(({ operation: _operation, ...entry }) => entry),
49
+ description: root.description(),
50
+ api_base_url_env: "CRAWL82_API_URL",
51
+ exit_codes: [
52
+ { code: EXIT.OK, meaning: "Success" },
53
+ { code: EXIT.API_ERROR, meaning: "API or server error, or the request never arrived" },
54
+ { code: EXIT.USAGE, meaning: "Bad usage: wrong flags, missing arguments, invalid input" },
55
+ { code: EXIT.AUTH, meaning: "Authentication or permission failure" },
56
+ { code: EXIT.NOT_FOUND, meaning: "The resource does not exist in this workspace" },
57
+ { code: EXIT.RATE_LIMITED, meaning: "Rate limited; honour Retry-After" },
58
+ { code: EXIT.CONFLICT, meaning: "State conflict, for example a result that is not ready" },
59
+ ],
60
+ environment: [
61
+ { name: "CRAWL82_API_KEY", purpose: "API key. Overrides any stored credential." },
62
+ { name: "CRAWL82_API_URL", purpose: "API base URL. Defaults to https://api.crawl82.com/v1." },
63
+ { name: "CRAWL82_MCP_URL", purpose: "MCP base URL. Defaults to https://mcp.crawl82.com." },
64
+ { name: "CRAWL82_AUTH_URL", purpose: "OAuth authorization server. Defaults to the API origin." },
65
+ { name: "CRAWL82_PROFILE", purpose: "Named credential profile. Same as --profile." },
66
+ { name: "CRAWL82_NO_TUI", purpose: "Any non-empty value forces JSON output." },
67
+ { name: "CRAWL82_NO_KEYCHAIN", purpose: "Any value skips the OS keychain and uses the config file." },
68
+ {
69
+ name: "NO_COLOR",
70
+ purpose: "Standard (no-color.org). Any non-empty value disables colour. It does not change the output format.",
71
+ },
72
+ ],
73
+ /**
74
+ * Which commands can be repeated safely after a failure, and which cannot.
75
+ * An agent deciding whether to try again after exit 1 needs this and cannot
76
+ * infer it from the command name.
77
+ */
78
+ retry_policy: {
79
+ description: "429 is retried for every command. 408 and 5xx are retried only for idempotent requests (RFC 9110 §9.2.2), which here means reads. A write that fails with a 5xx is reported rather than repeated, because it may already have been applied (a crawl started, a recipe run), so re-read the resource before retrying it yourself.",
80
+ never_retried_after_5xx: [
81
+ "crawl82 sites add",
82
+ "crawl82 sites update",
83
+ "crawl82 sites identity-update",
84
+ "crawl82 actions update",
85
+ "crawl82 crawls start",
86
+ "crawl82 crawls cancel",
87
+ "crawl82 recipes run",
88
+ "crawl82 feedback send",
89
+ "crawl82 api POST",
90
+ "crawl82 api PATCH",
91
+ ],
92
+ },
93
+ error_envelope: {
94
+ description: "Every failure is written to stderr as this shape, whether it came from the API or from the CLI itself. request_id is null when the request never reached the server.",
95
+ example: {
96
+ error: {
97
+ type: "not_found_error",
98
+ code: "resource_not_found",
99
+ message: "No site with id '…' in this workspace.",
100
+ docs_url: "https://crawl82.com/docs/api/errors#resource_not_found",
101
+ },
102
+ request_id: "req_01K9X7",
103
+ },
104
+ },
105
+ global_options: describeOptions(root),
106
+ commands: root.commands
107
+ .filter((command) => command.name() !== "help")
108
+ .map((command) => describeCommand(command, "crawl82")),
109
+ };
110
+ }
111
+ function describeCommand(command, prefix) {
112
+ const path = `${prefix} ${command.name()}`;
113
+ return {
114
+ name: command.name(),
115
+ path,
116
+ description: command.description(),
117
+ usage: `${path} ${command.usage()}`.trim(),
118
+ arguments: command.registeredArguments.map((argument) => ({
119
+ name: argument.name(),
120
+ required: argument.required,
121
+ description: argument.description,
122
+ })),
123
+ options: describeOptions(command),
124
+ commands: command.commands.map((child) => describeCommand(child, path)),
125
+ };
126
+ }
127
+ function describeOptions(command) {
128
+ return command.options.map((option) => ({
129
+ flags: option.flags,
130
+ description: option.description,
131
+ ...(option.defaultValue === undefined ? {} : { default: option.defaultValue }),
132
+ }));
133
+ }
134
+ function findCommand(root, segments) {
135
+ let current = root;
136
+ for (const segment of segments) {
137
+ const next = current.commands.find((candidate) => candidate.name() === segment || candidate.aliases().includes(segment));
138
+ if (!next)
139
+ return null;
140
+ current = next;
141
+ }
142
+ return current;
143
+ }
144
+ //# sourceMappingURL=help-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help-json.js","sourceRoot":"","sources":["../../src/commands/help-json.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAYxC,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,QAAQ,CAAC,cAAc,EAAE,kCAAkC,CAAC;SAC5D,WAAW,CAAC,2DAA2D,CAAC;SACxE,MAAM,CAAC,QAAQ,EAAE,kCAAkC,CAAC;SACpD,MAAM,CAAC,kBAAkB,EAAE,0DAA0D,CAAC;SACtF,MAAM,CAAC,CAAC,WAAqB,EAAE,OAAO,EAAE,OAAgB,EAAE,EAAE;QAC3D,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC;QAEvC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;YACtB,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;YAC3F,IAAI,CAAC,SAAS;gBAAE,MAAM,UAAU,CAAC,6DAA6D,EAAE,WAAW,CAAC,CAAC;YAC7G,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YAC1G,OAAO;QACT,CAAC;QACD,IAAI,WAAW,EAAE,MAAM,IAAI,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C,WAAW;SAClC,CAAC,CAAC;QACH,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC;QACjC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;KACxE,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,OAAgB;IACvC,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC;QAC9C,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,GAAG,CAAC,MAAM,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC;KAC/E,CAAC,CAAC,CAAC;AACN,CAAC;AAED,SAAS,WAAW,CAAC,IAAa,EAAE,QAAkB;IACpD,IAAI,OAAO,GAAY,IAAI,CAAC;IAC5B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAChC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,OAAO,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CACrF,CAAC;QACF,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QACvB,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * `crawl82 mcp` — a stdio-to-HTTP MCP bridge.
3
+ *
4
+ * The Crawl82 MCP server speaks Streamable HTTP; the legacy HTTP+SSE transport
5
+ * is deprecated by the specification and deliberately not implemented on the
6
+ * server. Some clients still only launch a subprocess and talk newline-delimited
7
+ * JSON-RPC over stdin/stdout. This bridge is how those clients reach the remote
8
+ * server without us maintaining a transport the spec has retired.
9
+ *
10
+ * It is intentionally dumb: it does not interpret MCP semantics, only frames
11
+ * and forwards. The two headers it does set — `Mcp-Method` and `Mcp-Name` — are
12
+ * part of the 2026-07-28 spec and let the edge rate-limiter treat
13
+ * `start_crawl` differently from `list_sites` without parsing a body.
14
+ */
15
+ import readline from "node:readline";
16
+ import { run } from "../run.js";
17
+ import { USER_AGENT } from "../version.js";
18
+ export function registerMcp(program) {
19
+ program
20
+ .command("mcp")
21
+ .description("Run a stdio↔HTTP bridge to the Crawl82 MCP server")
22
+ .action(async (_options, command) => {
23
+ await run(command, async (session) => bridge(session));
24
+ });
25
+ }
26
+ export async function bridge(session) {
27
+ const endpoint = `${session.mcpUrl}/mcp`;
28
+ // Resolved once, up front: a client that fails to authenticate should learn
29
+ // it immediately rather than on its first tool call.
30
+ const { token } = await session.requireToken();
31
+ const input = readline.createInterface({ input: process.stdin, crlfDelay: Infinity });
32
+ for await (const line of input) {
33
+ const trimmed = line.trim();
34
+ if (!trimmed)
35
+ continue;
36
+ let message;
37
+ try {
38
+ message = JSON.parse(trimmed);
39
+ }
40
+ catch {
41
+ writeLine(jsonRpcError(null, -32700, "Parse error: the bridge received invalid JSON."));
42
+ continue;
43
+ }
44
+ try {
45
+ await forward(endpoint, token, message);
46
+ }
47
+ catch (error) {
48
+ writeLine(jsonRpcError(message.id ?? null, -32603, `The MCP bridge could not reach ${endpoint}: ${error instanceof Error ? error.message : String(error)}`));
49
+ }
50
+ }
51
+ }
52
+ async function forward(endpoint, token, message) {
53
+ const headers = {
54
+ Authorization: `Bearer ${token}`,
55
+ "Content-Type": "application/json",
56
+ Accept: "application/json, text/event-stream",
57
+ "User-Agent": USER_AGENT,
58
+ };
59
+ if (typeof message.method === "string")
60
+ headers["Mcp-Method"] = message.method;
61
+ const params = message.params;
62
+ if (params && typeof params.name === "string")
63
+ headers["Mcp-Name"] = params.name;
64
+ const response = await fetch(endpoint, {
65
+ method: "POST",
66
+ headers,
67
+ body: JSON.stringify(message),
68
+ });
69
+ // A notification gets 202 and no body. Emitting anything here would break the
70
+ // client's request/response accounting.
71
+ if (response.status === 202 || response.status === 204)
72
+ return;
73
+ const contentType = (response.headers.get("content-type") ?? "").toLowerCase();
74
+ if (!response.ok && !contentType.includes("json")) {
75
+ const text = await response.text().catch(() => "");
76
+ writeLine(jsonRpcError(message.id ?? null, -32603, `The MCP server returned HTTP ${response.status}. ${text.slice(0, 300)}`));
77
+ return;
78
+ }
79
+ if (contentType.includes("text/event-stream") && response.body) {
80
+ await pipeEventStream(response.body);
81
+ return;
82
+ }
83
+ const text = await response.text();
84
+ if (!text.trim())
85
+ return;
86
+ writeLine(text.trim());
87
+ }
88
+ /**
89
+ * Streamable HTTP may answer a single POST with an SSE stream carrying several
90
+ * messages. Each `data:` payload is one JSON-RPC message and goes out as its
91
+ * own stdout line.
92
+ */
93
+ async function pipeEventStream(body) {
94
+ const decoder = new TextDecoder();
95
+ const reader = body.getReader();
96
+ let buffer = "";
97
+ for (;;) {
98
+ const { done, value } = await reader.read();
99
+ if (done)
100
+ break;
101
+ buffer += decoder.decode(value, { stream: true });
102
+ let separator = buffer.indexOf("\n\n");
103
+ while (separator !== -1) {
104
+ const event = buffer.slice(0, separator);
105
+ buffer = buffer.slice(separator + 2);
106
+ emitEvent(event);
107
+ separator = buffer.indexOf("\n\n");
108
+ }
109
+ }
110
+ if (buffer.trim())
111
+ emitEvent(buffer);
112
+ }
113
+ function emitEvent(event) {
114
+ const payload = event
115
+ .split(/\r?\n/)
116
+ .filter((line) => line.startsWith("data:"))
117
+ .map((line) => line.slice(5).trimStart())
118
+ .join("\n")
119
+ .trim();
120
+ if (payload)
121
+ writeLine(payload);
122
+ }
123
+ function writeLine(payload) {
124
+ process.stdout.write(`${payload}\n`);
125
+ }
126
+ function jsonRpcError(id, code, message) {
127
+ return JSON.stringify({ jsonrpc: "2.0", id, error: { code, message } });
128
+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AAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * The read-only commands: `account`, `credits`, `usage`.
3
+ *
4
+ * Each one is a single request and a single view. The pattern to copy: call the
5
+ * API, `unwrap` the envelope, and hand the raw object plus a field list to the
6
+ * printer. The printer decides between a table and JSON based on whether stdout
7
+ * is a terminal — a command should never make that choice itself, or piping it
8
+ * into `jq` breaks.
9
+ */
10
+ import { USAGE_GRANULARITY_VALUES, } from "../api-types.generated.js";
11
+ import { formatDate, formatNumber } from "../output.js";
12
+ import { run, unwrap } from "../run.js";
13
+ export function registerRead(program) {
14
+ program
15
+ .command("account")
16
+ .description("Workspace, plan, entitlements, and what this credential may do")
17
+ .action(async (_options, command) => {
18
+ await run(command, async (session) => {
19
+ const response = await session.client.request("GET", "/account");
20
+ const account = unwrap(response.body);
21
+ session.printer.data(account, {
22
+ fields: [
23
+ { label: "Workspace", value: `${account.workspace.name} (${account.workspace.slug})` },
24
+ { label: "Plan", value: account.workspace.plan },
25
+ { label: "Credits", value: formatNumber(account.credit_balance) },
26
+ { label: "Pages left this month", value: `${formatNumber(account.pages_this_month.left)} (resets ${account.pages_this_month.resets_at.slice(0, 10)})` },
27
+ { label: "Seats", value: describeLimit(account.entitlements.seats) },
28
+ { label: "Sites", value: formatNumber(account.entitlements.sites) },
29
+ { label: "URLs per crawl", value: formatNumber(account.entitlements.max_urls_per_crawl) },
30
+ { label: "Scopes", value: account.credential.scopes.join(", ") || "-" },
31
+ {
32
+ label: "Crawls",
33
+ value: account.capabilities.crawls ? "available" : "not available",
34
+ },
35
+ {
36
+ label: "Webhooks",
37
+ value: account.capabilities.webhooks ? "available" : "not available yet",
38
+ },
39
+ ],
40
+ });
41
+ });
42
+ });
43
+ program
44
+ .command("credits")
45
+ .description("Credit balance and every grant with its expiry")
46
+ .action(async (_options, command) => {
47
+ await run(command, async (session) => {
48
+ const response = await session.client.request("GET", "/credits");
49
+ const credits = unwrap(response.body);
50
+ session.printer.data(credits, {
51
+ rows: credits.grants,
52
+ fields: [
53
+ { label: "Balance", value: formatNumber(credits.balance) },
54
+ { label: "Plan", value: credits.plan },
55
+ { label: "Monthly", value: describeLimit(credits.monthly_allowance) },
56
+ { label: "Next refill", value: formatDate(credits.next_refill_estimated_at) },
57
+ ],
58
+ columns: [
59
+ { header: "TYPE", value: (row) => row.type },
60
+ { header: "AMOUNT", value: (row) => formatNumber(row.amount) },
61
+ { header: "REMAINING", value: (row) => formatNumber(row.remaining) },
62
+ { header: "EXPIRES", value: (row) => formatDate(row.expires_at) },
63
+ ],
64
+ });
65
+ });
66
+ });
67
+ program
68
+ .command("usage")
69
+ .description("Credits charged over a period (defaults to the last 30 days); the pages crawled this month are in account, pages_this_month")
70
+ .option("--from <date>", "Start date, '2026-07-01' or a full ISO timestamp")
71
+ .option("--to <date>", "End date, inclusive")
72
+ .option("--granularity <bucket>", `${USAGE_GRANULARITY_VALUES.join(" | ")} (defaults to the range length)`)
73
+ .action(async (options, command) => {
74
+ await run(command, async (session) => {
75
+ const response = await session.client.request("GET", "/usage", {
76
+ query: {
77
+ from: options.from,
78
+ to: options.to,
79
+ granularity: options.granularity,
80
+ },
81
+ });
82
+ const usage = unwrap(response.body);
83
+ session.printer.data(usage, {
84
+ rows: usage.points,
85
+ fields: [
86
+ { label: "Range", value: `${usage.from} → ${usage.to} (${usage.granularity})` },
87
+ { label: "Credits", value: formatNumber(usage.totals.credits_used) },
88
+ { label: "Charges", value: formatNumber(usage.totals.charges) },
89
+ ],
90
+ columns: [
91
+ { header: "DATE", value: (row) => row.date },
92
+ { header: "CREDITS", value: (row) => formatNumber(row.credits_used) },
93
+ { header: "CHARGES", value: (row) => formatNumber(row.charges) },
94
+ ],
95
+ });
96
+ });
97
+ });
98
+ }
99
+ /** `null` means unlimited in this API, and "—" would read as "unknown". */
100
+ function describeLimit(value) {
101
+ if (value === null)
102
+ return "unlimited";
103
+ if (value === undefined)
104
+ return "-";
105
+ return formatNumber(value);
106
+ }
107
+ //# sourceMappingURL=read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/commands/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,wBAAwB,GAIzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,gEAAgE,CAAC;SAC7E,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAgB,EAAE,EAAE;QAC3C,MAAM,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACnC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;YACjE,MAAM,OAAO,GAAG,MAAM,CAAqB,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC1D,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE;gBAC5B,MAAM,EAAE;oBACN,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,KAAK,OAAO,CAAC,SAAS,CAAC,IAAI,GAAG,EAAE;oBACtF,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE;oBAChD,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;oBACjE,EAAE,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC,OAAO,CAAC,gBAAgB,CAAC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