npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@melodyoftears/opencode-qwen-auth

v1.3.7

Published

Qwen OAuth authentication plugin for OpenCode - Access Qwen AI models (Coder, Vision) with your qwen.ai account

Readme

OpenCode Qwen Auth 插件

npm version npm downloads GitHub stars

使用 qwen.ai 账号为 OpenCode CLI 登录。该插件可让你使用 Qwen OAuth 模型(coder-modelvision-model),享受每天免费请求额度,无需 API Key 或信用卡。

English

功能

  • OAuth Device Flow (RFC 8628) - 基于浏览器的安全登录
  • PKCE 支持 (RFC 7636) - 增强公共客户端安全性
  • 自动轮询 - 授权完成后自动检测,无需手动输入
  • Token 自动刷新 - 过期前自动续期
  • 兼容 qwen-code - 复用 ~/.qwen/oauth_creds.json 凭据
  • 免费额度 - 通过 OAuth 每天 2,000 次请求

前置条件

  • 已安装 OpenCode CLI
  • 一个 qwen.ai 账号(可免费注册)

安装

1. 安装插件

cd ~/.opencode && npm install @melodyoftears/opencode-qwen-auth

2. 启用插件

编辑 ~/.opencode/opencode.jsonc

{
  "plugin": ["@melodyoftears/opencode-qwen-auth"]
}

使用

1. 登录

opencode auth login

2. 选择 Provider

选择 "Other",输入 qwen-code

3. 完成授权

选择 "Qwen Code (qwen.ai OAuth)"

  • 浏览器会自动打开授权页
  • 插件自动轮询并检测授权完成
  • 无需复制验证码或手动回车

可用模型

| 模型 | ID | 输入 | 输出 | 上下文 | 最大输出 | |------|----|------|------|--------|----------| | Qwen Coder (Qwen 3.5 Plus) | coder-model | text | text | 1M tokens | 65,536 tokens | | Qwen VL Plus (Vision) | vision-model | text, image | text | 128K tokens | 8,192 tokens |

指定模型运行

opencode --provider qwen-code --model coder-model
opencode --provider qwen-code --model vision-model

工作原理

  1. Device Flow 打开 chat.qwen.ai 授权页面
  2. 插件自动轮询授权结果
  3. 凭据保存到 ~/.qwen/oauth_creds.json
  4. Access Token 在到期前 30 秒自动刷新

使用限制

| 计划 | 频率限制 | 每日限制 | |------|----------|----------| | 免费(OAuth) | 60 req/min | 2,000 req/day |

配额按 UTC 零点重置。

故障排查

Token 过期或异常

插件会自动刷新 Token。如仍有问题:

# 删除旧凭据
rm ~/.qwen/oauth_creds.json

# 重新登录
opencode auth login

auth login 中看不到 provider

qwen-code 是插件注入的 provider。请在 opencode auth login 中:

  1. 选择 "Other"
  2. 输入 qwen-code

遇到 429 限流

  • 等待 UTC 零点配额重置
  • 配额耗尽时切换账号并重新登录

开发

# 克隆仓库
git clone https://github.com/1579364808/opencode-qwen-auth.git
cd opencode-qwencode-auth

# 安装依赖
bun install

# 构建
bun run build

# 类型检查
bun run typecheck

本地联调

编辑 ~/.opencode/package.json

{
  "dependencies": {
    "@melodyoftears/opencode-qwen-auth": "file:///absolute/path/to/opencode-qwencode-auth"
  }
}

然后重新安装:

cd ~/.opencode && npm install

项目结构

src/
├── constants.ts        # OAuth 端点、模型配置
├── types.ts            # TypeScript 接口
├── index.ts            # 主插件入口
├── cli.ts              # 手动授权 CLI 助手
├── qwen/
│   └── oauth.ts        # OAuth Device Flow + PKCE
├── plugin/
│   ├── auth.ts         # 凭据管理
│   └── utils.ts        # 工具函数
└── errors.ts           # 错误处理

相关项目

链接

支持

如果这个项目帮助到你,可以请我喝杯咖啡:

许可证

MIT