Skip to content

v3.1.0

Choose a tag to compare

@github-actions github-actions released this 26 Oct 03:01
· 18 commits to main since this release

English

Added

  • OpenCode 2 support. One package now loads on both OpenCode 1.x and 2.x. Thanks @vitaly74 (#6). How it works:
    • The default export is a single object that satisfies both loaders. OpenCode 2 looks for { id, setup }: setup(ctx) registers the opencode_sync tool through ctx.tool.transform, subscribes to session.idle through ctx.event.subscribe for the optional idle push, and runs the startup pull. OpenCode 1.x (1.3.4 and later) sees the same object's id and server() and calls server() once, so the plugin is registered exactly once.
    • No dependency on @opencode/plugin; the V2 context is used structurally.
    • Config key. OpenCode 1.x reads only "plugin" and silently drops "plugins". OpenCode 2 reads its native "plugins" and still accepts the legacy "plugin". So "plugin": ["opencode-github-sync"] is the one form that works on both, and it is what the README recommends. A 2.x-only setup may use "plugins", but never list the plugin under both keys: 2.x loads both lists.
    • Plugin cache pruning reads both keys, so a mixed fleet where some machines are on 1.x and some on 2.x keeps every plugin either version needs.
    • OpenCode 1.0–1.3.3 iterate every export and call each as a function, which the new object default export cannot satisfy. Stay on 3.0.1 there.

Fixed

  • Session import no longer cascade-deletes sessions. INSERT OR REPLACE deletes the conflicting row before inserting, so replacing a shared project row cascaded through ON DELETE CASCADE and removed every session imported before it. It is replaced by a real INSERT ... ON CONFLICT DO UPDATE upsert that never deletes and keeps newer-time_updated-wins per row. Reported with a tested fix by @logser13, cascade analysis by @aquelejota (#2).
  • The synthetic global project is machine-specific, so it is no longer exported, and importing an older shard that carries it never overwrites the local row. Reported by @logser13, confirmed by @aquelejota (#4).
  • Session shard export is deterministic: an unchanged session produces a byte-identical shard, so it no longer shows up as a change on every push. Reported by @logser13 (#3), fixed by @aquelejota (#5).
  • The session tests now actually run under vitest; previously node:sqlite failed to load there and every session test returned early. Found and fixed by @aquelejota (#5).
  • Plugin cache pruning reads both the plugin and plugins keys and understands [spec, options] tuples and { package } objects, so a plugin listed in either form is no longer pruned from the cache. Follow-up to @vitaly74's #6.

Changed

  • The minimum supported OpenCode 1.x is now 1.3.4. OpenCode 1.0–1.3.3 cannot load this release; stay on 3.0.1 there.

简体中文

新增

  • 支持 OpenCode 2。 同一个包现在在 OpenCode 1.x 和 2.x 上都能加载。感谢 @vitaly74(#6)。原理如下:
    • 默认导出是一个同时满足两种加载方式的对象。OpenCode 2 找的是 { id, setup }:setup(ctx) 通过 ctx.tool.transform 注册 opencode_sync 工具,通过 ctx.event.subscribe 监听 session.idle 以支持可选的空闲推送,并在启动时拉取一次。OpenCode 1.x(1.3.4 及以上)看到的是同一个对象上的 id 和 server(),只调用一次 server(),所以插件只注册一次,不会重复。
    • 不依赖 @opencode/plugin,V2 的上下文按结构直接使用。
    • 配置写法。 OpenCode 1.x 只读 "plugin",遇到 "plugins" 会直接丢掉且不报错;OpenCode 2 读自己的新写法 "plugins",同时也认旧的 "plugin"。所以 "plugin": ["opencode-github-sync"] 是两个版本都能用的唯一写法,README 也推荐这样写。只用 2.x 的话可以写 "plugins",但不要两个键里都写这个插件,2.x 会把两个列表都加载一遍。
    • 清理插件缓存时同时读取两个键,有的机器在 1.x、有的在 2.x 时,两个版本需要的插件都不会被误删。
    • OpenCode 1.0–1.3.3 会把每个导出都当函数调用,新的对象形式默认导出满足不了,这些版本请继续使用 3.0.1。

修复

  • 导入会话不再连带删除其他会话。INSERT OR REPLACE 会先删掉冲突的行再插入,替换共享的 project 行时会通过 ON DELETE CASCADE 把之前导入的会话全部删掉。现在改用真正的 INSERT ... ON CONFLICT DO UPDATE,从不删除行,并且按行保留 time_updated 较新的一方。由 @logser13 报告并附上验证过的修法,@aquelejota 补充了连带删除的分析(#2)。
  • 合成的 global 项目属于每台机器自己,不再导出;导入带有它的旧分片时,也不会覆盖本机的那一行。由 @logser13 报告,@aquelejota 确认(#4)。
  • 会话分片导出现在是确定的:没有变化的会话生成的分片逐字节相同,不会在每次推送时都显示为改动。由 @logser13 报告(#3),@aquelejota 修复(#5)。
  • 会话测试现在真的会在 vitest 下运行。以前 node:sqlite 在那里加载失败,每个会话测试都提前返回。由 @aquelejota 发现并修复(#5)。
  • 清理插件缓存时同时读取 plugin 和 plugins 两个键,并识别 [spec, options] 元组和 { package } 对象,无论用哪种写法列出的插件都不会再被误删缓存。这是对 @vitaly74 #6 的补充修改。

变更

  • OpenCode 1.x 的最低支持版本变为 1.3.4。OpenCode 1.0–1.3.3 无法加载此版本,请继续使用 3.0.1。

Install

npm install -g opencode-github-sync@3.1.0

Plugin users: OpenCode picks up the new version on its next start.

Contributors

Thank you to everyone who made this release possible:

What's Changed

  • fix: make session shard export deterministic by @aquelejota in #5
  • Add OpenCode 2 plugin entrypoint (dual V1+V2 export) by @vitaly74 in #6

New Contributors

Full Changelog: v3.0.1...v3.1.0