From c7718511748b5779149ef65e2a589bc52c4298b0 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 18:34:51 +0100 Subject: [PATCH] Add weekly CLI provider check against the real CLIs Installs Claude Code, Codex CLI, Mistral Vibe, OpenCode, Gemini CLI and Groq Code and checks that every option AI.duino passes (buildArgs() of the agent modules) still appears in the CLI's help text. Separate from the providerConfigs.js gate: the options live in the extension code, so a failure needs a release, not a config fix. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0197bdW9LDsZG6J8eRf7EiPS --- .github/scripts/check-cli-providers.js | 170 +++++++++++++++++++++++ .github/workflows/cli-provider-check.yml | 64 +++++++++ 2 files changed, 234 insertions(+) create mode 100644 .github/scripts/check-cli-providers.js create mode 100644 .github/workflows/cli-provider-check.yml diff --git a/.github/scripts/check-cli-providers.js b/.github/scripts/check-cli-providers.js new file mode 100644 index 0000000..6bf2a79 --- /dev/null +++ b/.github/scripts/check-cli-providers.js @@ -0,0 +1,170 @@ +#!/usr/bin/env node +/* + * AI.duino - Check the CLI providers against the real CLIs + * Copyright 2026 Monster Maker + * + * Licensed under the Apache License, Version 2.0 + * + * The CLIs change their options without AI.duino changing anything. This script + * takes the options AI.duino really uses (buildArgs() of each agent module in + * localProviders/processProviders) and checks that each one still appears in the + * help text of the installed CLI. No login needed. + * + * The options live in the extension code, not in providerConfigs.js: a failed + * check needs a code change and a release, the remote config cannot fix it. + * + * Usage: node .github/scripts/check-cli-providers.js [--all] [--install] + * --all: a missing CLI is an error (CI, where all CLIs are installed) + * --install: print "\t" for every CLI and exit + */ + +"use strict"; + +const path = require('path'); +const fs = require('fs'); +const { execFileSync, spawnSync } = require('child_process'); + +const EXTENSION_OUT = path.join(__dirname, '..', '..', 'aiduino', 'extension', 'out'); +const MODULE_DIR = path.join(EXTENSION_OUT, 'localProviders', 'processProviders'); +const { PROVIDER_CONFIGS } = require(path.join(EXTENSION_OUT, 'config', 'providerConfigs.js')); + +const HELP_TIMEOUT_MS = 30000; +const MAX_HELP_BUFFER = 4 * 1024 * 1024; +const OPTION_PATTERN = /^--?[a-zA-Z]/; +const BUILD_ARGS_SOURCE = /^function buildArgs\([\s\S]*?\n\}/m; + +// Install command (Linux) and help calls per agent module. +// Help is read from the subcommand AI.duino uses, e.g. 'codex exec'. +const CLIS = { + claudeCode: { install: 'curl -fsSL https://claude.ai/install.sh | bash', help: [['--help']] }, + codexCli: { install: 'npm install -g @openai/codex', help: [['exec', '--help'], ['exec', 'resume', '--help']] }, + mistralVibe: { install: 'curl -LsSf https://mistral.ai/vibe/install.sh | bash', help: [['--help']] }, + openCode: { install: 'curl -fsSL https://opencode.ai/install | bash', help: [['run', '--help']] }, + geminiCli: { install: 'npm install -g @google/gemini-cli', help: [['--help']] }, + groqCode: { + install: 'git clone --depth 1 https://github.com/NikolaiRadke/groq-code-cli.git "$RUNNER_TEMP/groq-code-cli" && cd "$RUNNER_TEMP/groq-code-cli" && npm install && npm run build && npm link', + help: [['--help']] + } +}; + +/** + * CLI providers of providerConfigs.js (they have a command to start) + * @returns {Array<{id: string, cfg: Object}>} Providers + */ +function cliProviders() { + return Object.entries(PROVIDER_CONFIGS) + .filter(([, cfg]) => cfg.agentModule && cfg.processConfig?.command) + .map(([id, cfg]) => ({ id, cfg })); +} + +/** + * Load buildArgs() of an agent module without loading the module itself + * (the modules need the extension runtime) + * @param {string} moduleName - Agent module name + * @returns {Function} buildArgs + */ +function loadBuildArgs(moduleName) { + const source = fs.readFileSync(path.join(MODULE_DIR, `${moduleName}.js`), 'utf8'); + const match = source.match(BUILD_ARGS_SOURCE); + if (!match) throw new Error(`no top-level buildArgs() in ${moduleName}.js`); + return new Function(`${match[0]}\nreturn buildArgs;`)(); +} + +/** + * All options AI.duino passes: chat and agentic mode, new and resumed session + * @param {Function} buildArgs - buildArgs of the module + * @returns {string[]} Options + */ +function collectOptions(buildArgs) { + const calls = [ + ['PROMPT', null, false, 'MODEL'], + ['PROMPT', 'SESSION', true, 'MODEL'] + ]; + const parts = calls.flatMap(call => buildArgs(...call)); + return [...new Set(parts.filter(part => typeof part === 'string' && OPTION_PATTERN.test(part)))]; +} + +/** + * Find an executable in PATH + * @param {string} command - Command name + * @returns {string|null} Path + */ +function which(command) { + try { + return execFileSync('which', [command], { encoding: 'utf8' }).split(/\r?\n/).find(Boolean) || null; + } catch { + return null; + } +} + +/** + * Run a CLI and return stdout and stderr (help often goes to stderr) + * @param {string} toolPath - Executable + * @param {string[]} args - Arguments + * @returns {string} Output + */ +function run(toolPath, args) { + const out = spawnSync(toolPath, args, { + encoding: 'utf8', timeout: HELP_TIMEOUT_MS, maxBuffer: MAX_HELP_BUFFER, + stdio: ['ignore', 'pipe', 'pipe'], env: { ...process.env, NO_COLOR: '1', CI: '1' } + }); + return `${out.stdout || ''}${out.stderr || ''}`; +} + +/** + * Does the help text list an option? + * @param {string} help - Help text + * @param {string} option - Option like --model + * @returns {boolean} Found + */ +function helpHasOption(help, option) { + const escaped = option.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + return new RegExp(`(^|[\\s,\\[(])${escaped}(?=[\\s,=\\])<]|$)`, 'm').test(help); +} + +function main() { + const args = process.argv.slice(2); + const providers = cliProviders(); + + if (args.includes('--install')) { + for (const { cfg } of providers) { + if (CLIS[cfg.agentModule]) console.log(`${cfg.agentModule}\t${CLIS[cfg.agentModule].install}`); + } + return; + } + + const all = args.includes('--all'); + let failed = false; + for (const { id, cfg } of providers) { + const cli = CLIS[cfg.agentModule]; + if (!cli) { + console.log(`✗ ${cfg.name}: no entry for '${cfg.agentModule}' in this script`); + failed = true; + continue; + } + let options; + try { + options = collectOptions(loadBuildArgs(cfg.agentModule)); + } catch (e) { + console.log(`✗ ${cfg.name}: ${e.message}`); + failed = true; + continue; + } + const command = cfg.processConfig.command; + const toolPath = which(command); + if (!toolPath) { + console.log(`${all ? '✗' : '-'} ${cfg.name} (${id}): '${command}' not installed${all ? '' : ', skipped'}`); + failed = failed || all; + continue; + } + const version = run(toolPath, ['--version']).trim().split(/\r?\n/)[0]; + const help = cli.help.map(helpArgs => run(toolPath, helpArgs)).join('\n'); + const missing = options.filter(option => !helpHasOption(help, option)); + console.log(`${missing.length ? '✗' : '✓'} ${cfg.name} (${version || '?'}): ${options.join(' ')}`); + missing.forEach(option => console.log(` option not in help: ${option}`)); + failed = failed || missing.length > 0; + } + process.exit(failed ? 1 : 0); +} + +main(); diff --git a/.github/workflows/cli-provider-check.yml b/.github/workflows/cli-provider-check.yml new file mode 100644 index 0000000..a11663d --- /dev/null +++ b/.github/workflows/cli-provider-check.yml @@ -0,0 +1,64 @@ +# Installs every CLI provider and checks the options AI.duino passes against the +# real CLIs. The CLIs change without AI.duino changing anything, so this runs +# weekly before the scheduled task "AI.duino Provider-Config Wochencheck", which +# reads the result. Deliberately not a gate on providerConfigs.js PRs: the options +# live in the extension code, so a failure here needs a release, not a config fix. +name: CLI provider check + +on: + schedule: + - cron: '47 3 * * 1' # Mondays 03:47 UTC, before the scheduled task in winter and summer time + workflow_dispatch: + push: + branches: [main] + paths: + - 'aiduino/extension/out/localProviders/processProviders/**' + - '.github/scripts/check-cli-providers.js' + - '.github/workflows/cli-provider-check.yml' + pull_request: + paths: + - 'aiduino/extension/out/localProviders/processProviders/**' + - '.github/scripts/check-cli-providers.js' + - '.github/workflows/cli-provider-check.yml' + +permissions: + contents: read + +jobs: + check: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + + # The install commands are part of the check: a broken one fails the run + - name: Install CLIs + shell: bash + run: | + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + echo "$HOME/.opencode/bin" >> "$GITHUB_PATH" + export PATH="$HOME/.local/bin:$HOME/.opencode/bin:$PATH" + failed=0 + while IFS=$'\t' read -r id command; do + echo "::group::$id: $command" + (bash -c "$command" < /dev/null) || { echo "::error::Install of $id failed: $command"; failed=1; } + echo "::endgroup::" + done < <(node .github/scripts/check-cli-providers.js --install) + exit $failed + + # Also after a failed install, so the report shows everything at once + - name: Check options + if: success() || failure() + shell: bash + run: | + set -o pipefail + node .github/scripts/check-cli-providers.js --all | tee "$RUNNER_TEMP/cli-report.txt" + + - name: Job summary + if: always() + run: | + { echo '### CLI provider check'; echo '```'; cat "$RUNNER_TEMP/cli-report.txt" 2>/dev/null; echo '```'; } >> "$GITHUB_STEP_SUMMARY"