@hueyexe/opencode-ensemble 0.1.0 → 0.1.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.
- package/README.md +22 -10
- package/dist/index.js +11 -4
- package/package.json +1 -1
- package/src/db.ts +11 -0
- package/src/index.ts +5 -3
package/README.md
CHANGED
|
@@ -79,26 +79,38 @@ Lead: "All validation and tests are complete. 5 endpoints validated,
|
|
|
79
79
|
|
|
80
80
|
## Install
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
Add the plugin to your OpenCode config. This can be project-level or global.
|
|
83
|
+
|
|
84
|
+
**Project-level** — `opencode.json` in your project root:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"plugin": ["@hueyexe/opencode-ensemble"]
|
|
89
|
+
}
|
|
84
90
|
```
|
|
85
91
|
|
|
86
|
-
|
|
92
|
+
**Global** — `~/.config/opencode/opencode.json`:
|
|
87
93
|
|
|
88
94
|
```json
|
|
89
95
|
{
|
|
90
|
-
"
|
|
91
|
-
"ensemble": {
|
|
92
|
-
"module": "opencode-ensemble"
|
|
93
|
-
}
|
|
94
|
-
}
|
|
96
|
+
"plugin": ["@hueyexe/opencode-ensemble"]
|
|
95
97
|
}
|
|
96
98
|
```
|
|
97
99
|
|
|
98
|
-
|
|
100
|
+
That's it. OpenCode auto-installs npm plugins at startup (cached in `~/.cache/opencode/node_modules/`). No `npm install` or `bun add` needed.
|
|
101
|
+
|
|
102
|
+
### Local development
|
|
103
|
+
|
|
104
|
+
For working on the plugin itself, create `.opencode/plugins/ensemble.ts` in your project:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
export { default } from "@hueyexe/opencode-ensemble"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Or point directly at the source checkout:
|
|
99
111
|
|
|
100
112
|
```ts
|
|
101
|
-
export { default } from "opencode-ensemble"
|
|
113
|
+
export { default } from "/path/to/opencode-ensemble/src/index.ts"
|
|
102
114
|
```
|
|
103
115
|
|
|
104
116
|
## Tools
|
package/dist/index.js
CHANGED
|
@@ -12335,10 +12335,12 @@ function tool(input) {
|
|
|
12335
12335
|
}
|
|
12336
12336
|
tool.schema = exports_external;
|
|
12337
12337
|
// src/index.ts
|
|
12338
|
-
import
|
|
12338
|
+
import path2 from "path";
|
|
12339
|
+
import { mkdirSync } from "fs";
|
|
12339
12340
|
|
|
12340
12341
|
// src/db.ts
|
|
12341
12342
|
import { Database } from "bun:sqlite";
|
|
12343
|
+
import path from "path";
|
|
12342
12344
|
|
|
12343
12345
|
// src/schema.ts
|
|
12344
12346
|
var MIGRATIONS = [
|
|
@@ -12417,8 +12419,12 @@ function applyMigrations(db) {
|
|
|
12417
12419
|
|
|
12418
12420
|
// src/db.ts
|
|
12419
12421
|
var instance;
|
|
12420
|
-
function
|
|
12421
|
-
const
|
|
12422
|
+
function getDbPath(env = process.env) {
|
|
12423
|
+
const home = env.HOME ?? env.USERPROFILE ?? "~";
|
|
12424
|
+
return path.join(home, ".config", "opencode", "ensemble.db");
|
|
12425
|
+
}
|
|
12426
|
+
function createDb(path2) {
|
|
12427
|
+
const db = new Database(path2);
|
|
12422
12428
|
db.exec("PRAGMA journal_mode=WAL");
|
|
12423
12429
|
db.exec("PRAGMA foreign_keys=ON");
|
|
12424
12430
|
applyMigrations(db);
|
|
@@ -13060,7 +13066,8 @@ var DEFAULT_RATE_LIMIT_CAPACITY = 10;
|
|
|
13060
13066
|
var DEFAULT_RATE_LIMIT_REFILL = 2;
|
|
13061
13067
|
var DEFAULT_RATE_LIMIT_INTERVAL_MS = 1000;
|
|
13062
13068
|
var plugin = async (input) => {
|
|
13063
|
-
const dbPath =
|
|
13069
|
+
const dbPath = getDbPath();
|
|
13070
|
+
mkdirSync(path2.dirname(dbPath), { recursive: true });
|
|
13064
13071
|
const db = createDb(dbPath);
|
|
13065
13072
|
const registry2 = new MemberRegistry;
|
|
13066
13073
|
const tracker = new DescendantTracker;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hueyexe/opencode-ensemble",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Agent teams for OpenCode — parallel agents with peer-to-peer communication, shared tasks, and coordinated execution",
|
|
5
5
|
"module": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
package/src/db.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { Database } from "bun:sqlite"
|
|
2
|
+
import path from "path"
|
|
2
3
|
import { applyMigrations } from "./schema"
|
|
3
4
|
|
|
4
5
|
let instance: Database | undefined
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Resolve the path for the ensemble SQLite database.
|
|
9
|
+
* Always uses the global ~/.config/opencode/ directory, never the project directory.
|
|
10
|
+
* Accepts an env override for testability.
|
|
11
|
+
*/
|
|
12
|
+
export function getDbPath(env: Record<string, string | undefined> = process.env): string {
|
|
13
|
+
const home = env.HOME ?? env.USERPROFILE ?? "~"
|
|
14
|
+
return path.join(home, ".config", "opencode", "ensemble.db")
|
|
15
|
+
}
|
|
16
|
+
|
|
6
17
|
/**
|
|
7
18
|
* Create and initialize a SQLite database at the given path.
|
|
8
19
|
* Applies all pending migrations and enables WAL mode.
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Plugin } from "@opencode-ai/plugin"
|
|
2
2
|
import { tool } from "@opencode-ai/plugin"
|
|
3
3
|
import path from "path"
|
|
4
|
-
import {
|
|
4
|
+
import { mkdirSync } from "node:fs"
|
|
5
|
+
import { createDb, getDbPath } from "./db"
|
|
5
6
|
import { recoverStaleMembers } from "./recovery"
|
|
6
7
|
import { MemberRegistry, DescendantTracker } from "./state"
|
|
7
8
|
import { handleSessionStatusEvent, handleSessionCreatedEvent, checkToolIsolation } from "./hooks"
|
|
@@ -32,8 +33,9 @@ const DEFAULT_RATE_LIMIT_INTERVAL_MS = 1000
|
|
|
32
33
|
* peer-to-peer communication, shared task management, and coordinated execution.
|
|
33
34
|
*/
|
|
34
35
|
const plugin: Plugin = async (input) => {
|
|
35
|
-
// Initialize SQLite database in the
|
|
36
|
-
const dbPath =
|
|
36
|
+
// Initialize SQLite database in the global OpenCode config directory
|
|
37
|
+
const dbPath = getDbPath()
|
|
38
|
+
mkdirSync(path.dirname(dbPath), { recursive: true })
|
|
37
39
|
const db = createDb(dbPath)
|
|
38
40
|
|
|
39
41
|
// Initialize in-memory state
|