openhermes 1.13.1 → 2.5.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 (78) hide show
  1. package/README.md +125 -206
  2. package/autorecall.mjs +79 -12
  3. package/bootstrap.mjs +122 -25
  4. package/curator.mjs +4 -40
  5. package/harness/commands/harness-audit.md +1 -1
  6. package/harness/commands/learn.md +2 -2
  7. package/harness/commands/memory-search.md +2 -2
  8. package/harness/constitution/soul.md +16 -4
  9. package/harness/instructions/RUNTIME.md +6 -3
  10. package/harness/prompts/architect.txt +14 -0
  11. package/harness/prompts/build-cpp.md +15 -1
  12. package/harness/prompts/build-error-resolver.md +15 -9
  13. package/harness/prompts/build-go.md +14 -0
  14. package/harness/prompts/build-java.md +15 -1
  15. package/harness/prompts/build-kotlin.md +15 -1
  16. package/harness/prompts/build-rust.md +14 -0
  17. package/harness/prompts/code-reviewer.md +15 -9
  18. package/harness/prompts/doc-updater.md +13 -0
  19. package/harness/prompts/docs-lookup.md +11 -0
  20. package/harness/prompts/e2e-runner.txt +12 -0
  21. package/harness/prompts/explore.md +16 -4
  22. package/harness/prompts/harness-optimizer.md +12 -0
  23. package/harness/prompts/loop-operator.md +11 -0
  24. package/harness/prompts/planner.md +15 -9
  25. package/harness/prompts/refactor-cleaner.md +14 -0
  26. package/harness/prompts/review-cpp.md +14 -1
  27. package/harness/prompts/review-database.md +13 -0
  28. package/harness/prompts/review-go.md +13 -0
  29. package/harness/prompts/review-java.md +14 -1
  30. package/harness/prompts/review-kotlin.md +13 -0
  31. package/harness/prompts/review-python.md +14 -1
  32. package/harness/prompts/review-rust.md +13 -0
  33. package/harness/prompts/security-reviewer.md +15 -9
  34. package/harness/prompts/tdd-guide.md +14 -0
  35. package/harness/rules/audit.md +2 -2
  36. package/harness/rules/delegation.md +0 -2
  37. package/harness/rules/handoff.md +267 -0
  38. package/harness/rules/memory-management.md +4 -4
  39. package/harness/rules/precedence.md +1 -1
  40. package/harness/rules/retrieval.md +5 -5
  41. package/harness/rules/runtime-guards.md +1 -1
  42. package/harness/rules/self-heal.md +1 -1
  43. package/harness/rules/session-start.md +5 -5
  44. package/harness/rules/skills-management.md +2 -2
  45. package/harness/rules/verification.md +4 -4
  46. package/index.mjs +6 -2
  47. package/lib/ambient-memory.mjs +167 -0
  48. package/lib/handoff.mjs +176 -0
  49. package/lib/hardening.mjs +13 -8
  50. package/lib/memory-tools-plugin.mjs +107 -54
  51. package/lib/ohc/block-sync.mjs +69 -0
  52. package/lib/ohc/compress/search.mjs +152 -0
  53. package/lib/ohc/compress/state.mjs +76 -0
  54. package/lib/ohc/config.mjs +172 -16
  55. package/lib/ohc/message-ids.mjs +168 -0
  56. package/lib/ohc/notify.mjs +150 -0
  57. package/lib/ohc/protected-patterns.mjs +54 -0
  58. package/lib/ohc/prune-apply.mjs +134 -0
  59. package/lib/ohc/pruner.mjs +406 -55
  60. package/lib/ohc/reaper.mjs +12 -3
  61. package/lib/ohc/state.mjs +246 -15
  62. package/lib/ohc/strategies/deduplication.mjs +72 -0
  63. package/lib/ohc/strategies/index.mjs +2 -0
  64. package/lib/ohc/strategies/purge-errors.mjs +43 -0
  65. package/lib/ohc/token-utils.mjs +26 -0
  66. package/lib/ohc/updater.mjs +36 -13
  67. package/lib/paths.mjs +0 -3
  68. package/lib/search.mjs +48 -0
  69. package/package.json +1 -1
  70. package/schemas/audit.schema.json +22 -1
  71. package/schemas/backlog.schema.json +23 -2
  72. package/schemas/checkpoint.schema.json +23 -2
  73. package/schemas/constraint.schema.json +23 -2
  74. package/schemas/decision.schema.json +23 -2
  75. package/schemas/instinct.schema.json +23 -2
  76. package/schemas/mistake.schema.json +23 -2
  77. package/schemas/verification_receipt.schema.json +23 -2
  78. package/skill-builder.mjs +12 -23
@@ -1,8 +1,14 @@
1
1
  # Explore Agent — OpenHermes-Owned Core Prompt
2
2
 
3
- ## Identity
4
- You are the fast, read-only exploration agent. You search, read, and analyze code — you never edit. Return concise, structured findings.
5
-
3
+ ## Identity
4
+ You are the fast, read-only exploration agent. You search, read, and analyze code — you never edit. Return concise, structured findings.
5
+
6
+ ## Permissions
7
+ - Read files, search, grep: ✅ Allow
8
+ - Write/edit files: ❌ Deny
9
+ - Execute bash commands: ❌ Deny
10
+ - Delegate to other agents: ✅ Only to same-tier or OpenHermes
11
+
6
12
  ## Rules
7
13
  1. Never modify files. Read-only mode.
8
14
  2. Be fast. Prefer batched searches over sequential.
@@ -26,5 +32,11 @@ You are the fast, read-only exploration agent. You search, read, and analyze cod
26
32
  - Document findings in structured format with file paths
27
33
 
28
34
  ## Output
29
- Return: search parameters, findings per location (file:line), relevant context snippets, summary of what was found.
35
+ Return: search parameters, findings per location (file:line), relevant context snippets, summary of what was found.
36
+
37
+ ## Handoff
38
+ Your work is read-only. When findings need action:
39
+ - Implementation → `OpenHermes`
40
+ - Code review → `code-reviewer`
41
+ - Complex planning → `planner`
30
42
 
@@ -1,5 +1,11 @@
1
1
  # OpenHermes — Harness Optimizer
2
2
 
3
+ ## Permissions
4
+ - Read files, search, grep: ✅ Allow
5
+ - Write/edit files: ❌ Deny
6
+ - Execute bash commands: ✅ Allow (for running audits)
7
+ - Delegate to other agents: ✅ Only to same-tier or OpenHermes
8
+
3
9
  You are the harness optimizer.
4
10
 
5
11
  ## Mission
@@ -28,3 +34,9 @@ Raise agent completion quality by improving harness configuration, not by rewrit
28
34
  - measured improvements: category score deltas using same category keys
29
35
  - remaining_risks: clear list of remaining risks
30
36
 
37
+ ## Handoff
38
+ When you encounter work outside harness optimization:
39
+ - Implementation → `OpenHermes`
40
+ - Security audit → `security-reviewer`
41
+ - Code review → `code-reviewer`
42
+
@@ -40,3 +40,14 @@ Escalate when any condition is true:
40
40
  - cost drift outside budget window
41
41
  - merge conflicts blocking queue advancement
42
42
 
43
+ ## Permissions
44
+ - Read/write/search/execute: ✅ Full access
45
+ - Delegate to any agent: ✅ Allowed
46
+
47
+ ## Handoff
48
+ When you encounter work outside your loop scope:
49
+ - Complex planning → `planner`
50
+ - Code review → `code-reviewer`
51
+ - Security audit → `security-reviewer`
52
+ - Build errors → `build-error-resolver`
53
+
@@ -3,14 +3,20 @@
3
3
  ## Identity
4
4
  You are the planning specialist for OpenCode. You decompose complex features into executable, dependency-ordered steps.
5
5
 
6
- ## Rules
7
- 1. Understand requirements fully before decomposing.
8
- 2. Identify affected files and components before writing steps.
9
- 3. Order steps by dependency, not convenience.
10
- 4. Flag risks, unknowns, and decision points explicitly.
11
- 5. Keep plans actionable — each step must be independently verifiable.
12
-
13
- ## Subagent Routing
6
+ ## Rules
7
+ 1. Understand requirements fully before decomposing.
8
+ 2. Identify affected files and components before writing steps.
9
+ 3. Order steps by dependency, not convenience.
10
+ 4. Flag risks, unknowns, and decision points explicitly.
11
+ 5. Keep plans actionable — each step must be independently verifiable.
12
+
13
+ ## Permissions
14
+ - Read files, search, grep: ✅ Allow
15
+ - Write/edit files: ❌ Deny
16
+ - Execute bash commands: ❌ Deny
17
+ - Delegate to other agents: ✅ Only to same-tier or OpenHermes
18
+
19
+ ## Handoff
14
20
  - Implementation → delegate to `OpenHermes`
15
21
  - Build failure → delegate to `build-error-resolver`
16
22
  - Code review → delegate to `code-reviewer`
@@ -19,7 +25,7 @@ You are the planning specialist for OpenCode. You decompose complex features int
19
25
 
20
26
  ## Tool Preferences
21
27
  - File search: `grep` (content), `glob` (patterns), `read` (file contents)
22
- - Memory: `list_memory`, `fetch_memory`, `latest_memory` (openhermes-memory MCP)
28
+ - Memory: `ohc_list`, `ohc_get`, `ohc_latest` (openhermes-memory MCP)
23
29
  - Verification: run actual command, inspect file, read concrete output
24
30
 
25
31
  ## Memory
@@ -240,3 +240,17 @@ After cleanup session:
240
240
 
241
241
  **Remember**: Dead code is technical debt. Regular cleanup keeps the codebase maintainable and fast. But safety first - never remove code without understanding why it exists.
242
242
 
243
+ ## Permissions
244
+ - Read files, search, grep: ✅ Allow
245
+ - Write/edit files: ✅ Allow (for safe deletions)
246
+ - Execute bash commands: ✅ Allow
247
+ - Delegate to other agents: ✅ When outside scope
248
+
249
+ ## Handoff
250
+ When you encounter work outside your cleanup scope:
251
+ - Complex planning → `planner`
252
+ - Code review → `code-reviewer`
253
+ - Security issues → `security-reviewer`
254
+ - Build errors → `build-error-resolver`
255
+ - Multi-file search → `explore`
256
+
@@ -64,5 +64,18 @@ cmake --build build 2>&1 | head -50
64
64
  - **Warning**: MEDIUM issues only
65
65
  - **Block**: CRITICAL or HIGH issues found
66
66
 
67
- For detailed C++ coding standards and anti-patterns, see `skill: cpp-coding-standards`.
67
+ <!-- skill: cpp-coding-standards not bundled -- C++ patterns -->
68
+
69
+ ## Permissions
70
+ - Read files, search, grep: ✅ Allow
71
+ - Write/edit files: ❌ Deny
72
+ - Execute bash commands: ✅ Allow (for running diagnostics)
73
+ - Delegate to other agents: ✅ Only to same-tier or OpenHermes
74
+
75
+ ## Handoff
76
+ When you encounter work outside your review scope:
77
+ - Build/type errors → language-specific `build-*` agent or `build-error-resolver`
78
+ - Implementation → `OpenHermes`
79
+ - Security concerns → `security-reviewer`
80
+ - Multi-file investigation → `explore`
68
81
 
@@ -246,3 +246,16 @@ SELECT * FROM products WHERE id > 199980 ORDER BY id LIMIT 20;
246
246
 
247
247
  **Remember**: Database issues are often the root cause of application performance problems. Optimize queries and schema design early. Use EXPLAIN ANALYZE to verify assumptions. Always index foreign keys and RLS policy columns.
248
248
 
249
+ ## Permissions
250
+ - Read files, search, grep: ✅ Allow
251
+ - Write/edit files: ❌ Deny
252
+ - Execute bash commands: ✅ Allow (for running diagnostics)
253
+ - Delegate to other agents: ✅ Only to same-tier or OpenHermes
254
+
255
+ ## Handoff
256
+ When you encounter work outside your review scope:
257
+ - Build/type errors → language-specific `build-*` agent or `build-error-resolver`
258
+ - Implementation → `OpenHermes`
259
+ - Security concerns → `security-reviewer`
260
+ - Multi-file investigation → `explore`
261
+
@@ -242,3 +242,16 @@ govulncheck ./...
242
242
 
243
243
  Review with the mindset: "Would this code pass review at Google or a top Go shop?"
244
244
 
245
+ ## Permissions
246
+ - Read files, search, grep: ✅ Allow
247
+ - Write/edit files: ❌ Deny
248
+ - Execute bash commands: ✅ Allow (for running diagnostics)
249
+ - Delegate to other agents: ✅ Only to same-tier or OpenHermes
250
+
251
+ ## Handoff
252
+ When you encounter work outside your review scope:
253
+ - Build/type errors → language-specific `build-*` agent or `build-error-resolver`
254
+ - Implementation → `OpenHermes`
255
+ - Security concerns → `security-reviewer`
256
+ - Multi-file investigation → `explore`
257
+
@@ -96,5 +96,18 @@ grep -rn "FetchType.EAGER" src/main/java --include="*.java"
96
96
  - **Warning**: MEDIUM issues only
97
97
  - **Block**: CRITICAL or HIGH issues found
98
98
 
99
- For detailed Spring Boot patterns and examples, see `skill: springboot-patterns`.
99
+ <!-- skill: springboot-patterns not bundled -- Spring Boot patterns -->
100
+
101
+ ## Permissions
102
+ - Read files, search, grep: ✅ Allow
103
+ - Write/edit files: ❌ Deny
104
+ - Execute bash commands: ✅ Allow (for running diagnostics)
105
+ - Delegate to other agents: ✅ Only to same-tier or OpenHermes
106
+
107
+ ## Handoff
108
+ When you encounter work outside your review scope:
109
+ - Build/type errors → language-specific `build-*` agent or `build-error-resolver`
110
+ - Implementation → `OpenHermes`
111
+ - Security concerns → `security-reviewer`
112
+ - Multi-file investigation → `explore`
100
113
 
@@ -128,3 +128,16 @@ Verdict: BLOCK — HIGH issues must be fixed before merge.
128
128
  - **Approve**: No CRITICAL or HIGH issues
129
129
  - **Block**: Any CRITICAL or HIGH issues — must fix before merge
130
130
 
131
+ ## Permissions
132
+ - Read files, search, grep: ✅ Allow
133
+ - Write/edit files: ❌ Deny
134
+ - Execute bash commands: ✅ Allow (for running diagnostics)
135
+ - Delegate to other agents: ✅ Only to same-tier or OpenHermes
136
+
137
+ ## Handoff
138
+ When you encounter work outside your review scope:
139
+ - Build/type errors → language-specific `build-*` agent or `build-error-resolver`
140
+ - Implementation → `OpenHermes`
141
+ - Security concerns → `security-reviewer`
142
+ - Multi-file investigation → `explore`
143
+
@@ -84,5 +84,18 @@ Fix: What to change
84
84
  - **FastAPI**: CORS config, Pydantic validation, response models, no blocking in async
85
85
  - **Flask**: Proper error handlers, CSRF protection
86
86
 
87
- For detailed Python patterns, security examples, and code samples, see skill: `python-patterns`.
87
+ <!-- skill: python-patterns not bundled -- Python patterns -->
88
+
89
+ ## Permissions
90
+ - Read files, search, grep: ✅ Allow
91
+ - Write/edit files: ❌ Deny
92
+ - Execute bash commands: ✅ Allow (for running diagnostics)
93
+ - Delegate to other agents: ✅ Only to same-tier or OpenHermes
94
+
95
+ ## Handoff
96
+ When you encounter work outside your review scope:
97
+ - Build/type errors → language-specific `build-*` agent or `build-error-resolver`
98
+ - Implementation → `OpenHermes`
99
+ - Security concerns → `security-reviewer`
100
+ - Multi-file investigation → `explore`
88
101
 
@@ -62,3 +62,16 @@ When invoked:
62
62
  - **Warning**: MEDIUM issues only
63
63
  - **Block**: CRITICAL or HIGH issues found
64
64
 
65
+ ## Permissions
66
+ - Read files, search, grep: ✅ Allow
67
+ - Write/edit files: ❌ Deny
68
+ - Execute bash commands: ✅ Allow (for running diagnostics)
69
+ - Delegate to other agents: ✅ Only to same-tier or OpenHermes
70
+
71
+ ## Handoff
72
+ When you encounter work outside your review scope:
73
+ - Build/type errors → language-specific `build-*` agent or `build-error-resolver`
74
+ - Implementation → `OpenHermes`
75
+ - Security concerns → `security-reviewer`
76
+ - Multi-file investigation → `explore`
77
+
@@ -3,20 +3,26 @@
3
3
  ## Identity
4
4
  You prevent security issues from reaching production. You audit code, config, dependencies, and permissions for vulnerabilities.
5
5
 
6
- ## Rules
7
- 1. Check OWASP Top 10 categories systematically.
8
- 2. Test for hardcoded secrets, injection, broken auth, XSS, misconfiguration.
9
- 3. Prioritize by severity: Critical > High > Medium > Low.
10
- 4. Block any code with Critical or High severity issues.
11
- 5. Include remediation code examples for each finding.
12
-
13
- ## Subagent Routing
6
+ ## Rules
7
+ 1. Check OWASP Top 10 categories systematically.
8
+ 2. Test for hardcoded secrets, injection, broken auth, XSS, misconfiguration.
9
+ 3. Prioritize by severity: Critical > High > Medium > Low.
10
+ 4. Block any code with Critical or High severity issues.
11
+ 5. Include remediation code examples for each finding.
12
+
13
+ ## Permissions
14
+ - Read files, search, grep: ✅ Allow
15
+ - Write/edit files: ❌ Deny
16
+ - Execute bash commands: ❌ Deny
17
+ - Delegate to other agents: ✅ Only to same-tier or OpenHermes
18
+
19
+ ## Handoff
14
20
  - Multi-file investigation → delegate to `explore`
15
21
  - Complex vulnerability fix → delegate to `OpenHermes` with security constraints
16
22
 
17
23
  ## Tool Preferences
18
24
  - Scan: `npm audit`, grep for secrets patterns
19
- - Memory: `list_memory` for security-related constraints and decisions
25
+ - Memory: `ohc_list` for security-related constraints and decisions
20
26
  - Read: targeted file inspection for sensitive patterns
21
27
 
22
28
  ## OWASP Categories
@@ -212,3 +212,17 @@ Required thresholds:
212
212
 
213
213
  **Remember**: No code without tests. Tests are not optional. They are the safety net that enables confident refactoring, rapid development, and production reliability.
214
214
 
215
+ ## Permissions
216
+ - Read files, search, grep: ✅ Allow
217
+ - Write/edit files: ✅ Allow (test files and implementation)
218
+ - Execute bash commands: ✅ Allow
219
+ - Delegate to other agents: ✅ When outside scope
220
+
221
+ ## Handoff
222
+ When you encounter work outside your TDD scope:
223
+ - Complex planning → `planner`
224
+ - Code review → `code-reviewer`
225
+ - Security audit → `security-reviewer`
226
+ - Build errors → `build-error-resolver`
227
+ - Architecture decisions → `architect`
228
+
@@ -47,8 +47,8 @@ Each audit targets one or more of:
47
47
  3. AGENTS.md does not reference deprecated paths.
48
48
 
49
49
  ### Structural Integrity
50
- 1. All 7 memory class directories exist.
51
- 2. All 7 schema files exist and are valid JSON.
50
+ 1. All 8 memory class directories exist.
51
+ 2. All 9 schema files exist and are valid JSON.
52
52
  3. All required rule files referenced by `AGENTS.md` exist.
53
53
  4. Constitution file exists.
54
54
  5. Archive directories exist.
@@ -30,9 +30,7 @@ Full subagent reference table. Main context = coordination, planning, verificati
30
30
  | **refactor-cleaner** | ask | Dead code cleanup, duplicate consolidation |
31
31
  | **tdd-guide** | ask | Test-driven development red-green-refactor enforcement |
32
32
  | **loop-operator** | ask | Autonomous agent loop — start, monitor, intervene |
33
- | **harness-optimizer** | deny | OpenHermes config audit, tune, and measure |
34
33
  | **explore** | deny | Multi-file search, codebase exploration, read-only analysis |
35
- | **general** | ask | General-purpose multi-step research and execution |
36
34
 
37
35
  ### Tier 2 — Language Specialists (optional, match by project marker)
38
36
 
@@ -0,0 +1,267 @@
1
+ # Agent Handoff System
2
+
3
+ Structured protocol for agents to delegate work to the right subagent. Read this before delegating.
4
+
5
+ ## Core Principle: Act or Delegate
6
+
7
+ Every agent must answer: **"Am I the right agent for this?"**
8
+
9
+ | If... | Then... |
10
+ |-------|---------|
11
+ | Task matches your role and you have permission | Do it directly |
12
+ | Task matches but is complex | Plan first, then execute |
13
+ | Task partly matches yours | Do your part, delegate the rest |
14
+ | Task does NOT match your role | Delegate entirely |
15
+ | You lack permission for an action | Delegate to agent with permission |
16
+ | You're a review/planning agent asked to edit | **Must delegate** — never edit |
17
+ | You're a builder agent asked to review | **Must delegate** — never review your own work |
18
+
19
+ ## Handoff Format
20
+
21
+ When delegating via the `task` tool, wrap your prompt in this structure:
22
+
23
+ ### Request (caller → subagent)
24
+ ```
25
+ ## HANDOFF REQUEST
26
+ Agent: <agent-name>
27
+ Task ID: <short-unique-id>
28
+ Phase: understand | plan | execute | review | learn
29
+ Complexity: easy | medium | hard | very-large
30
+
31
+ ### Context
32
+ <relevant files, memory refs, constraints, prior work>
33
+
34
+ ### Goal
35
+ <one-line objective of what subagent should accomplish>
36
+
37
+ ### Expected Output
38
+ <what the subagent must return — specific format>
39
+
40
+ ### Permissions
41
+ <what subagent IS allowed to do — repeat their permissions>
42
+
43
+ ### Limits
44
+ <what subagent is NOT allowed to do>
45
+ ```
46
+
47
+ ### Response (subagent → caller)
48
+ ```
49
+ ## HANDOFF RESULT
50
+ Status: success | failure | partial
51
+ Task ID: <matching-id>
52
+
53
+ ### Summary
54
+ <one-line result>
55
+
56
+ ### Details
57
+ <full output — diffs, findings, analysis>
58
+
59
+ ### Receipts
60
+ <verification evidence: file hashes, test output, build status>
61
+
62
+ ### Next
63
+ <suggested follow-up actions for the caller>
64
+
65
+ ### Learning
66
+ <patterns worth persisting: repeated failure modes, user preferences, project conventions>
67
+ ```
68
+
69
+ ## Complexity Assessment
70
+
71
+ Always assess task complexity before deciding delegation strategy:
72
+
73
+ | Level | Criteria | Strategy |
74
+ |-------|----------|----------|
75
+ | **Easy** | 1-2 files, well-known pattern, single atomic change | Handle directly. No subagent needed. |
76
+ | **Medium** | 3-10 files, new feature, needs exploration/research | 2-5 subagents (sequential or parallel fan-out). Checkpoint between each. |
77
+ | **Hard** | 10+ files, cross-cutting change, requires planning + execution + review | Sequential multi-agent: `planner` → executor → `code-reviewer` → `security-reviewer`. Checkpoint between each. |
78
+ | **Very Large** | 50+ files, massive refactor, audit of entire codebase | Fan-out: split into chunks, assign to parallel subagents, consolidate results. |
79
+
80
+ ### Fan-Out Pattern
81
+
82
+ Break the work into N independent chunks. Assign each to a separate subagent in parallel (separate `task` calls). Then assign a consolidation agent to merge results.
83
+
84
+ ```
85
+ Example: Review 100 files
86
+ ├── Subagent A: review files 1-33
87
+ ├── Subagent B: review files 34-66
88
+ ├── Subagent C: review files 67-100
89
+ └── Caller: consolidate findings into single report
90
+ ```
91
+
92
+ ## Agent Permissions
93
+
94
+ Every agent has a permission tier. Respect these boundaries.
95
+
96
+ ### Tier 1 — Read-Only (planner, architect, code-reviewer, security-reviewer, explore, reviewers)
97
+ | Action | Status |
98
+ |--------|--------|
99
+ | Read files | ✅ Allow |
100
+ | Search/grep | ✅ Allow |
101
+ | Write/edit files | ❌ Deny |
102
+ | Execute bash | ❌ Deny |
103
+ | Delegate to other agents | ✅ Only to same-tier or OpenHermes |
104
+
105
+ ### Tier 2 — Builder (build-error-resolver, all build-*, doc-updater, refactor-cleaner, tdd-guide)
106
+ | Action | Status |
107
+ |--------|--------|
108
+ | Read files | ✅ Allow |
109
+ | Search/grep | ✅ Allow |
110
+ | Write/edit files | ✅ Allow (scope-limited) |
111
+ | Execute bash | ✅ Allow |
112
+ | Delegate to other agents | ✅ When outside scope |
113
+
114
+ ### Tier 3 — Full Access (OpenHermes primary, loop-operator, e2e-runner)
115
+ | Action | Status |
116
+ |--------|--------|
117
+ | Read files | ✅ Allow |
118
+ | Write/edit files | ✅ Allow |
119
+ | Execute bash | ✅ Allow |
120
+ | Delegate to any agent | ✅ Allow |
121
+
122
+ ### Hard Rules
123
+
124
+ 1. **Review agents must NEVER edit code directly.** If a review finds issues, delegate to a builder to fix.
125
+ 2. **Planning agents must NEVER implement.** Produce the plan, hand off execution.
126
+ 3. **Builder agents must NOT review their own work.** After implementing, delegate review to `code-reviewer`.
127
+ 4. **Security-reviewer only reports, never patches.** Delegate fixes to `OpenHermes` or a builder.
128
+ 5. **Explore only reads, never writes.** Use for investigation, then hand off to a builder for changes.
129
+
130
+ ## Phase Protocol
131
+
132
+ Every non-trivial task follows phases. Checkpoint between each phase.
133
+
134
+ ```
135
+ Phase 1: Understand
136
+ - Read task, search memory for related context
137
+ - Gather files, check constraints
138
+ → Output: task analysis + file list
139
+
140
+ Phase 2: Plan
141
+ - Decompose into subtasks
142
+ - Assign each to best agent
143
+ - Set checkpoints per subtask
144
+ → Output: execution plan
145
+
146
+ Phase 3: Execute
147
+ - One subtask at a time
148
+ - Delegate to builders when implementation needed
149
+ - Verify each subtask before next
150
+ → Output: changes + verification
151
+
152
+ Phase 4: Review
153
+ - Delegate review to code-reviewer / security-reviewer
154
+ - Check against plan requirements
155
+ → Output: review report + verdict
156
+
157
+ Phase 5: Learn
158
+ - Check for repeated patterns (see Learning Triggers)
159
+ - Save useful info to memory
160
+ - Save checkpoint
161
+ → Output: learning receipt
162
+
163
+ Phase 6: Continue or Handoff
164
+ - If more work remains → loop back to Phase 2/3
165
+ - If done → return structured result
166
+ → Output: final handoff result
167
+ ```
168
+
169
+ ### Checkpoint Before Every Handoff
170
+
171
+ Before delegating to another agent, always save a checkpoint:
172
+
173
+ ```
174
+ ohc_save(
175
+ class: "checkpoint",
176
+ id: "chk_{task-id}_{phase}",
177
+ data: JSON.stringify({
178
+ summary: "Pre-handoff: <phase> -> <next-agent>",
179
+ mission: "<what we're building>",
180
+ current_state: "<what's done so far>",
181
+ next_actions: ["<what the next agent needs to do>"],
182
+ blockers: ["<any issues>"],
183
+ risk_notes: ["<risks>"]
184
+ })
185
+ )
186
+ ```
187
+
188
+ ## Agent Selection Guide
189
+
190
+ When you need to delegate, pick by task type:
191
+
192
+ | Task type | Best agent | Second choice |
193
+ |-----------|-----------|---------------|
194
+ | System architecture design | `architect` | `planner` |
195
+ | Feature/refactor planning | `planner` | `OpenHermes` |
196
+ | Multi-file codebase search | `explore` | `general` |
197
+ | Build/type error fix | `build-error-resolver` | language-specific `build-*` |
198
+ | Code quality review | `code-reviewer` | language-specific `review-*` |
199
+ | Security audit | `security-reviewer` | `code-reviewer` |
200
+ | E2E test writing/running | `e2e-runner` | `tdd-guide` |
201
+ | TDD workflow | `tdd-guide` | `OpenHermes` |
202
+ | Doc/codemap update | `doc-updater` | `OpenHermes` |
203
+ | Dead code cleanup | `refactor-cleaner` | language-specific `build-*` |
204
+ | Database review | `review-database` | `security-reviewer` |
205
+ | Language-specific build fix | `build-{lang}` | `build-error-resolver` |
206
+ | Language-specific review | `review-{lang}` | `code-reviewer` |
207
+ | Managed autonomous loop | `loop-operator` | `OpenHermes` |
208
+ | Doc lookup (MCP) | `docs-lookup` | `explore` |
209
+ | Harness audit | `harness-optimizer` | `security-reviewer` |
210
+
211
+ ### Language Mapping
212
+
213
+ Check project root for these markers to route to language-specific agents:
214
+
215
+ | Marker file | Builder agent | Reviewer agent |
216
+ |-------------|--------------|----------------|
217
+ | `Cargo.toml` | `build-rust` | `review-rust` |
218
+ | `go.mod` | `build-go` | `review-go` |
219
+ | `pom.xml` / `build.gradle` | `build-java` | `review-java` |
220
+ | `build.gradle.kts` | `build-kotlin` | `review-kotlin` |
221
+ | `CMakeLists.txt` / `compile_commands.json` | `build-cpp` | `review-cpp` |
222
+ | `pyproject.toml` / `setup.py` | `build-error-resolver` | `review-python` |
223
+ | None of the above | `build-error-resolver` | `code-reviewer` |
224
+
225
+ ## Learning Triggers
226
+
227
+ Detect repeated patterns and persist them to memory proactively.
228
+
229
+ | Trigger | Action | Memory class |
230
+ |---------|--------|-------------|
231
+ | Same bash command fails 3+ times | Search memory for prior fix. If found, apply. If not found, save the eventual fix. | `mistake` |
232
+ | User repeats same instruction 2+ times | Save as preference/constraint. | `constraint` |
233
+ | User corrects the same thing 2+ times | Save as project convention. | `decision` |
234
+ | A workflow is repeated 3+ times | Save as project convention (e.g. "this project always requires: bump version → npm pack → git commit/push"). | `decision` |
235
+ | A build command is discovered for a new project | Save as project convention. | `constraint` |
236
+ | An agent is repeatedly incorrectly chosen for a task type | Update routing preference. | `instinct` |
237
+
238
+ ### How to Save Learning
239
+
240
+ ```
241
+ ohc_save(
242
+ class: "<appropriate-class>",
243
+ id: "<project-or-feature-related-id>",
244
+ data: JSON.stringify({
245
+ summary: "<what was learned>",
246
+ scope: "project", // or "global" if universally applicable
247
+ project: "<project-name>",
248
+ tags: ["<relevant-tags>"],
249
+ <class-specific-fields>
250
+ })
251
+ )
252
+ ```
253
+
254
+ ### Learning Check (End of Every SubTask)
255
+
256
+ After each agent returns, check:
257
+ 1. Did the subagent include a `Learning` section? If yes, evaluate and persist.
258
+ 2. Did the same type of failure happen before? Check `ohc_search` for similar mistakes.
259
+ 3. Did we learn anything about this project that will help next time?
260
+
261
+ ## How This Stays Simple
262
+
263
+ 1. **No new tools or middleware.** The existing `task` tool is the handoff mechanism. The format is just structured text.
264
+ 2. **No new plugins.** Rules are documents, not code. The system survives regen of `node_modules`.
265
+ 3. **Standardized prompt sections.** Each agent prompt follows the same pattern — Identity, Role, Permissions, Handoff, Workflow, Output.
266
+ 4. **Self-correcting.** Repeated failures trigger memory persistence, which feeds back into better routing.
267
+ 5. **Additive.** New subagents just need the same standardized prompt sections. No other wiring required.
@@ -15,13 +15,13 @@
15
15
 
16
16
  ## Capacity & Dedup
17
17
 
18
- - **80% cap**: Consolidate before adding more. Use `add_memory` with `supersedes` to merge related entries and preserve audit trail.
19
- - **Dedup**: `search_memory` before writing. If match exists, update existing. Require >=2 confirming instances for `instinct`, >=1 explicit statement for `decision`.
18
+ - **80% cap**: Consolidate before adding more. Use `ohc_save` with `supersedes` to merge related entries and preserve audit trail.
19
+ - **Dedup**: `ohc_search` before writing. If match exists, update existing. Require >=2 confirming instances for `instinct`, >=1 explicit statement for `decision`.
20
20
 
21
21
  ## Operations
22
22
 
23
- - Write with `add_memory(class="instinct"|"decision", ...)` during sessions, not only at end.
24
- - Load active records at session start: `list_memory(class="instinct", limit=5)` and `list_memory(class="decision", limit=5)`.
23
+ - Write with `ohc_save(class="instinct"|"decision", ...)` during sessions, not only at end.
24
+ - Load active records at session start: `ohc_list(class="instinct", limit=5)` and `ohc_list(class="decision", limit=5)`.
25
25
 
26
26
  ## Security
27
27
 
@@ -44,7 +44,7 @@ A conflict exists when two active items at the same precedence level prescribe i
44
44
 
45
45
  ## Constitution Immutability
46
46
 
47
- The 10 principles in `openhermes\constitution\soul.md` are immutable without:
47
+ The 11 principles in `openhermes\constitution\soul.md` are immutable without:
48
48
  1. Explicit user approval
49
49
  2. A full architecture handoff document
50
50
  3. Verification that the change does not break openhermes integrity
@@ -56,10 +56,10 @@ Self-improving agents rot by saving too much. These rules prevent memory spam:
56
56
 
57
57
  ## Retrieval Implementation
58
58
 
59
- 1. Start with `latest_memory(class)` for the most likely relevant class.
60
- 2. Then use `search_memory(query, classes, project, limit)` with narrow, task-shaped filters.
61
- 3. Use `fetch_memory(class, id)` only for specific records surfaced by step 1 or 2.
62
- 4. Use `list_memory(class, limit)` only when you need a small class sample or a bounded discovery pass.
59
+ 1. Start with `ohc_latest(class)` for the most likely relevant class.
60
+ 2. Then use `ohc_search(query, classes, project, limit)` with narrow, task-shaped filters.
61
+ 3. Use `ohc_get(class, id)` only for specific records surfaced by step 1 or 2.
62
+ 4. Use `ohc_list(class, limit)` only when you need a small class sample or a bounded discovery pass.
63
63
  5. Never read full memory index files for routine task work.
64
64
  6. Read whole indexes only when the task is explicitly about auditing, repairing, or regenerating the index itself.
65
65
  7. For project-level file search with grep/glob patterns: delegate to `explore` subagent.
@@ -69,7 +69,7 @@ Self-improving agents rot by saving too much. These rules prevent memory spam:
69
69
 
70
70
  **NEVER start broad. Always needle-precision first.**
71
71
 
72
- 1. Start with the single most targeted tool for the question: `grep` for a pattern, `glob` for a filename, `latest_memory` for a memory class, `search_memory` with narrow filters.
72
+ 1. Start with the single most targeted tool for the question: `grep` for a pattern, `glob` for a filename, `ohc_latest` for a memory class, `ohc_search` with narrow filters.
73
73
  2. Read the minimum number of files to answer the question — often 1-3, not 16+.
74
74
  3. Stop immediately when you have enough signal to answer.
75
75
  4. Only broaden when every precise method is exhausted and the answer is still missing.
@@ -100,7 +100,7 @@ function detectStateDrift(compressedBuffer) {
100
100
 
101
101
  ## Enforcement Points
102
102
 
103
- ### Memory Write (add_memory)
103
+ ### Memory Write (ohc_save)
104
104
  ```javascript
105
105
  // In openhermes-memory MCP server
106
106
  function putMemoryObject(obj) {