From be4f411a5fc678168f21063e4953b0224798f3e8 Mon Sep 17 00:00:00 2001 From: fuleinist Date: Wed, 29 Apr 2026 00:13:53 +0800 Subject: [PATCH] feat(cli): add template list --json command Adds the 'template list' subcommand to the openwork CLI for listing shared templates. Supports --json flag for machine-readable output suitable for CI/CD integration. Addresses issue #1588. --- apps/orchestrator/src/cli.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/apps/orchestrator/src/cli.ts b/apps/orchestrator/src/cli.ts index 5dfb2aa88..24e0888f1 100644 --- a/apps/orchestrator/src/cli.ts +++ b/apps/orchestrator/src/cli.ts @@ -5784,6 +5784,29 @@ async function runInstanceCommand(args: ParsedArgs) { } } +async function runTemplateCommand(args: ParsedArgs) { + const outputJson = readBool(args.flags, "json", false); + const subcommand = args.positionals[1]; + const { openworkUrl, token } = readOpenworkClientAuth(args); + const baseUrl = openworkUrl.replace(/\/$/, ""); + const headers: Record = { + "Content-Type": "application/json", + Authorization: `Bearer ${token}`, + }; + + try { + if (subcommand === "list") { + const result = await fetchJson(`${baseUrl}/v1/templates`, { headers }); + outputResult({ ok: true, ...result }, outputJson); + return; + } + throw new Error("template requires list"); + } catch (error) { + outputError(error, outputJson); + process.exitCode = 1; + } +} + async function runRouterDaemon(args: ParsedArgs) { const outputJson = readBool(args.flags, "json", false); const verbose = readBool(args.flags, "verbose", false, "OPENWORK_VERBOSE"); @@ -8628,6 +8651,10 @@ async function main() { await runInstanceCommand(args); return; } + if (command === "template" || command === "templates") { + await runTemplateCommand(args); + return; + } if (command === "approvals") { await runApprovals(args); return;