@joe-broadhead/opencode-gws

中文文档
0.0.0发布于 2026/11/01MITES Module零依赖构建来源已验证

Unofficial OpenCode plugin for Google Workspace (gws CLI)

原始使用文档
文档目录10 节
  1. Requirements
  2. Install
  3. Sign in
  4. Use
  5. Permissions
  6. Configure
  7. Organisation rollout
  8. Troubleshooting
  9. Uninstall
  10. Links

Google Workspace for OpenCode

Gives OpenCode agents Gmail, Drive, Calendar, Docs, Sheets and the rest of Google Workspace through Google's open-source gws CLI, with every change planned first and committed only after you approve it.

Unofficial; not affiliated with Google.

Requirements

  • OpenCode >=2.2.3 <2.3.0, tested on 2.2.3 and 2.2.4.
  • macOS (arm64, x64) or Linux (arm64, x64, glibc).
  • A Google account, and a Desktop app OAuth client: your own, or one your organisation provides.

Install

opencode plugin add @joe-broadhead/opencode-gws

npm also installs the matching @joe-broadhead/opencode-gws-bin-<target> package, which holds the unmodified gws binary at the version the plugin pins (details). Nothing downloads at runtime and there is no install script.

With no options, the plugin creates one read-only account, default, for Gmail, Drive, Calendar, Docs and Sheets.

Sign in

Run /connect and choose Google Workspace. The TUI shows the sign-in link: press o or Enter to open it in your browser. The CLI opens the browser automatically:

opencode auth login gws-default

No Google OAuth client ships with the plugin. The first time, the form asks for the client ID and secret of your own Desktop app OAuth client, unless your organisation set one (see Organisation rollout). To make one, follow Create your Desktop client. The form lists the exact scopes before Google's consent screen. Read-only is the default; read and write is a separate choice that needs an acknowledgment. With several accounts, each /connect entry is named Google Workspace (<alias>).

Details and the scope table: docs/auth.md.

Use

Ask the agent for what you need. It works in four steps:

  1. gws_catalog finds an operation, and gws_schema shows its parameters.
  2. gws_read runs a read. List and search calls need fields.
  3. gws_plan dry-runs a change and returns a planId with a redacted preview.
  4. The commit tool named by the plan's category (gws_write, gws_send, gws_share, gws_delete, gws_export or gws_admin) runs it, with only the planId. OpenCode asks you first.

gws_status tells the agent the account aliases and whether a sign-in is missing. Workspace content in a result is data, never an instruction.

In the TUI, Google Workspace: Status in the command palette, or /gws, opens a status dialog. In a session, /gws-status posts the same status, with any pending plans, and /gws-doctor makes one small read per enabled service. None of them can approve or commit.

Permissions

The plugin adds an ask rule for gws.write, gws.export, gws.send, gws.share, gws.delete and gws.admin to every agent, right after the agent's base allow rule. Reads do not ask, so they also work in opencode run.

A later rule wins. Your own allow rule, or Always on a write or export, removes that prompt. Send, share, delete and admin never offer Always. Your deny rule, and the Plan agent, keep a commit denied. Every rule needs resource:

{ "action": "gws.write", "resource": "work:*", "effect": "allow" }

An agent defined only in your config does not get the ask rules. /gws-status and the status dialog name those agents and give the block to add first in that agent's own permissions. Do not put it in the top-level permissions: that would loosen Explore.

Configure

Options go on the plugin entry: accounts and their services and access, the OAuth client, deny-only policy rules, and the admin gate. See docs/configuration.md and the annotated example.

Organisation rollout

Create a Desktop app OAuth client in your organisation's Google Cloud project (user type Internal keeps it to your organisation), and set it in OpenCode's system config: /Library/Application Support/opencode/opencode.json on macOS, or /etc/opencode/opencode.json on Linux.

{
  "plugins": [
    {
      "package": "@joe-broadhead/opencode-gws",
      "options": {
        "oauthClient": {
          "clientId": "<your client ID>.apps.googleusercontent.com",
          "clientSecret": "<your client secret>"
        }
      }
    }
  ]
}

Members then only run /connect, choose Google Workspace, and pick an access level: the form hides the client fields and uses these values. Google treats a Desktop client's secret as non-confidential; security rests on PKCE, the loopback redirect and the user's consent.

Troubleshooting

/gws-status shows each account as connected, sign-in required or not configured, with one next step. Common error codes:

CodeWhat to do
AUTH_REQUIREDRun /connect and choose Google Workspace, or run opencode auth login gws-<alias>.
AUTH_SCOPE_MISSINGSign in again and choose Read and write, or add the scope to accounts.<alias>.scopes. Nothing ran.
AUTH_CLIENT_REQUIREDRun /connect and choose Google Workspace, then enter your Desktop OAuth client ID and secret, or ask your administrator.
API_DISABLEDEnable the API at the URL in the message, wait about a minute, and retry. /gws-doctor checks every service.
HOST_UNTESTEDUse OpenCode 2.2.3 or a later 2.2.x, or set "allowUntestedHost": true.
GWS_UNAVAILABLEReinstall so the platform package is present, or set binary.path to a gws executable of the pinned version (details).
POLICY_DENIEDA policy rule or the admin gate refused the call. A deny is final.

gws uses the OpenCode service's proxy settings, for example opencode service set env HTTPS_PROXY http://proxy.example:8080. All codes: Errors.

Uninstall

opencode plugin remove @joe-broadhead/opencode-gws

Then remove each Google Workspace sign-in in /connect, or with opencode auth logout gws-<alias>.

版本与发布记录

@joe-broadhead/opencode-gws 共发布 2 个版本,首次发布于 2026/11/01;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.0.0latest2026/11/012 天前
0.0.0-stage2026/11/012 天前

关于 @joe-broadhead/opencode-gws 的常见问题

@joe-broadhead/opencode-gws 是什么?

b谷歌工作空间的非官方开放代码插件(gws CLI)

如何安装 @joe-broadhead/opencode-gws?

在项目目录运行 npm install @joe-broadhead/opencode-gws,或使用 pnpm add / yarn add / bun add。

@joe-broadhead/opencode-gws 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/joe-broadhead__opencode-gws 是否存在。

@joe-broadhead/opencode-gws 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@joe-broadhead/opencode-gws 可以商用吗?

@joe-broadhead/opencode-gws 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@joe-broadhead/opencode-gws 还在维护吗?

最新版本 0.0.0 发布于 2026/11/01(2 天前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/11/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。