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

@heimoshuiyu/opencode-goal-plugin

v1.0.0

Published

OpenCode plugin that enables autonomous goal-driven agent mode with multi-turn continuation, independent completion verification, and interrupt auto-pause

Readme

OpenCode Goal 插件

一个 OpenCode 插件,用于启用自主目标驱动模式。设定一个目标,智能体将跨多个 turn 自主工作——读取、编写、编辑和验证——直到目标完全达成。

功能

  • 自主多轮执行 — 智能体在多个 turn 之间持续工作,直到目标达成。
  • 目标生命周期管理 — 通过专用的 goal 工具创建、暂停、恢复、取消和完成目标。
  • 独立完成验证 — 内置的 goal-verify 子智能体在标记目标完成前,从零开始独立检查代码库。
  • 中断自动暂停 — 按下 Esc 会自动暂停目标,而非触发下一轮续跑。
  • 会话持久化 — 目标状态存储在 Session.metadata(SQLite)中,服务器重启后不丢失。
  • 会话分支继承 — 分支的会话自动继承父会话的目标状态。

工作原理

用户: /goal 实现用户登录功能
  │
  ▼
┌──────────────────────────────────────────────┐
│  Turn 1                                       │
│  - 读取 /goal 命令模板                         │
│  - 调用 goal({op:"create", ...})              │
│  - 开始工作(read、edit、bash 等)              │
└──────────────┬───────────────────────────────┘
               │
               ▼  (session.status → idle)
┌──────────────────────────────────────────────┐
│  插件事件钩子                                   │
│  1. 接收 session.status idle 事件              │
│  2. 读取 Session.metadata.goal → active       │
│  3. client.promptAsync(continuationPrompt)    │
└──────────────┬───────────────────────────────┘
               │
               ▼
┌──────────────────────────────────────────────┐
│  Turn 2(自主续跑)                             │
│  - 继续工作...                                 │
└──────────────┬───────────────────────────────┘
               │
               ▼  (循环,直到目标完成)
┌──────────────────────────────────────────────┐
│  智能体调用 goal({op:"complete"})              │
│  → 被阻止:必须使用 goal-verify 子智能体        │
│  → 子智能体独立检查代码库                        │
│  → 验证通过 → 目标标记为完成                     │
│  → 验证未通过 → 智能体继续工作                   │
└──────────────────────────────────────────────┘

安装

OpenCode 配置文件 中添加插件:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-goal-plugin"]
}

OpenCode 会在下次运行时自动安装插件。

使用

启动目标

在聊天中输入 /goal,后跟你的目标:

/goal 重构认证模块,改用 JWT 令牌

智能体会创建目标,然后跨多个 turn 自主工作。

目标工具操作

goal 工具支持以下操作:

| 操作 | 描述 | | ------------ | ---------------------------------------------------------- | | create | 创建新目标。需要 objectivecompletion_criterion。 | | get | 返回当前目标状态。 | | pause | 暂停活跃的目标。 | | resume | 恢复已暂停的目标。 | | cancel | 完全丢弃当前目标。 | | complete | 标记目标为完成(触发验证子智能体)。 |

完成验证

当智能体认为目标已完成时,会调用 goal({op:"complete"})。此操作在主会话中被阻止——取而代之的是启动 goal-verify 子智能体,独立检查代码库:

  1. 通过 goal({op:"get"}) 获取目标和完成标准。
  2. 针对当前状态验证每个交付物(读取文件、运行测试、检查集成)。
  3. 如果所有要求都满足 → 标记目标完成。
  4. 如果发现任何差距 → 返回报告,主智能体继续工作。

这防止了过早完成,确保基于真实证据的验证。

中断

在智能体执行期间按 Esc 可中断。插件会检测中断事件并自动暂停目标——不会触发意外的续跑。

之后可以通过 /goal resume 或让智能体继续来恢复。

插件钩子

| 钩子 | 用途 | | ------------------------------------ | ------------------------------------------------- | | tool | 注册 goal 工具 | | config | 注入 /goal 命令和 goal-verify 子智能体 | | chat.message | 向子智能体消息注入目标上下文 | | command.execute.before | 将 /goal 模板部分标记为 synthetic(隐藏) | | event | 监听 idle/abort 事件以触发续跑/暂停 |

许可证

MIT