@guyghost/swarm-dao-opencode-adapter 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 +280 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +463 -0
- package/dist/index.js.map +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
# @guyghost/swarm-dao-opencode-adapter
|
|
2
|
+
|
|
3
|
+
> Swarm DAO governance adapter for [OpenCode](https://opencode.ai) — bring multi-agent deliberation, quality gates, and structured decision-making to your coding workflow.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This adapter bridges the [Swarm DAO](https://github.com/guyghost/swarm-dao) core governance engine to the OpenCode platform via the `@opencode-ai/plugin` API. It registers 15 DAO tools that OpenCode agents can invoke directly, enabling structured proposal creation, multi-agent deliberation, quality control gates, and execution tracking — all from within the OpenCode environment.
|
|
8
|
+
|
|
9
|
+
Swarm DAO implements a **4-layer governance model**:
|
|
10
|
+
|
|
11
|
+
| Layer | Purpose | Tools |
|
|
12
|
+
|-------|---------|-------|
|
|
13
|
+
| **L1 Governance** | Decide what enters the roadmap | `dao_setup`, `dao_propose`, `dao_propose_amendment` |
|
|
14
|
+
| **L2 Intelligence** | Produce analysis and recommendations | `dao_record_outputs`, `dao_roundtable` |
|
|
15
|
+
| **L3 Delivery** | Convert decisions into execution | `dao_execute`, `dao_plan`, `dao_artefacts`, `dao_dry_run`, `dao_rollback` |
|
|
16
|
+
| **L4 Control** | Reduce risk before publication | `dao_control`, `dao_audit`, `dao_dashboard` |
|
|
17
|
+
| **Utility** | Inspect DAO state | `dao_list`, `dao_agents` |
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
### Prerequisites
|
|
22
|
+
|
|
23
|
+
- [OpenCode](https://opencode.ai) v1.14.19 or later
|
|
24
|
+
- [Bun](https://bun.sh) v1.3.0 or later
|
|
25
|
+
|
|
26
|
+
### Install the package
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
bun add @guyghost/swarm-dao-opencode-adapter
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Register in your OpenCode config
|
|
33
|
+
|
|
34
|
+
Add the plugin to your `opencode.json` (or `opencode.jsonc`):
|
|
35
|
+
|
|
36
|
+
```jsonc
|
|
37
|
+
{
|
|
38
|
+
"plugin": [
|
|
39
|
+
["@guyghost/swarm-dao-opencode-adapter", {}]
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or register it without options:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"plugin": [
|
|
49
|
+
"@guyghost/swarm-dao-opencode-adapter"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The plugin initializes automatically when OpenCode starts. DAO state is persisted in a `.dao/` directory within your project root.
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
### 1. Initialize the DAO
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
> dao_setup
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Creates the DAO with 7 default product agents:
|
|
65
|
+
|
|
66
|
+
| Agent | Weight | Role |
|
|
67
|
+
|-------|--------|------|
|
|
68
|
+
| Product Strategist | 3 | Vision, objectives, hypotheses |
|
|
69
|
+
| Research Agent | 2 | Market, competition, user signals |
|
|
70
|
+
| Solution Architect | 3 | Technical options, tradeoffs |
|
|
71
|
+
| Critic / Risk Agent | 3 | Risk scoring, objections, guardrails |
|
|
72
|
+
| Prioritization Agent | 2 | Impact/cost/risk scoring, roadmap fit |
|
|
73
|
+
| Spec Writer | 1 | PRD, user stories, acceptance criteria |
|
|
74
|
+
| Delivery Agent | 1 | Implementation plan, tasks, CI/CD |
|
|
75
|
+
|
|
76
|
+
### 2. Create a Proposal
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
> dao_propose title="Add dark mode" type="product-feature" description="Implement dark theme for the application"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Supported proposal types:**
|
|
83
|
+
|
|
84
|
+
| Type | Description |
|
|
85
|
+
|------|-------------|
|
|
86
|
+
| `product-feature` | New user-facing feature |
|
|
87
|
+
| `technical-change` | Refactoring, architecture, tooling |
|
|
88
|
+
| `security-change` | Security-related modifications |
|
|
89
|
+
| `governance-change` | DAO configuration or agent changes |
|
|
90
|
+
| `bug-fix` | Bug fix with impact analysis |
|
|
91
|
+
| `experiment` | Time-boxed experiment with success criteria |
|
|
92
|
+
|
|
93
|
+
Optional fields for richer proposals:
|
|
94
|
+
- `context` — Additional context for reviewers
|
|
95
|
+
- `problemStatement` — What problem does this solve?
|
|
96
|
+
- `acceptanceCriteria` — List of acceptance criteria
|
|
97
|
+
- `successMetrics` — How to measure success
|
|
98
|
+
- `rollbackConditions` — When to rollback
|
|
99
|
+
- `affectedPaths` — File paths authorized for editing
|
|
100
|
+
|
|
101
|
+
### 3. Deliberate (Record Agent Outputs)
|
|
102
|
+
|
|
103
|
+
OpenCode doesn't support automatic agent spawning. Use `dao_record_outputs` to submit outputs collected manually from sub-agents:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
> dao_record_outputs proposalId=1 outputs='[
|
|
107
|
+
{ "agentId": "product-strategist", "content": "High impact...", "durationMs": 1200, "error": null },
|
|
108
|
+
{ "agentId": "critic", "content": "VOTE: FOR — Low risk...", "durationMs": 800, "error": null }
|
|
109
|
+
]'
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Agents can cast votes by including `VOTE: FOR|AGAINST` in their output text. The system tallies votes, calculates composite scores, and generates a synthesis automatically.
|
|
113
|
+
|
|
114
|
+
### 4. Run Quality Control
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
> dao_control proposalId=1
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Runs quality gates: risk assessment, scope validation, and readiness checks. Proposals must pass all gates before execution.
|
|
121
|
+
|
|
122
|
+
### 5. Preview (Dry Run)
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
> dao_dry_run proposalId=1
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Previews the execution plan without applying changes.
|
|
129
|
+
|
|
130
|
+
### 6. Execute
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
> dao_execute proposalId=1
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Executes an approved proposal. Requires the proposal to have passed through `approved` or `controlled` status.
|
|
137
|
+
|
|
138
|
+
### 7. Review and Monitor
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
> dao_list # List all proposals
|
|
142
|
+
> dao_agents # List registered agents
|
|
143
|
+
> dao_plan proposalId=1 # View delivery plan
|
|
144
|
+
> dao_artefacts proposalId=1 # View auto-generated artefacts
|
|
145
|
+
> dao_dashboard # Full governance dashboard
|
|
146
|
+
> dao_audit # Full audit trail
|
|
147
|
+
> dao_audit proposalId=1 # Proposal-specific audit trail
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### 8. Round Table
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
> dao_roundtable
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Asks every agent to suggest a proposal idea. Because OpenCode doesn't support automatic agent spawning, the round table uses the host adapter's dispatch mechanism. Any successfully parsed suggestions are automatically promoted to proposals.
|
|
157
|
+
|
|
158
|
+
### 9. Rollback
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
> dao_rollback proposalId=1
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Reverts a proposal execution to its pre-execution snapshot (if available).
|
|
165
|
+
|
|
166
|
+
### 10. Amendments
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
> dao_propose_amendment title="Increase critic weight" description="Give the critic more influence" amendmentType="agent-update" agentId="critic" agentChanges='{"weight": 5}'
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Supported amendment types:
|
|
173
|
+
|
|
174
|
+
| Type | Required Fields |
|
|
175
|
+
|------|----------------|
|
|
176
|
+
| `agent-update` | `agentId`, `agentChanges` (JSON) |
|
|
177
|
+
| `agent-add` | `newAgentId`, `newAgentName`, `newAgentRole`, `newAgentWeight` |
|
|
178
|
+
| `agent-remove` | `agentId` |
|
|
179
|
+
| `config-update` | `configChanges` (JSON) |
|
|
180
|
+
| `quorum-update` | `quorumChanges` (JSON) |
|
|
181
|
+
| `gate-update` | `addGates`, `removeGates` |
|
|
182
|
+
|
|
183
|
+
## Configuration
|
|
184
|
+
|
|
185
|
+
Per-project configuration in `.dao/config.json`:
|
|
186
|
+
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"mode": "suggest",
|
|
190
|
+
"criticalPaths": [
|
|
191
|
+
"src/auth/**",
|
|
192
|
+
"src/payment/**",
|
|
193
|
+
".env*"
|
|
194
|
+
],
|
|
195
|
+
"agentOverrides": {
|
|
196
|
+
"researcher": { "enabled": false },
|
|
197
|
+
"critic": { "weight": 5 }
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Modes:**
|
|
203
|
+
- `opt-in` *(default)* — Tools available but never auto-invoked
|
|
204
|
+
- `suggest` — Nudges assistant to consider DAO proposal for trigger keywords
|
|
205
|
+
- `enforce` — Blocks edits on critical paths without approved proposal
|
|
206
|
+
|
|
207
|
+
## Architecture
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
211
|
+
│ OpenCode Host │
|
|
212
|
+
│ ┌───────────────────────────────────────────────────────┐ │
|
|
213
|
+
│ │ @opencode-ai/plugin API │ │
|
|
214
|
+
│ │ PluginInput → Plugin → Hooks { tool, ... } │ │
|
|
215
|
+
│ └───────────────────────────┬───────────────────────────┘ │
|
|
216
|
+
│ │ │
|
|
217
|
+
│ ┌───────────────────────────┴───────────────────────────┐ │
|
|
218
|
+
│ │ OpenCode Adapter (this package) │ │
|
|
219
|
+
│ │ OpenCodeDAO plugin • 15 tools • HostAdapter impl │ │
|
|
220
|
+
│ └───────────────────────────┬───────────────────────────┘ │
|
|
221
|
+
│ │ │
|
|
222
|
+
│ ┌───────────────────────────┴───────────────────────────┐ │
|
|
223
|
+
│ │ @guyghost/swarm-dao-core │ │
|
|
224
|
+
│ │ ┌──────────┐ ┌────────────┐ ┌──────────┐ ┌────────┐ │ │
|
|
225
|
+
│ │ │Governance│ │Intelligence│ │ Delivery │ │Control │ │ │
|
|
226
|
+
│ │ │ (L1) │ │ (L2) │ │ (L3) │ │ (L4) │ │ │
|
|
227
|
+
│ │ └──────────┘ └────────────┘ └──────────┘ └────────┘ │ │
|
|
228
|
+
│ └───────────────────────────────────────────────────────┘ │
|
|
229
|
+
│ │ │
|
|
230
|
+
│ ┌───────────────────────────┴───────────────────────────┐ │
|
|
231
|
+
│ │ Persistence (.dao/ local files) │ │
|
|
232
|
+
│ └───────────────────────────────────────────────────────┘ │
|
|
233
|
+
└─────────────────────────────────────────────────────────────┘
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Tool Reference
|
|
237
|
+
|
|
238
|
+
| Tool | Description |
|
|
239
|
+
|------|-------------|
|
|
240
|
+
| `dao_setup` | Initialize the DAO with 7 default product agents |
|
|
241
|
+
| `dao_propose` | Create a new governance proposal |
|
|
242
|
+
| `dao_record_outputs` | Record sub-agent outputs and finalize deliberation |
|
|
243
|
+
| `dao_control` | Run quality control gates on an approved proposal |
|
|
244
|
+
| `dao_execute` | Execute an approved or controlled proposal |
|
|
245
|
+
| `dao_list` | List all DAO proposals |
|
|
246
|
+
| `dao_agents` | List all registered DAO agents |
|
|
247
|
+
| `dao_plan` | View the delivery plan for a proposal |
|
|
248
|
+
| `dao_artefacts` | View auto-generated artefacts (ADR, PRD, test plan, etc.) |
|
|
249
|
+
| `dao_dry_run` | Preview execution without applying changes |
|
|
250
|
+
| `dao_rollback` | Revert a proposal execution to pre-execution state |
|
|
251
|
+
| `dao_dashboard` | View the governance outcome dashboard with health score |
|
|
252
|
+
| `dao_roundtable` | Ask every agent to suggest a proposal idea |
|
|
253
|
+
| `dao_audit` | View the full audit trail or per-proposal trail |
|
|
254
|
+
| `dao_propose_amendment` | Propose a change to DAO agents, config, or gates |
|
|
255
|
+
|
|
256
|
+
## Proposal Lifecycle
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
open ──► deliberating ──► approved ──► controlled ──► executed
|
|
260
|
+
╲ ╲ ╲
|
|
261
|
+
rejected rejected failed
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Limitations
|
|
265
|
+
|
|
266
|
+
- **No automatic agent spawning** — OpenCode doesn't provide an API for spawning sub-agents. Use `dao_record_outputs` to manually submit outputs from sub-agent conversations.
|
|
267
|
+
- **Single-process** — All deliberation happens within the OpenCode plugin process. For large-scale parallel agent work, consider the CLI or Pi adapter.
|
|
268
|
+
|
|
269
|
+
## Related Packages
|
|
270
|
+
|
|
271
|
+
| Package | Description |
|
|
272
|
+
|---------|-------------|
|
|
273
|
+
| [`@guyghost/swarm-dao-core`](https://github.com/guyghost/swarm-dao/tree/main/packages/core) | Pure business logic (~3000 lines) |
|
|
274
|
+
| [`@guyghost/swarm-dao-pi-adapter`](https://github.com/guyghost/swarm-dao/tree/main/packages/pi-adapter) | Bridge to Pi coding agent |
|
|
275
|
+
| [`@guyghost/swarm-dao-opencode-adapter`](https://github.com/guyghost/swarm-dao/tree/main/packages/opencode-adapter) | Bridge to OpenCode (this package) |
|
|
276
|
+
| [`@guyghost/swarm-dao-cli`](https://github.com/guyghost/swarm-dao/tree/main/packages/cli) | Standalone CLI (`swarm-dao`) |
|
|
277
|
+
|
|
278
|
+
## License
|
|
279
|
+
|
|
280
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoDA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AA0D/D,eAAO,MAAM,WAAW,EAAE,MA8bzB,CAAC;AAEF,OAAO,EAAE,WAAW,IAAI,OAAO,EAAE,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Swarm DAO — OpenCode Adapter
|
|
3
|
+
// ============================================================
|
|
4
|
+
import { addVote, calculateCompositeScore, classifyRiskZone, computeHealthScore, createProposal, execCommand, executeProposal, formatAllArtefacts, formatAuditTrail, formatCompositeScore, formatControlResult, formatDryRun, formatHealthScore, formatPlan, formatRollback, formatRoundTableResults, formatTallyResult, generateAllArtefacts, generateDashboard, getAllAuditLog, getOrCreateState, getPlan, getProposal, getState, initializeAgents, initStorage, loadState, PROPOSAL_TYPES, parseVoteFromOutput, performDryRun, performRollback, readFileContained, recordAudit, runGates, runRoundTable, saveState, setState, storeAgentOutput, storeCompositeScore, storeSynthesis, synthesize, tallyVotes, transitionProposal, validateAmendmentPayload, writeFileContained, } from "@guyghost/swarm-dao-core";
|
|
5
|
+
import { tool } from "@opencode-ai/plugin";
|
|
6
|
+
const schema = tool.schema;
|
|
7
|
+
function formatAgentsTable(agents) {
|
|
8
|
+
let table = "| Agent | Weight | Role |\n|-------|--------|------|\n";
|
|
9
|
+
for (const agent of agents) {
|
|
10
|
+
table += `| ${agent.name} | ${agent.weight} | ${agent.role} |\n`;
|
|
11
|
+
}
|
|
12
|
+
return table;
|
|
13
|
+
}
|
|
14
|
+
function createOpenCodeHostAdapter(ctx) {
|
|
15
|
+
return {
|
|
16
|
+
hostId: "opencode",
|
|
17
|
+
async spawnAgent(params) {
|
|
18
|
+
return {
|
|
19
|
+
agentId: params.agent.id,
|
|
20
|
+
agentName: params.agent.name,
|
|
21
|
+
role: params.agent.role,
|
|
22
|
+
content: "",
|
|
23
|
+
durationMs: 0,
|
|
24
|
+
error: "OpenCode agent spawning requires manual dispatch via task tool",
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
async spawnAgents(_params) {
|
|
28
|
+
return [];
|
|
29
|
+
},
|
|
30
|
+
async log(params) {
|
|
31
|
+
try {
|
|
32
|
+
await ctx.client.app.log({
|
|
33
|
+
service: params.service,
|
|
34
|
+
level: params.level,
|
|
35
|
+
message: params.message,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
console.log(`[${params.level}] ${params.service}: ${params.message}`);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
getWorkingDirectory() {
|
|
43
|
+
return ctx.directory;
|
|
44
|
+
},
|
|
45
|
+
async readFile(path) {
|
|
46
|
+
return readFileContained(path, this.getWorkingDirectory());
|
|
47
|
+
},
|
|
48
|
+
async writeFile(path, content) {
|
|
49
|
+
return writeFileContained(path, content, this.getWorkingDirectory());
|
|
50
|
+
},
|
|
51
|
+
async exec(command, options) {
|
|
52
|
+
return execCommand(command, options);
|
|
53
|
+
},
|
|
54
|
+
hasCapability(capability) {
|
|
55
|
+
return ["read_file", "write_file", "exec", "log"].includes(capability);
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export const OpenCodeDAO = async (ctx) => {
|
|
60
|
+
const { directory } = ctx;
|
|
61
|
+
await initStorage(directory);
|
|
62
|
+
const loaded = await loadState(directory);
|
|
63
|
+
if (!loaded) {
|
|
64
|
+
setState(getOrCreateState(directory));
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
tool: {
|
|
68
|
+
// ── dao_setup ────────────────────────────────────────
|
|
69
|
+
dao_setup: tool({
|
|
70
|
+
description: "Initialize the DAO with default 7 product agents",
|
|
71
|
+
args: {
|
|
72
|
+
useDefaults: schema.boolean({ description: "Use default agents (default: true)" }),
|
|
73
|
+
},
|
|
74
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
75
|
+
async execute(_args, context) {
|
|
76
|
+
const workDir = context.directory;
|
|
77
|
+
await initStorage(workDir);
|
|
78
|
+
const state = getOrCreateState(workDir);
|
|
79
|
+
if (state.initialized) {
|
|
80
|
+
return `DAO already initialized with ${state.agents.length} agents.`;
|
|
81
|
+
}
|
|
82
|
+
const agents = initializeAgents();
|
|
83
|
+
state.agents = agents;
|
|
84
|
+
state.initialized = true;
|
|
85
|
+
await saveState();
|
|
86
|
+
return `# DAO Initialized\n\n${formatAgentsTable(agents)}\n\nRun \`dao_propose\` to create proposals.`;
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
89
|
+
// ── dao_propose ──────────────────────────────────────
|
|
90
|
+
dao_propose: tool({
|
|
91
|
+
description: "Create a new DAO proposal",
|
|
92
|
+
args: {
|
|
93
|
+
title: schema.string(),
|
|
94
|
+
type: schema.enum(PROPOSAL_TYPES, { description: "Proposal type" }),
|
|
95
|
+
description: schema.string(),
|
|
96
|
+
context: schema.string().describe("Additional context").optional(),
|
|
97
|
+
problemStatement: schema.string().describe("What problem does this solve?").optional(),
|
|
98
|
+
acceptanceCriteria: schema.array(schema.string()).describe("Acceptance criteria").optional(),
|
|
99
|
+
successMetrics: schema.array(schema.string()).describe("Success metrics").optional(),
|
|
100
|
+
rollbackConditions: schema.array(schema.string()).describe("Rollback conditions").optional(),
|
|
101
|
+
affectedPaths: schema.array(schema.string()).describe("File paths authorized for editing").optional(),
|
|
102
|
+
},
|
|
103
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
104
|
+
async execute(args, _context) {
|
|
105
|
+
const state = getState();
|
|
106
|
+
if (!state.initialized)
|
|
107
|
+
return "DAO not initialized.";
|
|
108
|
+
const proposal = await createProposal(args.title, args.type, args.description, "user", args.context);
|
|
109
|
+
if (args.problemStatement !== undefined)
|
|
110
|
+
proposal.problemStatement = args.problemStatement;
|
|
111
|
+
if (args.acceptanceCriteria !== undefined)
|
|
112
|
+
proposal.acceptanceCriteria = args.acceptanceCriteria;
|
|
113
|
+
if (args.successMetrics !== undefined)
|
|
114
|
+
proposal.successMetrics = args.successMetrics;
|
|
115
|
+
if (args.rollbackConditions !== undefined)
|
|
116
|
+
proposal.rollbackConditions = args.rollbackConditions;
|
|
117
|
+
if (args.affectedPaths !== undefined)
|
|
118
|
+
proposal.affectedPaths = args.affectedPaths;
|
|
119
|
+
const zone = classifyRiskZone(proposal);
|
|
120
|
+
proposal.riskZone = zone;
|
|
121
|
+
await saveState();
|
|
122
|
+
await recordAudit(proposal.id, "governance", "proposal_created", "user", `Proposal "${args.title}" created`);
|
|
123
|
+
await saveState();
|
|
124
|
+
return `# 📋 Proposal Created — #${proposal.id}\n\n**Title:** ${args.title}\n**Type:** ${args.type}\n**Zone:** ${zone}\n\nRun \`dao_deliberate proposalId=${proposal.id}\``;
|
|
125
|
+
},
|
|
126
|
+
}),
|
|
127
|
+
// ── dao_record_outputs ───────────────────────────────
|
|
128
|
+
dao_record_outputs: tool({
|
|
129
|
+
description: "Record sub-agent outputs and finalize deliberation",
|
|
130
|
+
args: {
|
|
131
|
+
proposalId: schema.number(),
|
|
132
|
+
outputs: schema.array(schema.object({
|
|
133
|
+
agentId: schema.string(),
|
|
134
|
+
content: schema.string(),
|
|
135
|
+
durationMs: schema.number(),
|
|
136
|
+
error: schema.string(),
|
|
137
|
+
}), { description: "Outputs from each sub-agent" }),
|
|
138
|
+
},
|
|
139
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
140
|
+
async execute(args, _context) {
|
|
141
|
+
const state = getState();
|
|
142
|
+
if (!state.initialized)
|
|
143
|
+
return "DAO not initialized.";
|
|
144
|
+
const proposal = getProposal(args.proposalId);
|
|
145
|
+
if (!proposal)
|
|
146
|
+
return `Proposal #${args.proposalId} not found.`;
|
|
147
|
+
if (proposal.status !== "deliberating")
|
|
148
|
+
return `Expected deliberating (current: ${proposal.status})`;
|
|
149
|
+
const votes = [];
|
|
150
|
+
const enrichedOutputs = [];
|
|
151
|
+
for (const raw of args.outputs) {
|
|
152
|
+
const agent = state.agents.find((a) => a.id === raw.agentId);
|
|
153
|
+
if (!agent)
|
|
154
|
+
continue;
|
|
155
|
+
const output = {
|
|
156
|
+
agentId: agent.id,
|
|
157
|
+
agentName: agent.name,
|
|
158
|
+
role: agent.role,
|
|
159
|
+
content: raw.content || "",
|
|
160
|
+
durationMs: raw.durationMs ?? 0,
|
|
161
|
+
error: raw.error,
|
|
162
|
+
};
|
|
163
|
+
const vote = parseVoteFromOutput(agent.id, agent.name, agent.weight, output.content);
|
|
164
|
+
if (vote) {
|
|
165
|
+
output.vote = vote;
|
|
166
|
+
votes.push(vote);
|
|
167
|
+
await addVote(proposal.id, vote);
|
|
168
|
+
}
|
|
169
|
+
await storeAgentOutput(proposal.id, output);
|
|
170
|
+
enrichedOutputs.push(output);
|
|
171
|
+
}
|
|
172
|
+
proposal.votes = votes;
|
|
173
|
+
const compositeScore = calculateCompositeScore(enrichedOutputs);
|
|
174
|
+
proposal.compositeScore = compositeScore;
|
|
175
|
+
await storeCompositeScore(proposal.id, compositeScore);
|
|
176
|
+
const synthesisText = synthesize(proposal, state.agents, enrichedOutputs);
|
|
177
|
+
proposal.synthesis = synthesisText;
|
|
178
|
+
await storeSynthesis(proposal.id, synthesisText);
|
|
179
|
+
const tally = tallyVotes(proposal, state.config);
|
|
180
|
+
if (tally.approved) {
|
|
181
|
+
transitionProposal(proposal, "approve");
|
|
182
|
+
await recordAudit(proposal.id, "intelligence", "deliberation_approved", "system", `Approved: ${tally.approvalScore}%`);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
transitionProposal(proposal, "reject");
|
|
186
|
+
await recordAudit(proposal.id, "intelligence", "deliberation_rejected", "system", `Rejected: ${tally.approvalScore}%`);
|
|
187
|
+
}
|
|
188
|
+
await saveState();
|
|
189
|
+
return `# 🗳️ Deliberation Complete — #${proposal.id}\n\n${formatTallyResult(tally)}\n\n${formatCompositeScore(compositeScore)}\n\n${synthesisText}\n\n> Next: \`dao_control proposalId=${proposal.id}\``;
|
|
190
|
+
},
|
|
191
|
+
}),
|
|
192
|
+
// ── dao_control ──────────────────────────────────────
|
|
193
|
+
dao_control: tool({
|
|
194
|
+
description: "Run quality control gates",
|
|
195
|
+
args: { proposalId: schema.number() },
|
|
196
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
197
|
+
async execute(args, _context) {
|
|
198
|
+
const state = getState();
|
|
199
|
+
if (!state.initialized)
|
|
200
|
+
return "DAO not initialized.";
|
|
201
|
+
const proposal = getProposal(args.proposalId);
|
|
202
|
+
if (!proposal)
|
|
203
|
+
return `Proposal #${args.proposalId} not found.`;
|
|
204
|
+
if (proposal.status !== "approved")
|
|
205
|
+
return `Must be approved (current: ${proposal.status})`;
|
|
206
|
+
const result = runGates(proposal, state.config);
|
|
207
|
+
if (result.allGatesPassed) {
|
|
208
|
+
transitionProposal(proposal, "control");
|
|
209
|
+
await recordAudit(proposal.id, "control", "gates_passed", "system", "All gates passed");
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
await recordAudit(proposal.id, "control", "gates_failed", "system", `${result.blockerCount} blockers`);
|
|
213
|
+
}
|
|
214
|
+
await saveState();
|
|
215
|
+
return formatControlResult(result);
|
|
216
|
+
},
|
|
217
|
+
}),
|
|
218
|
+
// ── dao_execute ──────────────────────────────────────
|
|
219
|
+
dao_execute: tool({
|
|
220
|
+
description: "Execute an approved or controlled proposal",
|
|
221
|
+
args: { proposalId: schema.number() },
|
|
222
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
223
|
+
async execute(args, _context) {
|
|
224
|
+
const _state = getState();
|
|
225
|
+
const proposal = getProposal(args.proposalId);
|
|
226
|
+
if (!proposal)
|
|
227
|
+
return `Proposal #${args.proposalId} not found.`;
|
|
228
|
+
if (proposal.status !== "controlled") {
|
|
229
|
+
return `Must be controlled (current: ${proposal.status}). Run dao_control first.`;
|
|
230
|
+
}
|
|
231
|
+
const result = await executeProposal(proposal);
|
|
232
|
+
await saveState();
|
|
233
|
+
await recordAudit(proposal.id, "delivery", "proposal_executed", "user", `Executed #${proposal.id}`);
|
|
234
|
+
await saveState();
|
|
235
|
+
return result.result;
|
|
236
|
+
},
|
|
237
|
+
}),
|
|
238
|
+
// ── dao_list ─────────────────────────────────────────
|
|
239
|
+
dao_list: tool({
|
|
240
|
+
description: "List all DAO proposals",
|
|
241
|
+
args: {},
|
|
242
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
243
|
+
async execute(_args, _context) {
|
|
244
|
+
const state = getState();
|
|
245
|
+
if (!state.initialized)
|
|
246
|
+
return "DAO not initialized.";
|
|
247
|
+
if (state.proposals.length === 0)
|
|
248
|
+
return "No proposals yet.";
|
|
249
|
+
let output = "# DAO Proposals\n\n";
|
|
250
|
+
for (const p of state.proposals) {
|
|
251
|
+
output += `## #${p.id}: ${p.title}\n${p.status} · ${p.type}\n\n`;
|
|
252
|
+
}
|
|
253
|
+
return output;
|
|
254
|
+
},
|
|
255
|
+
}),
|
|
256
|
+
// ── dao_agents ───────────────────────────────────────
|
|
257
|
+
dao_agents: tool({
|
|
258
|
+
description: "List all DAO agents",
|
|
259
|
+
args: {},
|
|
260
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
261
|
+
async execute(_args, _context) {
|
|
262
|
+
const state = getState();
|
|
263
|
+
if (!state.initialized)
|
|
264
|
+
return "DAO not initialized.";
|
|
265
|
+
return `# DAO Agents\n\n${formatAgentsTable(state.agents)}`;
|
|
266
|
+
},
|
|
267
|
+
}),
|
|
268
|
+
// ── dao_plan ─────────────────────────────────────────
|
|
269
|
+
dao_plan: tool({
|
|
270
|
+
description: "Get delivery plan",
|
|
271
|
+
args: { proposalId: schema.number() },
|
|
272
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
273
|
+
async execute(args, _context) {
|
|
274
|
+
const plan = getPlan(args.proposalId);
|
|
275
|
+
if (!plan)
|
|
276
|
+
return "No plan yet. Run deliberation first.";
|
|
277
|
+
return formatPlan(plan);
|
|
278
|
+
},
|
|
279
|
+
}),
|
|
280
|
+
// ── dao_artefacts ────────────────────────────────────
|
|
281
|
+
dao_artefacts: tool({
|
|
282
|
+
description: "View auto-generated artefacts for a proposal",
|
|
283
|
+
args: { proposalId: schema.number() },
|
|
284
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
285
|
+
async execute(args, _context) {
|
|
286
|
+
const proposal = getProposal(args.proposalId);
|
|
287
|
+
if (!proposal)
|
|
288
|
+
return `Proposal #${args.proposalId} not found.`;
|
|
289
|
+
const artefacts = generateAllArtefacts(proposal);
|
|
290
|
+
return formatAllArtefacts(artefacts);
|
|
291
|
+
},
|
|
292
|
+
}),
|
|
293
|
+
// ── dao_dry_run ──────────────────────────────────────
|
|
294
|
+
dao_dry_run: tool({
|
|
295
|
+
description: "Preview execution without applying changes",
|
|
296
|
+
args: { proposalId: schema.number() },
|
|
297
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
298
|
+
async execute(args, _context) {
|
|
299
|
+
const proposal = getProposal(args.proposalId);
|
|
300
|
+
if (!proposal)
|
|
301
|
+
return `Proposal #${args.proposalId} not found.`;
|
|
302
|
+
const result = await performDryRun(proposal);
|
|
303
|
+
proposal.dryRunAt = new Date().toISOString();
|
|
304
|
+
proposal.dryRunCanProceed = result.canProceed;
|
|
305
|
+
await saveState();
|
|
306
|
+
return formatDryRun(result);
|
|
307
|
+
},
|
|
308
|
+
}),
|
|
309
|
+
// ── dao_rollback ─────────────────────────────────────
|
|
310
|
+
dao_rollback: tool({
|
|
311
|
+
description: "Revert proposal execution to pre-execution snapshot",
|
|
312
|
+
args: { proposalId: schema.number() },
|
|
313
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
314
|
+
async execute(args, _context) {
|
|
315
|
+
const result = await performRollback(args.proposalId);
|
|
316
|
+
return formatRollback(result);
|
|
317
|
+
},
|
|
318
|
+
}),
|
|
319
|
+
// ── dao_dashboard ────────────────────────────────────
|
|
320
|
+
dao_dashboard: tool({
|
|
321
|
+
description: "View outcome tracking dashboard",
|
|
322
|
+
args: {},
|
|
323
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
324
|
+
async execute(_args, _context) {
|
|
325
|
+
const state = getState();
|
|
326
|
+
if (!state.initialized)
|
|
327
|
+
return "DAO not initialized.";
|
|
328
|
+
const dashboard = generateDashboard(state.proposals, state.outcomes, state.agents, state.healthSnapshots);
|
|
329
|
+
const health = computeHealthScore(state.proposals, state.outcomes, state.config.healthWeights);
|
|
330
|
+
return `${dashboard}\n\n${formatHealthScore(health)}`;
|
|
331
|
+
},
|
|
332
|
+
}),
|
|
333
|
+
// ── dao_roundtable ───────────────────────────────────
|
|
334
|
+
dao_roundtable: tool({
|
|
335
|
+
description: "Ask every agent to suggest a proposal idea",
|
|
336
|
+
args: {},
|
|
337
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
338
|
+
async execute(_args, _context) {
|
|
339
|
+
const state = getState();
|
|
340
|
+
if (!state.initialized)
|
|
341
|
+
return "DAO not initialized.";
|
|
342
|
+
const adapter = createOpenCodeHostAdapter(ctx);
|
|
343
|
+
const suggestions = await runRoundTable(adapter, state.agents, state.config.maxConcurrent);
|
|
344
|
+
const proposalIds = new Map();
|
|
345
|
+
for (const s of suggestions) {
|
|
346
|
+
if (!s.parsed)
|
|
347
|
+
continue;
|
|
348
|
+
try {
|
|
349
|
+
const proposal = await createProposal(s.parsed.title, s.parsed.type, s.parsed.description, s.agentId);
|
|
350
|
+
proposal.riskZone = classifyRiskZone(proposal);
|
|
351
|
+
s.proposalId = proposal.id;
|
|
352
|
+
proposalIds.set(s.agentId, proposal.id);
|
|
353
|
+
await recordAudit(proposal.id, "intelligence", "roundtable_proposal_created", s.agentId, `Auto-created from round table`);
|
|
354
|
+
// biome-ignore lint/suspicious/noExplicitAny: third-party error type unknown
|
|
355
|
+
}
|
|
356
|
+
catch (err) {
|
|
357
|
+
s.error = `Failed to create proposal: ${err?.message ?? err}`;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
await saveState();
|
|
361
|
+
return formatRoundTableResults(suggestions, proposalIds);
|
|
362
|
+
},
|
|
363
|
+
}),
|
|
364
|
+
// ── dao_audit ────────────────────────────────────────
|
|
365
|
+
dao_audit: tool({
|
|
366
|
+
description: "View audit trail",
|
|
367
|
+
args: { proposalId: schema.number({ description: "Optional proposal ID" }) },
|
|
368
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
369
|
+
async execute(args, _context) {
|
|
370
|
+
const entries = args.proposalId
|
|
371
|
+
? getAllAuditLog().filter((e) => e.proposalId === args.proposalId)
|
|
372
|
+
: getAllAuditLog();
|
|
373
|
+
return formatAuditTrail(entries, args.proposalId);
|
|
374
|
+
},
|
|
375
|
+
}),
|
|
376
|
+
// ── dao_propose_amendment ────────────────────────────
|
|
377
|
+
dao_propose_amendment: tool({
|
|
378
|
+
description: "Propose an amendment to the DAO",
|
|
379
|
+
args: {
|
|
380
|
+
title: schema.string(),
|
|
381
|
+
description: schema.string(),
|
|
382
|
+
amendmentType: schema.enum([
|
|
383
|
+
"agent-update",
|
|
384
|
+
"agent-add",
|
|
385
|
+
"agent-remove",
|
|
386
|
+
"config-update",
|
|
387
|
+
"quorum-update",
|
|
388
|
+
"gate-update",
|
|
389
|
+
]),
|
|
390
|
+
agentId: schema.string(),
|
|
391
|
+
agentChanges: schema.string(),
|
|
392
|
+
newAgentId: schema.string(),
|
|
393
|
+
newAgentName: schema.string(),
|
|
394
|
+
newAgentRole: schema.string(),
|
|
395
|
+
newAgentWeight: schema.number(),
|
|
396
|
+
configChanges: schema.string(),
|
|
397
|
+
quorumChanges: schema.string(),
|
|
398
|
+
addGates: schema.array(schema.string()),
|
|
399
|
+
removeGates: schema.array(schema.string()),
|
|
400
|
+
},
|
|
401
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK callback signature
|
|
402
|
+
async execute(args, _context) {
|
|
403
|
+
const state = getState();
|
|
404
|
+
if (!state.initialized)
|
|
405
|
+
return "DAO not initialized.";
|
|
406
|
+
let payload;
|
|
407
|
+
try {
|
|
408
|
+
switch (args.amendmentType) {
|
|
409
|
+
case "agent-update":
|
|
410
|
+
payload = { type: "agent-update", agentId: args.agentId, changes: JSON.parse(args.agentChanges) };
|
|
411
|
+
break;
|
|
412
|
+
case "agent-add":
|
|
413
|
+
payload = {
|
|
414
|
+
type: "agent-add",
|
|
415
|
+
agent: {
|
|
416
|
+
id: args.newAgentId,
|
|
417
|
+
name: args.newAgentName,
|
|
418
|
+
role: args.newAgentRole,
|
|
419
|
+
weight: args.newAgentWeight,
|
|
420
|
+
description: "Custom agent",
|
|
421
|
+
systemPrompt: "",
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
break;
|
|
425
|
+
case "agent-remove":
|
|
426
|
+
payload = { type: "agent-remove", agentId: args.agentId };
|
|
427
|
+
break;
|
|
428
|
+
case "config-update":
|
|
429
|
+
payload = { type: "config-update", changes: JSON.parse(args.configChanges) };
|
|
430
|
+
break;
|
|
431
|
+
case "quorum-update":
|
|
432
|
+
payload = { type: "quorum-update", typeQuorum: JSON.parse(args.quorumChanges) };
|
|
433
|
+
break;
|
|
434
|
+
case "gate-update":
|
|
435
|
+
payload = { type: "gate-update", addGates: args.addGates, removeGates: args.removeGates };
|
|
436
|
+
break;
|
|
437
|
+
default:
|
|
438
|
+
return `Error: Unknown amendment type "${args.amendmentType}"`;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
catch (err) {
|
|
442
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
443
|
+
return `Error: ${message}`;
|
|
444
|
+
}
|
|
445
|
+
const validation = validateAmendmentPayload(payload);
|
|
446
|
+
if (!validation.valid)
|
|
447
|
+
return `❌ Validation failed:\n${validation.errors.join("\n")}`;
|
|
448
|
+
const proposal = await createProposal(args.title, "governance-change", args.description, "user");
|
|
449
|
+
proposal.amendmentPayload = payload;
|
|
450
|
+
proposal.amendmentOrigin = { source: "human" };
|
|
451
|
+
proposal.amendmentState = "pending-vote";
|
|
452
|
+
proposal.riskZone = classifyRiskZone(proposal);
|
|
453
|
+
await saveState();
|
|
454
|
+
await recordAudit(proposal.id, "governance", "amendment_proposed", "user", `Amendment: ${payload.type}`);
|
|
455
|
+
await saveState();
|
|
456
|
+
return `# 📜 Amendment Proposed — #${proposal.id}\n\nType: ${payload.type}\n\nRun \`dao_deliberate proposalId=${proposal.id}\``;
|
|
457
|
+
},
|
|
458
|
+
}),
|
|
459
|
+
},
|
|
460
|
+
};
|
|
461
|
+
};
|
|
462
|
+
export { OpenCodeDAO as default };
|
|
463
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+BAA+B;AAC/B,+DAA+D;AAG/D,OAAO,EACL,OAAO,EACP,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,aAAa,EACb,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,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F,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,mBAAmB,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;oBACjG,QAAQ,CAAC,gBAAgB,GAAG,OAAO,CAAC;oBACpC,QAAQ,CAAC,eAAe,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;oBAC/C,QAAQ,CAAC,cAAc,GAAG,cAAc,CAAC;oBACzC,QAAQ,CAAC,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;oBAC/C,MAAM,SAAS,EAAE,CAAC;oBAElB,MAAM,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,EAAE,cAAc,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;oBACzG,MAAM,SAAS,EAAE,CAAC;oBAElB,OAAO,8BAA8B,QAAQ,CAAC,EAAE,aAAa,OAAO,CAAC,IAAI,uCAAuC,QAAQ,CAAC,EAAE,IAAI,CAAC;gBAClI,CAAC;aACF,CAAC;SACH;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,WAAW,IAAI,OAAO,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@guyghost/swarm-dao-opencode-adapter",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Swarm DAO governance adapter for OpenCode — multi-agent deliberation, quality gates, and structured decision-making",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"test": "bun test",
|
|
22
|
+
"lint": "biome check .",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"prepublishOnly": "bun run build"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@guyghost/swarm-dao-core": "^0.1.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@opencode-ai/plugin": ">=1.14.19"
|
|
31
|
+
},
|
|
32
|
+
"peerDependenciesMeta": {
|
|
33
|
+
"@opencode-ai/plugin": {
|
|
34
|
+
"optional": true
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/bun": "latest"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"swarm-dao",
|
|
42
|
+
"opencode",
|
|
43
|
+
"opencode-plugin",
|
|
44
|
+
"dao",
|
|
45
|
+
"governance",
|
|
46
|
+
"multi-agent",
|
|
47
|
+
"deliberation",
|
|
48
|
+
"ai-agents",
|
|
49
|
+
"quality-gates"
|
|
50
|
+
],
|
|
51
|
+
"author": "guyghost",
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+https://github.com/guyghost/swarm-dao.git",
|
|
56
|
+
"directory": "packages/opencode-adapter"
|
|
57
|
+
},
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "https://github.com/guyghost/swarm-dao/issues"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://github.com/guyghost/swarm-dao#readme",
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public"
|
|
64
|
+
}
|
|
65
|
+
}
|