#!/usr/bin/env node /** * arcrun CLI — acr * AI Workflow CLI for Cloudflare Workers + WASM * * 安裝:npm i -g arcrun * 使用:acr <指令> */ import { Command } from 'commander'; import { cmdInit } from './commands/init.js'; import { cmdCredsPush } from './commands/creds.js'; import { cmdPush } from './commands/push.js'; import { cmdRun } from './commands/run.js'; import { cmdValidate } from './commands/validate.js'; import { cmdParts, cmdPartsScaffold, cmdPartsPublish } from './commands/parts.js'; import { cmdRecipePush, cmdRecipeList, cmdRecipeDelete } from './commands/recipe.js'; import { cmdList } from './commands/list.js'; import { cmdLogs } from './commands/logs.js'; import { cmdAuthRecipeList, cmdAuthRecipeInfo, cmdAuthRecipeScaffold } from './commands/auth-recipe.js'; const program = new Command(); program .name('acr') .description('arcrun — AI Workflow CLI for Cloudflare Workers + WASM') .version('1.1.0'); // acr init [--self-hosted] program .command('init') .description('互動式初始化設定(建立 ~/.arcrun/config.yaml)') .option('--local', '本機模式:不需要 Cloudflare 帳號,直接在本機測試 workflow') .option('--self-hosted', '完全 Self-hosted 模式:自行部署所有 Cloudflare Worker') .action((options: { local?: boolean; selfHosted?: boolean }) => cmdInit(options)); // acr creds push [credentials.yaml] const credsCmd = program.command('creds').description('Credential 管理'); credsCmd .command('push [file]') .description('加密上傳 credentials.yaml 至你的 CF KV(不經過 arcrun.dev)') .action((file: string) => cmdCredsPush(file ?? 'credentials.yaml')); // acr push program .command('push ') .description('解析 workflow.yaml 並部署至你的 CF KV') .action((file: string) => cmdPush(file)); // acr run [--input key=value...] program .command('run ') .description('執行指定 workflow') .option('-i, --input ', 'input 參數(格式:key=value)') .action((workflow: string, options: { input?: string[] }) => cmdRun(workflow, options)); // acr validate program .command('validate ') .description('執行前驗證 workflow.yaml(格式、關係詞、零件存在性、credentials)') .option('--offline', '離線模式:跳過零件存在性與 credentials 的遠端檢查') .action((file: string, options: { offline?: boolean }) => cmdValidate(file, options)); // acr parts // acr parts scaffold // acr parts publish [--status ] const partsCmd = program.command('parts').description('零件庫管理'); partsCmd .action(() => cmdParts()); partsCmd .command('scaffold ') .description('輸出零件的 config 範本(可直接貼入 workflow.yaml)') .action((component: string) => cmdPartsScaffold(component)); partsCmd .command('publish ') .description('提交零件至 arcrun.dev 公眾 registry') .option('--status ', '查詢提交審核進度') .action((dir: string, options: { status?: string }) => cmdPartsPublish(dir, options)); // acr recipe push / list / delete const recipeCmd = program.command('recipe').description('API Recipe 管理'); recipeCmd .command('push ') .description('上傳 recipe YAML 到 arcrun.dev(不需要 deploy Worker)') .action((file: string) => cmdRecipePush(file)); recipeCmd .command('list') .description('列出已上傳的 recipe') .action(() => cmdRecipeList()); recipeCmd .command('delete ') .description('刪除 recipe(canonical_id 或 rec_hash)') .action((id: string) => cmdRecipeDelete(id)); // acr auth-recipe list / info / scaffold const authRecipeCmd = program.command('auth-recipe').description('第三方服務認證 Recipe(新增服務整合)'); authRecipeCmd .command('list') .description('列出所有平台預建的服務整合(Notion、Slack、GitHub 等)') .action(() => cmdAuthRecipeList()); authRecipeCmd .command('info ') .description('顯示服務 recipe 詳情(需要哪些 credential)') .action((service: string) => cmdAuthRecipeInfo(service)); authRecipeCmd .command('scaffold ') .description('輸出 credentials.yaml 範本 + workflow.yaml 使用範例') .action((service: string) => cmdAuthRecipeScaffold(service)); // acr list program .command('list') .description('列出 CF KV 中所有已部署的 workflow') .action(() => cmdList()); // acr logs program .command('logs ') .description('顯示 workflow 最近執行記錄') .action((workflow: string) => cmdLogs(workflow)); program.parse(process.argv);