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.
- package/README.md +125 -206
- package/autorecall.mjs +79 -12
- package/bootstrap.mjs +122 -25
- package/curator.mjs +4 -40
- package/harness/commands/harness-audit.md +1 -1
- package/harness/commands/learn.md +2 -2
- package/harness/commands/memory-search.md +2 -2
- package/harness/constitution/soul.md +16 -4
- package/harness/instructions/RUNTIME.md +6 -3
- package/harness/prompts/architect.txt +14 -0
- package/harness/prompts/build-cpp.md +15 -1
- package/harness/prompts/build-error-resolver.md +15 -9
- package/harness/prompts/build-go.md +14 -0
- package/harness/prompts/build-java.md +15 -1
- package/harness/prompts/build-kotlin.md +15 -1
- package/harness/prompts/build-rust.md +14 -0
- package/harness/prompts/code-reviewer.md +15 -9
- package/harness/prompts/doc-updater.md +13 -0
- package/harness/prompts/docs-lookup.md +11 -0
- package/harness/prompts/e2e-runner.txt +12 -0
- package/harness/prompts/explore.md +16 -4
- package/harness/prompts/harness-optimizer.md +12 -0
- package/harness/prompts/loop-operator.md +11 -0
- package/harness/prompts/planner.md +15 -9
- package/harness/prompts/refactor-cleaner.md +14 -0
- package/harness/prompts/review-cpp.md +14 -1
- package/harness/prompts/review-database.md +13 -0
- package/harness/prompts/review-go.md +13 -0
- package/harness/prompts/review-java.md +14 -1
- package/harness/prompts/review-kotlin.md +13 -0
- package/harness/prompts/review-python.md +14 -1
- package/harness/prompts/review-rust.md +13 -0
- package/harness/prompts/security-reviewer.md +15 -9
- package/harness/prompts/tdd-guide.md +14 -0
- package/harness/rules/audit.md +2 -2
- package/harness/rules/delegation.md +0 -2
- package/harness/rules/handoff.md +267 -0
- package/harness/rules/memory-management.md +4 -4
- package/harness/rules/precedence.md +1 -1
- package/harness/rules/retrieval.md +5 -5
- package/harness/rules/runtime-guards.md +1 -1
- package/harness/rules/self-heal.md +1 -1
- package/harness/rules/session-start.md +5 -5
- package/harness/rules/skills-management.md +2 -2
- package/harness/rules/verification.md +4 -4
- package/index.mjs +6 -2
- package/lib/ambient-memory.mjs +167 -0
- package/lib/handoff.mjs +176 -0
- package/lib/hardening.mjs +13 -8
- package/lib/memory-tools-plugin.mjs +107 -54
- package/lib/ohc/block-sync.mjs +69 -0
- package/lib/ohc/compress/search.mjs +152 -0
- package/lib/ohc/compress/state.mjs +76 -0
- package/lib/ohc/config.mjs +172 -16
- package/lib/ohc/message-ids.mjs +168 -0
- package/lib/ohc/notify.mjs +150 -0
- package/lib/ohc/protected-patterns.mjs +54 -0
- package/lib/ohc/prune-apply.mjs +134 -0
- package/lib/ohc/pruner.mjs +406 -55
- package/lib/ohc/reaper.mjs +12 -3
- package/lib/ohc/state.mjs +246 -15
- package/lib/ohc/strategies/deduplication.mjs +72 -0
- package/lib/ohc/strategies/index.mjs +2 -0
- package/lib/ohc/strategies/purge-errors.mjs +43 -0
- package/lib/ohc/token-utils.mjs +26 -0
- package/lib/ohc/updater.mjs +36 -13
- package/lib/paths.mjs +0 -3
- package/lib/search.mjs +48 -0
- package/package.json +1 -1
- package/schemas/audit.schema.json +22 -1
- package/schemas/backlog.schema.json +23 -2
- package/schemas/checkpoint.schema.json +23 -2
- package/schemas/constraint.schema.json +23 -2
- package/schemas/decision.schema.json +23 -2
- package/schemas/instinct.schema.json +23 -2
- package/schemas/mistake.schema.json +23 -2
- package/schemas/verification_receipt.schema.json +23 -2
- package/skill-builder.mjs +12 -23
package/bootstrap.mjs
CHANGED
|
@@ -3,18 +3,119 @@ import fs from "node:fs"
|
|
|
3
3
|
import { fileURLToPath } from "node:url"
|
|
4
4
|
|
|
5
5
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
6
|
-
const
|
|
6
|
+
const REQUIRED_HARNESS_FILES = [
|
|
7
|
+
["constitution", "soul.md"],
|
|
8
|
+
["instructions", "RUNTIME.md"],
|
|
9
|
+
["commands", "doctor.md"],
|
|
10
|
+
["prompts", "architect.txt"],
|
|
11
|
+
["rules", "precedence.md"],
|
|
12
|
+
["skills", "coding-standards", "SKILL.md"],
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
function ancestorDirs(start, limit = 6) {
|
|
16
|
+
const dirs = []
|
|
17
|
+
let current = path.resolve(start)
|
|
18
|
+
for (let i = 0; i < limit; i++) {
|
|
19
|
+
dirs.push(current)
|
|
20
|
+
const parent = path.dirname(current)
|
|
21
|
+
if (parent === current) break
|
|
22
|
+
current = parent
|
|
23
|
+
}
|
|
24
|
+
return dirs
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function buildHarnessCandidates(currentDir, execPath, cwd) {
|
|
28
|
+
const roots = [path.resolve(currentDir, "harness")]
|
|
29
|
+
const seen = new Set(roots)
|
|
30
|
+
|
|
31
|
+
const anchors = [path.dirname(execPath), path.dirname(path.dirname(execPath)), cwd]
|
|
32
|
+
for (const anchor of anchors) {
|
|
33
|
+
for (const dir of ancestorDirs(anchor)) {
|
|
34
|
+
for (const root of [
|
|
35
|
+
path.join(dir, "harness"),
|
|
36
|
+
path.join(dir, "node_modules", "openhermes", "harness"),
|
|
37
|
+
path.join(dir, "bin", "node_modules", "openhermes", "harness"),
|
|
38
|
+
]) {
|
|
39
|
+
const normalized = path.normalize(root)
|
|
40
|
+
if (seen.has(normalized)) continue
|
|
41
|
+
seen.add(normalized)
|
|
42
|
+
roots.push(normalized)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return roots
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function hasRequiredHarnessFiles(root) {
|
|
51
|
+
return REQUIRED_HARNESS_FILES.every(parts => fs.existsSync(path.join(root, ...parts)))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function resolveHarnessRoot({
|
|
55
|
+
currentDir = __dirname,
|
|
56
|
+
execPath = process.execPath,
|
|
57
|
+
cwd = process.cwd(),
|
|
58
|
+
candidateRoots,
|
|
59
|
+
} = {}) {
|
|
60
|
+
const roots = candidateRoots ?? buildHarnessCandidates(currentDir, execPath, cwd)
|
|
61
|
+
for (const root of roots) {
|
|
62
|
+
if (hasRequiredHarnessFiles(root)) return root
|
|
63
|
+
}
|
|
64
|
+
return path.resolve(currentDir, "harness")
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const HARNESS_DIR = resolveHarnessRoot()
|
|
7
68
|
const RULES_DIR = path.join(HARNESS_DIR, "rules")
|
|
8
69
|
const SKILLS_DIR = path.join(HARNESS_DIR, "skills")
|
|
9
70
|
const CONSTITUTION_FILE = path.join(HARNESS_DIR, "constitution", "soul.md")
|
|
10
71
|
const RUNTIME_FILE = path.join(HARNESS_DIR, "instructions", "RUNTIME.md")
|
|
11
72
|
|
|
12
73
|
|
|
13
|
-
|
|
74
|
+
function scanDirNames(dir) {
|
|
75
|
+
try { return fs.readdirSync(dir).filter(f => f.endsWith(".md")).map(f => f.replace(/\.md$/, "")).sort() }
|
|
76
|
+
catch { return [] }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function scanPromptNames(dir) {
|
|
80
|
+
try { return fs.readdirSync(dir).filter(f => f.endsWith('.md') || f.endsWith('.txt')).map(f => path.basename(f, path.extname(f))).sort() }
|
|
81
|
+
catch { return [] }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function scanSkillDirs(dir) {
|
|
85
|
+
try { return fs.readdirSync(dir).filter(f => fs.statSync(path.join(dir, f)).isDirectory()).sort() }
|
|
86
|
+
catch { return [] }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function scanSchemaNames(dir) {
|
|
90
|
+
try { return fs.readdirSync(dir).filter(f => f.endsWith(".schema.json")).map(f => f.replace(/\.schema\.json$/, "")).filter(f => f !== "loop-state").sort() }
|
|
91
|
+
catch { return [] }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function buildCapabilityMap(hDir) {
|
|
95
|
+
const cmds = scanDirNames(path.join(hDir, "commands"))
|
|
96
|
+
if (!cmds.includes("update-me")) cmds.push("update-me")
|
|
97
|
+
cmds.sort()
|
|
98
|
+
|
|
99
|
+
const agents = scanPromptNames(path.join(hDir, "prompts"))
|
|
100
|
+
const skills = scanSkillDirs(path.join(hDir, "skills"))
|
|
101
|
+
const schemas = scanSchemaNames(path.join(__dirname, "schemas"))
|
|
102
|
+
|
|
103
|
+
return [
|
|
104
|
+
"## Capability Map",
|
|
105
|
+
"",
|
|
106
|
+
`Commands (${cmds.length}): /${cmds.join(" /")}`,
|
|
107
|
+
`Subagents (${agents.length}): ${agents.join(" ")}`,
|
|
108
|
+
`Skills (${skills.length}): ${skills.join(" ")}`,
|
|
109
|
+
`Memory (${schemas.length}): ${schemas.join(" ")}`,
|
|
110
|
+
"",
|
|
111
|
+
`For problem → specialist routing see Delegation below. Skills via \`skill\` tool. Memory via \`ohc_save\` etc.`,
|
|
112
|
+
].join("\n")
|
|
113
|
+
}
|
|
14
114
|
|
|
15
115
|
function buildBootstrapContent() {
|
|
16
116
|
const constitution = fs.readFileSync(CONSTITUTION_FILE, "utf8")
|
|
17
117
|
const runtime = fs.readFileSync(RUNTIME_FILE, "utf8")
|
|
118
|
+
const capMap = buildCapabilityMap(HARNESS_DIR)
|
|
18
119
|
|
|
19
120
|
const router = `## AGENTS.md
|
|
20
121
|
|
|
@@ -22,28 +123,13 @@ OpenHermes thin constitutional router. Full harness → \`${HARNESS_DIR}\\\`.
|
|
|
22
123
|
|
|
23
124
|
## Soul
|
|
24
125
|
|
|
25
|
-
Pragmatic. Concise. Task-oriented. Subagent-first. Inspect, then act.
|
|
126
|
+
Pragmatic. Concise. Task-oriented. Subagent-first. Inspect, then act. Scope to the problem. Verify, don't claim. Receipts over vibes. Recover by narrowing, not posturing. Skeptical — demand proof. Precision-first search: needle then broad, never reverse.
|
|
26
127
|
|
|
27
128
|
## Safety
|
|
28
129
|
|
|
29
130
|
Snapshot before mutation. Never delete unrelated files. Never assume \`%USERPROFILE%\\\\.config\\\\opencode\` is a git repo. Verify or roll back. **NEVER delete \`auth.json\`** (\`%USERPROFILE%\\\\.local\\\\share\\\\opencode\\\\auth.json\`).
|
|
30
131
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
| Category | Items |
|
|
34
|
-
|----------|-------|
|
|
35
|
-
| **Native tools** | \`read\`, \`write\`, \`edit\`, \`glob\`, \`grep\`, \`bash\`, \`task\`, \`webfetch\`, \`skill\`, \`todowrite\`, \`todoread\` |
|
|
36
|
-
| **In-process tools** | \`add_memory\`, \`fetch_memory\`, \`list_memory\`, \`latest_memory\`, \`search_memory\`, \`archive_memory\` |
|
|
37
|
-
| **Memory recall cache** | \`openhermes/memory/recall/cache.json\` — read on session start, no MCP round-trip |
|
|
38
|
-
| **Subagents** | \`explore\` (read-only), \`general\` (multi-step), \`architect\`, \`planner\`, \`build-error-resolver\`, \`code-reviewer\`, \`security-reviewer\`, \`e2e-runner\`, \`docs-lookup\`, \`doc-updater\`, \`refactor-cleaner\`, \`loop-operator\`, \`harness-optimizer\`, \`tdd-guide\`, \`review-go\`, \`build-go\`, \`review-database\`, \`review-cpp\`, \`build-cpp\`, \`review-java\`, \`build-java\`, \`review-kotlin\`, \`build-kotlin\`, \`review-python\`, \`review-rust\`, \`build-rust\` |
|
|
39
|
-
| **Plugins** | \`curator\` (checkpoints, mistakes, audit, compaction), \`autorecall\` (recall cache on \`session.created\`), \`skill-builder\` (complex session detection) |
|
|
40
|
-
| **Slash commands** | <!-- COMMANDS:START --> \`/build-fix\`, \`/checkpoint\`, \`/code-review\`, \`/doctor\`, \`/eval\`, \`/go-build\`, \`/go-review\`, \`/harness-audit\`, \`/learn\`, \`/loop-start\`, \`/loop-status\`, \`/memory-search\`, \`/model-route\`, \`/ohc\`, \`/orchestrate\`, \`/plan\`, \`/quality-gate\`, \`/refactor-clean\`, \`/rust-build\`, \`/rust-review\`, \`/security\`, \`/setup-pm\`, \`/skill-create\`, \`/test-coverage\`, \`/update-codemaps\`, \`/update-docs\`, \`/update-me\`, \`/verify\`<!-- COMMANDS:END --> |
|
|
41
|
-
|
|
42
|
-
## Skills (available via \`skill\` tool)
|
|
43
|
-
|
|
44
|
-
\`agent-browser\` \`batch-files\` \`caveman\` \`create-architectural-decision-record\` \`create-readme\` \`design-md\` \`diagnose\` \`docker-expert\` \`enhance-prompt\` \`find-skills\` \`grill-me\` \`grill-with-docs\` \`improve-codebase-architecture\` \`opencode-doctor\` \`opencode-ecc-lifecycle\` \`opencode-docs\` \`opencode-expert\` \`opencode-models\` \`opencode-recall\` \`react:components\` \`setup-matt-pocock-skills\` \`skill-creator\` \`squeez-expert\` \`stitch-design\` \`stitch-loop\` \`tailored-resume-generator\` \`taste-design\` \`tdd\` \`to-issues\` \`to-prd\` \`triage\` \`typescript-expert\` \`write-a-skill\` \`write-coding-standards-from-file\` \`zoom-out\`
|
|
45
|
-
|
|
46
|
-
**OpenHermes-specific skills (discovered from harness):** \`api-design\` \`backend-patterns\` \`coding-standards\` \`e2e-testing\` \`frontend-patterns\` \`frontend-slides\` \`security-review\` \`strategic-compact\` \`tdd-workflow\` \`verification-loop\`
|
|
132
|
+
${capMap}
|
|
47
133
|
|
|
48
134
|
## Delegation (Mandatory)
|
|
49
135
|
|
|
@@ -75,15 +161,25 @@ Main context = coordination + verification only. Substantive work → subagent.
|
|
|
75
161
|
| Rust build fix | \`build-rust\` |
|
|
76
162
|
| Any non-trivial multi-step | appropriate specialist |
|
|
77
163
|
|
|
78
|
-
Never delegate trivial single-step ops. Subagent returns diff + summary + verification; inspect return only. Full ref: \`${RULES_DIR}
|
|
164
|
+
Never delegate trivial single-step ops. Subagent returns diff + summary + verification; inspect return only. Full ref: \`${RULES_DIR}\\\delegation.md\`.
|
|
165
|
+
|
|
166
|
+
## Handoff Protocol
|
|
167
|
+
|
|
168
|
+
Every agent knows its role, permissions, and when to delegate. Before delegating, assess task complexity (easy → direct, medium → single subagent, hard → sequential multi-agent, very-large → fan-out). Use structured handoff format documented in \`${RULES_DIR}\\\handoff.md\`.
|
|
169
|
+
|
|
170
|
+
- **Act**: Task matches your role and permissions → do it directly
|
|
171
|
+
- **Delegate**: Task outside your role → pass to correct agent via \`task\` tool
|
|
172
|
+
- **Escalate**: Review/planning agents must NEVER edit code. Delegate to builders.
|
|
173
|
+
- **Learn**: After each task, check for repeated patterns. Persist to memory via \`ohc_save\`.
|
|
174
|
+
- **Checkpoint**: Before every handoff, save a checkpoint.
|
|
79
175
|
|
|
80
176
|
## Memory — Gated & Precision-First
|
|
81
177
|
|
|
82
|
-
- **Start**: Read recall cache first. If stale/missing → \`
|
|
83
|
-
- **Before work**: Narrow \`
|
|
178
|
+
- **Start**: Read recall cache first. If stale/missing → \`ohc_latest\` for relevant classes.
|
|
179
|
+
- **Before work**: Narrow \`ohc_search\` by class, scope, keywords. Never read full indexes.
|
|
84
180
|
- **Before close**: Query same-type mistakes (7 days). Match → \`code-reviewer\` or \`security-reviewer\`.
|
|
85
|
-
- **On failure**: \`
|
|
86
|
-
- **Precision ladder**: \`
|
|
181
|
+
- **On failure**: \`ohc_search\` for similar incidents. Search memory before asking user.
|
|
182
|
+
- **Precision ladder**: \`ohc_latest\` → \`ohc_search\` → \`ohc_get\` → \`ohc_list\` (last resort). Full index reads only for explicit audit/repair tasks.
|
|
87
183
|
- **Anti-spam**: No obvious facts, no one-off prefs, no temp state, no low-risk mistakes. Supersede, don't duplicate. Full rules: \`${RULES_DIR}\\\\retrieval.md\`, \`${RULES_DIR}\\\\memory-management.md\`.
|
|
88
184
|
|
|
89
185
|
## Self-Edit Authority
|
|
@@ -103,7 +199,7 @@ Full tiers: \`${RULES_DIR}\\\\self-heal.md\`.
|
|
|
103
199
|
- Checkpoint on meaningful boundaries. Compress closed segments immediately.
|
|
104
200
|
- After subagent return: verify → compress that block.
|
|
105
201
|
- Compress proactively.
|
|
106
|
-
- Skill candidates → \`/learn\` only if repeated pattern + \`
|
|
202
|
+
- Skill candidates → \`/learn\` only if repeated pattern + \`ohc_search\` confirms no dup. See \`${RULES_DIR}\\\\skills-management.md\`.
|
|
107
203
|
- Audit triggers: openhermes/config change, repeated failures, session start when last audit >7 days. See \`${RULES_DIR}\\\\audit.md\`.
|
|
108
204
|
|
|
109
205
|
## Escalation
|
|
@@ -132,6 +228,7 @@ function getOwnVersion() {
|
|
|
132
228
|
}
|
|
133
229
|
|
|
134
230
|
export const BootstrapPlugin = async ({ client, directory }) => {
|
|
231
|
+
let _bootstrapCache
|
|
135
232
|
|
|
136
233
|
const getContent = () => {
|
|
137
234
|
if (_bootstrapCache !== undefined) return _bootstrapCache
|
package/curator.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import path from "node:path"
|
|
2
2
|
import fs from "node:fs"
|
|
3
|
-
import os from "node:os"
|
|
4
3
|
import { findUnsupportedSchemaKeywords, validateSchema } from "./lib/schema-validator.mjs"
|
|
5
|
-
import { atomicWriteJson,
|
|
4
|
+
import { atomicWriteJson, buildEnvironmentFingerprint, fingerprintFile, readJson, redactSensitiveText, sanitizeRecord, truncateText } from "./lib/hardening.mjs"
|
|
6
5
|
import { fileURLToPath } from "node:url"
|
|
7
6
|
import { dirname } from "node:path"
|
|
8
|
-
import { getDataRoot, getMemoryRoot
|
|
7
|
+
import { getDataRoot, getMemoryRoot } from "./lib/paths.mjs"
|
|
9
8
|
|
|
10
9
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
11
10
|
|
|
@@ -20,16 +19,6 @@ function curatorLog(message) {
|
|
|
20
19
|
process.stderr.write(`${message}\n`)
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
function buildEnvironmentFingerprint(root, directory, project) {
|
|
24
|
-
return fingerprintEnvironment({
|
|
25
|
-
cwd: directory,
|
|
26
|
-
harnessRoot: root,
|
|
27
|
-
projectRoot: directory,
|
|
28
|
-
project: project?.name || path.basename(directory),
|
|
29
|
-
sessionId: project?.session_id || null,
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
|
|
33
22
|
function isMeaningfulText(value) {
|
|
34
23
|
return typeof value === "string" && value.trim().length > 0 && !/^(n\/a|none|tbd|placeholder|pending|session in progress|no active checkpoint content)$/i.test(value.trim())
|
|
35
24
|
}
|
|
@@ -83,7 +72,7 @@ function validateRecordAgainstSchema(record) {
|
|
|
83
72
|
if (!schema) {
|
|
84
73
|
curatorLog(`[curator] no schema found for class "${record.class}", fallback check`)
|
|
85
74
|
const required = record.class === "checkpoint"
|
|
86
|
-
? ["id", "class", "summary", "mission", "current_state", "next_actions", "provenance", "created_at", "status"]
|
|
75
|
+
? ["id", "class", "summary", "mission", "current_state", "next_actions", "blockers", "risk_notes", "provenance", "created_at", "status"]
|
|
87
76
|
: ["id", "class", "summary", "provenance", "created_at", "status"]
|
|
88
77
|
const missing = required.filter(r => !record[r] && record[r] !== null)
|
|
89
78
|
if (missing.length) {
|
|
@@ -392,32 +381,7 @@ async function handlePermissionReplied(directory, project, event) {
|
|
|
392
381
|
export const CuratorPlugin = async ({ project, directory }) => {
|
|
393
382
|
return {
|
|
394
383
|
event: async ({ event }) => {
|
|
395
|
-
|
|
396
|
-
const SENTINEL = path.join(getDataRoot(), ".migrated-from-v1")
|
|
397
|
-
if (!fs.existsSync(SENTINEL)) {
|
|
398
|
-
const oldMemory = path.join(OLD_BASE, "memory")
|
|
399
|
-
const oldCache = path.join(oldMemory, "recall")
|
|
400
|
-
if (fs.existsSync(oldMemory)) {
|
|
401
|
-
fs.cpSync(oldMemory, getMemoryRoot(), { recursive: true })
|
|
402
|
-
if (fs.existsSync(oldCache)) {
|
|
403
|
-
fs.mkdirSync(getRecallRoot(), { recursive: true })
|
|
404
|
-
const files = fs.readdirSync(oldCache).filter(f => f.endsWith(".json"))
|
|
405
|
-
for (const f of files) fs.cpSync(path.join(oldCache, f), path.join(getRecallRoot(), f))
|
|
406
|
-
}
|
|
407
|
-
fs.rmSync(oldMemory, { recursive: true, force: true })
|
|
408
|
-
}
|
|
409
|
-
const oldRuntime = path.join(OLD_BASE, "runtime")
|
|
410
|
-
if (fs.existsSync(oldRuntime)) {
|
|
411
|
-
fs.cpSync(oldRuntime, getRuntimeRoot(), { recursive: true })
|
|
412
|
-
fs.rmSync(oldRuntime, { recursive: true, force: true })
|
|
413
|
-
}
|
|
414
|
-
const oldArchive = path.join(OLD_BASE, "archive")
|
|
415
|
-
if (fs.existsSync(oldArchive)) {
|
|
416
|
-
fs.rmSync(oldArchive, { recursive: true, force: true })
|
|
417
|
-
}
|
|
418
|
-
fs.mkdirSync(path.dirname(SENTINEL), { recursive: true })
|
|
419
|
-
fs.writeFileSync(SENTINEL, new Date().toISOString(), "utf8")
|
|
420
|
-
}
|
|
384
|
+
// A1: v1 migration owned by autorecall.mjs — removed to avoid race
|
|
421
385
|
if (event.type === "session.created") {
|
|
422
386
|
lastCheckpoint.ts = 0
|
|
423
387
|
writtenThisSession.length = 0
|
|
@@ -42,7 +42,7 @@ Evaluate each category by inspecting the harness files directly. No external scr
|
|
|
42
42
|
- [ ] checkpoint.md enables state tracking
|
|
43
43
|
|
|
44
44
|
### 4. Memory Persistence (0-10)
|
|
45
|
-
- [ ] Memory tools documented (
|
|
45
|
+
- [ ] Memory tools documented (ohc_save/ohc_get/ohc_list/ohc_latest/ohc_search)
|
|
46
46
|
- [ ] Checkpoint command references memory persistence
|
|
47
47
|
- [ ] Mistake/audit logging workflow documented
|
|
48
48
|
- [ ] Recall cache strategy defined
|
|
@@ -11,7 +11,7 @@ Create a new reusable skill from recent work patterns. $ARGUMENTS
|
|
|
11
11
|
## Your Task
|
|
12
12
|
|
|
13
13
|
1. **Search backlog** for pending skill candidates:
|
|
14
|
-
- Use `
|
|
14
|
+
- Use `ohc_search` with query="skill-candidate" classes=["backlog"]
|
|
15
15
|
- If $ARGUMENTS is non-empty, narrow search to that topic
|
|
16
16
|
2. **Analyze the candidate** — what pattern did the session reveal?
|
|
17
17
|
3. **Create the skill**:
|
|
@@ -19,7 +19,7 @@ Create a new reusable skill from recent work patterns. $ARGUMENTS
|
|
|
19
19
|
- Follow its instructions to create a new SKILL.md
|
|
20
20
|
- Target: `%USERPROFILE%\.config\opencode\skills\<name>\SKILL.md`
|
|
21
21
|
- Naming: lowercase, hyphenated, descriptive
|
|
22
|
-
4. **Close the backlog entry**: `
|
|
22
|
+
4. **Close the backlog entry**: `ohc_save(class="backlog", id="<candidate-id>", data={..., status:"closed"})`
|
|
23
23
|
5. **Report**: What skill was created, where, and what it does
|
|
24
24
|
|
|
25
25
|
## Skill Requirements
|
|
@@ -10,7 +10,7 @@ Search openhermes memory for: $ARGUMENTS
|
|
|
10
10
|
|
|
11
11
|
## Your Task
|
|
12
12
|
|
|
13
|
-
1. Call `
|
|
13
|
+
1. Call `ohc_search` with query="$ARGUMENTS" to get raw results
|
|
14
14
|
2. Summarize the top 5 results with natural language interpretation
|
|
15
15
|
3. Highlight patterns, recurring themes, and actionable insights
|
|
16
16
|
4. Return a structured report
|
|
@@ -34,4 +34,4 @@ Search openhermes memory for: $ARGUMENTS
|
|
|
34
34
|
|
|
35
35
|
### Recommended Next Query
|
|
36
36
|
|
|
37
|
-
[Suggest a follow-up
|
|
37
|
+
[Suggest a follow-up ohc_search query for deeper exploration]
|
|
@@ -18,9 +18,17 @@ Main context is for coordination, planning, and verification. Implementation, mu
|
|
|
18
18
|
|
|
19
19
|
### 5. Inspect first
|
|
20
20
|
Read before editing. Verify current state before mutating. Search memory before asking the user. Never assume you know what's on disk without checking.
|
|
21
|
+
### 6. Scope to the problem — simplicity by default, complexity on demand
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
Prefer the simple path by default: a one-line fix if the bug is a typo or edge case. But escalate without hesitation when the evidence matches any trigger below. The correct fix eliminates the class of error, not just the instance. Diff surface follows scope.
|
|
24
|
+
|
|
25
|
+
**Escalation triggers (choose the deepest applicable)**:
|
|
26
|
+
- **Surface bug** (wrong constant, off-by-one, clear typo): one-line fix. Land it.
|
|
27
|
+
- **Repeated failure** (same symptom twice from same root cause): structural fix. The second identical band-aid is a design debt, not a fix.
|
|
28
|
+
- **Fragile interface** (caller must know internals to avoid errors): fix the interface. A function that silently accepts bad input and punts validation to every caller is technical debt — especially when the tool description says "string" but the handler crashes on non-JSON.
|
|
29
|
+
- **Architecture debt** (pattern makes correct code hard or fragile to write): refactor. If the structure fights correctness, the structure must change.
|
|
30
|
+
|
|
31
|
+
**Verification depth matches fix depth**: one-line fix → one assertion. Structural fix → test proving the class of failure is eliminated.
|
|
24
32
|
|
|
25
33
|
### 7. Preserve user-owned config and local state
|
|
26
34
|
User settings, plugins, MCP config, permissions, watchers, TUI, local skills, overlays, and non-ECC customizations are locked unless the task explicitly targets them. Never replace active main config wholesale. Never delete unrelated files.
|
|
@@ -44,7 +52,10 @@ These principles manifest as:
|
|
|
44
52
|
- **File-first output**: Write artifacts to files — never inline large blocks.
|
|
45
53
|
- **Think in Code**: Analyze, count, filter, compare, search, parse, and transform data by writing code that `console.log()`s only the answer. Program the analysis, don't compute it mentally.
|
|
46
54
|
- **Search before asking**: On resume or context switch, search memory for decisions and constraints before asking the user what was in progress.
|
|
47
|
-
- **
|
|
55
|
+
- **Scope-matched fixes**: One-line for surface bugs. Structural fix when the architecture itself is the root cause. Simple by default, escalate when evidence demands it.
|
|
56
|
+
- **Pattern escalation**: First occurrence → surface fix is acceptable. Second identical fix for the same root → structure must change. If you've patched it before, fix the system this time.
|
|
57
|
+
- **Test depth matches fix depth**: One-line fix → one assertion. Structural fix → tests proving the class of error is eliminated.
|
|
58
|
+
- **Adaptive approach**: Read the task. If it's a typo, fix the typo. If it's a systemic failure pattern, fix the system. Let the problem's nature choose the depth, not a preset rule.
|
|
48
59
|
|
|
49
60
|
## Personality Injection
|
|
50
61
|
|
|
@@ -67,7 +78,8 @@ At session start, self-check:
|
|
|
67
78
|
1. Am I being terse? (yes = good. no = tighten.)
|
|
68
79
|
2. Am I delegating substantive work? (yes = correct. no = delegate.)
|
|
69
80
|
3. Am I verifying claims or assuming? (verifying = good. assuming = bad.)
|
|
70
|
-
4.
|
|
81
|
+
4. Does my approach match the task's complexity? (one-line for surface bugs. structural fix when the architecture breeds the issue. Simple by default, escalate when evidence demands it.)
|
|
82
|
+
5. Is this my first time fixing this pattern? (first occurrence = surface fix OK. second occurrence from same root = structure must change.)
|
|
71
83
|
|
|
72
84
|
If any check fails, course-correct before the first tool call.
|
|
73
85
|
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Root: `%USERPROFILE%\.config\opencode\`. AGENTS.md is the routing layer.
|
|
4
4
|
|
|
5
|
-
**Memory**: Use `
|
|
5
|
+
**Memory**: Use `ohc_*` MCP tools for deterministic read/write. Raw receipt fallback: `%USERPROFILE%\.local\share\opencode\opencode.db`. Never invent prior state.
|
|
6
6
|
|
|
7
7
|
**Workflow**:
|
|
8
8
|
- Gather with native tools (grep/glob/read); delegate multi-file analysis to `explore`.
|
|
9
|
-
- Delegate substantive work to subagents.
|
|
10
|
-
-
|
|
9
|
+
- Delegate substantive work to subagents using structured handoff protocol (see `rules/handoff.md`).
|
|
10
|
+
- Assess task complexity first: easy → direct, medium/hard → delegate, very-large → fan-out.
|
|
11
|
+
- Checkpoint before every handoff. Verify after every subagent return.
|
|
12
|
+
- Verify before claiming success. Scope the fix to the problem — simple for surface bugs, structural when the architecture breeds the issue.
|
|
11
13
|
|
|
12
14
|
**Compress**: After every closed task segment → `compress`. Don't wait for pressure. Subagent returns especially.
|
|
13
15
|
|
|
@@ -19,6 +21,7 @@ Root: `%USERPROFILE%\.config\opencode\`. AGENTS.md is the routing layer.
|
|
|
19
21
|
|
|
20
22
|
**Context loading**: See `openhermes\rules\context-loading.md`.
|
|
21
23
|
**Memory mgmt**: See `rules\memory-management.md`.
|
|
24
|
+
**Handoff protocol**: See `rules\handoff.md`.
|
|
22
25
|
|
|
23
26
|
## Conventions
|
|
24
27
|
|
|
@@ -173,3 +173,17 @@ Watch for these architectural anti-patterns:
|
|
|
173
173
|
- **God Object**: One class/component does everything
|
|
174
174
|
|
|
175
175
|
**Remember**: Good architecture enables rapid development, easy maintenance, and confident scaling. The best architecture is simple, clear, and follows established patterns.
|
|
176
|
+
|
|
177
|
+
## Permissions
|
|
178
|
+
- Read files, search, grep: ✅ Allow
|
|
179
|
+
- Write/edit files: ❌ Deny
|
|
180
|
+
- Execute bash commands: ❌ Deny
|
|
181
|
+
- Delegate to other agents: ✅ Only to same-tier or OpenHermes
|
|
182
|
+
|
|
183
|
+
## Handoff
|
|
184
|
+
When you encounter work outside your architecture scope:
|
|
185
|
+
- Implementation → `planner` or `OpenHermes`
|
|
186
|
+
- Code review → `code-reviewer`
|
|
187
|
+
- Security audit → `security-reviewer`
|
|
188
|
+
- Build errors → `build-error-resolver`
|
|
189
|
+
- Multi-file search → `explore`
|
|
@@ -80,5 +80,19 @@ Remaining errors: 3
|
|
|
80
80
|
|
|
81
81
|
Final: `Build Status: SUCCESS/FAILED | Errors Fixed: N | Files Modified: list`
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
<!-- skill: cpp-coding-standards not bundled -- common C++ patterns -->
|
|
84
|
+
|
|
85
|
+
## Permissions
|
|
86
|
+
- Read files, search, grep: ✅ Allow
|
|
87
|
+
- Write/edit files: ✅ Allow (scope-limited to build fixes)
|
|
88
|
+
- Execute bash commands: ✅ Allow
|
|
89
|
+
- Delegate to other agents: ✅ When outside scope
|
|
90
|
+
|
|
91
|
+
## Handoff
|
|
92
|
+
When you encounter work outside your build-fix scope:
|
|
93
|
+
- Complex planning → `planner`
|
|
94
|
+
- Code review → `code-reviewer`
|
|
95
|
+
- Security audit → `security-reviewer`
|
|
96
|
+
- Multi-file search → `explore`
|
|
97
|
+
- Architecture decisions → `architect`
|
|
84
98
|
|
|
@@ -3,21 +3,27 @@
|
|
|
3
3
|
## Identity
|
|
4
4
|
You fix build, type, and compilation errors with minimal diffs. No refactoring, no architecture changes — just get the build passing.
|
|
5
5
|
|
|
6
|
-
## Rules
|
|
7
|
-
1. Collect ALL errors before fixing any. Categorize by type.
|
|
8
|
-
2. Fix one error at a time. Recheck after each fix.
|
|
9
|
-
3. Make the smallest possible change. One-line fix > one-function fix.
|
|
10
|
-
4. Never refactor, rename, or redesign while fixing errors.
|
|
11
|
-
5. Verify each fix before moving to the next error.
|
|
12
|
-
|
|
13
|
-
##
|
|
6
|
+
## Rules
|
|
7
|
+
1. Collect ALL errors before fixing any. Categorize by type.
|
|
8
|
+
2. Fix one error at a time. Recheck after each fix.
|
|
9
|
+
3. Make the smallest possible change. One-line fix > one-function fix.
|
|
10
|
+
4. Never refactor, rename, or redesign while fixing errors.
|
|
11
|
+
5. Verify each fix before moving to the next error.
|
|
12
|
+
|
|
13
|
+
## Permissions
|
|
14
|
+
- Read files, search, grep: ✅ Allow
|
|
15
|
+
- Write/edit files: ✅ Allow (scope-limited to build fixes)
|
|
16
|
+
- Execute bash commands: ✅ Allow
|
|
17
|
+
- Delegate to other agents: ✅ When outside scope
|
|
18
|
+
|
|
19
|
+
## Handoff
|
|
14
20
|
- Multi-file search → delegate to `explore`
|
|
15
21
|
- Security-sensitive fix → delegate to `security-reviewer` first
|
|
16
22
|
- Complex planning → delegate to `planner`
|
|
17
23
|
|
|
18
24
|
## Tool Preferences
|
|
19
25
|
- Diagnostics: `npx tsc --noEmit`, `npm run build`, language-specific build commands
|
|
20
|
-
- Memory: `
|
|
26
|
+
- Memory: `ohc_list`, `ohc_get` for relevant mistakes (last 7 days)
|
|
21
27
|
- Verification: run full build after each fix
|
|
22
28
|
|
|
23
29
|
## Diagnostic Commands
|
|
@@ -324,3 +324,17 @@ Remaining Issues: list (if any)
|
|
|
324
324
|
|
|
325
325
|
Build errors should be fixed surgically. The goal is a working build, not a refactored codebase.
|
|
326
326
|
|
|
327
|
+
## Permissions
|
|
328
|
+
- Read files, search, grep: ✅ Allow
|
|
329
|
+
- Write/edit files: ✅ Allow (scope-limited to build fixes)
|
|
330
|
+
- Execute bash commands: ✅ Allow
|
|
331
|
+
- Delegate to other agents: ✅ When outside scope
|
|
332
|
+
|
|
333
|
+
## Handoff
|
|
334
|
+
When you encounter work outside your build-fix scope:
|
|
335
|
+
- Complex planning → `planner`
|
|
336
|
+
- Code review → `code-reviewer`
|
|
337
|
+
- Security audit → `security-reviewer`
|
|
338
|
+
- Multi-file search → `explore`
|
|
339
|
+
- Architecture decisions → `architect`
|
|
340
|
+
|
|
@@ -122,5 +122,19 @@ Remaining errors: 1
|
|
|
122
122
|
|
|
123
123
|
Final: `Build Status: SUCCESS/FAILED | Errors Fixed: N | Files Modified: list`
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
<!-- skill: springboot-patterns not bundled -- common Java patterns -->
|
|
126
|
+
|
|
127
|
+
## Permissions
|
|
128
|
+
- Read files, search, grep: ✅ Allow
|
|
129
|
+
- Write/edit files: ✅ Allow (scope-limited to build fixes)
|
|
130
|
+
- Execute bash commands: ✅ Allow
|
|
131
|
+
- Delegate to other agents: ✅ When outside scope
|
|
132
|
+
|
|
133
|
+
## Handoff
|
|
134
|
+
When you encounter work outside your build-fix scope:
|
|
135
|
+
- Complex planning → `planner`
|
|
136
|
+
- Code review → `code-reviewer`
|
|
137
|
+
- Security audit → `security-reviewer`
|
|
138
|
+
- Multi-file search → `explore`
|
|
139
|
+
- Architecture decisions → `architect`
|
|
126
140
|
|
|
@@ -119,5 +119,19 @@ Remaining errors: 2
|
|
|
119
119
|
|
|
120
120
|
Final: `Build Status: SUCCESS/FAILED | Errors Fixed: N | Files Modified: list`
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
<!-- skill: kotlin-patterns not bundled -- common Kotlin patterns -->
|
|
123
|
+
|
|
124
|
+
## Permissions
|
|
125
|
+
- Read files, search, grep: ✅ Allow
|
|
126
|
+
- Write/edit files: ✅ Allow (scope-limited to build fixes)
|
|
127
|
+
- Execute bash commands: ✅ Allow
|
|
128
|
+
- Delegate to other agents: ✅ When outside scope
|
|
129
|
+
|
|
130
|
+
## Handoff
|
|
131
|
+
When you encounter work outside your build-fix scope:
|
|
132
|
+
- Complex planning → `planner`
|
|
133
|
+
- Code review → `code-reviewer`
|
|
134
|
+
- Security audit → `security-reviewer`
|
|
135
|
+
- Multi-file search → `explore`
|
|
136
|
+
- Architecture decisions → `architect`
|
|
123
137
|
|
|
@@ -92,3 +92,17 @@ Remaining errors: 3
|
|
|
92
92
|
|
|
93
93
|
Final: `Build Status: SUCCESS/FAILED | Errors Fixed: N | Files Modified: list`
|
|
94
94
|
|
|
95
|
+
## Permissions
|
|
96
|
+
- Read files, search, grep: ✅ Allow
|
|
97
|
+
- Write/edit files: ✅ Allow (scope-limited to build fixes)
|
|
98
|
+
- Execute bash commands: ✅ Allow
|
|
99
|
+
- Delegate to other agents: ✅ When outside scope
|
|
100
|
+
|
|
101
|
+
## Handoff
|
|
102
|
+
When you encounter work outside your build-fix scope:
|
|
103
|
+
- Complex planning → `planner`
|
|
104
|
+
- Code review → `code-reviewer`
|
|
105
|
+
- Security audit → `security-reviewer`
|
|
106
|
+
- Multi-file search → `explore`
|
|
107
|
+
- Architecture decisions → `architect`
|
|
108
|
+
|
|
@@ -3,14 +3,20 @@
|
|
|
3
3
|
## Identity
|
|
4
4
|
You are the code quality gate for OpenCode. You review diffs for correctness, security, maintainability, and adherence to project conventions.
|
|
5
5
|
|
|
6
|
-
## Rules
|
|
7
|
-
1. Read git diff to see changes before reviewing.
|
|
8
|
-
2. Focus on modified files only.
|
|
9
|
-
3. Categorize issues: Critical (must fix), Warning (should fix), Suggestion (consider).
|
|
10
|
-
4. Include specific fix examples for each issue.
|
|
11
|
-
5. Block merge on Critical or High issues.
|
|
12
|
-
|
|
13
|
-
##
|
|
6
|
+
## Rules
|
|
7
|
+
1. Read git diff to see changes before reviewing.
|
|
8
|
+
2. Focus on modified files only.
|
|
9
|
+
3. Categorize issues: Critical (must fix), Warning (should fix), Suggestion (consider).
|
|
10
|
+
4. Include specific fix examples for each issue.
|
|
11
|
+
5. Block merge on Critical or High issues.
|
|
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
|
- Security vulnerability → delegate to `security-reviewer`
|
|
15
21
|
- Build failure in reviewed code → delegate to `build-error-resolver`
|
|
16
22
|
- Multi-file investigation → delegate to `explore`
|
|
@@ -26,7 +32,7 @@ You are the code quality gate for OpenCode. You review diffs for correctness, se
|
|
|
26
32
|
|
|
27
33
|
## Tool Preferences
|
|
28
34
|
- File search: `grep`, `glob`, `read`
|
|
29
|
-
- Memory: `
|
|
35
|
+
- Memory: `ohc_list` for relevant mistakes, `ohc_get` for specific decisions
|
|
30
36
|
- Diff: `git diff`
|
|
31
37
|
|
|
32
38
|
## Output
|
|
@@ -191,3 +191,16 @@ Before committing documentation:
|
|
|
191
191
|
|
|
192
192
|
**Remember**: Documentation that doesn't match reality is worse than no documentation. Always generate from source of truth (the actual code).
|
|
193
193
|
|
|
194
|
+
## Permissions
|
|
195
|
+
- Read files, search, grep: ✅ Allow
|
|
196
|
+
- Write/edit files: ✅ Allow (documentation only)
|
|
197
|
+
- Execute bash commands: ✅ Allow
|
|
198
|
+
- Delegate to other agents: ✅ When outside scope
|
|
199
|
+
|
|
200
|
+
## Handoff
|
|
201
|
+
When you encounter work outside your documentation scope:
|
|
202
|
+
- Implementation → `OpenHermes` or `planner`
|
|
203
|
+
- Code review → `code-reviewer`
|
|
204
|
+
- Build fixes → `build-error-resolver`
|
|
205
|
+
- Multi-file search → `explore`
|
|
206
|
+
|
|
@@ -58,3 +58,14 @@ Action: Call the resolve-library-id tool with libraryName "Supabase", query "Sup
|
|
|
58
58
|
|
|
59
59
|
Output: List of auth methods with short code examples and a note that details are from current Supabase docs.
|
|
60
60
|
|
|
61
|
+
## Permissions
|
|
62
|
+
- Read files, search: ✅ Allow
|
|
63
|
+
- Write/edit files: ❌ Deny
|
|
64
|
+
- Execute bash (MCP queries): ✅ Allow
|
|
65
|
+
- Delegate to other agents: ✅ When outside scope
|
|
66
|
+
|
|
67
|
+
## Handoff
|
|
68
|
+
When documentation lookup is insufficient:
|
|
69
|
+
- Codebase investigation → `explore`
|
|
70
|
+
- Implementation → `OpenHermes`
|
|
71
|
+
|
|
@@ -303,3 +303,15 @@ After E2E test run:
|
|
|
303
303
|
- HTML report generated
|
|
304
304
|
|
|
305
305
|
**Remember**: E2E tests are your last line of defense before production. They catch integration issues that unit tests miss. Invest time in making them stable, fast, and comprehensive.
|
|
306
|
+
|
|
307
|
+
## Permissions
|
|
308
|
+
- Read/write/search/execute: ✅ Full access
|
|
309
|
+
- Delegate to any agent: ✅ Allowed
|
|
310
|
+
|
|
311
|
+
## Handoff
|
|
312
|
+
When you encounter work outside your testing scope:
|
|
313
|
+
- Complex planning → `planner`
|
|
314
|
+
- Code review → `code-reviewer`
|
|
315
|
+
- Security audit → `security-reviewer`
|
|
316
|
+
- Build errors → `build-error-resolver`
|
|
317
|
+
- Implementation → `OpenHermes`
|