@ever-works/opencode-plugin

中文文档
1.0.18发布于 2026/11/03AGPL-3.0TypeScriptESM + CJS构建来源已验证近 30 天下载 2609

OpenCode Generator Plugin - Full pipeline plugin that delegates generation to OpenCode

原始使用文档
文档目录13 节
  1. Plugin metadata
  2. Pipeline Steps
  3. AI Provider Integration
  4. Settings
  5. Form Schema
  6. Prompt System
  7. Binary Management
  8. Error Handling
  9. Project Structure
  10. Development
  11. Troubleshooting
  12. Documentation
  13. License

@ever-works/opencode-plugin

Full pipeline plugin that delegates work generation to the OpenCode CLI. A single OpenCode CLI session autonomously handles web search, content creation, and file generation inside a temporary workspace while using the active Ever Works AI provider for model access.

Plugin metadata

FieldValue
IDopencode
Categorypipeline
Capabilitiespipeline, form-schema-provider
AuthorEver Works Team
LicenseAGPL-3.0
Built-inyes
Auto-enableno

Pipeline Steps

The plugin runs 6 sequential steps:

#StepDescriptionOptional
1Setup OpenCodeDownloads/caches the OpenCode CLI binary from GitHubNo
2Prepare ContextCreates a temp workspace, seeds existing items and metadataNo
3Generate ItemsExecutes OpenCode CLI to research and generate items as JSON filesNo
4Collect ResultsReads generated JSON files back into the pipeline resultNo
5Capture ScreenshotsTakes screenshots for generated items (via screenshot provider)Yes
6CleanupRemoves the temporary workspaceYes

During step 3, a taxonomy watcher monitors the workspace for new item files and keeps _meta/ taxonomy files (categories, tags, brands) in sync in real time. Progress is reported per item as files appear.

AI Provider Integration

OpenCode does not ask the user to configure a separate provider, auth mode, or model inside this plugin.

Instead, it resolves the active Ever Works ai-provider for the current { userId, workId } context and generates an isolated OpenCode config for the run:

  • Provider base URL and API key come from execContext.aiFacade.getProviderConfig(...)
  • Model selection comes from the AI provider routing config (complexModel first, then defaultModel)
  • OpenCode runs with a user-scoped, isolated config work rather than machine-global auth state
  • Web tools are explicitly enabled, including websearch

Settings

SettingTypeScopeDescription
versionstringhiddenOpenCode CLI version to install (default: v1.0.223)

Form Schema

The plugin provides a user-facing form with two configurable fields:

FieldTypeDefaultValidationDescription
target_itemsnumber501-500Target number of new items to generate
capture_screenshotsbooleanfalse-Take screenshots for generated items

Prompt System

Prompts are managed through a prompt facade (e.g., Langfuse). When no external prompt is found, hardcoded defaults are used as fallback.

Prompt keys:

  • opencode.system — System prompt template
  • opencode.user — User prompt template

Both support variable substitution for work context, existing items, categories, tags, and brands.

Binary Management

The plugin downloads the OpenCode CLI binary from GitHub releases:

  • Binaries are cached at {tmpdir}/opencode-generator/bin/opencode-{version}-{platform}/
  • Platform detection: linux-x64, linux-arm64, darwin-x64, darwin-arm64
  • SHA-256 checksum verification when available
  • Default version: v1.0.223

Error Handling

  • Non-zero exit codes: Treated as soft warnings. If items were still produced, the result succeeds with warnings attached.
  • Empty results: If OpenCode completes without producing any valid item JSON files, an error is thrown with CLI output excerpts for debugging.
  • Missing AI provider config: The pipeline fails early if the resolved Ever Works AI provider does not expose a base URL, API key, or runnable model.

Project Structure

src/
  opencode.plugin.ts       # Main plugin class (IPlugin, IPipelinePlugin, IFormSchemaProvider)
  types.ts                 # Step IDs, constants
  steps.ts                 # Pipeline step definitions
  form-schema.ts           # Form fields, groups, validation
  prompt-keys.ts           # Prompt facade keys
  index.ts                 # Public exports
  prompt/
    system-prompt.ts       # Default prompts and variable builders
  utils/
    binary-manager.ts      # CLI download from GitHub releases
    opencode-config.ts     # User-scoped OpenCode config generation and cleanup
    pipeline-helpers.ts    # State management, settings resolution, progress reporting
    process-runner.ts      # OpenCode CLI subprocess execution
    workspace-manager.ts   # Workspace I/O (create, seed, read, cleanup)
    screenshot-capture.ts  # Screenshot facade integration
    taxonomy-sync.ts       # Merge new categories/tags/brands into _meta files
    taxonomy-watcher.ts    # Filesystem watcher for live taxonomy sync
    platform.ts            # Platform/architecture detection

Development

# Build
pnpm build

# Type-check
pnpm type-check

# Run tests
pnpm test

# Watch mode
pnpm test:watch

# Coverage
pnpm test:coverage

Troubleshooting

SymptomLikely causeFix
Generation never starts / stays at 0%opencode not selected as the active pipeline plugin for this workOpen the work → Plugins → pipeline capability and set opencode as the active pipeline; or set it as the global pipeline default in Settings → Plugins
Step fails with No AI / search / screenshot provider configuredPipeline depends on capability plugins that are not enabled or have no credentialsEnable and configure the matching capability plugin (AI provider, search, screenshot, content-extractor) for the work or globally
Step output looks wrong / genericForm-field tuning not set; pipeline using defaults that don't match the work's domainOpen the Generator Form for the work, set domain-specific fields (categories, target keywords, source URLs), and re-run the affected step
Subprocess error: command not foundOpenCode Generator CLI not installed on the host running the APIInstall the OpenCode Generator CLI on the API host and ensure it is on PATH; verify by running which <cli> from the same shell that launches pnpm dev:api
Authentication / device-auth flow stallsDevice-auth code never confirmed in the upstream IDE / browserRe-run the device-auth flow from Settings → Plugins → opencode → Connect, then complete the prompt in the upstream service before the code expires
Pipeline cannot resume after host restartCheckpoint not persisted (only the standard pipeline persists checkpoints today)Cancel the stuck run and re-trigger generation; for production reliability prefer standard-pipeline

Documentation

License

AGPL-3.0

版本与发布记录

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

版本发布日期距今
1.0.18latest2026/11/0310 天前
1.0.172026/10/2817 天前
1.0.162026/10/2717 天前
1.0.152026/10/2717 天前
1.0.142026/10/2420 天前
1.0.132026/10/2025 天前

关于 @ever-works/opencode-plugin 的常见问题

@ever-works/opencode-plugin 是什么?

OpenCode Generator Plugin - Full pipeline plugin that delegates generation to OpenCode

如何安装 @ever-works/opencode-plugin?

在项目目录运行 npm install @ever-works/opencode-plugin,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@ever-works/plugin(^1.2.16)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@ever-works/opencode-plugin 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ever-works/opencode-plugin 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@ever-works/opencode-plugin 可以商用吗?

@ever-works/opencode-plugin 使用 AGPL-3.0 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@ever-works/opencode-plugin 的下载量有多少?

根据 npm 官方下载统计,@ever-works/opencode-plugin 在 2026/10/14 – 2026/11/12 这 30 天内被下载 2,609 次,日均约 87 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ever-works/opencode-plugin 还在维护吗?

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