mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-18 18:04:17 +00:00
fix(opencode): preserve v2 hook and plugin directory packages (#915)
* 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>
This commit is contained in:
co-authored by
Willie
parent
b9ca16a80e
commit
43059a1428
@@ -112,6 +112,9 @@ jobs:
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
- name: OpenCode version probe regression
|
||||
run: go test ./internal/hooks -run '^TestOpenCodeDefaultProbe$' -count=1
|
||||
|
||||
- name: Unit Tests
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
# 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
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
```bash
|
||||
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.
|
||||
@@ -213,7 +213,7 @@ func hooksAccounts(cfg *config.Config) map[string]hooks.Account {
|
||||
accounts := map[string]hooks.Account{}
|
||||
for name, target := range cfg.Targets {
|
||||
if target.Agent != "" && target.ConfigDir != "" {
|
||||
accounts[name] = hooks.Account{Agent: target.Agent, Dir: target.ConfigDir}
|
||||
accounts[name] = hooks.Account{Agent: target.Agent, Dir: target.ConfigDir, CLI: target.CLI}
|
||||
}
|
||||
}
|
||||
return accounts
|
||||
|
||||
@@ -442,7 +442,7 @@ func TestSchema_HooksAllowAccountBindings(t *testing.T) {
|
||||
t.Fatalf("%v", patterns)
|
||||
}
|
||||
refs := patterns[pattern].(map[string]any)["anyOf"].([]any)
|
||||
if len(refs) != 2 || refs[0].(map[string]any)["$ref"] != "#/$defs/commandBinding" || refs[1].(map[string]any)["$ref"] != "#/$defs/codeBinding" {
|
||||
if len(refs) != 2 || refs[0].(map[string]any)["$ref"] != "#/$defs/commandBinding" || refs[1].(map[string]any)["$ref"] != "#/$defs/openCodeBinding" {
|
||||
t.Fatalf("%v", refs)
|
||||
}
|
||||
global := defs["globalConfiguration"].(map[string]any)["properties"].(map[string]any)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
// Account is a target that is another config directory of a built-in Agent.
|
||||
type Account struct {
|
||||
CLI string `json:"cli,omitempty"`
|
||||
Agent string `json:"agent"`
|
||||
Dir string `json:"configDir"`
|
||||
}
|
||||
@@ -110,19 +111,55 @@ func (s *Service) parkReason(r record) string {
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if !samePath(recordDir(r), dir) {
|
||||
if !samePath(recordHome(r, dir, agent), dir) {
|
||||
reason := fmt.Sprintf("%s now resolves to %s", agent, dir)
|
||||
if sc.scopedAccount == "" && sc.ConfigDirs[agent] != "" && sc.envShadow(agent) == "" {
|
||||
reason += " (" + configDirEnv[agent] + ")"
|
||||
}
|
||||
return reason
|
||||
}
|
||||
if agent == "opencode" {
|
||||
// The version decides the layout, so an owned output is neither rewritten
|
||||
// nor removed while it is unknown.
|
||||
if _, err := sc.openCode2(); err != nil {
|
||||
return "the installed OpenCode version could not be detected"
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// recordDir identifies the previous home for warnings, including script outputs.
|
||||
func recordDir(r record) string {
|
||||
// recordHome recognizes package files from their exact owned entry and current
|
||||
// native home, never from folder names inside a package payload.
|
||||
func recordHome(r record, current, agent string) string {
|
||||
if agent == "opencode" && r.Event == "" && r.Entry != "" {
|
||||
packageDir := filepath.Join(current, "plugins", "skillshare-"+r.Entry)
|
||||
if rel, err := filepath.Rel(packageDir, r.Path); err == nil && rel != "." && filepath.IsLocal(rel) {
|
||||
return current
|
||||
}
|
||||
}
|
||||
return recordDir(r, agent)
|
||||
}
|
||||
|
||||
// recordDir identifies the previous home for moved-account warnings. Package
|
||||
// records carry their entry name; inner payload directories are not homes.
|
||||
func recordDir(r record, agent string) string {
|
||||
dir := filepath.Dir(r.Path)
|
||||
// A flat OpenCode v1 file may live under an account whose own path looks
|
||||
// like a package. Prefer its exact native filename to ancestor matching.
|
||||
if agent == "opencode" && r.Event == "" && r.Entry != "" && filepath.Base(dir) == "plugins" && filepath.Base(r.Path) == "skillshare-"+r.Entry+".ts" {
|
||||
return filepath.Dir(dir)
|
||||
}
|
||||
if agent == "opencode" && r.Event == "" && r.Entry != "" {
|
||||
home := ""
|
||||
for parent := dir; filepath.Dir(parent) != parent; parent = filepath.Dir(parent) {
|
||||
if filepath.Base(filepath.Dir(parent)) == "plugins" && filepath.Base(parent) == "skillshare-"+r.Entry {
|
||||
home = filepath.Dir(filepath.Dir(parent))
|
||||
}
|
||||
}
|
||||
if home != "" {
|
||||
return home
|
||||
}
|
||||
}
|
||||
if r.Event == "" && filepath.Base(filepath.Dir(dir)) == "skillshare" {
|
||||
return filepath.Dir(filepath.Dir(filepath.Dir(dir)))
|
||||
}
|
||||
|
||||
@@ -258,3 +258,57 @@ func TestAccountBackupRestoreFormerHomeRefused(t *testing.T) {
|
||||
t.Fatal("former home changed")
|
||||
}
|
||||
}
|
||||
|
||||
// An account home can itself look like an OpenCode package directory.
|
||||
func TestAccountHomeNamedLikeOpenCodePackage(t *testing.T) {
|
||||
for _, tc := range []struct{ agent, subdir, code string }{
|
||||
{"pi", "extensions", "export default function() {}\n"},
|
||||
{"opencode", "plugins", "export default {}\n"},
|
||||
} {
|
||||
t.Run(tc.agent, func(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
e.service.OpenCodeVersion = func(string) (string, error) { return "1.18.31", nil }
|
||||
old := filepath.Join(e.home, "plugins", "skillshare-lint")
|
||||
next := filepath.Join(e.home, "other-account")
|
||||
must(t, os.MkdirAll(old, 0755))
|
||||
must(t, os.MkdirAll(next, 0755))
|
||||
e.service.Accounts = map[string]Account{"work": {Agent: tc.agent, Dir: old}}
|
||||
m := Mutation{Name: "lint", Entry: &Entry{Bindings: map[string]Binding{"work": {Code: tc.code}}}}
|
||||
first := save(t, e.service, m)
|
||||
path := filepath.Join(old, tc.subdir, "skillshare-lint.ts")
|
||||
if !exists(path) || len(first.BackupIDs) == 0 {
|
||||
t.Fatal("missing native output or backup")
|
||||
}
|
||||
if r := sync(t, e.service); r.Plan.Blocked || len(r.Applied) != 0 || len(r.Plan.Warnings) != 0 {
|
||||
t.Fatalf("no-op sync parked account output: %+v", r.Plan)
|
||||
}
|
||||
p, err := e.service.PreviewRestore(first.BackupIDs[0])
|
||||
must(t, err)
|
||||
if p.Blocked {
|
||||
t.Fatalf("backup parked: %+v", p)
|
||||
}
|
||||
_, err = e.service.Restore(first.BackupIDs[0], p.Revision)
|
||||
must(t, err)
|
||||
if exists(path) {
|
||||
t.Fatal("restore did not undo the initial write")
|
||||
}
|
||||
sync(t, e.service)
|
||||
if !exists(path) {
|
||||
t.Fatal("sync did not recreate restored output")
|
||||
}
|
||||
e.service.Accounts["work"] = Account{Agent: tc.agent, Dir: next}
|
||||
r := sync(t, e.service)
|
||||
if !strings.Contains(strings.Join(r.Plan.Warnings, "\n"), "in "+old+" are left") || !exists(path) {
|
||||
t.Fatalf("former home not parked correctly: %v", r.Plan.Warnings)
|
||||
}
|
||||
if _, err := e.service.PreviewRestore(first.BackupIDs[0]); err == nil || !strings.Contains(err.Error(), old) {
|
||||
t.Fatalf("restore did not refuse former home: %v", err)
|
||||
}
|
||||
e.service.Accounts["work"] = Account{Agent: tc.agent, Dir: old}
|
||||
save(t, e.service, Mutation{Name: "lint", Remove: true})
|
||||
if exists(path) {
|
||||
t.Fatal("removed binding retained")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+10
-1
@@ -742,6 +742,7 @@ func (s *Service) PreviewRestore(id string) (*Plan, error) {
|
||||
if !backupID.MatchString(id) {
|
||||
return nil, fmt.Errorf("invalid hooks backup ID")
|
||||
}
|
||||
s = s.memoProbe()
|
||||
data, exists, _, err := safeRead(filepath.Join(s.stateDir(), "backups", id+".json"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -786,7 +787,15 @@ func (s *Service) PreviewRestore(id string) (*Plan, error) {
|
||||
}
|
||||
oldDir := filepath.Dir(b.Path)
|
||||
if b.Kind == kindFile {
|
||||
oldDir = recordDir(record{Path: b.Path})
|
||||
owned := record{Path: b.Path}
|
||||
for _, records := range []map[string]*record{b.OwnedBefore, b.OwnedAfter} {
|
||||
for _, r := range records {
|
||||
if r != nil && r.Path == b.Path {
|
||||
owned = *r
|
||||
}
|
||||
}
|
||||
}
|
||||
oldDir = recordHome(owned, dir, agent)
|
||||
}
|
||||
if !samePath(oldDir, dir) {
|
||||
return nil, fmt.Errorf("backup %s belongs to %s in %s, but %s now resolves to %s; use its former config_dir to restore", id, b.Target, oldDir, b.Target, dir)
|
||||
|
||||
@@ -25,14 +25,14 @@ func newEnv(t *testing.T) *env {
|
||||
config := filepath.Join(dir, "skillshare", "config.yaml")
|
||||
must(t, os.MkdirAll(home, 0755))
|
||||
write(t, config, "targets: {}\n")
|
||||
return &env{t: t, home: home, config: config, service: &Service{ConfigPath: config, Home: home, StateDir: filepath.Join(dir, "state"), ConfigDirs: map[string]string{}}}
|
||||
return &env{t: t, home: home, config: config, service: &Service{ConfigPath: config, Home: home, StateDir: filepath.Join(dir, "state"), OpenCodeVersion: func(string) (string, error) { return "1.18.31", nil }, ConfigDirs: map[string]string{}}}
|
||||
}
|
||||
|
||||
// project is a project scope sharing e's state directory.
|
||||
func (e *env) project(root string) *Service {
|
||||
config := filepath.Join(root, ".skillshare", "config.yaml")
|
||||
write(e.t, config, "targets: []\n")
|
||||
return &Service{ConfigPath: config, ProjectRoot: root, Home: e.home, StateDir: e.service.StateDir}
|
||||
return &Service{ConfigPath: config, ProjectRoot: root, Home: e.home, StateDir: e.service.StateDir, OpenCodeVersion: e.service.OpenCodeVersion}
|
||||
}
|
||||
|
||||
func must(t *testing.T, err error) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
// List reads the source, ownership and native files without writing. A plan that
|
||||
// cannot be computed is reported in PreviewError so the rest stays visible.
|
||||
func (s *Service) List() (*Inventory, error) {
|
||||
s = s.memoProbe()
|
||||
source, err := s.loadSource()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -158,9 +159,32 @@ func (s *Service) unownedFiles(target, dir string, state ledger) []string {
|
||||
return nil
|
||||
}
|
||||
var names []string
|
||||
var packages *bool
|
||||
for _, e := range entries {
|
||||
name := e.Name()
|
||||
ext := filepath.Ext(name)
|
||||
if target == "opencode" && e.IsDir() {
|
||||
// Only OpenCode v2 loads a directory as a plugin.
|
||||
if packages == nil {
|
||||
v2, err := s.openCode2()
|
||||
v2 = v2 && err == nil
|
||||
packages = &v2
|
||||
}
|
||||
if !*packages {
|
||||
continue
|
||||
}
|
||||
owned := false
|
||||
for _, r := range state.Records {
|
||||
if strings.HasPrefix(r.Path, filepath.Join(dir, name)+string(filepath.Separator)) {
|
||||
owned = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !owned {
|
||||
names = append(names, name)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if e.IsDir() || !(target == "copilot" && ext == ".json" || target != "copilot" && (ext == ".ts" || ext == ".js")) {
|
||||
continue
|
||||
}
|
||||
@@ -202,6 +226,7 @@ func candidateName(parts ...string) string {
|
||||
// matches a candidate picks that one; any other Name merges everything found into one
|
||||
// candidate.
|
||||
func (s *Service) Import(req ImportRequest) ([]Candidate, error) {
|
||||
s = s.memoProbe()
|
||||
target := canonicalTarget(req.From)
|
||||
if target == "git" {
|
||||
return nil, fmt.Errorf("Git hooks import is not supported yet; define commands explicitly")
|
||||
@@ -476,6 +501,9 @@ func (s *Service) importCode(target string, req ImportRequest, state ledger) ([]
|
||||
out := []Candidate{}
|
||||
for _, file := range s.unownedFiles(target, dir, state) {
|
||||
path := filepath.Join(dir, file)
|
||||
if info, err := os.Lstat(path); err == nil && info.IsDir() {
|
||||
continue
|
||||
}
|
||||
if err := checkPath(s.baseOrDir(target), path); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -491,5 +519,18 @@ func (s *Service) importCode(target string, req ImportRequest, state ledger) ([]
|
||||
}
|
||||
out = append(out, c)
|
||||
}
|
||||
if target == "opencode" {
|
||||
v2, err := s.openCode2()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if v2 {
|
||||
packages, err := s.importOpenCodePackages(state)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, packages...)
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
+12
-1
@@ -36,6 +36,8 @@ type Project struct {
|
||||
|
||||
// Binding is what one Agent receives. Command Agents use Events and Files, code Agents Code.
|
||||
type Binding struct {
|
||||
// Package preserves an OpenCode v2 directory, relative filename to UTF-8 contents.
|
||||
Package map[string]string `yaml:"package,omitempty" json:"package,omitempty"`
|
||||
// Events is the Agent's own event map, written without translation.
|
||||
Events map[string]any `yaml:"events,omitempty" json:"events,omitempty"`
|
||||
// Code is one standalone native TypeScript/JavaScript extension or plugin.
|
||||
@@ -285,7 +287,7 @@ var Targets = []TargetDef{
|
||||
{Name: "pi", Kind: KindCode, Note: "Pi discovers extensions at startup; project extensions load only after project trust is granted. The code must use the extension API of your installed Pi version."},
|
||||
{Name: "omp", Kind: KindCode, Note: "Oh My Pi discovers extensions at startup from its agent directory (~/.omp/agent/extensions, or PI_CODING_AGENT_DIR, which Pi reads too) and from .omp/extensions in a project. OMP has no project trust gate, so the next startup can execute the code. Its own hooks/pre and hooks/post factories are left untouched and listed as additional sources. The code must use the extension API of your installed OMP version."},
|
||||
{Name: "amp", Kind: KindCode, Note: "Amp runs plugins from its plugins folder with Bun; run 'plugins: reload' after sync. The code must use your Amp version's plugin API."},
|
||||
{Name: "opencode", Kind: KindCode, Note: "OpenCode loads plugins from its plugins folder. v1 plugins are named exports and v2 plugins export default Plugin.define(...); Skillshare writes your code as given and never converts between them."},
|
||||
{Name: "opencode", Kind: KindCode, Note: "OpenCode v1 receives a flat plugin file; v2 receives a directory package and directory registration. Code must match the installed API. Skillshare never loads code or installs dependencies."},
|
||||
}
|
||||
|
||||
// targetAliases are accepted spellings of canonical Agent names.
|
||||
@@ -421,6 +423,15 @@ func (e Entry) validate(name string, accounts map[string]string, scope validatio
|
||||
}
|
||||
}
|
||||
b := e.Bindings[target]
|
||||
if b.Package != nil {
|
||||
if agent != "opencode" || b.Code != "" || b.CodeFile != "" || len(b.Events) > 0 || len(b.Files) > 0 || b.Commands != nil || b.Scripts != nil {
|
||||
return fmt.Errorf("hook %s: package is exclusive to OpenCode v2; do not combine it with code, events or files", name)
|
||||
}
|
||||
if err := validateOpenCodePackage(b.Package); err != nil {
|
||||
return fmt.Errorf("hook %s: %w", name, err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if def.Kind == KindGit {
|
||||
if err := validateGit(b); err != nil {
|
||||
return fmt.Errorf("hook %s: git: %w", name, err)
|
||||
|
||||
@@ -44,7 +44,9 @@ func skeleton(target string, data []byte) bool {
|
||||
}
|
||||
|
||||
// wrapped reports whether the event map sits under a "hooks" key.
|
||||
func wrapped(target string) bool { return target != "droid" && target != "antigravity" }
|
||||
func wrapped(target string) bool {
|
||||
return target != "droid" && target != "antigravity" && target != "opencode"
|
||||
}
|
||||
|
||||
func uniqueJSON(v *hujson.Value) error {
|
||||
switch value := v.Value.(type) {
|
||||
@@ -98,6 +100,18 @@ func parseNative(target string, data []byte) (*nativeDoc, error) {
|
||||
if err := json.Unmarshal(standard.Pack(), &document); err != nil || document == nil {
|
||||
return nil, fmt.Errorf("configuration must be a JSON object")
|
||||
}
|
||||
if target == "opencode" {
|
||||
raw, has := document["plugins"]
|
||||
n.hasSection = has
|
||||
if has {
|
||||
items, ok := raw.([]any)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("OpenCode plugins must be an array")
|
||||
}
|
||||
n.events["plugins"] = items
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
if target == "cursor" {
|
||||
if version, ok := document["version"]; ok && version != float64(1) {
|
||||
return nil, fmt.Errorf("unsupported Cursor hooks version %v; only version 1 is supported", version)
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
package hooks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"skillshare/internal/opencode"
|
||||
)
|
||||
|
||||
const openCodeDependencyWarning = "OpenCode v2: package files and registration only; provision the declared dependencies yourself before loading. Skillshare does not execute plugins or install dependencies."
|
||||
|
||||
func (s *Service) openCode2() (bool, error) {
|
||||
bin := "opencode"
|
||||
if s.scopedAccount != "" && s.Accounts[s.scopedAccount].CLI != "" {
|
||||
bin = s.Accounts[s.scopedAccount].CLI
|
||||
}
|
||||
version, err := s.versionProbe()(bin)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("detect OpenCode API with %s --version: %w", bin, err)
|
||||
}
|
||||
key, err := opencode.ConfigKey(version)
|
||||
return key == "plugins", err
|
||||
}
|
||||
|
||||
func (s *Service) versionProbe() func(string) (string, error) {
|
||||
if s.OpenCodeVersion != nil {
|
||||
return s.OpenCodeVersion
|
||||
}
|
||||
return probeOpenCodeVersion
|
||||
}
|
||||
|
||||
func probeOpenCodeVersion(bin string) (string, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
path, err := exec.LookPath(bin)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if runtime.GOOS == "windows" && strings.EqualFold(filepath.Ext(path), ".cmd") {
|
||||
path, err = openCodeNPMExecutable(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
cmd := exec.CommandContext(ctx, path, "--version")
|
||||
cmd.WaitDelay = 100 * time.Millisecond
|
||||
output, err := cmd.Output()
|
||||
return string(output), err
|
||||
}
|
||||
|
||||
// memoProbe asks each OpenCode binary once per plan, however many bindings and
|
||||
// owned outputs need the answer. The answer is not kept between plans.
|
||||
func (s *Service) memoProbe() *Service {
|
||||
probe := s.versionProbe()
|
||||
type answer struct {
|
||||
version string
|
||||
err error
|
||||
}
|
||||
seen := map[string]answer{}
|
||||
c := *s
|
||||
c.OpenCodeVersion = func(bin string) (string, error) {
|
||||
a, ok := seen[bin]
|
||||
if !ok {
|
||||
a.version, a.err = probe(bin)
|
||||
seen[bin] = a
|
||||
}
|
||||
return a.version, a.err
|
||||
}
|
||||
return &c
|
||||
}
|
||||
|
||||
func validateOpenCodePackage(files map[string]string) error {
|
||||
for name, content := range files {
|
||||
if name == "." || !fs.ValidPath(name) || strings.ContainsAny(name, "\\:") || !utf8.ValidString(content) {
|
||||
return fmt.Errorf("OpenCode package file %q must be a relative UTF-8 file without traversal", name)
|
||||
}
|
||||
for parent := filepath.ToSlash(filepath.Dir(filepath.FromSlash(name))); parent != "."; parent = filepath.ToSlash(filepath.Dir(filepath.FromSlash(parent))) {
|
||||
if _, exists := files[parent]; exists {
|
||||
return fmt.Errorf("OpenCode package file %q is also a parent directory", parent)
|
||||
}
|
||||
}
|
||||
for _, part := range strings.Split(name, "/") {
|
||||
if part == "node_modules" || part == ".git" {
|
||||
return fmt.Errorf("OpenCode package must not contain %s", part)
|
||||
}
|
||||
}
|
||||
}
|
||||
return opencode.Package(func(name string) ([]byte, error) {
|
||||
data, ok := files[name]
|
||||
if !ok {
|
||||
return nil, fs.ErrNotExist
|
||||
}
|
||||
return []byte(data), nil
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Service) openCodeConfig() (string, error) {
|
||||
// Config overrides can redirect the native loader away from these scoped files.
|
||||
if os.Getenv("OPENCODE_CONFIG") != "" || os.Getenv("OPENCODE_CONFIG_CONTENT") != "" {
|
||||
return "", fmt.Errorf("unset OPENCODE_CONFIG and OPENCODE_CONFIG_CONTENT before managing OpenCode hook registrations")
|
||||
}
|
||||
dir, err := s.configDir("opencode")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
var found string
|
||||
for _, name := range []string{"opencode.json", "opencode.jsonc"} {
|
||||
p := filepath.Join(dir, name)
|
||||
if _, err := os.Lstat(p); err == nil {
|
||||
if found != "" {
|
||||
return "", fmt.Errorf("both opencode.json and opencode.jsonc exist; consolidate before hooks sync")
|
||||
}
|
||||
found = p
|
||||
} else if !os.IsNotExist(err) {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
if found != "" {
|
||||
return found, nil
|
||||
}
|
||||
return filepath.Join(dir, "opencode.json"), nil
|
||||
}
|
||||
|
||||
func (s *Service) renderOpenCode(d *desired, root, target, name string, b Binding, addFile func(wantFile) error) error {
|
||||
config, err := s.openCodeConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dir, err := s.nativePath("opencode")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dir = filepath.Join(dir, "skillshare-"+name)
|
||||
files := b.Package
|
||||
if files == nil {
|
||||
manifest, _ := json.MarshalIndent(map[string]any{"name": "skillshare-" + name, "type": "module", "exports": "./index.ts", "dependencies": map[string]string{"@opencode/plugin": "^2.0.0"}}, "", " ")
|
||||
files = map[string]string{"index.ts": b.Code, "package.json": string(manifest) + "\n"}
|
||||
}
|
||||
if err := validateOpenCodePackage(files); err != nil {
|
||||
return err
|
||||
}
|
||||
if d.packageFiles == nil {
|
||||
d.packageFiles = map[string]bool{}
|
||||
}
|
||||
for _, file := range sortedKeys(files) {
|
||||
path := filepath.Join(dir, filepath.FromSlash(file))
|
||||
if err := addFile(wantFile{target: target, path: path, root: root, entry: name, content: []byte(files[file]), mode: 0644}); err != nil {
|
||||
return err
|
||||
}
|
||||
d.packageFiles[path] = true
|
||||
}
|
||||
d.targets[config], d.roots[config] = target, root
|
||||
d.elements[config] = append(d.elements[config], wantElement{target: target, path: config, root: root, entry: name, event: "plugins", value: opencode.FileURL(dir)})
|
||||
return nil
|
||||
}
|
||||
|
||||
// importOpenCodePackages copies source files only. Installed dependencies and Git
|
||||
// metadata are not portable hook declarations, and symlinks are never followed.
|
||||
func (s *Service) importOpenCodePackages(state ledger) ([]Candidate, error) {
|
||||
dir, err := s.nativePath("opencode")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var out []Candidate
|
||||
for _, name := range s.unownedFiles("opencode", dir, state) {
|
||||
root := filepath.Join(dir, name)
|
||||
info, err := os.Lstat(root)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !info.IsDir() {
|
||||
continue
|
||||
}
|
||||
if err := checkPath(s.baseOrDir("opencode"), root); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
files := map[string]string{}
|
||||
// A file that cannot be read, such as a symlink, is this package's problem
|
||||
// only; the other packages and flat files stay importable.
|
||||
var problems []string
|
||||
_ = fs.WalkDir(os.DirFS(root), ".", func(name string, item fs.DirEntry, walkErr error) error {
|
||||
if walkErr != nil {
|
||||
problems = append(problems, fmt.Sprintf("OpenCode package file %q cannot be imported: %v", name, walkErr))
|
||||
return nil
|
||||
}
|
||||
if item.IsDir() {
|
||||
if item.Name() == "node_modules" || item.Name() == ".git" {
|
||||
return fs.SkipDir
|
||||
}
|
||||
return nil
|
||||
}
|
||||
data, _, _, err := safeRead(filepath.Join(root, filepath.FromSlash(name)))
|
||||
if err != nil {
|
||||
problems = append(problems, fmt.Sprintf("OpenCode package file %q cannot be imported: %v", name, err))
|
||||
return nil
|
||||
}
|
||||
files[name] = string(data)
|
||||
return nil
|
||||
})
|
||||
// Import reports the package's own validation problems once, for every candidate.
|
||||
c := Candidate{Name: candidateName(strings.TrimPrefix(name, "skillshare-")), Problems: problems, Entry: Entry{Bindings: map[string]Binding{s.targetKey("opencode"): {Package: files}}}}
|
||||
c.Warnings = []string{fmt.Sprintf("%s keeps loading; remove its original files and directory registration after syncing so the plugin does not run twice", root)}
|
||||
out = append(out, c)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package hooks
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// openCodeNPMExecutable recognizes npm's native-binary shim, not a general
|
||||
// batch program. Resolve the installed binary without invoking cmd.exe or
|
||||
// evaluating paths, environment variables, or commands from the shim.
|
||||
func openCodeNPMExecutable(shim string) (string, error) {
|
||||
data, err := os.ReadFile(shim)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
// npm/cmd-shim's no-shebang template, shared by current v1 and v2 packages.
|
||||
const header = "@ECHO off\nGOTO start\n:find_dp0\nSET dp0=%~dp0\nEXIT /b\n:start\nSETLOCAL\nCALL :find_dp0\n"
|
||||
body := strings.ReplaceAll(string(data), "\r\n", "\n")
|
||||
for _, prefix := range []string{`node_modules\`, `..\`} {
|
||||
for _, pkg := range []string{`opencode-ai`, `@opencode\cli`} {
|
||||
rel := prefix + pkg + `\bin\opencode.exe`
|
||||
if body == header+`"%dp0%\`+rel+`" %*`+"\n" {
|
||||
// The local npm shim lives in node_modules/.bin. These are
|
||||
// fixed paths only; no batch-file text becomes a command.
|
||||
return filepath.Join(filepath.Dir(shim), filepath.FromSlash(strings.ReplaceAll(rel, `\`, "/"))), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("unrecognized OpenCode npm launcher; put the installed native opencode.exe first on PATH, or set an account target's cli to its path")
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package hooks
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// The copied test executable is a harmless stand-in for OpenCode. No installed
|
||||
// CLI, npm package, batch file or plugin code runs in these tests.
|
||||
func TestMain(m *testing.M) {
|
||||
if version := os.Getenv("SKILLSHARE_TEST_OPENCODE_VERSION"); version != "" {
|
||||
if len(os.Args) != 2 || os.Args[1] != "--version" {
|
||||
os.Exit(2)
|
||||
}
|
||||
fmt.Println(version)
|
||||
os.Exit(0)
|
||||
}
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func TestOpenCodeDefaultProbe(t *testing.T) {
|
||||
exe, err := os.Executable()
|
||||
must(t, err)
|
||||
binary, err := os.ReadFile(exe)
|
||||
must(t, err)
|
||||
shim, err := os.ReadFile("testdata/opencode-npm.cmd")
|
||||
must(t, err)
|
||||
for _, tt := range []struct {
|
||||
name, pkg, version string
|
||||
local, explicit, invalid, missing bool
|
||||
}{
|
||||
{name: "native v1", version: "1.18.31"},
|
||||
{name: "native v2 account", version: "2.3.0", explicit: true},
|
||||
{name: "unknown native version", version: "3.0.0"},
|
||||
{name: "npm v1", pkg: "opencode-ai", version: "1.18.31"},
|
||||
{name: "npm v2", pkg: "@opencode/cli", version: "2.3.0"},
|
||||
{name: "npm local account", pkg: "@opencode/cli", version: "2.3.0", local: true, explicit: true},
|
||||
{name: "unknown npm version", pkg: "@opencode/cli", version: "3.0.0"},
|
||||
{name: "unrecognized shim", pkg: "opencode-ai", version: "1.18.31", invalid: true},
|
||||
{name: "missing native binary", pkg: "opencode-ai", version: "1.18.31", missing: true},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if tt.pkg != "" && runtime.GOOS != "windows" {
|
||||
t.Skip("npm .cmd lookup is Windows-only")
|
||||
}
|
||||
root := filepath.Join(t.TempDir(), "npm prefix with spaces")
|
||||
must(t, os.MkdirAll(root, 0755))
|
||||
binDir := root
|
||||
bin := filepath.Join(root, "opencode")
|
||||
if runtime.GOOS == "windows" {
|
||||
bin += ".exe"
|
||||
t.Setenv("PATHEXT", ".EXE;.CMD")
|
||||
}
|
||||
if tt.pkg != "" {
|
||||
target := `node_modules\` + strings.ReplaceAll(tt.pkg, "/", `\`) + `\bin\opencode.exe`
|
||||
if tt.local {
|
||||
binDir = filepath.Join(root, "node_modules", ".bin")
|
||||
target = `..\` + strings.ReplaceAll(tt.pkg, "/", `\`) + `\bin\opencode.exe`
|
||||
must(t, os.MkdirAll(binDir, 0755))
|
||||
}
|
||||
body := strings.ReplaceAll(string(shim), `node_modules\opencode-ai\bin\opencode.exe`, target)
|
||||
// Git may have checked out the fixture with CRLF already.
|
||||
body = strings.ReplaceAll(body, "\r\n", "\n")
|
||||
if tt.invalid {
|
||||
body = "@echo 1.18.31\n"
|
||||
}
|
||||
must(t, os.WriteFile(filepath.Join(binDir, "opencode.cmd"), []byte(strings.ReplaceAll(body, "\n", "\r\n")), 0644))
|
||||
bin = filepath.Join(root, "node_modules", filepath.FromSlash(tt.pkg), "bin", "opencode.exe")
|
||||
must(t, os.MkdirAll(filepath.Dir(bin), 0755))
|
||||
}
|
||||
if !tt.missing {
|
||||
must(t, os.WriteFile(bin, binary, 0755))
|
||||
}
|
||||
t.Setenv("PATH", binDir)
|
||||
t.Setenv("SKILLSHARE_TEST_OPENCODE_VERSION", tt.version)
|
||||
s := &Service{}
|
||||
if tt.explicit {
|
||||
cli := bin
|
||||
if tt.pkg != "" {
|
||||
cli = filepath.Join(binDir, "opencode.cmd")
|
||||
}
|
||||
s.scopedAccount = "work"
|
||||
s.Accounts = map[string]Account{"work": {CLI: cli}}
|
||||
}
|
||||
v2, err := s.openCode2()
|
||||
wantError := tt.invalid || tt.missing || tt.version == "3.0.0"
|
||||
if (err != nil) != wantError || !wantError && v2 != strings.HasPrefix(tt.version, "2.") {
|
||||
t.Fatalf("openCode2() = %v, %v; want error=%v, version=%s", v2, err, wantError, tt.version)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
package hooks
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestOpenCodePackageLifecycle(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
e.service.OpenCodeVersion = func(string) (string, error) { return "opencode v2.3.0", nil }
|
||||
config := filepath.Join(e.home, ".config/opencode/opencode.jsonc")
|
||||
write(t, config, "{\n // keep me\n \"model\":\"unchanged\",\"plugins\":[\"other\"],\n}\n")
|
||||
m := Mutation{Name: "native", Entry: entry(t, `{"bindings":{"opencode":{"code":"export default {}\n"}}}`)}
|
||||
save(t, e.service, m)
|
||||
dir := filepath.Join(e.home, ".config/opencode/plugins/skillshare-native")
|
||||
if got := read(t, filepath.Join(dir, "package.json")); !strings.Contains(got, "@opencode/plugin") {
|
||||
t.Fatal(got)
|
||||
}
|
||||
if got := read(t, config); !strings.Contains(got, "// keep me") || !strings.Contains(got, "other") || strings.Contains(got, "index.ts") {
|
||||
t.Fatal(got)
|
||||
}
|
||||
if r := sync(t, e.service); len(r.Applied) != 0 {
|
||||
t.Fatal(r.Applied)
|
||||
}
|
||||
m.Entry.Bindings["opencode"] = Binding{Code: "export default { changed: true }\n"}
|
||||
save(t, e.service, m)
|
||||
if !strings.Contains(read(t, filepath.Join(dir, "index.ts")), "changed") {
|
||||
t.Fatal("not updated")
|
||||
}
|
||||
if r := sync(t, e.service); len(r.Applied) != 0 {
|
||||
t.Fatal(r.Applied)
|
||||
}
|
||||
save(t, e.service, Mutation{Name: "native", Remove: true})
|
||||
if exists(dir) {
|
||||
t.Fatal("package directory remains")
|
||||
}
|
||||
if got := read(t, config); strings.Contains(got, "skillshare-native") || !strings.Contains(got, "other") || !strings.Contains(got, "// keep me") {
|
||||
t.Fatal(got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodePackageImportPreservesManifestAndOwnership(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
e.service.OpenCodeVersion = func(string) (string, error) { return "2.3.0", nil }
|
||||
original := filepath.Join(e.home, ".config/opencode/plugins/kata-user")
|
||||
manifest := "{\n \"name\":\"kata-native-agent-hooks\", \"type\":\"module\", \"exports\":\"./index.js\",\n \"dependencies\":{\"@opencode/plugin\":\"^2.0.0\"}, \"kata\":{\"api\":\"v2\"}\n}\n"
|
||||
write(t, filepath.Join(original, "package.json"), manifest)
|
||||
write(t, filepath.Join(original, "index.js"), "export default {}\n")
|
||||
write(t, filepath.Join(original, "lib/helper.js"), "export const helper = true\n")
|
||||
write(t, filepath.Join(original, "node_modules/ignored.js"), "not copied")
|
||||
candidates, err := e.service.Import(ImportRequest{From: "opencode", Name: "kata-user"})
|
||||
must(t, err)
|
||||
if len(candidates) != 1 || len(candidates[0].Problems) > 0 {
|
||||
t.Fatalf("%+v", candidates)
|
||||
}
|
||||
c := candidates[0]
|
||||
if c.Entry.Bindings["opencode"].Package["package.json"] != manifest || len(c.Entry.Bindings["opencode"].Package) != 3 || len(c.Warnings) == 0 {
|
||||
t.Fatalf("%+v", c)
|
||||
}
|
||||
save(t, e.service, Mutation{Name: c.Name, Entry: &c.Entry, Adopt: true})
|
||||
dir := filepath.Join(e.home, ".config/opencode/plugins/skillshare-kata-user")
|
||||
if got := read(t, filepath.Join(dir, "package.json")); got != manifest {
|
||||
t.Fatal(got)
|
||||
}
|
||||
if r := sync(t, e.service); len(r.Applied) != 0 {
|
||||
t.Fatal(r.Applied)
|
||||
}
|
||||
write(t, filepath.Join(dir, "lib/helper.js"), "outside edit")
|
||||
p, err := e.service.Preview()
|
||||
must(t, err)
|
||||
if !p.Blocked {
|
||||
t.Fatal("external package edits must conflict")
|
||||
}
|
||||
if read(t, filepath.Join(original, "package.json")) != manifest {
|
||||
t.Fatal("original modified")
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodeVersionAndScope(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
m := Mutation{Name: "native", Entry: entry(t, `{"bindings":{"opencode":{"code":"export default {}\n"}}}`)}
|
||||
version := "1.18.31"
|
||||
e.service.OpenCodeVersion = func(string) (string, error) { return version, nil }
|
||||
p, err := e.service.PreviewMutation(m)
|
||||
must(t, err)
|
||||
version = "2.3.0"
|
||||
if _, err := e.service.Mutate(m, p.Revision, true); err != ErrStaleRevision {
|
||||
t.Fatalf("version change accepted: %v", err)
|
||||
}
|
||||
version = "1.18.31"
|
||||
save(t, e.service, m)
|
||||
flat := filepath.Join(e.home, ".config/opencode/plugins/skillshare-native.ts")
|
||||
if !exists(flat) {
|
||||
t.Fatal("v1 output changed")
|
||||
}
|
||||
version = "2.3.0"
|
||||
sync(t, e.service)
|
||||
if exists(flat) {
|
||||
t.Fatal("owned v1 file not retired")
|
||||
}
|
||||
if r := sync(t, e.service); len(r.Applied) != 0 {
|
||||
t.Fatal(r.Applied)
|
||||
}
|
||||
project := e.project(t.TempDir())
|
||||
project.OpenCodeVersion = func(string) (string, error) { return "2.3.0", nil }
|
||||
save(t, project, m)
|
||||
if !exists(filepath.Join(project.ProjectRoot, ".opencode/opencode.json")) {
|
||||
t.Fatal("missing project registration")
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodePackageValidation(t *testing.T) {
|
||||
for _, name := range []string{".", "../escape.js", "/absolute.js", "nested/../../escape", "node_modules/x.js", "a\\b.js"} {
|
||||
files := map[string]string{"package.json": `{"name":"demo","exports":"./index.js"}`, "index.js": "export default {}", name: "no"}
|
||||
if err := validateOpenCodePackage(files); err == nil {
|
||||
t.Errorf("accepted %s", name)
|
||||
}
|
||||
}
|
||||
if err := validateOpenCodePackage(map[string]string{"package.json": `{"name":"demo","exports":"./lib/index.js"}`, "lib": "file", "lib/index.js": "export default {}"}); err == nil {
|
||||
t.Fatal("file/ancestor collision accepted")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestOpenCodePackageRender(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
e.service.OpenCodeVersion = func(string) (string, error) { return "2.3.0", nil }
|
||||
files, err := e.service.RenderNative(Mutation{Name: "native", Entry: entry(t, `{"bindings":{"opencode":{"code":"export default {}"}}}`)})
|
||||
must(t, err)
|
||||
if len(files) != 3 {
|
||||
t.Fatalf("%+v", files)
|
||||
}
|
||||
for _, file := range files {
|
||||
if file.Error != "" || file.Content == "" {
|
||||
t.Fatalf("%+v", file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodePackageNestedPaths(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
e.service.OpenCodeVersion = func(string) (string, error) { return "2.3.0", nil }
|
||||
files := map[string]string{"package.json": `{"name":"native","exports":"./index.js"}`, "index.js": "export default {}"}
|
||||
for _, dir := range []string{"hooks", "plugins", "extensions", "skillshare/nested", "plugins/skillshare-inner", "plugins/skillshare-native"} {
|
||||
files["lib/"+dir+"/helper.js"] = "export const helper = true"
|
||||
}
|
||||
m := Mutation{Name: "native", Entry: &Entry{Bindings: map[string]Binding{"opencode": {Package: files}}}}
|
||||
result := save(t, e.service, m)
|
||||
if r := sync(t, e.service); r.Plan.Blocked || len(r.Applied) != 0 {
|
||||
t.Fatalf("nested package is not a no-op: %+v", r.Plan)
|
||||
}
|
||||
for _, id := range result.BackupIDs {
|
||||
p, err := e.service.PreviewRestore(id)
|
||||
must(t, err)
|
||||
if p.Blocked {
|
||||
t.Fatalf("package backup parked: %+v", p)
|
||||
}
|
||||
}
|
||||
save(t, e.service, Mutation{Name: "native", Remove: true})
|
||||
if exists(filepath.Join(e.home, ".config/opencode/plugins/skillshare-native")) {
|
||||
t.Fatal("owned package remains")
|
||||
}
|
||||
}
|
||||
|
||||
const openCodeEntry = `{"bindings":{"opencode":{"code":"export default {}\n"}}}`
|
||||
|
||||
// A machine without a usable opencode binary still syncs every other Agent, and
|
||||
// leaves the OpenCode outputs it cannot lay out exactly as they are.
|
||||
func TestOpenCodeUndetectedVersionSkipsOnlyOpenCode(t *testing.T) {
|
||||
for name, probe := range map[string]func(string) (string, error){
|
||||
"missing binary": func(string) (string, error) { return "", errors.New("executable file not found in $PATH") },
|
||||
"future version": func(string) (string, error) { return "3.0.0", nil },
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
save(t, e.service, Mutation{Name: "a", Entry: entry(t, openCodeEntry)})
|
||||
save(t, e.service, Mutation{Name: "b", Entry: entry(t, openCodeEntry)})
|
||||
flat := filepath.Join(e.home, ".config/opencode/plugins/skillshare-a.ts")
|
||||
calls := 0
|
||||
e.service.OpenCodeVersion = func(bin string) (string, error) { calls++; return probe(bin) }
|
||||
r := save(t, e.service, Mutation{Name: "guard", Entry: entry(t, claudeEntry)})
|
||||
if r.Plan.Blocked || len(events(t, filepath.Join(e.home, ".claude/settings.json"), true)["PreToolUse"]) != 1 {
|
||||
t.Fatalf("claude did not sync: %+v", r.Plan)
|
||||
}
|
||||
if !exists(flat) {
|
||||
t.Fatal("owned OpenCode output removed while the version is unknown")
|
||||
}
|
||||
warnings := strings.Join(r.Plan.Warnings, "\n")
|
||||
if strings.Count(warnings, "its hook bindings are skipped") != 1 || !strings.Contains(warnings, "are left as they are") {
|
||||
t.Fatalf("warnings: %v", r.Plan.Warnings)
|
||||
}
|
||||
root := t.TempDir()
|
||||
save(t, e.service, Mutation{Project: root})
|
||||
r = save(t, e.service, Mutation{Project: root, Name: "a", Entry: entry(t, openCodeEntry)})
|
||||
if n := strings.Count(strings.Join(r.Plan.Warnings, "\n"), "its hook bindings are skipped"); n != 1 || exists(filepath.Join(root, ".opencode")) {
|
||||
t.Fatalf("project root: %d skip warnings: %v", n, r.Plan.Warnings)
|
||||
}
|
||||
calls = 0
|
||||
_, err := e.service.Preview()
|
||||
must(t, err)
|
||||
if calls != 1 {
|
||||
t.Fatalf("probe ran %d times for one plan", calls)
|
||||
}
|
||||
files, err := e.service.RenderNative(Mutation{Name: "a", Entry: entry(t, openCodeEntry)})
|
||||
must(t, err)
|
||||
if len(files) != 1 || !strings.Contains(files[0].Error, "skipped") {
|
||||
t.Fatalf("%+v", files)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodePackageOnV1IsSkipped(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
pkg := &Entry{Bindings: map[string]Binding{"opencode": {Package: map[string]string{"package.json": `{"name":"native","exports":"./index.js"}`, "index.js": "export default {}"}}}}
|
||||
r := save(t, e.service, Mutation{Name: "native", Entry: pkg})
|
||||
if r.Plan.Blocked || !strings.Contains(strings.Join(r.Plan.Warnings, "\n"), "requires OpenCode v2") {
|
||||
t.Fatalf("%+v", r.Plan)
|
||||
}
|
||||
if exists(filepath.Join(e.home, ".config/opencode/plugins/skillshare-native")) {
|
||||
t.Fatal("package written for OpenCode v1")
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodeDependencyWarningOnlyWhenWritten(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
e.service.OpenCodeVersion = func(string) (string, error) { return "2.3.0", nil }
|
||||
save(t, e.service, Mutation{Name: "a", Entry: entry(t, openCodeEntry)})
|
||||
r := save(t, e.service, Mutation{Name: "b", Entry: entry(t, openCodeEntry)})
|
||||
if n := strings.Count(strings.Join(r.Plan.Warnings, "\n"), openCodeDependencyWarning); n != 1 {
|
||||
t.Fatalf("warned %d times: %v", n, r.Plan.Warnings)
|
||||
}
|
||||
p, err := e.service.Preview()
|
||||
must(t, err)
|
||||
if len(p.Warnings) != 0 {
|
||||
t.Fatalf("synced packages still warn: %v", p.Warnings)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodePackageUpdateAndDowngrade(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
version := "2.3.0"
|
||||
e.service.OpenCodeVersion = func(string) (string, error) { return version, nil }
|
||||
manifest := `{"name":"native","exports":"./index.js"}`
|
||||
m := Mutation{Name: "native", Entry: &Entry{Bindings: map[string]Binding{"opencode": {Package: map[string]string{"package.json": manifest, "index.js": "export default {}", "lib/old.js": "old"}}}}}
|
||||
save(t, e.service, m)
|
||||
dir := filepath.Join(e.home, ".config/opencode/plugins/skillshare-native")
|
||||
m.Entry.Bindings["opencode"] = Binding{Package: map[string]string{"package.json": manifest, "index.js": "export default { changed: true }"}}
|
||||
save(t, e.service, m)
|
||||
if !strings.Contains(read(t, filepath.Join(dir, "index.js")), "changed") || exists(filepath.Join(dir, "lib/old.js")) {
|
||||
t.Fatal("package not updated in place")
|
||||
}
|
||||
save(t, e.service, Mutation{Name: "flat", Entry: entry(t, openCodeEntry)})
|
||||
version = "1.18.31"
|
||||
r := sync(t, e.service)
|
||||
config := filepath.Join(e.home, ".config/opencode/opencode.json")
|
||||
if exists(dir) || exists(filepath.Join(e.home, ".config/opencode/plugins/skillshare-flat")) || !exists(filepath.Join(e.home, ".config/opencode/plugins/skillshare-flat.ts")) {
|
||||
t.Fatalf("v2 outputs not retired on v1: %s", actions(r.Plan))
|
||||
}
|
||||
if exists(config) && strings.Contains(read(t, config), "skillshare-") {
|
||||
t.Fatal(read(t, config))
|
||||
}
|
||||
if r := sync(t, e.service); len(r.Applied) != 0 {
|
||||
t.Fatal(r.Applied)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodeImportKeepsOtherCandidatesBesideUnreadablePackage(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("symlink creation needs privileges on Windows")
|
||||
}
|
||||
e := newEnv(t)
|
||||
e.service.OpenCodeVersion = func(string) (string, error) { return "2.3.0", nil }
|
||||
plugins := filepath.Join(e.home, ".config/opencode/plugins")
|
||||
write(t, filepath.Join(plugins, "flat.ts"), "export default {}\n")
|
||||
for _, name := range []string{"good", "linked"} {
|
||||
write(t, filepath.Join(plugins, name, "package.json"), `{"name":"demo","exports":"./index.js"}`)
|
||||
write(t, filepath.Join(plugins, name, "index.js"), "export default {}\n")
|
||||
}
|
||||
must(t, os.Symlink(filepath.Join(e.home, "elsewhere"), filepath.Join(plugins, "linked", "bin")))
|
||||
candidates, err := e.service.Import(ImportRequest{From: "opencode"})
|
||||
must(t, err)
|
||||
problems := map[string][]string{}
|
||||
for _, c := range candidates {
|
||||
problems[c.Name] = c.Problems
|
||||
}
|
||||
if len(candidates) != 3 || len(problems["flat"]) != 0 || len(problems["good"]) != 0 {
|
||||
t.Fatalf("%+v", candidates)
|
||||
}
|
||||
if len(problems["linked"]) != 1 || !strings.Contains(problems["linked"][0], `"bin" cannot be imported`) {
|
||||
t.Fatalf("%v", problems["linked"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodeInvalidPackageProblemReportedOnce(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
e.service.OpenCodeVersion = func(string) (string, error) { return "2.3.0", nil }
|
||||
write(t, filepath.Join(e.home, ".config/opencode/plugins/broken/readme.md"), "no entry\n")
|
||||
candidates, err := e.service.Import(ImportRequest{From: "opencode"})
|
||||
must(t, err)
|
||||
if len(candidates) != 1 || len(candidates[0].Problems) != 1 {
|
||||
t.Fatalf("%+v", candidates)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodeV1DoesNotListDirectories(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
plugins := filepath.Join(e.home, ".config/opencode/plugins")
|
||||
write(t, filepath.Join(plugins, "lib/helper.js"), "export const helper = true\n")
|
||||
write(t, filepath.Join(plugins, "mine.ts"), "export const Mine = async () => ({})\n")
|
||||
inv, err := e.service.List()
|
||||
must(t, err)
|
||||
for _, u := range inv.Unmanaged {
|
||||
if u.Target == "opencode" && !slices.Equal(u.Names, []string{"mine.ts"}) {
|
||||
t.Fatalf("%+v", u)
|
||||
}
|
||||
}
|
||||
e.service.OpenCodeVersion = func(string) (string, error) { return "2.3.0", nil }
|
||||
inv, err = e.service.List()
|
||||
must(t, err)
|
||||
if !slices.ContainsFunc(inv.Unmanaged, func(u Unmanaged) bool { return u.Target == "opencode" && slices.Contains(u.Names, "lib") }) {
|
||||
t.Fatalf("%+v", inv.Unmanaged)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodeAccountProbesItsOwnCLI(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
work := filepath.Join(e.home, "work")
|
||||
must(t, os.MkdirAll(work, 0755))
|
||||
e.service.Accounts = map[string]Account{"work": {Agent: "opencode", Dir: work, CLI: "/opt/opencode-next"}}
|
||||
e.service.OpenCodeVersion = func(bin string) (string, error) {
|
||||
if bin == "/opt/opencode-next" {
|
||||
return "2.3.0", nil
|
||||
}
|
||||
return "1.18.31", nil
|
||||
}
|
||||
save(t, e.service, Mutation{Name: "native", Entry: &Entry{Bindings: map[string]Binding{"work": {Code: "export default {}\n"}, "opencode": {Code: "export default {}\n"}}}})
|
||||
if !exists(filepath.Join(work, "plugins/skillshare-native/package.json")) || !exists(filepath.Join(e.home, ".config/opencode/plugins/skillshare-native.ts")) {
|
||||
t.Fatal("each OpenCode home must follow its own CLI version")
|
||||
}
|
||||
}
|
||||
+36
-3
@@ -128,8 +128,10 @@ type desired struct {
|
||||
targets map[string]string // path -> target
|
||||
roots map[string]string // path -> root
|
||||
files map[string]wantFile
|
||||
warnings []string
|
||||
notes []Change
|
||||
// packageFiles are the files paths that belong to OpenCode v2 directory packages.
|
||||
packageFiles map[string]bool
|
||||
warnings []string
|
||||
notes []Change
|
||||
}
|
||||
|
||||
func (d *desired) addOwned(r record) {
|
||||
@@ -230,6 +232,28 @@ func (s *Service) renderScope(d *desired, root string, entries map[string]Entry)
|
||||
}
|
||||
dirOwner[canonical] = target
|
||||
def, _ := targetDef(agent)
|
||||
if agent == "opencode" {
|
||||
// The layout depends on the installed version. Without it only OpenCode
|
||||
// waits: the other Agents sync, and parkReason keeps what is already there.
|
||||
v2, err := sc.openCode2()
|
||||
if err != nil {
|
||||
// Said once per target, however many hooks and project roots bind it.
|
||||
if warning := fmt.Sprintf("target %s: %v; its hook bindings are skipped", target, err); !slices.Contains(d.warnings, warning) {
|
||||
d.warnings = append(d.warnings, warning)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if v2 {
|
||||
if err := sc.renderOpenCode(d, root, target, name, b, addFile); err != nil {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
}
|
||||
if b.Package != nil {
|
||||
d.warnings = append(d.warnings, fmt.Sprintf("hook %s: target %s: a directory package requires OpenCode v2; this binding is skipped", name, target))
|
||||
continue
|
||||
}
|
||||
}
|
||||
if def.Kind == KindCode || agent == "copilot" {
|
||||
path, err := sc.codePath(agent, name)
|
||||
if err != nil {
|
||||
@@ -485,6 +509,7 @@ func (s *Service) Preview() (*Plan, error) {
|
||||
|
||||
// previewSource plans a sync; replace and adopt are root + "\x00" + entry sets.
|
||||
func (s *Service) previewSource(source *Source, replace, adopt map[string]bool) (*Plan, error) {
|
||||
s = s.memoProbe()
|
||||
state, stateBytes, err := s.loadLedger()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -551,7 +576,11 @@ func (s *Service) previewSource(source *Source, replace, adopt map[string]bool)
|
||||
pl.note(r.Target, r.Path, r.Root, r.Entry, "release", "left in place; Skillshare no longer manages it")
|
||||
} else {
|
||||
pl.parked[key] = true
|
||||
dir := recordDir(r)
|
||||
scope := s
|
||||
if r.Root != "" {
|
||||
scope = s.scoped(r.Root)
|
||||
}
|
||||
dir := recordDir(r, scope.agentOf(r.Target))
|
||||
groupKey := r.Target + "\x00" + dir
|
||||
if parked[groupKey] == nil {
|
||||
parked[groupKey] = &parkedGroup{target: r.Target, dir: dir, reason: reason}
|
||||
@@ -627,6 +656,10 @@ func (s *Service) previewSource(source *Source, replace, adopt map[string]bool)
|
||||
p.files = append(p.files, f)
|
||||
}
|
||||
slices.SortStableFunc(p.files, func(a, b *filePlan) int { return gitWritePriority(a) - gitWritePriority(b) })
|
||||
// Said when a package is written, not on every preview, so a synced hook is in sync.
|
||||
if slices.ContainsFunc(p.files, func(f *filePlan) bool { return d.packageFiles[f.path] && f.changed() }) {
|
||||
p.Warnings = append(p.Warnings, openCodeDependencyWarning)
|
||||
}
|
||||
for _, f := range p.files {
|
||||
fingerprint += fmt.Sprintf("%s\x00%s\x00%t\x00%s\n", f.path, f.kind, f.exists, f.section)
|
||||
}
|
||||
|
||||
@@ -18,8 +18,9 @@ type RenderedFile struct {
|
||||
}
|
||||
|
||||
// RenderNative shows what one hook writes, per Agent, without the rest of any existing
|
||||
// file. It reads no ownership state or native file contents, writes nothing and runs
|
||||
// nothing. A disabled entry renders its stored bindings, which sync would not write.
|
||||
// file. It reads no ownership state or native file contents and writes nothing.
|
||||
// OpenCode runs only a read-only version probe. A disabled entry renders its stored
|
||||
// bindings, which sync would not write.
|
||||
// A binding whose path cannot be resolved or safely written reports its own error.
|
||||
func (s *Service) RenderNative(m Mutation) ([]RenderedFile, error) {
|
||||
if m.Remove || m.Replace {
|
||||
@@ -67,6 +68,7 @@ func (s *Service) RenderNative(m Mutation) ([]RenderedFile, error) {
|
||||
return nil, err
|
||||
}
|
||||
entry.Enabled = nil
|
||||
scope = scope.memoProbe()
|
||||
out := []RenderedFile{}
|
||||
for _, target := range sortedKeys(entry.Bindings) {
|
||||
one := Entry{Bindings: map[string]Binding{target: entry.Bindings[target]}}
|
||||
@@ -76,7 +78,7 @@ func (s *Service) RenderNative(m Mutation) ([]RenderedFile, error) {
|
||||
continue
|
||||
}
|
||||
// A skipped account home writes nothing; say why instead of rendering no file.
|
||||
if len(d.warnings) > 0 {
|
||||
if len(d.warnings) > 0 && len(d.files)+len(d.elements)+len(d.git) == 0 {
|
||||
out = append(out, RenderedFile{Target: target, Error: strings.Join(d.warnings, "; ")})
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ type Service struct {
|
||||
ConfigDirs map[string]string
|
||||
Accounts map[string]Account // global scope only
|
||||
scopedAccount string
|
||||
Git GitRunner
|
||||
// OpenCodeVersion is an injectable read-only version probe.
|
||||
OpenCodeVersion func(string) (string, error)
|
||||
Git GitRunner
|
||||
// GitGlobalConfig is the file override Git honors in GIT_CONFIG_GLOBAL.
|
||||
GitGlobalConfig string
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
"%dp0%\node_modules\opencode-ai\bin\opencode.exe" %*
|
||||
@@ -0,0 +1,76 @@
|
||||
// Package opencode describes native loader inputs without loading plugin code.
|
||||
package opencode
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ConfigKey recognizes the installed major rather than guessing a future API.
|
||||
func ConfigKey(version string) (string, error) {
|
||||
fields := strings.Fields(version)
|
||||
if len(fields) > 0 {
|
||||
v := strings.TrimPrefix(fields[len(fields)-1], "v")
|
||||
if strings.HasPrefix(v, "1.") {
|
||||
return "plugin", nil
|
||||
}
|
||||
if strings.HasPrefix(v, "2.") {
|
||||
return "plugins", nil
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("unrecognized OpenCode version; supports versions 1.x and 2.x")
|
||||
}
|
||||
|
||||
// FileURL keeps the native file URL spelling used by existing receipts.
|
||||
func FileURL(p string) string {
|
||||
return (&url.URL{Scheme: "file", Path: filepath.ToSlash(p)}).String()
|
||||
}
|
||||
|
||||
// Package validates the server entry selected by OpenCode v2. It leaves exports,
|
||||
// dependencies intact. Conditional server exports fail closed; read never executes code.
|
||||
func Package(read func(string) ([]byte, error)) error {
|
||||
var m struct {
|
||||
Name string `json:"name"`
|
||||
Exports any `json:"exports"`
|
||||
}
|
||||
data, err := read("package.json")
|
||||
if err != nil {
|
||||
return fmt.Errorf("OpenCode package.json: %w", err)
|
||||
}
|
||||
if err = json.Unmarshal(data, &m); err != nil {
|
||||
return fmt.Errorf("OpenCode package.json: %w", err)
|
||||
}
|
||||
if m.Name != "" && m.Exports != nil {
|
||||
exports := m.Exports
|
||||
if obj, ok := exports.(map[string]any); ok {
|
||||
if server, has := obj["./server"]; has {
|
||||
exports = server
|
||||
} else if root, has := obj["."]; has {
|
||||
exports = root
|
||||
}
|
||||
}
|
||||
entry, ok := exports.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("OpenCode server exports must be a string (. or ./server); conditional and fallback exports cannot be verified offline")
|
||||
}
|
||||
if !strings.HasPrefix(entry, "./") || strings.ContainsAny(entry, "\\:") || !filepath.IsLocal(filepath.FromSlash(strings.TrimPrefix(entry, "./"))) {
|
||||
return fmt.Errorf("OpenCode export %q must stay inside the package", entry)
|
||||
}
|
||||
if _, err := read(path.Clean(strings.TrimPrefix(entry, "./"))); err != nil {
|
||||
return fmt.Errorf("OpenCode export %q is missing: %w", entry, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
for _, base := range []string{"server", "index"} {
|
||||
for _, ext := range []string{".ts", ".tsx", ".js"} {
|
||||
if _, err := read(base + ext); err == nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("OpenCode v2 package requires name and exports, or a root server/index .ts, .tsx or .js file; --entry cannot override the directory loader")
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package opencode
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPackageLoaderInputs(t *testing.T) {
|
||||
for _, tt := range []struct {
|
||||
name, manifest, entry string
|
||||
valid bool
|
||||
}{
|
||||
{"kata", `{"name":"kata-native-agent-hooks","type":"module","exports":"./index.js","dependencies":{"@opencode/plugin":"^2.0.0"}}`, "index.js", true},
|
||||
{"server", `{"name":"demo","exports":{"./server":"./src/server.ts",".":"./other.js"}}`, "src/server.ts", true},
|
||||
{"root export", `{"name":"demo","exports":{".":"./src/plugin.js"}}`, "src/plugin.js", true},
|
||||
{"convention", `{"name":"demo","main":"missing.js"}`, "server.tsx", true},
|
||||
{"missing export", `{"name":"demo","exports":"./missing.js"}`, "index.js", false},
|
||||
{"explicit only", `{"name":"demo","main":"src/plugin.js"}`, "src/plugin.js", false},
|
||||
{"unnamed export", `{"exports":"./src/plugin.js"}`, "src/plugin.js", false},
|
||||
{"conditional", `{"name":"demo","exports":{".":{"import":"./index.js","require":null}}}`, "index.js", false},
|
||||
{"escape", `{"name":"demo","exports":"./../index.js"}`, "../index.js", false},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
files := map[string]string{"package.json": tt.manifest, tt.entry: "export default {}"}
|
||||
err := Package(func(name string) ([]byte, error) {
|
||||
v, ok := files[name]
|
||||
if !ok {
|
||||
return nil, fs.ErrNotExist
|
||||
}
|
||||
return []byte(v), nil
|
||||
})
|
||||
if (err == nil) != tt.valid {
|
||||
t.Fatalf("valid=%v: %v", tt.valid, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,12 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"skillshare/internal/opencode"
|
||||
)
|
||||
|
||||
// NormalizeTarget resolves the Antigravity CLI nickname without changing stored keys.
|
||||
@@ -266,5 +267,28 @@ func (s *Service) applyAdditional(ctx context.Context, c Change, b Binding) erro
|
||||
}
|
||||
|
||||
func fileURL(path string) string {
|
||||
return (&url.URL{Scheme: "file", Path: filepath.ToSlash(path)}).String()
|
||||
return opencode.FileURL(path)
|
||||
}
|
||||
|
||||
func isRegularFile(path string) bool {
|
||||
info, err := os.Stat(path)
|
||||
return err == nil && info.Mode().IsRegular()
|
||||
}
|
||||
|
||||
// openCodeDirectory checks only native loader files, never dependencies or code.
|
||||
func openCodeDirectory(root string) error {
|
||||
return opencode.Package(func(name string) ([]byte, error) {
|
||||
path := filepath.Join(root, filepath.FromSlash(name))
|
||||
if err := noSymlink(root, path); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
info, err := os.Lstat(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !info.Mode().IsRegular() {
|
||||
return nil, fmt.Errorf("OpenCode package entry must be a regular file: %s", path)
|
||||
}
|
||||
return os.ReadFile(path)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -73,7 +73,9 @@ func (r Request) isolatesTargets() bool {
|
||||
// ProblemKey names the sentence the dashboard can translate and ProblemArgs fill its
|
||||
// {placeholders}. Problem stays the English the CLI prints, and is the fallback.
|
||||
type TargetPackage struct {
|
||||
Manifest string `json:"manifest"`
|
||||
openCodeV1Error string
|
||||
openCodeV2Error string
|
||||
Manifest string `json:"manifest"`
|
||||
// Path is set when this Agent's catalog points at its own folder; empty means Candidate.Path.
|
||||
Path string `json:"path,omitempty"`
|
||||
Marketplace string `json:"marketplace,omitempty"`
|
||||
|
||||
@@ -29,6 +29,23 @@ func openCodeImportPath(id string) string {
|
||||
return filepath.FromSlash(path)
|
||||
}
|
||||
|
||||
// openCodeLocalPath resolves native relative registrations from their containing
|
||||
// config, keeping the original ID untouched for inventory matching and removal.
|
||||
func (s *Service) openCodeLocalPath(target, id string) (string, error) {
|
||||
path := openCodeImportPath(id)
|
||||
if filepath.IsAbs(path) {
|
||||
return path, nil
|
||||
}
|
||||
if strings.HasPrefix(id, "./") || strings.HasPrefix(id, "../") {
|
||||
config, err := s.openCodeConfigPath(target)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Clean(filepath.Join(filepath.Dir(config), filepath.FromSlash(id))), nil
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// A native file belongs to a package only when that package resolves to this
|
||||
// entry. Npm identifiers have no local root and keep their inventory identity.
|
||||
func openCodeImportRoot(id, entry string) (string, bool) {
|
||||
@@ -37,6 +54,10 @@ func openCodeImportRoot(id, entry string) (string, bool) {
|
||||
return "", !strings.HasPrefix(id, "file:")
|
||||
}
|
||||
info, err := os.Stat(path)
|
||||
if err == nil && info.IsDir() {
|
||||
err = openCodeDirectory(path)
|
||||
return path, err == nil
|
||||
}
|
||||
if err != nil || !info.Mode().IsRegular() {
|
||||
return "", false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func openCodePackageService(t *testing.T, version *string) *Service {
|
||||
t.Helper()
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
||||
for _, key := range []string{"OPENCODE_CONFIG", "OPENCODE_CONFIG_DIR", "OPENCODE_CONFIG_CONTENT"} {
|
||||
t.Setenv(key, "")
|
||||
}
|
||||
return &Service{ConfigPath: filepath.Join(home, "config.yaml"), StateDir: filepath.Join(home, "state"), Run: func(_ context.Context, _ string, _ []string, bin string, args ...string) ([]byte, error) {
|
||||
if bin != "opencode" || len(args) != 1 || args[0] != "--version" {
|
||||
return nil, fmt.Errorf("unexpected command %s %v", bin, args)
|
||||
}
|
||||
return []byte(*version), nil
|
||||
}}
|
||||
}
|
||||
|
||||
func TestOpenCodeDirectoryPackageLifecycle(t *testing.T) {
|
||||
version := "2.3.0"
|
||||
s := openCodePackageService(t, &version)
|
||||
source := t.TempDir()
|
||||
manifest := `{"name":"kata-native-agent-hooks","type":"module","exports":"./index.js","dependencies":{"@opencode/plugin":"^2.0.0"},"kata":{"api":"v2"}}`
|
||||
writePluginFile(t, source, "package.json", manifest)
|
||||
writePluginFile(t, source, "index.js", "export default {}")
|
||||
add := Request{Action: "add", Name: "native", Source: source, Targets: []string{"opencode"}, Entry: "index.js"}
|
||||
p, err := s.Preview(context.Background(), add)
|
||||
if err != nil || p.Blocked {
|
||||
t.Fatalf("%+v %v", p, err)
|
||||
}
|
||||
id := p.Changes[0].ID
|
||||
if filepath.Base(openCodeImportPath(id)) != "content" {
|
||||
t.Fatalf("not directory: %s", id)
|
||||
}
|
||||
applyPluginRequest(t, s, add)
|
||||
root := openCodeImportPath(id)
|
||||
if b, err := os.ReadFile(filepath.Join(root, "package.json")); err != nil || string(b) != manifest {
|
||||
t.Fatalf("manifest lost: %s %v", b, err)
|
||||
}
|
||||
for i := 0; i < 2; i++ {
|
||||
p, err = s.Preview(context.Background(), Request{Action: "sync"})
|
||||
if err != nil || p.Blocked || len(p.Changes) != 1 || p.Changes[0].Action != "noop" {
|
||||
t.Fatalf("not noop: %+v %v", p, err)
|
||||
}
|
||||
applyPluginRequest(t, s, Request{Action: "sync"})
|
||||
}
|
||||
writePluginFile(t, source, "index.js", "export default { changed: true }")
|
||||
applyPluginRequest(t, s, Request{Action: "update", Name: "native", Targets: []string{"opencode"}})
|
||||
if b, err := os.ReadFile(filepath.Join(root, "index.js")); err != nil || !strings.Contains(string(b), "changed") {
|
||||
t.Fatalf("not updated: %s %v", b, err)
|
||||
}
|
||||
// Removal unregisters the plugin but retains reviewed snapshots, as for v1.
|
||||
snapshotUnchanged := unchanged(t, filepath.Join(root, "package.json"), filepath.Join(root, "index.js"))
|
||||
applyPluginRequest(t, s, Request{Action: "remove", Name: "native"})
|
||||
h := s.host(context.Background(), "opencode")
|
||||
if h.Error != "" || len(h.Installed) != 0 {
|
||||
t.Fatalf("%+v", h)
|
||||
}
|
||||
snapshotUnchanged()
|
||||
}
|
||||
|
||||
func TestOpenCodeDirectoryImportAndFlatRefusal(t *testing.T) {
|
||||
for _, tt := range []struct{ scope, id string }{{"global", ""}, {"project", "./plugins/demo"}, {"account", "../native/demo"}} {
|
||||
t.Run(tt.scope, func(t *testing.T) {
|
||||
version := "2.3.0"
|
||||
s := openCodePackageService(t, &version)
|
||||
target := "opencode"
|
||||
if tt.scope == "project" {
|
||||
s.ProjectRoot = t.TempDir()
|
||||
}
|
||||
if tt.scope == "account" {
|
||||
target = "opencode-work"
|
||||
s.Accounts = map[string]Account{target: {Agent: "opencode", Dir: t.TempDir()}}
|
||||
}
|
||||
file, err := s.openCodeConfigPath(target)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
source := t.TempDir()
|
||||
id := fileURL(source)
|
||||
if tt.id != "" {
|
||||
id = tt.id
|
||||
source = filepath.Clean(filepath.Join(filepath.Dir(file), filepath.FromSlash(id)))
|
||||
}
|
||||
writePluginFile(t, source, "package.json", `{"name":"demo","exports":"./index.js","dependencies":{"@opencode/plugin":"^2.0.0"}}`)
|
||||
writePluginFile(t, source, "index.js", "export default {}")
|
||||
writePluginFile(t, filepath.Dir(file), filepath.Base(file), `{"plugins":["`+id+`"]}`)
|
||||
matches, err := s.importMatchesRecipe(context.Background(), target, Installed{ID: id}, declaration{Source: source, Plugin: "demo"})
|
||||
if err != nil || !matches {
|
||||
t.Fatalf("directory identity: %v %v", matches, err)
|
||||
}
|
||||
applyPluginRequest(t, s, Request{Action: "import", Name: "native", From: target, Plugin: id})
|
||||
applyPluginRequest(t, s, Request{Action: "sync"})
|
||||
data, err := os.ReadFile(file)
|
||||
if err != nil || !strings.Contains(string(data), id) {
|
||||
t.Fatalf("registration spelling changed: %s %v", data, err)
|
||||
}
|
||||
p, err := s.Preview(context.Background(), Request{Action: "update", Name: "native", Targets: []string{target}})
|
||||
if err != nil || len(p.Changes) != 1 || p.Changes[0].Action != "skip" {
|
||||
t.Fatalf("local update must not install dependencies: %+v %v", p, err)
|
||||
}
|
||||
applyPluginRequest(t, s, Request{Action: "remove", Name: "native"})
|
||||
if _, err := os.Stat(filepath.Join(source, "index.js")); err != nil {
|
||||
t.Fatal("import removed original package", err)
|
||||
}
|
||||
flat := id + "/index.js"
|
||||
writePluginFile(t, filepath.Dir(file), filepath.Base(file), `{"plugins":["`+flat+`"]}`)
|
||||
p, err = s.Preview(context.Background(), Request{Action: "import", Name: "flat", From: target, Plugin: flat})
|
||||
if err != nil || !p.Blocked {
|
||||
t.Fatalf("flat import accepted: %+v %v", p, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodeVersionChangesInvalidatePreview(t *testing.T) {
|
||||
version := "1.18.31"
|
||||
s := openCodePackageService(t, &version)
|
||||
source := t.TempDir()
|
||||
writePluginFile(t, source, "package.json", `{"name":"demo","main":"index.js","dependencies":{"@opencode-ai/plugin":"1"}}`)
|
||||
writePluginFile(t, source, "index.js", "export const Demo = async () => ({})")
|
||||
add := Request{Action: "add", Source: source, Targets: []string{"opencode"}}
|
||||
p, err := s.Preview(context.Background(), add)
|
||||
if err != nil || p.Blocked {
|
||||
t.Fatalf("%+v %v", p, err)
|
||||
}
|
||||
if !strings.HasSuffix(p.Changes[0].ID, "/index.js") {
|
||||
t.Fatal(p.Changes[0].ID)
|
||||
}
|
||||
version = "2.3.0"
|
||||
if _, err := s.Apply(context.Background(), add, p.Revision); err == nil {
|
||||
t.Fatal("runtime change accepted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodeDirectoryRejectsEscapingEntry(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
outside := filepath.Join(t.TempDir(), "entry.js")
|
||||
writePluginFile(t, filepath.Dir(outside), filepath.Base(outside), "export default {}")
|
||||
writePluginFile(t, root, "package.json", `{"name":"demo","exports":"./index.js"}`)
|
||||
if err := os.Symlink(outside, filepath.Join(root, "index.js")); err != nil {
|
||||
t.Skipf("symlinks unavailable: %v", err)
|
||||
}
|
||||
if _, ok := openCodeImportRoot(fileURL(root), ""); ok {
|
||||
t.Fatal("escaping directory import accepted")
|
||||
}
|
||||
}
|
||||
|
||||
// Hooks registers its own v2 packages in the array plugins reads.
|
||||
func TestOpenCodeInventoryLeavesHookPackagesToHooks(t *testing.T) {
|
||||
version := "2.3.0"
|
||||
s := openCodePackageService(t, &version)
|
||||
file, err := s.openCodeConfigPath("opencode")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hook := filepath.Join(filepath.Dir(file), "plugins", "skillshare-guard")
|
||||
writePluginFile(t, hook, "package.json", `{"name":"skillshare-guard","exports":"./index.ts"}`)
|
||||
writePluginFile(t, hook, "index.ts", "export default {}")
|
||||
writePluginFile(t, filepath.Dir(file), filepath.Base(file), `{"plugins":["`+fileURL(hook)+`","other"]}`)
|
||||
h := s.host(context.Background(), "opencode")
|
||||
if h.Error != "" || len(h.Installed) != 1 || h.Installed[0].ID != "other" {
|
||||
t.Fatalf("%+v", h)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodeV2BlocksSourceWithoutLoaderEntry(t *testing.T) {
|
||||
version := "2.3.0"
|
||||
s := openCodePackageService(t, &version)
|
||||
source := t.TempDir()
|
||||
writePluginFile(t, source, "package.json", `{"name":"demo","main":"plugins/demo.js","dependencies":{"@opencode-ai/plugin":"1"}}`)
|
||||
writePluginFile(t, source, "plugins/demo.js", "export const Demo = async () => ({})")
|
||||
p, err := s.Preview(context.Background(), Request{Action: "add", Name: "flat", Source: source, Targets: []string{"opencode"}})
|
||||
if err != nil || !p.Blocked || len(p.Changes) != 1 || p.Changes[0].Action != "blocked" {
|
||||
t.Fatalf("%+v %v", p, err)
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"skillshare/internal/opencode"
|
||||
|
||||
"github.com/gofrs/flock"
|
||||
"github.com/tailscale/hujson"
|
||||
)
|
||||
@@ -203,17 +205,7 @@ func openCode2(version string) bool {
|
||||
|
||||
// openCodeKey reads `opencode --version`: OpenCode 1 prints 1.x, OpenCode 2 "opencode v2.x".
|
||||
func openCodeKey(version string) (string, error) {
|
||||
v := ""
|
||||
if fields := strings.Fields(version); len(fields) > 0 {
|
||||
v = strings.TrimPrefix(fields[len(fields)-1], "v")
|
||||
}
|
||||
if strings.HasPrefix(v, "1.") {
|
||||
return "plugin", nil
|
||||
}
|
||||
if strings.HasPrefix(v, "2.") {
|
||||
return "plugins", nil
|
||||
}
|
||||
return "", fmt.Errorf("unrecognized OpenCode version; plugin config adapter supports versions 1.x and 2.x")
|
||||
return opencode.ConfigKey(version)
|
||||
}
|
||||
|
||||
func readPackageConfig(root, path, key string) ([]byte, *hujson.Value, []json.RawMessage, error) {
|
||||
@@ -289,6 +281,13 @@ func (s *Service) openCodeInventory(target, version string) ([]Installed, string
|
||||
if key == "plugins" && (strings.HasPrefix(id, "-") || id == "*" || strings.HasSuffix(id, ".*")) {
|
||||
continue
|
||||
}
|
||||
// A hook synced to OpenCode v2 registers plugins/skillshare-NAME in this same
|
||||
// array. Hooks owns it, so it is neither listed nor offered for import here.
|
||||
if key == "plugins" && strings.HasPrefix(id, "file:") {
|
||||
if hook := openCodeImportPath(id); filepath.Dir(hook) == filepath.Join(filepath.Dir(path), "plugins") && strings.HasPrefix(filepath.Base(hook), "skillshare-") {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if !validTargetID("opencode", id) {
|
||||
return nil, "", fmt.Errorf("unsupported OpenCode plugin control entry; manage it in OpenCode")
|
||||
}
|
||||
@@ -314,6 +313,21 @@ func (s *Service) applyOpenCode(ctx context.Context, c Change, b Binding) error
|
||||
_, err := s.run(ctx, c.Target, "plugin", "update", b.ID)
|
||||
return err
|
||||
}
|
||||
if b.Source != "" && (c.Action == "install" || c.Action == "update") {
|
||||
root := openCodeImportPath(b.ID)
|
||||
info, err := os.Stat(root)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (key == "plugins") != info.IsDir() {
|
||||
return fmt.Errorf("OpenCode API changed or registration has the wrong layout; preview again")
|
||||
}
|
||||
if key == "plugins" {
|
||||
if err := openCodeDirectory(root); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
path, err := s.openCodeConfigPath(c.Target)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -301,7 +301,11 @@ func (s *Service) preview(ctx context.Context, r Request, cleanup *ompRemoval) (
|
||||
b.ID = filepath.Join(s.snapshotPath(b, target), "content", filepath.FromSlash(c.pathFor(agent)))
|
||||
case "opencode":
|
||||
b.Entry = c.Entry
|
||||
b.ID = fileURL(filepath.Join(s.snapshotPath(b, target), "content", filepath.FromSlash(c.pathFor(agent)), c.Entry))
|
||||
path := filepath.Join(s.snapshotPath(b, target), "content", filepath.FromSlash(c.pathFor(agent)))
|
||||
if !openCode2(host(target).Version) {
|
||||
path = filepath.Join(path, c.Entry)
|
||||
}
|
||||
b.ID = fileURL(path)
|
||||
}
|
||||
recipe := declareBinding(b)
|
||||
change := Change{Name: name, Target: target, ID: b.ID, Binding: b, Action: "install", Components: b.Components, recipe: &recipe, sourceVersion: &c.Version}
|
||||
@@ -315,11 +319,20 @@ func (s *Service) preview(ctx context.Context, r Request, cleanup *ompRemoval) (
|
||||
change.Message = "No native manifest for this target; plugin components will not be silently converted or omitted."
|
||||
}
|
||||
}
|
||||
if agent == "opencode" {
|
||||
problem := c.TargetInfo[agent].openCodeV1Error
|
||||
if openCode2(host(target).Version) {
|
||||
problem = c.TargetInfo[agent].openCodeV2Error
|
||||
}
|
||||
if problem != "" {
|
||||
change.Action, change.Message = "blocked", problem
|
||||
}
|
||||
}
|
||||
if old, ok := d.packages[name].Bindings[target]; ok && old.ID != "" && !old.Cleanup {
|
||||
if old.Source == b.Source && old.Plugin == b.Plugin && old.SourceRef == b.SourceRef || d.intent[name].Bindings[target].Source == b.Source && d.intent[name].Bindings[target].Plugin == b.Plugin && d.intent[name].Bindings[target].SourceRef == b.SourceRef {
|
||||
change.Binding = old
|
||||
change.ID = old.ID
|
||||
if _, ok := find(target, old.ID); ok {
|
||||
if _, ok := find(target, old.ID); ok && change.Action != "blocked" {
|
||||
change.Action = "noop"
|
||||
}
|
||||
} else {
|
||||
@@ -710,6 +723,20 @@ func (s *Service) prepareChange(ctx context.Context, r Request, d *document, hos
|
||||
if h.Error != "" && c.Action != "blocked" && c.Action != "skip" {
|
||||
failChange(h.Error, h.ErrorKey, h.ErrorArgs)
|
||||
}
|
||||
if agent == "opencode" && openCode2(h.Version) && c.Action != "remove" && c.Action != "uninstall" && c.Action != "forget" && c.Action != "blocked" {
|
||||
path, err := s.openCodeLocalPath(c.Target, c.ID)
|
||||
if err != nil {
|
||||
failChange(err.Error(), "", nil)
|
||||
}
|
||||
if path != "" && isRegularFile(path) {
|
||||
failChange("OpenCode v2 requires a directory registration, not a plugin file; remove this binding and add its package again.", "plugins.problem.opencodeDirectory", nil)
|
||||
}
|
||||
if path != "" && c.Binding.Source == "" && c.Action != "blocked" && c.Action != "skip" {
|
||||
if err := openCodeDirectory(path); err != nil {
|
||||
failChange(err.Error(), "", nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
// An update that cannot reach a target skips it, so the plugin's other Agents still update.
|
||||
skip := func(key, message string, args map[string]string) {
|
||||
c.Action = "skip"
|
||||
@@ -748,6 +775,14 @@ func (s *Service) prepareChange(ctx context.Context, r Request, d *document, hos
|
||||
if c.Action == "update" && c.Binding.Source == "" && (s.ProjectRoot != "" && agent == "pi" || agent == "omp") || c.Action == "update" && c.Binding.Source == "" && agent == "opencode" && (s.ProjectRoot != "" || !openCode2(h.Version)) {
|
||||
skip("plugins.skip.imported", "Update imported packages in the native client; Skillshare updates reviewed source snapshots only.", nil)
|
||||
}
|
||||
if c.Action == "update" && agent == "opencode" && c.Binding.Source == "" {
|
||||
path, err := s.openCodeLocalPath(c.Target, c.ID)
|
||||
if err != nil {
|
||||
failChange(err.Error(), "", nil)
|
||||
} else if path != "" {
|
||||
skip("plugins.skip.opencodeLocal", "Imported local package: edit it at its source; Skillshare does not run a dependency installer.", nil)
|
||||
}
|
||||
}
|
||||
if c.Action == "update" && agent == "opencode" && c.Binding.Source == "" {
|
||||
help, err := s.run(ctx, c.Target, "plugin", "update", "--help")
|
||||
if err != nil || !strings.Contains(string(help), "update") {
|
||||
@@ -901,6 +936,16 @@ func (s *Service) checkOrUpdate(ctx context.Context, r Request, c Change, action
|
||||
return c, nil
|
||||
}
|
||||
|
||||
if agent == "opencode" {
|
||||
problem := candidate.TargetInfo[agent].openCodeV1Error
|
||||
if openCode2(host.Version) {
|
||||
problem = candidate.TargetInfo[agent].openCodeV2Error
|
||||
}
|
||||
if problem != "" {
|
||||
c.Action, c.Message = "blocked", problem
|
||||
return c, nil
|
||||
}
|
||||
}
|
||||
c.Components, c.sourceVersion = candidate.TargetInfo[agent].Components, &candidate.Version
|
||||
if disc.Digest == b.Digest && b.Pending == "" && source == b.Source && ref == b.SourceRef && plugin == b.Plugin && entry == b.Entry {
|
||||
c.Action = "noop"
|
||||
|
||||
@@ -94,13 +94,20 @@ func inspect(root string, explicit ...string) (Candidate, error) {
|
||||
for _, key := range []string{"dependencies", "peerDependencies", "devDependencies"} {
|
||||
var deps map[string]json.RawMessage
|
||||
_ = json.Unmarshal(m[key], &deps)
|
||||
sdk = sdk || deps["@opencode-ai/plugin"] != nil
|
||||
sdk = sdk || deps["@opencode-ai/plugin"] != nil || deps["@opencode/plugin"] != nil
|
||||
}
|
||||
if !sdk && (len(explicit) == 0 || explicit[0] == "") && !strings.HasPrefix(filepath.ToSlash(filepath.Clean(main)), ".opencode/plugins/") {
|
||||
continue
|
||||
}
|
||||
info.Entry, err = openCodeEntry(root, explicit...)
|
||||
if err != nil {
|
||||
info.openCodeV1Error = err.Error()
|
||||
}
|
||||
v2Err := openCodeDirectory(root)
|
||||
if v2Err != nil {
|
||||
info.openCodeV2Error = v2Err.Error()
|
||||
}
|
||||
if err != nil && v2Err != nil {
|
||||
var keyed agentError
|
||||
errors.As(err, &keyed)
|
||||
info.block(keyed.key, err.Error(), keyed.args)
|
||||
|
||||
@@ -397,7 +397,7 @@ func (s *Service) ownedSnapshot(b Binding, target string) bool {
|
||||
if c.Name == b.Plugin {
|
||||
path := filepath.Join(root, "content", filepath.FromSlash(c.pathFor(agent)))
|
||||
if agent == "opencode" {
|
||||
return b.ID == fileURL(filepath.Join(path, c.Entry))
|
||||
return b.ID == fileURL(path) || b.ID == fileURL(filepath.Join(path, c.Entry))
|
||||
}
|
||||
return b.ID == path
|
||||
}
|
||||
@@ -491,7 +491,13 @@ func (s *Service) importMatchesRecipe(ctx context.Context, target string, instal
|
||||
case isNpmSource(installed.ID):
|
||||
nativeName = logicalName(installed.ID)
|
||||
case agent == "opencode":
|
||||
root, ok := openCodeImportRoot(installed.ID, decl.Entry)
|
||||
id := installed.ID
|
||||
if path, err := s.openCodeLocalPath(target, id); err != nil {
|
||||
return false, err
|
||||
} else if path != "" {
|
||||
id = path
|
||||
}
|
||||
root, ok := openCodeImportRoot(id, decl.Entry)
|
||||
if !ok {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ func hooksAccounts(cfg *config.Config) map[string]hooks.Account {
|
||||
accounts := map[string]hooks.Account{}
|
||||
for name, target := range cfg.Targets {
|
||||
if target.Agent != "" && target.ConfigDir != "" {
|
||||
accounts[name] = hooks.Account{Agent: target.Agent, Dir: target.ConfigDir}
|
||||
accounts[name] = hooks.Account{Agent: target.Agent, Dir: target.ConfigDir, CLI: target.CLI}
|
||||
}
|
||||
}
|
||||
return accounts
|
||||
|
||||
@@ -1070,5 +1070,13 @@
|
||||
"root": "uiDir",
|
||||
"reason": "assets",
|
||||
"note": "Clean old extracted UI distributions"
|
||||
},
|
||||
{
|
||||
"file": "internal/hooks/opencode.go",
|
||||
"function": "(*Service).importOpenCodePackages",
|
||||
"callee": "fs.WalkDir",
|
||||
"root": "\".\"",
|
||||
"reason": "hooks",
|
||||
"note": "Read native package files without following symlinks; dependencies excluded"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -37,6 +37,30 @@
|
||||
"codeFile": {"type": "string", "minLength": 1, "description": "Instead of code: a path, relative to the config's folder and inside it, whose contents are used as code. Read every time the config is read."}
|
||||
}
|
||||
},
|
||||
"openCodeBinding": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/$defs/codeBinding"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"package"
|
||||
],
|
||||
"properties": {
|
||||
"package": {
|
||||
"type": "object",
|
||||
"minProperties": 1,
|
||||
"description": "OpenCode v2 directory package: relative filenames mapped to UTF-8 contents, including package.json. Dependencies are preserved, never installed.",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"gitBinding": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
@@ -148,7 +172,7 @@
|
||||
"pi": {"$ref": "#/$defs/codeBinding"},
|
||||
"omp": {"$ref": "#/$defs/codeBinding"},
|
||||
"amp": {"$ref": "#/$defs/codeBinding"},
|
||||
"opencode": {"$ref": "#/$defs/codeBinding"}
|
||||
"opencode": {"$ref": "#/$defs/openCodeBinding"}
|
||||
}
|
||||
},
|
||||
"globalBindings": {
|
||||
@@ -170,12 +194,12 @@
|
||||
"pi": {"$ref": "#/$defs/codeBinding"},
|
||||
"omp": {"$ref": "#/$defs/codeBinding"},
|
||||
"amp": {"$ref": "#/$defs/codeBinding"},
|
||||
"opencode": {"$ref": "#/$defs/codeBinding"}
|
||||
"opencode": {"$ref": "#/$defs/openCodeBinding"}
|
||||
},
|
||||
"patternProperties": {
|
||||
"^(?!(claude|codex|gemini|qwen|copilot|cursor|droid|factory|antigravity|antigravity-cli|agy|pi|omp|amp|opencode|git)$)[A-Za-z0-9][A-Za-z0-9._-]*$": {
|
||||
"description": "Account keys are declared under targets with agent and config_dir and are valid in global config only.",
|
||||
"anyOf": [{"$ref": "#/$defs/commandBinding"}, {"$ref": "#/$defs/codeBinding"}]
|
||||
"anyOf": [{"$ref": "#/$defs/commandBinding"}, {"$ref": "#/$defs/openCodeBinding"}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -119,3 +119,22 @@ Git bindings refuse `--keep-files`. Git import, scripts bindings, hookdir
|
||||
scanning/recognizers and doctor checks are not implemented in this phase.
|
||||
Inspect old hookdir copies manually before migration; Git can execute both.
|
||||
Management never executes hooks. Native Windows execution is unverified.
|
||||
|
||||
OpenCode probes the installed major with `--version`: v1 keeps flat `.ts` output;
|
||||
v2 writes a package directory, manifest and directory URL in `opencode.json(c)`.
|
||||
Use `package` instead of `code`/`codeFile` to retain a relative-filename → UTF-8
|
||||
contents map, including package.json and dependencies. Native directory imports
|
||||
copy to Skillshare-owned output and warn to remove the original after sync.
|
||||
No code runs or dependencies install. Provision dependencies before loading.
|
||||
Only string server exports or conventional root server/index entries are verified;
|
||||
conditional/fallback server exports fail closed. When the version cannot be
|
||||
detected (missing or failing binary, unknown major), only OpenCode bindings are
|
||||
skipped with a warning; existing OpenCode output stays and other Agents sync.
|
||||
A `package` binding on v1 is skipped with a warning. `code` is written as given,
|
||||
not checked against the v1 or v2 API.
|
||||
|
||||
Windows hook probes resolve standard native npm shims for `opencode-ai` (later
|
||||
v1) and `@opencode/cli` (v2), without a shell. Older v1 Node launchers and custom
|
||||
batch wrappers fail closed: set the account `cli` to the installed native
|
||||
`opencode.exe` absolute path, or put its directory first on `PATH`. No postinstall
|
||||
scripts run and missing binaries are not repaired.
|
||||
|
||||
@@ -130,7 +130,7 @@ no Agent holds it, drops the package from Skillshare entirely.
|
||||
|
||||
Claude supports native updates; Codex re-adds the reviewed snapshot unless the plugin is disabled in Codex. Cursor/Antigravity replace managed
|
||||
local copies; Pi/OpenCode refresh reviewed source snapshots; OMP removes its scoped registration and reinstalls the reviewed commit. Imported Codex plugins update by upgrading their marketplace; imported Pi packages through `pi update`, global only. Imported OpenCode v1 packages must be updated natively. OpenCode v2 global
|
||||
imports may use native update; project imports may not. Copilot and Antigravity CLI source updates
|
||||
package imports may use native update; imported local directories and project imports may not. Copilot and Antigravity CLI source updates
|
||||
require known native enabled state; Grok updates natively. Project mode supports Claude, Antigravity, Pi,
|
||||
OMP and OpenCode, never falling back to global scope. An update reports failed targets and continues healthy targets; intentional skips remain pending. Dry runs print the complete plan and exit nonzero on failure; isolated failures include `failed: true` in JSON.
|
||||
|
||||
@@ -210,7 +210,7 @@ OMP and OpenCode, never falling back to global scope. An update reports failed t
|
||||
during selection management, and selected never means loaded or running.
|
||||
- OpenCode: SDK dependency, `.opencode/plugins/` convention, or explicit `--entry`,
|
||||
with an existing JS/TS entry.
|
||||
Preserve the whole tree and register its file URL in the native JSON/JSONC config.
|
||||
Preserve the whole tree and manifest: v1 registers the entry file URL, v2 the directory URL in native JSON/JSONC. v2 requires name plus a string root/server export or a conventional root server/index file; --entry cannot override it. Conditional/fallback server exports fail closed. Hook packages registered as `plugins/skillshare-NAME` belong to hooks and are not listed.
|
||||
Version 1 uses `plugin`, version 2 uses `plugins`. Runtime dependencies must already
|
||||
be available. The CLI version selects the schema; do not guess from docs alone.
|
||||
- Another account of an Agent (a target with `agent:` and `config_dir:` in the global
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//go:build !online
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHooksOpenCodeV2FileInput(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("synthetic POSIX version probe")
|
||||
}
|
||||
sb := newHooksSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
bin := filepath.Join(sb.Home, "bin")
|
||||
probe := filepath.Join(bin, "opencode")
|
||||
sb.WriteFile(probe, "#!/bin/sh\n[ \"$#\" = 1 ] && [ \"$1\" = --version ] || exit 91\nprintf 'opencode v2.3.0\\n'\n")
|
||||
if err := os.Chmod(probe, 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sb.SetEnv("PATH", bin+string(os.PathListSeparator)+os.Getenv("PATH"))
|
||||
sb.SetEnv("XDG_CONFIG_HOME", filepath.Join(sb.Home, ".config"))
|
||||
for _, key := range []string{"OPENCODE_CONFIG", "OPENCODE_CONFIG_DIR", "OPENCODE_CONFIG_CONTENT"} {
|
||||
sb.SetEnv(key, "")
|
||||
}
|
||||
input := filepath.Join(sb.Root, "entry.json")
|
||||
sb.WriteFile(input, `{"bindings":{"opencode":{"code":"export default {}\n"}}}`)
|
||||
dir := filepath.Join(sb.Home, ".config/opencode/plugins/skillshare-native")
|
||||
preview := sb.RunCLI("hooks", "add", "native", "--file", input, "--dry-run", "--json", "-g")
|
||||
preview.AssertSuccess(t)
|
||||
if !strings.Contains(preview.Stdout, "package.json") || strings.Contains(preview.Stdout, "skillshare-native.ts") {
|
||||
t.Fatal(preview.Stdout)
|
||||
}
|
||||
if _, err := os.Stat(dir); !os.IsNotExist(err) {
|
||||
t.Fatal("dry-run wrote package", err)
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ export interface HookBinding {
|
||||
/** The Agent's own event map, passed through as written. */
|
||||
events?: Record<string, unknown>;
|
||||
code?: string;
|
||||
/** OpenCode v2 directory: relative filenames mapped to UTF-8 contents. */
|
||||
package?: Record<string, string>;
|
||||
/** Path, relative to the config's folder, that `code` was read from. */
|
||||
codeFile?: string;
|
||||
/** Relative script filename → UTF-8 contents. */
|
||||
|
||||
@@ -224,8 +224,8 @@ export default function HookBindingEditor({ agent, name, draft, check, onChange,
|
||||
<Expandable title={`${hookLabel(agent)} ${t('hooks.code')}`} tools={(expanded) => <span className="flex-1 text-[13px] font-semibold">{!expanded && t('hooks.code')}</span>}>
|
||||
{(expanded) => (
|
||||
<>
|
||||
<CodeEditor value={draft.code} onChange={(code) => onChange({ ...draft, code })} lang="typescript" ariaLabel={`${hookLabel(agent)} ${t('hooks.code')}`} placeholder={t('hooks.codePlaceholder')} disabled={disabled} minHeight="240px" maxHeight="480px" fill={expanded} className={expanded ? 'min-h-0 flex-1' : ''} />
|
||||
{check.codeMissing ? <span className="hp !text-bad">{t('hooks.codeRequired')}</span> : <span className="hp">{t('hooks.codeHint', { agent: hookLabel(agent), name: name || '<name>' })}</span>}
|
||||
<CodeEditor value={draft.code} onChange={(code) => onChange({ ...draft, code })} lang={draft.package ? "json" : "typescript"} ariaLabel={`${hookLabel(agent)} ${t('hooks.code')}`} placeholder={t('hooks.codePlaceholder')} disabled={disabled} minHeight="240px" maxHeight="480px" fill={expanded} className={expanded ? 'min-h-0 flex-1' : ''} />
|
||||
{check.codeMissing ? <span className="hp !text-bad">{t('hooks.codeRequired')}</span> : <span className="hp">{draft.package ? 'package.json' : t('hooks.codeHint', { agent: hookLabel(agent), name: name || '<name>' })}</span>}
|
||||
</>
|
||||
)}
|
||||
</Expandable>
|
||||
|
||||
@@ -14,7 +14,7 @@ import CopyButton from '../CopyButton';
|
||||
import DialogShell from '../DialogShell';
|
||||
import IconButton from '../IconButton';
|
||||
import Spinner from '../Spinner';
|
||||
import { hookLabel } from './hooksView';
|
||||
import { hookLabel, hookMessage } from './hooksView';
|
||||
|
||||
/** The list item for the Skillshare source; every native file is numbered after it. */
|
||||
const SOURCE = -1;
|
||||
@@ -85,7 +85,7 @@ export function HooksConfigView({ mutation, sourcePath }: { mutation: HookMutati
|
||||
{content !== undefined && <CopyButton value={content} />}
|
||||
</div>
|
||||
{view.isPending && <Spinner size="sm" />}
|
||||
{file?.error && <div className="ss-note warn"><span className="flex-1">{file.error}</span></div>}
|
||||
{file?.error && <div className="ss-note warn"><span className="flex-1">{hookMessage(t, file.error)}</span></div>}
|
||||
{content !== undefined && <CodeView content={content} lang={shown === SOURCE ? 'json' : path ?? ''} className="max-h-[420px]" />}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -125,7 +125,10 @@ export default function HooksImportDialog({ data, project, onClose, onImported }
|
||||
</div>
|
||||
{list.map((row) => {
|
||||
const lines = bindingLines(row.candidate.entry.bindings[row.target]);
|
||||
const notes = [...row.candidate.problems, ...row.candidate.warnings.filter((w) => w !== ADOPT_WARNING).map((w) => hookMessage(t, w))];
|
||||
const notes = [
|
||||
...row.candidate.problems.map((message) => ({ message, problem: true })),
|
||||
...row.candidate.warnings.filter((w) => w !== ADOPT_WARNING).map((message) => ({ message, problem: false })),
|
||||
];
|
||||
const error = checked(row) ? nameError(row) : '';
|
||||
return (
|
||||
<div key={row.id} className="flex items-start gap-3 border-t border-line px-3.5 py-3">
|
||||
@@ -138,7 +141,7 @@ export default function HooksImportDialog({ data, project, onClose, onImported }
|
||||
<span className="min-w-0 truncate" title={l.command}>{l.command}</span>
|
||||
</span>
|
||||
)) : <span className="font-mono text-[13px]">{row.candidate.name}</span>}
|
||||
{notes.map((n) => <span key={n} className={`text-xs leading-normal ${row.candidate.problems.includes(n) ? 'text-bad' : 'text-ink-2'}`}>{n}</span>)}
|
||||
{notes.map(({ message, problem }) => <span key={`${problem}:${message}`} className={`text-xs leading-normal ${problem ? 'text-bad' : 'text-ink-2'}`}>{hookMessage(t, message)}</span>)}
|
||||
</span>
|
||||
<span className="flex shrink-0 flex-col items-end gap-1">
|
||||
<span className="flex items-center gap-2">
|
||||
|
||||
@@ -129,16 +129,8 @@ export default function (pi: ExtensionAPI) {
|
||||
});
|
||||
}
|
||||
`,
|
||||
opencode: `import type { Plugin } from "@opencode-ai/plugin";
|
||||
|
||||
export const SkillsharePlugin: Plugin = async ({ project, client, $, directory }) => {
|
||||
return {
|
||||
"tool.execute.before": async (input, output) => {
|
||||
// Throw an error to stop the tool call.
|
||||
},
|
||||
};
|
||||
};
|
||||
`,
|
||||
// OpenCode v1 and v2 APIs differ; require the user's matching code.
|
||||
opencode: '',
|
||||
})[agent] ?? '';
|
||||
|
||||
/** Native field names offered inside an event's entries. */
|
||||
|
||||
@@ -209,11 +209,33 @@ describe('project isolation', () => {
|
||||
});
|
||||
|
||||
describe('hookMessage', () => {
|
||||
it.each([
|
||||
['OpenCode server exports must be a string (. or ./server); conditional and fallback exports cannot be verified offline', 'opencodeExports', undefined],
|
||||
['OpenCode v2 package requires name and exports, or a root server/index .ts, .tsx or .js file; --entry cannot override the directory loader', 'opencodeEntry', undefined],
|
||||
['OpenCode package file "../asset" must be a relative UTF-8 file without traversal', 'opencodePackageFile', { path: '"../asset"' }],
|
||||
['OpenCode package file "lib" is also a parent directory', 'opencodePackageParent', { path: '"lib"' }],
|
||||
['OpenCode package must not contain node_modules', 'opencodePackageExcluded', { path: 'node_modules' }],
|
||||
['OpenCode package must not contain .git', 'opencodePackageExcluded', { path: '.git' }],
|
||||
['OpenCode package.json: invalid character at byte 3', 'opencodeManifest', { detail: 'invalid character at byte 3' }],
|
||||
['OpenCode export "./../server.js" must stay inside the package', 'opencodeExportPath', { path: '"./../server.js"' }],
|
||||
['OpenCode export "./server.js" is missing: open /tmp/native/server.js: permission denied', 'opencodeExportMissing', { path: '"./server.js"', detail: 'open /tmp/native/server.js: permission denied' }],
|
||||
] as const)('localizes package guidance without changing diagnostic parameters: %s', (message, key, params) => {
|
||||
const t = (key: string, params?: Record<string, string>) => JSON.stringify({ key, params });
|
||||
expect(hookMessage(t, message)).toBe(t(`hooks.message.${key}`, params));
|
||||
});
|
||||
it('words the known domain notes with UI keys and passes any other note through', () => {
|
||||
const t = (key: string) => `[${key}]`;
|
||||
expect(hookMessage(t, 'saving the import takes over the existing registrations in place; sync leaves them as they are instead of adding duplicates')).toBe('[hooks.message.importUnmanaged]');
|
||||
expect(hookMessage(t, 'an identical hook exists that Skillshare does not manage; import it or explicitly replace it')).toBe('[hooks.message.identicalUnmanaged]');
|
||||
expect(hookMessage(t, 'hook guard: gemini does not document the event "Stopp"; check its spelling')).toBe('[hooks.message.unknownEvent]');
|
||||
expect(hookMessage(t, 'OpenCode v2: package files and registration only; provision the declared dependencies yourself before loading. Skillshare does not execute plugins or install dependencies.')).toBe('[hooks.message.opencodeDependencies]');
|
||||
expect(hookMessage(t, 'hook kata: OpenCode package must not contain node_modules')).toBe(hookMessage(t, 'OpenCode package must not contain node_modules'));
|
||||
expect(hookMessage(t, 'hook kata: something untranslated')).toBe('hook kata: something untranslated');
|
||||
expect(hookMessage(t, 'target opencode: detect OpenCode API with opencode --version: exec: "opencode": executable file not found in $PATH; its hook bindings are skipped')).toBe('[hooks.message.opencodeUndetected]');
|
||||
expect(hookMessage(t, 'target work: config_dir /OpenCode does not exist on this machine; its hook bindings are skipped')).toBe('target work: config_dir /OpenCode does not exist on this machine; its hook bindings are skipped');
|
||||
expect(hookMessage(t, 'hook kata: target opencode: a directory package requires OpenCode v2; this binding is skipped')).toBe('[hooks.message.opencodePackageNeedsV2]');
|
||||
expect(hookMessage(t, 'OpenCode package file "bin" cannot be imported: refusing symlink')).toBe('[hooks.message.opencodePackageUnreadable]');
|
||||
expect(hookMessage((key, params) => `${key}:${params?.path}`, '/home/native keeps loading; remove its original files and directory registration after syncing so the plugin does not run twice')).toBe('hooks.message.opencodeImport:/home/native');
|
||||
expect(hookMessage(t, 'something new')).toBe('something new');
|
||||
});
|
||||
});
|
||||
@@ -252,3 +274,14 @@ describe('inactive Git sync decisions', () => {
|
||||
expect(syncState(plan, 'check', 'git')).toBe('inactive');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('OpenCode directory package editor', () => {
|
||||
it('round-trips package files and rejects a malformed package map', () => {
|
||||
const binding = { package: { 'package.json': '{"name":"demo","exports":"./index.js","dependencies":{"@opencode/plugin":"^2.0.0"}}', 'index.js': 'export default {}\n' } };
|
||||
const draft = bindingToDraft('opencode', binding);
|
||||
expect(draftToBinding('opencode', draft)).toEqual(binding);
|
||||
expect(checkBinding('opencode', draft)).toMatchObject({ nativeError: false, empty: false });
|
||||
expect(checkBinding('opencode', { ...draft, code: '{"index.js":false}' }).nativeError).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -54,12 +54,42 @@ export const actionLabel = (t: (key: string) => string, action: string) => (KNOW
|
||||
const messageKeys: Record<string, string> = {
|
||||
'an identical hook exists that Skillshare does not manage; import it or explicitly replace it': 'hooks.message.identicalUnmanaged',
|
||||
'saving the import takes over the existing registrations in place; sync leaves them as they are instead of adding duplicates': 'hooks.message.importUnmanaged',
|
||||
'OpenCode v2: package files and registration only; provision the declared dependencies yourself before loading. Skillshare does not execute plugins or install dependencies.': 'hooks.message.opencodeDependencies',
|
||||
'OpenCode server exports must be a string (. or ./server); conditional and fallback exports cannot be verified offline': 'hooks.message.opencodeExports',
|
||||
'OpenCode v2 package requires name and exports, or a root server/index .ts, .tsx or .js file; --entry cannot override the directory loader': 'hooks.message.opencodeEntry',
|
||||
};
|
||||
const UNKNOWN_EVENT = /^hook (.+): (\S+) does not document the event "(.+)"; check its spelling$/;
|
||||
export const hookMessage = (t: (key: string, params?: Record<string, string>) => string, message: string) => {
|
||||
export const hookMessage = (t: (key: string, params?: Record<string, string>) => string, message: string): string => {
|
||||
if (messageKeys[message]) return t(messageKeys[message]);
|
||||
const importedPackage = /^(.+) keeps loading; remove its original files and directory registration after syncing so the plugin does not run twice$/.exec(message);
|
||||
if (importedPackage) return t('hooks.message.opencodeImport', { path: importedPackage[1] });
|
||||
const packageFile = /^OpenCode package file (".*") must be a relative UTF-8 file without traversal$/.exec(message);
|
||||
if (packageFile) return t('hooks.message.opencodePackageFile', { path: packageFile[1] });
|
||||
const packageParent = /^OpenCode package file (".*") is also a parent directory$/.exec(message);
|
||||
if (packageParent) return t('hooks.message.opencodePackageParent', { path: packageParent[1] });
|
||||
const packageExcluded = /^OpenCode package must not contain (node_modules|\.git)$/.exec(message);
|
||||
if (packageExcluded) return t('hooks.message.opencodePackageExcluded', { path: packageExcluded[1] });
|
||||
const manifest = /^OpenCode package\.json: ([\s\S]+)$/.exec(message);
|
||||
if (manifest) return t('hooks.message.opencodeManifest', { detail: manifest[1] });
|
||||
const exportPath = /^OpenCode export (".*") must stay inside the package$/.exec(message);
|
||||
if (exportPath) return t('hooks.message.opencodeExportPath', { path: exportPath[1] });
|
||||
const missingExport = /^OpenCode export (".*") is missing: ([\s\S]+)$/.exec(message);
|
||||
if (missingExport) return t('hooks.message.opencodeExportMissing', { path: missingExport[1], detail: missingExport[2] });
|
||||
const unreadable = /^OpenCode package file (".*") cannot be imported: ([\s\S]+)$/.exec(message);
|
||||
if (unreadable) return t('hooks.message.opencodePackageUnreadable', { path: unreadable[1], detail: unreadable[2] });
|
||||
const undetected = /^target (\S+): (detect OpenCode API [\s\S]+); its hook bindings are skipped$/.exec(message);
|
||||
if (undetected) return t('hooks.message.opencodeUndetected', { target: undetected[1], detail: undetected[2] });
|
||||
const needsV2 = /^hook (.+): target (\S+): a directory package requires OpenCode v2; this binding is skipped$/.exec(message);
|
||||
if (needsV2) return t('hooks.message.opencodePackageNeedsV2', { name: needsV2[1], target: needsV2[2] });
|
||||
const unknown = UNKNOWN_EVENT.exec(message);
|
||||
return unknown ? t('hooks.message.unknownEvent', { name: unknown[1], agent: hookLabel(unknown[2]), event: unknown[3] }) : message;
|
||||
if (unknown) return t('hooks.message.unknownEvent', { name: unknown[1], agent: hookLabel(unknown[2]), event: unknown[3] });
|
||||
// Entry validation names its hook first; the row already shows which hook it is.
|
||||
const named = /^hook [^:]+: ([\s\S]+)$/.exec(message);
|
||||
if (named) {
|
||||
const inner = hookMessage(t, named[1]);
|
||||
if (inner !== named[1]) return inner;
|
||||
}
|
||||
return message;
|
||||
};
|
||||
export const needsTakeover = (change: HookChange) => change.action === 'conflict' && messageKeys[change.message ?? ''] === 'hooks.message.identicalUnmanaged';
|
||||
|
||||
@@ -215,6 +245,7 @@ export interface BindingDraft {
|
||||
/** The Agent's native event map as JSON text. */
|
||||
native: string;
|
||||
code: string;
|
||||
package?: boolean;
|
||||
/** The codeFile the code was read from; kept on save while the code is unchanged. */
|
||||
codeFile?: { path: string; code: string };
|
||||
files: FileRow[];
|
||||
@@ -230,7 +261,8 @@ export function bindingToDraft(agent: string, binding: HookEntry['bindings'][str
|
||||
mode: rows ? 'simple' : 'native',
|
||||
rows: rows ?? [],
|
||||
native: binding.events ? JSON.stringify(binding.events, null, 2) : '',
|
||||
code: binding.code ?? '',
|
||||
code: binding.package ? JSON.stringify(binding.package, null, 2) : binding.code ?? '',
|
||||
...(binding.package && { package: true }),
|
||||
...(binding.codeFile && { codeFile: { path: binding.codeFile, code: binding.code ?? '' } }),
|
||||
files: Object.entries(binding.files ?? {}).map(([name, content]) => {
|
||||
const path = binding.filesFrom?.[name];
|
||||
@@ -286,6 +318,11 @@ export function checkBinding(agent: string, d: BindingDraft): BindingCheck {
|
||||
const parsed = parseGitBinding(d.native);
|
||||
return { nativeError: Boolean(parsed.error), rowErrors: 0, fileErrors: false, codeMissing: false, empty: !isObject(parsed.value?.commands) || Object.keys(parsed.value.commands).length === 0 };
|
||||
}
|
||||
if (agent === 'opencode' && d.package) {
|
||||
const parsed = parseNative(d.code);
|
||||
const invalid = !parsed.value || Object.values(parsed.value).some((v) => typeof v !== 'string');
|
||||
return { nativeError: Boolean(parsed.error) || invalid, rowErrors: 0, fileErrors: false, codeMissing: invalid, empty: !parsed.value || Object.keys(parsed.value).length === 0 };
|
||||
}
|
||||
if (isCodeAgent(agent)) return { nativeError: false, rowErrors: 0, fileErrors: false, codeMissing: !d.code.trim(), empty: !d.code.trim() };
|
||||
const nativeError = d.mode === 'native' && Boolean(parseNative(d.native).error);
|
||||
const active = d.rows.filter((r) => !rowBlank(r));
|
||||
@@ -303,6 +340,7 @@ export function draftToBinding(agent: string, d: BindingDraft) {
|
||||
const files = Object.fromEntries(d.files.filter((f) => f.name.trim()).map((f) => [f.name.trim(), f.content]));
|
||||
const filesFrom = Object.fromEntries(d.files.filter((f) => f.from && f.name.trim() === f.from.name && f.content === f.from.content).map((f) => [f.from!.name, f.from!.path]));
|
||||
const withFiles = { ...(Object.keys(files).length > 0 && { files }), ...(Object.keys(filesFrom).length > 0 && { filesFrom }) };
|
||||
if (agent === 'opencode' && d.package) return { package: parseNative(d.code).value as Record<string, string> };
|
||||
if (isCodeAgent(agent)) return d.codeFile && d.code === d.codeFile.code ? { codeFile: d.codeFile.path } : { code: d.code, ...withFiles };
|
||||
const events = d.mode === 'native' ? parseNative(d.native).value : rowsToEvents(d.rows);
|
||||
return { ...(events && { events }), ...withFiles };
|
||||
|
||||
@@ -3027,7 +3027,7 @@
|
||||
"hooks.native.pi": "Pi erkennt Erweiterungen beim Start; Projekt-Erweiterungen werden erst geladen, nachdem dem Projekt vertraut wurde. Der Code muss die Erweiterungs-API deiner installierten Pi-Version verwenden.",
|
||||
"hooks.native.omp": "Oh My Pi lädt Erweiterungen beim Start aus seinem Extensions-Ordner und fragt nicht nach Projektvertrauen. Eine synchronisierte Datei kann daher beim nächsten Start von omp in diesem Ordner ausgeführt werden. Der Code muss die Extension-API deiner installierten omp-Version verwenden.",
|
||||
"hooks.native.amp": "Amp führt Plugins aus seinem plugins-Ordner mit Bun aus; führe nach dem Sync 'plugins: reload' aus. Der Code muss die Plugin-API deiner Amp-Version verwenden.",
|
||||
"hooks.native.opencode": "OpenCode lädt Plugins aus seinem plugins-Ordner. v1-Plugins sind benannte Exporte, v2-Plugins exportieren default Plugin.define(...); Skillshare schreibt deinen Code unverändert und konvertiert nie zwischen beiden.",
|
||||
"hooks.native.opencode": "OpenCode v1 erhält eine einzelne Datei, v2 ein Verzeichnispaket mit Verzeichnis-URL. Der Code muss zur installierten API passen. Skillshare führt keine Plugins aus und installiert keine Abhängigkeiten; diese müssen vor dem Laden bereitstehen.",
|
||||
"hooks.syncHint": "Speichern ändert nur die Quelle. „Hooks synchronisieren“ schreibt die nativen Dateien.",
|
||||
"hooks.syncDialog.subtitle": "Diese nativen Dateien werden geschrieben. Hooks werden nicht ausgeführt.",
|
||||
"hooks.syncDialog.done": "Hooks synchronisiert. Jeder Agent entscheidet weiterhin selbst, ob er ihnen vertraut und sie lädt.",
|
||||
@@ -3056,7 +3056,7 @@
|
||||
"hooks.code": "Erweiterungscode",
|
||||
"hooks.codePlaceholder": "// Eine eigenständige TypeScript- oder JavaScript-Datei in der eigenen API des Agents",
|
||||
"hooks.codeRequired": "Füge den Erweiterungscode hinzu.",
|
||||
"hooks.codeHint": "Wird unverändert nach skillshare-{name}.ts im Erweiterungsordner von {agent} geschrieben.",
|
||||
"hooks.codeHint": "Wird unverändert im nativen Layout von {agent} für skillshare-{name} geschrieben.",
|
||||
"hooks.codeVersionNote": "Dieser Code wird weder konvertiert noch gegen deine {agent}-Version geprüft. Schreibe ihn für die API der Version, die du nutzt.",
|
||||
"hooks.ompNoTrust": "Oh My Pi hat keine Abfrage für Projektvertrauen: Eine Projekterweiterung kann beim nächsten Start von omp dort ausgeführt werden. Skillshare schreibt diesen Code unverändert, übersetzt ihn nie und führt ihn nie aus.",
|
||||
"hooks.incomplete": "Korrigiere {agents} vor dem Speichern",
|
||||
@@ -3627,5 +3627,20 @@
|
||||
"plugins.error.importRecipeIdentityRequired": "Dieses entfernte Installationsrezept enthält keine Plugin-Identität. Setze plugin: in der gemeinsamen Deklaration vor dem Import auf den nativen Paketnamen; beim Import wird kein Quellcode heruntergeladen.",
|
||||
"plugins.error.unimportTargetRequired": "unimport benötigt --target zur Auswahl eines lokalen Importbelegs",
|
||||
"plugins.error.unimportTargetMissing": "{name} hat keine Bindung für das Ziel {target}",
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} hat keinen lokalen Import mit einem gemeinsamen Quellrezept"
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} hat keinen lokalen Import mit einem gemeinsamen Quellrezept",
|
||||
"hooks.message.opencodeDependencies": "OpenCode v2: nur Paketdateien und Registrierung. Stelle die deklarierten Abhängigkeiten vor dem Laden bereit. Skillshare führt keine Plugins aus und installiert keine Abhängigkeiten.",
|
||||
"hooks.message.opencodeImport": "{path} wird weiterhin geladen. Entferne nach dem Synchronisieren die ursprünglichen Dateien und die Verzeichnisregistrierung, damit das Plugin nicht doppelt läuft.",
|
||||
"hooks.message.opencodeExports": "OpenCode-Server-Exports müssen eine Zeichenfolge sein (. oder ./server). Bedingte Exports und Fallback-Exports lassen sich offline nicht prüfen.",
|
||||
"hooks.message.opencodeEntry": "OpenCode v2 benötigt name und exports oder eine server/index-Datei mit .ts, .tsx oder .js im Stammverzeichnis. --entry kann das Laden eines Verzeichnisses nicht überschreiben.",
|
||||
"hooks.message.opencodePackageFile": "Die OpenCode-Paketdatei {path} muss einen relativen Pfad ohne Verzeichniswechsel nach oben und UTF-8-Inhalt verwenden.",
|
||||
"hooks.message.opencodePackageParent": "Die OpenCode-Paketdatei {path} ist zugleich ein übergeordnetes Verzeichnis.",
|
||||
"hooks.message.opencodePackageExcluded": "OpenCode-Pakete dürfen {path} nicht enthalten.",
|
||||
"hooks.message.opencodeManifest": "Die OpenCode-package.json kann nicht gelesen werden: {detail}",
|
||||
"hooks.message.opencodeExportPath": "Der OpenCode-Export {path} muss innerhalb des Pakets bleiben.",
|
||||
"hooks.message.opencodeExportMissing": "Der OpenCode-Export {path} fehlt: {detail}",
|
||||
"hooks.message.opencodeUndetected": "OpenCode auf {target}: Die installierte Version konnte nicht ermittelt werden ({detail}). Die Hook-Bindings werden übersprungen; vorhandene Ausgaben bleiben unverändert.",
|
||||
"hooks.message.opencodePackageNeedsV2": "{name}: Ein Verzeichnispaket erfordert OpenCode v2 und wird für {target} übersprungen.",
|
||||
"hooks.message.opencodePackageUnreadable": "Die OpenCode-Paketdatei {path} kann nicht importiert werden: {detail}",
|
||||
"plugins.problem.opencodeDirectory": "OpenCode v2 benötigt eine Verzeichnisregistrierung statt einer Plugin-Datei. Entferne diese Bindung und füge das Paket erneut hinzu.",
|
||||
"plugins.skip.opencodeLocal": "Importiertes lokales Paket: Aktualisiere es an seiner Quelle. Skillshare führt keinen Abhängigkeitsinstaller aus."
|
||||
}
|
||||
|
||||
@@ -3027,7 +3027,7 @@
|
||||
"hooks.native.pi": "Pi discovers extensions at startup; project extensions load only after project trust is granted. The code must use the extension API of your installed Pi version.",
|
||||
"hooks.native.omp": "Oh My Pi loads extensions from its extensions folder at startup and asks for no project trust, so a synced file can run the next time omp starts in that folder. The code must use the extension API of your installed omp version.",
|
||||
"hooks.native.amp": "Amp runs plugins from its plugins folder with Bun; run 'plugins: reload' after sync. The code must use your Amp version's plugin API.",
|
||||
"hooks.native.opencode": "OpenCode loads plugins from its plugins folder. v1 plugins are named exports and v2 plugins export default Plugin.define(...); Skillshare writes your code as given and never converts between them.",
|
||||
"hooks.native.opencode": "OpenCode v1 receives a flat file; v2 receives a directory package and directory URL. Supply code for the installed API. Skillshare never runs plugins or installs dependencies; provision declared dependencies before loading.",
|
||||
"hooks.syncHint": "Saving only changes the source. Sync hooks writes the native files.",
|
||||
"hooks.syncDialog.subtitle": "These native files will be written. Hooks are not executed.",
|
||||
"hooks.syncDialog.done": "Hooks synchronized. Each target still decides whether to trust and load them.",
|
||||
@@ -3056,7 +3056,7 @@
|
||||
"hooks.code": "Extension code",
|
||||
"hooks.codePlaceholder": "// One standalone TypeScript or JavaScript file in the target's own API",
|
||||
"hooks.codeRequired": "Add the extension code.",
|
||||
"hooks.codeHint": "Written as-is to skillshare-{name}.ts in {agent}'s extension folder.",
|
||||
"hooks.codeHint": "Written verbatim using {agent}'s native layout for skillshare-{name}.",
|
||||
"hooks.codeVersionNote": "This code is not converted or checked against your {agent} version. Write it for the API of the version you run.",
|
||||
"hooks.ompNoTrust": "Oh My Pi has no project trust prompt: a project extension can run the next time omp starts there. Skillshare writes this code as given, never translates it and never executes it.",
|
||||
"hooks.incomplete": "Fix {agents} before saving",
|
||||
@@ -3627,5 +3627,20 @@
|
||||
"plugins.error.importRecipeIdentityRequired": "This remote recipe has no plugin identity. Set plugin: to the native package name in the shared declaration before importing; import does not download source.",
|
||||
"plugins.error.unimportTargetRequired": "unimport requires --target to select a local import receipt",
|
||||
"plugins.error.unimportTargetMissing": "{name} has no binding for target {target}",
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} has no local import backed by a shared source recipe"
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} has no local import backed by a shared source recipe",
|
||||
"hooks.message.opencodeDependencies": "OpenCode v2: package files and registration only. Prepare the declared dependencies before loading. Skillshare never runs plugins or installs dependencies.",
|
||||
"hooks.message.opencodeImport": "{path} still loads. After syncing, remove its original files and directory registration to avoid running the plugin twice.",
|
||||
"hooks.message.opencodeExports": "OpenCode server exports must be a string (. or ./server). Conditional and fallback exports cannot be verified offline.",
|
||||
"hooks.message.opencodeEntry": "OpenCode v2 needs name and exports, or a root server/index .ts, .tsx or .js file. --entry cannot override directory loading.",
|
||||
"hooks.message.opencodePackageFile": "OpenCode package file {path} must use a relative path without traversal and UTF-8 contents.",
|
||||
"hooks.message.opencodePackageParent": "OpenCode package file {path} is also a parent directory.",
|
||||
"hooks.message.opencodePackageExcluded": "OpenCode packages must not contain {path}.",
|
||||
"hooks.message.opencodeManifest": "Cannot read the OpenCode package.json: {detail}",
|
||||
"hooks.message.opencodeExportPath": "OpenCode export {path} must stay inside the package.",
|
||||
"hooks.message.opencodeExportMissing": "OpenCode export {path} is missing: {detail}",
|
||||
"hooks.message.opencodeUndetected": "OpenCode on {target}: the installed version could not be detected ({detail}). Its hook bindings are skipped; existing output is left as it is.",
|
||||
"hooks.message.opencodePackageNeedsV2": "{name}: a directory package needs OpenCode v2, so it is skipped for {target}.",
|
||||
"hooks.message.opencodePackageUnreadable": "OpenCode package file {path} cannot be imported: {detail}",
|
||||
"plugins.problem.opencodeDirectory": "OpenCode v2 requires a directory registration, not a plugin file. Remove this binding and add its package again.",
|
||||
"plugins.skip.opencodeLocal": "Imported local package: update it at its source. Skillshare does not run a dependency installer."
|
||||
}
|
||||
|
||||
@@ -3027,7 +3027,7 @@
|
||||
"hooks.native.pi": "Pi descubre las extensiones al iniciar; las extensiones de proyecto se cargan solo después de conceder confianza al proyecto. El código debe usar la API de extensiones de tu versión instalada de Pi.",
|
||||
"hooks.native.omp": "Oh My Pi carga extensiones desde su carpeta de extensiones al iniciar y no pide confianza del proyecto, así que un archivo sincronizado puede ejecutarse la próxima vez que omp se inicie en esa carpeta. El código debe usar la API de extensiones de la versión de omp que tienes instalada.",
|
||||
"hooks.native.amp": "Amp ejecuta con Bun los plugins de su carpeta plugins; ejecuta 'plugins: reload' después de sincronizar. El código debe usar la API de plugins de tu versión de Amp.",
|
||||
"hooks.native.opencode": "OpenCode carga los plugins de su carpeta plugins. Los plugins v1 son exports con nombre y los v2 hacen export default Plugin.define(...); Skillshare escribe tu código tal cual y nunca convierte entre ambos.",
|
||||
"hooks.native.opencode": "OpenCode v1 recibe un archivo; v2 recibe un paquete de directorio y su URL. Proporciona código para la API instalada. Skillshare no ejecuta plugins ni instala dependencias; prepáralas antes de cargarlo.",
|
||||
"hooks.syncHint": "Guardar solo cambia el origen. Sincronizar hooks escribe los archivos nativos.",
|
||||
"hooks.syncDialog.subtitle": "Se escribirán estos archivos nativos. Los hooks no se ejecutan.",
|
||||
"hooks.syncDialog.done": "Hooks sincronizados. Cada Agent sigue decidiendo si confía en ellos y los carga.",
|
||||
@@ -3056,7 +3056,7 @@
|
||||
"hooks.code": "Código de extensión",
|
||||
"hooks.codePlaceholder": "// Un archivo TypeScript o JavaScript independiente con la API propia del Agent",
|
||||
"hooks.codeRequired": "Añade el código de extensión.",
|
||||
"hooks.codeHint": "Se escribe tal cual en skillshare-{name}.ts, en la carpeta de extensiones de {agent}.",
|
||||
"hooks.codeHint": "Se escribe sin cambios con la estructura nativa de {agent} para skillshare-{name}.",
|
||||
"hooks.codeVersionNote": "Este código no se convierte ni se comprueba con tu versión de {agent}. Escríbelo para la API de la versión que usas.",
|
||||
"hooks.ompNoTrust": "Oh My Pi no tiene aviso de confianza del proyecto: una extensión de proyecto puede ejecutarse la próxima vez que omp se inicie allí. Skillshare escribe este código tal cual, nunca lo traduce y nunca lo ejecuta.",
|
||||
"hooks.incomplete": "Corrige {agents} antes de guardar",
|
||||
@@ -3627,5 +3627,20 @@
|
||||
"plugins.error.importRecipeIdentityRequired": "Esta receta remota no tiene una identidad de plugin. Antes de importar, establece plugin: con el nombre del paquete nativo en la declaración compartida; la importación no descarga el código fuente.",
|
||||
"plugins.error.unimportTargetRequired": "unimport requiere --target para seleccionar un registro de importación local",
|
||||
"plugins.error.unimportTargetMissing": "{name} no tiene un enlace para el destino {target}",
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} no tiene una importación local respaldada por una receta de fuente compartida"
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} no tiene una importación local respaldada por una receta de fuente compartida",
|
||||
"hooks.message.opencodeDependencies": "OpenCode v2: solo archivos del paquete y registro. Prepara las dependencias declaradas antes de cargarlo. Skillshare no ejecuta plugins ni instala dependencias.",
|
||||
"hooks.message.opencodeImport": "{path} sigue cargándose. Tras sincronizar, elimina sus archivos originales y su registro de directorio para evitar ejecutar el plugin dos veces.",
|
||||
"hooks.message.opencodeExports": "Los exports del servidor de OpenCode deben ser una cadena (. o ./server). Los exports condicionales y alternativos no se pueden verificar sin conexión.",
|
||||
"hooks.message.opencodeEntry": "OpenCode v2 necesita name y exports, o un archivo server/index .ts, .tsx o .js en la raíz. --entry no puede sustituir la carga del directorio.",
|
||||
"hooks.message.opencodePackageFile": "El archivo del paquete OpenCode {path} debe usar una ruta relativa sin salir del directorio y contenido UTF-8.",
|
||||
"hooks.message.opencodePackageParent": "El archivo del paquete OpenCode {path} también es un directorio padre.",
|
||||
"hooks.message.opencodePackageExcluded": "Los paquetes OpenCode no deben contener {path}.",
|
||||
"hooks.message.opencodeManifest": "No se puede leer package.json de OpenCode: {detail}",
|
||||
"hooks.message.opencodeExportPath": "El export de OpenCode {path} debe permanecer dentro del paquete.",
|
||||
"hooks.message.opencodeExportMissing": "Falta el export de OpenCode {path}: {detail}",
|
||||
"hooks.message.opencodeUndetected": "OpenCode en {target}: no se pudo detectar la versión instalada ({detail}). Se omiten sus bindings de hooks; la salida existente se deja como está.",
|
||||
"hooks.message.opencodePackageNeedsV2": "{name}: un paquete de directorio requiere OpenCode v2, así que se omite para {target}.",
|
||||
"hooks.message.opencodePackageUnreadable": "No se puede importar el archivo {path} del paquete de OpenCode: {detail}",
|
||||
"plugins.problem.opencodeDirectory": "OpenCode v2 requiere registrar un directorio, no un archivo de plugin. Elimina esta vinculación y vuelve a añadir su paquete.",
|
||||
"plugins.skip.opencodeLocal": "Paquete local importado: actualízalo en su origen. Skillshare no ejecuta un instalador de dependencias."
|
||||
}
|
||||
|
||||
@@ -3027,7 +3027,7 @@
|
||||
"hooks.native.pi": "Pi افزونهها را هنگام شروع پیدا میکند؛ افزونههای پروژه فقط پس از اعطای اعتماد به پروژه بارگذاری میشوند. کد باید از API افزونهی نسخهی نصبشدهی Pi شما استفاده کند.",
|
||||
"hooks.native.omp": "Oh My Pi در زمان شروع، افزونهها را از پوشهٴ extensions بارگذاری میکند و دربارهٴ اعتماد به پروژه نمیپرسد؛ بنابراین فایل همگامشده ممکن است در شروع بعدی omp در آن پوشه اجرا شود. کد باید از API افزونهٴ نسخهٴ نصبشدهٴ omp استفاده کند.",
|
||||
"hooks.native.amp": "Amp پلاگینهای پوشهی plugins خود را با Bun اجرا میکند؛ پس از همگامسازی 'plugins: reload' را اجرا کنید. کد باید از API پلاگین نسخهی Amp شما استفاده کند.",
|
||||
"hooks.native.opencode": "OpenCode پلاگینها را از پوشهی plugins خود بارگذاری میکند. پلاگینهای v1 خروجیهای نامدار (named export) هستند و پلاگینهای v2 export default Plugin.define(...) میکنند؛ Skillshare کد شما را همانطور که هست مینویسد و هرگز بین این دو تبدیل نمیکند.",
|
||||
"hooks.native.opencode": "OpenCode v1 یک فایل و v2 یک بستهٔ پوشهای و URL پوشه دریافت میکند. کد باید با API نصبشده سازگار باشد. Skillshare پلاگینها را اجرا و وابستگیها را نصب نمیکند؛ وابستگیهای اعلامشده را پیش از بارگذاری آماده کنید.",
|
||||
"hooks.syncHint": "ذخیره فقط منبع را تغییر میدهد. «همگامسازی hooks» فایلهای بومی را مینویسد.",
|
||||
"hooks.syncDialog.subtitle": "این فایلهای بومی نوشته میشوند. hookها اجرا نمیشوند.",
|
||||
"hooks.syncDialog.done": "hookها همگام شدند. هر Agent همچنان خودش تصمیم میگیرد که به آنها اعتماد و آنها را بارگذاری کند.",
|
||||
@@ -3056,7 +3056,7 @@
|
||||
"hooks.code": "کد افزونه",
|
||||
"hooks.codePlaceholder": "// یک فایل مستقل TypeScript یا JavaScript با API خود Agent",
|
||||
"hooks.codeRequired": "کد افزونه را اضافه کنید.",
|
||||
"hooks.codeHint": "همانطور که هست در skillshare-{name}.ts داخل پوشهٔ افزونهٔ {agent} نوشته میشود.",
|
||||
"hooks.codeHint": "بدون تغییر با ساختار بومی {agent} برای skillshare-{name} نوشته میشود.",
|
||||
"hooks.codeVersionNote": "این کد تبدیل نمیشود و با نسخهٔ {agent} شما هم بررسی نمیشود. آن را برای API نسخهای که اجرا میکنید بنویسید.",
|
||||
"hooks.ompNoTrust": "Oh My Pi پرسش اعتماد به پروژه ندارد: افزونهٴ پروژه ممکن است در شروع بعدی omp در آنجا اجرا شود. Skillshare این کد را همانطور که هست مینویسد، هرگز آن را ترجمه نمیکند و هرگز اجرا نمیکند.",
|
||||
"hooks.incomplete": "پیش از ذخیره {agents} را درست کنید",
|
||||
@@ -3627,5 +3627,20 @@
|
||||
"plugins.error.importRecipeIdentityRequired": "این دستور نصب راه دور، شناسهٔ افزونه ندارد. پیش از واردکردن، مقدار plugin: را در تعریف مشترک روی نام بستهٔ بومی تنظیم کنید؛ واردکردن، کد منبع را دانلود نمیکند.",
|
||||
"plugins.error.unimportTargetRequired": "unimport برای انتخاب سابقهٔ واردکردن محلی به --target نیاز دارد",
|
||||
"plugins.error.unimportTargetMissing": "{name} هیچ اتصالی برای مقصد {target} ندارد",
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} هیچ واردکردن محلی با دستور نصب منبع مشترک ندارد"
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} هیچ واردکردن محلی با دستور نصب منبع مشترک ندارد",
|
||||
"hooks.message.opencodeDependencies": "OpenCode v2: فقط فایلهای بسته و ثبت آن مدیریت میشوند. وابستگیهای اعلامشده را پیش از بارگذاری آماده کنید. Skillshare پلاگینها را اجرا و وابستگیها را نصب نمیکند.",
|
||||
"hooks.message.opencodeImport": "{path} همچنان بارگذاری میشود. پس از همگامسازی، فایلهای اصلی و ثبت پوشهٔ آن را حذف کنید تا پلاگین دو بار اجرا نشود.",
|
||||
"hooks.message.opencodeExports": "exports سرور OpenCode باید رشته باشد (. یا ./server). exports شرطی و جایگزین را نمیتوان آفلاین بررسی کرد.",
|
||||
"hooks.message.opencodeEntry": "OpenCode v2 به name و exports یا فایل server/index با پسوند .ts، .tsx یا .js در ریشه نیاز دارد. --entry نمیتواند بارگذاری پوشه را تغییر دهد.",
|
||||
"hooks.message.opencodePackageFile": "فایل بستهٔ OpenCode به مسیر {path} باید مسیر نسبی بدون خروج از پوشه و محتوای UTF-8 داشته باشد.",
|
||||
"hooks.message.opencodePackageParent": "فایل بستهٔ OpenCode به مسیر {path} همزمان پوشهٔ والد نیز هست.",
|
||||
"hooks.message.opencodePackageExcluded": "بستههای OpenCode نباید شامل {path} باشند.",
|
||||
"hooks.message.opencodeManifest": "خواندن package.json در OpenCode ممکن نیست: {detail}",
|
||||
"hooks.message.opencodeExportPath": "export در OpenCode به مسیر {path} باید داخل بسته بماند.",
|
||||
"hooks.message.opencodeExportMissing": "export در OpenCode به مسیر {path} یافت نشد: {detail}",
|
||||
"hooks.message.opencodeUndetected": "OpenCode در {target}: نسخهٔ نصبشده تشخیص داده نشد ({detail}). بایندینگهای هوک آن نادیده گرفته میشوند؛ خروجی موجود دستنخورده میماند.",
|
||||
"hooks.message.opencodePackageNeedsV2": "{name}: بستهٔ پوشهای به OpenCode v2 نیاز دارد، بنابراین برای {target} نادیده گرفته میشود.",
|
||||
"hooks.message.opencodePackageUnreadable": "فایل {path} از بستهٔ OpenCode قابل وارد کردن نیست: {detail}",
|
||||
"plugins.problem.opencodeDirectory": "OpenCode v2 به ثبت پوشه نیاز دارد، نه فایل پلاگین. این اتصال را حذف و بستهٔ آن را دوباره اضافه کنید.",
|
||||
"plugins.skip.opencodeLocal": "بستهٔ محلی واردشده: آن را در محل اصلی بهروز کنید. Skillshare نصبکنندهٔ وابستگی اجرا نمیکند."
|
||||
}
|
||||
|
||||
@@ -3027,7 +3027,7 @@
|
||||
"hooks.native.pi": "Pi découvre les extensions au démarrage ; les extensions de projet ne se chargent qu'une fois la confiance accordée au projet. Le code doit utiliser l'API d'extensions de votre version de Pi installée.",
|
||||
"hooks.native.omp": "Oh My Pi charge les extensions depuis son dossier d'extensions au démarrage et ne demande aucune confiance de projet ; un fichier synchronisé peut donc s'exécuter au prochain démarrage d'omp dans ce dossier. Le code doit utiliser l'API d'extension de la version d'omp installée.",
|
||||
"hooks.native.amp": "Amp exécute avec Bun les plugins de son dossier plugins ; lancez 'plugins: reload' après la synchronisation. Le code doit utiliser l'API de plugins de votre version d'Amp.",
|
||||
"hooks.native.opencode": "OpenCode charge les plugins depuis son dossier plugins. Les plugins v1 sont des exports nommés et les plugins v2 font export default Plugin.define(...) ; Skillshare écrit votre code tel quel et ne convertit jamais de l'un à l'autre.",
|
||||
"hooks.native.opencode": "OpenCode v1 reçoit un fichier unique ; v2 reçoit un paquet répertoire et son URL. Fournissez du code pour l’API installée. Skillshare n’exécute pas les plugins et n’installe pas les dépendances ; préparez-les avant le chargement.",
|
||||
"hooks.syncHint": "L'enregistrement ne modifie que la source. Synchroniser les hooks écrit les fichiers natifs.",
|
||||
"hooks.syncDialog.subtitle": "Ces fichiers natifs vont être écrits. Les hooks ne sont pas exécutés.",
|
||||
"hooks.syncDialog.done": "Hooks synchronisés. Chaque Agent décide toujours s'il leur fait confiance et les charge.",
|
||||
@@ -3056,7 +3056,7 @@
|
||||
"hooks.code": "Code d'extension",
|
||||
"hooks.codePlaceholder": "// Un seul fichier TypeScript ou JavaScript autonome, avec l'API propre à l'Agent",
|
||||
"hooks.codeRequired": "Ajoutez le code d'extension.",
|
||||
"hooks.codeHint": "Écrit tel quel dans skillshare-{name}.ts, dans le dossier d'extensions de {agent}.",
|
||||
"hooks.codeHint": "Écrit tel quel dans la structure native de {agent} pour skillshare-{name}.",
|
||||
"hooks.codeVersionNote": "Ce code n'est ni converti ni vérifié par rapport à votre version de {agent}. Écrivez-le pour l'API de la version que vous utilisez.",
|
||||
"hooks.ompNoTrust": "Oh My Pi n'a pas d'invite de confiance de projet : une extension de projet peut s'exécuter au prochain démarrage d'omp à cet endroit. Skillshare écrit ce code tel quel, ne le traduit jamais et ne l'exécute jamais.",
|
||||
"hooks.incomplete": "Corrigez {agents} avant d'enregistrer",
|
||||
@@ -3627,5 +3627,20 @@
|
||||
"plugins.error.importRecipeIdentityRequired": "Cette recette distante ne définit pas l’identité du plugin. Avant l’import, définissez plugin: avec le nom du paquet natif dans la déclaration partagée ; l’import ne télécharge pas le code source.",
|
||||
"plugins.error.unimportTargetRequired": "unimport nécessite --target pour sélectionner un enregistrement d’import local",
|
||||
"plugins.error.unimportTargetMissing": "{name} n’a aucune liaison pour la cible {target}",
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} n’a aucun import local associé à une recette de source partagée"
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} n’a aucun import local associé à une recette de source partagée",
|
||||
"hooks.message.opencodeDependencies": "OpenCode v2 : fichiers du paquet et inscription uniquement. Préparez les dépendances déclarées avant le chargement. Skillshare n’exécute aucun plugin et n’installe aucune dépendance.",
|
||||
"hooks.message.opencodeImport": "{path} est toujours chargé. Après la synchronisation, supprimez ses fichiers d’origine et son inscription de répertoire pour éviter d’exécuter le plugin deux fois.",
|
||||
"hooks.message.opencodeExports": "Les exports du serveur OpenCode doivent être une chaîne (. ou ./server). Les exports conditionnels et de repli ne peuvent pas être vérifiés hors ligne.",
|
||||
"hooks.message.opencodeEntry": "OpenCode v2 nécessite name et exports, ou un fichier server/index .ts, .tsx ou .js à la racine. --entry ne peut pas remplacer le chargement du répertoire.",
|
||||
"hooks.message.opencodePackageFile": "Le fichier du paquet OpenCode {path} doit utiliser un chemin relatif sans remontée de répertoire et un contenu UTF-8.",
|
||||
"hooks.message.opencodePackageParent": "Le fichier du paquet OpenCode {path} est aussi un répertoire parent.",
|
||||
"hooks.message.opencodePackageExcluded": "Les paquets OpenCode ne doivent pas contenir {path}.",
|
||||
"hooks.message.opencodeManifest": "Impossible de lire le package.json OpenCode : {detail}",
|
||||
"hooks.message.opencodeExportPath": "L’export OpenCode {path} doit rester dans le paquet.",
|
||||
"hooks.message.opencodeExportMissing": "L’export OpenCode {path} est absent : {detail}",
|
||||
"hooks.message.opencodeUndetected": "OpenCode sur {target} : la version installée n'a pas pu être détectée ({detail}). Ses bindings de hooks sont ignorés ; la sortie existante est laissée telle quelle.",
|
||||
"hooks.message.opencodePackageNeedsV2": "{name} : un paquet de répertoire nécessite OpenCode v2 ; il est donc ignoré pour {target}.",
|
||||
"hooks.message.opencodePackageUnreadable": "Le fichier {path} du paquet OpenCode ne peut pas être importé : {detail}",
|
||||
"plugins.problem.opencodeDirectory": "OpenCode v2 exige l’inscription d’un répertoire, pas d’un fichier de plugin. Supprimez cette liaison, puis ajoutez à nouveau son paquet.",
|
||||
"plugins.skip.opencodeLocal": "Paquet local importé : mettez-le à jour à sa source. Skillshare n’exécute pas d’installateur de dépendances."
|
||||
}
|
||||
|
||||
@@ -3027,7 +3027,7 @@
|
||||
"hooks.native.pi": "Pi menemukan ekstensi saat mulai; ekstensi proyek hanya dimuat setelah kepercayaan proyek diberikan. Kode harus memakai API ekstensi dari versi Pi yang Anda pasang.",
|
||||
"hooks.native.omp": "Oh My Pi memuat ekstensi dari folder extensions saat mulai dan tidak meminta kepercayaan proyek, sehingga file yang disinkronkan dapat berjalan saat omp berikutnya dimulai di folder itu. Kode harus memakai API ekstensi dari versi omp yang terpasang.",
|
||||
"hooks.native.amp": "Amp menjalankan plugin dari folder plugins-nya dengan Bun; jalankan 'plugins: reload' setelah sinkronisasi. Kode harus memakai API plugin dari versi Amp Anda.",
|
||||
"hooks.native.opencode": "OpenCode memuat plugin dari folder plugins-nya. Plugin v1 adalah named export dan plugin v2 melakukan export default Plugin.define(...); Skillshare menulis kode Anda apa adanya dan tidak pernah mengonversi di antara keduanya.",
|
||||
"hooks.native.opencode": "OpenCode v1 menerima satu file; v2 menerima paket direktori dan URL direktori. Gunakan kode untuk API yang terpasang. Skillshare tidak menjalankan plugin atau memasang dependensi; siapkan dependensi yang dinyatakan sebelum memuat.",
|
||||
"hooks.syncHint": "Menyimpan hanya mengubah sumber. Sinkronkan hooks menulis file native.",
|
||||
"hooks.syncDialog.subtitle": "File native ini akan ditulis. Hook tidak dijalankan.",
|
||||
"hooks.syncDialog.done": "Hooks tersinkron. Setiap Agent tetap memutuskan sendiri apakah akan memercayai dan memuatnya.",
|
||||
@@ -3056,7 +3056,7 @@
|
||||
"hooks.code": "Kode ekstensi",
|
||||
"hooks.codePlaceholder": "// Satu file TypeScript atau JavaScript mandiri dengan API milik Agent",
|
||||
"hooks.codeRequired": "Tambahkan kode ekstensi.",
|
||||
"hooks.codeHint": "Ditulis apa adanya ke skillshare-{name}.ts di folder ekstensi {agent}.",
|
||||
"hooks.codeHint": "Ditulis apa adanya menggunakan tata letak native {agent} untuk skillshare-{name}.",
|
||||
"hooks.codeVersionNote": "Kode ini tidak dikonversi atau diperiksa terhadap versi {agent} Anda. Tulis sesuai API versi yang Anda jalankan.",
|
||||
"hooks.ompNoTrust": "Oh My Pi tidak punya konfirmasi kepercayaan proyek: ekstensi proyek dapat berjalan saat omp berikutnya dimulai di sana. Skillshare menulis kode ini apa adanya, tidak pernah menerjemahkannya, dan tidak pernah menjalankannya.",
|
||||
"hooks.incomplete": "Perbaiki {agents} sebelum menyimpan",
|
||||
@@ -3627,5 +3627,20 @@
|
||||
"plugins.error.importRecipeIdentityRequired": "Resep jarak jauh ini tidak memiliki identitas plugin. Sebelum mengimpor, isi plugin: dengan nama paket native dalam deklarasi bersama; impor tidak mengunduh kode sumber.",
|
||||
"plugins.error.unimportTargetRequired": "unimport memerlukan --target untuk memilih catatan impor lokal",
|
||||
"plugins.error.unimportTargetMissing": "{name} tidak memiliki ikatan untuk target {target}",
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} tidak memiliki impor lokal yang didukung resep sumber bersama"
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} tidak memiliki impor lokal yang didukung resep sumber bersama",
|
||||
"hooks.message.opencodeDependencies": "OpenCode v2: hanya file paket dan pendaftaran. Siapkan dependensi yang dinyatakan sebelum memuat. Skillshare tidak menjalankan plugin atau memasang dependensi.",
|
||||
"hooks.message.opencodeImport": "{path} masih dimuat. Setelah sinkronisasi, hapus file asli dan pendaftaran direktorinya agar plugin tidak berjalan dua kali.",
|
||||
"hooks.message.opencodeExports": "Exports server OpenCode harus berupa string (. atau ./server). Exports bersyarat dan cadangan tidak dapat diverifikasi secara offline.",
|
||||
"hooks.message.opencodeEntry": "OpenCode v2 memerlukan name dan exports, atau file server/index .ts, .tsx, atau .js di root. --entry tidak dapat menggantikan pemuatan direktori.",
|
||||
"hooks.message.opencodePackageFile": "File paket OpenCode {path} harus memakai jalur relatif tanpa keluar dari direktori dan konten UTF-8.",
|
||||
"hooks.message.opencodePackageParent": "File paket OpenCode {path} juga merupakan direktori induk.",
|
||||
"hooks.message.opencodePackageExcluded": "Paket OpenCode tidak boleh berisi {path}.",
|
||||
"hooks.message.opencodeManifest": "Tidak dapat membaca package.json OpenCode: {detail}",
|
||||
"hooks.message.opencodeExportPath": "Export OpenCode {path} harus tetap di dalam paket.",
|
||||
"hooks.message.opencodeExportMissing": "Export OpenCode {path} tidak ditemukan: {detail}",
|
||||
"hooks.message.opencodeUndetected": "OpenCode di {target}: versi terpasang tidak dapat dideteksi ({detail}). Binding hook-nya dilewati; keluaran yang ada dibiarkan apa adanya.",
|
||||
"hooks.message.opencodePackageNeedsV2": "{name}: paket direktori memerlukan OpenCode v2, jadi dilewati untuk {target}.",
|
||||
"hooks.message.opencodePackageUnreadable": "File paket OpenCode {path} tidak dapat diimpor: {detail}",
|
||||
"plugins.problem.opencodeDirectory": "OpenCode v2 memerlukan pendaftaran direktori, bukan file plugin. Hapus binding ini dan tambahkan paketnya lagi.",
|
||||
"plugins.skip.opencodeLocal": "Paket lokal yang diimpor: perbarui di sumbernya. Skillshare tidak menjalankan pemasang dependensi."
|
||||
}
|
||||
|
||||
@@ -3027,7 +3027,7 @@
|
||||
"hooks.native.pi": "Pi は起動時に拡張機能を検出します。プロジェクトの拡張機能は、プロジェクトの信頼が付与された後にのみ読み込まれます。コードは、インストール済みの Pi バージョンの拡張機能 API を使う必要があります。",
|
||||
"hooks.native.omp": "Oh My Pi は起動時に extensions フォルダーから拡張を読み込み、プロジェクトの信頼を確認しません。そのため同期したファイルは、そのフォルダーで omp が次に起動したときに実行される可能性があります。コードはインストール済みの omp バージョンの拡張 API に合わせて書いてください。",
|
||||
"hooks.native.amp": "Amp は plugins フォルダのプラグインを Bun で実行します。同期後に 'plugins: reload' を実行してください。コードは、お使いの Amp バージョンのプラグイン API を使う必要があります。",
|
||||
"hooks.native.opencode": "OpenCode は plugins フォルダからプラグインを読み込みます。v1 プラグインは名前付き export、v2 プラグインは export default Plugin.define(...) です。Skillshare はコードをそのまま書き込み、両者の間で変換することはありません。",
|
||||
"hooks.native.opencode": "OpenCode v1 は単一ファイル、v2 はディレクトリパッケージとディレクトリ URL を使います。インストール済み API に合うコードを指定してください。Skillshare はプラグインを実行せず、依存関係もインストールしません。読み込み前に宣言された依存関係を用意してください。",
|
||||
"hooks.syncHint": "保存してもソースが変わるだけです。「hooks を同期」でネイティブファイルに書き込みます。",
|
||||
"hooks.syncDialog.subtitle": "これらのネイティブファイルを書き込みます。hook は実行されません。",
|
||||
"hooks.syncDialog.done": "hooks を同期しました。信頼して読み込むかどうかは、引き続き各 Agent が判断します。",
|
||||
@@ -3056,7 +3056,7 @@
|
||||
"hooks.code": "拡張コード",
|
||||
"hooks.codePlaceholder": "// Agent 固有の API を使う、単独の TypeScript または JavaScript ファイル",
|
||||
"hooks.codeRequired": "拡張コードを入力してください。",
|
||||
"hooks.codeHint": "{agent} の拡張フォルダーの skillshare-{name}.ts にそのまま書き込まれます。",
|
||||
"hooks.codeHint": "{agent} のネイティブ形式で skillshare-{name} にそのまま書き込みます。",
|
||||
"hooks.codeVersionNote": "このコードは変換されず、お使いの {agent} のバージョンとも照合されません。実行しているバージョンの API 向けに書いてください。",
|
||||
"hooks.ompNoTrust": "Oh My Pi にはプロジェクト信頼の確認がありません。プロジェクトの拡張は、omp がそこで次に起動したときに実行される可能性があります。Skillshare はこのコードをそのまま書き込み、変換も実行も行いません。",
|
||||
"hooks.incomplete": "保存する前に {agents} を直してください",
|
||||
@@ -3627,5 +3627,20 @@
|
||||
"plugins.error.importRecipeIdentityRequired": "このリモートレシピにはプラグインの識別情報がありません。インポート前に、共有宣言の plugin: にネイティブパッケージ名を設定してください。インポートではソースをダウンロードしません。",
|
||||
"plugins.error.unimportTargetRequired": "unimport にはローカルのインポート記録を選択する --target が必要です",
|
||||
"plugins.error.unimportTargetMissing": "{name} にはターゲット {target} のバインディングがありません",
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} には共有ソースレシピに対応するローカルのインポートがありません"
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} には共有ソースレシピに対応するローカルのインポートがありません",
|
||||
"hooks.message.opencodeDependencies": "OpenCode v2:パッケージファイルと登録のみを管理します。読み込み前に宣言された依存関係を用意してください。Skillshare はプラグインの実行や依存関係のインストールを行いません。",
|
||||
"hooks.message.opencodeImport": "{path} は引き続き読み込まれます。同期後に元のファイルとディレクトリ登録を削除し、プラグインの二重実行を防いでください。",
|
||||
"hooks.message.opencodeExports": "OpenCode サーバーの exports は文字列(. または ./server)である必要があります。条件付き・フォールバックの exports はオフラインで検証できません。",
|
||||
"hooks.message.opencodeEntry": "OpenCode v2 には name と exports、またはルートの server/index .ts、.tsx、.js ファイルが必要です。--entry でディレクトリの読み込みを上書きすることはできません。",
|
||||
"hooks.message.opencodePackageFile": "OpenCode パッケージファイル {path} には、上位ディレクトリに移動しない相対パスと UTF-8 の内容が必要です。",
|
||||
"hooks.message.opencodePackageParent": "OpenCode パッケージファイル {path} は親ディレクトリでもあります。",
|
||||
"hooks.message.opencodePackageExcluded": "OpenCode パッケージに {path} を含めることはできません。",
|
||||
"hooks.message.opencodeManifest": "OpenCode の package.json を読み取れません:{detail}",
|
||||
"hooks.message.opencodeExportPath": "OpenCode の export {path} はパッケージ内にある必要があります。",
|
||||
"hooks.message.opencodeExportMissing": "OpenCode の export {path} が見つかりません:{detail}",
|
||||
"hooks.message.opencodeUndetected": "{target} の OpenCode: インストールされているバージョンを検出できませんでした({detail})。フックのバインディングはスキップされ、既存の出力はそのまま残ります。",
|
||||
"hooks.message.opencodePackageNeedsV2": "{name}: ディレクトリパッケージには OpenCode v2 が必要なため、{target} ではスキップされます。",
|
||||
"hooks.message.opencodePackageUnreadable": "OpenCode パッケージのファイル {path} をインポートできません: {detail}",
|
||||
"plugins.problem.opencodeDirectory": "OpenCode v2 にはプラグインファイルではなくディレクトリの登録が必要です。このバインディングを削除してパッケージを追加し直してください。",
|
||||
"plugins.skip.opencodeLocal": "インポート済みローカルパッケージ:元の場所で更新してください。Skillshare は依存関係のインストーラーを実行しません。"
|
||||
}
|
||||
|
||||
@@ -3027,7 +3027,7 @@
|
||||
"hooks.native.pi": "Pi는 시작할 때 확장을 찾습니다. 프로젝트 확장은 프로젝트 신뢰가 부여된 후에만 로드됩니다. 코드는 설치된 Pi 버전의 확장 API를 사용해야 합니다.",
|
||||
"hooks.native.omp": "Oh My Pi는 시작할 때 extensions 폴더에서 확장을 불러오며 프로젝트 신뢰를 묻지 않습니다. 따라서 동기화된 파일은 해당 폴더에서 omp가 다음에 시작될 때 실행될 수 있습니다. 코드는 설치된 omp 버전의 확장 API를 사용해야 합니다.",
|
||||
"hooks.native.amp": "Amp는 plugins 폴더의 플러그인을 Bun으로 실행합니다. 동기화 후 'plugins: reload'를 실행하세요. 코드는 사용 중인 Amp 버전의 플러그인 API를 사용해야 합니다.",
|
||||
"hooks.native.opencode": "OpenCode는 plugins 폴더에서 플러그인을 불러옵니다. v1 플러그인은 명명된 export이고 v2 플러그인은 export default Plugin.define(...)입니다. Skillshare는 코드를 그대로 작성하며 둘 사이를 변환하지 않습니다.",
|
||||
"hooks.native.opencode": "OpenCode v1은 단일 파일, v2는 디렉터리 패키지와 디렉터리 URL을 사용합니다. 설치된 API에 맞는 코드를 제공하세요. Skillshare는 플러그인을 실행하거나 의존성을 설치하지 않습니다. 로드 전에 선언된 의존성을 준비하세요.",
|
||||
"hooks.syncHint": "저장은 소스만 변경합니다. 'hooks 동기화'가 네이티브 파일에 기록합니다.",
|
||||
"hooks.syncDialog.subtitle": "다음 네이티브 파일이 작성됩니다. hook은 실행되지 않습니다.",
|
||||
"hooks.syncDialog.done": "hooks를 동기화했습니다. 신뢰하고 불러올지는 여전히 각 Agent가 결정합니다.",
|
||||
@@ -3056,7 +3056,7 @@
|
||||
"hooks.code": "확장 코드",
|
||||
"hooks.codePlaceholder": "// Agent 고유의 API를 사용하는 독립된 TypeScript 또는 JavaScript 파일 하나",
|
||||
"hooks.codeRequired": "확장 코드를 입력하세요.",
|
||||
"hooks.codeHint": "{agent}의 확장 폴더에 skillshare-{name}.ts로 그대로 기록됩니다.",
|
||||
"hooks.codeHint": "{agent}의 네이티브 구조에 따라 skillshare-{name}에 그대로 기록됩니다.",
|
||||
"hooks.codeVersionNote": "이 코드는 변환되거나 {agent} 버전에 맞춰 검사되지 않습니다. 실행 중인 버전의 API에 맞게 작성하세요.",
|
||||
"hooks.ompNoTrust": "Oh My Pi에는 프로젝트 신뢰 확인이 없습니다. 프로젝트 확장은 omp가 그곳에서 다음에 시작될 때 실행될 수 있습니다. Skillshare는 이 코드를 그대로 쓰기만 하며 변환하거나 실행하지 않습니다.",
|
||||
"hooks.incomplete": "저장하기 전에 {agents}을(를) 고치세요",
|
||||
@@ -3627,5 +3627,20 @@
|
||||
"plugins.error.importRecipeIdentityRequired": "이 원격 설치 설정에는 플러그인 식별 정보가 없습니다. 가져오기 전에 공유 선언의 plugin:을 네이티브 패키지 이름으로 설정하세요. 가져오기는 소스를 다운로드하지 않습니다.",
|
||||
"plugins.error.unimportTargetRequired": "unimport에는 로컬 가져오기 기록을 선택하는 --target이 필요합니다",
|
||||
"plugins.error.unimportTargetMissing": "{name}에 대상 {target}의 바인딩이 없습니다",
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target}에 공유 소스 설정에 연결된 로컬 가져오기가 없습니다"
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target}에 공유 소스 설정에 연결된 로컬 가져오기가 없습니다",
|
||||
"hooks.message.opencodeDependencies": "OpenCode v2: 패키지 파일과 등록만 관리합니다. 로드 전에 선언된 의존성을 준비하세요. Skillshare는 플러그인을 실행하거나 의존성을 설치하지 않습니다.",
|
||||
"hooks.message.opencodeImport": "{path}은(는) 계속 로드됩니다. 동기화 후 원본 파일과 디렉터리 등록을 제거해 플러그인 중복 실행을 방지하세요.",
|
||||
"hooks.message.opencodeExports": "OpenCode 서버 exports는 문자열(. 또는 ./server)이어야 합니다. 조건부 및 대체 exports는 오프라인에서 검증할 수 없습니다.",
|
||||
"hooks.message.opencodeEntry": "OpenCode v2에는 name과 exports 또는 루트의 server/index .ts, .tsx, .js 파일이 필요합니다. --entry로 디렉터리 로드를 재정의할 수 없습니다.",
|
||||
"hooks.message.opencodePackageFile": "OpenCode 패키지 파일 {path}에는 상위 디렉터리로 이동하지 않는 상대 경로와 UTF-8 내용이 필요합니다.",
|
||||
"hooks.message.opencodePackageParent": "OpenCode 패키지 파일 {path}은(는) 상위 디렉터리이기도 합니다.",
|
||||
"hooks.message.opencodePackageExcluded": "OpenCode 패키지에는 {path}을(를) 포함할 수 없습니다.",
|
||||
"hooks.message.opencodeManifest": "OpenCode package.json을 읽을 수 없습니다: {detail}",
|
||||
"hooks.message.opencodeExportPath": "OpenCode export {path}은(는) 패키지 내부에 있어야 합니다.",
|
||||
"hooks.message.opencodeExportMissing": "OpenCode export {path}을(를) 찾을 수 없습니다: {detail}",
|
||||
"hooks.message.opencodeUndetected": "{target}의 OpenCode: 설치된 버전을 감지할 수 없습니다({detail}). 훅 바인딩은 건너뛰며 기존 출력은 그대로 둡니다.",
|
||||
"hooks.message.opencodePackageNeedsV2": "{name}: 디렉터리 패키지는 OpenCode v2가 필요하므로 {target}에서는 건너뜁니다.",
|
||||
"hooks.message.opencodePackageUnreadable": "OpenCode 패키지 파일 {path}을(를) 가져올 수 없습니다: {detail}",
|
||||
"plugins.problem.opencodeDirectory": "OpenCode v2에는 플러그인 파일이 아닌 디렉터리 등록이 필요합니다. 이 바인딩을 제거한 후 패키지를 다시 추가하세요.",
|
||||
"plugins.skip.opencodeLocal": "가져온 로컬 패키지: 원본 위치에서 업데이트하세요. Skillshare는 의존성 설치 프로그램을 실행하지 않습니다."
|
||||
}
|
||||
|
||||
@@ -3027,7 +3027,7 @@
|
||||
"hooks.native.pi": "O Pi descobre extensões na inicialização; as extensões de projeto só são carregadas depois que a confiança no projeto é concedida. O código deve usar a API de extensões da sua versão instalada do Pi.",
|
||||
"hooks.native.omp": "O Oh My Pi carrega extensões da sua pasta de extensões ao iniciar e não pede confiança do projeto, então um arquivo sincronizado pode ser executado na próxima vez que o omp iniciar nessa pasta. O código deve usar a API de extensões da versão do omp instalada.",
|
||||
"hooks.native.amp": "O Amp executa com Bun os plugins da sua pasta plugins; execute 'plugins: reload' após o sync. O código deve usar a API de plugins da sua versão do Amp.",
|
||||
"hooks.native.opencode": "O OpenCode carrega plugins da sua pasta plugins. Plugins v1 são exports nomeados e plugins v2 fazem export default Plugin.define(...); o Skillshare grava seu código como está e nunca converte entre os dois.",
|
||||
"hooks.native.opencode": "OpenCode v1 recebe um arquivo; v2 recebe um pacote de diretório e sua URL. Forneça código para a API instalada. O Skillshare não executa plugins nem instala dependências; prepare-as antes de carregar.",
|
||||
"hooks.syncHint": "Salvar só altera a origem. Sincronizar hooks grava os arquivos nativos.",
|
||||
"hooks.syncDialog.subtitle": "Estes arquivos nativos serão gravados. Os hooks não são executados.",
|
||||
"hooks.syncDialog.done": "Hooks sincronizados. Cada Agent ainda decide se confia neles e os carrega.",
|
||||
@@ -3056,7 +3056,7 @@
|
||||
"hooks.code": "Código da extensão",
|
||||
"hooks.codePlaceholder": "// Um único arquivo TypeScript ou JavaScript independente, na API do próprio Agent",
|
||||
"hooks.codeRequired": "Adicione o código da extensão.",
|
||||
"hooks.codeHint": "Gravado como está em skillshare-{name}.ts na pasta de extensões de {agent}.",
|
||||
"hooks.codeHint": "Gravado sem alterações na estrutura nativa de {agent} para skillshare-{name}.",
|
||||
"hooks.codeVersionNote": "Este código não é convertido nem verificado com a sua versão do {agent}. Escreva-o para a API da versão que você usa.",
|
||||
"hooks.ompNoTrust": "O Oh My Pi não tem aviso de confiança do projeto: uma extensão de projeto pode ser executada na próxima vez que o omp iniciar ali. O Skillshare grava este código como está, nunca o traduz e nunca o executa.",
|
||||
"hooks.incomplete": "Corrija {agents} antes de salvar",
|
||||
@@ -3627,5 +3627,20 @@
|
||||
"plugins.error.importRecipeIdentityRequired": "Esta receita remota não define a identidade do plugin. Antes de importar, defina plugin: com o nome do pacote nativo na declaração compartilhada; a importação não baixa o código-fonte.",
|
||||
"plugins.error.unimportTargetRequired": "unimport requer --target para selecionar um registro de importação local",
|
||||
"plugins.error.unimportTargetMissing": "{name} não tem vínculo com o destino {target}",
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} não tem importação local associada a uma receita de fonte compartilhada"
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} não tem importação local associada a uma receita de fonte compartilhada",
|
||||
"hooks.message.opencodeDependencies": "OpenCode v2: somente arquivos do pacote e registro. Prepare as dependências declaradas antes de carregar. O Skillshare não executa plugins nem instala dependências.",
|
||||
"hooks.message.opencodeImport": "{path} continua sendo carregado. Após sincronizar, remova os arquivos originais e o registro do diretório para evitar executar o plugin duas vezes.",
|
||||
"hooks.message.opencodeExports": "Os exports do servidor OpenCode devem ser uma string (. ou ./server). Exports condicionais e alternativos não podem ser verificados offline.",
|
||||
"hooks.message.opencodeEntry": "OpenCode v2 precisa de name e exports, ou de um arquivo server/index .ts, .tsx ou .js na raiz. --entry não pode substituir o carregamento do diretório.",
|
||||
"hooks.message.opencodePackageFile": "O arquivo do pacote OpenCode {path} deve usar um caminho relativo sem sair do diretório e conteúdo UTF-8.",
|
||||
"hooks.message.opencodePackageParent": "O arquivo do pacote OpenCode {path} também é um diretório pai.",
|
||||
"hooks.message.opencodePackageExcluded": "Pacotes OpenCode não devem conter {path}.",
|
||||
"hooks.message.opencodeManifest": "Não foi possível ler o package.json do OpenCode: {detail}",
|
||||
"hooks.message.opencodeExportPath": "O export do OpenCode {path} deve permanecer dentro do pacote.",
|
||||
"hooks.message.opencodeExportMissing": "O export do OpenCode {path} está ausente: {detail}",
|
||||
"hooks.message.opencodeUndetected": "OpenCode em {target}: não foi possível detectar a versão instalada ({detail}). Seus bindings de hooks são ignorados; a saída existente é mantida como está.",
|
||||
"hooks.message.opencodePackageNeedsV2": "{name}: um pacote de diretório requer o OpenCode v2, então é ignorado para {target}.",
|
||||
"hooks.message.opencodePackageUnreadable": "O arquivo {path} do pacote OpenCode não pode ser importado: {detail}",
|
||||
"plugins.problem.opencodeDirectory": "O OpenCode v2 exige o registro de um diretório, não de um arquivo de plugin. Remova esse vínculo e adicione o pacote novamente.",
|
||||
"plugins.skip.opencodeLocal": "Pacote local importado: atualize-o na origem. O Skillshare não executa instaladores de dependências."
|
||||
}
|
||||
|
||||
@@ -3027,7 +3027,7 @@
|
||||
"hooks.native.pi": "Pi 在启动时发现扩展;项目扩展要在授予项目信任后才会加载。代码必须使用你所安装 Pi 版本的扩展 API。",
|
||||
"hooks.native.omp": "Oh My Pi 启动时会从 extensions 文件夹加载 extension,且不会询问项目信任,所以同步进去的文件可能在 omp 下次于该文件夹启动时就执行。代码必须使用你安装的 omp 版本的 extension API。",
|
||||
"hooks.native.amp": "Amp 用 Bun 运行其 plugins 文件夹中的插件;同步后请运行 'plugins: reload'。代码必须使用你的 Amp 版本的插件 API。",
|
||||
"hooks.native.opencode": "OpenCode 从其 plugins 文件夹加载插件。v1 插件是具名 export,v2 插件则 export default Plugin.define(...);Skillshare 按原样写入你的代码,不会在两者之间转换。",
|
||||
"hooks.native.opencode": "OpenCode v1 使用单一文件;v2 使用目录包与目录 URL。请提供符合已安装 API 的代码。Skillshare 不执行插件或安装依赖;加载前请自行准备声明的依赖。",
|
||||
"hooks.syncHint": "保存只会更改来源。点「同步 hooks」才会写入原生文件。",
|
||||
"hooks.syncDialog.subtitle": "将写入这些原生文件,hook 不会被执行。",
|
||||
"hooks.syncDialog.done": "Hooks 已同步。各个目标仍会自行决定是否信任并加载。",
|
||||
@@ -3056,7 +3056,7 @@
|
||||
"hooks.code": "扩展代码",
|
||||
"hooks.codePlaceholder": "// 单个独立的 TypeScript 或 JavaScript 文件,使用目标自己的 API",
|
||||
"hooks.codeRequired": "请填入扩展代码。",
|
||||
"hooks.codeHint": "原样写入 {agent} 扩展文件夹中的 skillshare-{name}.ts。",
|
||||
"hooks.codeHint": "按 {agent} 的原生布局,原样写入 skillshare-{name}。",
|
||||
"hooks.codeVersionNote": "这段代码不会转换,也不会按你的 {agent} 版本检查。请按你使用的版本 API 编写。",
|
||||
"hooks.ompNoTrust": "Oh My Pi 没有项目信任提示:项目 extension 可能在 omp 下次于该处启动时就执行。Skillshare 会原样写入这段代码,不会转换,也绝不会执行它。",
|
||||
"hooks.incomplete": "保存前请先修正 {agents}",
|
||||
@@ -3627,5 +3627,20 @@
|
||||
"plugins.error.importRecipeIdentityRequired": "此远程安装配方没有插件标识。导入前,请将共享声明中的 plugin: 设为原生包名;导入不会下载源代码。",
|
||||
"plugins.error.unimportTargetRequired": "unimport 需要 --target 来选择本机导入记录",
|
||||
"plugins.error.unimportTargetMissing": "{name} 没有目标 {target} 的绑定",
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} 没有共享来源配置支持的本机导入"
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} 没有共享来源配置支持的本机导入",
|
||||
"hooks.message.opencodeDependencies": "OpenCode v2:仅管理包文件与注册。加载前请准备声明的依赖。Skillshare 不会执行插件或安装依赖。",
|
||||
"hooks.message.opencodeImport": "{path} 仍会加载。同步后请移除其原始文件及目录注册,避免插件执行两次。",
|
||||
"hooks.message.opencodeExports": "OpenCode 服务器 exports 必须是字符串(. 或 ./server)。无法离线验证条件或后备 exports。",
|
||||
"hooks.message.opencodeEntry": "OpenCode v2 需要 name 和 exports,或根目录下的 server/index .ts、.tsx 或 .js 文件。--entry 不能覆盖目录加载方式。",
|
||||
"hooks.message.opencodePackageFile": "OpenCode 包文件 {path} 必须使用不越界的相对路径和 UTF-8 内容。",
|
||||
"hooks.message.opencodePackageParent": "OpenCode 包文件 {path} 同时也是父目录。",
|
||||
"hooks.message.opencodePackageExcluded": "OpenCode 包不能包含 {path}。",
|
||||
"hooks.message.opencodeManifest": "无法读取 OpenCode 的 package.json:{detail}",
|
||||
"hooks.message.opencodeExportPath": "OpenCode export {path} 必须位于包内。",
|
||||
"hooks.message.opencodeExportMissing": "缺少 OpenCode export {path}:{detail}",
|
||||
"hooks.message.opencodeUndetected": "{target} 的 OpenCode:无法检测已安装的版本({detail})。已跳过其 hook 绑定;现有输出保持不变。",
|
||||
"hooks.message.opencodePackageNeedsV2": "{name}:目录包需要 OpenCode v2,因此在 {target} 上跳过。",
|
||||
"hooks.message.opencodePackageUnreadable": "无法导入 OpenCode 包文件 {path}:{detail}",
|
||||
"plugins.problem.opencodeDirectory": "OpenCode v2 需要目录注册,而非插件文件。请移除此绑定,再重新添加其包。",
|
||||
"plugins.skip.opencodeLocal": "已导入的本地包:请在源位置更新。Skillshare 不会运行依赖安装程序。"
|
||||
}
|
||||
|
||||
@@ -3027,7 +3027,7 @@
|
||||
"hooks.native.pi": "Pi 在啟動時探索擴充功能;專案擴充功能要在授予專案信任後才會載入。程式碼必須使用你所安裝 Pi 版本的擴充功能 API。",
|
||||
"hooks.native.omp": "Oh My Pi 啟動時會從 extensions 資料夾載入 extension,且不會詢問專案信任,所以同步進去的檔案可能在 omp 下次於該資料夾啟動時就執行。程式碼必須使用你安裝的 omp 版本的 extension API。",
|
||||
"hooks.native.amp": "Amp 用 Bun 執行其 plugins 資料夾中的外掛;同步後請執行 'plugins: reload'。程式碼必須使用你的 Amp 版本的外掛 API。",
|
||||
"hooks.native.opencode": "OpenCode 從其 plugins 資料夾載入外掛。v1 外掛是具名 export,v2 外掛則 export default Plugin.define(...);Skillshare 照原樣寫入你的程式碼,不會在兩者之間轉換。",
|
||||
"hooks.native.opencode": "OpenCode v1 使用單一檔案;v2 使用目錄套件與目錄 URL。請提供符合已安裝 API 的程式碼。Skillshare 不執行外掛或安裝相依套件;載入前請自行準備宣告的相依套件。",
|
||||
"hooks.syncHint": "儲存只會更改來源。按「同步 hooks」才會寫入原生檔案。",
|
||||
"hooks.syncDialog.subtitle": "將寫入這些原生檔案,hook 不會被執行。",
|
||||
"hooks.syncDialog.done": "Hooks 已同步。各個目標仍會自行決定是否信任並載入。",
|
||||
@@ -3056,7 +3056,7 @@
|
||||
"hooks.code": "擴充程式碼",
|
||||
"hooks.codePlaceholder": "// 單一獨立的 TypeScript 或 JavaScript 檔案,使用目標自己的 API",
|
||||
"hooks.codeRequired": "請填入擴充程式碼。",
|
||||
"hooks.codeHint": "原樣寫入 {agent} 擴充資料夾中的 skillshare-{name}.ts。",
|
||||
"hooks.codeHint": "依 {agent} 的原生配置,原樣寫入 skillshare-{name}。",
|
||||
"hooks.codeVersionNote": "這段程式碼不會轉換,也不會依你的 {agent} 版本檢查。請依你使用的版本 API 撰寫。",
|
||||
"hooks.ompNoTrust": "Oh My Pi 沒有專案信任提示:專案 extension 可能在 omp 下次於該處啟動時就執行。Skillshare 會原樣寫入這段程式碼,不會轉換,也絕不會執行它。",
|
||||
"hooks.incomplete": "儲存前請先修正 {agents}",
|
||||
@@ -3627,5 +3627,20 @@
|
||||
"plugins.error.importRecipeIdentityRequired": "此遠端安裝配方沒有外掛識別資訊。匯入前,請將共用宣告中的 plugin: 設為原生套件名稱;匯入不會下載原始碼。",
|
||||
"plugins.error.unimportTargetRequired": "unimport 需要 --target 來選取本機匯入紀錄",
|
||||
"plugins.error.unimportTargetMissing": "{name} 沒有目標 {target} 的綁定",
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} 沒有共用來源設定支持的本機匯入"
|
||||
"plugins.error.unimportReceiptRequired": "{name}/{target} 沒有共用來源設定支持的本機匯入",
|
||||
"hooks.message.opencodeDependencies": "OpenCode v2:僅管理套件檔案與註冊。載入前請準備宣告的相依套件。Skillshare 不會執行外掛或安裝相依套件。",
|
||||
"hooks.message.opencodeImport": "{path} 仍會載入。同步後請移除其原始檔案及目錄註冊,避免外掛執行兩次。",
|
||||
"hooks.message.opencodeExports": "OpenCode 伺服器 exports 必須是字串(. 或 ./server)。無法離線驗證條件或備援 exports。",
|
||||
"hooks.message.opencodeEntry": "OpenCode v2 需要 name 和 exports,或根目錄下的 server/index .ts、.tsx 或 .js 檔案。--entry 不能覆寫目錄載入方式。",
|
||||
"hooks.message.opencodePackageFile": "OpenCode 套件檔案 {path} 必須使用不越界的相對路徑與 UTF-8 內容。",
|
||||
"hooks.message.opencodePackageParent": "OpenCode 套件檔案 {path} 同時也是父目錄。",
|
||||
"hooks.message.opencodePackageExcluded": "OpenCode 套件不能包含 {path}。",
|
||||
"hooks.message.opencodeManifest": "無法讀取 OpenCode 的 package.json:{detail}",
|
||||
"hooks.message.opencodeExportPath": "OpenCode export {path} 必須位於套件內。",
|
||||
"hooks.message.opencodeExportMissing": "缺少 OpenCode export {path}:{detail}",
|
||||
"hooks.message.opencodeUndetected": "{target} 的 OpenCode:無法偵測已安裝的版本({detail})。已略過其 hook 綁定;現有輸出保持不變。",
|
||||
"hooks.message.opencodePackageNeedsV2": "{name}:目錄套件需要 OpenCode v2,因此在 {target} 上略過。",
|
||||
"hooks.message.opencodePackageUnreadable": "無法匯入 OpenCode 套件檔案 {path}:{detail}",
|
||||
"plugins.problem.opencodeDirectory": "OpenCode v2 需要目錄註冊,而非外掛檔案。請移除此綁定,再重新加入其套件。",
|
||||
"plugins.skip.opencodeLocal": "已匯入的本機套件:請在來源位置更新。Skillshare 不會執行相依套件安裝程式。"
|
||||
}
|
||||
|
||||
@@ -40,8 +40,9 @@ export const fieldDocs: Record<string, FieldDoc> = {
|
||||
'hooks.entries.enabled': { description: 'Defaults to true. A disabled hook keeps its definition and is removed from the Agents at the next sync.', type: 'boolean', example: 'enabled: false' },
|
||||
'hooks.entries.bindings': { description: 'What each Agent receives, keyed by Agent name. Written in that Agent\'s own format without translation.', type: 'object', example: 'bindings:\n claude:\n events: {}' },
|
||||
'hooks.entries.bindings.events': { description: 'The Agent\'s own event map, such as SessionStart or Stop, copied into its hook file as written.', type: 'object', example: 'events:\n Stop:\n - command: echo done' },
|
||||
'hooks.entries.bindings.code': { description: 'For Agents whose hooks are code (Pi, Amp, OpenCode): one TypeScript or JavaScript extension or plugin.', type: 'string', example: 'code: |\n export default function (pi) {}' },
|
||||
'hooks.entries.bindings.code': { description: 'For Agents whose hooks are code (Pi, Amp, OpenCode): one TypeScript or JavaScript extension or plugin. For a whole OpenCode v2 directory, use package instead.', type: 'string', example: 'code: |\n export default function (pi) {}' },
|
||||
'hooks.entries.bindings.codeFile': { description: 'Instead of code: a path, relative to this config\'s folder, whose contents are used as the code. Read every time the config is read.', type: 'string', example: 'codeFile: hooks/lint.pi.ts' },
|
||||
'hooks.entries.bindings.package': { description: 'OpenCode v2 only, instead of code: a whole plugin directory as relative filename → UTF-8 contents, including package.json. Dependencies are kept as declared and never installed.', type: 'object', example: 'package:\n package.json: |\n {"name": "guard", "exports": "./index.ts"}\n index.ts: |\n export default {}' },
|
||||
'hooks.entries.bindings.files': { description: 'Script files the hook calls, written to <Agent config dir>/hooks/skillshare/<hook>/. A value is the contents or {from: path}, a path relative to this config\'s folder.', type: 'object', example: 'files:\n check.sh:\n from: hooks/check.sh' },
|
||||
'hooks.projects': { description: 'Hooks for other projects, keyed by project path, so one sync from the global config reaches each project.', type: 'object', example: 'projects:\n /work/app:\n entries: {}' },
|
||||
'mcp.targets': {
|
||||
|
||||
@@ -143,7 +143,7 @@ Agents add events over time. Pi, OMP, Amp and OpenCode code is not checked.
|
||||
|
||||
Pi, OMP, Amp and OpenCode use their own extension/plugin APIs. Supply code matching
|
||||
the installed Agent version, including its imports. Skillshare writes it to a
|
||||
dedicated `skillshare-NAME.ts` file without generating a universal hook runtime.
|
||||
dedicated `skillshare-NAME.ts` file (OpenCode v1), or an OpenCode v2 directory package, without generating a universal hook runtime.
|
||||
|
||||
Longer code and scripts can live in their own files, which a tsconfig, shellcheck or
|
||||
an editor can check. Use `codeFile` instead of `code`, and `{from: path}` instead of a
|
||||
@@ -210,7 +210,7 @@ you provide. Inspect the exact paths in the preview.
|
||||
| [Pi](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/extensions.md) | `~/.pi/agent/extensions/skillshare-NAME.ts` | `.pi/extensions/skillshare-NAME.ts` | Native extension code |
|
||||
| [Oh My Pi](https://github.com/can1357/oh-my-pi/blob/v18.6.1/docs/extensions.md) | `~/.omp/agent/extensions/skillshare-NAME.ts` | `.omp/extensions/skillshare-NAME.ts` | Native OMP extension code |
|
||||
| [Amp](https://ampcode.com/docs/plugin-api) | `~/.config/amp/plugins/skillshare-NAME.ts` | `.amp/plugins/skillshare-NAME.ts` | Native plugin code |
|
||||
| [OpenCode](https://opencode.ai/docs/plugins/) | `~/.config/opencode/plugins/skillshare-NAME.ts` | `.opencode/plugins/skillshare-NAME.ts` | Supplied v1/v2 plugin code |
|
||||
| [OpenCode](https://opencode.ai/docs/plugins/) | `~/.config/opencode/plugins/skillshare-NAME[.ts]` | `.opencode/plugins/skillshare-NAME[.ts]` | v1 file; v2 directory package (see below) |
|
||||
|
||||
Native config-directory environment overrides apply in global scope, unless
|
||||
they point at an account's `config_dir`. Project
|
||||
@@ -413,3 +413,15 @@ not replace your source definition. Use **Settings → Backups → Hooks** or
|
||||
Agent as its native workflow requires; native trust, enabling hooks and code
|
||||
compatibility remain controlled by that Agent. Skillshare never executes hook
|
||||
commands during management or changes native trust automatically.
|
||||
|
||||
### OpenCode v2 directory packages
|
||||
|
||||
On Windows, the hook version probe resolves npm's standard native `.cmd` shims for `opencode-ai` (later v1) and `@opencode/cli` (v2) directly to their installed `bin/opencode.exe`, without a shell. Older v1 Node-based launchers and custom batch wrappers are not inferred or executed. For those installations, set the OpenCode account's `cli` to the absolute path of its installed native `opencode.exe` (for example, the matching `opencode-windows-x64-baseline` package's `bin/opencode.exe`), or put that native executable's directory first on `PATH`. Skillshare does not run postinstall scripts or repair missing binaries.
|
||||
|
||||
Skillshare probes only `opencode --version` (or the account's `cli`). When the version cannot be detected, because the binary is missing or fails or reports a major version other than 1 or 2, only the OpenCode bindings are skipped: the preview shows a warning, existing OpenCode output is left as it is, and every other Agent syncs normally. v1 keeps the flat `.ts` file. v2 writes `plugins/skillshare-NAME/index.ts` plus `package.json`, declaring `@opencode/plugin: ^2.0.0`, and adds the directory's `file://` URL to `plugins` in `opencode.json(c)`. Project hooks use `.opencode/opencode.json(c)`. Comments and unrelated registrations remain unchanged. Conflicting JSON/JSONC files or `OPENCODE_CONFIG`/`OPENCODE_CONFIG_CONTENT` overrides are refused for hooks. A `code` binding is written as given on either version; Skillshare does not check that it matches the v1 or v2 plugin API.
|
||||
|
||||
For a complete v2 package, use `bindings.opencode.package` instead of `code`/`codeFile`: a map of relative filenames to UTF-8 contents, including `package.json`. The manifest and its dependency requirements are preserved verbatim. Nested files are allowed; traversal, symlinks, file/directory collisions, `.git`, and `node_modules` are not package payloads. The native editor displays this file map as JSON. The server entry must be a string root or `./server` export with a package name, or a conventional root `server`/`index` file (`.ts`, `.tsx`, `.js`). Conditional and fallback server exports are refused rather than guessed. A `package` binding needs OpenCode v2; on v1 it is skipped with a warning.
|
||||
|
||||
`hooks import --from opencode` also reads immediate package directories under the native `plugins` folder. Like flat code imports, it copies them to Skillshare's named output and warns you to remove the original files and registration after syncing to avoid duplicate loading. Installed `node_modules` and `.git` are not imported. A package holding a file that cannot be read, such as a symlink, is listed with that problem; the other packages and flat files stay importable. On OpenCode v1, directories under `plugins` are not listed as hooks. Sync, edits and removal use the same ownership checks and backups as other hooks; an externally edited package file conflicts rather than being overwritten.
|
||||
|
||||
Provision declared dependencies yourself before loading; the preview says so whenever it writes package files. Skillshare never runs plugin code, installs dependencies, or converts v1 code to v2. Registration is not proof the plugin loaded. The dashboard intentionally supplies no OpenCode starter code because the two APIs differ.
|
||||
|
||||
@@ -395,14 +395,16 @@ folders, including files linked there by [extras](./extras.md), are listed
|
||||
read-only with where to change them; a project lists its own folder, which Pi
|
||||
reads only if it trusts the project, and the global one.
|
||||
|
||||
OpenCode registers the managed entry as a file URL in `opencode.json` or the
|
||||
OpenCode v1 registers the managed entry file; v2 registers the package directory as a file URL in `opencode.json` or the
|
||||
existing `opencode.jsonc`, preserving comments and unrelated entries. Version 1
|
||||
uses `plugin`; version 2 uses `plugins`. `XDG_CONFIG_HOME` and an absolute global
|
||||
`OPENCODE_CONFIG` are respected; ambiguous or unsupported overrides are rejected.
|
||||
OpenCode must be on PATH so Skillshare can choose the version's schema.
|
||||
A v2 directory package that [`hooks`](./hooks.md) registers in the same `plugins`
|
||||
array (`plugins/skillshare-NAME`) belongs to hooks; `plugin list` and
|
||||
`plugin import` do not show it.
|
||||
|
||||
A local OpenCode source must already include its built entry (`main`, a string
|
||||
root export, or `index.js`) and required runtime dependencies. Skillshare does not
|
||||
A local OpenCode v1 source needs its built entry (`main`, a string root export, or `index.js`). v2 uses the directory loader: `name` plus a string root or `./server` export, or a root `server`/`index` file (`.ts`, `.tsx`, `.js`). `--entry` does not override v2 directory loading; conditional and fallback server exports are refused. Both `@opencode-ai/plugin` and `@opencode/plugin` identify OpenCode packages. Manifests and dependency requirements remain unchanged. Skillshare does not
|
||||
run build scripts or install dependencies into the source. Registration is not
|
||||
proof the module loaded successfully; check OpenCode after reload.
|
||||
|
||||
@@ -426,7 +428,7 @@ can be imported; filtered OpenCode entries are still rejected.
|
||||
Imported Pi packages are updated with `pi update SOURCE` in global mode, which
|
||||
keeps their settings entry; a project's are updated in Pi, because `pi update`
|
||||
also reaches global packages. Imported OpenCode v1 packages are updated in their
|
||||
native tool. OpenCode v2 global imports can use its native update command; project imports must be
|
||||
native tool. OpenCode v2 global package imports can use its native update command; imported local directories are left for you to update without running dependency installers; project imports must be
|
||||
updated natively because the v2 update command is global.
|
||||
|
||||
```bash
|
||||
@@ -640,3 +642,5 @@ its local receipt. Shared declarations and other machines' installations stay
|
||||
unchanged. The next sync installs the shared source recipe.
|
||||
|
||||
Uninstalling also removes native-client configuration or login associated with that installation.
|
||||
|
||||
A flat-file registration left by an older Skillshare OpenCode v2 adapter is rejected for add/import/sync/update. Remove the old managed binding and add its directory package again. Removal remains available and leaves unrelated native registrations untouched. A runtime version change after preview requires a fresh preview.
|
||||
|
||||
@@ -91,7 +91,7 @@ Skillshare は `hooks` セクションをインデントした block 形式で
|
||||
| `bindings.AGENT.codeFile` | `code` の代わりに、config のフォルダからの相対パス。ファイルの内容を `code` として使い、config を読むたびに読み込みます。パスはそのフォルダ内に限られます |
|
||||
| `bindings.AGENT.files` | 相対ファイル名を key とした任意の UTF-8 スクリプト。値は内容、または `codeFile` と同じ規則で読み込む `{from: path}` |
|
||||
|
||||
Agent ID は `claude`、`codex`、`gemini`、`copilot`、`cursor`、`droid`、`qwen`、`antigravity`、`pi`、`omp`、`amp`、`opencode`、`git`。`factory` は `droid` の、`antigravity-cli` と `agy` は `antigravity` の別名です。event、matcher、handler type、command、timeout 単位、payload はネイティブ形式のまま保持し、自動変換しません。event 名は各 command Agent のドキュメントにある event と照合します。未知の名前(例:綴り違いの `Stopp`)はプレビューと plan の `warnings` に警告として表示されますが、Agent は event を追加していくため同期は止めません。Pi、OMP、Amp、OpenCode のコードは確認しません。Pi、OMP、Amp、OpenCode のコードと imports はインストール済みバージョンに合わせ、専用の `skillshare-NAME.ts` に出力します。共通実行エンジンは生成しません。
|
||||
Agent ID は `claude`、`codex`、`gemini`、`copilot`、`cursor`、`droid`、`qwen`、`antigravity`、`pi`、`omp`、`amp`、`opencode`、`git`。`factory` は `droid` の、`antigravity-cli` と `agy` は `antigravity` の別名です。event、matcher、handler type、command、timeout 単位、payload はネイティブ形式のまま保持し、自動変換しません。event 名は各 command Agent のドキュメントにある event と照合します。未知の名前(例:綴り違いの `Stopp`)はプレビューと plan の `warnings` に警告として表示されますが、Agent は event を追加していくため同期は止めません。Pi、OMP、Amp、OpenCode のコードは確認しません。Pi、OMP、Amp、OpenCode のコードと imports はインストール済みバージョンに合わせ、専用の `skillshare-NAME.ts` ファイル(OpenCode v1)または OpenCode v2 のディレクトリパッケージに出力します。共通実行エンジンは生成しません。
|
||||
|
||||
長いコードやスクリプトは、`codeFile` または `files` の `{from: path}` で別ファイルから読み込めます。パスの基準は entry を持つ config のフォルダです(project では `.skillshare/`、global の `hooks.projects` では global config のフォルダ)。`hooks add|edit --file` でも entry ファイルの場所ではなく、選択した config が基準です。パスはそのフォルダ内に限られ、symlink を通過できません。ファイルがなければ config の読み込みは失敗します。config を読むたびに再読み込みし、プレビュー後に変更された場合は適用を拒否します。
|
||||
|
||||
@@ -140,7 +140,7 @@ command binding のスクリプトは Agent 設定ディレクトリの `hooks/s
|
||||
| [Pi](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/extensions.md) | `~/.pi/agent/extensions/skillshare-NAME.ts` | `.pi/extensions/skillshare-NAME.ts` | Native extension code |
|
||||
| [Oh My Pi](https://github.com/can1357/oh-my-pi/blob/v18.6.1/docs/extensions.md) | `~/.omp/agent/extensions/skillshare-NAME.ts` | `.omp/extensions/skillshare-NAME.ts` | Native OMP extension code |
|
||||
| [Amp](https://ampcode.com/docs/plugin-api) | `~/.config/amp/plugins/skillshare-NAME.ts` | `.amp/plugins/skillshare-NAME.ts` | Native plugin code |
|
||||
| [OpenCode](https://opencode.ai/docs/plugins/) | `~/.config/opencode/plugins/skillshare-NAME.ts` | `.opencode/plugins/skillshare-NAME.ts` | Supplied v1/v2 plugin code |
|
||||
| [OpenCode](https://opencode.ai/docs/plugins/) | `~/.config/opencode/plugins/skillshare-NAME[.ts]` | `.opencode/plugins/skillshare-NAME[.ts]` | v1 file; v2 directory package (see below) |
|
||||
|
||||
アカウント target の `config_dir` を指す場合を除き、global scope はネイティブ設定ディレクトリの環境変数 override を使います。project scope はプロジェクト内にのみ書き込み、global にフォールバックしません。Codex inline TOML など他のソースは別のままです。Antigravity とその CLI(`agy`)は同じ `hooks.json` を読みます。各 hook は名前付きの 1 ブロックで、インポートしても名前は変わりません。CLI の `~/.gemini/antigravity-cli/settings.json` にある hooks は別のままです。Droid の独立 hooks ファイルは読み込むソースを変えるため、既存 inline hooks を先に確認してください。 Copilot は `.github/hooks` のプロジェクト hooks を信頼済みフォルダーでのみ読み込みます。
|
||||
|
||||
@@ -237,3 +237,16 @@ global 設定の `hooks.projects` は絶対プロジェクトパスを同じ Ent
|
||||
バックアップは後から加わった無関係な変更を保持してネイティブ出力を復元し、ソース定義は変更しません。**Settings → Backups → Hooks** または `hooks restore` でプレビューして復元します。
|
||||
|
||||
**Synced** は Skillshare が設定を書いた状態です。Agent の手順に従って再起動/再読み込みしてください。信頼、hooks の有効化、コード互換性は Agent が制御します。管理時に hook command を実行したり、ネイティブ信頼を自動変更したりしません。
|
||||
|
||||
|
||||
### OpenCode v2 ディレクトリパッケージ
|
||||
|
||||
Windows のフック用バージョン検出は、`opencode-ai`(後期 v1)と `@opencode/cli`(v2)の標準 npm `.cmd` ラッパーから、インストール済みの `bin/opencode.exe` をシェルなしで直接実行します。初期 v1 の Node ランチャーや独自のバッチラッパーは推測・実行しません。その場合は OpenCode アカウントの `cli` にインストール済みネイティブ `opencode.exe` の絶対パス(例:対応する `opencode-windows-x64-baseline` パッケージの `bin/opencode.exe`)を設定するか、そのディレクトリを `PATH` の先頭に置いてください。postinstall スクリプトの実行や欠落したバイナリの修復は行いません。
|
||||
|
||||
Skillshare が実行するのは `opencode --version`(またはアカウントの `cli`)のみです。バイナリが見つからない、失敗する、またはメジャーバージョンが 1 でも 2 でもないなどでバージョンを検出できない場合、スキップされるのは OpenCode の binding だけです。プレビューに警告が表示され、既存の OpenCode の出力はそのまま残り、他の Agent は通常どおり同期されます。v1 は単一の `.ts` ファイルのままです。v2 は `plugins/skillshare-NAME/index.ts` と `package.json`(`@opencode/plugin: ^2.0.0` を宣言)を書き出し、そのディレクトリの `file://` URL を `opencode.json(c)` の `plugins` に追加します。プロジェクトの hook は `.opencode/opencode.json(c)` を使います。コメントと無関係な登録は変更しません。競合する JSON/JSONC ファイルや `OPENCODE_CONFIG`/`OPENCODE_CONFIG_CONTENT` の override は、hooks では拒否されます。`code` binding はどちらのバージョンでも指定どおりに書き出され、v1 と v2 のどちらのプラグイン API に合うかは確認しません。
|
||||
|
||||
完全な v2 パッケージには、`code`/`codeFile` の代わりに `bindings.opencode.package` を使います。`package.json` を含め、相対ファイル名を UTF-8 の内容に対応させたマップです。manifest と依存関係の要件はそのまま保持されます。ネストしたファイルは使えますが、パスの逸脱、シンボリックリンク、ファイルとディレクトリの衝突、`.git`、`node_modules` はパッケージの内容になりません。ネイティブエディタはこのファイルマップを JSON として表示します。server entry は、パッケージ名を持つ文字列の root または `./server` export、もしくはルートの `server`/`index` ファイル(`.ts`、`.tsx`、`.js`)である必要があります。条件付き・フォールバックの server export は推測せず拒否します。`package` binding には OpenCode v2 が必要で、v1 では警告を出してスキップされます。
|
||||
|
||||
`hooks import --from opencode` は、ネイティブの `plugins` フォルダ直下のパッケージディレクトリも読み込みます。単一ファイルのコードの import と同様に Skillshare の名前付き出力へコピーし、同期後に元のファイルと登録を削除して二重読み込みを避けるよう警告します。インストール済みの `node_modules` と `.git` は import しません。読み込めないファイル(シンボリックリンクなど)を含むパッケージは、その問題とともに一覧に表示され、他のパッケージや単一ファイルは引き続き import できます。OpenCode v1 では、`plugins` 配下のディレクトリは hook として一覧表示されません。同期、編集、削除は他の hook と同じ所有権チェックとバックアップを使い、外部で編集されたパッケージファイルは上書きされず競合になります。
|
||||
|
||||
宣言された依存関係は、読み込む前にご自身で用意してください。パッケージファイルを書き出すときは、プレビューにもその旨が表示されます。Skillshare はプラグインコードを実行せず、依存関係もインストールせず、v1 コードを v2 に変換することもありません。登録されていても、プラグインが読み込まれた証拠にはなりません。2 つの API が異なるため、ダッシュボードは OpenCode のスターターコードを意図的に提供しません。
|
||||
|
||||
@@ -251,13 +251,14 @@ Skillshare はパッケージを実行せずに読み取るため、このタブ
|
||||
|
||||
Pi に同期するプロジェクトにも、プロジェクトページに同じタブがあります。プロジェクトの設定をグローバルの設定に重ねた結果、各パッケージで何が選択されるかを示し、`pi (global)` から継承したものかプロジェクトの上書きかを表示します。スイッチはルールをプロジェクトの `.pi/settings.json` だけに保存し、`pi config` と同じ方法で書きます。グローバルのパッケージには、指定したファイルだけを変更するプロジェクトエントリ `{"source": ..., "autoload": false, "extensions": [...]}` が追加され、グローバルのエントリはそのままです。ローカルのソースは `.pi` からの相対パスで、npm や git のソースはグローバル設定の記述どおりに書かれます。そのようなエントリの最後のプロジェクトルールを削除した場合、以前の登録の filters が有効にならないときだけエントリを削除します。それ以外は空の winning override を保持します。明示的な JSON `false` だけが delta を意味し、`autoload: null` は `false` ではありません。対応するグローバルエントリがなく `autoload: false` のプロジェクトエントリは、`+` で指定したファイルだけを読み込みます。ファイルとその `.pi` フォルダは適用したときにだけ作成されます。グローバル設定と Pi の `trust.json` は書き込まれず、Skillshare が代わりにプロジェクトを信頼することもありません。Pi はプロジェクトを信頼している場合にだけプロジェクトの設定を使います。認証情報やクエリを含むグローバルのソースはプロジェクトにコピーされないため、そのパッケージはプロジェクトでは読み取り専用です。プロジェクトの設定に Skillshare が読み取れないエントリがある場合は、すべてのパッケージが読み取り専用になります。適用時は Pi のプロジェクトファイルのロックを保持し、書き込む直前に両方の設定ファイルとパッケージを再確認します。Pi 自身の `extensions` フォルダにある拡張機能([extras](./extras.md) がそこにリンクしたファイルを含む)は、変更する場所とともに読み取り専用で一覧表示されます。プロジェクトは自身のフォルダ(Pi はプロジェクトを信頼している場合にだけ読み込みます)とグローバルのフォルダを表示します。
|
||||
|
||||
OpenCode は、管理下エントリを `opencode.json` または既存の `opencode.jsonc` にファイル URL として登録し、コメントや無関係なエントリを保持します。version 1 は `plugin` を、version 2 は `plugins` を使用します。`XDG_CONFIG_HOME` と絶対パスの global `OPENCODE_CONFIG` は尊重されます。曖昧または非対応のオーバーライドは拒否されます。Skillshare が version のスキーマを選択できるよう、OpenCode は PATH 上にある必要があります。
|
||||
OpenCode v1 は管理下のエントリファイルを、v2 はパッケージディレクトリを `opencode.json` または既存の `opencode.jsonc` にファイル URL として登録し、コメントや無関係なエントリを保持します。version 1 は `plugin` を、version 2 は `plugins` を使用します。`XDG_CONFIG_HOME` と絶対パスの global `OPENCODE_CONFIG` は尊重されます。曖昧または非対応のオーバーライドは拒否されます。Skillshare が version のスキーマを選択できるよう、OpenCode は PATH 上にある必要があります。
|
||||
v2 のディレクトリパッケージのうち、[`hooks`](./hooks.md) が同じ `plugins` 配列に登録するもの(`plugins/skillshare-NAME`)は hooks の管理下にあり、`plugin list` と `plugin import` には表示されません。
|
||||
|
||||
ローカルの OpenCode source は、ビルド済みのエントリ(`main`、文字列のルート export、または `index.js`)と必要なランタイム依存関係をすでに含んでいる必要があります。Skillshare はビルドスクリプトを実行したり、source に依存関係をインストールしたりしません。登録はモジュールが正常にロードされたことの証明ではありません。再読み込み後に OpenCode を確認してください。
|
||||
ローカルの OpenCode v1 source にはビルド済みのエントリ(`main`、文字列のルート export、または `index.js`)が必要です。v2 はディレクトリローダーを使い、`name` と文字列のルートまたは `./server` export、あるいはルートの `server`/`index` ファイル(`.ts`、`.tsx`、`.js`)を必要とします。`--entry` は v2 のディレクトリ読み込みを変更しません。条件付き・フォールバックの server export は拒否します。`@opencode-ai/plugin` と `@opencode/plugin` のどちらも OpenCode パッケージの識別に使われます。manifest と依存関係の要件は変更しません。Skillshare はビルドスクリプトを実行したり、source に依存関係をインストールしたりしません。登録はモジュールが正常にロードされたことの証明ではありません。再読み込み後に OpenCode を確認してください。
|
||||
|
||||
ユーザースコープの npm 登録に managed cache がない場合は Unknown/読み取り専用です。未インストールとは限りません。Pi は Skillshare が調べない legacy global npm/pnpm パスを使うことがあります。
|
||||
|
||||
インポートは通常の Pi source に加え、Pi 0.99.2 以降の対応する source とオプション形式を持つ filtered object を受け付けます。プレビューは保持するキー名だけを表示し、opaque 値を表示しません。ネイティブ設定とファイルは変更せず、元のエントリを Skillshare の非公開 state に保存し、ローカル receipt に digest だけを記録します。sync/update は現在のエントリを保持します。アンインストール前に最新のオプションを保存し、再インストール時はネイティブ install の前に object を復元して、他のリソースが一時的に既定で有効になるのを防ぎます。同じ Apply で複数を復元するときは、その操作自身が書いた正確な内容だけを受け入れます。他の設定変更がある場合は後続の復元を止めます。非公開 state を保持してください。記録の欠落・変更や別 target の記録は復元を拒否します。Windows の新しい登録ディレクトリは owner/SYSTEM 用の保護された ACL で作成します。既存ディレクトリと記録は、現在のユーザーと特権を持つ SYSTEM/Administrators 以外にアクセスを許可している場合、または ACL を確認できない場合、インポート・復元を拒否します。既存 ACL は変更しません。記録を保持し、所有者がアクセス保護を修復してから再試行してください。不明な source・優先順位、非対応のエンコーディング、Pi が正規化するローカル参照は読み取り専用です。通常の OpenCode エントリは取り込めますが、filtered OpenCode は引き続き拒否します。10 秒の stale 閾値を超えた空のロックディレクトリは inode と mtime が変わっていない場合だけ回収します。新しい・更新された・置換されたロック、空でないディレクトリ、ファイル、symlink は保持します。古さは所有者の終了を証明せず、最終確認と削除は atomic CAS ではありません。インポートされた Pi の package は、global モードでは `pi update SOURCE` で更新され、設定エントリは保持されます。project のものは Pi で更新してください。`pi update` は global の package にも及ぶためです。インポートされた OpenCode v1 の package は、そのネイティブツール上で更新されます。OpenCode v2 の global インポートはネイティブの update コマンドを使用できますが、v2 の update コマンドは global 向けであるため、project のインポートはネイティブに更新する必要があります。
|
||||
インポートは通常の Pi source に加え、Pi 0.99.2 以降の対応する source とオプション形式を持つ filtered object を受け付けます。プレビューは保持するキー名だけを表示し、opaque 値を表示しません。ネイティブ設定とファイルは変更せず、元のエントリを Skillshare の非公開 state に保存し、ローカル receipt に digest だけを記録します。sync/update は現在のエントリを保持します。アンインストール前に最新のオプションを保存し、再インストール時はネイティブ install の前に object を復元して、他のリソースが一時的に既定で有効になるのを防ぎます。同じ Apply で複数を復元するときは、その操作自身が書いた正確な内容だけを受け入れます。他の設定変更がある場合は後続の復元を止めます。非公開 state を保持してください。記録の欠落・変更や別 target の記録は復元を拒否します。Windows の新しい登録ディレクトリは owner/SYSTEM 用の保護された ACL で作成します。既存ディレクトリと記録は、現在のユーザーと特権を持つ SYSTEM/Administrators 以外にアクセスを許可している場合、または ACL を確認できない場合、インポート・復元を拒否します。既存 ACL は変更しません。記録を保持し、所有者がアクセス保護を修復してから再試行してください。不明な source・優先順位、非対応のエンコーディング、Pi が正規化するローカル参照は読み取り専用です。通常の OpenCode エントリは取り込めますが、filtered OpenCode は引き続き拒否します。10 秒の stale 閾値を超えた空のロックディレクトリは inode と mtime が変わっていない場合だけ回収します。新しい・更新された・置換されたロック、空でないディレクトリ、ファイル、symlink は保持します。古さは所有者の終了を証明せず、最終確認と削除は atomic CAS ではありません。インポートされた Pi の package は、global モードでは `pi update SOURCE` で更新され、設定エントリは保持されます。project のものは Pi で更新してください。`pi update` は global の package にも及ぶためです。インポートされた OpenCode v1 の package は、そのネイティブツール上で更新されます。OpenCode v2 の global パッケージインポートはネイティブの update コマンドを使用できます。インポートしたローカルディレクトリは依存関係のインストーラーを実行せず、利用者が元の場所で更新します。v2 の update コマンドは global 向けであるため、project のインポートはネイティブに更新する必要があります。
|
||||
|
||||
```bash
|
||||
skillshare plugin add ./cursor-plugin --target cursor --no-tui
|
||||
@@ -356,3 +357,5 @@ skillshare plugin sync NAME --no-tui
|
||||
`unimport` には 1 つ以上の明示的な `--target` と、各ターゲットの既存のローカル import 記録および共有ソース設定が必要です。ターゲットの削除アダプターを使って、このマシンのインポート済みのインストールを解除してからローカル記録を削除します。共有宣言と他のマシンのインストールは変更しません。次の sync が共有ソースからインストールします。
|
||||
|
||||
アンインストールすると、そのインストールに関連するネイティブクライアントの設定やログイン情報も削除されます。
|
||||
|
||||
古い Skillshare の OpenCode v2 アダプターが残した単一ファイルの登録は、add/import/sync/update では拒否されます。古い管理下の binding を削除し、そのディレクトリパッケージを追加し直してください。削除は引き続き可能で、無関係なネイティブ登録には触れません。プレビュー後にランタイムのバージョンが変わった場合は、プレビューをやり直す必要があります。
|
||||
|
||||
@@ -91,7 +91,7 @@ Skillshare는 `hooks` 섹션을 들여쓴 block 형식으로 쓰며, 저장할
|
||||
| `bindings.AGENT.codeFile` | `code` 대신 config 폴더 기준 상대 경로. 파일 내용을 `code`로 사용하며 config를 읽을 때마다 다시 읽습니다. 경로는 그 폴더 안이어야 합니다 |
|
||||
| `bindings.AGENT.files` | 상대 파일명을 key로 하는 선택 UTF-8 스크립트. 값은 내용 또는 `codeFile`과 같은 규칙으로 읽는 `{from: path}` |
|
||||
|
||||
Agent ID는 `claude`, `codex`, `gemini`, `copilot`, `cursor`, `droid`, `qwen`, `antigravity`, `pi`, `omp`, `amp`, `opencode`, `git`입니다. `factory`는 `droid`, `antigravity-cli`와 `agy`는 `antigravity`의 별칭입니다. event, matcher, handler type, command, timeout 단위와 payload는 원래 형식을 유지하고 자동 변환하지 않습니다. event 이름은 각 command Agent 문서의 event와 대조합니다. 알 수 없는 이름(예: 철자가 틀린 `Stopp`)은 미리보기와 plan의 `warnings`에 경고로 표시되지만, Agent가 event를 계속 추가하므로 동기화를 막지 않습니다. Pi, OMP, Amp, OpenCode 코드는 확인하지 않습니다. Pi, OMP, Amp, OpenCode의 코드와 imports는 설치된 버전에 맞춰 제공하며 전용 `skillshare-NAME.ts`에 기록됩니다. 공통 실행 엔진을 생성하지 않습니다. command binding 스크립트는 Agent 설정 디렉터리의 `hooks/skillshare/NAME/`에 저장하며 command의 macro/명시 경로를 변경하지 않습니다. 미리보기에서 전체 경로를 확인하세요. global binding에는 `targets` 아래 선언한 계정 target 이름도 사용할 수 있습니다.
|
||||
Agent ID는 `claude`, `codex`, `gemini`, `copilot`, `cursor`, `droid`, `qwen`, `antigravity`, `pi`, `omp`, `amp`, `opencode`, `git`입니다. `factory`는 `droid`, `antigravity-cli`와 `agy`는 `antigravity`의 별칭입니다. event, matcher, handler type, command, timeout 단위와 payload는 원래 형식을 유지하고 자동 변환하지 않습니다. event 이름은 각 command Agent 문서의 event와 대조합니다. 알 수 없는 이름(예: 철자가 틀린 `Stopp`)은 미리보기와 plan의 `warnings`에 경고로 표시되지만, Agent가 event를 계속 추가하므로 동기화를 막지 않습니다. Pi, OMP, Amp, OpenCode 코드는 확인하지 않습니다. Pi, OMP, Amp, OpenCode의 코드와 imports는 설치된 버전에 맞춰 제공하며 전용 `skillshare-NAME.ts` 파일(OpenCode v1) 또는 OpenCode v2 디렉터리 패키지에 기록됩니다. 공통 실행 엔진을 생성하지 않습니다. command binding 스크립트는 Agent 설정 디렉터리의 `hooks/skillshare/NAME/`에 저장하며 command의 macro/명시 경로를 변경하지 않습니다. 미리보기에서 전체 경로를 확인하세요. global binding에는 `targets` 아래 선언한 계정 target 이름도 사용할 수 있습니다.
|
||||
|
||||
긴 코드나 스크립트는 `codeFile` 또는 `files`의 `{from: path}`로 별도 파일에서 읽을 수 있습니다. 경로는 entry를 가진 config 폴더 기준입니다(project에서는 `.skillshare/`, global의 `hooks.projects`에서는 global config 폴더). `hooks add|edit --file`도 entry 파일 위치가 아닌 선택한 config가 기준입니다. 경로는 그 폴더 안에 있어야 하며 symlink를 거칠 수 없습니다. 파일이 없으면 config를 읽지 못합니다. config를 읽을 때마다 다시 읽으며 미리보기 후 바뀌면 적용을 거부합니다.
|
||||
|
||||
@@ -136,7 +136,7 @@ Pi와 OMP는 모두 `PI_CODING_AGENT_DIR`을 따릅니다. binding이 같은 출
|
||||
| [Pi](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/extensions.md) | `~/.pi/agent/extensions/skillshare-NAME.ts` | `.pi/extensions/skillshare-NAME.ts` | Native extension code |
|
||||
| [Oh My Pi](https://github.com/can1357/oh-my-pi/blob/v18.6.1/docs/extensions.md) | `~/.omp/agent/extensions/skillshare-NAME.ts` | `.omp/extensions/skillshare-NAME.ts` | Native OMP extension code |
|
||||
| [Amp](https://ampcode.com/docs/plugin-api) | `~/.config/amp/plugins/skillshare-NAME.ts` | `.amp/plugins/skillshare-NAME.ts` | Native plugin code |
|
||||
| [OpenCode](https://opencode.ai/docs/plugins/) | `~/.config/opencode/plugins/skillshare-NAME.ts` | `.opencode/plugins/skillshare-NAME.ts` | Supplied v1/v2 plugin code |
|
||||
| [OpenCode](https://opencode.ai/docs/plugins/) | `~/.config/opencode/plugins/skillshare-NAME[.ts]` | `.opencode/plugins/skillshare-NAME[.ts]` | v1 file; v2 directory package (see below) |
|
||||
|
||||
계정 target의 `config_dir`을 가리키는 경우를 제외하고 global scope는 네이티브 설정 디렉터리 환경 변수 override를 사용합니다. project scope는 프로젝트에만 쓰며 global 경로로 대체하지 않습니다. Codex inline TOML 같은 다른 소스는 별도로 유지됩니다. Antigravity와 CLI(`agy`)는 같은 `hooks.json`을 읽습니다. 각 hook은 이름이 붙은 블록 하나이며 가져와도 이름이 유지됩니다. CLI의 `~/.gemini/antigravity-cli/settings.json`에 있는 hooks는 별도로 유지됩니다. Droid의 독립 hooks 파일은 로딩 소스를 바꿀 수 있으므로 기존 inline hooks를 먼저 확인하세요. Copilot은 신뢰된 폴더에서만 `.github/hooks`의 프로젝트 hooks를 불러옵니다.
|
||||
|
||||
@@ -233,3 +233,16 @@ global 설정의 `hooks.projects`는 절대 프로젝트 경로를 같은 Entry
|
||||
백업은 이후의 관련 없는 변경을 유지하며 네이티브 출력을 복원하고 소스 정의는 바꾸지 않습니다. **Settings → Backups → Hooks** 또는 `hooks restore`로 미리 보고 복원하세요.
|
||||
|
||||
**Synced**는 Skillshare가 설정을 기록했다는 뜻입니다. Agent 절차에 따라 다시 시작/로딩하세요. 신뢰, hooks 활성화와 코드 호환성은 Agent가 제어합니다. 관리 작업은 hook command를 실행하거나 네이티브 신뢰를 자동 변경하지 않습니다.
|
||||
|
||||
|
||||
### OpenCode v2 디렉터리 패키지
|
||||
|
||||
Windows의 훅 버전 확인은 `opencode-ai`(후기 v1)와 `@opencode/cli`(v2)의 표준 npm `.cmd` 래퍼에서 설치된 `bin/opencode.exe`를 셸 없이 직접 실행합니다. 초기 v1의 Node 실행기나 사용자 지정 배치 래퍼는 추측하거나 실행하지 않습니다. 이 경우 OpenCode 계정의 `cli`를 설치된 네이티브 `opencode.exe`의 절대 경로(예: 해당 `opencode-windows-x64-baseline` 패키지의 `bin/opencode.exe`)로 설정하거나 해당 디렉터리를 `PATH` 맨 앞에 두세요. postinstall 스크립트를 실행하거나 누락된 바이너리를 복구하지 않습니다.
|
||||
|
||||
Skillshare는 `opencode --version`(또는 계정의 `cli`)만 실행합니다. 바이너리가 없거나 실패하거나 주 버전이 1 또는 2가 아니어서 버전을 감지할 수 없으면 OpenCode binding만 건너뜁니다. 미리보기에 경고가 표시되고 기존 OpenCode 출력은 그대로 유지되며 다른 모든 Agent는 정상적으로 동기화됩니다. v1은 단일 `.ts` 파일을 유지합니다. v2는 `plugins/skillshare-NAME/index.ts`와 `package.json`(`@opencode/plugin: ^2.0.0` 선언)을 쓰고, 해당 디렉터리의 `file://` URL을 `opencode.json(c)`의 `plugins`에 추가합니다. 프로젝트 hook은 `.opencode/opencode.json(c)`를 사용합니다. 주석과 관련 없는 등록은 변경되지 않습니다. 충돌하는 JSON/JSONC 파일이나 `OPENCODE_CONFIG`/`OPENCODE_CONFIG_CONTENT` override는 hooks에서 거부됩니다. `code` binding은 두 버전 모두에서 지정한 그대로 기록되며, Skillshare는 이것이 v1 또는 v2 플러그인 API에 맞는지 확인하지 않습니다.
|
||||
|
||||
완전한 v2 패키지에는 `code`/`codeFile` 대신 `bindings.opencode.package`를 사용합니다. `package.json`을 포함해 상대 파일명을 UTF-8 내용에 대응시킨 맵입니다. manifest와 의존성 요구 사항은 그대로 보존됩니다. 중첩된 파일은 허용되지만 경로 이탈, 심볼릭 링크, 파일/디렉터리 충돌, `.git`, `node_modules`는 패키지 내용이 될 수 없습니다. 네이티브 편집기는 이 파일 맵을 JSON으로 표시합니다. server entry는 패키지 이름이 있는 문자열 root 또는 `./server` export이거나, 관례적인 루트 `server`/`index` 파일(`.ts`, `.tsx`, `.js`)이어야 합니다. 조건부 및 폴백 server export는 추측하지 않고 거부합니다. `package` binding에는 OpenCode v2가 필요하며, v1에서는 경고와 함께 건너뜁니다.
|
||||
|
||||
`hooks import --from opencode`는 네이티브 `plugins` 폴더 바로 아래의 패키지 디렉터리도 읽습니다. 단일 파일 코드 import와 마찬가지로 Skillshare의 이름이 지정된 출력으로 복사하고, 동기화 후 중복 로드를 피하려면 원본 파일과 등록을 제거하라고 경고합니다. 설치된 `node_modules`와 `.git`은 가져오지 않습니다. 읽을 수 없는 파일(예: 심볼릭 링크)이 있는 패키지는 해당 문제와 함께 표시되며, 다른 패키지와 단일 파일은 계속 가져올 수 있습니다. OpenCode v1에서는 `plugins` 아래의 디렉터리가 hook으로 나열되지 않습니다. 동기화, 편집, 제거는 다른 hook과 같은 소유권 검사와 백업을 사용하며, 외부에서 편집된 패키지 파일은 덮어쓰지 않고 충돌로 처리됩니다.
|
||||
|
||||
선언된 의존성은 로드하기 전에 직접 준비하세요. 패키지 파일을 쓸 때마다 미리보기에 이 안내가 표시됩니다. Skillshare는 플러그인 코드를 실행하지 않고, 의존성을 설치하지 않으며, v1 코드를 v2로 변환하지 않습니다. 등록되었다고 해서 플러그인이 로드되었다는 증거는 아닙니다. 두 API가 다르기 때문에 대시보드는 OpenCode 시작 코드를 의도적으로 제공하지 않습니다.
|
||||
|
||||
@@ -177,13 +177,13 @@ Skillshare는 패키지를 실행하지 않고 읽기 때문에, 이 탭은 설
|
||||
|
||||
Pi로 동기화하는 프로젝트도 프로젝트 페이지에 같은 탭이 있습니다. 프로젝트 설정을 전역 설정 위에 적용했을 때 각 패키지가 무엇을 선택하는지 보여 주며, `pi (global)`에서 상속한 것인지 프로젝트 재정의인지 표시합니다. 스위치는 규칙을 프로젝트의 `.pi/settings.json`에만 저장하며, `pi config`와 같은 방식으로 씁니다. 전역 패키지에는 지정한 파일만 바꾸는 프로젝트 항목 `{"source": ..., "autoload": false, "extensions": [...]}`이 추가되고 전역 항목은 그대로 유지됩니다. 로컬 소스는 `.pi` 기준 상대 경로로, npm 또는 git 소스는 전역 설정에 적힌 그대로 씁니다. 이런 항목의 마지막 프로젝트 규칙을 제거하면 이전 등록의 filters가 활성화되지 않을 때만 항목을 제거하고, 그렇지 않으면 빈 winning override를 유지합니다. 명시적인 JSON `false`만 delta이며 `autoload: null`은 `false`가 아닙니다. 대응하는 전역 항목이 없고 `autoload: false`인 프로젝트 항목은 `+`로 지정한 파일만 로드합니다. 파일과 그 `.pi` 폴더는 적용할 때만 만들어집니다. 전역 설정과 Pi의 `trust.json`은 절대 쓰지 않으며, Skillshare가 대신 프로젝트를 신뢰하지도 않습니다. Pi는 프로젝트를 신뢰할 때만 프로젝트 설정을 사용합니다. 자격 증명이나 쿼리가 있는 전역 소스는 프로젝트에 복사하지 않으므로 그 패키지는 프로젝트에서 읽기 전용이며, 프로젝트 설정에 Skillshare가 읽을 수 없는 항목이 있으면 모든 패키지가 읽기 전용입니다. 적용 중에는 프로젝트 파일에 대한 Pi의 잠금을 유지하고, 쓰기 직전에 두 설정 파일과 패키지를 다시 확인합니다. Pi 자체의 `extensions` 폴더에 있는 extension([extras](./extras.md)가 그곳에 연결한 파일 포함)은 변경할 위치와 함께 읽기 전용으로 표시됩니다. 프로젝트는 자체 폴더(Pi는 프로젝트를 신뢰할 때만 읽음)와 전역 폴더를 표시합니다.
|
||||
|
||||
OpenCode는 관리되는 entry를 `opencode.json` 또는 기존의 `opencode.jsonc`에 file URL로 등록하며, 주석과 관련 없는 항목은 유지합니다. Version 1은 `plugin`을 사용하고, version 2는 `plugins`를 사용합니다. `XDG_CONFIG_HOME`과 절대 경로의 global `OPENCODE_CONFIG`를 준수합니다. 모호하거나 지원되지 않는 override는 거부됩니다. Skillshare가 버전의 스키마를 선택할 수 있도록 OpenCode는 PATH에 있어야 합니다.
|
||||
OpenCode v1은 관리되는 entry 파일을, v2는 패키지 디렉터리를 `opencode.json` 또는 기존의 `opencode.jsonc`에 file URL로 등록하며, 주석과 관련 없는 항목은 유지합니다. Version 1은 `plugin`을 사용하고, version 2는 `plugins`를 사용합니다. `XDG_CONFIG_HOME`과 절대 경로의 global `OPENCODE_CONFIG`를 준수합니다. 모호하거나 지원되지 않는 override는 거부됩니다. Skillshare가 버전의 스키마를 선택할 수 있도록 OpenCode는 PATH에 있어야 합니다. [`hooks`](./hooks.md)가 같은 `plugins` 배열에 등록하는 v2 디렉터리 패키지(`plugins/skillshare-NAME`)는 hooks에 속하며, `plugin list`와 `plugin import`에는 표시되지 않습니다.
|
||||
|
||||
로컬 OpenCode source는 빌드된 entry(`main`, 문자열 root export, 또는 `index.js`)와 필요한 런타임 의존성을 이미 포함하고 있어야 합니다. Skillshare는 빌드 스크립트를 실행하거나 source에 의존성을 설치하지 않습니다. 등록되었다고 해서 모듈이 성공적으로 로드되었다는 증거는 아닙니다. 다시 로드한 후 OpenCode를 확인하세요.
|
||||
로컬 OpenCode v1 source에는 빌드된 entry(`main`, 문자열 root export, 또는 `index.js`)가 필요합니다. v2는 디렉터리 로더를 사용하며, `name`과 문자열 root 또는 `./server` export, 또는 루트의 `server`/`index` 파일(`.ts`, `.tsx`, `.js`)이 필요합니다. `--entry`는 v2 디렉터리 로딩을 변경하지 않습니다. 조건부·폴백 server export는 거부합니다. `@opencode-ai/plugin`과 `@opencode/plugin` 모두 OpenCode 패키지를 식별합니다. manifest와 의존성 요구사항은 변경하지 않습니다. Skillshare는 빌드 스크립트를 실행하거나 source에 의존성을 설치하지 않습니다. 등록되었다고 해서 모듈이 성공적으로 로드되었다는 증거는 아닙니다. 다시 로드한 후 OpenCode를 확인하세요.
|
||||
|
||||
사용자 범위 npm 등록에 managed cache가 없으면 Unknown/읽기 전용으로 표시합니다. 미설치라는 뜻은 아닙니다. Pi가 Skillshare에서 조회하지 않는 legacy global npm/pnpm 경로를 사용할 수 있습니다.
|
||||
|
||||
Import는 일반 Pi source와 Pi 0.99.2 이상에서 지원되는 source 및 옵션 형식의 filtered object를 받아들입니다. 미리보기에는 보존할 키 이름만 표시하며 opaque 값은 표시하지 않습니다. 네이티브 설정과 설치 파일은 변경하지 않고, 원본 entry는 Skillshare의 비공개 state에 저장하며 로컬 receipt에 digest만 기록합니다. sync/update는 현재 entry를 유지합니다. 제거 전에 최신 옵션을 저장하고 재설치 시 네이티브 install 전에 object를 복원하여 다른 리소스가 일시적으로 기본 활성화되는 것을 방지합니다. 같은 Apply에서 여러 항목을 복원할 때는 해당 작업이 직접 쓴 정확한 내용만 허용합니다. 다른 설정 변경이 있으면 이후 복원을 중단합니다. 비공개 state를 보관하세요. 기록이 없거나 변경되었거나 다른 target 소유이면 복원을 거부합니다. Windows의 새 등록 디렉터리는 owner/SYSTEM용 보호 ACL로 생성합니다. 기존 디렉터리와 기록이 현재 사용자와 특권 SYSTEM/Administrators 이외에 접근을 허용하거나 ACL을 검증할 수 없으면 가져오기·복원을 거부합니다. 기존 ACL은 변경하지 않습니다. 기록을 보관하고 소유자가 접근 보호를 복구한 뒤 다시 시도하세요. 불확실한 source·우선순위, 미지원 인코딩, Pi가 정규화할 로컬 참조는 읽기 전용입니다. 일반 OpenCode entry는 가져올 수 있지만 filtered OpenCode는 계속 거부됩니다. 10초 stale 기준을 넘긴 빈 lock 디렉터리는 inode와 mtime이 바뀌지 않은 경우에만 회수합니다. 새 lock, 갱신·교체된 lock, 비어 있지 않은 디렉터리, 파일, symlink는 유지합니다. 오래되었다고 소유자가 종료된 것은 아니며 마지막 확인과 제거는 atomic CAS가 아닙니다. import된 Pi 패키지는 global 모드에서 `pi update SOURCE`로 업데이트되며 설정 entry는 유지됩니다. project의 패키지는 Pi에서 업데이트하세요. `pi update`는 global 패키지에도 영향을 주기 때문입니다. import된 OpenCode v1 패키지는 해당 네이티브 도구에서 업데이트됩니다. OpenCode v2의 global import는 자체 네이티브 업데이트 명령을 사용할 수 있지만, v2 업데이트 명령이 global이기 때문에 project import는 네이티브로 업데이트해야 합니다.
|
||||
Import는 일반 Pi source와 Pi 0.99.2 이상에서 지원되는 source 및 옵션 형식의 filtered object를 받아들입니다. 미리보기에는 보존할 키 이름만 표시하며 opaque 값은 표시하지 않습니다. 네이티브 설정과 설치 파일은 변경하지 않고, 원본 entry는 Skillshare의 비공개 state에 저장하며 로컬 receipt에 digest만 기록합니다. sync/update는 현재 entry를 유지합니다. 제거 전에 최신 옵션을 저장하고 재설치 시 네이티브 install 전에 object를 복원하여 다른 리소스가 일시적으로 기본 활성화되는 것을 방지합니다. 같은 Apply에서 여러 항목을 복원할 때는 해당 작업이 직접 쓴 정확한 내용만 허용합니다. 다른 설정 변경이 있으면 이후 복원을 중단합니다. 비공개 state를 보관하세요. 기록이 없거나 변경되었거나 다른 target 소유이면 복원을 거부합니다. Windows의 새 등록 디렉터리는 owner/SYSTEM용 보호 ACL로 생성합니다. 기존 디렉터리와 기록이 현재 사용자와 특권 SYSTEM/Administrators 이외에 접근을 허용하거나 ACL을 검증할 수 없으면 가져오기·복원을 거부합니다. 기존 ACL은 변경하지 않습니다. 기록을 보관하고 소유자가 접근 보호를 복구한 뒤 다시 시도하세요. 불확실한 source·우선순위, 미지원 인코딩, Pi가 정규화할 로컬 참조는 읽기 전용입니다. 일반 OpenCode entry는 가져올 수 있지만 filtered OpenCode는 계속 거부됩니다. 10초 stale 기준을 넘긴 빈 lock 디렉터리는 inode와 mtime이 바뀌지 않은 경우에만 회수합니다. 새 lock, 갱신·교체된 lock, 비어 있지 않은 디렉터리, 파일, symlink는 유지합니다. 오래되었다고 소유자가 종료된 것은 아니며 마지막 확인과 제거는 atomic CAS가 아닙니다. import된 Pi 패키지는 global 모드에서 `pi update SOURCE`로 업데이트되며 설정 entry는 유지됩니다. project의 패키지는 Pi에서 업데이트하세요. `pi update`는 global 패키지에도 영향을 주기 때문입니다. import된 OpenCode v1 패키지는 해당 네이티브 도구에서 업데이트됩니다. OpenCode v2의 global 패키지 import는 네이티브 업데이트 명령을 사용할 수 있습니다. import된 로컬 디렉터리는 의존성 설치 프로그램을 실행하지 않고 사용자가 원본에서 업데이트해야 합니다. v2 업데이트 명령이 global이기 때문에 project import는 네이티브로 업데이트해야 합니다.
|
||||
|
||||
```bash
|
||||
skillshare plugin add ./cursor-plugin --target cursor --no-tui
|
||||
@@ -282,3 +282,5 @@ skillshare plugin sync NAME --no-tui
|
||||
`unimport`에는 하나 이상의 명시적인 `--target`이 필요하며, 선택한 각 대상에 기존 로컬 가져오기 기록과 공유 소스 설정이 있어야 합니다. 대상의 제거 어댑터를 사용해 이 기기에서 가져온 설치를 제거한 다음 로컬 기록을 삭제합니다. 공유 선언과 다른 기기의 설치는 그대로 유지됩니다. 다음 sync는 공유 소스에서 설치합니다.
|
||||
|
||||
제거하면 해당 설치와 연결된 네이티브 클라이언트 설정이나 로그인 정보도 삭제됩니다.
|
||||
|
||||
이전 Skillshare OpenCode v2 어댑터가 남긴 단일 파일 등록은 add/import/sync/update에서 거부됩니다. 이전의 관리되는 binding을 제거하고 해당 디렉터리 패키지를 다시 추가하세요. 제거는 계속 가능하며 관련 없는 네이티브 등록은 건드리지 않습니다. 미리보기 후 런타임 버전이 바뀌면 새 미리보기가 필요합니다.
|
||||
|
||||
+15
-2
@@ -91,7 +91,7 @@ Skillshare 以缩进的 block 格式写入 `hooks` 区段;每次保存也会
|
||||
| `bindings.AGENT.codeFile` | 代替 `code`:相对于 config 所在文件夹的路径,文件内容作为 `code` 使用,每次读取 config 时重新读取;路径必须位于该文件夹内 |
|
||||
| `bindings.AGENT.files` | 可选 UTF-8 脚本文件,以相对文件名为 key;值为文件内容,或按 `codeFile` 相同规则读取的 `{from: path}` |
|
||||
|
||||
Agent ID 为 `claude`、`codex`、`gemini`、`copilot`、`cursor`、`droid`、`qwen`、`antigravity`、`pi`、`omp`、`amp`、`opencode`、`git`;`factory` 是 `droid` 的别名,`antigravity-cli` 和 `agy` 是 `antigravity` 的别名。event、matcher、handler type、command、timeout 单位和 payload 均保留原生格式,不自动跨 Agent 转换。event 名称会对照各 command Agent 文档列出的事件检查:未知名称(例如拼错的 `Stopp`)在预览和 plan 的 `warnings` 中显示警告,但不阻止同步,因为 Agent 会陆续新增事件。Pi、OMP、Amp、OpenCode 的代码不检查。Pi、OMP、Amp、OpenCode 的代码及 imports 须匹配已安装版本,发布为独立的 `skillshare-NAME.ts`,不生成共享执行引擎。
|
||||
Agent ID 为 `claude`、`codex`、`gemini`、`copilot`、`cursor`、`droid`、`qwen`、`antigravity`、`pi`、`omp`、`amp`、`opencode`、`git`;`factory` 是 `droid` 的别名,`antigravity-cli` 和 `agy` 是 `antigravity` 的别名。event、matcher、handler type、command、timeout 单位和 payload 均保留原生格式,不自动跨 Agent 转换。event 名称会对照各 command Agent 文档列出的事件检查:未知名称(例如拼错的 `Stopp`)在预览和 plan 的 `warnings` 中显示警告,但不阻止同步,因为 Agent 会陆续新增事件。Pi、OMP、Amp、OpenCode 的代码不检查。Pi、OMP、Amp、OpenCode 的代码及 imports 须匹配已安装版本,发布为独立的 `skillshare-NAME.ts` 文件(OpenCode v1)或 OpenCode v2 目录包,不生成共享执行引擎。
|
||||
|
||||
较长的代码和脚本可以用 `codeFile` 或 `files` 的 `{from: path}` 从独立文件读取。路径以持有该 entry 的 config 所在文件夹为准(项目是 `.skillshare/`,global 的 `hooks.projects` 则是 global config 文件夹);`hooks add|edit --file` 也以选定的 config 为准,而不是 entry 文件所在位置。路径必须位于该文件夹内,不能经过 symlink;文件缺失会使 config 读取失败。每次读取 config 都会重新读取文件,预览后内容有变化就会拒绝应用。
|
||||
|
||||
@@ -138,7 +138,7 @@ command binding 的脚本位于 Agent 配置目录的 `hooks/skillshare/NAME/`
|
||||
| [Pi](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/extensions.md) | `~/.pi/agent/extensions/skillshare-NAME.ts` | `.pi/extensions/skillshare-NAME.ts` | Native extension code |
|
||||
| [Oh My Pi](https://github.com/can1357/oh-my-pi/blob/v18.6.1/docs/extensions.md) | `~/.omp/agent/extensions/skillshare-NAME.ts` | `.omp/extensions/skillshare-NAME.ts` | Native OMP extension code |
|
||||
| [Amp](https://ampcode.com/docs/plugin-api) | `~/.config/amp/plugins/skillshare-NAME.ts` | `.amp/plugins/skillshare-NAME.ts` | Native plugin code |
|
||||
| [OpenCode](https://opencode.ai/docs/plugins/) | `~/.config/opencode/plugins/skillshare-NAME.ts` | `.opencode/plugins/skillshare-NAME.ts` | Supplied v1/v2 plugin code |
|
||||
| [OpenCode](https://opencode.ai/docs/plugins/) | `~/.config/opencode/plugins/skillshare-NAME[.ts]` | `.opencode/plugins/skillshare-NAME[.ts]` | v1 file; v2 directory package (see below) |
|
||||
|
||||
global scope 使用原生配置目录的环境变量 override,但指向账号 `config_dir` 时除外;project scope 只写入项目,不回退到 global。Codex inline TOML 等其他来源仍独立存在。Antigravity 及其 CLI(`agy`)读取同一份 `hooks.json`;每个 hook 是一个以其名称命名的 block,导入时保留原名。CLI 的 `~/.gemini/antigravity-cli/settings.json` 中的 hooks 保持独立。Droid 发布独立 hooks 文件会影响原生加载来源,请先检查已有 inline hooks。Copilot 只在受信任的文件夹中加载 `.github/hooks` 的项目 hooks。
|
||||
|
||||
@@ -229,3 +229,16 @@ global 配置的 `hooks.projects` 将绝对项目路径映射到相同 Entry 格
|
||||
备份恢复原生输出并保留后续无关改动,不改写来源定义。使用“设置 → 备份 → Hooks”或 `hooks restore` 先预览再恢复。
|
||||
|
||||
**已同步**只表示 Skillshare 已写入配置。请按 Agent 原生流程重启/重新加载;信任、启用 hooks 和代码兼容性由 Agent 控制。管理操作不执行 hook command,也不自动改变原生信任。
|
||||
|
||||
|
||||
### OpenCode v2 目录包
|
||||
|
||||
Windows 上的 hook 版本探测会将 `opencode-ai`(较新 v1)和 `@opencode/cli`(v2)的标准 npm `.cmd` 启动器直接解析为已安装的 `bin/opencode.exe`,不使用 shell。不会推测或执行早期 v1 的 Node 启动器或自定义批处理包装器。此类安装请将 OpenCode 账户的 `cli` 设为已安装的原生 `opencode.exe` 的绝对路径(例如匹配的 `opencode-windows-x64-baseline` 包内的 `bin/opencode.exe`),或将其目录放在 `PATH` 最前面。Skillshare 不运行 postinstall 脚本,也不修复缺失的二进制文件。
|
||||
|
||||
Skillshare 只探测 `opencode --version`(或账户的 `cli`)。当无法检测到版本时(二进制文件缺失、执行失败,或报告的主版本不是 1 或 2),只会跳过 OpenCode 的 binding:预览会显示警告,现有的 OpenCode 输出保持不变,其他所有 Agent 照常同步。v1 保留扁平的 `.ts` 文件。v2 写入 `plugins/skillshare-NAME/index.ts` 和 `package.json`(声明 `@opencode/plugin: ^2.0.0`),并将该目录的 `file://` URL 添加到 `opencode.json(c)` 的 `plugins` 中。项目 hook 使用 `.opencode/opencode.json(c)`。注释和无关的注册保持不变。存在冲突的 JSON/JSONC 文件,或 `OPENCODE_CONFIG`/`OPENCODE_CONFIG_CONTENT` 覆盖,会被 hooks 拒绝。`code` binding 在两个版本上都按给定内容写入;Skillshare 不检查它是否符合 v1 或 v2 的插件 API。
|
||||
|
||||
完整的 v2 包请使用 `bindings.opencode.package` 代替 `code`/`codeFile`:这是一个从相对文件名到 UTF-8 内容的映射,其中包含 `package.json`。manifest 及其依赖要求会原样保留。允许嵌套文件;路径越界、符号链接、文件与目录冲突、`.git` 和 `node_modules` 都不属于包的内容。原生编辑器将此文件映射显示为 JSON。server 入口必须是带有包名的字符串形式根导出或 `./server` 导出,或是约定的根目录 `server`/`index` 文件(`.ts`、`.tsx`、`.js`)。条件式和回退式 server 导出会被拒绝,而不是猜测。`package` binding 需要 OpenCode v2;在 v1 上会被跳过并给出警告。
|
||||
|
||||
`hooks import --from opencode` 还会读取原生 `plugins` 文件夹下的直接子包目录。与扁平代码导入一样,它会将其复制到 Skillshare 的命名输出,并警告你在同步后移除原始文件和注册,以避免重复加载。已安装的 `node_modules` 和 `.git` 不会导入。包含无法读取的文件(例如符号链接)的包会连同该问题一起列出;其他包和扁平文件仍可导入。在 OpenCode v1 上,`plugins` 下的目录不会作为 hook 列出。同步、编辑和移除使用与其他 hook 相同的所有权检查和备份;被外部编辑的包文件会产生冲突,而不是被覆盖。
|
||||
|
||||
请在加载前自行准备声明的依赖;只要预览会写入包文件,就会提示这一点。Skillshare 从不运行插件代码、安装依赖或将 v1 代码转换为 v2。注册并不能证明插件已加载。由于两种 API 不同,仪表板有意不提供 OpenCode 入门代码。
|
||||
|
||||
+6
-4
@@ -248,19 +248,19 @@ Skillshare 读取包时不会运行它们,因此这个标签页显示的是设
|
||||
|
||||
同步到 Pi 的项目在项目页面上也有这个标签页。它显示项目设置叠加在全局设置之上后,每个包选中的内容,并标明是继承自 `pi (global)` 还是项目覆盖。开关只会把规则保存到项目的 `.pi/settings.json`,做法与 `pi config` 相同:全局包会得到一个项目条目 `{"source": ..., "autoload": false, "extensions": [...]}`,只改变它指明的文件,全局条目保持不变。本地来源会写成相对于 `.pi` 的路径,npm 或 git 来源则按全局设置的写法。移除这类条目的最后一条项目规则时,只有不会让更早注册的 filters 生效才移除该条目;否则保留空的 winning override。只有明确的 JSON `false` 才表示 delta,`autoload: null` 不是 `false`。没有对应全局条目、且 `autoload: false` 的项目条目只会加载它用 `+` 指明的文件。文件及其 `.pi` 文件夹只会在应用时创建。全局设置和 Pi 的 `trust.json` 永远不会被写入,Skillshare 也不会替你信任项目:Pi 只有在信任项目时才会使用项目设置。含有凭据或查询字符串的全局来源不会被复制到项目中,所以该包在项目中是只读的;项目设置中有 Skillshare 无法读取的条目时,所有包都是只读的。应用时会持有 Pi 对项目文件的锁,并在写入前再次检查两个设置文件和包。Pi 自己的 `extensions` 文件夹中的 extension(包括 [extras](./extras.md) 链接到那里的文件)以只读方式列出,并说明在哪里修改;项目会列出自己的文件夹(Pi 只有在信任项目时才会读取)和全局文件夹。
|
||||
|
||||
OpenCode 会在 `opencode.json` 或已存在的 `opencode.jsonc` 中将受管理的 entry 注册为文件 URL,
|
||||
OpenCode v1 将受管理的 entry 文件、v2 将 package 目录作为文件 URL 注册到 `opencode.json` 或已存在的 `opencode.jsonc` 中,
|
||||
并保留注释和无关的条目。Version 1 使用 `plugin`;version 2 使用 `plugins`。`XDG_CONFIG_HOME`
|
||||
和绝对路径的全局 `OPENCODE_CONFIG` 会被遵循;含糊或不受支持的覆盖会被拒绝。
|
||||
OpenCode 必须在 PATH 上,以便 Skillshare 能够选择对应版本的 schema。
|
||||
[`hooks`](./hooks.md) 在同一 `plugins` 数组中注册的 v2 目录包(`plugins/skillshare-NAME`)归 hooks 所有;`plugin list` 和 `plugin import` 不会显示它。
|
||||
|
||||
本地 OpenCode source 必须已经包含其构建好的 entry(`main`、字符串形式的 root export,
|
||||
或 `index.js`)以及所需的运行时依赖。Skillshare 不会运行构建脚本,也不会将依赖安装到 source 中。
|
||||
本地 OpenCode v1 source 需要构建好的 entry(`main`、字符串形式的 root export,或 `index.js`)。v2 使用目录加载器:需要 `name` 加字符串形式的 root 或 `./server` export,或根目录的 `server`/`index` 文件(`.ts`、`.tsx`、`.js`)。`--entry` 不会覆盖 v2 的目录加载;条件或回退形式的 server export 会被拒绝。`@opencode-ai/plugin` 和 `@opencode/plugin` 都能标识 OpenCode package。manifest 与依赖要求保持不变。Skillshare 不会运行构建脚本,也不会将依赖安装到 source 中。
|
||||
注册成功并不代表模块已成功加载;请在重新加载后检查 OpenCode。
|
||||
|
||||
全局 npm 注册没有 managed cache 时显示 Unknown/只读,不代表尚未安装;Pi 可能使用 Skillshare 不探查的 legacy global npm/pnpm 路径。
|
||||
|
||||
Import 接受普通 Pi source,以及Pi 0.99.2 及以上来源与选项格式受支持的 filtered object。预览只显示保留的字段名称,不显示 opaque 值。导入不修改原生设置或已安装文件;原始条目保存在 Skillshare 私有状态,本机安装记录仅存 digest。sync/update 保留当前条目;卸载前保存最新选项,重新安装时先恢复 object,避免暂时按默认规则启用其他资源。同一次 Apply 批量恢复时,只接受此次操作自己写出的精确内容;其他设置变动仍会阻止后续恢复。这些 bindings 必须保留私有状态:记录丢失、被修改或属于其他 target 时拒绝恢复。Windows 的新注册目录以受保护的 owner/SYSTEM ACL 创建。现有目录与记录若允许当前用户及特权 SYSTEM/Administrators 之外的主体访问,或无法验证 ACL,便拒绝导入或恢复。不会修改现有 ACL;请保留记录,由所有者修复访问保护后再重试。不确定的来源或优先级、不支持的编码,以及 Pi 会规范化的本地引用仍为只读。普通 OpenCode 条目可导入,filtered OpenCode 条目仍拒绝。超过 Pi 10 秒过期阈值的空锁目录,只有 inode 与 mtime 未变动时才能回收;新锁、更新或被替换的锁、非空目录、文件与 symlink 一律保留。过期不代表持有者已终止,最后检查与移除不是原子 CAS。已导入的 Pi package 在全局模式下用 `pi update SOURCE` 更新,并保留其设置条目;project 中的则要在 Pi 里更新,因为 `pi update` 也会影响全局 package。已导入的 OpenCode v1 packages 会在其原生工具中更新。
|
||||
OpenCode v2 的全局导入可以使用其原生的更新命令;project 导入则必须原生更新,
|
||||
OpenCode v2 的全局 package 导入可以使用其原生的更新命令;导入的本地目录由你在源位置更新,不运行依赖安装器;project 导入则必须原生更新,
|
||||
因为 v2 的更新命令是全局的。
|
||||
|
||||
```bash
|
||||
@@ -401,3 +401,5 @@ skillshare plugin sync NAME --no-tui
|
||||
`unimport` 要求明确指定一个或多个 `--target`,且各目标必须已有本机导入记录和共享来源配置。它通过目标的卸载适配器移除本机导入的安装,然后清除本机记录。共享声明和其他机器的安装保持不变。下一次 sync 会从共享来源安装。
|
||||
|
||||
卸载也会移除原生客户端中与该安装相关的配置或登录信息。
|
||||
|
||||
旧版 Skillshare OpenCode v2 适配器留下的扁平文件注册,在 add/import/sync/update 时会被拒绝。请移除旧的受管理 binding,再重新添加其目录包。移除操作仍然可用,且不会改动无关的原生注册。预览之后运行时版本发生变化,需要重新预览。
|
||||
|
||||
+15
-2
@@ -91,7 +91,7 @@ Skillshare 以縮排的 block 格式寫入 `hooks` 區段;每次儲存也會
|
||||
| `bindings.AGENT.codeFile` | 取代 `code`:相對於 config 所在資料夾的路徑,檔案內容作為 `code` 使用,每次讀取 config 時重新讀取;路徑必須位於該資料夾內 |
|
||||
| `bindings.AGENT.files` | 可選 UTF-8 腳本檔,以相對檔名為 key;值為檔案內容,或依 `codeFile` 相同規則讀取的 `{from: path}` |
|
||||
|
||||
Agent ID 為 `claude`、`codex`、`gemini`、`copilot`、`cursor`、`droid`、`qwen`、`antigravity`、`pi`、`omp`、`amp`、`opencode`、`git`;`factory` 是 `droid` 的別名,`antigravity-cli` 與 `agy` 是 `antigravity` 的別名。event、matcher、handler type、command、timeout 單位與 payload 均保留原生格式,不自動跨 Agent 轉換。event 名稱會對照各 command Agent 文件列出的事件檢查:未知名稱(例如拼錯的 `Stopp`)在預覽與 plan 的 `warnings` 中顯示警告,但不阻擋同步,因為 Agent 會陸續新增事件。Pi、OMP、Amp、OpenCode 的程式碼不檢查。Pi、OMP、Amp、OpenCode 的程式碼與 imports 須符合已安裝版本;發布至獨立的 `skillshare-NAME.ts`,不產生共用執行引擎。
|
||||
Agent ID 為 `claude`、`codex`、`gemini`、`copilot`、`cursor`、`droid`、`qwen`、`antigravity`、`pi`、`omp`、`amp`、`opencode`、`git`;`factory` 是 `droid` 的別名,`antigravity-cli` 與 `agy` 是 `antigravity` 的別名。event、matcher、handler type、command、timeout 單位與 payload 均保留原生格式,不自動跨 Agent 轉換。event 名稱會對照各 command Agent 文件列出的事件檢查:未知名稱(例如拼錯的 `Stopp`)在預覽與 plan 的 `warnings` 中顯示警告,但不阻擋同步,因為 Agent 會陸續新增事件。Pi、OMP、Amp、OpenCode 的程式碼不檢查。Pi、OMP、Amp、OpenCode 的程式碼與 imports 須符合已安裝版本;發布至獨立的 `skillshare-NAME.ts` 檔案(OpenCode v1)或 OpenCode v2 目錄套件,不產生共用執行引擎。
|
||||
|
||||
較長的程式碼與腳本可以用 `codeFile` 或 `files` 的 `{from: path}` 從獨立檔案讀取。路徑以持有該 entry 的 config 所在資料夾為準(專案是 `.skillshare/`,global 的 `hooks.projects` 則是 global config 資料夾);`hooks add|edit --file` 也以選定的 config 為準,而非 entry 檔案所在位置。路徑必須位於該資料夾內,不能經過 symlink;檔案不存在會讓 config 讀取失敗。每次讀取 config 都會重新讀取檔案,預覽後內容有變更就會拒絕套用。
|
||||
|
||||
@@ -138,7 +138,7 @@ command binding 的腳本位於 Agent 設定目錄的 `hooks/skillshare/NAME/`
|
||||
| [Pi](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/extensions.md) | `~/.pi/agent/extensions/skillshare-NAME.ts` | `.pi/extensions/skillshare-NAME.ts` | Native extension code |
|
||||
| [Oh My Pi](https://github.com/can1357/oh-my-pi/blob/v18.6.1/docs/extensions.md) | `~/.omp/agent/extensions/skillshare-NAME.ts` | `.omp/extensions/skillshare-NAME.ts` | Native OMP extension code |
|
||||
| [Amp](https://ampcode.com/docs/plugin-api) | `~/.config/amp/plugins/skillshare-NAME.ts` | `.amp/plugins/skillshare-NAME.ts` | Native plugin code |
|
||||
| [OpenCode](https://opencode.ai/docs/plugins/) | `~/.config/opencode/plugins/skillshare-NAME.ts` | `.opencode/plugins/skillshare-NAME.ts` | Supplied v1/v2 plugin code |
|
||||
| [OpenCode](https://opencode.ai/docs/plugins/) | `~/.config/opencode/plugins/skillshare-NAME[.ts]` | `.opencode/plugins/skillshare-NAME[.ts]` | v1 file; v2 directory package (see below) |
|
||||
|
||||
global scope 使用原生設定目錄的環境變數 override,但指向帳號 `config_dir` 時除外;project scope 只寫入專案,不退回 global 路徑。Codex inline TOML 等其他來源仍獨立存在。Antigravity 與其 CLI(`agy`)讀取同一份 `hooks.json`;每個 hook 是一個以其名稱命名的 block,匯入時保留原名。CLI 的 `~/.gemini/antigravity-cli/settings.json` 中的 hooks 保持獨立。Droid 發布獨立 hooks 檔會影響原生載入來源,請先檢查既有 inline hooks。Copilot 只在受信任的資料夾中載入 `.github/hooks` 的專案 hooks。
|
||||
|
||||
@@ -229,3 +229,16 @@ global 設定的 `hooks.projects` 將絕對專案路徑對應到相同 Entry 格
|
||||
備份還原原生輸出並保留之後新增的無關內容,不改寫來源定義。使用「設定 → 備份 → Hooks」或 `hooks restore` 先預覽再還原。
|
||||
|
||||
**已同步**只表示 Skillshare 已寫入設定。請依 Agent 的原生流程重啟/重新載入;信任、啟用 hooks 及程式碼相容性由 Agent 控制。管理操作不執行 hook command,也不自動改變原生信任。
|
||||
|
||||
|
||||
### OpenCode v2 目錄套件
|
||||
|
||||
Windows 上的 hook 版本探測會將 `opencode-ai`(較新 v1)和 `@opencode/cli`(v2)的標準 npm `.cmd` 啟動器直接解析為已安裝的 `bin/opencode.exe`,不使用 shell。不會推測或執行早期 v1 的 Node 啟動器或自訂批次包裝器。此類安裝請將 OpenCode 帳戶的 `cli` 設為已安裝的原生 `opencode.exe` 的絕對路徑(例如相符的 `opencode-windows-x64-baseline` 套件內的 `bin/opencode.exe`),或將其目錄放在 `PATH` 最前面。Skillshare 不執行 postinstall 腳本,也不修復缺少的二進位檔。
|
||||
|
||||
Skillshare 只探測 `opencode --version`(或帳戶的 `cli`)。當無法偵測到版本時(二進位檔缺少、執行失敗,或回報的主要版本不是 1 或 2),只會略過 OpenCode 的 binding:預覽會顯示警告,現有的 OpenCode 輸出保持不變,其他所有 Agent 照常同步。v1 保留單一的 `.ts` 檔案。v2 寫入 `plugins/skillshare-NAME/index.ts` 和 `package.json`(宣告 `@opencode/plugin: ^2.0.0`),並將該目錄的 `file://` URL 加入 `opencode.json(c)` 的 `plugins` 中。專案 hook 使用 `.opencode/opencode.json(c)`。註解和無關的註冊保持不變。存在衝突的 JSON/JSONC 檔案,或 `OPENCODE_CONFIG`/`OPENCODE_CONFIG_CONTENT` 覆寫,會被 hooks 拒絕。`code` binding 在兩個版本上都依給定內容寫入;Skillshare 不檢查它是否符合 v1 或 v2 的外掛 API。
|
||||
|
||||
完整的 v2 套件請使用 `bindings.opencode.package` 取代 `code`/`codeFile`:這是一個從相對檔名到 UTF-8 內容的對應,其中包含 `package.json`。manifest 及其相依需求會原樣保留。允許巢狀檔案;路徑越界、符號連結、檔案與目錄衝突、`.git` 和 `node_modules` 都不屬於套件的內容。原生編輯器會將此檔案對應顯示為 JSON。server 進入點必須是帶有套件名稱的字串形式根匯出或 `./server` 匯出,或是慣例的根目錄 `server`/`index` 檔案(`.ts`、`.tsx`、`.js`)。條件式和後備式 server 匯出會被拒絕,而不是猜測。`package` binding 需要 OpenCode v2;在 v1 上會被略過並給出警告。
|
||||
|
||||
`hooks import --from opencode` 還會讀取原生 `plugins` 資料夾下的直接子套件目錄。與單一檔案程式碼匯入一樣,它會將其複製到 Skillshare 的命名輸出,並警告你在同步後移除原始檔案和註冊,以避免重複載入。已安裝的 `node_modules` 和 `.git` 不會匯入。包含無法讀取的檔案(例如符號連結)的套件會連同該問題一起列出;其他套件和單一檔案仍可匯入。在 OpenCode v1 上,`plugins` 下的目錄不會列為 hook。同步、編輯和移除使用與其他 hook 相同的擁有權檢查和備份;被外部編輯的套件檔案會產生衝突,而不是被覆蓋。
|
||||
|
||||
請在載入前自行準備宣告的相依套件;只要預覽會寫入套件檔案,就會提示這一點。Skillshare 從不執行外掛程式碼、安裝相依套件或將 v1 程式碼轉換為 v2。註冊並不能證明外掛已載入。由於兩種 API 不同,儀表板刻意不提供 OpenCode 入門程式碼。
|
||||
|
||||
+6
-4
@@ -249,19 +249,19 @@ Skillshare 讀取套件時不會執行它們,因此這個分頁顯示的是設
|
||||
|
||||
同步到 Pi 的專案在專案頁面上也有這個分頁。它顯示專案設定疊加在全域設定之上後,每個套件選取的內容,並標示是繼承自 `pi (global)` 還是專案覆寫。開關只會把規則存到專案的 `.pi/settings.json`,做法和 `pi config` 相同:全域套件會得到一個專案項目 `{"source": ..., "autoload": false, "extensions": [...]}`,只改變它指名的檔案,全域項目維持原樣。本機來源會寫成相對於 `.pi` 的路徑,npm 或 git 來源則照全域設定的寫法。移除這類項目的最後一條專案規則時,只有不會讓較早登錄的 filters 生效才移除該項目;否則保留空的 winning override。只有明確的 JSON `false` 才表示 delta,`autoload: null` 不是 `false`。沒有對應全域項目、且 `autoload: false` 的專案項目只會載入它用 `+` 指名的檔案。檔案與其 `.pi` 資料夾只會在套用時建立。全域設定與 Pi 的 `trust.json` 永遠不會被寫入,Skillshare 也不會替你信任專案:Pi 只有在信任專案時才會使用專案設定。含有憑證或查詢字串的全域來源不會被複製到專案,所以該套件在專案中是唯讀;專案設定中有 Skillshare 無法讀取的項目時,所有套件都是唯讀。套用時會持有 Pi 對專案檔案的鎖,並在寫入前再次檢查兩個設定檔與套件。Pi 自己的 `extensions` 資料夾中的 extension(包括 [extras](./extras.md) 連結到那裡的檔案)以唯讀方式列出,並說明在哪裡修改;專案會列出自己的資料夾(Pi 只有在信任專案時才會讀取)和全域資料夾。
|
||||
|
||||
OpenCode 會在 `opencode.json` 或既有的 `opencode.jsonc` 中,把受管理的進入點註冊為 file URL,
|
||||
OpenCode v1 將受管理的進入點檔案、v2 將 package 目錄作為 file URL 註冊到 `opencode.json` 或既有的 `opencode.jsonc` 中,
|
||||
並保留註解與無關的項目。Version 1 使用 `plugin`;version 2 使用 `plugins`。會遵循
|
||||
`XDG_CONFIG_HOME` 與絕對路徑的全域 `OPENCODE_CONFIG`;模糊或不支援的覆寫會被拒絕。OpenCode
|
||||
必須位於 PATH 上,Skillshare 才能選擇對應版本的 schema。
|
||||
[`hooks`](./hooks.md) 在同一個 `plugins` 陣列中註冊的 v2 目錄套件(`plugins/skillshare-NAME`)歸 hooks 所有;`plugin list` 與 `plugin import` 不會顯示它。
|
||||
|
||||
本機 OpenCode source 必須已經包含建置好的進入點(`main`、字串形式的 root export,或
|
||||
`index.js`)以及所需的執行期依賴。Skillshare 不會執行建置腳本,也不會將依賴安裝進 source。
|
||||
本機 OpenCode v1 source 需要建置好的進入點(`main`、字串形式的 root export,或 `index.js`)。v2 使用目錄載入器:需要 `name` 加字串形式的 root 或 `./server` export,或根目錄的 `server`/`index` 檔案(`.ts`、`.tsx`、`.js`)。`--entry` 不會覆寫 v2 的目錄載入;條件式或後備形式的 server export 會被拒絕。`@opencode-ai/plugin` 與 `@opencode/plugin` 都能識別 OpenCode package。manifest 與依賴要求保持不變。Skillshare 不會執行建置腳本,也不會將依賴安裝進 source。
|
||||
註冊成功不代表模組已成功載入;請在重新載入後檢查 OpenCode。
|
||||
|
||||
全域 npm 登錄沒有 managed cache 時顯示 Unknown/唯讀,不代表尚未安裝;Pi 可能使用 Skillshare 不探查的 legacy global npm/pnpm 路徑。
|
||||
|
||||
匯入接受一般 Pi source,以及Pi 0.99.2 以上來源與選項格式受支援的 filtered object。預覽只顯示保留的欄位名稱,不顯示 opaque 值。匯入不修改原生設定或已安裝檔案;原始項目保存在 Skillshare 私有狀態,本機安裝紀錄僅存 digest。sync/update 保留現有項目;解除安裝前保存最新選項,重新安裝時先恢復 object,避免暫時以預設規則啟用其他資源。同一次 Apply 批次恢復時,只接受此次操作自己寫出的精確內容;其他設定變動仍會阻止後續恢復。這些 bindings 必須保留私有狀態:紀錄遺失、被修改或屬於其他 target 時拒絕恢復。Windows 的新登錄目錄以受保護的 owner/SYSTEM ACL 建立。現有目錄與紀錄若允許目前使用者及特權 SYSTEM/Administrators 以外的主體存取,或無法驗證 ACL,便拒絕匯入或恢復。不會修改現有 ACL;請保留紀錄,由擁有者修復存取保護後再重試。不確定的來源或優先序、不支援的編碼,以及 Pi 會正規化的本機參照仍為唯讀。一般 OpenCode 項目可匯入,filtered OpenCode 項目仍拒絕。超過 Pi 10 秒過期門檻的空鎖目錄,只有 inode 與 mtime 未變動時才能回收;新鎖、更新或被替換的鎖、非空目錄、檔案與 symlink 一律保留。過期不代表擁有者已終止,最後檢查與移除不是原子 CAS。已匯入的 Pi 套件在全域模式下以 `pi update SOURCE` 更新,並保留其設定項目;專案中的則要在 Pi 裡更新,因為 `pi update` 也會動到全域套件。已匯入的 OpenCode v1 套件會在其原生工具中更新。OpenCode
|
||||
v2 的全域匯入可以使用其原生更新指令;專案匯入則必須以原生方式更新,因為 v2 的更新指令是
|
||||
v2 的全域 package 匯入可以使用其原生更新指令;匯入的本機目錄由你在來源位置更新,不執行依賴安裝器;專案匯入則必須以原生方式更新,因為 v2 的更新指令是
|
||||
全域性的。
|
||||
|
||||
```bash
|
||||
@@ -394,3 +394,5 @@ skillshare plugin sync NAME --no-tui
|
||||
`unimport` 要求明確指定一個或多個 `--target`,且各目標必須已有本機匯入紀錄及共用來源設定。它透過目標的移除配接器解除本機匯入的安裝,然後清除本機紀錄。共用宣告和其他機器的安裝保持不變。下一次 sync 會從共用來源安裝。
|
||||
|
||||
解除安裝也會移除原生用戶端中與該安裝相關的設定或登入資料。
|
||||
|
||||
舊版 Skillshare OpenCode v2 配接器留下的單一檔案註冊,在 add/import/sync/update 時會被拒絕。請移除舊的受管理 binding,再重新加入其目錄套件。移除操作仍然可用,且不會更動無關的原生註冊。預覽之後執行階段版本若有變更,需要重新預覽。
|
||||
|
||||
Reference in New Issue
Block a user