@guyghost/swarm-dao-pi-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 +183 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +504 -0
- package/dist/index.js.map +1 -0
- package/package.json +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# @guyghost/swarm-dao-pi-adapter
|
|
2
|
+
|
|
3
|
+
> Bridge [Swarm DAO](https://github.com/guyghost/swarm-dao) governance to the [Pi Coding Agent](https://github.com/earendil-works/pi-coding-agent).
|
|
4
|
+
|
|
5
|
+
This package exports a Pi extension that registers tools, commands, and event hooks so any Pi user can run multi-agent governance directly inside their coding session.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
### As a dependency
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Add the adapter and its peer dependencies
|
|
13
|
+
bun add @guyghost/swarm-dao-pi-adapter typebox
|
|
14
|
+
bun add --peer @earendil-works/pi-coding-agent @earendil-works/pi-ai
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Register with Pi
|
|
18
|
+
|
|
19
|
+
Create or edit `.pi/extensions/swarm-dao.ts` in your project:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import swarmDaoExtension from "@guyghost/swarm-dao-pi-adapter";
|
|
23
|
+
|
|
24
|
+
export default swarmDaoExtension;
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Alternatively, point Pi at the built file via `package.json`:
|
|
28
|
+
|
|
29
|
+
```jsonc
|
|
30
|
+
{
|
|
31
|
+
"pi": {
|
|
32
|
+
"extensions": ["./node_modules/@guyghost/swarm-dao-pi-adapter/dist/index.js"]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
### Quick Start
|
|
40
|
+
|
|
41
|
+
Once Pi starts, the extension automatically:
|
|
42
|
+
|
|
43
|
+
1. **Restores state** on `session_start` — loads `.dao/` from your project root
|
|
44
|
+
2. **Injects context** on `before_agent_start` — appends DAO status to the system prompt
|
|
45
|
+
|
|
46
|
+
Inside Pi, use any of the registered tools or the `/dao` command:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
> dao_setup # Initialize with 7 default agents
|
|
50
|
+
> dao_propose title="Add dark mode" # Create a proposal
|
|
51
|
+
type="product-feature"
|
|
52
|
+
description="Implement dark mode toggle"
|
|
53
|
+
> dao_deliberate proposalId=1 # Run swarm deliberation
|
|
54
|
+
> dao_check proposalId=1 # Quality control gates
|
|
55
|
+
> dao_execute proposalId=1 # Execute approved proposal
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Tools
|
|
59
|
+
|
|
60
|
+
All tools are registered as MCP tools and can be invoked by the LLM or manually.
|
|
61
|
+
|
|
62
|
+
| Tool | Description | Key Parameters |
|
|
63
|
+
|------|-------------|----------------|
|
|
64
|
+
| `dao_setup` | Initialize the DAO with 7 default agents | `useDefaults?: boolean` |
|
|
65
|
+
| `dao_propose` | Create a new governance proposal | `title`, `type`, `description`, `context?`, `problemStatement?`, `acceptanceCriteria?`, `successMetrics?`, `rollbackConditions?`, `affectedPaths?` |
|
|
66
|
+
| `dao_deliberate` | Run swarm deliberation on a proposal | `proposalId` |
|
|
67
|
+
| `dao_check` | Run quality control gates on an approved proposal | `proposalId` |
|
|
68
|
+
| `dao_plan` | View the delivery plan for a proposal | `proposalId` |
|
|
69
|
+
| `dao_execute` | Execute a controlled/approved proposal | `proposalId` |
|
|
70
|
+
| `dao_audit` | View the audit trail (optionally filtered by proposal) | `proposalId?` |
|
|
71
|
+
| `dao_artefacts` | View auto-generated artefacts (ADR, risk report, PRD, etc.) | `proposalId` |
|
|
72
|
+
| `dao_rate` | Rate a proposal outcome post-execution (1–5 stars) | `proposalId`, `score`, `comment` |
|
|
73
|
+
| `dao_dashboard` | View outcome tracking dashboard and health score | *(none)* |
|
|
74
|
+
| `dao_dry_run` | Preview execution without applying changes | `proposalId` |
|
|
75
|
+
| `dao_rollback` | Revert a proposal to its pre-execution snapshot | `proposalId` |
|
|
76
|
+
| `dao_roundtable` | Ask every agent to suggest a proposal idea | *(none)* |
|
|
77
|
+
| `dao_update_proposal` | Update structured fields on an open proposal | `proposalId`, `problemStatement?`, `acceptanceCriteria?`, `successMetrics?`, `rollbackConditions?` |
|
|
78
|
+
|
|
79
|
+
### Commands
|
|
80
|
+
|
|
81
|
+
| Command | Description |
|
|
82
|
+
|---------|-------------|
|
|
83
|
+
| `/dao` | Show the DAO dashboard — agent count, proposal counts by status |
|
|
84
|
+
|
|
85
|
+
### Event Hooks
|
|
86
|
+
|
|
87
|
+
| Event | When | What it does |
|
|
88
|
+
|-------|------|--------------|
|
|
89
|
+
| `session_start` | Pi session begins | Initializes `.dao/` storage, loads or creates state |
|
|
90
|
+
| `before_agent_start` | Before each LLM turn | Injects DAO status into the system prompt so the agent is context-aware |
|
|
91
|
+
|
|
92
|
+
## Proposal Types
|
|
93
|
+
|
|
94
|
+
Proposals are categorized and routed through type-specific councils and quorum rules:
|
|
95
|
+
|
|
96
|
+
| Type | Label | Default Quorum |
|
|
97
|
+
|------|-------|----------------|
|
|
98
|
+
| `product-feature` | ✨ Product Feature | 60% |
|
|
99
|
+
| `security-change` | 🔒 Security Change | 75% |
|
|
100
|
+
| `technical-change` | ⚙️ Technical Change | 60% |
|
|
101
|
+
| `release-change` | 📦 Release Change | 50% |
|
|
102
|
+
| `governance-change` | 📜 Governance Change | 70% |
|
|
103
|
+
|
|
104
|
+
## Architecture
|
|
105
|
+
|
|
106
|
+
The adapter bridges Pi to the Swarm DAO core's **4-layer governance model**:
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
┌─────────────────────────────────────────────────────────┐
|
|
110
|
+
│ Pi Coding Agent │
|
|
111
|
+
│ ┌─────────────────────────────────────────────────┐ │
|
|
112
|
+
│ │ swarm-dao-pi-adapter (this package) │ │
|
|
113
|
+
│ │ • Registers tools, commands, event hooks │ │
|
|
114
|
+
│ │ • Implements HostAdapter for Pi's agent runner │ │
|
|
115
|
+
│ └──────────────────────┬──────────────────────────┘ │
|
|
116
|
+
└─────────────────────────┼───────────────────────────────┘
|
|
117
|
+
│
|
|
118
|
+
┌─────────────────────────┼───────────────────────────────┐
|
|
119
|
+
│ @guyghost/swarm-dao-core │
|
|
120
|
+
│ │
|
|
121
|
+
│ L1 Governance ── L2 Intelligence ── L3 Delivery │
|
|
122
|
+
│ Proposals Deliberation Execution │
|
|
123
|
+
│ Voting Scoring Plans │
|
|
124
|
+
│ Lifecycle Synthesis Dry-run │
|
|
125
|
+
│ Round Table Rollback │
|
|
126
|
+
│ │
|
|
127
|
+
│ L4 Control ─────────────────────────────────────────── │
|
|
128
|
+
│ Quality Gates · Audit Trail · Checklists │
|
|
129
|
+
└─────────────────────────────────────────────────────────┘
|
|
130
|
+
│
|
|
131
|
+
┌─────────────────────────┼───────────────────────────────┐
|
|
132
|
+
│ Persistence (.dao/) │
|
|
133
|
+
│ state.json · audit.json · scores.json · artefacts/ │
|
|
134
|
+
└─────────────────────────────────────────────────────────┘
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Host Adapter
|
|
138
|
+
|
|
139
|
+
The adapter implements the `HostAdapter` interface from `@guyghost/swarm-dao-core`:
|
|
140
|
+
|
|
141
|
+
| Method | Pi Implementation |
|
|
142
|
+
|--------|-------------------|
|
|
143
|
+
| `spawnAgent` | Returns a placeholder error — automatic agent spawning requires Pi's subprocess API |
|
|
144
|
+
| `spawnAgents` | Delegates to `spawnAgent` sequentially |
|
|
145
|
+
| `log` | Writes to `console.log` with structured format |
|
|
146
|
+
| `getWorkingDirectory` | Returns `process.cwd()` |
|
|
147
|
+
| `readFile` | Uses `node:fs/promises` |
|
|
148
|
+
| `writeFile` | Uses `node:fs/promises` |
|
|
149
|
+
| `exec` | Uses `node:child_process` |
|
|
150
|
+
| `hasCapability` | Reports `read_file`, `write_file`, `exec`, `log` |
|
|
151
|
+
|
|
152
|
+
> **Note on `spawnAgent`:** Automatic agent spawning is not yet wired to Pi's subprocess API. The adapter returns a descriptive error. Deliberation still works — it falls through to the manual flow where the host orchestrates agents. This is expected behavior and will be enhanced in a future release.
|
|
153
|
+
|
|
154
|
+
## Configuration
|
|
155
|
+
|
|
156
|
+
The DAO uses sensible defaults. To customize, modify `.dao/state.json` after initialization:
|
|
157
|
+
|
|
158
|
+
| Setting | Default | Description |
|
|
159
|
+
|---------|---------|-------------|
|
|
160
|
+
| `quorumPercent` | 60 | Minimum participation % |
|
|
161
|
+
| `approvalThreshold` | 55 | Minimum approval % |
|
|
162
|
+
| `riskThreshold` | 7 | Risk score threshold (1–10) |
|
|
163
|
+
| `maxConcurrent` | 4 | Max agents running in parallel |
|
|
164
|
+
|
|
165
|
+
## Development
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
# Install dependencies
|
|
169
|
+
bun install
|
|
170
|
+
|
|
171
|
+
# Build
|
|
172
|
+
cd packages/pi-adapter && bun run build
|
|
173
|
+
|
|
174
|
+
# Test
|
|
175
|
+
bun test
|
|
176
|
+
|
|
177
|
+
# Type-check only
|
|
178
|
+
bun run typecheck
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
MIT — see [LICENSE](../../LICENSE).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,iCAAiC,CAAC;AA6M7F,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EAAE,EAAE,YAAY,QA6dzD"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Swarm DAO — Pi Adapter
|
|
3
|
+
// ============================================================
|
|
4
|
+
// Bridges the Swarm DAO core to Pi's ExtensionAPI.
|
|
5
|
+
// Registers tools, commands, and event hooks.
|
|
6
|
+
import { StringEnum } from "@earendil-works/pi-ai";
|
|
7
|
+
import { addRating, addVote,
|
|
8
|
+
// Intelligence
|
|
9
|
+
buildDispatchInstructions, calculateCompositeScore,
|
|
10
|
+
// Lifecycle
|
|
11
|
+
classifyRiskZone,
|
|
12
|
+
// Health Score
|
|
13
|
+
computeHealthScore, createProposal, dispatchSwarm,
|
|
14
|
+
// Delivery
|
|
15
|
+
execCommand, executeProposal, formatAllArtefacts, formatAuditTrail, formatCompositeScore, formatControlResult, formatDryRun, formatHealthScore, formatPlan, formatRollback, formatRoundTableResults, formatTallyResult, generateAllArtefacts, generateDashboard, getAllAuditLog, getOrCreateState, getPlan, getProposal, getState,
|
|
16
|
+
// Governance
|
|
17
|
+
initializeAgents, initStorage,
|
|
18
|
+
// Persistence
|
|
19
|
+
loadState, PROPOSAL_TYPE_LABELS,
|
|
20
|
+
// Types
|
|
21
|
+
PROPOSAL_TYPES,
|
|
22
|
+
// Voting & Scoring
|
|
23
|
+
parseVoteFromOutput, performDryRun, performRollback, readFileContained, recordAudit,
|
|
24
|
+
// Control
|
|
25
|
+
runGates,
|
|
26
|
+
// Round Table
|
|
27
|
+
runRoundTable, saveState, setState, storeAgentOutput, storeCompositeScore, storeSynthesis, synthesize, tallyVotes, transitionProposal, writeFileContained, } from "@guyghost/swarm-dao-core";
|
|
28
|
+
import { Type } from "typebox";
|
|
29
|
+
// ── Pi Host Adapter Implementation ───────────────────────────
|
|
30
|
+
function createPiHostAdapter(_pi, _ctx) {
|
|
31
|
+
return {
|
|
32
|
+
hostId: "pi",
|
|
33
|
+
async spawnAgent(params) {
|
|
34
|
+
const startTime = Date.now();
|
|
35
|
+
// Pi-specific: spawn sub-agent via pi's agent runner
|
|
36
|
+
// This is a simplified version — full implementation uses pi's subprocess API
|
|
37
|
+
return {
|
|
38
|
+
agentId: params.agent.id,
|
|
39
|
+
agentName: params.agent.name,
|
|
40
|
+
role: params.agent.role,
|
|
41
|
+
content: "",
|
|
42
|
+
durationMs: Date.now() - startTime,
|
|
43
|
+
error: "Pi agent spawning not yet implemented in adapter — use manual deliberation",
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
async spawnAgents(params) {
|
|
47
|
+
const outputs = [];
|
|
48
|
+
for (const agent of params.agents) {
|
|
49
|
+
const output = await this.spawnAgent({ agent, proposal: params.proposal, systemPrompt: agent.systemPrompt });
|
|
50
|
+
outputs.push(output);
|
|
51
|
+
}
|
|
52
|
+
return outputs;
|
|
53
|
+
},
|
|
54
|
+
async log(params) {
|
|
55
|
+
console.log(`[${params.level}] ${params.service}: ${params.message}`);
|
|
56
|
+
},
|
|
57
|
+
getWorkingDirectory() {
|
|
58
|
+
return process.cwd();
|
|
59
|
+
},
|
|
60
|
+
async readFile(path) {
|
|
61
|
+
return readFileContained(path, this.getWorkingDirectory());
|
|
62
|
+
},
|
|
63
|
+
async writeFile(path, content) {
|
|
64
|
+
return writeFileContained(path, content, this.getWorkingDirectory());
|
|
65
|
+
},
|
|
66
|
+
async exec(command, options) {
|
|
67
|
+
return execCommand(command, options);
|
|
68
|
+
},
|
|
69
|
+
hasCapability(capability) {
|
|
70
|
+
const caps = ["read_file", "write_file", "exec", "log"];
|
|
71
|
+
return caps.includes(capability);
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// ── Tool Result Helper ───────────────────────────────────────
|
|
76
|
+
function toolResult(content) {
|
|
77
|
+
return {
|
|
78
|
+
content: [{ type: "text", text: content }],
|
|
79
|
+
details: {},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// ── Main Extension Export ────────────────────────────────────
|
|
83
|
+
export default function swarmDaoExtension(pi) {
|
|
84
|
+
// Restore state on session start
|
|
85
|
+
pi.on("session_start", async (_event, _ctx) => {
|
|
86
|
+
const cwd = process.cwd();
|
|
87
|
+
await initStorage(cwd);
|
|
88
|
+
const loaded = await loadState(cwd);
|
|
89
|
+
if (!loaded) {
|
|
90
|
+
setState(getOrCreateState(cwd));
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
});
|
|
94
|
+
// System prompt injection
|
|
95
|
+
pi.on("before_agent_start", async (event, _ctx) => {
|
|
96
|
+
const state = getState();
|
|
97
|
+
if (!state.initialized) {
|
|
98
|
+
return {
|
|
99
|
+
systemPrompt: event.systemPrompt +
|
|
100
|
+
"\n\n## Swarm DAO\nThe swarm-dao extension is loaded (4-layer architecture: Governance → Intelligence → Control → Delivery). Use `dao_setup` to initialize the DAO with default agents, or run `/dao` for the dashboard.",
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const agents = state.agents;
|
|
104
|
+
const totalWeight = agents.reduce((s, a) => s + a.weight, 0);
|
|
105
|
+
const agentList = agents.map((a) => `${a.name}[${a.weight}]`).join(", ");
|
|
106
|
+
const openProposals = state.proposals.filter((p) => p.status === "open" || p.status === "deliberating");
|
|
107
|
+
let daoContext = `\n\n## Swarm DAO Status (4-Layer: Governance → Intelligence → Control → Delivery)`;
|
|
108
|
+
daoContext += `\n- Active agents: ${agents.length} (${agentList}) — Total weight: ${totalWeight}`;
|
|
109
|
+
daoContext += `\n- Open proposals: ${openProposals.length}`;
|
|
110
|
+
if (openProposals.length > 0) {
|
|
111
|
+
for (const p of openProposals) {
|
|
112
|
+
daoContext += `\n - #${p.id} "${p.title}" (${p.type}) (${p.status})`;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
daoContext += `\n- Config: quorum=${state.config.quorumPercent}%, approval=${state.config.approvalThreshold}%, risk=${state.config.riskThreshold}/10`;
|
|
116
|
+
daoContext += `\n\nAvailable tools: dao_setup, dao_propose, dao_deliberate, dao_check, dao_plan, dao_execute, dao_audit, dao_artefacts, dao_verify, dao_rate, dao_dashboard, dao_dry_run, dao_rollback`;
|
|
117
|
+
return { systemPrompt: event.systemPrompt + daoContext };
|
|
118
|
+
});
|
|
119
|
+
// ── Tool: dao_setup ──────────────────────────────────────
|
|
120
|
+
pi.registerTool({
|
|
121
|
+
name: "dao_setup",
|
|
122
|
+
label: "DAO Setup",
|
|
123
|
+
description: "Initialize the DAO with 7 default agents",
|
|
124
|
+
parameters: Type.Object({
|
|
125
|
+
useDefaults: Type.Optional(Type.Boolean({ description: "Use default agents (default: true)" })),
|
|
126
|
+
}),
|
|
127
|
+
async execute(_id, params) {
|
|
128
|
+
const state = getState();
|
|
129
|
+
if (state.initialized) {
|
|
130
|
+
return toolResult(`DAO already initialized with ${state.agents.length} agents.`);
|
|
131
|
+
}
|
|
132
|
+
const agents = initializeAgents(params.useDefaults !== false ? undefined : []);
|
|
133
|
+
state.agents = agents;
|
|
134
|
+
state.initialized = true;
|
|
135
|
+
await saveState();
|
|
136
|
+
const table = agents.map((a) => `| ${a.name} | ${a.weight} | ${a.role} |`).join("\n");
|
|
137
|
+
return toolResult(`# DAO Initialized\n\n| Agent | Weight | Role |\n|-------|--------|------|\n${table}\n\nRun \`dao_propose\` to create proposals.`);
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
// ── Tool: dao_propose ────────────────────────────────────
|
|
141
|
+
pi.registerTool({
|
|
142
|
+
name: "dao_propose",
|
|
143
|
+
label: "DAO Propose",
|
|
144
|
+
description: "Create a new proposal",
|
|
145
|
+
parameters: Type.Object({
|
|
146
|
+
title: Type.String(),
|
|
147
|
+
type: StringEnum(PROPOSAL_TYPES),
|
|
148
|
+
description: Type.String(),
|
|
149
|
+
context: Type.Optional(Type.String()),
|
|
150
|
+
problemStatement: Type.Optional(Type.String()),
|
|
151
|
+
acceptanceCriteria: Type.Optional(Type.Array(Type.String())),
|
|
152
|
+
successMetrics: Type.Optional(Type.Array(Type.String())),
|
|
153
|
+
rollbackConditions: Type.Optional(Type.Array(Type.String())),
|
|
154
|
+
affectedPaths: Type.Optional(Type.Array(Type.String())),
|
|
155
|
+
}),
|
|
156
|
+
async execute(_id, params) {
|
|
157
|
+
const state = getState();
|
|
158
|
+
if (!state.initialized)
|
|
159
|
+
return toolResult("DAO not initialized. Run `dao_setup` first.");
|
|
160
|
+
const proposal = await createProposal(params.title, params.type, params.description, "user", params.context);
|
|
161
|
+
if (params.problemStatement !== undefined)
|
|
162
|
+
proposal.problemStatement = params.problemStatement;
|
|
163
|
+
if (params.acceptanceCriteria !== undefined)
|
|
164
|
+
proposal.acceptanceCriteria = params.acceptanceCriteria;
|
|
165
|
+
if (params.successMetrics !== undefined)
|
|
166
|
+
proposal.successMetrics = params.successMetrics;
|
|
167
|
+
if (params.rollbackConditions !== undefined)
|
|
168
|
+
proposal.rollbackConditions = params.rollbackConditions;
|
|
169
|
+
if (params.affectedPaths !== undefined)
|
|
170
|
+
proposal.affectedPaths = params.affectedPaths;
|
|
171
|
+
const zone = classifyRiskZone(proposal);
|
|
172
|
+
proposal.riskZone = zone;
|
|
173
|
+
await saveState();
|
|
174
|
+
await recordAudit(proposal.id, "governance", "proposal_created", "user", `Proposal "${params.title}" created`);
|
|
175
|
+
await saveState();
|
|
176
|
+
return toolResult(`# 📋 Proposal Created — #${proposal.id}\n\n**Title:** ${params.title}\n**Type:** ${PROPOSAL_TYPE_LABELS[params.type]}\n**Zone:** ${zone}\n\nRun \`dao_deliberate proposalId=${proposal.id}\` to deliberate.`);
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
// ── Tool: dao_deliberate ─────────────────────────────────
|
|
180
|
+
pi.registerTool({
|
|
181
|
+
name: "dao_deliberate",
|
|
182
|
+
label: "DAO Deliberate",
|
|
183
|
+
description: "Run swarm deliberation on a proposal",
|
|
184
|
+
parameters: Type.Object({
|
|
185
|
+
proposalId: Type.Number(),
|
|
186
|
+
}),
|
|
187
|
+
async execute(_id, params, _signal, onUpdate, ctx) {
|
|
188
|
+
const state = getState();
|
|
189
|
+
if (!state.initialized)
|
|
190
|
+
return toolResult("DAO not initialized.");
|
|
191
|
+
const proposal = getProposal(Number(params.proposalId));
|
|
192
|
+
if (!proposal)
|
|
193
|
+
return toolResult(`Proposal #${params.proposalId} not found.`);
|
|
194
|
+
if (proposal.status !== "open")
|
|
195
|
+
return toolResult(`Proposal #${proposal.id} is ${proposal.status}, must be open.`);
|
|
196
|
+
// Transition
|
|
197
|
+
const transition = transitionProposal(proposal, "deliberate");
|
|
198
|
+
if (!transition.success)
|
|
199
|
+
return toolResult(`Cannot deliberate: ${transition.error}`);
|
|
200
|
+
await recordAudit(proposal.id, "governance", "deliberation_started", "system", `Deliberation on #${proposal.id}`);
|
|
201
|
+
await saveState();
|
|
202
|
+
if (onUpdate) {
|
|
203
|
+
onUpdate({ content: [{ type: "text", text: `🗳️ Deliberating proposal #${proposal.id}...` }], details: {} });
|
|
204
|
+
}
|
|
205
|
+
const startTime = Date.now();
|
|
206
|
+
const adapter = createPiHostAdapter(pi, ctx);
|
|
207
|
+
// For Pi, we build instructions but let the host spawn agents
|
|
208
|
+
const _instructions = buildDispatchInstructions(proposal, state.agents);
|
|
209
|
+
// Attempt automatic dispatch if Pi supports it
|
|
210
|
+
const outputs = await dispatchSwarm(proposal, state.agents, adapter, state.config.maxConcurrent, (update) => {
|
|
211
|
+
if (onUpdate) {
|
|
212
|
+
onUpdate({
|
|
213
|
+
content: [{ type: "text", text: `${update.agentName}: ${update.phase}` }],
|
|
214
|
+
details: {},
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
// Parse votes
|
|
219
|
+
const votes = [];
|
|
220
|
+
for (const output of outputs) {
|
|
221
|
+
if (output.content) {
|
|
222
|
+
const vote = parseVoteFromOutput(output.agentId, output.agentName, state.agents.find((a) => a.id === output.agentId)?.weight ?? 1, output.content);
|
|
223
|
+
if (vote) {
|
|
224
|
+
vote.weight = state.agents.find((a) => a.id === output.agentId)?.weight ?? 1;
|
|
225
|
+
votes.push(vote);
|
|
226
|
+
await addVote(proposal.id, vote);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
await storeAgentOutput(proposal.id, output);
|
|
230
|
+
}
|
|
231
|
+
proposal.votes = votes;
|
|
232
|
+
// Composite score
|
|
233
|
+
const compositeScore = calculateCompositeScore(outputs);
|
|
234
|
+
proposal.compositeScore = compositeScore;
|
|
235
|
+
await storeCompositeScore(proposal.id, compositeScore);
|
|
236
|
+
// Synthesis
|
|
237
|
+
const tally = tallyVotes(proposal, state.config);
|
|
238
|
+
const synthesisText = synthesize(proposal, state.agents, outputs, tally);
|
|
239
|
+
proposal.synthesis = synthesisText;
|
|
240
|
+
await storeSynthesis(proposal.id, synthesisText);
|
|
241
|
+
// Final transition
|
|
242
|
+
if (tally.approved) {
|
|
243
|
+
transitionProposal(proposal, "approve");
|
|
244
|
+
await recordAudit(proposal.id, "intelligence", "deliberation_approved", "system", `Approved: ${tally.approvalScore}%`);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
transitionProposal(proposal, "reject");
|
|
248
|
+
await recordAudit(proposal.id, "intelligence", "deliberation_rejected", "system", `Rejected: ${tally.approvalScore}%`);
|
|
249
|
+
}
|
|
250
|
+
await saveState();
|
|
251
|
+
const duration = Date.now() - startTime;
|
|
252
|
+
return toolResult(`# 🗳️ Deliberation Complete — #${proposal.id} (${duration}ms)\n\n${formatTallyResult(tally)}\n\n${formatCompositeScore(compositeScore)}\n\n${synthesisText}\n\n> Next: \`dao_check proposalId=${proposal.id}\``);
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
// ── Tool: dao_check ──────────────────────────────────────
|
|
256
|
+
pi.registerTool({
|
|
257
|
+
name: "dao_check",
|
|
258
|
+
label: "DAO Check",
|
|
259
|
+
description: "Run quality control gates",
|
|
260
|
+
parameters: Type.Object({ proposalId: Type.Number() }),
|
|
261
|
+
async execute(_id, params) {
|
|
262
|
+
const state = getState();
|
|
263
|
+
if (!state.initialized)
|
|
264
|
+
return toolResult("DAO not initialized.");
|
|
265
|
+
const proposal = getProposal(params.proposalId);
|
|
266
|
+
if (!proposal)
|
|
267
|
+
return toolResult(`Proposal #${params.proposalId} not found.`);
|
|
268
|
+
if (proposal.status !== "approved")
|
|
269
|
+
return toolResult(`Must be approved (current: ${proposal.status})`);
|
|
270
|
+
const result = runGates(proposal, state.config);
|
|
271
|
+
if (result.allGatesPassed) {
|
|
272
|
+
transitionProposal(proposal, "control");
|
|
273
|
+
await recordAudit(proposal.id, "control", "gates_passed", "system", "All gates passed");
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
transitionProposal(proposal, "fail");
|
|
277
|
+
await recordAudit(proposal.id, "control", "gates_failed", "system", `${result.blockerCount} blockers`);
|
|
278
|
+
}
|
|
279
|
+
await saveState();
|
|
280
|
+
return toolResult(formatControlResult(result));
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
// ── Tool: dao_plan ───────────────────────────────────────
|
|
284
|
+
pi.registerTool({
|
|
285
|
+
name: "dao_plan",
|
|
286
|
+
label: "DAO Plan",
|
|
287
|
+
description: "Get delivery plan",
|
|
288
|
+
parameters: Type.Object({ proposalId: Type.Number() }),
|
|
289
|
+
async execute(_id, params) {
|
|
290
|
+
const plan = getPlan(params.proposalId);
|
|
291
|
+
if (!plan)
|
|
292
|
+
return toolResult("No plan yet. Run deliberation first.");
|
|
293
|
+
return toolResult(formatPlan(plan));
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
// ── Tool: dao_execute ────────────────────────────────────
|
|
297
|
+
pi.registerTool({
|
|
298
|
+
name: "dao_execute",
|
|
299
|
+
label: "DAO Execute",
|
|
300
|
+
description: "Execute a controlled proposal",
|
|
301
|
+
parameters: Type.Object({ proposalId: Type.Number() }),
|
|
302
|
+
async execute(_id, params) {
|
|
303
|
+
const _state = getState();
|
|
304
|
+
const proposal = getProposal(params.proposalId);
|
|
305
|
+
if (!proposal)
|
|
306
|
+
return toolResult(`Proposal #${params.proposalId} not found.`);
|
|
307
|
+
if (proposal.status !== "controlled") {
|
|
308
|
+
return toolResult(`Must be controlled (current: ${proposal.status}). Run dao_control first.`);
|
|
309
|
+
}
|
|
310
|
+
const result = await executeProposal(proposal);
|
|
311
|
+
await saveState();
|
|
312
|
+
await recordAudit(proposal.id, "delivery", "proposal_executed", "user", `Executed #${proposal.id}`);
|
|
313
|
+
await saveState();
|
|
314
|
+
return toolResult(result.result);
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
// ── Tool: dao_audit ──────────────────────────────────────
|
|
318
|
+
pi.registerTool({
|
|
319
|
+
name: "dao_audit",
|
|
320
|
+
label: "DAO Audit",
|
|
321
|
+
description: "View audit trail",
|
|
322
|
+
parameters: Type.Object({ proposalId: Type.Optional(Type.Number()) }),
|
|
323
|
+
async execute(_id, params) {
|
|
324
|
+
const entries = params.proposalId !== undefined
|
|
325
|
+
? getAllAuditLog().filter((e) => e.proposalId === params.proposalId)
|
|
326
|
+
: getAllAuditLog();
|
|
327
|
+
return toolResult(formatAuditTrail(entries, params.proposalId));
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
// ── Tool: dao_artefacts ─────────────────────────────────
|
|
331
|
+
pi.registerTool({
|
|
332
|
+
name: "dao_artefacts",
|
|
333
|
+
label: "DAO Artefacts",
|
|
334
|
+
description: "View auto-generated artefacts for a proposal",
|
|
335
|
+
parameters: Type.Object({ proposalId: Type.Number() }),
|
|
336
|
+
async execute(_id, params) {
|
|
337
|
+
const proposal = getProposal(Number(params.proposalId));
|
|
338
|
+
if (!proposal)
|
|
339
|
+
return toolResult(`Proposal #${params.proposalId} not found.`);
|
|
340
|
+
const artefacts = generateAllArtefacts(proposal);
|
|
341
|
+
return toolResult(formatAllArtefacts(artefacts));
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
// ── Tool: dao_rate ───────────────────────────────────────
|
|
345
|
+
pi.registerTool({
|
|
346
|
+
name: "dao_rate",
|
|
347
|
+
label: "DAO Rate",
|
|
348
|
+
description: "Rate a proposal outcome post-execution (1-5 stars)",
|
|
349
|
+
parameters: Type.Object({
|
|
350
|
+
proposalId: Type.Number(),
|
|
351
|
+
score: Type.Number({ minimum: 1, maximum: 5 }),
|
|
352
|
+
comment: Type.String(),
|
|
353
|
+
}),
|
|
354
|
+
async execute(_id, params) {
|
|
355
|
+
const proposal = getProposal(Number(params.proposalId));
|
|
356
|
+
if (!proposal)
|
|
357
|
+
return toolResult(`Proposal #${params.proposalId} not found.`);
|
|
358
|
+
if (proposal.status !== "executed")
|
|
359
|
+
return toolResult(`Proposal #${proposal.id} is ${proposal.status}, must be executed.`);
|
|
360
|
+
await addRating(proposal.id, {
|
|
361
|
+
proposalId: proposal.id,
|
|
362
|
+
rater: "user",
|
|
363
|
+
score: Number(params.score),
|
|
364
|
+
comment: params.comment,
|
|
365
|
+
ratedAt: new Date().toISOString(),
|
|
366
|
+
});
|
|
367
|
+
await saveState();
|
|
368
|
+
return toolResult(`# ⭐ Rating Recorded — #${proposal.id}\n\n**Score:** ${params.score}/5\n**Comment:** ${params.comment}`);
|
|
369
|
+
},
|
|
370
|
+
});
|
|
371
|
+
// ── Tool: dao_dashboard ──────────────────────────────────
|
|
372
|
+
pi.registerTool({
|
|
373
|
+
name: "dao_dashboard",
|
|
374
|
+
label: "DAO Dashboard",
|
|
375
|
+
description: "View outcome tracking dashboard",
|
|
376
|
+
parameters: Type.Object({}),
|
|
377
|
+
async execute(_id, _params) {
|
|
378
|
+
const state = getState();
|
|
379
|
+
if (!state.initialized)
|
|
380
|
+
return toolResult("DAO not initialized.");
|
|
381
|
+
const dashboard = generateDashboard(state.proposals, state.outcomes, state.agents, state.healthSnapshots);
|
|
382
|
+
const health = computeHealthScore(state.proposals, state.outcomes, state.config.healthWeights);
|
|
383
|
+
return toolResult(`${dashboard}\n\n${formatHealthScore(health)}`);
|
|
384
|
+
},
|
|
385
|
+
});
|
|
386
|
+
// ── Tool: dao_dry_run ────────────────────────────────────
|
|
387
|
+
pi.registerTool({
|
|
388
|
+
name: "dao_dry_run",
|
|
389
|
+
label: "DAO Dry Run",
|
|
390
|
+
description: "Preview execution without applying changes",
|
|
391
|
+
parameters: Type.Object({ proposalId: Type.Number() }),
|
|
392
|
+
async execute(_id, params) {
|
|
393
|
+
const proposal = getProposal(Number(params.proposalId));
|
|
394
|
+
if (!proposal)
|
|
395
|
+
return toolResult(`Proposal #${params.proposalId} not found.`);
|
|
396
|
+
const result = await performDryRun(proposal);
|
|
397
|
+
proposal.dryRunAt = new Date().toISOString();
|
|
398
|
+
proposal.dryRunCanProceed = result.canProceed;
|
|
399
|
+
await saveState();
|
|
400
|
+
return toolResult(formatDryRun(result));
|
|
401
|
+
},
|
|
402
|
+
});
|
|
403
|
+
// ── Tool: dao_rollback ───────────────────────────────────
|
|
404
|
+
pi.registerTool({
|
|
405
|
+
name: "dao_rollback",
|
|
406
|
+
label: "DAO Rollback",
|
|
407
|
+
description: "Revert proposal execution to pre-execution snapshot",
|
|
408
|
+
parameters: Type.Object({ proposalId: Type.Number() }),
|
|
409
|
+
async execute(_id, params) {
|
|
410
|
+
const result = await performRollback(Number(params.proposalId));
|
|
411
|
+
return toolResult(formatRollback(result));
|
|
412
|
+
},
|
|
413
|
+
});
|
|
414
|
+
// ── Tool: dao_roundtable ─────────────────────────────────
|
|
415
|
+
pi.registerTool({
|
|
416
|
+
name: "dao_roundtable",
|
|
417
|
+
label: "DAO Roundtable",
|
|
418
|
+
description: "Ask every agent to suggest a proposal idea",
|
|
419
|
+
parameters: Type.Object({}),
|
|
420
|
+
async execute(_id, _params, _signal, _onUpdate, ctx) {
|
|
421
|
+
const state = getState();
|
|
422
|
+
if (!state.initialized)
|
|
423
|
+
return toolResult("DAO not initialized.");
|
|
424
|
+
const adapter = createPiHostAdapter(pi, ctx);
|
|
425
|
+
const suggestions = await runRoundTable(adapter, state.agents, state.config.maxConcurrent);
|
|
426
|
+
// Create proposals from valid suggestions
|
|
427
|
+
const proposalIds = new Map();
|
|
428
|
+
for (const s of suggestions) {
|
|
429
|
+
if (!s.parsed)
|
|
430
|
+
continue;
|
|
431
|
+
try {
|
|
432
|
+
const proposal = await createProposal(s.parsed.title, s.parsed.type, s.parsed.description, s.agentId);
|
|
433
|
+
proposal.riskZone = classifyRiskZone(proposal);
|
|
434
|
+
s.proposalId = proposal.id;
|
|
435
|
+
proposalIds.set(s.agentId, proposal.id);
|
|
436
|
+
await recordAudit(proposal.id, "intelligence", "roundtable_proposal_created", s.agentId, `Auto-created from round table`);
|
|
437
|
+
}
|
|
438
|
+
catch (err) {
|
|
439
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
440
|
+
s.error = `Failed to create proposal: ${msg}`;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
await saveState();
|
|
444
|
+
return toolResult(formatRoundTableResults(suggestions, proposalIds));
|
|
445
|
+
},
|
|
446
|
+
});
|
|
447
|
+
// ── Tool: dao_update_proposal ────────────────────────────
|
|
448
|
+
pi.registerTool({
|
|
449
|
+
name: "dao_update_proposal",
|
|
450
|
+
label: "DAO Update Proposal",
|
|
451
|
+
description: "Update structured fields on an open proposal",
|
|
452
|
+
parameters: Type.Object({
|
|
453
|
+
proposalId: Type.Number(),
|
|
454
|
+
problemStatement: Type.Optional(Type.String()),
|
|
455
|
+
acceptanceCriteria: Type.Optional(Type.Array(Type.String())),
|
|
456
|
+
successMetrics: Type.Optional(Type.Array(Type.String())),
|
|
457
|
+
rollbackConditions: Type.Optional(Type.Array(Type.String())),
|
|
458
|
+
}),
|
|
459
|
+
async execute(_id, params) {
|
|
460
|
+
const proposal = getProposal(Number(params.proposalId));
|
|
461
|
+
if (!proposal)
|
|
462
|
+
return toolResult(`Proposal #${params.proposalId} not found.`);
|
|
463
|
+
if (proposal.status !== "open")
|
|
464
|
+
return toolResult(`Must be open (current: ${proposal.status})`);
|
|
465
|
+
if (params.problemStatement !== undefined)
|
|
466
|
+
proposal.problemStatement = params.problemStatement;
|
|
467
|
+
if (params.acceptanceCriteria !== undefined)
|
|
468
|
+
proposal.acceptanceCriteria = params.acceptanceCriteria;
|
|
469
|
+
if (params.successMetrics !== undefined)
|
|
470
|
+
proposal.successMetrics = params.successMetrics;
|
|
471
|
+
if (params.rollbackConditions !== undefined)
|
|
472
|
+
proposal.rollbackConditions = params.rollbackConditions;
|
|
473
|
+
await saveState();
|
|
474
|
+
return toolResult(`# 📝 Proposal Updated — #${proposal.id}\n\nUpdated fields applied.`);
|
|
475
|
+
},
|
|
476
|
+
});
|
|
477
|
+
// ── Command: /dao ────────────────────────────────────────
|
|
478
|
+
pi.registerCommand("/dao", {
|
|
479
|
+
description: "Show DAO dashboard",
|
|
480
|
+
handler: async (_args, _ctx) => {
|
|
481
|
+
let state;
|
|
482
|
+
try {
|
|
483
|
+
state = getState();
|
|
484
|
+
}
|
|
485
|
+
catch {
|
|
486
|
+
return "DAO not initialized. Run `dao_setup`.";
|
|
487
|
+
}
|
|
488
|
+
if (!state.initialized) {
|
|
489
|
+
return "DAO not initialized. Run `dao_setup`.";
|
|
490
|
+
}
|
|
491
|
+
const byStatus = {};
|
|
492
|
+
for (const p of state.proposals) {
|
|
493
|
+
byStatus[p.status] = (byStatus[p.status] ?? 0) + 1;
|
|
494
|
+
}
|
|
495
|
+
let output = `# Swarm DAO Dashboard\n`;
|
|
496
|
+
output += `Agents: ${state.agents.length} | Proposals: ${state.proposals.length}\n`;
|
|
497
|
+
for (const [status, count] of Object.entries(byStatus)) {
|
|
498
|
+
output += ` ${status}: ${count}\n`;
|
|
499
|
+
}
|
|
500
|
+
return output.trim();
|
|
501
|
+
},
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
//# 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,yBAAyB;AACzB,+DAA+D;AAC/D,mDAAmD;AACnD,8CAA8C;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EACL,SAAS,EACT,OAAO;AACP,eAAe;AACf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
+
"name": "@guyghost/swarm-dao-pi-adapter",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Swarm DAO adapter for the Pi coding agent — multi-agent governance tools, commands, and event hooks",
|
|
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
|
+
"@earendil-works/pi-coding-agent": ">=0.1.0",
|
|
31
|
+
"@earendil-works/pi-ai": ">=0.1.0",
|
|
32
|
+
"typebox": ">=1.0.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependenciesMeta": {
|
|
35
|
+
"@earendil-works/pi-coding-agent": {
|
|
36
|
+
"optional": true
|
|
37
|
+
},
|
|
38
|
+
"@earendil-works/pi-ai": {
|
|
39
|
+
"optional": true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/bun": "latest"
|
|
44
|
+
},
|
|
45
|
+
"pi": {
|
|
46
|
+
"extensions": [
|
|
47
|
+
"./dist/index.js"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"pi",
|
|
52
|
+
"pi-coding-agent",
|
|
53
|
+
"dao",
|
|
54
|
+
"governance",
|
|
55
|
+
"swarm",
|
|
56
|
+
"agents",
|
|
57
|
+
"multi-agent",
|
|
58
|
+
"ai",
|
|
59
|
+
"extension"
|
|
60
|
+
],
|
|
61
|
+
"author": "guyghost",
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"repository": {
|
|
64
|
+
"type": "git",
|
|
65
|
+
"url": "git+https://github.com/guyghost/swarm-dao.git",
|
|
66
|
+
"directory": "packages/pi-adapter"
|
|
67
|
+
},
|
|
68
|
+
"bugs": {
|
|
69
|
+
"url": "https://github.com/guyghost/swarm-dao/issues"
|
|
70
|
+
},
|
|
71
|
+
"homepage": "https://github.com/guyghost/swarm-dao#readme",
|
|
72
|
+
"publishConfig": {
|
|
73
|
+
"access": "public"
|
|
74
|
+
}
|
|
75
|
+
}
|