pi-reason-harness 1.0.1

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/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "pi-reason-harness",
3
+ "version": "1.0.1",
4
+ "description": "Recursive self-improving reasoning harness for pi \u2014 iterate, verify, improve. Builds task-specific reasoning strategies on top of any LLM.",
5
+ "keywords": [
6
+ "pi-package"
7
+ ],
8
+ "bin": {
9
+ "pi-reason-harness": "harness/cli.ts"
10
+ },
11
+ "files": [
12
+ "extensions",
13
+ "harness",
14
+ "skills",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "license": "MIT",
19
+ "type": "module",
20
+ "pi": {
21
+ "extensions": [
22
+ "./extensions"
23
+ ],
24
+ "skills": [
25
+ "./skills"
26
+ ]
27
+ },
28
+ "scripts": {
29
+ "test": "vitest run",
30
+ "test:watch": "vitest",
31
+ "typecheck": "tsc --noEmit"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "25.9.1",
35
+ "typescript": "6.0.3",
36
+ "vitest": "4.1.7",
37
+ "@earendil-works/pi-tui": "0.79.4"
38
+ },
39
+ "peerDependencies": {
40
+ "@earendil-works/pi-ai": ">=0.74.0",
41
+ "@earendil-works/pi-coding-agent": ">=0.74.0",
42
+ "@sinclair/typebox": "0.34.49"
43
+ },
44
+ "overrides": {
45
+ "brace-expansion": "5.0.6",
46
+ "fast-xml-builder": "1.2.0",
47
+ "protobufjs": "8.4.0",
48
+ "ws": "8.20.1"
49
+ }
50
+ }
@@ -0,0 +1,178 @@
1
+ ---
2
+ name: reason-harness
3
+ description: Run iterative solve-verify-feedback reasoning loops on top of any LLM with a 13-layer self-improving meta-system. Use when you need to solve problems requiring code generation with verification, knowledge extraction through chain-of-questions probing, or hybrid reasoning tasks. The system learns from past problems, adapts strategy, generates diverse approaches, decomposes hard problems, and transfers insights across domains. Works by generating candidate solutions, executing them in sandboxes or self-auditing, building feedback from failures, and confidence-weighted voting across parallel experts with different strategies.
4
+ ---
5
+
6
+ # Reason Harness
7
+
8
+ Recursive self-improving reasoning harness with 13 meta-system layers. Generate solutions, test them, learn from failures, evolve strategies, decompose hard problems, transfer across domains, and improve autonomously.
9
+
10
+ The `pi-reason-harness` CLI auto-spawns a long-lived harness server on first use. Every call dispatches an action to the harness, which holds session state across calls. The system uses pi's own LLM infrastructure (pi-ai) and runs code in Node's vm sandbox — zero Python dependency.
11
+
12
+ ## Setup (once, first use)
13
+
14
+ Symlink the CLI if not on PATH:
15
+
16
+ ```bash
17
+ # macOS (Apple Silicon + Homebrew)
18
+ command -v pi-reason-harness >/dev/null || ln -sf <skill-dir>/harness/cli.ts /opt/homebrew/bin/pi-reason-harness
19
+
20
+ # macOS (Intel) / most Linux
21
+ command -v pi-reason-harness >/dev/null || ln -sf <skill-dir>/harness/cli.ts /usr/local/bin/pi-reason-harness
22
+ ```
23
+
24
+ ## How to use
25
+
26
+ ```bash
27
+ # Initialize a reasoning session
28
+ pi-reason-harness init --name "ARC solver" --type code-reasoning \
29
+ --models '["anthropic/claude-sonnet-4-5","openai/gpt-4o"]' --num-experts 3
30
+
31
+ # Solve with the full 13-layer meta-system pipeline
32
+ pi-reason-harness solve --meta --problem "Transform the grid by..." \
33
+ --train-inputs '[[1,2],[3,4]]' \
34
+ --train-outputs '[[4,3],[2,1]]' \
35
+ --test-inputs '[[5,6]]'
36
+
37
+ # Decompose a hard problem into sub-problems
38
+ pi-reason-harness decompose --problem "Rotate a 3x3 grid 90 degrees clockwise. Input: [[1,2,3],[4,5,6],[7,8,9]]"
39
+
40
+ # Analyze a problem without solving
41
+ pi-reason-harness meta-analyze --problem "Rotate a 2x2 grid 90 degrees clockwise"
42
+
43
+ # Check harness specs (different solve approaches)
44
+ pi-reason-harness harness-specs
45
+
46
+ # Evolve the worst-performing harness spec
47
+ pi-reason-harness evolve-harness
48
+
49
+ # Check the strategy library
50
+ pi-reason-harness strategies
51
+
52
+ # Transfer a strategy from grid-transformation to pattern-completion
53
+ pi-reason-harness transfer --source-category grid-transformation --target-category pattern-completion
54
+
55
+ # Check meta-rules
56
+ pi-reason-harness meta-rules
57
+
58
+ # Check model routing stats
59
+ pi-reason-harness model-routes
60
+ ```
61
+
62
+ ## CLI commands
63
+
64
+ | Command | Behavior |
65
+ |---|---|
66
+ | `pi-reason-harness init` | Initialize a reasoning session with task config |
67
+ | `pi-reason-harness solve` | Run the iterative solve-verify-feedback loop |
68
+ | `pi-reason-harness status` | Show session state, budget, and learned adaptations |
69
+ | `pi-reason-harness results` | Show iteration results |
70
+ | `pi-reason-harness learn` | Inspect strategy adaptations learned from past problems |
71
+ | `pi-reason-harness reset-learn` | Clear all learned adaptations and history |
72
+ | `pi-reason-harness clear` | Clear session state |
73
+ | `pi-reason-harness meta-analyze` | Analyze a problem with the critic (no solving) |
74
+ | `pi-reason-harness meta-improve` | Evolve worst-performing strategy + extract rules |
75
+ | `pi-reason-harness strategies` | List strategy library with ROI + quality metrics |
76
+ | `pi-reason-harness meta-rules` | List cross-strategy principles with validation stats |
77
+ | `pi-reason-harness model-routes` | List model routing stats per model×category |
78
+ | `pi-reason-harness harness-specs` | List harness specifications with stats |
79
+ | `pi-reason-harness evolve-harness` | Evolve the worst-performing spec |
80
+ | `pi-reason-harness transfer` | Transfer strategy between categories |
81
+ | `pi-reason-harness decompose` | Decompose a problem into sub-problems |
82
+ | `pi-reason-harness synth-prompts` | List synthesized prompts |
83
+ | `pi-reason-harness meta-harnesses` | List meta-harnesses |
84
+ | `pi-reason-harness generate-meta-harness` | Generate new approach type |
85
+ | `pi-reason-harness arc-benchmark` | Run ARC-AGI benchmark |
86
+ | `pi-reason-harness route-decompose --problem '...'` | Multi-model decomposition |
87
+
88
+ ## The 20-Layer Meta-System
89
+
90
+ | Layer | Name | What it does |
91
+ |-------|------|-------------|
92
+ | 0 | Problem Critic | Proposes targeted deltas to proven templates |
93
+ | 1 | Strategy Library | Persistent store with ROI + quality metrics |
94
+ | 2 | Meta-Rule Engine | Cross-strategy principles that compound |
95
+ | 3 | Model Router | Thompson sampling for model selection |
96
+ | 4 | Budget Bandit | Early stopping + re-exploration |
97
+ | 5 | Auto-Trigger | Self-improvement runs automatically |
98
+ | 6 | Recursive Harness Generation | Generates entire approach configurations |
99
+ | 7 | Ensemble Diversification | Different approach per expert |
100
+ | 8 | Sub-problem Decomposition | Break hard problems, solve, combine |
101
+ | 9 | Budget Optimization | Marginal ROI reallocation |
102
+ | 10 | Cross-Domain Transfer | Transfer strategies across categories |
103
+ | 11 | Confidence-Weighted Voting | Weight votes by quality |
104
+ | 12 | Progressive Difficulty | Easiest examples first |
105
+ | 14 | Per-Problem Prompt Synthesis | Generate + validate prompts for novel types |
106
+ | 15 | Meta-Meta Level | Harness-of-harnesses — new approach types |
107
+ | 16 | Gradient-Based Budget Optimization | Trajectory-based improvement estimation |
108
+ | 17 | Recursive Meta-Meta Nesting | Meta-harnesses feed back into solve |
109
+ | 18 | Multi-Model Decomposition | Route sub-questions to different models |
110
+ | 19 | Per-Iteration Prompt Adaptation | Evolve prompt mid-solve |
111
+ | 20 | ARC-AGI Benchmark Integration | Validate against real challenges |
112
+
113
+ ## Approach Types (Ensemble Diversification)
114
+
115
+ When using `--meta` with multiple experts, each gets a different approach:
116
+
117
+ | Approach | Description | Best for |
118
+ |----------|-------------|----------|
119
+ | code-sandbox | Generate JS, execute, verify output | Grid/array transformations |
120
+ | decomposition | Break into sub-problems, solve each | Multi-step problems |
121
+ | chain-of-questions | Hierarchical broad→specific probing | Knowledge questions |
122
+ | analogy | Solve simpler version first, scale up | Hard spatial problems |
123
+ | counter-factual | Generate wrong solutions, analyze failures | Stubborn problems |
124
+ | exhaustive-search | Enumerate possibilities, filter | Small search spaces |
125
+
126
+ ## Verification Methods
127
+
128
+ | Method | How it works |
129
+ |---|---|
130
+ | `sandbox` | Execute JS code in Node vm sandbox, compare output |
131
+ | `self-audit` | LLM checks its own answer for accuracy |
132
+ | `external` | Run a custom shell command to verify |
133
+ | `none` | No verification |
134
+
135
+ ## Persistent Data
136
+
137
+ All meta-system data persists at `~/.pi-reason-harness/`:
138
+
139
+ | File | Contents |
140
+ |------|----------|
141
+ | `strategies.json` | Strategy library with ROI, quality metrics, lineage |
142
+ | `meta-rules.json` | Cross-strategy principles with validation stats |
143
+ | `model-routes.json` | Per model×category routing stats |
144
+ | `harness-specs.json` | Complete harness specs per category×approach |
145
+ | `synthesized-prompts.json` | Per-problem-type specialized prompts |
146
+ | `meta-harnesses.json` | Generated approach types with evolution |
147
+
148
+ ## Key Principles
149
+
150
+ 1. **The loop is the intelligence** — The multi-step verify-feedback loop, not the prompt
151
+ 2. **Critique, don't create** — Modify proven templates with targeted deltas
152
+ 3. **Meta-rules compound** — Cross-strategy principles bias all future improvements
153
+ 4. **Diversity beats depth** — Different approaches per expert > more iterations with same approach
154
+ 5. **Budget is a bandit** — Allocate compute where marginal ROI is highest
155
+ 6. **Transfer compounds** — Grid strategies inform knowledge strategies via meta-rules
156
+ 7. **JS-exclusive** — Zero Python dependency
157
+
158
+ ## init Parameters
159
+
160
+ | Parameter | Required | Default | Description |
161
+ |-----------|----------|---------|-------------|
162
+ | `--name` | Yes | — | Session name |
163
+ | `--type` | No | `code-reasoning` | Task type |
164
+ | `--models` | No | `["openai/gpt-4o"]` | JSON array of model IDs |
165
+ | `--num-experts` | No | `1` | Number of parallel experts |
166
+ | `--verification` | No | `sandbox` | Verification method |
167
+ | `--max-cost` | No | — | Max cost per problem (USD) |
168
+ | `--max-time` | No | — | Max time per problem (seconds) |
169
+
170
+ ## solve Parameters
171
+
172
+ | Parameter | Required | Description |
173
+ |-----------|----------|-------------|
174
+ | `--problem` | No* | Problem description (*or use --train-inputs) |
175
+ | `--train-inputs` | No | JSON array of training inputs |
176
+ | `--train-outputs` | No | JSON array of training outputs |
177
+ | `--test-inputs` | No | JSON array of test inputs |
178
+ | `--meta` / `-m` | No | Enable the 13-layer meta-system |