openhermes 1.5.2 → 1.12.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.
Files changed (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +256 -157
  3. package/autorecall.mjs +2 -12
  4. package/bootstrap.mjs +158 -8
  5. package/curator.mjs +1 -5
  6. package/harness/commands/checkpoint.md +68 -0
  7. package/harness/commands/eval.md +89 -0
  8. package/harness/commands/go-build.md +87 -0
  9. package/harness/commands/go-review.md +71 -0
  10. package/harness/commands/harness-audit.md +90 -0
  11. package/harness/commands/learn.md +2 -2
  12. package/harness/commands/loop-start.md +38 -0
  13. package/harness/commands/loop-status.md +30 -0
  14. package/harness/commands/memory-search.md +2 -2
  15. package/harness/commands/model-route.md +32 -0
  16. package/harness/commands/orchestrate.md +88 -0
  17. package/harness/commands/quality-gate.md +35 -0
  18. package/harness/commands/refactor-clean.md +102 -0
  19. package/harness/commands/rust-build.md +78 -0
  20. package/harness/commands/rust-review.md +65 -0
  21. package/harness/commands/setup-pm.md +65 -0
  22. package/harness/commands/skill-create.md +99 -0
  23. package/harness/commands/test-coverage.md +80 -0
  24. package/harness/commands/update-codemaps.md +81 -0
  25. package/harness/commands/update-docs.md +67 -0
  26. package/harness/commands/verify.md +68 -0
  27. package/harness/instructions/CONVENTIONS.md +206 -0
  28. package/harness/instructions/RUNTIME.md +8 -1
  29. package/harness/prompts/build-cpp.md +84 -0
  30. package/harness/prompts/build-error-resolver.md +2 -1
  31. package/harness/prompts/build-go.md +326 -0
  32. package/harness/prompts/build-java.md +126 -0
  33. package/harness/prompts/build-kotlin.md +123 -0
  34. package/harness/prompts/build-rust.md +94 -0
  35. package/harness/prompts/code-reviewer.md +2 -1
  36. package/harness/prompts/doc-updater.md +193 -0
  37. package/harness/prompts/docs-lookup.md +60 -0
  38. package/harness/prompts/explore.md +1 -0
  39. package/harness/prompts/harness-optimizer.md +30 -0
  40. package/harness/prompts/loop-operator.md +42 -0
  41. package/harness/prompts/planner.md +3 -2
  42. package/harness/prompts/refactor-cleaner.md +242 -0
  43. package/harness/prompts/review-cpp.md +68 -0
  44. package/harness/prompts/review-database.md +248 -0
  45. package/harness/prompts/review-go.md +244 -0
  46. package/harness/prompts/review-java.md +100 -0
  47. package/harness/prompts/review-kotlin.md +130 -0
  48. package/harness/prompts/review-python.md +88 -0
  49. package/harness/prompts/review-rust.md +64 -0
  50. package/harness/prompts/security-reviewer.md +3 -2
  51. package/harness/prompts/tdd-guide.md +214 -0
  52. package/harness/rules/delegation.md +28 -22
  53. package/harness/rules/memory-management.md +4 -4
  54. package/harness/rules/retrieval.md +5 -5
  55. package/harness/rules/runtime-guards.md +1 -1
  56. package/harness/rules/session-start.md +4 -4
  57. package/harness/rules/skills-management.md +2 -2
  58. package/harness/rules/state-drift.md +1 -1
  59. package/harness/rules/verification.md +4 -4
  60. package/harness/skills/coding-standards/SKILL.md +1 -1
  61. package/index.mjs +25 -4
  62. package/lib/hardening.mjs +11 -1
  63. package/lib/memory-tools-plugin.mjs +101 -54
  64. package/lib/ohc/config.mjs +30 -0
  65. package/lib/ohc/pruner.mjs +239 -0
  66. package/lib/ohc/reaper.mjs +61 -0
  67. package/lib/ohc/state.mjs +32 -0
  68. package/lib/ohc/updater.mjs +110 -0
  69. package/package.json +1 -1
  70. package/skill-builder.mjs +2 -6
  71. package/lib/tools/_memory.mjs +0 -230
  72. package/lib/tools/hm_get.mjs +0 -13
  73. package/lib/tools/hm_latest.mjs +0 -12
  74. package/lib/tools/hm_list.mjs +0 -13
  75. package/lib/tools/hm_put.mjs +0 -14
  76. package/lib/tools/hm_search.mjs +0 -16
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 nathwn12
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 CHANGED
@@ -5,14 +5,14 @@
5
5
 
6
6
  <p align="center">
7
7
  <a href="https://www.npmjs.com/package/openhermes"><img src="https://img.shields.io/npm/v/openhermes?style=for-the-badge&label=version&color=FFD700" alt="npm version"></a>
8
- <a href="https://github.com/nathwn12/openhermes/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green?style=for-the-badge" alt="License: MIT"></a>
8
+ <a href="https://github.com/nathwn12/openhermes/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green?style=for-the-badge" alt="License: MIT"></a>
9
9
  <a href="https://opencode.ai"><img src="https://img.shields.io/badge/runs%20on-OpenCode-6366f1?style=for-the-badge" alt="Runs on OpenCode"></a>
10
10
  <a href="https://github.com/nathwn12/openhermes/issues"><img src="https://img.shields.io/badge/issues-welcome-orange?style=for-the-badge" alt="Issues welcome"></a>
11
11
  </p>
12
12
 
13
13
  ---
14
14
 
15
- **Your OpenCode agent, leveled up.** Add it to your plugins your agent gains a personality, a memory, a conscience, 7 specialist subagents, 7 slash commands, 5 native memory tools, 10 procedural skills, and the discipline to self-improve.
15
+ **Your OpenCode agent, leveled up.** Add it to your plugins and your agent gains a personality, a memory, a conscience, 25 specialist subagents, 27 slash commands, 6 native memory tools, 10 procedural skills, autonomous checkpointing, and the discipline to self-improve.
16
16
 
17
17
  ```bash
18
18
  npm i openhermes
@@ -23,27 +23,34 @@ npm i openhermes
23
23
  > &#9764; **Inspired by [Hermes Agent](https://github.com/NousResearch/hermes-agent)** — Nous Research's self-improving agent that brought closed learning loops, skill creation, and cross-session memory to the agent ecosystem. OpenHermes reimagines that vision **native to the OpenCode platform**: zero dependencies, no sidecars, no installers. Your entire agent OS in a single npm package.
24
24
  >
25
25
  > **Pruning inspiration**: The autonomous context-pressure system is heavily inspired by [Opencode-DCP (Dynamic Context Pruning)](https://github.com/Opencode-DCP/opencode-dynamic-context-pruning). The curator plugin's compaction-trigger logic and recall-cache freshness model are direct ports of DCP's approach, adapted to run inside OpenHermes with no sidecars or installers.
26
+ >
27
+ > **Subagent & command expansion**: The 18 language-specialist subagents and 19 orchestration commands are adapted from [Everything Claude Code (ECC)](https://github.com/everything-claude-code/ecc) — an open-source OpenCode plugin system.
26
28
 
27
29
  ---
28
30
 
29
31
  ## What OpenHermes Does For Your Agent
30
32
 
31
33
  <table>
32
- <tr><td width="160"><b>&#129302; Personality Layer</b></td><td>A 11-principle constitution (soul.md) injected into every session — pragmatic, concise, subagent-first, verify-don't-claim. Your agent stops rambling and starts delivering.</td></tr>
34
+ <tr><td width="160"><b>&#129302; Personality Layer</b></td><td>An 11-principle constitution (<code>soul.md</code>) injected into every session — pragmatic, concise, subagent-first, verify-don't-claim. Your agent stops rambling and starts delivering.</td></tr>
33
35
  <tr><td><b>&#128204; Delegation Discipline</b></td><td>Mandated routing table — every non-trivial task goes to the right specialist subagent. Main context stays clean, coordination-only. No more bloated chat logs.</td></tr>
34
- <tr><td><b>&#128190; 9-Class Durable Memory</b></td><td>Checkpoints, decisions, constraints, instincts, mistakes, backlog items, audit reports, verification receipts, and session recall — all schema-validated, fingerprint-verified, persisted to disk.</td></tr>
35
- <tr><td><b>&#129520; Precision-First Retrieval</b></td><td>Gated retrieval with anti-spam controls. <code>hm_latest</code> → <code>hm_search</code> → <code>hm_get</code> → <code>hm_list</code>. No full-index reads unless explicitly scoped. Memory stays lean.</td></tr>
36
- <tr><td><b>&#128293; Autonomous Checkpointing</b></td><td>Pre-compaction snapshots capture mission, current state, next actions, active decisions, blockers, and risk notes so compaction never loses the plot.</td></tr>
36
+ <tr><td><b>&#128190; 9-Class Durable Memory</b></td><td>Checkpoints, decisions, constraints, instincts, mistakes, backlog items, audit reports, verification receipts, and session recall — all schema-validated, fingerprint-aware, persisted to disk.</td></tr>
37
+ <tr><td><b>&#129520; Precision-First Retrieval</b></td><td>Gated retrieval with anti-spam controls. <code>latest_memory</code> → <code>search_memory</code> → <code>fetch_memory</code> → <code>list_memory</code>. No full-index reads unless explicitly scoped. Memory stays lean.</td></tr>
38
+ <tr><td><b>&#128293; Autonomous Checkpointing</b></td><td>Pre-compaction snapshots capture mission, current state, next actions, blockers, and risk notes so compaction never loses the plot.</td></tr>
37
39
  <tr><td><b>&#128260; Closed Learning Loop</b></td><td>Mistakes are logged with root cause + prevention rule. Complex sessions auto-generate skill-candidate backlogs. Strike tracking escalates repeat failures. The agent gets better — you don't have to teach it twice.</td></tr>
38
- <tr><td><b>&#128736; 10 Bundled Procedural Skills</b></td><td>Pre-built skills for API design, backend patterns, coding standards, E2E testing, frontend patterns, security reviews, strategic compaction, TDD workflow, verification loops, and presentation building. Discovered automatically — use <code>skill</code> tool to list and load.</td></tr>
39
- <tr><td><b>&#129513; Zero Infrastructure</b></td><td>No Python. No uv. No Docker. No PostgreSQL. No gateway. No cron daemon. Just Node.js which OpenCode's Bun runtime already bundles. Everything runs inside your existing OpenCode session.</td></tr>
40
+ <tr><td><b>&#128736; 10 Bundled Procedural Skills</b></td><td>Pre-built skills for API design, backend patterns, coding standards, E2E testing, frontend patterns, frontend slides, security reviews, strategic compaction, TDD workflow, and verification loops. Discovered automatically — use <code>skill</code> to list and load.</td></tr>
41
+ <tr><td><b>&#128270; Context Pruner</b></td><td>Agent-controlled compression via <code>ohc.json</code> (soft defaults) + <code>compress</code> tool with <code>targetTokens</code> override. No token claimsreports message count only. Recommend <code>compaction.auto: false</code> to prevent double pruning with OpenCode's built-in system.</td></tr>
42
+ <tr><td><b>&#129513; Zero Infrastructure</b></td><td>No Python. No uv. No Docker. No PostgreSQL. No gateway. No cron daemon. Just Node.js and your existing OpenCode runtime.</td></tr>
40
43
  </table>
41
44
 
42
45
  ---
43
46
 
44
47
  ## Setup
45
48
 
46
- Add one line to your `opencode.json`:
49
+ Add one line to your `opencode.json`. Two good options:
50
+
51
+ ### Published Release
52
+
53
+ Use npm when you want a stable release boundary.
47
54
 
48
55
  ```json
49
56
  {
@@ -51,224 +58,316 @@ Add one line to your `opencode.json`:
51
58
  }
52
59
  ```
53
60
 
54
- That's it. **No other config needed.** The plugin auto-registers:
61
+ ### Git-Backed
62
+
63
+ Use GitHub when you want the latest pushed changes immediately.
64
+
65
+ ```json
66
+ {
67
+ "plugin": ["openhermes@git+https://github.com/nathwn12/openhermes.git"]
68
+ }
69
+ ```
70
+
71
+ Either way, **no other config needed.** The plugin auto-registers:
55
72
 
56
73
  | What | Details |
57
74
  |------|---------|
58
- | **7 subagents** | `architect`, `planner`, `code-reviewer`, `security-reviewer`, `build-error-resolver`, `e2e-runner`, `explore` |
59
- | **7 slash commands** | `/plan`, `/build-fix`, `/code-review`, `/security`, `/doctor`, `/memory-search`, `/learn` |
60
- | **5 native memory tools** | `hm_put`, `hm_get`, `hm_list`, `hm_latest`, `hm_search` — in-process, no MCP server needed |
75
+ | **25 subagents** | 7 core + 18 specialist:<br>**Core:** architect, planner, build-error-resolver, code-reviewer, security-reviewer, e2e-runner, explore<br>**Specialist:** tdd-guide, docs-lookup, doc-updater, refactor-cleaner, loop-operator, harness-optimizer, review-go, build-go, review-rust, build-rust, review-python, review-java, build-java, review-kotlin, build-kotlin, review-cpp, build-cpp, review-database |
76
+ | **27 slash commands** | `/plan`, `/build-fix`, `/code-review`, `/security`, `/doctor`, `/memory-search`, `/learn`, `/ohc`, `/orchestrate`, `/eval`, `/model-route`, `/quality-gate`, `/test-coverage`, `/update-docs`, `/update-codemaps`, `/refactor-clean`, `/verify`, `/checkpoint`, `/loop-start`, `/loop-status`, `/harness-audit`, `/setup-pm`, `/go-build`, `/go-review`, `/rust-build`, `/rust-review`, `/skill-create`, `/update-me` |
77
+ | **6 native memory tools** | `add_memory`, `fetch_memory`, `list_memory`, `latest_memory`, `search_memory`, `archive_memory` — in-process, no MCP server needed |
61
78
  | **10 procedural skills** | API design, backend patterns, coding standards, E2E testing, frontend patterns, frontend slides, security review, strategic compaction, TDD workflow, verification loop |
62
- | **5 lifecycle plugins** | bootstrap, curator, autorecall, skill-builder, memory-tools |
79
+ | **6 lifecycle plugins** | bootstrap, curator, autorecall, skill-builder, memory-tools, ohc |
63
80
 
64
81
  You only need to define primary agents (like `build` or `OpenHermes`) in `opencode.json` — subagents are injected automatically.
65
82
 
83
+ > **🔄 Force update / repair:** Run `/update-me` anytime to clear the cached OpenHermes and reload from source. Works with both git-backed and npm installs. Use when the plugin feels stale, broken, or you just pushed changes upstream.
84
+
66
85
  <details>
67
86
  <summary><b>What happens on your next session</b></summary>
68
87
 
69
- 1. **Config hook** — BootstrapPlugin registers auto-config: 7 subagents, 7 commands, 10 skill dirs.
70
- 2. **Chat transform hook** — ~12KB of context injected into the first user message:
71
- - &#9733; **Constitution** (soul.md) — 11 immutable principles
72
- - &#9733; **Runtime** (RUNTIME.md) — gather → delegate → verify → compress
73
- - &#9733; **Router** (AGENTS.md) — delegation table, memory policy, escalation, with absolute paths to every rule
74
- 3. **Session created** — AutorecallPlugin builds recall cache from prior session memory
75
- 4. **Tools execute** — SkillBuilderPlugin watches tool calls and subagent spawns; MemoryToolsPlugin provides 5 native tools immediately
76
- 5. **Session idle** — CuratorPlugin snapshots checkpoint + verification receipt
77
- 6. **Session error** — CuratorPlugin logs mistake with root cause + prevention rule
78
- 7. **Compaction** — CuratorPlugin force-writes pre-compaction checkpoint, injects state into buffer
88
+ 1. **Config hook** — BootstrapPlugin registers auto-config: 25 subagents, 27 commands, 10 skill dirs.
89
+ 2. **Chat transform hook** — bootstrap content is injected into the first user message:
90
+ - &#9733; **Constitution** (`soul.md`) — 11 immutable principles
91
+ - &#9733; **Runtime** (`RUNTIME.md`) — gather → delegate → verify → compress
92
+ - &#9733; **Router** (`AGENTS.md`) — delegation table, memory policy, escalation, and rule paths
93
+ 3. **Session created** — AutorecallPlugin builds recall cache from prior session memory.
94
+ 4. **Tools execute** — SkillBuilderPlugin watches tool calls and subagent spawns; MemoryToolsPlugin provides 5 native tools immediately.
95
+ 5. **Session idle** — CuratorPlugin snapshots checkpoint + verification receipt.
96
+ 6. **Session error** — CuratorPlugin logs mistake with root cause + prevention rule.
97
+ 7. **Compaction** — CuratorPlugin force-writes a pre-compaction checkpoint and injects state into the compaction buffer.
79
98
 
80
- The LLM reads rules on demand via the injected paths. Memory directories auto-create. Everything Just Works™.
99
+ The LLM reads rules on demand via the injected paths. Memory directories auto-create. Everything Just Works.
81
100
 
82
101
  </details>
83
102
 
84
103
  ---
85
104
 
86
- ## The Five Plugins
105
+ ## Context Pruner (OHC)
106
+
107
+ ### Required: disable OpenCode's built-in compaction
108
+
109
+ Add to your `opencode.json` to prevent double pruning:
110
+
111
+ ```json
112
+ {
113
+ "compaction": {
114
+ "auto": false
115
+ }
116
+ }
117
+ ```
118
+
119
+ See [OpenCode compaction docs](https://opencode.ai/docs/config/#compaction).
120
+
121
+ ### Configure OHC
122
+
123
+ Config lives at `~/.config/opencode/ohc.json` — auto-generated with defaults on first load if missing:
124
+
125
+ ```json
126
+ {
127
+ "enabled": true,
128
+ "max": 200000,
129
+ "min": 50000
130
+ }
131
+ ```
132
+
133
+ | Field | Default | Job |
134
+ |-------|---------|-----|
135
+ | `enabled` | `true` | Master switch |
136
+ | `max` | `200000` | Advisory prune threshold (soft — agent can override) |
137
+ | `min` | `50000` | Advisory token floor (soft — agent can override via `targetTokens`) |
138
+
139
+ Values are **soft defaults** — the agent has full control. When the user asks "compress to X", pass `targetTokens` to the `compress` tool.
140
+
141
+ System prompt is injected with your budget and floor. As context grows, progressive nudges appear at 70%, 85%, and 95% urging proactive compression. Use `/ohc compress [focus]` or call the `compress` tool to free space on demand.
142
+
143
+ **Commands:**
144
+ - `/ohc status` — show current context usage
145
+ - `/ohc compress [targetTokens] [focus]` — queue compression with optional numeric target
146
+
147
+ **Compress tool:** LLM-available. Call `compress` with a technical summary and optional `targetTokens` (lower = more aggressive). Token counts are rough estimates — the tool reports message count removed, not token savings.
148
+
149
+ ---
150
+
151
+ ## The Seven Plugins
152
+
153
+ ### BootstrapPlugin
154
+ _Registers agents, commands, skills at config hook; injects constitution + router + runtime into every session._
155
+ - **Hooks:** `config`, `chat.transform`
156
+ - Registers 25 subagents, 27 commands, 10 skill paths
157
+
158
+ ### MemoryToolsPlugin
159
+ _Provides 6 native memory tools — no MCP server, no network, no sidecars._
160
+ - Registers `add_memory`, `fetch_memory`, `list_memory`, `latest_memory`, `search_memory`, `archive_memory`
161
+
162
+ ### CuratorPlugin
163
+ _Snapshots state, logs mistakes, records decisions — the agent's durable memory layer._
164
+ - **Hooks:** `session.idle`, `.error`, `.compacted`, `.compacting`, `permission.replied`
165
+ - Writes checkpoints, logs mistakes with root cause + prevention, records audits, injects state into compaction
87
166
 
88
- | Plugin | Triggers On | What It Does |
89
- |--------|------------|--------------|
90
- | **BootstrapPlugin** | `config`, `chat.transform` | Registers 7 subagents, 7 commands, 10 skill paths. Injects constitution + router + runtime. |
91
- | **MemoryToolsPlugin** | | Registers 5 native tools: `hm_put`, `hm_get`, `hm_list`, `hm_latest`, `hm_search`. Runs in-process — no MCP server needed. |
92
- | **CuratorPlugin** | `session.idle`, `.compacted`, `.error`, `.compacting`, `permission.replied` | Writes checkpoints, logs mistakes, records audits, injects state into compaction. |
93
- | **AutorecallPlugin** | `session.created` | Loads memory from disk, builds session recall cache. |
94
- | **SkillBuilderPlugin** | `session.idle`, `.created`, `tool.execute.after` | Detects complex sessions (8+ tool calls or 2+ subagent spawns) → creates skill-candidate backlogs. |
167
+ ### AutorecallPlugin
168
+ _Loads prior session memory into recall cache at startup._
169
+ - **Hooks:** `session.created`
170
+ - Builds recall cache from disk, aggregates active state for compaction injection
171
+
172
+ ### SkillBuilderPlugin
173
+ _Auto-detects complex sessions and creates skill-candidate backlogs._
174
+ - **Hooks:** `session.created`, `session.idle`, `tool.execute.after`
175
+ - Tracks tool call count and subagent spawns per session; flags sessions exceeding threshold (8+ tool calls or 2+ subagent spawns)
176
+
177
+ ### OhcPlugin
178
+ _Silent config-driven context pruner. No tool calls, no chat output, no toasts._
179
+ - **Hooks:** `config`, `experimental.chat.system.transform`, `.messages.transform`, `command.execute.before`, `tool.compress`
180
+ - Injects context budget via system prompt; progressive nudges at 70%/85%/95%; silent reaper enforces hard limit; `/ohc` command + `compress` tool for on-demand pruning
181
+
182
+ ### UpdaterPlugin
183
+ _Force-update / repair command for OpenHermes itself._
184
+ - **Hooks:** `command.execute.before`
185
+ - Registers `/update-me` — detects install method (git or npm), clears stale cache, tells user to restart. Safe to run anytime.
95
186
 
96
187
  ---
97
188
 
98
189
  ## Memory Architecture
99
190
 
100
- Nine memory classes, all schema-validated before persistence, stored at `~/.local/share/opencode/openhermes/memory/`:
191
+ Nine schema-validated classes across two dimensions what the record is and where it lives.
101
192
 
102
- | Class | Format | Purpose |
103
- |-------|--------|---------|
104
- | `checkpoint` | JSON | Pre-compaction snapshots: mission, current state, next actions, blockers |
105
- | `constraint` | JSON | Hard limits, env realities, safety rules — enforced by precedence engine |
106
- | `decision` | JSON | Durable project choices — shapes all future behavior |
107
- | `instinct` | JSON | Reusable trigger→action patterns with success/failure tracking |
108
- | `backlog` | JSON | Evidence-backed self-improvement items with acceptance criteria |
109
- | `mistake` | JSONL | Failure registry: type, root cause, fix, prevention rule, strike count |
110
- | `audit` | JSON | Structured quality/integrity evaluations with health scores |
111
- | `verification_receipt` | JSON | Cached verification results keyed by artifact fingerprint |
112
- | `recall` | JSON | Session-start cache aggregating active state for compaction injection |
193
+ ### Classes
113
194
 
114
- OpenHermes follows the same storage contract as OpenCode itself — see [OpenCode docs on storage](https://opencode.ai/docs/troubleshooting/#storage):
195
+ | Class | Format | Layer | Purpose |
196
+ |-------|--------|-------|---------|
197
+ | `checkpoint` | JSON | 🧠 State | Pre-compaction snapshots: mission, state, next actions, blockers |
198
+ | `constraint` | JSON | 🧠 State | Hard limits, env realities, safety rules |
199
+ | `decision` | JSON | 🧠 State | Durable project choices shaping all future behavior |
200
+ | `instinct` | JSON | 📈 Learning | Reusable trigger→action patterns with hit tracking |
201
+ | `backlog` | JSON | 📈 Learning | Evidence-backed self-improvement items with acceptance criteria |
202
+ | `mistake` | JSONL | 📈 Learning | Failure registry: type, root cause, fix, prevention, strike count |
203
+ | `audit` | JSON | ✅ Integrity | Structured quality evaluations with health scores |
204
+ | `verification_receipt` | JSON | ✅ Integrity | Cached verification results keyed by artifact fingerprint |
205
+ | `recall` | JSON | ✅ Integrity | Session-start cache for compaction buffer injection |
206
+
207
+ ### Storage
115
208
 
116
209
  | What | Where |
117
- |---|---|
118
- | Config (schemas, archive) | `~/.config/opencode/openhermes/` |
210
+ |------|-------|
211
+ | OHC config | `~/.config/opencode/ohc.json` |
119
212
  | Durable memory + runtime state | `~/.local/share/opencode/openhermes/` |
120
213
  | Derived recall cache | `~/.cache/opencode/openhermes/recall/` |
121
214
 
122
- **Runtime hardening**: All records pass through `sanitizeRecord()` (strips `__proto__`, `constructor`, `prototype`), `redactSensitiveText()` (strips bearer tokens, API keys, passwords), and `truncateText()` before persistence. Schema validation gate runs before every write.
215
+ ### Hardening
216
+
217
+ Every record is scrubbed before persistence: `sanitizeRecord()` strips proto-poison (`__proto__`, `constructor`, `prototype`), `redactSensitiveText()` strips bearer tokens / API keys / passwords, `truncateText()` caps field sizes. Schema validation runs before every write.
123
218
 
124
219
  ---
125
220
 
126
221
  ## Session Lifecycle
127
222
 
223
+ A session runs through three phases. Six plugins coordinate across 20+ OpenCode hooks — no polling, no cron, no sidecars.
224
+
225
+ **▶️ Warmup — one-shot, session start**
128
226
  ```
129
- session.startup (config hook)
130
- BootstrapPlugin registers harness/skills/
131
- │ OpenCode discovers 10 procedural skills
132
-
133
- session.created (chat.transform + session.created hooks)
134
- │ BootstrapPlugin injects constitution ▸ router ▸ runtime
135
- │ AutorecallPlugin loads memory writes recall cache
136
- │ SkillBuilderPlugin resets session counters
137
-
138
- tools execute...
139
- │ SkillBuilderPlugin counts tool calls + subagent spawns
140
-
141
- session.idle
142
- CuratorPlugin snapshots checkpoint + verification receipt
143
- SkillBuilderPlugin checks complexity → backlog entry if threshold met
144
-
145
- session.compacted
146
- │ CuratorPlugin updates loop-state → "compacted"
147
-
148
- experimental.session.compacting
149
- │ CuratorPlugin force-writes pre-compaction checkpoint
150
- │ Injects harness state + recall context compaction buffer
151
-
152
- session.error
153
- │ CuratorPlugin logs mistake (type, root cause, fix, prevention, strike)
154
- │ Updates loop-state with error status
155
-
156
- permission.replied
157
- │ CuratorPlugin writes audit record for every permission decision
227
+ config hook BootstrapPlugin registers harness/skills/, skills auto-discover
228
+ session.created BootstrapPlugin injects constitution ▸ router ▸ runtime
229
+ AutorecallPlugin loads disk memory → writes recall cache
230
+ SkillBuilderPlugin resets counters
231
+ ```
232
+
233
+ **⚙️ Execution per tool call, per subagent spawn**
234
+ ```
235
+ tool.execute.* SkillBuilderPlugin counts calls + spawns
236
+ ```
237
+
238
+ **⏹️ Cooldown — auto-triggered by OpenCode lifecycle**
239
+ ```
240
+ session.idle CuratorPlugin: checkpoint snapshot + verification receipt
241
+ SkillBuilderPlugin: complexity check → backlog candidate
242
+
243
+ session.compacting CuratorPlugin: force-writes pre-compaction checkpoint
244
+ Injects harness state + recall context compaction buffer
245
+
246
+ session.compacted CuratorPlugin: updates loop-state to "compacted"
247
+
248
+ session.error CuratorPlugin: logs mistake (type, root cause, fix, prevention)
249
+
250
+ permission.replied CuratorPlugin: writes audit record for every permission decision
158
251
  ```
159
252
 
160
253
  ---
161
254
 
255
+ ## Verification Discipline
256
+
257
+ One core habit — **verify before claiming success.**
258
+
259
+ | Rule | Why |
260
+ |------|-----|
261
+ | 🕵️ Read before editing | Don't fix what you haven't seen |
262
+ | 🧪 Run before announcing | Don't claim what you haven't tested |
263
+ | 🧬 Cache by fingerprint | Same file, same receipt — skip re-verify |
264
+ | 🔄 Re-verify on change | Stale receipt is worse than no receipt |
265
+ | 🚩 Flag contradictions | Silence is consent to bugs |
266
+
267
+ Verification receipts are a first-class memory type — keyed by artifact identity + fingerprint (path, mtime, hash). When the artifact is unchanged, the cached receipt suffices. When the artifact changes, re-verify. This is not an afterthought — it's the difference between "I think it works" and "I know it works."
268
+
269
+ ---
270
+
162
271
  ## Bundled Harness
163
272
 
164
- The full OpenHermes framework ships inside the package 60 files across 6 directories:
273
+ The full operational doctrine ships inside the package. Six directories, zero dependencies outside Node.js.
165
274
 
166
- ```
167
- harness/
168
- ├── constitution/soul.md # 11 immutable personality principles
169
- ├── instructions/RUNTIME.md # Session workflow: gather delegate verify
170
- ├── rules/ (16 files)
171
- │ ├── delegation.md # Mandatory subagent routing
172
- │ ├── retrieval.md # Gated precision-first memory retrieval
173
- │ ├── session-start.md # Session-start checklist and memory hydration
174
- │ ├── credential-exposure.md # Secret redaction and credential exposure guard
175
- │ ├── self-heal.md # T0→T3 escalation tiers
176
- │ ├── verification.md # Skeptical evidence protocol
177
- │ ├── memory-management.md # Dual-target memory + anti-spam
178
- │ ├── precedence.md # 9-level conflict resolution
179
- │ ├── checkpointing.md # Compaction snapshot discipline
180
- │ ├── audit.md # Structured health checks
181
- │ ├── skills-management.md # Progressive disclosure loading
182
- │ ├── context-loading.md # Priority chain + size limits
183
- │ ├── promotion.md # High-signal-only promotion
184
- │ ├── ranking.md # Metadata-first retrieval
185
- │ ├── runtime-guards.md # Stale assumption prevention
186
- │ └── state-drift.md # Hash-based fingerprinting
187
- ├── skills/ (10 directories)
188
- │ ├── api-design/SKILL.md # REST API patterns (523 lines)
189
- │ ├── backend-patterns/SKILL.md # Backend architecture (598 lines)
190
- │ ├── coding-standards/SKILL.md # Baseline conventions (549 lines)
191
- │ ├── e2e-testing/SKILL.md # Playwright E2E patterns (326 lines)
192
- │ ├── frontend-patterns/SKILL.md # React/Next.js patterns (642 lines)
193
- │ ├── frontend-slides/SKILL.md # HTML presentation builder (184 lines)
194
- │ ├── security-review/SKILL.md # OWASP Top 10 checklist (495 lines)
195
- │ ├── strategic-compact/SKILL.md # Context compaction strategy (131 lines)
196
- │ ├── tdd-workflow/SKILL.md # Red-green-refactor discipline (463 lines)
197
- │ └── verification-loop/SKILL.md # Pre-PR quality gates (126 lines)
198
- ├── prompts/ (7 files)
199
- │ # Subagent prompt templates: architect, build-error-resolver,
200
- │ # code-reviewer, e2e-runner, explore, planner, security-reviewer
201
- └── commands/ (7 files)
202
- # Slash command templates: build-fix, code-review, doctor,
203
- # learn, memory-search, plan, security
204
- ```
275
+ | Directory | What it contains | Why it matters |
276
+ |-----------|-----------------|----------------|
277
+ | `constitution/` | `soul.md` 11 immutable principles | Your agent's personality, frozen |
278
+ | `instructions/` | Runtime workflow + coding conventions | The playbook every session runs on |
279
+ | `rules/` | 16 files: retrieval, verification, audit, self-heal, delegation, ... | The legal framework — no ambiguity |
280
+ | `skills/` | 10 procedural SKILL.md files | Domain expertise discovered automatically |
281
+ | `prompts/` | 25 subagent prompt templates | Language specialists, docs lookup, loop drivers — all on tap |
282
+ | `commands/` | 26 slash command templates | From `/verify` to `/review-go` full toolbelt |
283
+
284
+ OpenHermes is not a runtime shim. The doctrine ships with the package — every subagent and every command follows the same constitution, rules, and conventions.
205
285
 
206
286
  ---
207
287
 
208
288
  ## Self-Healing Escalation
209
289
 
210
- When your agent makes a mistake, OpenHermes doesn't just log it it escalates:
290
+ A mistake is not a failure it's a signal. OpenHermes escalates through four tiers before it ever reaches you.
291
+
292
+ ```
293
+ T0 ── Any mistake
294
+ Observe → log mistake record → smallest safe correction → verify
295
+
296
+ T1 ── Same mistake repeats within 7 days
297
+ Add prevention rule → targeted verification
211
298
 
212
- | Tier | Trigger | Action |
213
- |------|---------|--------|
214
- | **T0** | Any mistake | Observe → log mistake record → smallest safe correction → verify |
215
- | **T1** | Same mistake repeats within 7 days | Add prevention rule → targeted verification |
216
- | **T2** | Prevention failed / systemic issue | Delegate to specialist → audit → backlog item |
217
- | **T3** | Cascading failures | Constrained safe mode: narrow claims, preserve receipts, produce handoff |
299
+ T2 ── Prevention failed / systemic issue
300
+ Delegate to specialist → deep audit → backlog item
218
301
 
219
- No self-termination. No grandstanding. Narrow, log, recover, improve.
302
+ T3 ── Cascading failures
303
+ Constrained safe mode: narrow claims, preserve receipts, produce handoff
304
+ ```
305
+
306
+ No self-termination. No grandstanding. Narrow, log, recover, improve. The agent gets better — you don't have to teach it twice.
220
307
 
221
308
  ---
222
309
 
223
310
  ## Environment Variables
224
311
 
312
+ Two knobs. That's it.
313
+
225
314
  | Variable | Default | Effect |
226
315
  |----------|---------|--------|
227
- | `OPENCODE_ALLOW_PROJECT_HARNESS` | `false` | Use project-local harness at `.opencode/openhermes/` |
228
- | `OPENCODE_CURATOR_LOGS` | `false` | Enable curator diagnostic output to stderr |
316
+ | `OPENCODE_ALLOW_PROJECT_HARNESS` | `false` | Enable project-local harness at `.opencode/openhermes/` |
317
+ | `OPENCODE_CURATOR_LOGS` | `false` | Pipe curator diagnostics to stderr for debugging |
229
318
 
230
319
  ---
231
320
 
232
321
  ## Architecture
233
322
 
323
+ Three layers. All ES modules. One runtime dependency.
324
+
234
325
  ```
235
326
  openhermes/
236
- ├── index.mjs # Re-exports all 5 plugins
237
- ├── bootstrap.mjs # Config hook (agents/commands/skills) + chat.transform
238
- ├── autorecall.mjs # Recall cache builder
239
- ├── curator.mjs # Lifecycle hooks engine (~470 lines)
240
- ├── skill-builder.mjs # Complexity detection engine
241
- ├── lib/
242
- ├── memory-tools-plugin.mjs # 5 native memory tools (hm_put/get/list/latest/search)
243
- ├── hardening.mjs # atomicWriteJson, fingerprint, sanitize, redact
244
- └── schema-validator.mjs # Draft-07 subset validator
245
- ├── schemas/ # 9 JSON schemas for memory validation
246
- ├── harness/ # Full framework (44 files)
247
- └── package.json
327
+
328
+ ├── ⚡ index.mjs # Plugin exports (all 5)
329
+ ├── ⚡ bootstrap.mjs # Config hook + chat.transform
330
+ ├── ⚡ autorecall.mjs # Memory recall cache
331
+ ├── ⚡ curator.mjs # Lifecycle hooks engine
332
+ ├── ⚡ skill-builder.mjs # Complexity detection
333
+
334
+ ├── lib/
335
+ ├── memory-tools-plugin.mjs # 5 hm_* tools
336
+ ├── hardening.mjs # sanitize, redact, atomic write
337
+ ├── paths.mjs # storage root resolver
338
+ │ ├── schema-validator.mjs # Draft-07 validation
339
+ │ └── ohc/ # context pruner
340
+
341
+ ├── ⚡ schemas/ # 9 Draft-07 memory schemas
342
+
343
+ ├── 📦 harness/
344
+ │ ├── constitution/ # soul.md — 11 principles
345
+ │ ├── instructions/ # runtime + conventions
346
+ │ ├── rules/ # 16 files
347
+ │ ├── skills/ # 10 procedural skills
348
+ │ ├── prompts/ # 25 subagent templates
349
+ │ └── commands/ # 26 slash command templates
350
+
351
+ └── 📦 package.json # one dependency: @opencode-ai/plugin
248
352
  ```
249
353
 
250
- **Minimal npm dependency footprint.** Tool definitions use OpenCode's tiny `@opencode-ai/plugin` SDK. No postinstall scripts. No native compilation.
251
-
252
- ---
253
-
254
- ## Dependencies
255
-
256
- - **Node.js >= 18** — `node:path`, `node:fs`, `node:os`, `node:url`, `node:crypto`
257
- - **OpenCode** — provides the Bun runtime, plugin loader, hook dispatcher, and `skill` tool
354
+ **Dependency footprint:** `@opencode-ai/plugin` only. No postinstall scripts. No native compilation. No Docker. No Python. Your entire agent OS in a single `npm install`.
258
355
 
259
356
  ---
260
357
 
261
358
  ## Why OpenHermes ≠ Hermes Agent
262
359
 
360
+ Same messenger emoji. Entirely different mediums.
361
+
263
362
  | | Hermes Agent | OpenHermes |
264
- |--|------------|------------|
265
- | **Platform** | Standalone agent with custom TUI, multi-platform gateway, cron scheduler | OpenCode-native plugin — runs *inside* your existing setup |
266
- | **Installation** | `curl | bash` + Python 3.11 + uv + Docker (optional) + PostgreSQL (optional) | `npm i` — that's it |
267
- | **Infrastructure** | Sidecar processes, gateway daemon, FTS5 database, Honcho user modeling | Zero sidecars — everything is a plugin hook |
268
- | **Memory** | Honcho dialectic user profiles + skills system | Schema-validated 9-class memory + in-process native tools |
269
- | **Skills** | Agentskills.io standard, self-created + improving | SKILL.md progressive disclosure, skill-builder auto-detection |
270
- | **Context** | Context files + session search with LLM summarization | Harness injection at session start, recall cache at compaction |
271
- | **Philosophy** | "The self-improving agent" — feature-rich, platform-expansive | "The constitutional router" — discipline-first, precision-only |
363
+ |-|------------|------------|
364
+ | Platform | Standalone agent TUI + gateway + cron | OpenCode-native plugin — lives *inside* your editor |
365
+ | Installation | Python 3.11 + uv + 30+ deps 5-15 min | `npm i` — 3 seconds |
366
+ | Infrastructure | Long-running gateway, cron daemon, 20 platform adapters, 7 terminal backends, SQLite+FTS5 | Zero sidecars — everything is a plugin hook |
367
+ | Memory | MEMORY.md + USER.md files + optional Honcho | 9-class schema-validated memory with in-process tools |
368
+ | Skills | agentskills.io standard, auto-creation + self-improvement | SKILL.md progressive disclosure, auto-detected |
369
+ | Context | Context files + FTS5 search + LLM summarization | Harness injection at startup, recall cache at compaction |
370
+ | Philosophy | "The self-improving agent" — feature-rich, platform-expansive | "The constitutional router" — discipline-first, precision-only |
272
371
 
273
372
  Both are &#9764; messengers. Different mediums.
274
373
 
@@ -285,5 +384,5 @@ Problems, ideas, improvements? [Open an issue](https://github.com/nathwn12/openh
285
384
  MIT — see [LICENSE](LICENSE).
286
385
 
287
386
  <p align="center">
288
- <sub><b>&#9764;</b> Built with discipline. Inspired by <a href="https://github.com/NousResearch/hermes-agent">Hermes Agent</a>. Built for <a href="https://opencode.ai">OpenCode</a>.</sub>
387
+ <sub><b>&#9764;</b> Built with discipline. Inspired by <a href="https://github.com/NousResearch/hermes-agent">Hermes Agent</a>, <a href="https://github.com/everything-claude-code/ecc">Everything Claude Code</a>, and <a href="https://github.com/Opencode-DCP/opencode-dynamic-context-pruning">Dynamic Context Pruning</a>. Built for <a href="https://opencode.ai">OpenCode</a>.</sub>
289
388
  </p>
package/autorecall.mjs CHANGED
@@ -1,21 +1,11 @@
1
1
  import path from "node:path"
2
2
  import os from "node:os"
3
3
  import fs from "node:fs"
4
- import { atomicWriteJson, fingerprintEnvironment, isTruthy, sanitizeRecord, truncateText } from "./lib/hardening.mjs"
4
+ import { atomicWriteJson, fingerprintEnvironment, isTruthy, readJson, readJsonl, sanitizeRecord, truncateText } from "./lib/hardening.mjs"
5
5
  import { getDataRoot, getCacheRoot, getMemoryRoot, getRecallRoot, getRuntimeRoot } from "./lib/paths.mjs"
6
6
 
7
7
  const OLD_BASE = path.join(os.homedir(), ".config", "opencode", "openhermes")
8
8
 
9
- function readJson(fp, fallback) {
10
- try { return JSON.parse(fs.readFileSync(fp, "utf8")) } catch { return fallback }
11
- }
12
-
13
- function readJsonl(fp) {
14
- try {
15
- return fs.readFileSync(fp, "utf8").trim().split("\n").filter(Boolean).map(l => JSON.parse(l))
16
- } catch { return [] }
17
- }
18
-
19
9
  function loadMemoryRecord(root, className, entry) {
20
10
  const recordPath = path.join(root, "memory", className, `${entry.id}.json`)
21
11
  const record = readJson(recordPath, null)
@@ -64,7 +54,7 @@ function formatBacklogNudge(candidates) {
64
54
  `Top candidates:`,
65
55
  top,
66
56
  `Trigger: /learn to create skills from these sessions.`,
67
- `If none are skill-worthy, close them via hm_put with status:"closed".`
57
+ `If none are skill-worthy, close them via add_memory with status:"closed".`
68
58
  ].join("\n")
69
59
  }
70
60