opencode-remote-brain 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -0
- package/assets/remote-brain.schema.json +31 -0
- package/dist/index.js +15348 -0
- package/dist/index.js.map +83 -0
- package/package.json +32 -0
- package/postinstall.mjs +19 -0
package/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# opencode-remote-brain
|
|
2
|
+
|
|
3
|
+
OpenCode plugin that syncs rules and skills from a public GitHub repository into OpenCode's native configuration.
|
|
4
|
+
|
|
5
|
+
## How it works
|
|
6
|
+
|
|
7
|
+
On startup, the plugin clones (or pulls) the configured GitHub repo, parses `index.yaml`, then injects the listed rules as instructions and skills as skill paths into your OpenCode config. Everything is cached locally so subsequent startups are fast.
|
|
8
|
+
|
|
9
|
+
The `remote-sync` tool lets you manually trigger a re-sync mid-session. Changes take effect on the next startup.
|
|
10
|
+
|
|
11
|
+
If a sync fails for any reason, the plugin falls back to the last successful sync so you're never left without your rules and skills.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install opencode-remote-brain
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Requires `git` to be installed and available on your `PATH`.
|
|
20
|
+
|
|
21
|
+
## Configuration
|
|
22
|
+
|
|
23
|
+
Create `~/.config/opencode/remote-brain.jsonc` (or `$XDG_CONFIG_HOME/opencode/remote-brain.jsonc`):
|
|
24
|
+
|
|
25
|
+
```jsonc
|
|
26
|
+
{
|
|
27
|
+
// Required: GitHub repo in "owner/repo" format
|
|
28
|
+
"repo": "your-org/your-brain",
|
|
29
|
+
// Optional: branch, tag, or commit (default: "main")
|
|
30
|
+
"ref": "main",
|
|
31
|
+
// Optional: index file path within the repo (default: "index.yaml")
|
|
32
|
+
"indexFile": "index.yaml",
|
|
33
|
+
// Optional: local cache directory (default: "~/.cache/opencode/remote-brain")
|
|
34
|
+
"cacheDir": "~/.cache/opencode/remote-brain"
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
You can also point `$schema` at the bundled schema for editor validation:
|
|
39
|
+
|
|
40
|
+
```jsonc
|
|
41
|
+
{
|
|
42
|
+
"$schema": "./node_modules/opencode-remote-brain/assets/remote-brain.schema.json",
|
|
43
|
+
"repo": "your-org/your-brain"
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Repository index format
|
|
48
|
+
|
|
49
|
+
Your remote repo needs an `index.yaml` at the root (or at the path set by `indexFile`):
|
|
50
|
+
|
|
51
|
+
```yaml
|
|
52
|
+
version: 1
|
|
53
|
+
rules:
|
|
54
|
+
- rules/my-rule.md # relative path to a markdown rule file
|
|
55
|
+
skills:
|
|
56
|
+
- skills/my-skill # relative path to a skill directory (must contain SKILL.md)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
All paths are relative to the repo root. Absolute paths and `..` segments are rejected.
|
|
60
|
+
|
|
61
|
+
## Register the plugin in OpenCode
|
|
62
|
+
|
|
63
|
+
Add the plugin to your `~/.config/opencode/config.json`:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"plugins": ["opencode-remote-brain"]
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Using the remote-sync tool
|
|
72
|
+
|
|
73
|
+
Inside OpenCode, run the `remote-sync` tool to pull the latest changes from your remote repo. The sync updates the local cache. Restart OpenCode (or start a new session) for the changes to take effect.
|
|
74
|
+
|
|
75
|
+
## Troubleshooting
|
|
76
|
+
|
|
77
|
+
**Sync fails silently**
|
|
78
|
+
Check that `git` is installed and accessible, and that the configured repo is public.
|
|
79
|
+
|
|
80
|
+
**Rules or skills not loading**
|
|
81
|
+
Verify that the paths in `index.yaml` are relative, exist in the repo, and that rule files end in `.md`. Skill directories must contain a `SKILL.md` file.
|
|
82
|
+
|
|
83
|
+
**Path traversal rejected**
|
|
84
|
+
Paths containing `..` segments or absolute paths are blocked for security. Keep all paths relative to the repo root.
|
|
85
|
+
|
|
86
|
+
## Security
|
|
87
|
+
|
|
88
|
+
Every path read from `index.yaml` is validated before use. Paths with `..` segments or absolute paths are rejected outright. A realpath check then confirms the resolved file stays within the cloned repo directory, preventing any traversal outside the cache.
|
|
89
|
+
|
|
90
|
+
## Development
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Install dependencies
|
|
94
|
+
bun install
|
|
95
|
+
|
|
96
|
+
# Run tests
|
|
97
|
+
bun test
|
|
98
|
+
|
|
99
|
+
# Type-check
|
|
100
|
+
bun run typecheck
|
|
101
|
+
|
|
102
|
+
# Build
|
|
103
|
+
bun run build
|
|
104
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "RemoteBrainConfig",
|
|
4
|
+
"description": "Configuration for opencode-remote-brain plugin",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["repo"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"$schema": { "type": "string" },
|
|
9
|
+
"repo": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "GitHub repository in owner/repo format",
|
|
12
|
+
"pattern": "^[\\w.-]+/[\\w.-]+$"
|
|
13
|
+
},
|
|
14
|
+
"ref": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "Git ref (branch, tag, commit). Default: main",
|
|
17
|
+
"default": "main"
|
|
18
|
+
},
|
|
19
|
+
"indexFile": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "Path to index file in repo. Default: index.yaml",
|
|
22
|
+
"default": "index.yaml"
|
|
23
|
+
},
|
|
24
|
+
"cacheDir": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Local cache directory. Default: ~/.cache/opencode/remote-brain",
|
|
27
|
+
"default": "~/.cache/opencode/remote-brain"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"additionalProperties": false
|
|
31
|
+
}
|