@heretek-ai/epistemic-swarm 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/.claude-plugin/marketplace.json +14 -0
- package/.claude-plugin/plugin.json +58 -0
- package/LICENSE +126 -0
- package/README.md +130 -0
- package/bin/cli.js +119 -0
- package/config/claude-settings-patch.json +10 -0
- package/config/docker-compose.infra.yml +23 -0
- package/config/mcp-research-servers.json +26 -0
- package/config/searxng_mcp.py +133 -0
- package/install.sh +102 -0
- package/package.json +52 -0
- package/prompts/agent_alpha_thesis.md +70 -0
- package/prompts/agent_beta_antithesis.md +78 -0
- package/prompts/base_epistemic_system.md +50 -0
- package/prompts/epistemic_auditor.md +74 -0
- package/prompts/orchestrator.md +70 -0
- package/runner/__init__.py +0 -0
- package/runner/__pycache__/__init__.cpython-314.pyc +0 -0
- package/runner/__pycache__/auditor_engine.cpython-314.pyc +0 -0
- package/runner/__pycache__/research_swarm.cpython-314.pyc +0 -0
- package/runner/__pycache__/state_machine.cpython-314.pyc +0 -0
- package/runner/auditor_engine.py +222 -0
- package/runner/research_swarm.py +337 -0
- package/runner/state_machine.py +192 -0
- package/runner/tests/__pycache__/test_swarm.cpython-314.pyc +0 -0
- package/runner/tests/test_swarm.py +178 -0
- package/skills/grilling/SKILL.md +48 -0
- package/skills/grilling/__init__.py +0 -0
- package/skills/grilling/socratic_tree.py +148 -0
- package/skills/research-cache/SKILL.md +36 -0
- package/skills/research-cache/__init__.py +0 -0
- package/skills/research-cache/__pycache__/__init__.cpython-314.pyc +0 -0
- package/skills/research-cache/__pycache__/hasher.cpython-314.pyc +0 -0
- package/skills/research-cache/hasher.py +195 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "heretek-official",
|
|
3
|
+
"owner": "Heretek AI",
|
|
4
|
+
"description": "Official plugins and agent harnesses from Heretek AI",
|
|
5
|
+
"plugins": {
|
|
6
|
+
"epistemic-swarm": {
|
|
7
|
+
"source": {
|
|
8
|
+
"source": "github",
|
|
9
|
+
"repo": "Heretek-AI/IUMBTEMS"
|
|
10
|
+
},
|
|
11
|
+
"description": "High-Integrity Dialectic Research Agent Harness for Claude Code"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "epistemic-swarm",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "High-Integrity Dialectic Research Agent Harness for Claude Code enforcing empirical evidence over parametric hallucination.",
|
|
5
|
+
"author": "Heretek AI",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": "https://github.com/Heretek-AI/IUMBTEMS",
|
|
8
|
+
"mcpServers": {
|
|
9
|
+
"brave-search": {
|
|
10
|
+
"command": "npx",
|
|
11
|
+
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
|
|
12
|
+
"env": {
|
|
13
|
+
"BRAVE_SEARCH_API_KEY": "${BRAVE_SEARCH_API_KEY}"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"firecrawl": {
|
|
17
|
+
"command": "npx",
|
|
18
|
+
"args": ["-y", "firecrawl-mcp"],
|
|
19
|
+
"env": {
|
|
20
|
+
"FIRECRAWL_API_KEY": "${FIRECRAWL_API_KEY}",
|
|
21
|
+
"FIRECRAWL_API_URL": "${FIRECRAWL_API_URL:-http://localhost:3002}"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"searxng": {
|
|
25
|
+
"command": "python3",
|
|
26
|
+
"args": ["${PLUGIN_DIR}/config/searxng_mcp.py"],
|
|
27
|
+
"env": {
|
|
28
|
+
"SEARXNG_URL": "${SEARXNG_URL:-http://localhost:8080}"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"skills": [
|
|
33
|
+
"./skills/grilling",
|
|
34
|
+
"./skills/research-cache"
|
|
35
|
+
],
|
|
36
|
+
"configuration": {
|
|
37
|
+
"SEARXNG_URL": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "SearXNG metasearch instance URL",
|
|
40
|
+
"default": "http://localhost:8080"
|
|
41
|
+
},
|
|
42
|
+
"FIRECRAWL_API_URL": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"description": "Firecrawl API endpoint for JS/Markdown extraction",
|
|
45
|
+
"default": "http://localhost:3002"
|
|
46
|
+
},
|
|
47
|
+
"FIRECRAWL_API_KEY": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"description": "Firecrawl API Key (optional for self-hosted instances)",
|
|
50
|
+
"default": ""
|
|
51
|
+
},
|
|
52
|
+
"BRAVE_SEARCH_API_KEY": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "Brave Search API Key for discovery",
|
|
55
|
+
"default": ""
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work.
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean any work of authorship, including
|
|
48
|
+
the original version of the Work and any modifications or additions
|
|
49
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
50
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
51
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
52
|
+
the copyright owner.
|
|
53
|
+
|
|
54
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
55
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
56
|
+
subsequently incorporated within the Work.
|
|
57
|
+
|
|
58
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
59
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
60
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
61
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
62
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
63
|
+
Work and such Derivative Works in Source or Object form.
|
|
64
|
+
|
|
65
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
66
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
67
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
68
|
+
(except as stated in this section) patent license to make, have made,
|
|
69
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
70
|
+
where such license applies only to those patent claims licensable
|
|
71
|
+
by such Contributor that are necessarily infringed by their
|
|
72
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
73
|
+
with the Work to which such Contribution(s) was submitted.
|
|
74
|
+
|
|
75
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
76
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
77
|
+
modifications, and in Source or Object form, provided that You
|
|
78
|
+
meet the following conditions:
|
|
79
|
+
|
|
80
|
+
(a) You must give any other recipients of the Work or
|
|
81
|
+
Derivative Works a copy of this License; and
|
|
82
|
+
|
|
83
|
+
(b) You must cause any modified files to carry prominent notices
|
|
84
|
+
stating that You changed the files; and
|
|
85
|
+
|
|
86
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
87
|
+
that You distribute, all copyright, patent, trademark, and
|
|
88
|
+
attribution notices from the Source form of the Work,
|
|
89
|
+
excluding those notices that do not pertain to any part of
|
|
90
|
+
the Derivative Works; and
|
|
91
|
+
|
|
92
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
93
|
+
distribution, then any Derivative Works that You distribute must
|
|
94
|
+
include a readable copy of the attribution notices contained
|
|
95
|
+
within such NOTICE file.
|
|
96
|
+
|
|
97
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
98
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
99
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
100
|
+
this License, without any additional terms or conditions.
|
|
101
|
+
|
|
102
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
103
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
104
|
+
except as required for reasonable and customary use in describing the
|
|
105
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
106
|
+
|
|
107
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
108
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
109
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
110
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
111
|
+
implied, including, without limitation, any warranties or conditions
|
|
112
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
113
|
+
PARTICULAR PURPOSE.
|
|
114
|
+
|
|
115
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
116
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
117
|
+
unless required by applicable law (such as deliberate and grossly
|
|
118
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
119
|
+
liable to You for damages, including any direct, indirect, special,
|
|
120
|
+
incidental, or consequential damages of any character arising as a
|
|
121
|
+
result of this License or out of the use or inability to use the
|
|
122
|
+
Work.
|
|
123
|
+
|
|
124
|
+
END OF TERMS AND CONDITIONS
|
|
125
|
+
|
|
126
|
+
Copyright 2026 Heretek AI
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Epistemic Swarm 🌟
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@heretek-ai/epistemic-swarm)
|
|
4
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
5
|
+
[](https://github.com/Heretek-AI/IUMBTEMS/actions)
|
|
6
|
+
|
|
7
|
+
> **High-Integrity Dialectic Research Agent Harness for Claude Code**
|
|
8
|
+
> *Enforcing verified empirical evidence over parametric hallucination.*
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🎯 The Epistemic Mandate
|
|
13
|
+
|
|
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
|
+
|
|
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.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
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)"]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## ⚡ Quickstart
|
|
54
|
+
|
|
55
|
+
### Option 1: Run via NPX (Zero Setup)
|
|
56
|
+
```bash
|
|
57
|
+
# Execute deep research swarm directly
|
|
58
|
+
npx @heretek-ai/epistemic-swarm run "Evaluate FPGA Poseidon prover latency bounds"
|
|
59
|
+
|
|
60
|
+
# Run Socratic decision tree framing
|
|
61
|
+
npx @heretek-ai/epistemic-swarm grill --objective "L1 vs L2 state verification trade-offs"
|
|
62
|
+
```
|
|
63
|
+
|
|
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
|
|
69
|
+
```
|
|
70
|
+
This automatically symlinks the `/grilling` and `/research-cache` skills into `~/.claude/skills/` and configures MCP servers in `~/.claude.json`.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 🏷️ Epistemic Tagging Taxonomy
|
|
75
|
+
|
|
76
|
+
| Tag | Meaning | Requirement |
|
|
77
|
+
| :--- | :--- | :--- |
|
|
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. |
|
|
80
|
+
| `[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. |
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 🔍 Multi-Tier OSINT & Search Pipeline
|
|
86
|
+
|
|
87
|
+
1. **Discovery Tier**: SearXNG (metasearch) and Brave Search API.
|
|
88
|
+
2. **Extraction Tier**: Firecrawl (headless JavaScript rendering, DOM cleaning, Markdown extraction).
|
|
89
|
+
3. **Academic Tier**: Semantic Scholar / arXiv MCPs for DOI resolution.
|
|
90
|
+
4. **Caching Tier**: Content-addressed SHA-256 storage (`skills/research-cache/hasher.py`).
|
|
91
|
+
|
|
92
|
+
### Optional Turnkey Infrastructure (SearXNG + Firecrawl)
|
|
93
|
+
To run your own unbiased metasearch and headless extractor locally:
|
|
94
|
+
```bash
|
|
95
|
+
docker compose -f config/docker-compose.infra.yml up -d
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 🧪 Testing
|
|
101
|
+
|
|
102
|
+
Epistemic Swarm comes with an automated test suite verifying source hashing, quote substring matching, IPC state transitions, and mock swarm dispatch:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npm test
|
|
106
|
+
```
|
|
107
|
+
|
|
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
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 📄 License
|
|
129
|
+
|
|
130
|
+
Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Epistemic Swarm CLI
|
|
5
|
+
* Multi-agent dialectic research harness for Claude Code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { spawnSync } = require('child_process');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
|
|
12
|
+
const PKG_ROOT = path.resolve(__dirname, '..');
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
const command = args[0] || 'help';
|
|
15
|
+
|
|
16
|
+
function printHelp() {
|
|
17
|
+
console.log(`
|
|
18
|
+
🌟 Epistemic Swarm: High-Integrity Research Harness for Claude Code
|
|
19
|
+
Organization: @heretek-ai | Repository: Heretek-AI/IUMBTEMS
|
|
20
|
+
|
|
21
|
+
Usage:
|
|
22
|
+
npx @heretek-ai/epistemic-swarm <command> [options]
|
|
23
|
+
iumbtems <command> [options]
|
|
24
|
+
|
|
25
|
+
Commands:
|
|
26
|
+
run "<objective>" Run the dialectic multi-agent research swarm
|
|
27
|
+
grill Launch interactive Socratic decision tree framing
|
|
28
|
+
install Install skills & MCP servers into ~/.claude/
|
|
29
|
+
test Run test suite for hashing, state machine & auditor
|
|
30
|
+
doctor Check environment requirements (Claude Code, Python, Node)
|
|
31
|
+
help Show this help message
|
|
32
|
+
|
|
33
|
+
Options:
|
|
34
|
+
--mock-claude Run swarm with synthetic mock responses (zero API cost)
|
|
35
|
+
--frontier <file> Path to settled frontier.json from Socratic grilling
|
|
36
|
+
--dir <path> Path to .research workspace directory (default: .research)
|
|
37
|
+
|
|
38
|
+
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
|
|
42
|
+
`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function runPython(scriptRelPath, extraArgs = []) {
|
|
46
|
+
let finalArgs = [];
|
|
47
|
+
if (scriptRelPath === '-m') {
|
|
48
|
+
finalArgs = ['-m', ...extraArgs];
|
|
49
|
+
} else {
|
|
50
|
+
const scriptPath = path.join(PKG_ROOT, scriptRelPath);
|
|
51
|
+
finalArgs = [scriptPath, ...extraArgs];
|
|
52
|
+
}
|
|
53
|
+
const result = spawnSync('python3', finalArgs, {
|
|
54
|
+
stdio: 'inherit',
|
|
55
|
+
cwd: process.cwd(),
|
|
56
|
+
env: { ...process.env, PYTHONPATH: PKG_ROOT }
|
|
57
|
+
});
|
|
58
|
+
process.exit(result.status !== null ? result.status : 1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function runBash(scriptRelPath, extraArgs = []) {
|
|
62
|
+
const scriptPath = path.join(PKG_ROOT, scriptRelPath);
|
|
63
|
+
const result = spawnSync('bash', [scriptPath, ...extraArgs], {
|
|
64
|
+
stdio: 'inherit',
|
|
65
|
+
cwd: process.cwd()
|
|
66
|
+
});
|
|
67
|
+
process.exit(result.status !== null ? result.status : 1);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
switch (command) {
|
|
71
|
+
case 'run': {
|
|
72
|
+
const objective = args[1];
|
|
73
|
+
if (!objective || objective.startsWith('--')) {
|
|
74
|
+
console.error('Error: Please provide a research objective string.');
|
|
75
|
+
console.error('Example: npx @heretek-ai/epistemic-swarm run "Evaluate FPGA prover latency"');
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
const forwardArgs = ['--objective', objective, ...args.slice(2)];
|
|
79
|
+
runPython('runner/research_swarm.py', forwardArgs);
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
case 'grill': {
|
|
84
|
+
runPython('skills/grilling/socratic_tree.py', args.slice(1));
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
case 'install': {
|
|
89
|
+
runBash('install.sh', args.slice(1));
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
case 'test': {
|
|
94
|
+
runPython('-m', ['unittest', 'discover', '-s', 'runner/tests']);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
case 'doctor': {
|
|
99
|
+
console.log('🔍 Checking Epistemic Swarm Environment:\n');
|
|
100
|
+
const claudeCheck = spawnSync('claude', ['--version'], { encoding: 'utf-8' });
|
|
101
|
+
if (claudeCheck.status === 0) {
|
|
102
|
+
console.log(`✅ Claude Code: ${claudeCheck.stdout.trim()}`);
|
|
103
|
+
} else {
|
|
104
|
+
console.log('⚠️ Claude Code CLI not found in PATH (Install via npm i -g @anthropic-ai/claude-code)');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const pyCheck = spawnSync('python3', ['--version'], { encoding: 'utf-8' });
|
|
108
|
+
console.log(`✅ Python: ${pyCheck.stdout ? pyCheck.stdout.trim() : 'python3 missing'}`);
|
|
109
|
+
|
|
110
|
+
console.log(`✅ Node.js: ${process.version}`);
|
|
111
|
+
console.log(`📁 Package Root: ${PKG_ROOT}`);
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
case 'help':
|
|
116
|
+
default:
|
|
117
|
+
printHelp();
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
version: '3.8'
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
searxng:
|
|
5
|
+
image: docker.io/searxng/searxng:latest
|
|
6
|
+
container_name: epistemic-searxng
|
|
7
|
+
ports:
|
|
8
|
+
- "8080:8080"
|
|
9
|
+
volumes:
|
|
10
|
+
- ./searxng-data:/etc/searxng:rw
|
|
11
|
+
environment:
|
|
12
|
+
- SEARXNG_BASE_URL=http://localhost:8080/
|
|
13
|
+
restart: unless-stopped
|
|
14
|
+
|
|
15
|
+
firecrawl:
|
|
16
|
+
image: mendableai/firecrawl:latest
|
|
17
|
+
container_name: epistemic-firecrawl
|
|
18
|
+
ports:
|
|
19
|
+
- "3002:3002"
|
|
20
|
+
environment:
|
|
21
|
+
- PORT=3002
|
|
22
|
+
- NUM_WORKERS=4
|
|
23
|
+
restart: unless-stopped
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mcpServers": {
|
|
3
|
+
"brave-search": {
|
|
4
|
+
"command": "npx",
|
|
5
|
+
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
|
|
6
|
+
"env": {
|
|
7
|
+
"BRAVE_SEARCH_API_KEY": "${BRAVE_SEARCH_API_KEY}"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"searxng": {
|
|
11
|
+
"command": "python3",
|
|
12
|
+
"args": ["config/searxng_mcp.py"],
|
|
13
|
+
"env": {
|
|
14
|
+
"SEARXNG_URL": "${SEARXNG_URL:-http://localhost:8080}"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"firecrawl": {
|
|
18
|
+
"command": "npx",
|
|
19
|
+
"args": ["-y", "firecrawl-mcp"],
|
|
20
|
+
"env": {
|
|
21
|
+
"FIRECRAWL_API_KEY": "${FIRECRAWL_API_KEY}",
|
|
22
|
+
"FIRECRAWL_API_URL": "${FIRECRAWL_API_URL:-http://localhost:3002}"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Lightweight MCP Server for SearXNG Metasearch.
|
|
4
|
+
Provides unbiased search results directly to Claude Code agents.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
import json
|
|
10
|
+
import urllib.request
|
|
11
|
+
import urllib.parse
|
|
12
|
+
from typing import Dict, Any, List
|
|
13
|
+
|
|
14
|
+
SEARXNG_URL = os.environ.get("SEARXNG_URL", "http://localhost:8080")
|
|
15
|
+
|
|
16
|
+
def search_searxng(query: str, categories: str = "general", max_results: int = 10) -> List[Dict[str, Any]]:
|
|
17
|
+
"""Query SearXNG JSON endpoint."""
|
|
18
|
+
params = {
|
|
19
|
+
"q": query,
|
|
20
|
+
"format": "json",
|
|
21
|
+
"categories": categories,
|
|
22
|
+
"language": "en"
|
|
23
|
+
}
|
|
24
|
+
url = f"{SEARXNG_URL.rstrip('/')}/search?{urllib.parse.urlencode(params)}"
|
|
25
|
+
req = urllib.request.Request(url, headers={"User-Agent": "EpistemicSwarm/1.0"})
|
|
26
|
+
|
|
27
|
+
try:
|
|
28
|
+
with urllib.request.urlopen(req, timeout=10) as resp:
|
|
29
|
+
data = json.loads(resp.read().decode("utf-8"))
|
|
30
|
+
results = data.get("results", [])[:max_results]
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
"title": r.get("title", ""),
|
|
34
|
+
"url": r.get("url", ""),
|
|
35
|
+
"snippet": r.get("content", ""),
|
|
36
|
+
"engine": r.get("engine", "")
|
|
37
|
+
}
|
|
38
|
+
for r in results
|
|
39
|
+
]
|
|
40
|
+
except Exception as e:
|
|
41
|
+
return [{"error": f"Failed to query SearXNG at {SEARXNG_URL}: {str(e)}"}]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def handle_json_rpc(line: str):
|
|
45
|
+
"""Minimal JSON-RPC 2.0 loop for MCP protocol."""
|
|
46
|
+
try:
|
|
47
|
+
msg = json.loads(line)
|
|
48
|
+
except Exception:
|
|
49
|
+
return
|
|
50
|
+
|
|
51
|
+
msg_id = msg.get("id")
|
|
52
|
+
method = msg.get("method")
|
|
53
|
+
|
|
54
|
+
if method == "initialize":
|
|
55
|
+
response = {
|
|
56
|
+
"jsonrpc": "2.0",
|
|
57
|
+
"id": msg_id,
|
|
58
|
+
"result": {
|
|
59
|
+
"protocolVersion": "2024-11-05",
|
|
60
|
+
"capabilities": {
|
|
61
|
+
"tools": {}
|
|
62
|
+
},
|
|
63
|
+
"serverInfo": {
|
|
64
|
+
"name": "searxng-mcp",
|
|
65
|
+
"version": "1.0.0"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
sys.stdout.write(json.dumps(response) + "\n")
|
|
70
|
+
sys.stdout.flush()
|
|
71
|
+
|
|
72
|
+
elif method == "tools/list":
|
|
73
|
+
response = {
|
|
74
|
+
"jsonrpc": "2.0",
|
|
75
|
+
"id": msg_id,
|
|
76
|
+
"result": {
|
|
77
|
+
"tools": [
|
|
78
|
+
{
|
|
79
|
+
"name": "searxng_search",
|
|
80
|
+
"description": "Execute an unbiased multi-engine metasearch via SearXNG.",
|
|
81
|
+
"inputSchema": {
|
|
82
|
+
"type": "object",
|
|
83
|
+
"properties": {
|
|
84
|
+
"query": {"type": "string", "description": "Search query"},
|
|
85
|
+
"categories": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"description": "Categories (general, science, it)",
|
|
88
|
+
"default": "general"
|
|
89
|
+
},
|
|
90
|
+
"max_results": {"type": "integer", "default": 10}
|
|
91
|
+
},
|
|
92
|
+
"required": ["query"]
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
sys.stdout.write(json.dumps(response) + "\n")
|
|
99
|
+
sys.stdout.flush()
|
|
100
|
+
|
|
101
|
+
elif method == "tools/call":
|
|
102
|
+
params = msg.get("params", {})
|
|
103
|
+
tool_name = params.get("name")
|
|
104
|
+
args = params.get("arguments", {})
|
|
105
|
+
|
|
106
|
+
if tool_name == "searxng_search":
|
|
107
|
+
query = args.get("query", "")
|
|
108
|
+
cat = args.get("categories", "general")
|
|
109
|
+
limit = args.get("max_results", 10)
|
|
110
|
+
res = search_searxng(query, categories=cat, max_results=limit)
|
|
111
|
+
response = {
|
|
112
|
+
"jsonrpc": "2.0",
|
|
113
|
+
"id": msg_id,
|
|
114
|
+
"result": {
|
|
115
|
+
"content": [
|
|
116
|
+
{
|
|
117
|
+
"type": "text",
|
|
118
|
+
"text": json.dumps(res, indent=2)
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
sys.stdout.write(json.dumps(response) + "\n")
|
|
124
|
+
sys.stdout.flush()
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def main():
|
|
128
|
+
for line in sys.stdin:
|
|
129
|
+
if line.strip():
|
|
130
|
+
handle_json_rpc(line.strip())
|
|
131
|
+
|
|
132
|
+
if __name__ == "__main__":
|
|
133
|
+
main()
|