cli: opencode models <provider> filter from v1 is rejected in v2 ("Unexpected positional argument")

未关闭 适合新手
#68,364 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@nilparra-dev 已经在做这个了。

开始于 2026年12月4日。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
cli

调研方向

阅读 packages/cli/src/commands/commands.ts:348 中的 models 命令规范,以及 packages/cli-rs/crates/cli/src/args.rs:416 中的 Rust CLI 规范;目前两者都未声明供应商参数。将它们与 issue 中引用的 V1 命令和文档进行比较,然后确定当前 CLI 如何处理命令参数。供应商筛选器能够正常工作,或有文档说明的替代方案和迁移指南处理被拒绝的参数,即为完成。

由索引模型根据 Issue 内容生成。

描述

area/cli platform/macos type/feature version/v2

Summary

OpenCode 1 documented an optional provider argument for opencode models (opencode models [provider], e.g. opencode models vultr). OpenCode 2 rejects that argument, so the documented command exits 1 after printing help instead of listing the provider's models, and V2 has no equivalent filter flag.

Environment

  • opencode version: 2.4.4 (matches the latest release, v2.4.4)
  • Client: CLI (opencode models, opencode run) against both the shared background service and a server started with opencode serve
  • Model and provider: vultr (provider supplied by the @vultr/model-provider-opencode plugin); the argument failure is provider-independent
  • OS: Darwin 27.2.0 (darwin arm64)
  • Terminal: TERM=xterm-256color; TERM_PROGRAM/COLORTERM unset (non-TTY shell, so the app itself is Unavailable)
  • Shell: /bin/zsh
  • Install/channel: latest; two installs on this machine — ~/.opencode/bin/opencode v2.4.4 and the desktop app's bundled ~/Library/Application Support/ai.opencode.desktop/cli/2.4.4-arm64/opencode-cli serve --service
  • Active plugins: vultr.model-provider (@vultr/[email protected], state active) plus built-ins (opencode.tool.input.repair, opencode.config.worktree, …). Nothing in plugins of ~/.config/opencode/cli.json, and no local plugin dirs.

Reproduction

  1. Run opencode models — prints provider/model lines for every enabled provider, including the plugin's models. Works.
  2. Run opencode models vultr — the V1 form for filtering to one provider.
  3. Run opencode models anthropic — same failure, so it is not provider-specific.
  4. Run opencode models --help — USAGE opencode models [flags], with only the global server flags (--standalone, --server, …).

Step 2 exits with code 1 and prints the models help, then the global flag list, then:

ERROR
  Unexpected positional argument: "vultr"

Expected Behavior

Either:

  1. opencode models [provider] keeps V1's behaviour and filters the list to that provider; or
  2. V2 ships a documented replacement (e.g. opencode models --provider <id>), and the V1→V2 migration guide states that the positional filter was dropped and what to use instead.

Actual Behavior

The positional argument is rejected (exit 1), and the error text appears only after the full help dump, so it reads like the command is broken rather than like an unsupported argument. There is no flag to filter by provider either, so opencode models | grep '^vultr/' is the only way to get the list V1 produced with one command.

This is not the only V1 surface of this command that is gone (--refresh and --verbose — see #53682), and V2's CLI docs (https://opencode.ai/docs/cli) do not document models at all, so the V1 page is what users and third-party guides still follow.

Additional Context

Spec in a v2 checkout (branch local, 185232200c, version 2.4.4):

  • packages/cli/src/commands/commands.ts:348 — the models spec declares only globalFlags: ServerFlags: no positional argument, no --refresh, no --verbose.
  • packages/cli-rs/crates/cli/src/args.rs:416 — Spec::new("models", "List all available models").globals(SERVER_FLAGS).

V1 behaviour and docs (the filter is still documented there):

  • V1 CLI docs: https://opencode.ai/v1/docs/cli — "You can optionally pass a provider ID to filter models by that provider." with the example opencode models anthropic.
  • V1 implementation, packages/opencode/src/cli/cmd/models.ts (package removed in 44b6938b2a):
export const ModelsCommand = effectCmd({
  command: "models [provider]",
  describe: "list all available models",
  builder: (yargs) =>
    yargs
      .positional("provider", { describe: "provider ID to filter models by", type: "string", array: false })
      .option("verbose", { … })
      .option("refresh", { … }),

Related issues, none of which covers this:

  • #53682 — opencode models --refresh / --verbose removed in the V2 rewrite (same command, the flags rather than the positional argument).
  • #56218 — opencode -m provider/model no longer accepted on the root command (same class of V1 CLI surface loss).
  • #49986 — V1 config whitelist / blacklist model filtering dropped in V2 (config surface, not the CLI).

Why this matters beyond convenience: provider integration guides aimed at OpenCode users still print the V1 command. Vultr's OpenCode integration page, for example, tells users to run opencode models vultr to check that its plugin's live model list was picked up. On OpenCode 2 that command fails with the message above, which looks like a broken provider rather than a removed CLI argument — exactly when the user is trying to verify a provider fix.

Reproducibility: consistent on 2.4.4, with the shared service, with --standalone, and against an explicit --server <url>. No config or plugin is needed to reproduce the argument rejection itself.

主要语言
TypeScript
星标
230k
派生
31.3k
平均合并
5 小时 44 分钟
30 天内合并 PR
529

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode 的其他 Issue

查看 anomalyco/opencode 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。