ennodia 0.1.0-rc.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.
Files changed (53) hide show
  1. package/CONTRIBUTING.md +21 -0
  2. package/LICENSE +21 -0
  3. package/README.md +99 -0
  4. package/bench/README.md +32 -0
  5. package/bench/bug-recall/run.ts +331 -0
  6. package/bench/bug-recall/scorer.ts +424 -0
  7. package/bench/fixtures/bug-recall/001-missing-await/input.ts +33 -0
  8. package/bench/fixtures/bug-recall/001-missing-await/oracle.json +28 -0
  9. package/bench/fixtures/bug-recall/001-missing-await/responses/claude-code-solo.md +1 -0
  10. package/bench/fixtures/bug-recall/001-missing-await/responses/codex-solo.md +1 -0
  11. package/bench/fixtures/bug-recall/001-missing-await/responses/ennodia-parallel-compare.md +1 -0
  12. package/bench/fixtures/bug-recall/002-timeout-drain/input.ts +40 -0
  13. package/bench/fixtures/bug-recall/002-timeout-drain/oracle.json +28 -0
  14. package/bench/fixtures/bug-recall/002-timeout-drain/responses/claude-code-solo.md +1 -0
  15. package/bench/fixtures/bug-recall/002-timeout-drain/responses/codex-solo.md +1 -0
  16. package/bench/fixtures/bug-recall/002-timeout-drain/responses/ennodia-parallel-compare.md +1 -0
  17. package/bench/fixtures/bug-recall/003-schema-contract/input.ts +22 -0
  18. package/bench/fixtures/bug-recall/003-schema-contract/oracle.json +28 -0
  19. package/bench/fixtures/bug-recall/003-schema-contract/responses/claude-code-solo.md +1 -0
  20. package/bench/fixtures/bug-recall/003-schema-contract/responses/codex-solo.md +1 -0
  21. package/bench/fixtures/bug-recall/003-schema-contract/responses/ennodia-parallel-compare.md +1 -0
  22. package/bench/fixtures/bug-recall/004-cancel-propagation/input.ts +28 -0
  23. package/bench/fixtures/bug-recall/004-cancel-propagation/oracle.json +28 -0
  24. package/bench/fixtures/bug-recall/004-cancel-propagation/responses/claude-code-solo.md +1 -0
  25. package/bench/fixtures/bug-recall/004-cancel-propagation/responses/codex-solo.md +1 -0
  26. package/bench/fixtures/bug-recall/004-cancel-propagation/responses/ennodia-parallel-compare.md +1 -0
  27. package/bench/results/.gitkeep +1 -0
  28. package/docs/assets/agents/antigravity-color.svg +1 -0
  29. package/docs/assets/agents/claudecode-color.svg +1 -0
  30. package/docs/assets/agents/codex-color.svg +1 -0
  31. package/docs/assets/agents/opencode-dark.svg +1 -0
  32. package/docs/assets/agents/opencode-light.svg +1 -0
  33. package/docs/assets/icons/arrow.svg +1 -0
  34. package/docs/assets/icons/github.svg +1 -0
  35. package/docs/assets/icons/link.svg +1 -0
  36. package/docs/assets/logo-dark.svg +1 -0
  37. package/docs/assets/logo.svg +1 -0
  38. package/docs/assets/orchestration-pipeline.svg +74 -0
  39. package/docs/getting-started.md +107 -0
  40. package/docs/in-depth/architecture.md +53 -0
  41. package/docs/in-depth/releasing.md +120 -0
  42. package/docs/index.md +16 -0
  43. package/docs/reference/mcp-tools.md +104 -0
  44. package/package.json +87 -0
  45. package/src/compare.ts +777 -0
  46. package/src/diagnosis.ts +161 -0
  47. package/src/harnesses.ts +302 -0
  48. package/src/index.ts +52 -0
  49. package/src/planner.ts +106 -0
  50. package/src/runs.ts +777 -0
  51. package/src/server.ts +747 -0
  52. package/src/tasks.ts +602 -0
  53. package/src/version.ts +1 -0
@@ -0,0 +1,21 @@
1
+ # Contributing to Ennodia
2
+
3
+ ## Prerequisites
4
+
5
+ - **Bun** 1.3.14+
6
+ - Local AI tools are optional unless you are changing their adapters
7
+
8
+ ## Quickstart
9
+
10
+ ```sh
11
+ bun install
12
+ bun run verify
13
+ ```
14
+
15
+ `verify` runs typechecking, Oxlint, unit tests, and local MCP smoke checks.
16
+
17
+ Before changing release metadata or package contents, also run:
18
+
19
+ ```sh
20
+ bun run release:check
21
+ ```
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present, Theo Chernin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,99 @@
1
+ <div align="center">
2
+
3
+ <a href="https://ennodia.cherninlab.com">
4
+ <picture>
5
+ <source media="(prefers-color-scheme: dark)" srcset="docs/assets/logo-dark.svg">
6
+ <source media="(prefers-color-scheme: light)" srcset="docs/assets/logo.svg">
7
+ <img alt="Ennodia" src="docs/assets/logo.svg" width="235" height="50">
8
+ </picture>
9
+ </a>
10
+
11
+ <p><strong>MCP server that lets one AI agent ask other agents for help</strong></p>
12
+
13
+ <p>
14
+ <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-informational"></a>
15
+ <img alt="CI" src="https://github.com/cherninlab/ennodia/actions/workflows/ci.yml/badge.svg" />
16
+ </p>
17
+
18
+ </div>
19
+
20
+ Ennodia is a local MCP server that lets one AI agent ask other agents for help while a task is still in progress. It routes the request, runs selected command line tools, tracks status and output, and can compare several answers before returning one result.
21
+
22
+ It is built for workflows where no single model or agent should be trusted as the only reviewer.
23
+
24
+ ## Local Setup
25
+
26
+ From a checkout:
27
+
28
+ ```sh
29
+ git clone https://github.com/cherninlab/ennodia
30
+ cd ennodia
31
+ bun install
32
+ bun run verify
33
+ ```
34
+
35
+ After the npm package is published, the prerelease channel will be available as
36
+ `bunx ennodia@next`. `npx` can also launch Ennodia, but only when `bun` is
37
+ already available on `PATH`.
38
+
39
+ ## What Ennodia Does
40
+
41
+ - Discovers available local AI tools
42
+ - Plans which tool should handle a request
43
+ - Starts and monitors child tasks
44
+ - Shows status, timing, logs, and failures
45
+ - Cancels tasks and runs explicitly
46
+ - Compares multiple completed outputs
47
+ - Synthesizes one answer from the comparison
48
+
49
+ ## Supported Harnesses
50
+
51
+ Current adapters:
52
+
53
+ - Codex CLI
54
+ - Claude Code
55
+ - OpenCode
56
+ - Antigravity
57
+
58
+ Adapters stay thin. Shared routing, tracing, task state, recovery, and Compare
59
+ logic live in the core modules.
60
+
61
+ ## MCP Tools
62
+
63
+ Common entrypoints:
64
+
65
+ - `ennodia_list_harnesses` - show detected tools
66
+ - `ennodia_plan` - preview routing for a prompt
67
+ - `ennodia_start` - start direct child tasks without run-level synthesis
68
+ - `ennodia_run` - plan, execute, optionally Compare, and return a final answer
69
+ - `ennodia_get_run` - inspect run state, events, ETA, and final output
70
+ - `ennodia_cancel_run` - cancel a running orchestration
71
+ - `ennodia_start_compare` - compare completed task outputs or supplied responses
72
+
73
+ Lower-level task tools are available for polling and cancellation.
74
+
75
+ ## Documentation
76
+
77
+ - [Getting started](docs/getting-started.md)
78
+ - [How Ennodia works](docs/in-depth/architecture.md)
79
+ - [MCP tools](docs/reference/mcp-tools.md)
80
+ - [Releasing Ennodia](docs/in-depth/releasing.md)
81
+
82
+ ## Benchmarks
83
+
84
+ The first benchmark is `multi-model-bug-recall`: small TypeScript review
85
+ fixtures scored against committed bug oracles. Run the deterministic fixture
86
+ suite with:
87
+
88
+ ```sh
89
+ bun run bench:bug-recall
90
+ ```
91
+
92
+ Live harness runs are available through `bun run bench:bug-recall:live` and are
93
+ kept out of `bun run verify`.
94
+
95
+ ## Contributing
96
+
97
+ Ennodia is under active development. Bug reports and small, focused pull requests
98
+ are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for the local verification
99
+ workflow.
@@ -0,0 +1,32 @@
1
+ # Benchmarks
2
+
3
+ Ennodia's first release-candidate benchmark is `multi-model-bug-recall`: small
4
+ TypeScript review fixtures with committed oracles. It measures whether
5
+ parallel peer review plus Compare recovers more required findings than a solo
6
+ harness answer.
7
+
8
+ The default command is deterministic and uses committed reference outputs:
9
+
10
+ ```sh
11
+ bun run bench:bug-recall
12
+ ```
13
+
14
+ The live command starts a fresh Ennodia MCP server and runs real harnesses. It
15
+ is intentionally not part of `bun run verify`.
16
+
17
+ ```sh
18
+ bun run bench:bug-recall:live -- --fixture 001-missing-await
19
+ ```
20
+
21
+ Useful flags:
22
+
23
+ - `--fixture <id>` runs one fixture; repeat it to select several.
24
+ - `--harness <id>` adds a solo baseline harness in live mode. Defaults to
25
+ `codex` and `claude-code`.
26
+ - `--judge-harness <id>` and `--synthesizer-harness <id>` pin Compare roles.
27
+ - `--timeout-ms <ms>` sets the per-run timeout for live harness calls.
28
+ - `--out <dir>` writes results to a specific directory.
29
+
30
+ Results are written under `bench/results/bug-recall/`. Raw benchmark output is
31
+ gitignored by default because live runs include model output and environment
32
+ metadata.
@@ -0,0 +1,331 @@
1
+ import { mkdir, readdir, writeFile } from "node:fs/promises";
2
+ import { basename, join } from "node:path";
3
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
4
+ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
5
+ import {
6
+ buildPrompt,
7
+ DEFAULT_FIXTURES_ROOT,
8
+ formatConditionTable,
9
+ loadCases,
10
+ scoreBenchmark,
11
+ type BenchmarkCase,
12
+ type BenchmarkSummary,
13
+ type OutputRecord,
14
+ } from "./scorer";
15
+ import { ENNODIA_VERSION } from "../../src/version";
16
+
17
+ type CliOptions = {
18
+ live: boolean;
19
+ fixtureIds: string[];
20
+ harnessIds: string[];
21
+ timeoutMs: number;
22
+ outDir?: string;
23
+ judgeHarnessId?: string;
24
+ synthesizerHarnessId?: string;
25
+ };
26
+
27
+ type McpTextContent = {
28
+ type: "text";
29
+ text: string;
30
+ };
31
+
32
+ type RunView = {
33
+ id: string;
34
+ status: "executing" | "comparing" | "succeeded" | "failed" | "cancelled";
35
+ finalAnswer?: string;
36
+ selectedHarnessIds?: string[];
37
+ taskIds?: string[];
38
+ compareId?: string;
39
+ elapsedMs?: number;
40
+ error?: string;
41
+ };
42
+
43
+ const DEFAULT_LIVE_HARNESSES = ["codex", "claude-code"];
44
+
45
+ const options = parseArgs(Bun.argv.slice(2));
46
+ const cases = await selectCases(await loadCases(), options.fixtureIds);
47
+ const outputs = options.live
48
+ ? await runLiveBenchmark(cases, options)
49
+ : await loadFixtureOutputs(cases);
50
+ const summary = await scoreBenchmark({
51
+ cases,
52
+ outputs,
53
+ mode: options.live ? "live" : "fixture",
54
+ });
55
+ const outDir = await resolveOutDir(options, summary);
56
+
57
+ await writeSummary(outDir, summary, outputs);
58
+
59
+ console.log(formatConditionTable(summary));
60
+ console.log("");
61
+ console.log(`Wrote benchmark results to ${outDir}`);
62
+
63
+ async function loadFixtureOutputs(cases: BenchmarkCase[]): Promise<OutputRecord[]> {
64
+ const outputs: OutputRecord[] = [];
65
+
66
+ for (const benchmarkCase of cases) {
67
+ const responseDir = new URL(
68
+ `${benchmarkCase.id}/responses/`,
69
+ DEFAULT_FIXTURES_ROOT,
70
+ );
71
+ const entries = await readdir(responseDir, { withFileTypes: true });
72
+ const files = entries
73
+ .filter((entry) => entry.isFile() && entry.name.endsWith(".md"))
74
+ .map((entry) => entry.name)
75
+ .sort();
76
+
77
+ for (const file of files) {
78
+ outputs.push({
79
+ caseId: benchmarkCase.id,
80
+ condition: basename(file, ".md"),
81
+ text: await Bun.file(new URL(file, responseDir)).text(),
82
+ metadata: { mode: "fixture", source: file },
83
+ });
84
+ }
85
+ }
86
+
87
+ return outputs;
88
+ }
89
+
90
+ async function runLiveBenchmark(
91
+ cases: BenchmarkCase[],
92
+ options: CliOptions,
93
+ ): Promise<OutputRecord[]> {
94
+ const client = new Client({
95
+ name: "ennodia-benchmark",
96
+ version: ENNODIA_VERSION,
97
+ });
98
+ const transport = new StdioClientTransport({
99
+ command: "bun",
100
+ args: ["run", "src/index.ts"],
101
+ cwd: new URL("../../", import.meta.url).pathname,
102
+ stderr: "pipe",
103
+ });
104
+ await client.connect(transport);
105
+
106
+ try {
107
+ const outputs: OutputRecord[] = [];
108
+ const harnessIds = options.harnessIds.length > 0
109
+ ? options.harnessIds
110
+ : DEFAULT_LIVE_HARNESSES;
111
+
112
+ for (const benchmarkCase of cases) {
113
+ const prompt = buildPrompt(benchmarkCase);
114
+
115
+ for (const harnessId of harnessIds) {
116
+ const run = await startAndWaitForRun(client, {
117
+ prompt,
118
+ harnessId,
119
+ mode: "single",
120
+ compare: false,
121
+ timeoutMs: options.timeoutMs,
122
+ });
123
+ outputs.push(runToOutput(benchmarkCase.id, `${harnessId}-solo`, run));
124
+ }
125
+
126
+ const parallelRun = await startAndWaitForRun(client, {
127
+ prompt,
128
+ mode: "parallel",
129
+ compare: true,
130
+ timeoutMs: options.timeoutMs,
131
+ judgeHarnessId: options.judgeHarnessId,
132
+ synthesizerHarnessId: options.synthesizerHarnessId,
133
+ maxOutputChars: 16_000,
134
+ });
135
+ outputs.push(runToOutput(
136
+ benchmarkCase.id,
137
+ "ennodia-parallel-compare",
138
+ parallelRun,
139
+ ));
140
+ }
141
+
142
+ return outputs;
143
+ } finally {
144
+ await client.close();
145
+ }
146
+ }
147
+
148
+ async function startAndWaitForRun(
149
+ client: Client,
150
+ args: Record<string, unknown>,
151
+ ): Promise<RunView> {
152
+ const started = parseTextResult(await client.callTool({
153
+ name: "ennodia_run",
154
+ arguments: args,
155
+ })) as RunView;
156
+
157
+ let run = started;
158
+ while (run.status === "executing" || run.status === "comparing") {
159
+ await Bun.sleep(1_000);
160
+ run = parseTextResult(await client.callTool({
161
+ name: "ennodia_get_run",
162
+ arguments: {
163
+ runId: started.id,
164
+ includeEvents: true,
165
+ maxEvents: 80,
166
+ maxAnswerChars: 120_000,
167
+ },
168
+ })) as RunView;
169
+ }
170
+
171
+ if (run.status !== "succeeded") {
172
+ throw new Error(`Run ${started.id} ended as ${run.status}: ${run.error ?? ""}`);
173
+ }
174
+
175
+ return run;
176
+ }
177
+
178
+ function runToOutput(
179
+ caseId: string,
180
+ condition: string,
181
+ run: RunView,
182
+ ): OutputRecord {
183
+ return {
184
+ caseId,
185
+ condition,
186
+ text: run.finalAnswer ?? "",
187
+ metadata: {
188
+ mode: "live",
189
+ runId: run.id,
190
+ elapsedMs: run.elapsedMs,
191
+ selectedHarnessIds: run.selectedHarnessIds,
192
+ taskIds: run.taskIds,
193
+ compareId: run.compareId,
194
+ },
195
+ };
196
+ }
197
+
198
+ async function writeSummary(
199
+ outDir: string,
200
+ summary: BenchmarkSummary,
201
+ outputs: OutputRecord[],
202
+ ): Promise<void> {
203
+ await mkdir(outDir, { recursive: true });
204
+ await writeFile(
205
+ join(outDir, "summary.json"),
206
+ `${JSON.stringify({ ...summary, outputs }, null, 2)}\n`,
207
+ );
208
+ await writeFile(
209
+ join(outDir, "summary.md"),
210
+ [
211
+ `# ${summary.benchmark}`,
212
+ "",
213
+ `Mode: ${summary.mode}`,
214
+ "",
215
+ formatConditionTable(summary),
216
+ "",
217
+ "## Wins",
218
+ "",
219
+ ...summary.wins.map((win) =>
220
+ `- ${win.condition}: ${win.fixtures} fixture(s)`
221
+ ),
222
+ "",
223
+ ].join("\n"),
224
+ );
225
+ }
226
+
227
+ async function resolveOutDir(
228
+ options: CliOptions,
229
+ summary: BenchmarkSummary,
230
+ ): Promise<string> {
231
+ if (options.outDir) {
232
+ return options.outDir;
233
+ }
234
+
235
+ const stamp = summary.createdAt.replace(/[:.]/g, "-");
236
+ return join(
237
+ new URL("../results/bug-recall/", import.meta.url).pathname,
238
+ `${summary.mode}-${stamp}`,
239
+ );
240
+ }
241
+
242
+ async function selectCases(
243
+ cases: BenchmarkCase[],
244
+ fixtureIds: string[],
245
+ ): Promise<BenchmarkCase[]> {
246
+ if (fixtureIds.length === 0) {
247
+ return cases;
248
+ }
249
+
250
+ const selected = cases.filter((benchmarkCase) =>
251
+ fixtureIds.includes(benchmarkCase.id)
252
+ );
253
+ const missing = fixtureIds.filter((fixtureId) =>
254
+ !selected.some((benchmarkCase) => benchmarkCase.id === fixtureId)
255
+ );
256
+
257
+ if (missing.length > 0) {
258
+ throw new Error(`Unknown fixture id(s): ${missing.join(", ")}`);
259
+ }
260
+
261
+ return selected;
262
+ }
263
+
264
+ function parseArgs(args: string[]): CliOptions {
265
+ const options: CliOptions = {
266
+ live: false,
267
+ fixtureIds: [],
268
+ harnessIds: [],
269
+ timeoutMs: 300_000,
270
+ };
271
+
272
+ for (let index = 0; index < args.length; index += 1) {
273
+ const arg = args[index];
274
+
275
+ if (arg === "--live") {
276
+ options.live = true;
277
+ } else if (arg === "--fixture") {
278
+ options.fixtureIds.push(requireValue(args, ++index, arg));
279
+ } else if (arg === "--harness") {
280
+ options.harnessIds.push(requireValue(args, ++index, arg));
281
+ } else if (arg === "--timeout-ms") {
282
+ options.timeoutMs = Number(requireValue(args, ++index, arg));
283
+ } else if (arg === "--out") {
284
+ options.outDir = requireValue(args, ++index, arg);
285
+ } else if (arg === "--judge-harness") {
286
+ options.judgeHarnessId = requireValue(args, ++index, arg);
287
+ } else if (arg === "--synthesizer-harness") {
288
+ options.synthesizerHarnessId = requireValue(args, ++index, arg);
289
+ } else {
290
+ throw new Error(`Unknown option: ${arg}`);
291
+ }
292
+ }
293
+
294
+ if (!Number.isFinite(options.timeoutMs) || options.timeoutMs <= 0) {
295
+ throw new Error("--timeout-ms must be a positive number.");
296
+ }
297
+
298
+ return options;
299
+ }
300
+
301
+ function requireValue(args: string[], index: number, flag: string): string {
302
+ const value = args[index];
303
+ if (!value) {
304
+ throw new Error(`${flag} requires a value.`);
305
+ }
306
+
307
+ return value;
308
+ }
309
+
310
+ function parseTextResult(result: unknown): unknown {
311
+ const content = (result as { content?: unknown }).content;
312
+ if (!Array.isArray(content)) {
313
+ throw new Error("MCP response did not include content.");
314
+ }
315
+
316
+ const text = content
317
+ .filter(isMcpTextContent)
318
+ .map((item) => item.text)
319
+ .join("\n");
320
+
321
+ return JSON.parse(text);
322
+ }
323
+
324
+ function isMcpTextContent(value: unknown): value is McpTextContent {
325
+ return (
326
+ value !== null &&
327
+ typeof value === "object" &&
328
+ (value as { type?: unknown }).type === "text" &&
329
+ typeof (value as { text?: unknown }).text === "string"
330
+ );
331
+ }