opencode-bifrost 0.0.1

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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +121 -0
  3. package/assets/demo.gif +0 -0
  4. package/bun.lock +34 -0
  5. package/dist/config.d.ts +13 -0
  6. package/dist/config.d.ts.map +1 -0
  7. package/dist/hooks.d.ts +2 -0
  8. package/dist/hooks.d.ts.map +1 -0
  9. package/dist/index.d.ts +4 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +26655 -0
  12. package/dist/manager.d.ts +54 -0
  13. package/dist/manager.d.ts.map +1 -0
  14. package/dist/security.d.ts +8 -0
  15. package/dist/security.d.ts.map +1 -0
  16. package/dist/tools/connect.d.ts +3 -0
  17. package/dist/tools/connect.d.ts.map +1 -0
  18. package/dist/tools/disconnect.d.ts +3 -0
  19. package/dist/tools/disconnect.d.ts.map +1 -0
  20. package/dist/tools/download.d.ts +3 -0
  21. package/dist/tools/download.d.ts.map +1 -0
  22. package/dist/tools/exec.d.ts +3 -0
  23. package/dist/tools/exec.d.ts.map +1 -0
  24. package/dist/tools/status.d.ts +3 -0
  25. package/dist/tools/status.d.ts.map +1 -0
  26. package/dist/tools/upload.d.ts +3 -0
  27. package/dist/tools/upload.d.ts.map +1 -0
  28. package/package.json +47 -0
  29. package/src/config.ts +151 -0
  30. package/src/hooks.ts +1 -0
  31. package/src/index.ts +64 -0
  32. package/src/manager.ts +471 -0
  33. package/src/security.ts +98 -0
  34. package/src/tools/connect.ts +35 -0
  35. package/src/tools/disconnect.ts +30 -0
  36. package/src/tools/download.ts +51 -0
  37. package/src/tools/exec.ts +68 -0
  38. package/src/tools/status.ts +49 -0
  39. package/src/tools/upload.ts +56 -0
  40. package/test/config.test.ts +233 -0
  41. package/test/integration.test.ts +199 -0
  42. package/test/manager.test.ts +209 -0
  43. package/test/security.test.ts +245 -0
  44. package/tsconfig.json +27 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 itsmylife44
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # Bifrost
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
4
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue.svg)](https://www.typescriptlang.org/)
5
+ [![Bun](https://img.shields.io/badge/Bun-1.x-orange.svg)](https://bun.sh/)
6
+
7
+ Persistent SSH connection plugin for [OpenCode](https://github.com/opencode-ai/opencode).
8
+
9
+ Bifrost maintains a single SSH connection using ControlMaster multiplexing, so every command reuses the same connection instead of reconnecting each time.
10
+
11
+ ![Bifrost Demo](assets/demo.gif)
12
+
13
+ ## Installation
14
+
15
+ ### 1. Register the plugin
16
+
17
+ Add to your `~/.config/opencode/opencode.json`:
18
+
19
+ ```json
20
+ {
21
+ "plugins": [
22
+ "github:itsmylife44/bifrost"
23
+ ]
24
+ }
25
+ ```
26
+
27
+ ### 2. Create the SSH config
28
+
29
+ Create `~/.config/opencode/bifrost.json`:
30
+
31
+ ```json
32
+ {
33
+ "host": "your-server-ip",
34
+ "user": "root",
35
+ "keyPath": "~/.ssh/id_rsa"
36
+ }
37
+ ```
38
+
39
+ | Field | Required | Default | Description |
40
+ |-------|----------|---------|-------------|
41
+ | `host` | Yes | - | Server IP or hostname |
42
+ | `user` | No | `root` | SSH username |
43
+ | `keyPath` | Yes | - | Path to SSH private key |
44
+ | `port` | No | `22` | SSH port |
45
+
46
+ > **Note:** Password authentication is not supported. Use SSH keys only.
47
+
48
+ ### 3. Restart OpenCode
49
+
50
+ The plugin is installed automatically on startup.
51
+
52
+ ## Usage
53
+
54
+ Once configured, the agent automatically uses Bifrost when you mention:
55
+ - "server", "remote", "deploy", "production", "staging"
56
+ - "check the server", "run on server", "server logs"
57
+
58
+ ### Available Tools
59
+
60
+ | Tool | Description |
61
+ |------|-------------|
62
+ | `bifrost_connect` | Establish SSH connection (called automatically) |
63
+ | `bifrost_exec` | Run a command on the server |
64
+ | `bifrost_status` | Check connection status |
65
+ | `bifrost_disconnect` | Close the connection |
66
+ | `bifrost_upload` | Upload a file to the server |
67
+ | `bifrost_download` | Download a file from the server |
68
+
69
+ ### Example Prompts
70
+
71
+ ```
72
+ "How's the server doing?"
73
+ "Show me the nginx logs"
74
+ "Restart the docker containers"
75
+ "Upload config.yaml to /etc/app/"
76
+ "What's using port 8080?"
77
+ ```
78
+
79
+ ## How It Works
80
+
81
+ Bifrost uses SSH ControlMaster to maintain a persistent connection:
82
+
83
+ ```
84
+ First command: [Connect] -----> [Execute] -----> [Keep socket open]
85
+ Next commands: [Reuse socket] -> [Execute] -----> [Still open]
86
+ Session ends: [Auto-disconnect]
87
+ ```
88
+
89
+ The control socket is stored at `~/.ssh/bifrost-control/`.
90
+
91
+ ## Security
92
+
93
+ All inputs are validated before execution to prevent injection attacks:
94
+
95
+ - **Path traversal** (`../`) blocked
96
+ - **Command injection** (`;`, `|`, `&`, `` ` ``, `$()`) blocked
97
+ - **Shell expansion** (`*`, `?`, `~`, `{}`) blocked
98
+ - **Unicode bypass attempts** detected and rejected
99
+ - **Null bytes** and control characters rejected
100
+
101
+ ## Requirements
102
+
103
+ - OpenCode with plugin support
104
+ - SSH key-based authentication
105
+
106
+ ## Development
107
+
108
+ ```bash
109
+ # Run tests
110
+ bun test
111
+
112
+ # Type check
113
+ bun run typecheck
114
+
115
+ # Build
116
+ bun run build
117
+ ```
118
+
119
+ ## License
120
+
121
+ MIT
Binary file
package/bun.lock ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "configVersion": 1,
4
+ "workspaces": {
5
+ "": {
6
+ "name": "bifrost",
7
+ "dependencies": {
8
+ "@opencode-ai/plugin": "^1.1.53",
9
+ "zod": "^4.3.6",
10
+ },
11
+ "devDependencies": {
12
+ "bun-types": "latest",
13
+ "typescript": "^5.9.3",
14
+ },
15
+ },
16
+ },
17
+ "packages": {
18
+ "@opencode-ai/plugin": ["@opencode-ai/plugin@1.1.53", "", { "dependencies": { "@opencode-ai/sdk": "1.1.53", "zod": "4.1.8" } }, "sha512-9ye7Wz2kESgt02AUDaMea4hXxj6XhWwKAG8NwFhrw09Ux54bGaMJFt1eIS8QQGIMaD+Lp11X4QdyEg96etEBJw=="],
19
+
20
+ "@opencode-ai/sdk": ["@opencode-ai/sdk@1.1.53", "", {}, "sha512-RUIVnPOP1CyyU32FrOOYuE7Ge51lOBuhaFp2NSX98ncApT7ffoNetmwzqrhOiJQgZB1KrbCHLYOCK6AZfacxag=="],
21
+
22
+ "@types/node": ["@types/node@25.2.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-BkmoP5/FhRYek5izySdkOneRyXYN35I860MFAGupTdebyE66uZaR+bXLHq8k4DirE5DwQi3NuhvRU1jqTVwUrQ=="],
23
+
24
+ "bun-types": ["bun-types@1.3.9", "", { "dependencies": { "@types/node": "*" } }, "sha512-+UBWWOakIP4Tswh0Bt0QD0alpTY8cb5hvgiYeWCMet9YukHbzuruIEeXC2D7nMJPB12kbh8C7XJykSexEqGKJg=="],
25
+
26
+ "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
27
+
28
+ "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
29
+
30
+ "zod": ["zod@4.3.6", "", {}, "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg=="],
31
+
32
+ "@opencode-ai/plugin/zod": ["zod@4.1.8", "", {}, "sha512-5R1P+WwQqmmMIEACyzSvo4JXHY5WiAFHRMg+zBZKgKS+Q1viRa0C1hmUKtHltoIFKtIdki3pRxkmpP74jnNYHQ=="],
33
+ }
34
+ }
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ export declare const BifrostConfigSchema: z.ZodObject<{
3
+ host: z.ZodString;
4
+ user: z.ZodDefault<z.ZodString>;
5
+ keyPath: z.ZodString;
6
+ port: z.ZodDefault<z.ZodNumber>;
7
+ connectTimeout: z.ZodDefault<z.ZodNumber>;
8
+ controlPersist: z.ZodDefault<z.ZodString>;
9
+ serverAliveInterval: z.ZodDefault<z.ZodNumber>;
10
+ }, z.core.$strip>;
11
+ export type BifrostConfig = z.infer<typeof BifrostConfigSchema>;
12
+ export declare function parseConfig(configPath: string): BifrostConfig;
13
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,mBAAmB;;;;;;;;iBA2C9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AA8ChE,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,CAoD7D"}
@@ -0,0 +1,2 @@
1
+ export declare const placeholder = true;
2
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,OAAO,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Plugin } from "@opencode-ai/plugin";
2
+ declare const Bifrost: Plugin;
3
+ export default Bifrost;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AASlD,QAAA,MAAM,OAAO,EAAE,MAoDd,CAAC;AAEF,eAAe,OAAO,CAAC"}