From 735998acbf56e22dc95ab47681fbd7be0bb9bd04 Mon Sep 17 00:00:00 2001 From: John Xie Date: Wed, 25 Nov 2026 15:49:44 -0800 Subject: [PATCH] ci: Check the README table of hosted tools against a snapshot of the tool list (#152) --- .github/workflows/ci.yml | 4 + CONTRIBUTING.md | 8 + README.md | 4 + hosted-tools.json | 238 +++++++++++++++++ package.json | 2 + packages/server/scripts/hosted-tools.test.ts | 153 +++++++++++ packages/server/scripts/hosted-tools.ts | 264 +++++++++++++++++++ 7 files changed, 673 insertions(+) create mode 100644 hosted-tools.json create mode 100644 packages/server/scripts/hosted-tools.test.ts create mode 100644 packages/server/scripts/hosted-tools.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b3d03d4..a5ab585 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,10 @@ jobs: - name: Test run: yarn test + - name: Check the hosted tool table + # The README table of hosted tools must match hosted-tools.json. This step uses no network. + run: yarn hosted-tools:check + - name: Smoke test the packed codegen package # Install the codegen tarball in an empty project outside the workspace and run it # with plain Node. This step fails if the tarball has no build output or if a diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1b389ef..e98f253 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,6 +28,14 @@ The Claude plugin directory reads only `plugins/taskade/`. Codex, Cursor, Gemini The other fields of the manifests and `LICENSE` belong to this repository. In each sync pull request, write the release notes of the new version in `publication.release_notes` of `plugin.json`, and update the `interface` text of `plugin.json` when the skills change what the plugin does. The script prints these fields at the end of each run. When you edit `LICENSE` or a field that both `.claude-plugin/plugin.json` files hold, edit both copies. `yarn test` fails when the copies differ. +## Hosted tool table + +The section "Hosted tools" of `README.md` lists the tools of the hosted server `https://www.taskade.com/mcp` in a table between the markers `` and ``. `hosted-tools.json` is a snapshot of the same tool list. It holds each tool name, and the title and the read or write mark when they are known. + +- `yarn hosted-tools:check` fails when the table and the snapshot do not hold the same tools, or when a tool is in the wrong column. It uses no network. CI runs it. +- `yarn hosted-tools:sync` fetches the public tool list file `https://www.taskade.com/.well-known/mcp/tools.json`, writes the snapshot, and writes the table from it. The table keeps its rows and its text. A new tool goes to the row "Other". When the file does not answer 200 with the expected shape, the script changes nothing. +- Until that file is available, edit the snapshot and the table by hand, then run `yarn hosted-tools:check`. Keep the tools of the snapshot sorted by name, and set `count` to the number of tools. + ## Pull requests We uses Cchangesets to track and publish new releases. diff --git a/README.md b/README.md index 5914e14..5af9a16 100644 --- a/README.md +++ b/README.md @@ -341,6 +341,8 @@ Full guide: [Hosted Taskade MCP](https://www.taskade.com/docs/mcp/hosted-mcp). Every hosted tool declares MCP tool annotations. Claude can run a read-only tool without a confirmation, and it asks before a tool that deletes or replaces data. + + | Area | Read-only tools | Write tools | |---|---|---| | Workspaces | `list_spaces`, `list_folders`, `list_media`, `list_templates`, `inspect_space` | `write_file` (Taskade Genesis app source in `app/`) | @@ -351,6 +353,8 @@ Every hosted tool declares MCP tool annotations. Claude can run a read-only tool | AI agents | `list_agents`, `get_agent`, `list_conversations`, `get_conversation` | `create_agent`, `update_agent`, `delete_agent`, `prompt_agent`, `add_knowledge_project`, `remove_knowledge_project`, `add_knowledge_media`, `remove_knowledge_media` | | App kits | `list_my_kits` | `publish_kit_version` | + + - `get_flow_runs`: reads the recent runs of one automation, newest first. Each run has its status and times. A failed run also names the failed step and a short error. It needs edit rights on automations. - `switch_automation`: turns one automation On or Off, like its switch in Taskade. The first call changes nothing. It shows how the automation starts, its steps, and what it spends or sends. A second call with `confirm: true` makes the change and returns an `undo` call. It needs edit rights on automations. - `edit_automation`: reads the steps of one automation, and changes the text, number, date and fixed-choice fields of its existing steps. It shows a preview first, applies the change only with `confirm: true`, and returns an `undo` call. A field that can hold a secret reads only as "set" or "not set". It needs edit rights on automations. diff --git a/hosted-tools.json b/hosted-tools.json new file mode 100644 index 0000000..c07788f --- /dev/null +++ b/hosted-tools.json @@ -0,0 +1,238 @@ +{ + "server": "https://www.taskade.com/mcp", + "count": 58, + "tools": [ + { + "name": "add_knowledge_media", + "readOnly": false + }, + { + "name": "add_knowledge_project", + "readOnly": false + }, + { + "name": "app_access", + "readOnly": true + }, + { + "name": "app_users", + "readOnly": false + }, + { + "name": "assign_task", + "readOnly": false + }, + { + "name": "complete_project", + "readOnly": false + }, + { + "name": "complete_task", + "readOnly": false + }, + { + "name": "copy_project", + "readOnly": false + }, + { + "name": "create_agent", + "readOnly": false + }, + { + "name": "create_project", + "readOnly": false + }, + { + "name": "create_project_from_template", + "readOnly": false + }, + { + "name": "create_task", + "readOnly": false + }, + { + "name": "delete_agent", + "readOnly": false + }, + { + "name": "delete_task", + "readOnly": false + }, + { + "name": "delete_task_date", + "readOnly": false + }, + { + "name": "delete_task_field_value", + "readOnly": false + }, + { + "name": "delete_task_note", + "readOnly": false + }, + { + "name": "edit_automation", + "readOnly": false + }, + { + "name": "enable_share_link", + "readOnly": false + }, + { + "name": "get_agent", + "readOnly": true + }, + { + "name": "get_conversation", + "readOnly": true + }, + { + "name": "get_flow_runs", + "readOnly": true + }, + { + "name": "get_project", + "readOnly": true + }, + { + "name": "get_share_link", + "readOnly": true + }, + { + "name": "inspect_space", + "readOnly": true + }, + { + "name": "list_agents", + "readOnly": true + }, + { + "name": "list_automations", + "readOnly": true + }, + { + "name": "list_blocks", + "readOnly": true + }, + { + "name": "list_conversations", + "readOnly": true + }, + { + "name": "list_fields", + "readOnly": true + }, + { + "name": "list_folders", + "readOnly": true + }, + { + "name": "list_media", + "readOnly": true + }, + { + "name": "list_my_kits", + "readOnly": true + }, + { + "name": "list_my_projects", + "readOnly": true + }, + { + "name": "list_project_members", + "readOnly": true + }, + { + "name": "list_projects", + "readOnly": true + }, + { + "name": "list_spaces", + "readOnly": true + }, + { + "name": "list_tasks", + "readOnly": true + }, + { + "name": "list_templates", + "readOnly": true + }, + { + "name": "move_task", + "readOnly": false + }, + { + "name": "prompt_agent", + "readOnly": false + }, + { + "name": "publish_kit_version", + "readOnly": false + }, + { + "name": "read_project", + "readOnly": true + }, + { + "name": "remove_knowledge_media", + "readOnly": false + }, + { + "name": "remove_knowledge_project", + "readOnly": false + }, + { + "name": "rename_project", + "readOnly": false + }, + { + "name": "restore_project", + "readOnly": false + }, + { + "name": "run_flow", + "readOnly": false + }, + { + "name": "set_field", + "readOnly": false + }, + { + "name": "set_task_date", + "readOnly": false + }, + { + "name": "set_task_field_value", + "readOnly": false + }, + { + "name": "set_task_note", + "readOnly": false + }, + { + "name": "switch_automation", + "readOnly": false + }, + { + "name": "unassign_task", + "readOnly": false + }, + { + "name": "uncomplete_task", + "readOnly": false + }, + { + "name": "update_agent", + "readOnly": false + }, + { + "name": "update_task", + "readOnly": false + }, + { + "name": "write_file", + "readOnly": false + } + ] +} diff --git a/package.json b/package.json index 2914231..5900f6c 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,8 @@ "lint": "eslint . --ext .js,.jsx,.ts,.tsx", "lint:fix": "eslint --fix . --ext .js,.jsx,.ts,.tsx", "test": "vitest run", + "hosted-tools:check": "tsx packages/server/scripts/hosted-tools.ts check", + "hosted-tools:sync": "tsx packages/server/scripts/hosted-tools.ts sync", "changeset:version": "changeset version && tsx packages/server/scripts/sync-dockerfile-version.ts", "changeset:publish": "changeset publish", "publish": "run-s build lint changeset:publish" diff --git a/packages/server/scripts/hosted-tools.test.ts b/packages/server/scripts/hosted-tools.test.ts new file mode 100644 index 0000000..9d49672 --- /dev/null +++ b/packages/server/scripts/hosted-tools.test.ts @@ -0,0 +1,153 @@ +import { describe, expect, it } from 'vitest'; + +import { + checkFiles, + END_MARKER, + formatSnapshot, + renderReadme, + START_MARKER, + tableNames, + toSnapshot, +} from './hosted-tools'; + +const README = [ + '# Tools', + '', + START_MARKER, + '', + '| Area | Read-only tools | Write tools |', + '|---|---|---|', + '| Projects | `list_projects`, `get_project` | `create_project` (in a folder), `copy_project` |', + '| Tasks | `list_tasks` | `create_task` |', + '', + END_MARKER, + '', + 'More text.', + '', +].join('\n'); + +const snapshotOf = (tools: { name: string; readOnly?: boolean }[]) => + toSnapshot({ tools: tools.map((tool) => ({ ...tool })) }); + +const MATCHING = snapshotOf([ + { name: 'list_projects', readOnly: true }, + { name: 'get_project', readOnly: true }, + { name: 'create_project', readOnly: false }, + { name: 'copy_project', readOnly: false }, + { name: 'list_tasks', readOnly: true }, + { name: 'create_task', readOnly: false }, +]); + +describe('toSnapshot', () => { + it('sorts the tools by name, keeps only the known fields and sets the count', () => { + expect( + toSnapshot({ + tools: [ + { name: 'list_tasks', title: 'List tasks', readOnly: true, inputSchema: {} }, + { name: 'delete_task', destructive: true, openWorld: false }, + ], + }), + ).toEqual({ + server: 'https://www.taskade.com/mcp', + count: 2, + tools: [ + { name: 'delete_task', destructive: true, openWorld: false }, + { name: 'list_tasks', title: 'List tasks', readOnly: true }, + ], + }); + }); + + it.each([ + ['no tools array', { name: 'x' }, 'no "tools" array'], + ['an empty list', { tools: [] }, 'has no tools'], + ['a tool with no name', { tools: [{ title: 'x' }] }, 'has no "name"'], + ['a name with capitals', { tools: [{ name: 'listTasks' }] }, 'is not lower case'], + ['a flag that is not a boolean', { tools: [{ name: 'a', readOnly: 'yes' }] }, 'not true'], + ['a name two times', { tools: [{ name: 'a' }, { name: 'a' }] }, 'two times'], + ['a wrong count', { count: 3, tools: [{ name: 'a' }] }, 'holds 1 tools'], + ['another server', { server: 'https://example.com/mcp', tools: [{ name: 'a' }] }, 'names'], + ])('refuses %s', (_name, data, message) => { + expect(() => toSnapshot(data)).toThrow(message); + }); +}); + +describe('renderReadme', () => { + it('changes nothing when the table matches the snapshot', () => { + expect(renderReadme(README, MATCHING)).toBe(README); + expect(checkFiles(formatSnapshot(MATCHING), README)).toEqual([]); + }); + + it('removes a tool that the snapshot does not hold, and keeps the text after a name', () => { + const snapshot = snapshotOf(MATCHING.tools.filter((tool) => tool.name !== 'copy_project')); + expect(renderReadme(README, snapshot)).toContain( + '| Projects | `list_projects`, `get_project` | `create_project` (in a folder) |', + ); + }); + + it('adds a new tool to the row Other, in the column of its readOnly value', () => { + const snapshot = snapshotOf([ + ...MATCHING.tools, + { name: 'list_media', readOnly: true }, + { name: 'upload_media' }, + ]); + const readme = renderReadme(README, snapshot); + expect(readme).toContain( + '| Tasks | `list_tasks` | `create_task` |\n| Other | `list_media` | `upload_media` |\n', + ); + expect(tableNames(readme)).toHaveLength(8); + expect(renderReadme(readme, snapshot)).toBe(readme); + }); + + it('moves a tool when its readOnly value changes, and drops an empty row', () => { + const snapshot = snapshotOf( + MATCHING.tools + .filter((tool) => !['list_tasks', 'create_task'].includes(tool.name)) + .map((tool) => (tool.name === 'get_project' ? { ...tool, readOnly: false } : tool)), + ); + const readme = renderReadme(README, snapshot); + expect(readme).toContain( + '| Projects | `list_projects` | `get_project`, `create_project` (in a folder), `copy_project` |', + ); + expect(readme).not.toContain('| Tasks |'); + }); +}); + +describe('checkFiles', () => { + it('names a tool that the table lists and the snapshot does not hold', () => { + const snapshot = snapshotOf(MATCHING.tools.filter((tool) => tool.name !== 'create_task')); + expect(checkFiles(formatSnapshot(snapshot), README)).toEqual([ + 'README.md: the table lists create_task, which hosted-tools.json does not hold.', + 'README.md: the table lists 6 tools, and hosted-tools.json holds 5.', + ]); + }); + + it('names a tool that the snapshot holds and the table does not list', () => { + const snapshot = snapshotOf([...MATCHING.tools, { name: 'list_media', readOnly: true }]); + expect(checkFiles(formatSnapshot(snapshot), README)).toEqual([ + 'README.md: the table does not list list_media, which hosted-tools.json holds.', + 'README.md: the table lists 6 tools, and hosted-tools.json holds 7.', + ]); + }); + + it('finds a tool in the wrong column', () => { + const snapshot = snapshotOf( + MATCHING.tools.map((tool) => + tool.name === 'list_tasks' ? { ...tool, readOnly: false } : tool, + ), + ); + expect(checkFiles(formatSnapshot(snapshot), README)).toEqual([ + 'README.md: a tool is in the wrong column, a name is in the table two times, or the table format changed.', + ]); + }); + + it('refuses a snapshot that is not sorted or has a wrong count', () => { + const text = JSON.stringify({ ...MATCHING, count: 7 }, null, 2); + expect(checkFiles(text, README)[0]).toContain('holds 6 tools'); + const unsorted = `${JSON.stringify({ ...MATCHING, tools: [...MATCHING.tools].reverse() }, null, 2)}\n`; + expect(checkFiles(unsorted, README)[0]).toContain('sorted by name'); + }); + + it('refuses a README with no markers', () => { + expect(() => tableNames('# Tools\n')).toThrow('has no table between'); + }); +}); diff --git a/packages/server/scripts/hosted-tools.ts b/packages/server/scripts/hosted-tools.ts new file mode 100644 index 0000000..5836b26 --- /dev/null +++ b/packages/server/scripts/hosted-tools.ts @@ -0,0 +1,264 @@ +import { readFileSync, writeFileSync } from 'node:fs'; +import { fileURLToPath, pathToFileURL } from 'node:url'; + +// The README lists the tools of the hosted server in a table between two HTML comment markers. +// hosted-tools.json at the repository root is a snapshot of that tool list. +// +// yarn hosted-tools:check fails when the table does not match the snapshot. It uses no network. +// yarn hosted-tools:sync fetches the public tool list file of the hosted server, writes the +// snapshot, and writes the table from the snapshot. +// +// The table keeps its rows and the text after each tool name. `sync` removes a tool that the +// snapshot does not hold, puts a tool in the column of its `readOnly` value, and adds each new +// tool to the row "Other". + +export const SERVER = 'https://www.taskade.com/mcp'; +export const TOOL_LIST_URL = 'https://www.taskade.com/.well-known/mcp/tools.json'; +export const START_MARKER = ''; +export const END_MARKER = ''; +export const NEW_TOOL_AREA = 'Other'; + +export const snapshotPath = fileURLToPath(new URL('../../../hosted-tools.json', import.meta.url)); +export const readmePath = fileURLToPath(new URL('../../../README.md', import.meta.url)); + +const FLAGS = ['readOnly', 'destructive', 'openWorld'] as const; +const TOOL_NAME = /^[a-z][a-z0-9_]*$/; + +export type HostedTool = { + name: string; + title?: string; + readOnly?: boolean; + destructive?: boolean; + openWorld?: boolean; +}; + +export type Snapshot = { server: string; count: number; tools: HostedTool[] }; + +// Reads a tool list and returns the snapshot, sorted by name, with only the known fields. +// Throws with the reason when the list does not have the expected shape. +export const toSnapshot = (data: unknown): Snapshot => { + const list = data as Record | null; + if (list == null || typeof list !== 'object' || !Array.isArray(list.tools)) { + throw new Error('The tool list has no "tools" array.'); + } + if (list.server !== undefined && list.server !== SERVER) { + throw new Error(`The tool list names the server ${String(list.server)}, not ${SERVER}.`); + } + const tools = list.tools.map((item: unknown, index: number) => { + const tool = item as Record | null; + if (tool == null || typeof tool !== 'object' || typeof tool.name !== 'string') { + throw new Error(`Tool ${index} has no "name".`); + } + if (!TOOL_NAME.test(tool.name)) { + throw new Error(`The tool name "${tool.name}" is not lower case letters, digits and "_".`); + } + const entry: HostedTool = { name: tool.name }; + if (tool.title !== undefined) { + if (typeof tool.title !== 'string') { + throw new Error(`The "title" of ${tool.name} is not a string.`); + } + entry.title = tool.title; + } + for (const flag of FLAGS) { + if (tool[flag] !== undefined) { + if (typeof tool[flag] !== 'boolean') { + throw new Error(`The "${flag}" of ${tool.name} is not true or false.`); + } + entry[flag] = tool[flag] as boolean; + } + } + return entry; + }); + if (tools.length === 0) { + throw new Error('The tool list has no tools.'); + } + tools.sort((a, b) => (a.name < b.name ? -1 : 1)); + const repeated = tools.filter((tool, index) => index > 0 && tools[index - 1].name === tool.name); + if (repeated.length > 0) { + throw new Error(`The tool list holds a name two times: ${repeated[0].name}.`); + } + if (list.count !== undefined && list.count !== tools.length) { + throw new Error( + `The tool list says "count": ${list.count}, but it holds ${tools.length} tools.`, + ); + } + return { server: SERVER, count: tools.length, tools }; +}; + +export const formatSnapshot = (snapshot: Snapshot): string => + `${JSON.stringify(snapshot, null, 2)}\n`; + +type Row = { area: string; columns: [string[], string[]] }; + +// An item is a tool name in backticks, and the text that follows it up to the next item. +const nameOf = (item: string): string => { + const match = /^`([a-z][a-z0-9_]*)`/.exec(item); + if (match == null) { + throw new Error(`The table item "${item}" does not start with a tool name in backticks.`); + } + return match[1]; +}; + +const cellsOf = (line: string): string[] => + line + .replace(/^\|/, '') + .replace(/\|$/, '') + .split('|') + .map((cell) => cell.trim()); + +// Splits the README into the text before the table, the two header lines, the rows, and the +// text after the table. +export const parseReadme = (readme: string) => { + const start = readme.indexOf(START_MARKER); + const end = readme.indexOf(END_MARKER); + if (start === -1 || end === -1 || end < start) { + throw new Error(`README.md has no table between ${START_MARKER} and ${END_MARKER}.`); + } + const lines = readme + .slice(start + START_MARKER.length, end) + .split('\n') + .filter((line) => line.trim() !== ''); + if (lines.length < 2 || lines.some((line) => !line.startsWith('|'))) { + throw new Error('The text between the markers must be one Markdown table and nothing else.'); + } + const rows: Row[] = lines.slice(2).map((line) => { + const cells = cellsOf(line); + if (cells.length !== 3) { + throw new Error(`The table row "${line}" does not have 3 cells.`); + } + const items = (cell: string) => (cell === '' ? [] : cell.split(/, (?=`)/)); + return { area: cells[0], columns: [items(cells[1]), items(cells[2])] }; + }); + rows.forEach((row) => row.columns.flat().forEach(nameOf)); + return { + before: readme.slice(0, start), + header: lines.slice(0, 2), + rows, + after: readme.slice(end + END_MARKER.length), + }; +}; + +export const tableNames = (readme: string): string[] => + parseReadme(readme).rows.flatMap((row) => row.columns.flat().map(nameOf)); + +// Returns the README with the table written from the snapshot. +export const renderReadme = (readme: string, snapshot: Snapshot): string => { + const { before, header, rows, after } = parseReadme(readme); + const tools = new Map(snapshot.tools.map((tool) => [tool.name, tool])); + const column = (tool: HostedTool, current: number) => + tool.readOnly === undefined ? current : tool.readOnly ? 0 : 1; + const placed = new Set(); + const kept: Row[] = rows.map((row) => { + const columns: [string[], string[]] = [[], []]; + row.columns.forEach((items, current) => + items.forEach((item) => { + const tool = tools.get(nameOf(item)); + if (tool != null) { + placed.add(tool.name); + columns[column(tool, current)].push(item); + } + }), + ); + return { area: row.area, columns }; + }); + const added = snapshot.tools.filter((tool) => !placed.has(tool.name)); + if (added.length > 0) { + let other = kept.find((row) => row.area === NEW_TOOL_AREA); + if (other == null) { + other = { area: NEW_TOOL_AREA, columns: [[], []] }; + kept.push(other); + } + // A new tool with no readOnly value goes in the column of the write tools. + for (const tool of added) { + other.columns[tool.readOnly === true ? 0 : 1].push(`\`${tool.name}\``); + } + } + const lines = kept + .filter((row) => row.columns.flat().length > 0) + .map((row) => `| ${row.area} | ${row.columns[0].join(', ')} | ${row.columns[1].join(', ')} |`); + return `${before}${START_MARKER}\n\n${[...header, ...lines].join('\n')}\n\n${END_MARKER}${after}`; +}; + +// Returns each problem. An empty list means that the snapshot and the table match. +export const checkFiles = (snapshotText: string, readme: string): string[] => { + let snapshot: Snapshot; + try { + snapshot = toSnapshot(JSON.parse(snapshotText)); + } catch (error) { + return [`hosted-tools.json: ${(error as Error).message}`]; + } + const problems: string[] = []; + if (formatSnapshot(snapshot) !== snapshotText) { + problems.push( + 'hosted-tools.json: the file must hold "server", "count" and the tools sorted by name, as `yarn hosted-tools:sync` writes it.', + ); + } + const names = tableNames(readme); + const known = new Set(snapshot.tools.map((tool) => tool.name)); + const listed = new Set(names); + for (const name of names.filter((item) => !known.has(item))) { + problems.push(`README.md: the table lists ${name}, which hosted-tools.json does not hold.`); + } + for (const name of [...known].filter((item) => !listed.has(item))) { + problems.push(`README.md: the table does not list ${name}, which hosted-tools.json holds.`); + } + if (names.length !== snapshot.count) { + problems.push( + `README.md: the table lists ${names.length} tools, and hosted-tools.json holds ${snapshot.count}.`, + ); + } + if (problems.length === 0 && renderReadme(readme, snapshot) !== readme) { + problems.push( + 'README.md: a tool is in the wrong column, a name is in the table two times, or the table format changed.', + ); + } + return problems; +}; + +const check = () => { + const problems = checkFiles(readFileSync(snapshotPath, 'utf8'), readFileSync(readmePath, 'utf8')); + if (problems.length > 0) { + console.error( + `${problems.map((problem) => `- ${problem}`).join('\n')}\nCorrect the snapshot or the table, or run \`yarn hosted-tools:sync\`.`, + ); + process.exit(1); + } + const { count } = JSON.parse(readFileSync(snapshotPath, 'utf8')) as Snapshot; + console.log(`The hosted tool table matches hosted-tools.json (${count} tools).`); +}; + +const sync = async () => { + const fail = (reason: string) => { + console.error(`${reason}\nhosted-tools.json and README.md did not change.`); + process.exit(1); + }; + let snapshot: Snapshot; + try { + const response = await fetch(TOOL_LIST_URL, { signal: AbortSignal.timeout(30_000) }); + if (response.status !== 200) { + return fail(`${TOOL_LIST_URL} answered HTTP ${response.status}, not 200.`); + } + snapshot = toSnapshot(await response.json()); + } catch (error) { + return fail(`Could not read ${TOOL_LIST_URL}: ${(error as Error).message}`); + } + const readme = renderReadme(readFileSync(readmePath, 'utf8'), snapshot); + writeFileSync(snapshotPath, formatSnapshot(snapshot)); + writeFileSync(readmePath, readme); + console.log(`Wrote hosted-tools.json and the README table (${snapshot.count} tools).`); +}; + +if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { + const mode = process.argv[2]; + if (mode === 'check') { + check(); + } else if (mode === 'sync') { + sync().catch((error) => { + console.error(error); + process.exit(1); + }); + } else { + console.error('Usage: tsx packages/server/scripts/hosted-tools.ts '); + process.exit(1); + } +}