* fix(opencode): preserve v2 directory packages
Stage the reviewed issue 913 source for isolated fork validation. Preserve
package directories and manifests without executing managed packages or
installing their dependencies, and include receipt and localized UI fixes.
Reviewed local source: 15ac88e2f266571b8a6dc8d777302db0f4dcae44
Exact source tree: 45ebabfe2b
Static checks and independent inspection completed. Go, integration,
dashboard, rendering, and hosted runtime validation remain pending.
This fork staging commit is not an upstream publication or merge.
* test(opencode): align schema and snapshot assertions
Check the version-aware binding schema and verify native unregister retains the unchanged managed snapshot.
* fix(opencode): resolve Windows npm native launchers
Probe recognized native Opencode executables without invoking a batch shell; exercise the default version probe on hosted Windows.
* test(opencode): normalize Windows fixture line endings
Avoid doubling carriage returns when Git checks out the npm fixture with CRLF.
* fix(opencode): keep an undetected OpenCode version from blocking other agents
Review of the v2 directory package change found that one failed
`opencode --version` probe failed the whole hooks plan, so a machine
without the binary (a second machine sharing the config, CI, a
devcontainer) could no longer sync hooks to any agent, and doctor and
the dashboard preview failed with it.
Hooks:
- A probe that fails or reports an unknown major now skips only the
OpenCode bindings with one warning per target. Outputs already owned
there are parked, so they are neither rewritten nor removed while the
layout is unknown. The probe runs once per plan, list and import.
- A `package` binding on OpenCode v1 is skipped with a warning instead
of failing the plan.
- The v2 dependency warning is reported once, and only when a package
file is written, so a synced hook no longer keeps doctor yellow.
- `hooks import` reports an unreadable file such as a symlink as that
package's problem; other packages and flat files stay importable.
The package validation problem is reported once instead of twice.
- Directories under `plugins/` are listed as unmanaged only on v2.
Plugins:
- The inventory leaves `plugins/skillshare-NAME` registrations to
hooks, so a synced v2 hook is not offered as an importable plugin.
Dashboard: the new warnings are translated in every locale, a
`hook NAME:` prefix no longer defeats translation, the native preview
translates its per-file error, and the YAML editor documents `package`.
Docs: the English pages and the built-in skill describe the behavior
above; the ja, ko, zh-Hans and zh-Hant pages now carry the same
content as the English ones. The runbook drives the CLI with mdproof
assertions instead of prose expectations.
Refs #913.
---------
Co-authored-by: Willie <egg358358@gmail.com>
5.0 KiB
OpenCode directory package regression
Scope
Verify issue #913 through the CLI: a hook bound to OpenCode becomes a directory package and a directory registration on OpenCode v2, stays a flat file on v1, and an OpenCode version that cannot be detected holds back only the OpenCode binding.
A shell script named opencode that answers --version stands in for the client.
No OpenCode session, plugin code, dependency installation or real user
configuration is used.
Environment
Run inside the devcontainer in a fresh ssenv. Every step writes only under
$HOME and the environment's config directory. Shell variables do not persist between steps, so each step sets its own.
Steps
Step 1: OpenCode v2 receives a directory package
set -e
unset OPENCODE_CONFIG OPENCODE_CONFIG_DIR OPENCODE_CONFIG_CONTENT
C="${XDG_CONFIG_HOME:-$HOME/.config}"
rm -rf "$HOME/oc-v1" "$HOME/oc-v2" "$HOME/oc-broken" "$C/opencode"
ss hooks remove native --sync -g >/dev/null 2>&1 || true
mkdir -p "$HOME/oc-v1" "$HOME/oc-v2" "$HOME/oc-broken"
printf '#!/bin/sh\n[ "$#" = 1 ] && [ "$1" = --version ] || exit 91\necho 1.18.31\n' > "$HOME/oc-v1/opencode"
printf '#!/bin/sh\n[ "$#" = 1 ] && [ "$1" = --version ] || exit 91\necho "opencode v2.3.0"\n' > "$HOME/oc-v2/opencode"
printf '#!/bin/sh\nexit 127\n' > "$HOME/oc-broken/opencode"
chmod +x "$HOME/oc-v1/opencode" "$HOME/oc-v2/opencode" "$HOME/oc-broken/opencode"
cat > "$HOME/opencode-entry.json" <<'JSON'
{"bindings":{
"opencode":{"code":"export default {}\n"},
"claude":{"events":{"Stop":[{"hooks":[{"type":"command","command":"echo done"}]}]}}
}}
JSON
PATH="$HOME/oc-v2:$PATH" ss hooks add native --file "$HOME/opencode-entry.json" --sync -g --json
Expected:
- exit_code: 0
- jq: .plan.blocked == false
- jq: [.applied[] | select(endswith("/opencode/plugins/skillshare-native/package.json"))] | length == 1
- jq: [.applied[] | select(endswith("/opencode/plugins/skillshare-native/index.ts"))] | length == 1
- jq: [.applied[] | select(endswith("skillshare-native.ts"))] | length == 0
- jq: [.plan.warnings[] | select(startswith("OpenCode v2:"))] | length == 1
Step 2: The registration is the package directory
set -e
C="${XDG_CONFIG_HOME:-$HOME/.config}"
jq -c '{plugins, manifest: input}' "$C/opencode/opencode.json" "$C/opencode/plugins/skillshare-native/package.json"
Expected:
- exit_code: 0
- jq: .plugins | length == 1
- jq: .plugins[0] | startswith("file://") and endswith("/opencode/plugins/skillshare-native")
- jq: .manifest.exports == "./index.ts"
Step 3: A second sync on v2 changes nothing and reports nothing
set -e
unset OPENCODE_CONFIG OPENCODE_CONFIG_DIR OPENCODE_CONFIG_CONTENT
PATH="$HOME/oc-v2:$PATH" ss hooks sync -g --json
Expected:
- exit_code: 0
- jq: .applied | length == 0
- jq: .plan.warnings | length == 0
- jq: [.plan.changes[] | select(.action != "unchanged")] | length == 0
Step 4: An undetectable OpenCode version holds back only OpenCode
set -e
unset OPENCODE_CONFIG OPENCODE_CONFIG_DIR OPENCODE_CONFIG_CONTENT
C="${XDG_CONFIG_HOME:-$HOME/.config}"
PATH="$HOME/oc-broken:$PATH" ss hooks sync -g --json
test -f "$C/opencode/plugins/skillshare-native/package.json"
Expected:
- exit_code: 0
- jq: .plan.blocked == false
- jq: [.plan.changes[] | select(.target == "claude" and .action == "unchanged")] | length == 1
- jq: [.plan.changes[] | select(.target == "opencode")] | length == 0
- jq: [.plan.warnings[] | select(contains("its hook bindings are skipped"))] | length == 1
- jq: [.plan.warnings[] | select(contains("are left as they are"))] | length == 1
Step 5: OpenCode v1 receives the flat file and retires the package
set -e
unset OPENCODE_CONFIG OPENCODE_CONFIG_DIR OPENCODE_CONFIG_CONTENT
C="${XDG_CONFIG_HOME:-$HOME/.config}"
PATH="$HOME/oc-v1:$PATH" ss hooks sync -g >/dev/null
P="$C/opencode/plugins"
REGISTERED=$(grep -c skillshare-native "$C/opencode/opencode.json" 2>/dev/null || true)
jq -n --argjson flat "$(test -f "$P/skillshare-native.ts" && echo true || echo false)" \
--argjson package "$(test -e "$P/skillshare-native" && echo true || echo false)" \
--argjson registered "${REGISTERED:-0}" \
'{flat: $flat, package: $package, registered: $registered}'
Expected:
- exit_code: 0
- jq: .flat == true
- jq: .package == false
- jq: .registered == 0
Step 6: Removing the hook removes its OpenCode output
set -e
unset OPENCODE_CONFIG OPENCODE_CONFIG_DIR OPENCODE_CONFIG_CONTENT
C="${XDG_CONFIG_HOME:-$HOME/.config}"
PATH="$HOME/oc-v1:$PATH" ss hooks remove native --sync -g >/dev/null
ls "$C/opencode/plugins" 2>/dev/null | grep -c skillshare- || true
Expected:
- exit_code: 0
- regex: ^0$
Pass Criteria
All steps pass. Together they show the v2 directory layout and registration, a
no-op second sync without warnings, that a missing or failing opencode binary
neither blocks other Agents nor touches existing OpenCode output, the v1 flat
file, and cleanup. A passing run is not evidence that a real OpenCode runtime
loaded or executed a plugin.