dialectic 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/.cursor/commands/setup-test.mdc +175 -0
- package/.cursor/rules/basic-code-cleanup.mdc +1110 -0
- package/.cursor/rules/riper5.mdc +96 -0
- package/.env.example +6 -0
- package/AGENTS.md +1052 -0
- package/LICENSE +21 -0
- package/README.md +93 -0
- package/WARP.md +113 -0
- package/dialectic-1.0.0.tgz +0 -0
- package/dialectic.js +10 -0
- package/docs/commands.md +375 -0
- package/docs/configuration.md +882 -0
- package/docs/context_summarization.md +1023 -0
- package/docs/debate_flow.md +1127 -0
- package/docs/eval_flow.md +795 -0
- package/docs/evaluator.md +141 -0
- package/examples/debate-config-openrouter.json +48 -0
- package/examples/debate_config1.json +48 -0
- package/examples/eval/eval1/eval_config1.json +13 -0
- package/examples/eval/eval1/result1.json +62 -0
- package/examples/eval/eval1/result2.json +97 -0
- package/examples/eval_summary_format.md +11 -0
- package/examples/example3/debate-config.json +64 -0
- package/examples/example3/eval_config2.json +25 -0
- package/examples/example3/problem.md +17 -0
- package/examples/example3/rounds_test/eval_run.sh +16 -0
- package/examples/example3/rounds_test/run_test.sh +16 -0
- package/examples/kata1/architect-only-solution_2-rounds.json +121 -0
- package/examples/kata1/architect-perf-solution_2-rounds.json +234 -0
- package/examples/kata1/debate-config-kata1.json +54 -0
- package/examples/kata1/eval_architect-only_2-rounds.json +97 -0
- package/examples/kata1/eval_architect-perf_2-rounds.json +97 -0
- package/examples/kata1/kata1-report.md +12224 -0
- package/examples/kata1/kata1-report_temps-01_01_01_07.md +2451 -0
- package/examples/kata1/kata1.md +5 -0
- package/examples/kata1/meta.txt +1 -0
- package/examples/kata2/debate-config.json +54 -0
- package/examples/kata2/eval_config1.json +21 -0
- package/examples/kata2/eval_config2.json +25 -0
- package/examples/kata2/kata2.md +5 -0
- package/examples/kata2/only_architect/debate-config.json +45 -0
- package/examples/kata2/only_architect/eval_run.sh +11 -0
- package/examples/kata2/only_architect/run_test.sh +5 -0
- package/examples/kata2/rounds_test/eval_run.sh +11 -0
- package/examples/kata2/rounds_test/run_test.sh +5 -0
- package/examples/kata2/summary_length_test/eval_run.sh +11 -0
- package/examples/kata2/summary_length_test/eval_run_w_clarify.sh +7 -0
- package/examples/kata2/summary_length_test/run_test.sh +5 -0
- package/examples/task-queue/debate-config.json +76 -0
- package/examples/task-queue/debate_report.md +566 -0
- package/examples/task-queue/task-queue-system.md +25 -0
- package/jest.config.ts +13 -0
- package/multi_agent_debate_spec.md +2980 -0
- package/package.json +38 -0
- package/sanity-check-problem.txt +9 -0
- package/src/agents/prompts/architect-prompts.ts +203 -0
- package/src/agents/prompts/generalist-prompts.ts +157 -0
- package/src/agents/prompts/index.ts +41 -0
- package/src/agents/prompts/judge-prompts.ts +19 -0
- package/src/agents/prompts/kiss-prompts.ts +230 -0
- package/src/agents/prompts/performance-prompts.ts +142 -0
- package/src/agents/prompts/prompt-types.ts +68 -0
- package/src/agents/prompts/security-prompts.ts +149 -0
- package/src/agents/prompts/shared.ts +144 -0
- package/src/agents/prompts/testing-prompts.ts +149 -0
- package/src/agents/role-based-agent.ts +386 -0
- package/src/cli/commands/debate.ts +761 -0
- package/src/cli/commands/eval.ts +475 -0
- package/src/cli/commands/report.ts +265 -0
- package/src/cli/index.ts +79 -0
- package/src/core/agent.ts +198 -0
- package/src/core/clarifications.ts +34 -0
- package/src/core/judge.ts +257 -0
- package/src/core/orchestrator.ts +432 -0
- package/src/core/state-manager.ts +322 -0
- package/src/eval/evaluator-agent.ts +130 -0
- package/src/eval/prompts/system.md +41 -0
- package/src/eval/prompts/user.md +64 -0
- package/src/providers/llm-provider.ts +25 -0
- package/src/providers/openai-provider.ts +84 -0
- package/src/providers/openrouter-provider.ts +122 -0
- package/src/providers/provider-factory.ts +64 -0
- package/src/types/agent.types.ts +141 -0
- package/src/types/config.types.ts +47 -0
- package/src/types/debate.types.ts +237 -0
- package/src/types/eval.types.ts +85 -0
- package/src/utils/common.ts +104 -0
- package/src/utils/context-formatter.ts +102 -0
- package/src/utils/context-summarizer.ts +143 -0
- package/src/utils/env-loader.ts +46 -0
- package/src/utils/exit-codes.ts +5 -0
- package/src/utils/id.ts +11 -0
- package/src/utils/logger.ts +48 -0
- package/src/utils/paths.ts +10 -0
- package/src/utils/progress-ui.ts +313 -0
- package/src/utils/prompt-loader.ts +79 -0
- package/src/utils/report-generator.ts +301 -0
- package/tests/clarifications.spec.ts +128 -0
- package/tests/cli.debate.spec.ts +144 -0
- package/tests/config-loading.spec.ts +206 -0
- package/tests/context-summarizer.spec.ts +131 -0
- package/tests/debate-config-custom.json +38 -0
- package/tests/env-loader.spec.ts +149 -0
- package/tests/eval.command.spec.ts +1191 -0
- package/tests/logger.spec.ts +19 -0
- package/tests/openai-provider.spec.ts +26 -0
- package/tests/openrouter-provider.spec.ts +279 -0
- package/tests/orchestrator-summary.spec.ts +386 -0
- package/tests/orchestrator.spec.ts +207 -0
- package/tests/prompt-loader.spec.ts +52 -0
- package/tests/prompts/architect.md +16 -0
- package/tests/provider-factory.spec.ts +150 -0
- package/tests/report.command.spec.ts +546 -0
- package/tests/role-based-agent-summary.spec.ts +476 -0
- package/tests/security-agent.spec.ts +221 -0
- package/tests/shared-prompts.spec.ts +318 -0
- package/tests/state-manager.spec.ts +251 -0
- package/tests/summary-prompts.spec.ts +153 -0
- package/tsconfig.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Lior Schejter
|
|
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,93 @@
|
|
|
1
|
+
# Dialectic - Multi-Agent Debate
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
- [Overview](#overview)
|
|
6
|
+
- [Quickstart](#quickstart)
|
|
7
|
+
- [Setup](#setup)
|
|
8
|
+
- [Basic Command](#basic-command)
|
|
9
|
+
- [Commands](#commands)
|
|
10
|
+
- [Debate Command](#debate-command)
|
|
11
|
+
- [Evaluator Command](#evaluator-command)
|
|
12
|
+
- [Report Command](#report-command)
|
|
13
|
+
- [Configuration](#configuration)
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
Dialectic is a CLI tool that orchestrates multi-agent debates to solve software design problems. Multiple AI agents with different perspectives (architecture, performance, security) debate a problem through structured rounds of proposals, critiques, and refinements, culminating in a synthesized solution from a judge agent.
|
|
18
|
+
|
|
19
|
+
## Quickstart
|
|
20
|
+
|
|
21
|
+
### Setup
|
|
22
|
+
|
|
23
|
+
**Requirements:**
|
|
24
|
+
- **Node.js** >= 18
|
|
25
|
+
- **API Key**: Set `OPENAI_API_KEY` (for OpenAI) or `OPENROUTER_API_KEY` (for OpenRouter) in a `.env` file or as an environment variable
|
|
26
|
+
|
|
27
|
+
**Installation:**
|
|
28
|
+
|
|
29
|
+
For end users (when published to npm):
|
|
30
|
+
```bash
|
|
31
|
+
npm install -g dialectic
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
For local development:
|
|
35
|
+
```bash
|
|
36
|
+
# Install dependencies
|
|
37
|
+
npm install
|
|
38
|
+
|
|
39
|
+
# Build the project
|
|
40
|
+
npm run build
|
|
41
|
+
|
|
42
|
+
# Link the dialectic command globally
|
|
43
|
+
npm link
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**API Key Setup:**
|
|
47
|
+
|
|
48
|
+
Create a `.env` file in your project directory:
|
|
49
|
+
```bash
|
|
50
|
+
OPENAI_API_KEY=sk-your-key-here
|
|
51
|
+
# OR
|
|
52
|
+
OPENROUTER_API_KEY=sk-or-your-key-here
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Basic Command
|
|
56
|
+
|
|
57
|
+
Run a debate with a problem statement:
|
|
58
|
+
```bash
|
|
59
|
+
dialectic debate "Design a rate limiting system"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Or use a problem description file:
|
|
63
|
+
```bash
|
|
64
|
+
dialectic debate --problemDescription problem.txt
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Commands
|
|
68
|
+
|
|
69
|
+
Dialectic provides three main commands:
|
|
70
|
+
|
|
71
|
+
- **`debate`** - Orchestrate a multi-agent debate to solve a design problem
|
|
72
|
+
- **`eval`** - Evaluate a completed debate using evaluator agents
|
|
73
|
+
- **`report`** - Generate a markdown report from a saved debate state
|
|
74
|
+
|
|
75
|
+
For detailed command documentation, including all options and examples, see [docs/commands.md](docs/commands.md).
|
|
76
|
+
|
|
77
|
+
### Debate Command
|
|
78
|
+
|
|
79
|
+
The `debate` command orchestrates a multi-agent debate to solve a software design problem. You provide a problem statement (either inline or from a file), and multiple AI agents with different perspectives debate the problem through structured rounds. Each round consists of proposals, critiques, and refinements, culminating in a synthesized solution from a judge agent. The command supports various options for customizing agent roles, number of rounds, output format, and includes features like interactive clarifications and detailed reporting.
|
|
80
|
+
|
|
81
|
+
### Evaluator Command
|
|
82
|
+
|
|
83
|
+
The `eval` command evaluates a completed debate using evaluator agents. This allows you to assess the quality and effectiveness of a debate's outcome by running specialized evaluator agents that analyze the debate process and final solution. The evaluators provide structured feedback and scores across multiple dimensions, helping you understand the strengths and weaknesses of the debate outcome.
|
|
84
|
+
|
|
85
|
+
### Report Command
|
|
86
|
+
|
|
87
|
+
The `report` command generates a comprehensive markdown report from a saved debate state JSON file. This is useful when you want to create a detailed report from a previously completed debate without re-running it. The report includes the full debate transcript, agent contributions, clarifications (if any), and the final synthesis, formatted as a readable markdown document.
|
|
88
|
+
|
|
89
|
+
## Configuration
|
|
90
|
+
|
|
91
|
+
Debate behavior is configured via a JSON file (default: `./debate-config.json`). If the file is missing, built-in defaults are used.
|
|
92
|
+
|
|
93
|
+
For detailed configuration documentation, including all fields, validation rules, and examples, see [docs/configuration.md](docs/configuration.md).
|
package/WARP.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# WARP.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to WARP (warp.dev) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Setup and prerequisites
|
|
6
|
+
- Node.js >= 18
|
|
7
|
+
- macOS/zsh (set OpenAI key):
|
|
8
|
+
```sh
|
|
9
|
+
export OPENAI_API_KEY="{{OPENAI_API_KEY}}"
|
|
10
|
+
```
|
|
11
|
+
- Install dependencies:
|
|
12
|
+
```sh
|
|
13
|
+
npm install
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Common commands
|
|
17
|
+
- Build
|
|
18
|
+
```sh
|
|
19
|
+
npm run build
|
|
20
|
+
```
|
|
21
|
+
- Lint
|
|
22
|
+
- No linter configured in this repo (no eslint/prettier config or npm scripts).
|
|
23
|
+
- Tests
|
|
24
|
+
- All tests
|
|
25
|
+
```sh
|
|
26
|
+
npm test
|
|
27
|
+
```
|
|
28
|
+
- Watch mode
|
|
29
|
+
```sh
|
|
30
|
+
npm run test:watch
|
|
31
|
+
```
|
|
32
|
+
- Coverage
|
|
33
|
+
```sh
|
|
34
|
+
npm run test:coverage
|
|
35
|
+
```
|
|
36
|
+
- Single test file
|
|
37
|
+
```sh
|
|
38
|
+
npx jest tests/<file>.spec.ts
|
|
39
|
+
# example:
|
|
40
|
+
npx jest tests/orchestrator.spec.ts
|
|
41
|
+
```
|
|
42
|
+
- Single test by name
|
|
43
|
+
```sh
|
|
44
|
+
npx jest -t "<test name substring>"
|
|
45
|
+
```
|
|
46
|
+
- Run the CLI during development (TypeScript, full command)
|
|
47
|
+
```sh
|
|
48
|
+
# Inline problem text
|
|
49
|
+
npx ts-node src/cli/index.ts debate "Design a rate limiting system"
|
|
50
|
+
|
|
51
|
+
# File-based problem
|
|
52
|
+
npx ts-node src/cli/index.ts debate --problemDescription path/to/problem.txt
|
|
53
|
+
|
|
54
|
+
# Verbose and output examples
|
|
55
|
+
npx ts-node src/cli/index.ts debate "Design a rate limiting system" --verbose
|
|
56
|
+
npx ts-node src/cli/index.ts debate "Design a rate limiting system" --output result.json
|
|
57
|
+
npx ts-node src/cli/index.ts debate "Design a rate limiting system" --output solution.txt
|
|
58
|
+
```
|
|
59
|
+
- Run the built JavaScript CLI (after build)
|
|
60
|
+
```sh
|
|
61
|
+
node dist/cli/index.js debate "Design a rate limiting system"
|
|
62
|
+
node dist/cli/index.js debate --problemDescription path/to/problem.txt --verbose
|
|
63
|
+
node dist/cli/index.js debate "Design a rate limiting system" --output result.json
|
|
64
|
+
node dist/cli/index.js debate "Design a rate limiting system" --output solution.txt
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Architecture overview
|
|
68
|
+
- CLI layer
|
|
69
|
+
- `src/cli/index.ts` bootstraps Commander, registers the `debate` command, and centralizes stderr helpers (warnUser, infoUser, writeStderr). The published binary is `debate` (see package.json `bin`).
|
|
70
|
+
- Debate command flow
|
|
71
|
+
- `src/cli/commands/debate.ts` parses args, enforces exactly-one of problem string vs `--problemDescription`, validates `OPENAI_API_KEY`, loads `SystemConfig` (defaults if missing/incomplete with warnings), filters agents, resolves system prompts (built-in vs file), records provenance, runs the orchestrator, and handles output.
|
|
72
|
+
- Providers
|
|
73
|
+
- `src/providers/openai-provider.ts` exposes `complete()` with a two-tier strategy: OpenAI Responses API first, falling back to Chat Completions. Returns text, usage, and latency for contribution metadata.
|
|
74
|
+
- Agents and Judge
|
|
75
|
+
- Role agents live under `src/agents/` and extend the base in `src/core/agent.ts`. The judge (`src/core/judge.ts`) synthesizes the final solution after all rounds complete.
|
|
76
|
+
- Orchestration
|
|
77
|
+
- `src/core/orchestrator.ts` runs N full rounds: proposal → critique → refinement (all three every round), then judge synthesis. Optional hooks log phase completion in verbose mode.
|
|
78
|
+
- State persistence
|
|
79
|
+
- `src/core/state-manager.ts` persists debate state JSON files under `./debates` after initialization, at round start, after each contribution, and on completion.
|
|
80
|
+
- Output behavior
|
|
81
|
+
- By default, final solution text is written to stdout. If `--output` ends with `.json`, the full debate state is written; otherwise only the solution text. Verbose summaries and save-path notices go to stderr (pipe-friendly).
|
|
82
|
+
|
|
83
|
+
## Configuration essentials
|
|
84
|
+
- Full schema and defaults: see `docs/configuration.md`.
|
|
85
|
+
- Default config path: `./debate-config.json` (resolved from current working directory).
|
|
86
|
+
- If agents are missing/empty → built-in defaults are used (architect + performance) with warnings.
|
|
87
|
+
- If judge/debate missing → they are filled from defaults (warning for judge).
|
|
88
|
+
- `systemPromptPath` is resolved relative to the configuration file’s directory; if invalid/empty/unreadable, the built-in prompt is used and the chosen source is recorded once per debate.
|
|
89
|
+
- Environment requirement: `OPENAI_API_KEY` must be set before invoking the CLI.
|
|
90
|
+
|
|
91
|
+
## Execution flow at a glance
|
|
92
|
+
- High-level steps (details and diagram in `docs/debate_flow.md`):
|
|
93
|
+
1) CLI parses arguments and resolves the problem (string or file)
|
|
94
|
+
2) Validates `OPENAI_API_KEY` and loads `SystemConfig`
|
|
95
|
+
3) Initializes provider, agents, and judge (with prompt provenance)
|
|
96
|
+
4) Orchestrator runs N rounds: proposal → critique → refinement (all three per round)
|
|
97
|
+
5) Judge synthesizes the final solution
|
|
98
|
+
6) State is saved throughout under `./debates/<debate-id>.json`
|
|
99
|
+
7) Output written to stdout or a file per `--output`
|
|
100
|
+
|
|
101
|
+
## Debugging and logs
|
|
102
|
+
- Saved debate path is written to stderr: `Saved debate to ./debates/<debate-id>.json`
|
|
103
|
+
- Use `--verbose` for round-by-round summaries (to stderr), including latency and token stats when available.
|
|
104
|
+
- Tests mock OpenAI; use `npm test` for fast iterations.
|
|
105
|
+
- Git commit graph (if you use a global alias):
|
|
106
|
+
```sh
|
|
107
|
+
git tree --all --decorate --oneline
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## References
|
|
111
|
+
- `README.md` (CLI usage, options, exit codes)
|
|
112
|
+
- `docs/configuration.md` (complete configuration schema and defaults)
|
|
113
|
+
- `docs/debate_flow.md` (sequence diagram and deeper flow)
|
|
Binary file
|
package/dialectic.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { runCli } = require('./dist/cli/index.js');
|
|
3
|
+
const { EXIT_GENERAL_ERROR } = require('./dist/utils/exit-codes.js');
|
|
4
|
+
|
|
5
|
+
runCli(process.argv.slice(2)).catch((err) => {
|
|
6
|
+
const code = typeof err?.code === 'number' ? err.code : EXIT_GENERAL_ERROR;
|
|
7
|
+
const msg = err?.message || 'Unknown error';
|
|
8
|
+
process.stderr.write(msg + '\n');
|
|
9
|
+
process.exit(code);
|
|
10
|
+
});
|
package/docs/commands.md
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
# Dialectic Commands
|
|
2
|
+
|
|
3
|
+
This document provides comprehensive documentation for all Dialectic CLI commands, including options, examples, and detailed usage information.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Debate Command](#debate-command)
|
|
8
|
+
- [Evaluator Command](#evaluator-command)
|
|
9
|
+
- [Report Command](#report-command)
|
|
10
|
+
- [Exit Codes](#exit-codes)
|
|
11
|
+
|
|
12
|
+
## Debate Command
|
|
13
|
+
|
|
14
|
+
The `debate` command orchestrates a multi-agent debate to solve a software design problem. Multiple AI agents with different perspectives debate the problem through structured rounds of proposals, critiques, and refinements, culminating in a synthesized solution from a judge agent.
|
|
15
|
+
|
|
16
|
+
### Basic Usage
|
|
17
|
+
|
|
18
|
+
**Inline problem string:**
|
|
19
|
+
```bash
|
|
20
|
+
dialectic debate "Design a rate limiting system"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**With problem description file:**
|
|
24
|
+
```bash
|
|
25
|
+
dialectic debate --problemDescription problem.txt
|
|
26
|
+
dialectic debate --problemDescription ./problems/rate-limiting.md
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Command Options
|
|
30
|
+
|
|
31
|
+
- `[problem]` - Problem statement as inline string (mutually exclusive with `--problemDescription`)
|
|
32
|
+
- `--problemDescription <path>` - Path to a text file containing the problem description
|
|
33
|
+
- **Encoding**: UTF-8
|
|
34
|
+
- **Format**: Any text format (plain text, markdown, etc.)
|
|
35
|
+
- **Content**: Must be non-empty (whitespace-only files are rejected)
|
|
36
|
+
- **Path resolution**: Relative paths resolved from current working directory
|
|
37
|
+
- **Mutual exclusivity**: Cannot provide both string problem and `--problemDescription` file
|
|
38
|
+
- `--agents <list>` - Comma-separated agent roles to participate (default: `architect,performance,kiss`)
|
|
39
|
+
- Available roles: `architect`, `performance`, `security`, `testing`, `kiss`, `generalist`
|
|
40
|
+
- Filters agents from configuration file by role; uses defaults if no matches found
|
|
41
|
+
- `--rounds <n>` - Number of debate rounds (default: `3`, minimum: `1`)
|
|
42
|
+
- `--config <path>` - Path to configuration file (default: `./debate-config.json`)
|
|
43
|
+
- `--env-file <path>` - Path to environment file (default: `.env`)
|
|
44
|
+
- `--output <path>` - Output file path
|
|
45
|
+
- If ending with `.json`: writes full debate state
|
|
46
|
+
- Otherwise: writes final solution text only
|
|
47
|
+
- If omitted: solution written to stdout, state saved to `./debates/` directory
|
|
48
|
+
- `--verbose` - Enable detailed logging with round-by-round breakdown
|
|
49
|
+
- Detailed summary written to `stderr` including:
|
|
50
|
+
- Round-by-round breakdown
|
|
51
|
+
- Individual contributions with metadata (tokens, latency)
|
|
52
|
+
- Total statistics (rounds, duration, token counts)
|
|
53
|
+
- `--report <path>` - Generate a detailed Markdown report of the debate
|
|
54
|
+
- If the path does not end with `.md`, the extension is appended automatically
|
|
55
|
+
- Creates parent directories as needed
|
|
56
|
+
- Non-fatal on failure (debate still succeeds even if report generation fails)
|
|
57
|
+
- `--clarify` - Run a one-time pre-debate clarifications phase
|
|
58
|
+
- Each agent can ask up to 5 clarifying questions (configurable)
|
|
59
|
+
- Interactive Q&A session before the debate begins
|
|
60
|
+
- Questions and answers are included in the debate context and final report
|
|
61
|
+
|
|
62
|
+
### Examples
|
|
63
|
+
|
|
64
|
+
**Basic debate:**
|
|
65
|
+
```bash
|
|
66
|
+
dialectic debate "Design a rate limiting system"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**With specific agent roles:**
|
|
70
|
+
```bash
|
|
71
|
+
dialectic debate "Design a secure authentication system" --agents architect,security
|
|
72
|
+
dialectic debate "Build a high-performance API" --agents architect,performance,security
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**With clarifications phase:**
|
|
76
|
+
```bash
|
|
77
|
+
dialectic debate "Design a rate limiting system" --clarify
|
|
78
|
+
dialectic debate --problemDescription complex-problem.md --clarify --agents architect,security,performance
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**With custom configuration:**
|
|
82
|
+
```bash
|
|
83
|
+
dialectic debate "Design a caching system" --config ./configs/production.json
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Save solution to file:**
|
|
87
|
+
```bash
|
|
88
|
+
dialectic debate "Design a system" --output solution.txt
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Save full debate state:**
|
|
92
|
+
```bash
|
|
93
|
+
dialectic debate "Design a system" --output debate-result.json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Generate report:**
|
|
97
|
+
```bash
|
|
98
|
+
dialectic debate "Design a rate limiting system" --report ./reports/rate-limit
|
|
99
|
+
dialectic debate --problemDescription problems/rate-limiting.md --verbose --report ./reports/rate-limit.md
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Complex example with all options:**
|
|
103
|
+
```bash
|
|
104
|
+
dialectic debate \
|
|
105
|
+
--problemDescription ./problems/rate-limiting.md \
|
|
106
|
+
--config ./configs/production.json \
|
|
107
|
+
--agents architect,performance,security \
|
|
108
|
+
--rounds 5 \
|
|
109
|
+
--output ./results/rate-limiting-solution.json \
|
|
110
|
+
--report ./reports/rate-limiting-report.md \
|
|
111
|
+
--verbose \
|
|
112
|
+
--clarify \
|
|
113
|
+
--env-file .env.production
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Output Behavior
|
|
117
|
+
|
|
118
|
+
**Default behavior:**
|
|
119
|
+
- Final solution text written to `stdout`
|
|
120
|
+
- Complete debate state saved to `./debates/<debate-id>.json`
|
|
121
|
+
- Save path notification written to `stderr`
|
|
122
|
+
|
|
123
|
+
**With `--output` option:**
|
|
124
|
+
- If path ends with `.json`: full debate state written to file
|
|
125
|
+
- Otherwise: only final solution text written to file
|
|
126
|
+
|
|
127
|
+
### Markdown Report (`--report`)
|
|
128
|
+
|
|
129
|
+
Generate a comprehensive Markdown report capturing the full debate transcript and metadata.
|
|
130
|
+
|
|
131
|
+
**Report contents:**
|
|
132
|
+
- Problem Description
|
|
133
|
+
- Agents table and Judge table
|
|
134
|
+
- Clarifications (if `--clarify` was used):
|
|
135
|
+
- Questions and answers grouped by agent
|
|
136
|
+
- Includes "NA" responses for skipped questions
|
|
137
|
+
- Rounds with sections:
|
|
138
|
+
- Proposals
|
|
139
|
+
- Critiques
|
|
140
|
+
- Refinements
|
|
141
|
+
- Final Synthesis
|
|
142
|
+
|
|
143
|
+
**Notes:**
|
|
144
|
+
- When `--verbose` is provided, contribution titles include metadata such as latency and tokens.
|
|
145
|
+
- If a section has no items, a succinct "No … in this round." line is shown.
|
|
146
|
+
- The report path is normalized to `.md` and parent directories are created automatically.
|
|
147
|
+
|
|
148
|
+
### Interactive Clarifications (`--clarify`)
|
|
149
|
+
|
|
150
|
+
The `--clarify` option enables a pre-debate interactive clarification phase where agents can ask clarifying questions about the problem statement. This feature helps ensure all agents have a clear understanding before the debate begins.
|
|
151
|
+
|
|
152
|
+
**How it works:**
|
|
153
|
+
1. Each participating agent generates up to 5 clarifying questions (configurable via `clarificationsMaxPerAgent` in config)
|
|
154
|
+
2. The CLI presents questions grouped by agent in an interactive session
|
|
155
|
+
3. You can answer each question or press Enter to skip (recorded as "NA")
|
|
156
|
+
4. Questions and answers are included in the debate context and final report
|
|
157
|
+
5. The judge does not participate in the clarification phase
|
|
158
|
+
|
|
159
|
+
**Configuration options:**
|
|
160
|
+
- `debate.interactiveClarifications`: Enable clarifications by default (boolean, default: false)
|
|
161
|
+
- `debate.clarificationsMaxPerAgent`: Maximum questions per agent (number, default: 5)
|
|
162
|
+
- `AgentConfig.clarificationPromptPath`: Custom clarification prompt for specific agents
|
|
163
|
+
|
|
164
|
+
**Example workflow:**
|
|
165
|
+
```bash
|
|
166
|
+
dialectic debate "Design a distributed cache system" --clarify
|
|
167
|
+
# Agents ask questions like:
|
|
168
|
+
# [Architect] Q1: What are the expected read/write ratios?
|
|
169
|
+
# > 80% reads, 20% writes
|
|
170
|
+
# [Performance] Q2: What's the target latency requirement?
|
|
171
|
+
# > < 10ms for 95th percentile
|
|
172
|
+
# [Security] Q3: What data sensitivity level?
|
|
173
|
+
# > (press Enter to skip)
|
|
174
|
+
# Q3: NA
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Technical Details
|
|
178
|
+
|
|
179
|
+
**LLM Providers:**
|
|
180
|
+
- **OpenAI**: Direct integration with OpenAI API using OpenAI SDK
|
|
181
|
+
- **OpenRouter**: Integration with OpenRouter API using OpenAI SDK for compatibility
|
|
182
|
+
- Both providers support Responses API with fallback to Chat Completions API
|
|
183
|
+
|
|
184
|
+
**Debate Round Flow:**
|
|
185
|
+
- Round 1: Proposals are generated via LLM, then critiques, then refinements.
|
|
186
|
+
- Rounds ≥ 2: Each agent's proposal is the previous round's refinement (no LLM call). If a prior refinement is missing, the system warns to stderr and falls back to generating a proposal via LLM for that agent only. Critiques and refinements proceed as usual against the current round's proposals.
|
|
187
|
+
|
|
188
|
+
**Debate Persistence:**
|
|
189
|
+
- Debate states are saved to `./debates/` directory
|
|
190
|
+
- Filename format: `deb-YYYYMMDD-HHMMSS-RAND.json`
|
|
191
|
+
- Files are saved incrementally during execution and upon completion
|
|
192
|
+
|
|
193
|
+
**Agent Roles:**
|
|
194
|
+
- `architect`: System design and architecture perspective
|
|
195
|
+
- `performance`: Performance optimization and efficiency perspective
|
|
196
|
+
- `security`: Security and threat modeling perspective
|
|
197
|
+
- `testing`: Testing strategy and quality assurance perspective (future use)
|
|
198
|
+
- `kiss`: Simplicity-focused perspective, challenges complexity
|
|
199
|
+
- `generalist`: General-purpose role (typically used for judge)
|
|
200
|
+
|
|
201
|
+
**Context Summarization:**
|
|
202
|
+
- Automatically manages debate history length to avoid context window limitations
|
|
203
|
+
- Each agent independently summarizes their perspective-based history when it exceeds configured thresholds
|
|
204
|
+
- Agent-specific summaries stored per round, keyed by agent ID for isolated access
|
|
205
|
+
- Dynamic retrieval: agents always see their own most recent summary
|
|
206
|
+
- Configurable at both system-wide and per-agent levels
|
|
207
|
+
- Summaries preserve critical insights while reducing context size for subsequent rounds
|
|
208
|
+
- Default threshold: 5000 characters, max summary length: 2500 characters
|
|
209
|
+
- See `docs/configuration.md` and `docs/context_summarization.md` for detailed documentation
|
|
210
|
+
|
|
211
|
+
## Evaluator Command
|
|
212
|
+
|
|
213
|
+
The `eval` command evaluates a completed debate using evaluator agents. This allows you to assess the quality and effectiveness of a debate's outcome.
|
|
214
|
+
|
|
215
|
+
**Basic usage:**
|
|
216
|
+
```bash
|
|
217
|
+
dialectic eval --config ./eval-config.json --debate ./debates/deb-YYYYMMDD-HHMMSS-XYZ.json
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**With JSON output:**
|
|
221
|
+
```bash
|
|
222
|
+
dialectic eval \
|
|
223
|
+
--config ./eval-config.json \
|
|
224
|
+
--debate ./debates/deb-20250101-010203-ABC.json \
|
|
225
|
+
--output ./results/evaluation.json
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**With verbose logs:**
|
|
229
|
+
```bash
|
|
230
|
+
dialectic eval \
|
|
231
|
+
--config ./eval-config.json \
|
|
232
|
+
--debate ./debates/deb-20250101-010203-ABC.json \
|
|
233
|
+
--verbose \
|
|
234
|
+
--env-file .env
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Command Options
|
|
238
|
+
|
|
239
|
+
- `-c, --config <path>` - Evaluator configuration JSON (required)
|
|
240
|
+
- `-d, --debate <path>` - Debate state JSON to evaluate (required)
|
|
241
|
+
- `--env-file <path>` - Optional .env file path
|
|
242
|
+
- `-v, --verbose` - Verbose diagnostic logs to stderr
|
|
243
|
+
- `-o, --output <path>` - Output destination
|
|
244
|
+
- If ends with `.json`: writes aggregated JSON output
|
|
245
|
+
- Otherwise: writes Markdown table (or stdout by default)
|
|
246
|
+
|
|
247
|
+
### Examples
|
|
248
|
+
|
|
249
|
+
**Basic evaluation:**
|
|
250
|
+
```bash
|
|
251
|
+
dialectic eval --config ./eval-config.json --debate ./debates/deb-20250101-010203-ABC.json
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Evaluator with JSON output:**
|
|
255
|
+
```bash
|
|
256
|
+
dialectic eval \
|
|
257
|
+
--config ./eval-config.json \
|
|
258
|
+
--debate ./debates/deb-20250101-010203-ABC.json \
|
|
259
|
+
--output ./results/evaluation.json
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Evaluator with verbose logs:**
|
|
263
|
+
```bash
|
|
264
|
+
dialectic eval \
|
|
265
|
+
--config ./eval-config.json \
|
|
266
|
+
--debate ./debates/deb-20250101-010203-ABC.json \
|
|
267
|
+
--verbose \
|
|
268
|
+
--env-file .env
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
For detailed evaluator documentation, see [docs/evaluator.md](evaluator.md).
|
|
272
|
+
|
|
273
|
+
## Report Command
|
|
274
|
+
|
|
275
|
+
The `report` command generates a markdown report from a saved debate state JSON file. This command is useful when you want to create a report from a previously completed debate without re-running it.
|
|
276
|
+
|
|
277
|
+
**Basic usage:**
|
|
278
|
+
```bash
|
|
279
|
+
# Generate report and write to stdout
|
|
280
|
+
dialectic report --debate ./debates/deb-20250101-010203-ABC.json
|
|
281
|
+
|
|
282
|
+
# Write report to a file
|
|
283
|
+
dialectic report --debate ./debates/deb-20250101-010203-ABC.json --output ./reports/debate-report.md
|
|
284
|
+
|
|
285
|
+
# With verbose metadata (latency, tokens in contribution titles)
|
|
286
|
+
dialectic report --debate ./debates/deb-20250101-010203-ABC.json --verbose --output ./reports/debate-report.md
|
|
287
|
+
|
|
288
|
+
# Use custom configuration file
|
|
289
|
+
dialectic report --debate ./debates/debate.json --config ./custom-config.json --output report.md
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Command Options
|
|
293
|
+
|
|
294
|
+
- `--debate <path>` - **Required**. Path to debate JSON file (DebateState format)
|
|
295
|
+
- `--config <path>` - Optional. Path to configuration file
|
|
296
|
+
- If provided: loads configuration file and matches agent/judge configs with agent IDs found in debate state
|
|
297
|
+
- If not provided: creates minimal agent/judge configs from debate state (no validation of IDs)
|
|
298
|
+
- `-o, --output <path>` - Optional. Path to output markdown file (default: stdout)
|
|
299
|
+
- If not provided, writes report to stdout (allows piping: `report --debate file.json > output.md`)
|
|
300
|
+
- Creates parent directories automatically if they don't exist
|
|
301
|
+
- Overwrites existing file if it exists
|
|
302
|
+
- `-v, --verbose` - Optional. Enable verbose mode for report generation
|
|
303
|
+
- Includes metadata (latency, tokens) in contribution titles
|
|
304
|
+
|
|
305
|
+
### Report Contents
|
|
306
|
+
|
|
307
|
+
- Problem Description
|
|
308
|
+
- Agents table (from configuration file if provided, or minimal configs from debate state)
|
|
309
|
+
- Judge table (from configuration file if provided, or minimal config from debate state)
|
|
310
|
+
- Clarifications (if any were collected during the debate)
|
|
311
|
+
- Rounds with sections:
|
|
312
|
+
- Proposals
|
|
313
|
+
- Critiques
|
|
314
|
+
- Refinements
|
|
315
|
+
- Final Synthesis
|
|
316
|
+
|
|
317
|
+
### How It Works
|
|
318
|
+
|
|
319
|
+
1. Loads and validates the debate state JSON file
|
|
320
|
+
2. If `--config` is provided:
|
|
321
|
+
- Loads configuration file to get agent and judge configurations
|
|
322
|
+
- Matches agent configs with agent IDs found in the debate state contributions
|
|
323
|
+
3. If `--config` is not provided:
|
|
324
|
+
- Creates minimal agent/judge configs from debate state (extracts agent IDs and roles from contributions)
|
|
325
|
+
- No validation of agent/judge IDs is performed
|
|
326
|
+
4. Generates markdown report using the same generator as the `--report` option in the debate command
|
|
327
|
+
5. Writes report to stdout or specified file
|
|
328
|
+
|
|
329
|
+
### Differences from `--report` Option
|
|
330
|
+
|
|
331
|
+
- `--report` in `debate` command: Generates report during an active debate from in-memory state
|
|
332
|
+
- `report` command: Generates report from a saved debate state JSON file after the debate is complete
|
|
333
|
+
- Both produce the same markdown format and content structure
|
|
334
|
+
|
|
335
|
+
### Error Handling
|
|
336
|
+
|
|
337
|
+
- Exits with error code 2 (EXIT_INVALID_ARGS) if:
|
|
338
|
+
- Debate file doesn't exist
|
|
339
|
+
- Debate file is invalid JSON
|
|
340
|
+
- Debate file is missing required fields (id, problem, status, rounds)
|
|
341
|
+
- Path is a directory instead of a file
|
|
342
|
+
- Exits with error code 1 (EXIT_GENERAL_ERROR) for other errors
|
|
343
|
+
|
|
344
|
+
### Examples
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
# Generate report from a saved debate and view it
|
|
348
|
+
dialectic report --debate ./debates/deb-20250101-010203-ABC.json
|
|
349
|
+
|
|
350
|
+
# Save report to file
|
|
351
|
+
dialectic report --debate ./debates/deb-20250101-010203-ABC.json --output ./reports/my-debate-report.md
|
|
352
|
+
|
|
353
|
+
# Generate report with verbose metadata and custom config
|
|
354
|
+
dialectic report --debate ./debates/debate.json --config ./configs/production.json --verbose --output report.md
|
|
355
|
+
|
|
356
|
+
# Pipe report to another command
|
|
357
|
+
dialectic report --debate ./debates/debate.json | grep "Final Synthesis"
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
## Exit Codes
|
|
361
|
+
|
|
362
|
+
| Code | Description |
|
|
363
|
+
|------|-------------|
|
|
364
|
+
| `0` | Success |
|
|
365
|
+
| `1` | General error |
|
|
366
|
+
| `2` | Invalid CLI arguments (e.g., missing problem, invalid rounds) |
|
|
367
|
+
| `3` | Provider error (reserved for future use) |
|
|
368
|
+
| `4` | Configuration error (e.g., missing `OPENAI_API_KEY`) |
|
|
369
|
+
|
|
370
|
+
**Checking exit codes:**
|
|
371
|
+
```bash
|
|
372
|
+
dialectic debate "Design a system" && echo "Success!"
|
|
373
|
+
dialectic debate "Design a system" || echo "Failed with code: $?"
|
|
374
|
+
```
|
|
375
|
+
|