From 17243d7dd3ea019cbf099fb012e69cac8319127b Mon Sep 17 00:00:00 2001 From: baranwang Date: Sat, 7 Nov 2026 09:58:58 +0800 Subject: [PATCH] chore(zen-free): test against current Godwit and split the README Godwit moved its plugin sandbox from goja to moejs, and the model API's SDK is on npm, so checks use the published SDK and a current host pin. The README gets English and zh-Hans versions and says the plugin identifies itself to the upstream as the OpenCode client. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/plugins.yml | 19 ++++++++----------- README.md | 15 ++++++--------- packages/zen-free/README.md | 22 ++++++++++++---------- packages/zen-free/README.zh-Hans.md | 21 +++++++++++++++++++++ packages/zen-free/build.test.ts | 2 +- packages/zen-free/build_test.go | 7 ++++--- 6 files changed, 52 insertions(+), 34 deletions(-) create mode 100644 packages/zen-free/README.zh-Hans.md diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 2c44d2b..d347b80 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -73,11 +73,11 @@ jobs: - name: Require a tagged commit from main for releases if: github.event_name == 'workflow_dispatch' run: git merge-base --is-ancestor HEAD origin/main - # Pin the host/API used by the real goja integration test. + # Pin the host/API used by the real sandbox integration test. - uses: actions/checkout@v7 with: repository: godwit-email/godwit - ref: 95eb0180654353e4e0a026a33258d6f9f0c6fb54 + ref: 40cad22278abd39582db8effdbbd41b613e614f5 path: .godwit-ci - uses: actions/setup-go@v7 with: @@ -86,17 +86,14 @@ jobs: - uses: oven-sh/setup-bun@v2 with: bun-version: 1.4.3 - - name: Install published SDK for releases - if: github.event_name == 'workflow_dispatch' + # core/plugins imports internal/i18n, whose catalog_gen.go is generated and not committed. + - name: Generate the pinned host's sources + run: | + (cd "$GODWIT_CHECKOUT/web" && bun install --frozen-lockfile) + cd "$GODWIT_CHECKOUT" && go tool mygo generate + - name: Install published SDK working-directory: packages/${{ matrix.plugin }} run: bun install --no-save --ignore-scripts - - name: Install packed SDK for source checks - if: github.event_name != 'workflow_dispatch' - working-directory: packages/${{ matrix.plugin }} - run: | - # shortcut: model types ship in the next SDK release; use the pinned API until then. - (cd "$GODWIT_CHECKOUT/sdk" && bun pm pack --ignore-scripts --filename "$RUNNER_TEMP/godwit-sdk.tgz") - bun add --dev --no-save --ignore-scripts "@godwit/sdk@file:$RUNNER_TEMP/godwit-sdk.tgz" - run: bun run --bun typecheck working-directory: packages/${{ matrix.plugin }} - run: bun test scripts diff --git a/README.md b/README.md index fd235e6..7678696 100644 --- a/README.md +++ b/README.md @@ -85,23 +85,20 @@ Each `packages//` contains `plugin.json` and `package.json`, whose scripts write `dist/plugin.json` and a bundled `dist/index.js`. New packages join the shared CI without adding a workflow. -1. Release Godwit 1.7.0 or later with model plugin support; its release publishes the matching - `@godwit/sdk` version. The published 1.6.0 SDK predates the model API. -2. Bump `packages//package.json` and `plugin.json` together and merge to main. -3. Create and push `-vX.Y.Z` for that main commit. -4. Run **Actions → Plugins → Run workflow** on main, supplying the plugin name, tag, and actual +1. Bump `packages//package.json` and `plugin.json` together and merge to main. +2. Create and push `-vX.Y.Z` for that main commit. +3. Run **Actions → Plugins → Run workflow** on main, supplying the plugin name, tag, and actual minimum released Godwit version. The workflow checks the tagged source, installs the published SDK, and publishes `index.js`, `plugin.json`, `.tar.gz`, `registry-plugin.json`, and `SHA256SUMS` to GitHub Releases. -5. Copy the release from the released `registry-plugin.json` into the plugin's +4. Copy the release from the released `registry-plugin.json` into the plugin's `packages//godwit-plugin.json`, preserving older releases, and merge it. Then open a PR that sets the plugin's `source.sha` in `directory.json` to that commit (a new plugin: adds its entry, whose title, summary and risk wording are the reviewers'). **Publish** builds the registry, validates the real downloads, signs, and uploads it. -PR checks provide a `-dist` artifact. Until the model API's SDK is published, they -pack it from the pinned Godwit commit used by the goja integration test. Release runs -install the published SDK from npm. Update the host pin when updating the SDK/API. +PR checks provide a `-dist` artifact. Checks and release runs install the published SDK +from npm and test against the pinned Godwit commit. Update the pin when updating the SDK/API. Release runs require `contents: write`. If a failed run leaves a draft release, inspect and delete that unpublished draft before retrying. Never replace published files; bump the version instead. The workflow does not modify the registry. diff --git a/packages/zen-free/README.md b/packages/zen-free/README.md index bfa53c2..be8f9dd 100644 --- a/packages/zen-free/README.md +++ b/packages/zen-free/README.md @@ -1,19 +1,21 @@ # Zen Free for Godwit -在 Godwit 中使用 OpenCode Zen 的免费模型,无需 API Key。 +Use OpenCode Zen's free models in Godwit, with no API key. -## 使用 +[简体中文](README.zh-Hans.md) -插件尚未发布。发布并收录后: +## Use -1. 打开 Godwit「设置 → 扩展」,在插件目录中安装 Zen Free。 -2. 启用插件,允许它声明的网络权限。 -3. 打开「设置 → 模型服务」,选择 Zen Free 的模型。 +The plugin is not released yet. Once it is listed: -可用模型由上游免费目录决定,无需手动配置接口或协议。需要支持模型插件的 Godwit 版本。 +1. Open Godwit **Settings → Extensions** and install Zen Free from the plugin directory. +2. Enable the plugin and allow the network access it declares. +3. Open **Settings → Model Services** and choose a Zen Free model. -## 数据与可用性 +The available models follow the upstream free catalog; there is no endpoint or protocol to set up. -使用模型时,提示、邮件上下文、工具定义及工具结果会发送到 OpenCode 及其模型服务商,请阅读上游的数据使用条款。 +## Data and availability -插件依赖非官方公共接口。免费模型、限流和免费期限可能变化,不保证配额或持续可用。 +When you use a model, prompts, mail context, tool definitions and tool results are sent to OpenCode and its model providers. Read their data terms before using it with mail you care about. + +The plugin relies on an unofficial public interface and identifies itself to it as the OpenCode client. Free models, rate limits and free periods can change, and neither quota nor continued availability is guaranteed. diff --git a/packages/zen-free/README.zh-Hans.md b/packages/zen-free/README.zh-Hans.md new file mode 100644 index 0000000..bfd4444 --- /dev/null +++ b/packages/zen-free/README.zh-Hans.md @@ -0,0 +1,21 @@ +# Zen Free for Godwit + +在 Godwit 中使用 OpenCode Zen 的免费模型,无需 API Key。 + +[English](README.md) + +## 使用 + +插件尚未发布。发布并收录后: + +1. 打开 Godwit「设置 → 扩展」,在插件目录中安装 Zen Free。 +2. 启用插件,允许它声明的网络权限。 +3. 打开「设置 → 模型服务」,选择 Zen Free 的模型。 + +可用模型由上游免费目录决定,无需手动配置接口或协议。 + +## 数据与可用性 + +使用模型时,提示、邮件上下文、工具定义及工具结果会发送到 OpenCode 及其模型服务商,请阅读上游的数据使用条款。 + +插件依赖非官方公共接口,并以 OpenCode 客户端的身份访问它。免费模型、限流和免费期限可能变化,不保证配额或持续可用。 diff --git a/packages/zen-free/build.test.ts b/packages/zen-free/build.test.ts index 558f72d..145961d 100644 --- a/packages/zen-free/build.test.ts +++ b/packages/zen-free/build.test.ts @@ -1,7 +1,7 @@ import {expect,test} from "bun:test" import {resolve} from "node:path" const checkout=process.env.GODWIT_CHECKOUT -test.skipIf(!checkout)("built plugin runs in Godwit's actual goja sandbox",()=>{ +test.skipIf(!checkout)("built plugin runs in Godwit's actual plugin sandbox",()=>{ const built=Bun.spawnSync(["bun","run","build.ts"],{cwd:import.meta.dir});expect(built.exitCode).toBe(0) const host=Bun.spawnSync(["go","test",resolve(import.meta.dir,"build_test.go"),"-count=1"],{cwd:checkout,env:{...process.env,GODWIT_ZEN_FREE_DIST:resolve(import.meta.dir,"dist")},timeout:120000}) if(host.exitCode!==0)throw new Error(host.stdout.toString()+host.stderr.toString()) diff --git a/packages/zen-free/build_test.go b/packages/zen-free/build_test.go index e09fb6b..2f03cd8 100644 --- a/packages/zen-free/build_test.go +++ b/packages/zen-free/build_test.go @@ -8,7 +8,7 @@ import ( "path/filepath" "testing" - "github.com/dop251/goja" + "github.com/MoeForge/moejs" "github.com/godwit-email/godwit/core/plugins" "github.com/stretchr/testify/require" ) @@ -43,9 +43,10 @@ func TestZenFree(t *testing.T) { require.NoError(t, err) code, err := plugins.Build(dist, m.Main) require.NoError(t, err) - program, err := goja.Compile("zen-free", string(code), true) + mod, err := moejs.Compile("zen-free.js", string(code)) + require.NoError(t, err) + vm, err := plugins.NewVM("zen-free", mod, plugins.VMOptions{}) require.NoError(t, err) - vm := plugins.NewVM("zen-free", program, plugins.VMOptions{}) t.Cleanup(vm.Close) cfg := &plugins.ConfigSnapshot{Values: map[string]any{}} p, err := plugins.Load(context.Background(), vm, m, catalogHost{}, cfg)