@dzhechkov/harness-cli 0.3.237 → 0.3.238
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/.dz-manifest.json +8 -8
- package/README.md +35 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +100 -6
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
- package/sbom.json +7 -7
- package/src/cli.ts +97 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dzhechkov/harness-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.238",
|
|
4
4
|
"description": "The dz CLI — install AI skills for Claude Code, Codex, OpenCode, Hermes, OpenClaude, GitHub Copilot. 35 commands, 13 presets, 6 platform targets.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@dzhechkov/skills-reverse-engineering": "^0.1.0",
|
|
58
58
|
"@dzhechkov/skills-presentation-storyteller": "^0.1.0",
|
|
59
59
|
"@dzhechkov/skills-website-cloner": "^0.1.0",
|
|
60
|
-
"@dzhechkov/harness-core": "0.3.
|
|
60
|
+
"@dzhechkov/harness-core": "0.3.129"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "^25.6.0",
|
package/sbom.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"hashes": [
|
|
26
26
|
{
|
|
27
27
|
"alg": "SHA-256",
|
|
28
|
-
"content": "
|
|
28
|
+
"content": "ef6603652143fc1517c81506dad9d5e7b79e5d5138aad9f6281ad77492d58b71"
|
|
29
29
|
}
|
|
30
30
|
]
|
|
31
31
|
},
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"hashes": [
|
|
106
106
|
{
|
|
107
107
|
"alg": "SHA-256",
|
|
108
|
-
"content": "
|
|
108
|
+
"content": "8f8807920c7ddd901361eb5a602df9c85fa69726e47535a146937038eab6b281"
|
|
109
109
|
}
|
|
110
110
|
]
|
|
111
111
|
},
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"hashes": [
|
|
116
116
|
{
|
|
117
117
|
"alg": "SHA-256",
|
|
118
|
-
"content": "
|
|
118
|
+
"content": "5f5fbcc7c040a272f6af992ef1f9c39482b941d74dbcadec9f3d9008babcb08a"
|
|
119
119
|
}
|
|
120
120
|
]
|
|
121
121
|
},
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"hashes": [
|
|
126
126
|
{
|
|
127
127
|
"alg": "SHA-256",
|
|
128
|
-
"content": "
|
|
128
|
+
"content": "420d1178a513e54f315095a17e9c5722543ca6cbdbebd9a674d4d50ef61b8aa0"
|
|
129
129
|
}
|
|
130
130
|
]
|
|
131
131
|
},
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
"hashes": [
|
|
186
186
|
{
|
|
187
187
|
"alg": "SHA-256",
|
|
188
|
-
"content": "
|
|
188
|
+
"content": "8fbaf10d29b5733cf9445e1ef5804a3e124f733c3390a99937d2d8dc3b4cf02a"
|
|
189
189
|
}
|
|
190
190
|
]
|
|
191
191
|
},
|
|
@@ -205,7 +205,7 @@
|
|
|
205
205
|
"hashes": [
|
|
206
206
|
{
|
|
207
207
|
"alg": "SHA-256",
|
|
208
|
-
"content": "
|
|
208
|
+
"content": "131f23a50187e1be19875d4ccd76d8c354b1fbb8d193c03e73fda16ff64f51dc"
|
|
209
209
|
}
|
|
210
210
|
]
|
|
211
211
|
},
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
"hashes": [
|
|
226
226
|
{
|
|
227
227
|
"alg": "SHA-256",
|
|
228
|
-
"content": "
|
|
228
|
+
"content": "3deb99917f3d8b4a5c9a3b0315bd65a3099ce2b508121cfa2bdeed19b7554d48"
|
|
229
229
|
}
|
|
230
230
|
]
|
|
231
231
|
},
|
package/src/cli.ts
CHANGED
|
@@ -64,6 +64,13 @@ import {
|
|
|
64
64
|
recallHybrid,
|
|
65
65
|
teachGuard,
|
|
66
66
|
mirrorPatternsToVector,
|
|
67
|
+
mirrorEntriesToVector,
|
|
68
|
+
patternVectorEntry,
|
|
69
|
+
readMemoryLearningConfig,
|
|
70
|
+
promotePatterns,
|
|
71
|
+
quarantineExpiryCandidates,
|
|
72
|
+
pruneQuarantinePatterns,
|
|
73
|
+
clearAgentdbQuarantine,
|
|
67
74
|
vectorMirrorEnabled,
|
|
68
75
|
vectorTierStatus,
|
|
69
76
|
resolveVectorEngine,
|
|
@@ -218,8 +225,8 @@ Usage:
|
|
|
218
225
|
dz setup --target <name> [--preset <name>] [--select id,id,...] [--skills-dir <dir>] [--project <dir>] [--memory agentdb] [--no-memory] [--no-hooks] [--install-driver] [--force] [--enrich]
|
|
219
226
|
dz teach "<pattern>" [--reward <0-1>] [--domain <name>] [--type rule|success-pattern|lesson-learned] [--project <dir>] [--no-mirror] (--project pins the learned store to <dir>/.dz, not the cwd — pin to a canonical brain)
|
|
220
227
|
dz teach --from-json <file> [--project <dir>] [--no-mirror] (bulk-import a 'dz recall --all --json' export — share a learned store across machines)
|
|
221
|
-
dz consolidate [--sessions-dir <dir>] [--project <dir>] [--no-mirror] [--prune-noise [--apply]] (
|
|
222
|
-
dz recall "<query>" [--limit <N>] [--semantic | --no-semantic] [--books [--book <slug>]] [--project <dir>] | dz recall --all [--json] | dz recall --usage [--json] | dz recall --forget <dzId>[,<dzId>] [--apply] (forget: dry-run default; snapshots before removing)
|
|
228
|
+
dz consolidate [--sessions-dir <dir>] [--project <dir>] [--no-mirror] [--prune-noise [--apply]] [--prune-quarantine [--apply]] (both prunes: DRY-RUN by default; --apply snapshots then deletes; prune-quarantine = expired unproven lessons ONLY, never coupled to noise)
|
|
229
|
+
dz recall "<query>" [--limit <N>] [--semantic | --no-semantic] [--books [--book <slug>]] [--project <dir>] | dz recall --all [--json] | dz recall --usage [--json] | dz recall --forget <dzId>[,<dzId>] [--apply] | dz recall --promote <dzId>[,<dzId>] [--apply] (forget/promote: dry-run default; forget snapshots before removing; promote lifts lesson-quarantine)
|
|
223
230
|
dz vector status [--project <dir>] [--json] (semantic tier: engine, mirrored vs lexical counts, pending queue)
|
|
224
231
|
dz vector reindex [--project <dir>] [--json] (snapshot, re-embed learned-pattern vectors, stamp current model)
|
|
225
232
|
dz vector export <path> [--project <dir>] (portable VECTOR form (.rvf, opt-in RVF engine); patterns ship via recall --all --json)
|
|
@@ -1515,6 +1522,16 @@ async function cmdTeach(options: Map<string, string>, flags: Set<string>, cwd: s
|
|
|
1515
1522
|
const receipt = await mirrorPatternsToVector(root, records, source);
|
|
1516
1523
|
if (receipt.mirrored > 0) write(` ↳ mirrored to vector tier (${receipt.engine ?? 'vector'})`);
|
|
1517
1524
|
};
|
|
1525
|
+
// lesson-quarantine FR-8: the fresh-teach mirror carries the qStatus marker so the hook daemon
|
|
1526
|
+
// (which reads only the mirror's metadata) can exclude unproven lessons from auto-inject.
|
|
1527
|
+
const emitMirrorQ = async (root: string, records: readonly PatternRecord[], source: string, quarantined: boolean): Promise<void> => {
|
|
1528
|
+
if (flags.has('no-mirror') || records.length === 0 || !vectorMirrorEnabled(root)) return;
|
|
1529
|
+
const entries = records
|
|
1530
|
+
.map((r) => patternVectorEntry(r, source, quarantined ? { quarantined: true } : {}))
|
|
1531
|
+
.filter((e): e is NonNullable<typeof e> => e !== undefined);
|
|
1532
|
+
const receipt = await mirrorEntriesToVector(root, entries);
|
|
1533
|
+
if (receipt.mirrored > 0) write(` ↳ mirrored to vector tier (${receipt.engine ?? 'vector'})${quarantined ? ' [quarantined]' : ''}`);
|
|
1534
|
+
};
|
|
1518
1535
|
|
|
1519
1536
|
// `dz teach --harmonize` — documented ALIAS of `dz vector harmonize`: SEMANTIC dedup of the
|
|
1520
1537
|
// learned store. ONE implementation (harmonizeVectorStore), two entry points (QR-6). Routed
|
|
@@ -1595,6 +1612,9 @@ async function cmdTeach(options: Map<string, string>, flags: Set<string>, cwd: s
|
|
|
1595
1612
|
const trained = await backend.train();
|
|
1596
1613
|
if (trained.flushed > 0) {
|
|
1597
1614
|
write(`↳ reinforced ${reinforce}`);
|
|
1615
|
+
// lesson-quarantine: reinforcement IS promotion — keep the hook daemon's mirror in step.
|
|
1616
|
+
const clearedQ = clearAgentdbQuarantine(projectRoot, [reinforce]);
|
|
1617
|
+
if (clearedQ.cleared > 0) write(` ↳ promoted out of quarantine (mirror updated)`);
|
|
1598
1618
|
return 0;
|
|
1599
1619
|
}
|
|
1600
1620
|
// HIGH-fix: a no-match must NOT auto-teach the raw argument — callers pass dzIds or truncated
|
|
@@ -1629,6 +1649,8 @@ async function cmdTeach(options: Map<string, string>, flags: Set<string>, cwd: s
|
|
|
1629
1649
|
// teach below so the lesson is NEVER silently discarded (the exact silent-drop the ADR forbids).
|
|
1630
1650
|
if (trained.flushed > 0) {
|
|
1631
1651
|
write(`↳ reinforced existing pattern ${verdict.dzId} (cos=${verdict.cosine.toFixed(2)}) — not re-added`);
|
|
1652
|
+
const clearedQ = clearAgentdbQuarantine(projectRoot, [verdict.dzId]);
|
|
1653
|
+
if (clearedQ.cleared > 0) write(' ↳ promoted out of quarantine (mirror updated)');
|
|
1632
1654
|
return 0;
|
|
1633
1655
|
}
|
|
1634
1656
|
write(`dz teach --guard: reinforce of ${verdict.dzId} did not flush (backend off or write failure) — teaching the lesson normally instead`);
|
|
@@ -1658,13 +1680,18 @@ async function cmdTeach(options: Map<string, string>, flags: Set<string>, cwd: s
|
|
|
1658
1680
|
// Tier-2 (ADR-005): persist through the unified @dzhechkov/memory store. recordPattern
|
|
1659
1681
|
// folds any legacy .dz/patterns.jsonl into the backend (idempotent) and returns the
|
|
1660
1682
|
// total count. The lossy `npx agentdb add` dual-write was removed in Tier-1 (audit #6).
|
|
1661
|
-
|
|
1683
|
+
// lesson-quarantine (opt-in): a fresh lesson is a HYPOTHESIS until it earns promotion.
|
|
1684
|
+
const quarantineOn = readMemoryLearningConfig(projectRoot).quarantine;
|
|
1685
|
+
const count = await recordPattern(projectRoot, entry, quarantineOn ? { quarantine: true } : {});
|
|
1662
1686
|
|
|
1663
1687
|
write(`Learned: "${pattern.slice(0, 60)}${pattern.length > 60 ? '...' : ''}"`);
|
|
1664
1688
|
write(` Domain: ${domain} Reward: ${reward} Backend: memory (@dzhechkov/memory)`);
|
|
1665
1689
|
write(` Total patterns: ${count}`);
|
|
1690
|
+
if (quarantineOn) {
|
|
1691
|
+
write(' ⚠ quarantined: excluded from auto-inject, damped in recall — promote by confirming it (dz teach --reinforce "<text>") or dz recall --promote <dzId> --apply');
|
|
1692
|
+
}
|
|
1666
1693
|
// The lexical write above is durable — the vector mirror is strictly best-effort (I-3).
|
|
1667
|
-
await
|
|
1694
|
+
await emitMirrorQ(projectRoot, [entry], 'dz-teach', quarantineOn);
|
|
1668
1695
|
return 0;
|
|
1669
1696
|
}
|
|
1670
1697
|
|
|
@@ -1673,6 +1700,23 @@ async function cmdConsolidate(options: Map<string, string>, flags: Set<string>,
|
|
|
1673
1700
|
const sessionsDirOpt = options.get('sessions-dir');
|
|
1674
1701
|
const pruneNoise = flags.has('prune-noise');
|
|
1675
1702
|
|
|
1703
|
+
// lesson-quarantine FR-7: expiry is a SEPARATE, explicit surface — never coupled to prune-noise
|
|
1704
|
+
// (the recalled decay-vs-noise lesson: valid-but-unproven is not garbage). Dry-run by default.
|
|
1705
|
+
if (flags.has('prune-quarantine')) {
|
|
1706
|
+
const cfg = readMemoryLearningConfig(projectRoot);
|
|
1707
|
+
const res = pruneQuarantinePatterns(projectRoot, { dryRun: !flags.has('apply'), expireDays: cfg.quarantineExpireDays });
|
|
1708
|
+
if (!flags.has('apply')) {
|
|
1709
|
+
write(`dz consolidate --prune-quarantine: DRY RUN — ${res.candidates.length} expired quarantined lesson(s) (> ${cfg.quarantineExpireDays}d, never reinforced)`);
|
|
1710
|
+
for (const c of res.candidates) write(` [${c.ageDays < 0 ? '?' : c.ageDays}d] ${c.dzId} ${c.text.slice(0, 70)}`);
|
|
1711
|
+
if (res.candidates.length > 0) write(' → re-run with --apply to remove (snapshots first); or promote keepers: dz recall --promote <dzId> --apply');
|
|
1712
|
+
return 0;
|
|
1713
|
+
}
|
|
1714
|
+
if (res.error !== undefined) { write(`dz consolidate --prune-quarantine: ${res.error}`); return 1; }
|
|
1715
|
+
write(`dz consolidate --prune-quarantine: removed ${res.removed} expired quarantined lesson(s)`);
|
|
1716
|
+
if (res.snapshot !== undefined) write(` snapshot: ${res.snapshot}`);
|
|
1717
|
+
return 0;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1676
1720
|
// --prune-noise: RETRO-PRUNE legacy noise (tool telemetry + system-wrapper "responses") from
|
|
1677
1721
|
// the lexical store AND the agentdb vector mirror BEFORE harvesting, so this run's watermark
|
|
1678
1722
|
// never re-learns from junk. Best-effort — a prune error is reported, never fatal.
|
|
@@ -1890,12 +1934,53 @@ async function cmdRecallForget(
|
|
|
1890
1934
|
return 0;
|
|
1891
1935
|
}
|
|
1892
1936
|
|
|
1937
|
+
/**
|
|
1938
|
+
* `dz recall --promote <dzId>[,<dzId>…] [--apply]` — lift quarantine from NAMED records
|
|
1939
|
+
* (lesson-quarantine FR-6b). Dry-run by default, the --forget symmetry. Also clears the
|
|
1940
|
+
* agentdb mirror's qStatus (best-effort) so the hook daemon stops excluding promoted lessons.
|
|
1941
|
+
*/
|
|
1942
|
+
async function cmdRecallPromote(
|
|
1943
|
+
options: Map<string, string>,
|
|
1944
|
+
flags: Set<string>,
|
|
1945
|
+
projectRoot: string,
|
|
1946
|
+
write: Write,
|
|
1947
|
+
): Promise<number> {
|
|
1948
|
+
const ids = (options.get('promote') ?? '').split(',').map((s) => s.trim()).filter((s) => s.length > 0);
|
|
1949
|
+
if (ids.length === 0) {
|
|
1950
|
+
write('dz recall --promote: no ids given (comma-separated dzIds; quarantined ones are marked ⚠q in recall)');
|
|
1951
|
+
return 1;
|
|
1952
|
+
}
|
|
1953
|
+
if (!flags.has('apply')) {
|
|
1954
|
+
const records = loadStoreRecords(projectRoot);
|
|
1955
|
+
const found = ids.filter((id) => records.some((r) => r.id === id));
|
|
1956
|
+
write(`dz recall --promote: DRY RUN — ${found.length}/${ids.length} id(s) match the store. Re-run with --apply to promote.`);
|
|
1957
|
+
return 0;
|
|
1958
|
+
}
|
|
1959
|
+
const res = await promotePatterns(projectRoot, ids);
|
|
1960
|
+
// Codex-QE finding 5: even on a mid-batch failure, the ALREADY-promoted records must get their
|
|
1961
|
+
// mirror rows cleared — otherwise the canonical store and the hook-visible mirror split-brain.
|
|
1962
|
+
if (res.promoted.length > 0) {
|
|
1963
|
+
const cleared = clearAgentdbQuarantine(projectRoot, res.promoted);
|
|
1964
|
+
if (cleared.cleared > 0) write(` ↳ mirror updated (${cleared.cleared} row(s) un-quarantined in agentdb)`);
|
|
1965
|
+
else if (cleared.error !== undefined) write(` ⚠ mirror not updated (${cleared.error}) — run dz vector reindex to resync`);
|
|
1966
|
+
}
|
|
1967
|
+
if (!res.ok) {
|
|
1968
|
+
write(`dz recall --promote: failed — ${res.error ?? 'unknown error'} (promoted so far: ${res.promoted.length})`);
|
|
1969
|
+
return 1;
|
|
1970
|
+
}
|
|
1971
|
+
write(`dz recall --promote: promoted ${res.promoted.length} record(s)`);
|
|
1972
|
+
if (res.notQuarantined.length > 0) write(` already promoted (not quarantined): ${res.notQuarantined.join(', ')}`);
|
|
1973
|
+
if (res.notFound.length > 0) write(` not found: ${res.notFound.join(', ')}`);
|
|
1974
|
+
return 0;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1893
1977
|
async function cmdRecall(options: Map<string, string>, flags: Set<string>, cwd: string, write: Write): Promise<number> {
|
|
1894
1978
|
const projectRoot = resolve(cwd, options.get('project') ?? '.');
|
|
1895
1979
|
const asJson = flags.has('json');
|
|
1896
1980
|
const all = flags.has('all');
|
|
1897
1981
|
if (flags.has('usage')) return cmdRecallUsage(options, flags, projectRoot, write);
|
|
1898
1982
|
if (options.has('forget')) return cmdRecallForget(options, flags, projectRoot, write);
|
|
1983
|
+
if (options.has('promote')) return cmdRecallPromote(options, flags, projectRoot, write);
|
|
1899
1984
|
|
|
1900
1985
|
// --all: dump the entire learned store (backend-agnostic, via loadStorePatternsSync).
|
|
1901
1986
|
// With --json this is the portable export the agentdb-memory MCP bridge consumes.
|
|
@@ -1994,9 +2079,16 @@ async function cmdRecall(options: Map<string, string>, flags: Set<string>, cwd:
|
|
|
1994
2079
|
const lexLabel = result.lexicalBackend === 'sqlite' ? 'SQLite FTS5' : 'keyword (JSON)';
|
|
1995
2080
|
const ranking = vectorOn ? `${lexLabel} + vector (${result.vectorEngine}) ranking` : `${lexLabel} ranking (lexical)`;
|
|
1996
2081
|
write(`dz recall "${query}" — ${hits.length} hit(s), ${ranking}`);
|
|
2082
|
+
let sawQuarantined = false;
|
|
1997
2083
|
for (const h of hits) {
|
|
1998
2084
|
const backendTag = vectorOn ? ` ⟨${h.backend}⟩` : '';
|
|
1999
|
-
|
|
2085
|
+
const qTag = h.quarantined === true ? ' ⚠q' : '';
|
|
2086
|
+
if (h.quarantined === true) sawQuarantined = true;
|
|
2087
|
+
write(` [${h.pattern.reward.toFixed(2)}] (${h.pattern.domain})${backendTag}${qTag} ${h.pattern.pattern.slice(0, 80)}`);
|
|
2088
|
+
}
|
|
2089
|
+
if (sawQuarantined) {
|
|
2090
|
+
// The loop stays VISIBLE (ADR D2): a quarantined hit is shown, marked, and explained.
|
|
2091
|
+
write(' ⚠q = quarantined (unproven hypothesis, rank damped) — confirm with dz teach --reinforce, or dz recall --promote <dzId> --apply');
|
|
2000
2092
|
}
|
|
2001
2093
|
if (result.vectorError !== undefined && mode !== 'lexical') {
|
|
2002
2094
|
// Engine present but the semantic leg failed/timed out — one honest line, exit 0 (05 §2.3).
|