Skip to content

v3.1.1 — OpenCode 2 support and sync fixes

Choose a tag to compare

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

This release rolls up everything since 3.0.1: the community fixes and OpenCode 2 support from 3.1.0, plus the 3.1.1 sync fixes.

本版本汇总了 3.0.1 之后的全部改动:3.1.0 的社区修复和 OpenCode 2 支持,以及 3.1.1 的同步修复。

English

3.1.1

Fixed

  • A push that rebased onto other machines' commits now writes the merged result out to the real directories (~/.agents/skills, state, data, extra paths). Previously the new files landed only in the repository, a later pull saw nothing incoming and skipped the write-out, and the next push staged the stale local tree and deleted another machine's new skills. A push with nothing local now fast-forwards and writes out the same way.
  • The commit last written out is recorded in .git/info/opencode-sync-stage-out. When HEAD has moved past it (for example a push that stopped after the rebase), the next push or pull writes the repository out before doing anything else, so the gap can no longer be published as deletions.
  • An extraPaths source that does not exist on this machine no longer deletes the shared repository copy. It is skipped and reported; other machines keep receiving it.
  • Writing out a directory extraPaths entry no longer deletes local files that are not in the repository copy, so a tool's runtime files beside its synced config survive a pull. --force still makes it an exact copy. File entries continue to replace only that file.

3.1.0

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.

简体中文

3.1.1

修复

  • 推送时如果先合并了其他机器的提交,现在会把合并后的结果写回本机的真实目录(~/.agents/skills、state、data、额外路径)。以前这些新文件只进了仓库,之后的拉取发现没有新提交就跳过写回,下一次推送又把本机过时的目录打包上去,结果把别的机器刚装的 skill 删掉了。本机没有改动的推送现在会直接快进,并用同样的方式写回。
  • 最近一次写回的提交记录在 .git/info/opencode-sync-stage-out。如果 HEAD 已经越过这个记录(例如推送在合并之后中断),下一次推送或拉取会先把仓库写回本机,再做其他事,这段差异不会再被当成删除推送出去。
  • extraPaths 里的文件在本机不存在时,不再删除仓库里的共享副本,而是跳过并提示,其他机器照常接收。
  • 写回目录类型的 extraPaths 时,不再删除仓库副本里没有的本机文件,同步配置旁边的工具运行文件在拉取后能保留下来。--force 仍然会做成完全一致的副本。文件类型的条目仍然只替换那一个文件。

3.1.0

新增

  • 支持 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.1

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.1