@heretek-ai/epistemic-swarm 0.1.0 → 0.2.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 CHANGED
@@ -1,127 +1,133 @@
1
- # Epistemic Swarm 🌟
1
+ # IUMBTEMS: I Use My Brain To Express My Self 🧠
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@heretek-ai/epistemic-swarm.svg)](https://www.npmjs.com/package/@heretek-ai/epistemic-swarm)
4
4
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
5
  [![CI/CD](https://github.com/Heretek-AI/IUMBTEMS/actions/workflows/publish.yml/badge.svg)](https://github.com/Heretek-AI/IUMBTEMS/actions)
6
6
 
7
- > **High-Integrity Dialectic Research Agent Harness for Claude Code**
7
+ > **High-Integrity Dialectic Research Agent Harness**
8
+ > *Universal support for Claude Code, Pi (pi.dev), and OpenCode V2.*
8
9
  > *Enforcing verified empirical evidence over parametric hallucination.*
9
10
 
10
11
  ---
11
12
 
12
- ## 🎯 The Epistemic Mandate
13
+ ## 💡 The Philosophy of IUMBTEMS
13
14
 
14
- Current AI research assistants suffer from parametric hallucination, sycophancy, and premature narrative consensus. They invent citations, smooth over technical contradictions, and extrapolate beyond empirical bounds.
15
+ **IUMBTEMS** (**I Use My Brain To Express My Self**) is grounded in a singular design mandate: **Epistemic Sovereignty**.
15
16
 
16
- **Epistemic Swarm** is an autonomous, dialectic research harness built on top of [Claude Code](https://claude.ai/code) (`~/.claude/` and `~/.claude.json`). It enforces **evidentiary primacy** through:
17
- 1. **Mathematical Evidentiary Tags**: Every factual claim is tagged `[VERIFIED: <hash>]`, `[INFERRED: ...]`, `[HYPOTHESIS: ...]`, or `[NEGATIVE_KNOWLEDGE: ...]`.
18
- 2. **Dialectic Swarm Architecture**: Competitively dispatches **Agent Alpha** (The Thesis / Primary Literature Proponent) and **Agent Beta** (The Antithesis / Hostile Red Team / Active Falsifier).
19
- 3. **Content-Addressed Source Caching**: Web pages and papers are hashed to SHA-256 (`.research/sources/<sha256>.md`).
20
- 4. **Algorithmic Epistemic Auditor**: Verifies cited quotes verbatim against the raw source cache, downgrades fabricated claims, scores divergence, and synthesizes the unvarnished empirical truth.
21
- 5. **Socratic Grilling & Divergent Ideation**: Matt Pocock-style design tree traversal that explores assumption inversions and clarifies constraints *before* committing to search queries.
17
+ Modern LLMs suffer from parametric hallucination, sycophancy, and premature narrative consensus. They invent citations, smooth over technical contradictions, and extrapolate beyond empirical bounds.
18
+
19
+ **IUMBTEMS** restores rigorous empirical grounding by pairing an unconstrained divergent exploration phase (Matt Pocock-style Socratic grilling and assumption inversion) with a multi-agent dialectic swarm:
20
+ 1. **Agent Alpha (The Proponent / Thesis)**: Gathers corroborating primary sources, empirical proofs, and implementation benchmarks.
21
+ 2. **Agent Beta (The Adversary / Antithesis / Red Team)**: Hunts for counter-arguments, retracted data, methodology flaws, and edge-case failures.
22
+ 3. **Epistemic Auditor**: Verifies cited quotes verbatim against content-addressed raw markdown caches (`.research/sources/<sha256>.md`), prunes ungrounded assertions, and scores dialectic divergence.
22
23
 
23
24
  ---
24
25
 
25
- ## 🏗️ System Architecture
26
-
27
- ```mermaid
28
- flowchart TD
29
- User([Research Objective]) --> Grilling["Phase 1: Socratic Grilling (/grilling)\n(Assumption Inversion & Frontier Resolution)"]
30
- Grilling --> SettledFrontier[Settled Problem Frontier & Constraints]
31
- SettledFrontier --> Orchestrator["Phase 2: Swarm Orchestrator\n(Scope Decomposition & DAG Planner)"]
32
-
33
- Orchestrator --> Scope1[Scope 1: Technical Mechanisms]
34
- Orchestrator --> Scope2[Scope 2: Scalability & Economics]
35
-
36
- subgraph DialecticLoop [Parallel Dialectic Execution per Scope]
37
- Scope1 --> Alpha["Agent Alpha: The Proponent\n(Empirical Evidence, Primary Literature)"]
38
- Scope1 --> Beta["Agent Beta: The Adversary\n(Active Falsification, Red-Teaming)"]
39
-
40
- Alpha -->|Writes| AlphaDossier[alpha_dossier.json + Cached Sources]
41
- Beta -->|Writes| BetaDossier[beta_dossier.json + Cached Sources]
42
-
43
- AlphaDossier --> Auditor["Phase 3: Epistemic Auditor\n(Verbatim Quote Hash Verification & Divergence Scoring)"]
44
- BetaDossier --> Auditor
45
- Auditor --> ScopeSynth[Scope Synthesis & Audit Report]
46
- end
47
-
48
- ScopeSynth --> MasterSynth["Phase 4: Master Synthesis (.research/final_synthesis.md)"]
26
+ ## 🌐 Universal Multi-Platform Support
27
+
28
+ IUMBTEMS is packaged as a single universal npm package (`@heretek-ai/epistemic-swarm` with `iumbtems` binary) that runs across the three major autonomous agent platforms:
29
+
30
+ ### 1. Claude Code
31
+ Install skills and MCP servers into `~/.claude/` and `~/.claude.json`:
32
+ ```bash
33
+ npx @heretek-ai/epistemic-swarm install
34
+ # or from local repo:
35
+ npm run install-local
36
+ ```
37
+ - Run `/grilling` inside any interactive Claude Code session.
38
+ - Run headless dialectic research:
39
+ ```bash
40
+ iumbtems run "Evaluate FPGA Poseidon prover latency bounds"
41
+ ```
42
+
43
+ ### 2. Pi (`pi.dev`)
44
+ Install directly into Pi via its native package manager:
45
+ ```bash
46
+ pi install npm:@heretek-ai/epistemic-swarm
47
+ ```
48
+ - Exposes native `/swarm <objective>` and `/grill` slash commands in the Pi interactive terminal.
49
+ - Discovers skills (`skills/grilling`, `skills/research-cache`) and prompts automatically via the `pi` manifest block.
50
+
51
+ ### 3. OpenCode V2 (`opencode.ai`)
52
+ Enable IUMBTEMS in your `~/.config/opencode/opencode.json` or project `opencode.jsonc`:
53
+ ```json
54
+ {
55
+ "plugin": [
56
+ "@heretek-ai/epistemic-swarm"
57
+ ]
58
+ }
49
59
  ```
60
+ OpenCode V2 automatically registers:
61
+ - `iumbtems_swarm_research`: Dispatches dialectic researcher pairs.
62
+ - `iumbtems_verify_quote`: Audits verbatim citations against the SHA-256 source cache.
63
+ - `iumbtems_socratic_frontier`: Advances the Socratic decision tree frontier.
64
+
65
+ *(See [config/opencode-snippet.json](config/opencode-snippet.json) for custom agent definitions).*
50
66
 
51
67
  ---
52
68
 
53
- ## ⚡ Quickstart
69
+ ## ⚡ CLI Command Reference
54
70
 
55
- ### Option 1: Run via NPX (Zero Setup)
56
71
  ```bash
57
- # Execute deep research swarm directly
58
- npx @heretek-ai/epistemic-swarm run "Evaluate FPGA Poseidon prover latency bounds"
72
+ # Run the autonomous dialectic research swarm
73
+ iumbtems run "Sub-millisecond ZK state updates on L1 rollups"
59
74
 
60
- # Run Socratic decision tree framing
61
- npx @heretek-ai/epistemic-swarm grill --objective "L1 vs L2 state verification trade-offs"
62
- ```
75
+ # Run Socratic grilling and decision frontier calculation
76
+ iumbtems grill --objective "L1 vs L2 state verification trade-offs"
63
77
 
64
- ### Option 2: Install into Claude Code Environment
65
- ```bash
66
- git clone https://github.com/Heretek-AI/IUMBTEMS.git
67
- cd IUMBTEMS
68
- npm run install-local
78
+ # Environment diagnostics (Claude Code, Node, Python)
79
+ iumbtems doctor
80
+
81
+ # Run automated test suite
82
+ iumbtems test
69
83
  ```
70
- This automatically symlinks the `/grilling` and `/research-cache` skills into `~/.claude/skills/` and configures MCP servers in `~/.claude.json`.
71
84
 
72
85
  ---
73
86
 
74
87
  ## 🏷️ Epistemic Tagging Taxonomy
75
88
 
76
- | Tag | Meaning | Requirement |
89
+ Every factual claim in IUMBTEMS carries an explicit evidentiary tag:
90
+
91
+ | Tag | Formal Definition | Verification Standard |
77
92
  | :--- | :--- | :--- |
78
- | `[VERIFIED: <hash>]` | Direct empirical fact backed by primary source. | Verbatim quote must exist in `.research/sources/<hash>.md`. |
79
- | `[INFERRED: <reasoning>]` | Deductive conclusion from verified facts. | Must list parent verified claims and deductive step. |
93
+ | `[VERIFIED: <hash>]` | Direct empirical fact from primary source. | Verbatim quote must exist in `.research/sources/<hash>.md`. |
94
+ | `[INFERRED: <reasoning>]` | Deductive conclusion from verified facts. | Explicit list of parent verified premises and bridging logic. |
80
95
  | `[HYPOTHESIS: <test>]` | Speculative assertion or projection. | Must define a measurable falsification criterion. |
81
- | `[NEGATIVE_KNOWLEDGE: <query>]` | Verified absence of empirical evidence. | Records exact search query and confirmed literature gap. |
96
+ | `[NEGATIVE_KNOWLEDGE: <query>]` | Verified absence of empirical evidence. | Records exact search query and literature gap. |
82
97
 
83
98
  ---
84
99
 
85
100
  ## 🔍 Multi-Tier OSINT & Search Pipeline
86
101
 
87
- 1. **Discovery Tier**: SearXNG (metasearch) and Brave Search API.
102
+ 1. **Discovery Tier**: SearXNG (unbiased metasearch) and Brave Search API.
88
103
  2. **Extraction Tier**: Firecrawl (headless JavaScript rendering, DOM cleaning, Markdown extraction).
89
- 3. **Academic Tier**: Semantic Scholar / arXiv MCPs for DOI resolution.
104
+ 3. **Academic Tier**: Semantic Scholar / arXiv MCPs for DOI citation resolution.
90
105
  4. **Caching Tier**: Content-addressed SHA-256 storage (`skills/research-cache/hasher.py`).
91
106
 
92
- ### Optional Turnkey Infrastructure (SearXNG + Firecrawl)
93
- To run your own unbiased metasearch and headless extractor locally:
107
+ ### Local Infrastructure (Optional)
108
+ Run local SearXNG and Firecrawl instances via Docker Compose:
94
109
  ```bash
95
110
  docker compose -f config/docker-compose.infra.yml up -d
96
111
  ```
97
112
 
98
113
  ---
99
114
 
100
- ## 🧪 Testing
115
+ ## 📦 CI/CD & Trusted Publishing
101
116
 
102
- Epistemic Swarm comes with an automated test suite verifying source hashing, quote substring matching, IPC state transitions, and mock swarm dispatch:
117
+ This package is distributed on npm under `@heretek-ai` with [npm Trusted Publishing (OIDC)](https://docs.npmjs.com/trusted-publishers) and GitHub Actions.
103
118
 
119
+ ### First-Time CLI Bootstrap
104
120
  ```bash
105
- npm test
121
+ git pull origin main
122
+ npm publish --access public
106
123
  ```
107
124
 
108
- ---
109
-
110
- ## 📦 Deployment & CI/CD
111
-
112
- This package is distributed via npm under `@heretek-ai` with [npm Trusted Publishing (OIDC)](https://docs.npmjs.com/trusted-publishers) and GitHub Actions.
113
-
114
- ### First-Time Publication (One-Time Bootstrap)
115
- 1. Authenticate locally:
116
- ```bash
117
- npm login
118
- ```
119
- 2. Publish initial version:
120
- ```bash
121
- npm publish --access public
122
- ```
123
- 3. In `npmjs.com/package/@heretek-ai/epistemic-swarm/access`, add **GitHub Actions** as a Trusted Publisher for repository `Heretek-AI/IUMBTEMS` and workflow `.github/workflows/publish.yml`.
124
- 4. Subsequent releases publish automatically upon pushing a GitHub Release or git tag!
125
+ ### GitHub Actions OIDC Setup
126
+ 1. In `npmjs.com/package/@heretek-ai/epistemic-swarm/access`, add **GitHub Actions** as a Trusted Publisher:
127
+ - **Repository Owner**: `Heretek-AI`
128
+ - **Repository Name**: `IUMBTEMS`
129
+ - **Workflow Pattern**: `.github/workflows/publish.yml`
130
+ 2. Future releases publish automatically upon pushing a GitHub Release or version tag (`v*.*.*`)!
125
131
 
126
132
  ---
127
133
 
package/bin/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * Epistemic Swarm CLI
5
- * Multi-agent dialectic research harness for Claude Code.
4
+ * IUMBTEMS CLI: I Use My Brain To Express My Self
5
+ * High-Integrity Dialectic Research Harness for Claude Code, Pi, and OpenCode V2.
6
6
  */
7
7
 
8
8
  const { spawnSync } = require('child_process');
@@ -15,30 +15,37 @@ const command = args[0] || 'help';
15
15
 
16
16
  function printHelp() {
17
17
  console.log(`
18
- 🌟 Epistemic Swarm: High-Integrity Research Harness for Claude Code
18
+ 🧠 IUMBTEMS: I Use My Brain To Express My Self
19
+ 🌟 Epistemic Swarm: High-Integrity Research Harness
20
+ Platforms: Claude Code | Pi (pi.dev) | OpenCode V2
19
21
  Organization: @heretek-ai | Repository: Heretek-AI/IUMBTEMS
20
22
 
21
23
  Usage:
22
- npx @heretek-ai/epistemic-swarm <command> [options]
23
24
  iumbtems <command> [options]
25
+ npx @heretek-ai/epistemic-swarm <command> [options]
24
26
 
25
27
  Commands:
26
28
  run "<objective>" Run the dialectic multi-agent research swarm
27
29
  grill Launch interactive Socratic decision tree framing
28
30
  install Install skills & MCP servers into ~/.claude/
29
31
  test Run test suite for hashing, state machine & auditor
30
- doctor Check environment requirements (Claude Code, Python, Node)
32
+ doctor Check environment requirements (Claude Code, Pi, OpenCode)
31
33
  help Show this help message
32
34
 
35
+ Platform Extensions:
36
+ Pi (pi.dev): pi install npm:@heretek-ai/epistemic-swarm
37
+ OpenCode V2: add "@heretek-ai/epistemic-swarm" to opencode.json plugins
38
+ Claude Code: npx @heretek-ai/epistemic-swarm install
39
+
33
40
  Options:
34
41
  --mock-claude Run swarm with synthetic mock responses (zero API cost)
35
42
  --frontier <file> Path to settled frontier.json from Socratic grilling
36
43
  --dir <path> Path to .research workspace directory (default: .research)
37
44
 
38
45
  Examples:
39
- npx @heretek-ai/epistemic-swarm run "Verify sub-millisecond ZK prover latency"
40
- npx @heretek-ai/epistemic-swarm grill --objective "Rollup architecture trade-offs"
41
- npx @heretek-ai/epistemic-swarm install
46
+ iumbtems run "Verify sub-millisecond ZK prover latency"
47
+ iumbtems grill --objective "Rollup architecture trade-offs"
48
+ iumbtems doctor
42
49
  `);
43
50
  }
44
51
 
@@ -0,0 +1,48 @@
1
+ {
2
+ "$schema": "https://opencode.ai/config.json",
3
+ "plugin": [
4
+ "@heretek-ai/epistemic-swarm"
5
+ ],
6
+ "agent": {
7
+ "alpha-thesis": {
8
+ "description": "IUMBTEMS Proponent Agent: Gathers corroborating primary sources, benchmark results, and empirical proofs.",
9
+ "tools": {
10
+ "bash": true,
11
+ "read": true,
12
+ "write": true,
13
+ "grep": true,
14
+ "glob": true,
15
+ "task": true,
16
+ "iumbtems_verify_quote": true
17
+ }
18
+ },
19
+ "beta-redteam": {
20
+ "description": "IUMBTEMS Adversary Agent: Active falsification, red-teaming, hunting for counter-benchmarks, and edge-case failure modes.",
21
+ "tools": {
22
+ "bash": true,
23
+ "read": true,
24
+ "write": true,
25
+ "grep": true,
26
+ "glob": true,
27
+ "task": true,
28
+ "iumbtems_verify_quote": true
29
+ }
30
+ },
31
+ "epistemic-auditor": {
32
+ "description": "IUMBTEMS Synthesizer & Auditor: Verifies verbatim source quotes, downgrades unverified claims, and calculates divergence.",
33
+ "tools": {
34
+ "read": true,
35
+ "write": true,
36
+ "grep": true,
37
+ "glob": true,
38
+ "iumbtems_verify_quote": true
39
+ }
40
+ }
41
+ },
42
+ "skills": {
43
+ "paths": [
44
+ "./skills/grilling",
45
+ "./skills/research-cache"
46
+ ]
47
+ }
48
+ }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * IUMBTEMS: I Use My Brain To Express My Self
3
+ * Native Extension for Pi (pi.dev)
4
+ *
5
+ * Exposes /grill and /swarm slash commands and epistemic verification tools in Pi.
6
+ */
7
+
8
+ import { spawnSync } from 'child_process';
9
+ import path from 'path';
10
+ import { fileURLToPath } from 'url';
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = path.dirname(__filename);
14
+ const PKG_ROOT = path.resolve(__dirname, '../..');
15
+
16
+ export default function initPiExtension(pi) {
17
+ // Check if Pi extension API is available
18
+ if (!pi) return;
19
+
20
+ // 1. Register /swarm slash command
21
+ if (typeof pi.registerCommand === 'function') {
22
+ pi.registerCommand('swarm', {
23
+ description: 'Run IUMBTEMS dialectic research swarm on an objective',
24
+ usage: '/swarm <objective>',
25
+ handler: async (args, ctx) => {
26
+ const objective = args.trim();
27
+ if (!objective) {
28
+ ctx.output?.('⚠️ Please provide a research objective. Example: /swarm "ZK prover latency bounds"');
29
+ return;
30
+ }
31
+
32
+ ctx.output?.(`🌟 [IUMBTEMS] Dispatching Dialectic Swarm: "${objective}"...`);
33
+ const runnerPath = path.join(PKG_ROOT, 'runner/research_swarm.py');
34
+ const res = spawnSync('python3', [runnerPath, '--objective', objective], {
35
+ encoding: 'utf-8',
36
+ cwd: ctx.cwd || process.cwd(),
37
+ env: { ...process.env, PYTHONPATH: PKG_ROOT }
38
+ });
39
+
40
+ if (res.status === 0) {
41
+ ctx.output?.(res.stdout);
42
+ ctx.output?.('\n✅ Research complete! Summary written to .research/final_synthesis.md');
43
+ } else {
44
+ ctx.output?.(`❌ Swarm failed:\n${res.stderr || res.stdout}`);
45
+ }
46
+ }
47
+ });
48
+
49
+ // 2. Register /grill slash command
50
+ pi.registerCommand('grill', {
51
+ description: 'Launch Socratic grilling and decision tree frontier exploration',
52
+ usage: '/grill [--objective <text>]',
53
+ handler: async (args, ctx) => {
54
+ ctx.output?.('🧠 [IUMBTEMS] Launching Socratic Grilling decision tree...');
55
+ const treePath = path.join(PKG_ROOT, 'skills/grilling/socratic_tree.py');
56
+ const forwardArgs = args.trim() ? ['--objective', args.trim()] : ['--show-frontier'];
57
+ const res = spawnSync('python3', [treePath, ...forwardArgs], {
58
+ encoding: 'utf-8',
59
+ cwd: ctx.cwd || process.cwd()
60
+ });
61
+ ctx.output?.(res.stdout || res.stderr);
62
+ }
63
+ });
64
+ }
65
+
66
+ // 3. Register tool for epistemic quote verification
67
+ if (typeof pi.registerTool === 'function') {
68
+ pi.registerTool({
69
+ name: 'iumbtems_verify_quote',
70
+ description: 'Verify that an empirical claim quote matches verbatim text in the source cache',
71
+ parameters: {
72
+ type: 'object',
73
+ properties: {
74
+ hash: { type: 'string', description: 'SHA-256 hash of cached source' },
75
+ quote: { type: 'string', description: 'Verbatim quote string to verify' }
76
+ },
77
+ required: ['hash', 'quote']
78
+ },
79
+ execute: async ({ hash, quote }) => {
80
+ const hasherPath = path.join(PKG_ROOT, 'skills/research-cache/hasher.py');
81
+ const res = spawnSync('python3', [hasherPath, 'verify', '--hash', hash, '--quote', quote], {
82
+ encoding: 'utf-8'
83
+ });
84
+ return {
85
+ content: [{ type: 'text', text: res.stdout || res.stderr }]
86
+ };
87
+ }
88
+ });
89
+ }
90
+ }
package/package.json CHANGED
@@ -1,11 +1,17 @@
1
1
  {
2
2
  "name": "@heretek-ai/epistemic-swarm",
3
- "version": "0.1.0",
4
- "description": "Epistemic Swarm: High-Integrity Dialectic Research Agent Harness for Claude Code",
3
+ "version": "0.2.0",
4
+ "description": "IUMBTEMS: I Use My Brain To Express My Self — High-Integrity Dialectic Research Agent Harness for Claude Code, Pi (pi.dev), and OpenCode V2",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {
7
- "epistemic-swarm": "bin/cli.js",
8
- "iumbtems": "bin/cli.js"
7
+ "iumbtems": "bin/cli.js",
8
+ "epistemic-swarm": "bin/cli.js"
9
+ },
10
+ "exports": {
11
+ ".": "./bin/cli.js",
12
+ "./opencode": "./plugins/opencode/index.js",
13
+ "./server": "./plugins/opencode/index.js",
14
+ "./pi": "./extensions/pi/index.js"
9
15
  },
10
16
  "publishConfig": {
11
17
  "access": "public"
@@ -19,6 +25,10 @@
19
25
  },
20
26
  "homepage": "https://github.com/Heretek-AI/IUMBTEMS#readme",
21
27
  "keywords": [
28
+ "iumbtems",
29
+ "pi-package",
30
+ "opencode",
31
+ "opencode-plugin",
22
32
  "claude-code",
23
33
  "ai-agents",
24
34
  "dialectic-swarm",
@@ -28,6 +38,18 @@
28
38
  "deep-research",
29
39
  "socratic-grilling"
30
40
  ],
41
+ "pi": {
42
+ "extensions": [
43
+ "./extensions/pi/index.js"
44
+ ],
45
+ "skills": [
46
+ "./skills/grilling",
47
+ "./skills/research-cache"
48
+ ],
49
+ "prompts": [
50
+ "./prompts/*.md"
51
+ ]
52
+ },
31
53
  "author": "Heretek AI",
32
54
  "license": "Apache-2.0",
33
55
  "files": [
@@ -36,6 +58,8 @@
36
58
  "skills",
37
59
  "config",
38
60
  "runner",
61
+ "extensions",
62
+ "plugins",
39
63
  ".claude-plugin",
40
64
  "install.sh",
41
65
  "README.md",
@@ -0,0 +1,149 @@
1
+ /**
2
+ * IUMBTEMS: I Use My Brain To Express My Self
3
+ * Native Plugin for OpenCode V2 (opencode.ai)
4
+ *
5
+ * Exposes dialectic swarm research tools, Socratic decision frontier calculation,
6
+ * and content-addressed quote verification directly into OpenCode V2 agents.
7
+ */
8
+
9
+ import { spawnSync } from 'child_process';
10
+ import path from 'path';
11
+ import { fileURLToPath } from 'url';
12
+
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = path.dirname(__filename);
15
+ const PKG_ROOT = path.resolve(__dirname, '../..');
16
+
17
+ export function createOpenCodePlugin(context = {}) {
18
+ return {
19
+ id: "heretek.iumbtems.epistemic-swarm",
20
+ name: "IUMBTEMS Epistemic Swarm",
21
+ version: "0.1.0",
22
+ description: "I Use My Brain To Express My Self: Dialectic research swarm enforcing empirical verification",
23
+
24
+ server: (toolContext) => [
25
+ {
26
+ name: "iumbtems_swarm_research",
27
+ description: "Execute an autonomous dialectic research swarm on an objective using Agent Alpha (Thesis) and Agent Beta (Red Team).",
28
+ input: {
29
+ type: "object",
30
+ properties: {
31
+ objective: {
32
+ type: "string",
33
+ description: "The research question or hypothesis to investigate"
34
+ },
35
+ mock_mode: {
36
+ type: "boolean",
37
+ description: "Run in mock/dry-run mode without external API charges",
38
+ default: false
39
+ }
40
+ },
41
+ required: ["objective"]
42
+ },
43
+ options: { codemode: false },
44
+ execute: async (args) => {
45
+ const runnerPath = path.join(PKG_ROOT, "runner/research_swarm.py");
46
+ const cmdArgs = [runnerPath, "--objective", args.objective];
47
+ if (args.mock_mode) {
48
+ cmdArgs.push("--mock-claude");
49
+ }
50
+
51
+ const res = spawnSync("python3", cmdArgs, {
52
+ encoding: "utf-8",
53
+ cwd: toolContext?.cwd || process.cwd(),
54
+ env: { ...process.env, PYTHONPATH: PKG_ROOT }
55
+ });
56
+
57
+ return {
58
+ content: res.stdout || res.stderr,
59
+ status: res.status === 0 ? "success" : "error"
60
+ };
61
+ }
62
+ },
63
+
64
+ {
65
+ name: "iumbtems_verify_quote",
66
+ description: "Cryptographically verify whether a cited quote matches verbatim text inside the content-addressed source cache.",
67
+ input: {
68
+ type: "object",
69
+ properties: {
70
+ hash: {
71
+ type: "string",
72
+ description: "SHA-256 hash or prefix of the cached source"
73
+ },
74
+ quote: {
75
+ type: "string",
76
+ description: "The verbatim excerpt to verify"
77
+ }
78
+ },
79
+ required: ["hash", "quote"]
80
+ },
81
+ options: { codemode: false },
82
+ execute: async (args) => {
83
+ const hasherPath = path.join(PKG_ROOT, "skills/research-cache/hasher.py");
84
+ const res = spawnSync("python3", [hasherPath, "verify", "--hash", args.hash, "--quote", args.quote], {
85
+ encoding: "utf-8",
86
+ cwd: toolContext?.cwd || process.cwd()
87
+ });
88
+
89
+ return {
90
+ content: res.stdout || res.stderr,
91
+ status: res.status === 0 ? "verified" : "failed"
92
+ };
93
+ }
94
+ },
95
+
96
+ {
97
+ name: "iumbtems_socratic_frontier",
98
+ description: "Inspect or advance the Socratic grilling decision frontier for research framing.",
99
+ input: {
100
+ type: "object",
101
+ properties: {
102
+ objective: {
103
+ type: "string",
104
+ description: "Research objective to inspect"
105
+ },
106
+ settle_node: {
107
+ type: "string",
108
+ description: "Optional node ID to settle with an answer"
109
+ },
110
+ settle_answer: {
111
+ type: "string",
112
+ description: "Answer for the settled node"
113
+ }
114
+ }
115
+ },
116
+ options: { codemode: false },
117
+ execute: async (args) => {
118
+ const treePath = path.join(PKG_ROOT, "skills/grilling/socratic_tree.py");
119
+ const cmdArgs = [treePath];
120
+
121
+ if (args.settle_node && args.settle_answer) {
122
+ cmdArgs.push("--settle", args.settle_node, args.settle_answer);
123
+ } else if (args.objective) {
124
+ cmdArgs.push("--objective", args.objective, "--show-frontier");
125
+ } else {
126
+ cmdArgs.push("--show-frontier");
127
+ }
128
+
129
+ const res = spawnSync("python3", cmdArgs, {
130
+ encoding: "utf-8",
131
+ cwd: toolContext?.cwd || process.cwd()
132
+ });
133
+
134
+ return {
135
+ content: res.stdout || res.stderr
136
+ };
137
+ }
138
+ }
139
+ ],
140
+
141
+ setup: async (appContext) => {
142
+ // OpenCode V2 lifecycle hook
143
+ return { initialized: true, platform: "opencode-v2" };
144
+ }
145
+ };
146
+ }
147
+
148
+ const defaultPlugin = createOpenCodePlugin();
149
+ export default defaultPlugin;
@@ -5,6 +5,7 @@ Tests source hashing, state machine IPC transitions, auditor engine, and swarm m
5
5
  """
6
6
 
7
7
  import sys
8
+ import json
8
9
  import shutil
9
10
  import tempfile
10
11
  import unittest
@@ -173,6 +174,34 @@ In our experiments, the 70B parameter model was trained on 15.0 trillion tokens.
173
174
  self.assertIn("Master Epistemic Research Report", report_text)
174
175
  self.assertIn("Swarm Epistemic Audit Totals", report_text)
175
176
 
177
+ def test_pi_and_opencode_manifest_integrity(self):
178
+ pkg_json_path = PROJECT_ROOT / "package.json"
179
+ self.assertTrue(pkg_json_path.exists())
180
+ with open(pkg_json_path, "r", encoding="utf-8") as f:
181
+ pkg = json.load(f)
182
+
183
+ # 1. Pi manifest validation
184
+ self.assertIn("pi", pkg)
185
+ self.assertIn("pi-package", pkg.get("keywords", []))
186
+ for skill_path in pkg["pi"].get("skills", []):
187
+ resolved = (PROJECT_ROOT / skill_path).resolve()
188
+ self.assertTrue(resolved.exists(), f"Pi skill path not found: {skill_path}")
189
+
190
+ for ext_path in pkg["pi"].get("extensions", []):
191
+ resolved = (PROJECT_ROOT / ext_path).resolve()
192
+ self.assertTrue(resolved.exists(), f"Pi extension path not found: {ext_path}")
193
+
194
+ # 2. OpenCode plugin validation
195
+ self.assertIn("opencode", pkg.get("keywords", []))
196
+ self.assertIn("./opencode", pkg.get("exports", {}))
197
+ opencode_entry = PROJECT_ROOT / "plugins/opencode/index.js"
198
+ self.assertTrue(opencode_entry.exists())
199
+
200
+ # 3. IUMBTEMS binary alias
201
+ self.assertIn("iumbtems", pkg.get("bin", {}))
202
+ self.assertTrue((PROJECT_ROOT / pkg["bin"]["iumbtems"]).exists())
203
+
176
204
 
177
205
  if __name__ == "__main__":
178
206
  unittest.main()
207
+