monomind 1.18.13 → 1.19.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/.claude/agents/core/researcher.md +29 -24
- package/.claude/agents/github/code-review-swarm.md +1 -1
- package/.claude/agents/github/github-modes.md +1 -1
- package/.claude/agents/github/issue-tracker.md +1 -1
- package/.claude/agents/github/multi-repo-swarm.md +1 -1
- package/.claude/agents/github/pr-manager.md +1 -1
- package/.claude/agents/github/project-board-sync.md +1 -1
- package/.claude/agents/github/release-manager.md +1 -1
- package/.claude/agents/github/repo-architect.md +1 -1
- package/.claude/agents/github/swarm-issue.md +1 -1
- package/.claude/agents/github/swarm-pr.md +1 -1
- package/.claude/agents/github/sync-coordinator.md +1 -1
- package/.claude/agents/github/workflow-automation.md +1 -1
- package/.claude/agents/goal/goal-planner.md +1 -1
- package/.claude/agents/specialized/specialized-workflow-architect.md +11 -14
- package/.claude/agents/testing/production-validator.md +8 -7
- package/.claude/agents/testing/testing-evidence-collector.md +3 -1
- package/.claude/commands/mastermind/_repeat.md +22 -3
- package/.claude/commands/mastermind/architect.md +1 -1
- package/.claude/commands/mastermind/autodev.md +1 -1
- package/.claude/commands/mastermind/build.md +1 -1
- package/.claude/commands/mastermind/code-review.md +5 -5
- package/.claude/commands/mastermind/debug.md +1 -1
- package/.claude/commands/mastermind/help.md +2 -2
- package/.claude/commands/mastermind/idea.md +1 -1
- package/.claude/commands/mastermind/improve.md +1 -1
- package/.claude/commands/mastermind/okf-export.md +14 -0
- package/.claude/commands/mastermind/okf-import.md +15 -0
- package/.claude/commands/mastermind/plan.md +1 -1
- package/.claude/commands/mastermind/research.md +1 -1
- package/.claude/commands/mastermind/review.md +12 -1
- package/.claude/commands/mastermind/runorg.md +1 -1
- package/.claude/commands/mastermind/taskdev.md +1 -1
- package/.claude/commands/mastermind/tdd.md +1 -1
- package/.claude/commands/mastermind/verify.md +1 -1
- package/.claude/helpers/graphify-freshen.cjs +16 -20
- package/.claude/helpers/handlers/agent-start-handler.cjs +11 -36
- package/.claude/helpers/handlers/capture-handler.cjs +110 -0
- package/.claude/helpers/handlers/route-handler.cjs +180 -256
- package/.claude/helpers/handlers/session-handler.cjs +139 -142
- package/.claude/helpers/handlers/session-restore-handler.cjs +15 -10
- package/.claude/helpers/handlers/task-handler.cjs +8 -155
- package/.claude/helpers/hook-handler.cjs +89 -5
- package/.claude/helpers/intelligence.cjs +164 -15
- package/.claude/helpers/learning-service.mjs +1 -0
- package/.claude/helpers/mastermind-activate.cjs +33 -51
- package/.claude/helpers/monolean-activate.cjs +13 -3
- package/.claude/helpers/monolean-propagate.cjs +7 -3
- package/.claude/helpers/router.cjs +47 -9
- package/.claude/helpers/utils/monograph.cjs +37 -20
- package/.claude/settings.json +0 -20
- package/.claude/skills/mastermind-skills/_repeat.md +29 -4
- package/.claude/skills/mastermind-skills/architect.md +5 -6
- package/.claude/skills/mastermind-skills/autodev.md +8 -5
- package/.claude/skills/mastermind-skills/review.md +25 -11
- package/.claude/skills/mastermind-skills/techport.md +37 -3
- package/.claude/skills/monodesign/document.md +9 -6
- package/.claude/skills/monodesign/extract.md +1 -1
- package/.claude/skills/monodesign/reference/document.md +1 -1
- package/.claude/skills/monodesign/reference/live.md +1 -1
- package/.claude/skills/monolean/SKILL.md +1 -1
- package/package.json +1 -1
- package/packages/@monomind/cli/.claude/agents/core/researcher.md +29 -24
- package/packages/@monomind/cli/.claude/agents/github/code-review-swarm.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/github-modes.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/issue-tracker.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/multi-repo-swarm.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/pr-manager.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/project-board-sync.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/release-manager.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/repo-architect.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/swarm-issue.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/swarm-pr.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/sync-coordinator.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/workflow-automation.md +1 -1
- package/packages/@monomind/cli/.claude/agents/goal/goal-planner.md +1 -1
- package/packages/@monomind/cli/.claude/agents/specialized/specialized-workflow-architect.md +11 -14
- package/packages/@monomind/cli/.claude/agents/testing/production-validator.md +8 -7
- package/packages/@monomind/cli/.claude/agents/testing/testing-evidence-collector.md +3 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/_repeat.md +22 -3
- package/packages/@monomind/cli/.claude/commands/mastermind/architect.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/autodev.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/build.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/code-review.md +5 -5
- package/packages/@monomind/cli/.claude/commands/mastermind/debug.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/help.md +2 -2
- package/packages/@monomind/cli/.claude/commands/mastermind/idea.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/improve.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/okf-export.md +14 -0
- package/packages/@monomind/cli/.claude/commands/mastermind/okf-import.md +15 -0
- package/packages/@monomind/cli/.claude/commands/mastermind/plan.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/research.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/review.md +12 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/runorg.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/taskdev.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/tdd.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/verify.md +1 -1
- package/packages/@monomind/cli/.claude/helpers/graphify-freshen.cjs +16 -20
- package/packages/@monomind/cli/.claude/helpers/handlers/agent-start-handler.cjs +11 -36
- package/packages/@monomind/cli/.claude/helpers/handlers/capture-handler.cjs +110 -0
- package/packages/@monomind/cli/.claude/helpers/handlers/route-handler.cjs +180 -256
- package/packages/@monomind/cli/.claude/helpers/handlers/session-handler.cjs +139 -142
- package/packages/@monomind/cli/.claude/helpers/handlers/session-restore-handler.cjs +15 -10
- package/packages/@monomind/cli/.claude/helpers/handlers/task-handler.cjs +8 -155
- package/packages/@monomind/cli/.claude/helpers/hook-handler.cjs +89 -5
- package/packages/@monomind/cli/.claude/helpers/intelligence.cjs +164 -15
- package/packages/@monomind/cli/.claude/helpers/learning-service.mjs +1 -0
- package/packages/@monomind/cli/.claude/helpers/mastermind-activate.cjs +33 -51
- package/packages/@monomind/cli/.claude/helpers/monolean-activate.cjs +13 -3
- package/packages/@monomind/cli/.claude/helpers/monolean-propagate.cjs +7 -3
- package/packages/@monomind/cli/.claude/helpers/router.cjs +47 -9
- package/packages/@monomind/cli/.claude/helpers/utils/monograph.cjs +37 -20
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/_repeat.md +29 -4
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/architect.md +5 -6
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/autodev.md +8 -5
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/review.md +25 -11
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/techport.md +37 -3
- package/packages/@monomind/cli/.claude/skills/monodesign/document.md +9 -6
- package/packages/@monomind/cli/.claude/skills/monodesign/extract.md +1 -1
- package/packages/@monomind/cli/.claude/skills/monodesign/reference/document.md +1 -1
- package/packages/@monomind/cli/.claude/skills/monodesign/reference/live.md +1 -1
- package/packages/@monomind/cli/.claude/skills/monolean/SKILL.md +1 -1
- package/packages/@monomind/cli/bin/mcp-server.js +11 -1
- package/packages/@monomind/cli/dist/src/commands/agent-ops.d.ts +1 -2
- package/packages/@monomind/cli/dist/src/commands/agent-ops.js +1 -59
- package/packages/@monomind/cli/dist/src/commands/agent.js +2 -3
- package/packages/@monomind/cli/dist/src/commands/analyze-diff.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/browse-action.js +94 -2
- package/packages/@monomind/cli/dist/src/commands/completions.js +11 -56
- package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/hive-mind-helpers.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.d.ts +1 -3
- package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.js +2 -116
- package/packages/@monomind/cli/dist/src/commands/hive-mind.js +2 -5
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-commands.js +8 -7
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-gaps.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-routing.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/hooks-extended-commands.d.ts +0 -3
- package/packages/@monomind/cli/dist/src/commands/hooks-extended-commands.js +0 -307
- package/packages/@monomind/cli/dist/src/commands/hooks.js +1 -12
- package/packages/@monomind/cli/dist/src/commands/index.d.ts +3 -51
- package/packages/@monomind/cli/dist/src/commands/index.js +36 -184
- package/packages/@monomind/cli/dist/src/commands/init-wizard.js +2 -4
- package/packages/@monomind/cli/dist/src/commands/mcp.js +32 -4
- package/packages/@monomind/cli/dist/src/commands/memory-admin.d.ts +1 -2
- package/packages/@monomind/cli/dist/src/commands/memory-admin.js +1 -118
- package/packages/@monomind/cli/dist/src/commands/memory-transfer.d.ts +1 -2
- package/packages/@monomind/cli/dist/src/commands/memory-transfer.js +5 -171
- package/packages/@monomind/cli/dist/src/commands/memory.js +3 -6
- package/packages/@monomind/cli/dist/src/commands/neural-core.d.ts +3 -1
- package/packages/@monomind/cli/dist/src/commands/neural-core.js +145 -6
- package/packages/@monomind/cli/dist/src/commands/neural-optimize.js +4 -4
- package/packages/@monomind/cli/dist/src/commands/neural-registry.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/neural-registry.js +4 -4
- package/packages/@monomind/cli/dist/src/commands/neural.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/neural.js +6 -6
- package/packages/@monomind/cli/dist/src/commands/performance.js +68 -58
- package/packages/@monomind/cli/dist/src/commands/providers.js +2 -131
- package/packages/@monomind/cli/dist/src/commands/security-misc.d.ts +0 -1
- package/packages/@monomind/cli/dist/src/commands/security-misc.js +69 -45
- package/packages/@monomind/cli/dist/src/commands/security.js +2 -4
- package/packages/@monomind/cli/dist/src/commands/session.js +1 -285
- package/packages/@monomind/cli/dist/src/commands/start.js +2 -41
- package/packages/@monomind/cli/dist/src/commands/status.js +18 -29
- package/packages/@monomind/cli/dist/src/commands/swarm.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/task.js +2 -49
- package/packages/@monomind/cli/dist/src/commands/workflow.js +2 -104
- package/packages/@monomind/cli/dist/src/index.js +7 -0
- package/packages/@monomind/cli/dist/src/init/executor.js +3 -14
- package/packages/@monomind/cli/dist/src/init/helpers-generator.js +2 -22
- package/packages/@monomind/cli/dist/src/init/settings-generator.js +0 -1
- package/packages/@monomind/cli/dist/src/init/types.d.ts +1 -3
- package/packages/@monomind/cli/dist/src/init/types.js +0 -2
- package/packages/@monomind/cli/dist/src/mcp-client.js +0 -6
- package/packages/@monomind/cli/dist/src/mcp-server.js +16 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +0 -17
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/causal-infer.d.ts +5 -5
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/causal-infer.js +32 -46
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/consensus-verify.d.ts +2 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/consensus-verify.js +22 -20
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/memory-gate.d.ts +3 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/memory-gate.js +32 -19
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/quantum-topology.d.ts +4 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/quantum-topology.js +11 -17
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/spectral-analyze.d.ts +2 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/spectral-analyze.js +51 -32
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/types.d.ts +5 -9
- package/packages/@monomind/cli/dist/src/mcp-tools/guidance-tools.js +2 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +25 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-routing.d.ts +0 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-routing.js +45 -159
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-tools.js +1 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/index.d.ts +0 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/index.js +0 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/memory-tools.js +24 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +452 -7
- package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.d.ts +4 -10
- package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.js +28 -54
- package/packages/@monomind/cli/dist/src/mcp-tools/performance-tools.js +5 -17
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js +2 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +4 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/quality-tools.d.ts +7 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/quality-tools.js +7 -257
- package/packages/@monomind/cli/dist/src/memory/intelligence.d.ts +7 -8
- package/packages/@monomind/cli/dist/src/memory/intelligence.js +15 -16
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.d.ts +1 -0
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +37 -0
- package/packages/@monomind/cli/dist/src/services/worker-daemon.d.ts +3 -21
- package/packages/@monomind/cli/dist/src/services/worker-daemon.js +13 -80
- package/packages/@monomind/cli/dist/src/suggest.js +0 -5
- package/packages/@monomind/cli/package.json +1 -1
- package/packages/@monomind/guidance/README.md +49 -1153
- package/packages/@monomind/guidance/package.json +1 -74
- package/.claude/helpers/auto-memory-hook.mjs +0 -503
- package/packages/@monomind/cli/.claude/helpers/auto-memory-hook.mjs +0 -503
- package/packages/@monomind/cli/dist/src/commands/deployment.d.ts +0 -10
- package/packages/@monomind/cli/dist/src/commands/deployment.js +0 -706
|
@@ -1,503 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Auto Memory Bridge Hook (ADR-048/049)
|
|
4
|
-
*
|
|
5
|
-
* Wires AutoMemoryBridge + LearningBridge + MemoryGraph into Claude Code
|
|
6
|
-
* session lifecycle. Called by settings.json SessionStart/SessionEnd hooks.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* node auto-memory-hook.mjs import # SessionStart: import auto memory files into backend
|
|
10
|
-
* node auto-memory-hook.mjs sync # SessionEnd: sync insights back to MEMORY.md
|
|
11
|
-
* node auto-memory-hook.mjs status # Show bridge status
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { existsSync, mkdirSync, openSync, closeSync, unlinkSync, readFileSync, writeFileSync, renameSync, statSync } from 'fs';
|
|
15
|
-
import { join, dirname } from 'path';
|
|
16
|
-
import { fileURLToPath } from 'url';
|
|
17
|
-
|
|
18
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
19
|
-
const __dirname = dirname(__filename);
|
|
20
|
-
const PROJECT_ROOT = join(__dirname, '../..');
|
|
21
|
-
const DATA_DIR = join(PROJECT_ROOT, '.monomind', 'data');
|
|
22
|
-
const STORE_PATH = join(DATA_DIR, 'auto-memory-store.json');
|
|
23
|
-
|
|
24
|
-
// Colors
|
|
25
|
-
const GREEN = '\x1b[0;32m';
|
|
26
|
-
const CYAN = '\x1b[0;36m';
|
|
27
|
-
const DIM = '\x1b[2m';
|
|
28
|
-
const RESET = '\x1b[0m';
|
|
29
|
-
|
|
30
|
-
const log = (msg) => console.log(`${CYAN}[AutoMemory] ${msg}${RESET}`);
|
|
31
|
-
const success = (msg) => console.log(`${GREEN}[AutoMemory] ✓ ${msg}${RESET}`);
|
|
32
|
-
const dim = (msg) => console.log(` ${DIM}${msg}${RESET}`);
|
|
33
|
-
|
|
34
|
-
// Ensure data dir
|
|
35
|
-
if (!existsSync(DATA_DIR)) mkdirSync(DATA_DIR, { recursive: true });
|
|
36
|
-
|
|
37
|
-
// ============================================================================
|
|
38
|
-
// File-lock helper for concurrent hook coordination
|
|
39
|
-
// Uses O_EXCL exclusive-create as a spin lock.
|
|
40
|
-
// A 10ms synchronous wait (via Atomics.wait) is used between retries to avoid
|
|
41
|
-
// pegging the CPU. Acceptable for low-contention hook processes.
|
|
42
|
-
// ============================================================================
|
|
43
|
-
|
|
44
|
-
function withFileLock(lockPath, fn, timeoutMs = 5000) {
|
|
45
|
-
const start = Date.now();
|
|
46
|
-
const sharedBuf = new Int32Array(new SharedArrayBuffer(4));
|
|
47
|
-
while (true) {
|
|
48
|
-
try {
|
|
49
|
-
// O_EXCL: exclusive create — fails atomically if file already exists
|
|
50
|
-
const fd = openSync(lockPath, 'wx');
|
|
51
|
-
closeSync(fd);
|
|
52
|
-
break; // acquired lock
|
|
53
|
-
} catch {
|
|
54
|
-
if (Date.now() - start > timeoutMs) {
|
|
55
|
-
// Timeout: proceed without lock rather than deadlocking hook processes
|
|
56
|
-
try { fn(); } catch { /* best effort */ }
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
// Synchronous 10ms sleep via Atomics.wait (avoids busy-spin CPU peg)
|
|
60
|
-
Atomics.wait(sharedBuf, 0, 0, 10);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
try { fn(); } finally {
|
|
64
|
-
try { unlinkSync(lockPath); } catch { /* ignore */ }
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// ============================================================================
|
|
69
|
-
// Simple JSON File Backend (implements IMemoryBackend interface)
|
|
70
|
-
// ============================================================================
|
|
71
|
-
|
|
72
|
-
class JsonFileBackend {
|
|
73
|
-
constructor(filePath) {
|
|
74
|
-
this.filePath = filePath;
|
|
75
|
-
this.entries = new Map();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async initialize() {
|
|
79
|
-
if (existsSync(this.filePath)) {
|
|
80
|
-
try {
|
|
81
|
-
const MAX_STORE_BYTES = 50 * 1024 * 1024; // 50 MiB
|
|
82
|
-
if (statSync(this.filePath).size > MAX_STORE_BYTES) return;
|
|
83
|
-
const data = JSON.parse(readFileSync(this.filePath, 'utf-8'));
|
|
84
|
-
if (Array.isArray(data)) {
|
|
85
|
-
for (const entry of data) this.entries.set(entry.id, entry);
|
|
86
|
-
}
|
|
87
|
-
} catch { /* start fresh */ }
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async shutdown() { this._persist(); }
|
|
92
|
-
async store(entry) { this.entries.set(entry.id, entry); this._persist(); }
|
|
93
|
-
async get(id) { return this.entries.get(id) ?? null; }
|
|
94
|
-
async getByKey(key, ns) {
|
|
95
|
-
for (const e of this.entries.values()) {
|
|
96
|
-
if (e.key === key && (!ns || e.namespace === ns)) return e;
|
|
97
|
-
}
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
async update(id, updates) {
|
|
101
|
-
const e = this.entries.get(id);
|
|
102
|
-
if (!e) return null;
|
|
103
|
-
if (updates.metadata) Object.assign(e.metadata, updates.metadata);
|
|
104
|
-
if (updates.content !== undefined) e.content = updates.content;
|
|
105
|
-
if (updates.tags) e.tags = updates.tags;
|
|
106
|
-
e.updatedAt = Date.now();
|
|
107
|
-
this._persist();
|
|
108
|
-
return e;
|
|
109
|
-
}
|
|
110
|
-
async delete(id) { return this.entries.delete(id); }
|
|
111
|
-
async query(opts) {
|
|
112
|
-
let results = [...this.entries.values()];
|
|
113
|
-
if (opts?.namespace) results = results.filter(e => e.namespace === opts.namespace);
|
|
114
|
-
if (opts?.type) results = results.filter(e => e.type === opts.type);
|
|
115
|
-
if (opts?.limit) results = results.slice(0, opts.limit);
|
|
116
|
-
return results;
|
|
117
|
-
}
|
|
118
|
-
async search() { return []; } // No vector search in JSON backend
|
|
119
|
-
async bulkInsert(entries) { for (const e of entries) this.entries.set(e.id, e); this._persist(); }
|
|
120
|
-
async bulkDelete(ids) { let n = 0; for (const id of ids) { if (this.entries.delete(id)) n++; } this._persist(); return n; }
|
|
121
|
-
async count() { return this.entries.size; }
|
|
122
|
-
async listNamespaces() {
|
|
123
|
-
const ns = new Set();
|
|
124
|
-
for (const e of this.entries.values()) ns.add(e.namespace || 'default');
|
|
125
|
-
return [...ns];
|
|
126
|
-
}
|
|
127
|
-
async clearNamespace(ns) {
|
|
128
|
-
let n = 0;
|
|
129
|
-
for (const [id, e] of this.entries) {
|
|
130
|
-
if (e.namespace === ns) { this.entries.delete(id); n++; }
|
|
131
|
-
}
|
|
132
|
-
this._persist();
|
|
133
|
-
return n;
|
|
134
|
-
}
|
|
135
|
-
async getStats() {
|
|
136
|
-
return {
|
|
137
|
-
totalEntries: this.entries.size,
|
|
138
|
-
entriesByNamespace: {},
|
|
139
|
-
entriesByType: { semantic: 0, episodic: 0, procedural: 0, working: 0, cache: 0 },
|
|
140
|
-
memoryUsage: 0, avgQueryTime: 0, avgSearchTime: 0,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
async healthCheck() {
|
|
144
|
-
return {
|
|
145
|
-
status: 'healthy',
|
|
146
|
-
components: {
|
|
147
|
-
storage: { status: 'healthy', latency: 0 },
|
|
148
|
-
index: { status: 'healthy', latency: 0 },
|
|
149
|
-
cache: { status: 'healthy', latency: 0 },
|
|
150
|
-
},
|
|
151
|
-
timestamp: Date.now(), issues: [], recommendations: [],
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
_persist() {
|
|
156
|
-
const lockPath = this.filePath + '.lock';
|
|
157
|
-
withFileLock(lockPath, () => {
|
|
158
|
-
const data = JSON.stringify([...this.entries.values()], null, 2);
|
|
159
|
-
const tmpPath = this.filePath + '.tmp';
|
|
160
|
-
writeFileSync(tmpPath, data, 'utf-8');
|
|
161
|
-
renameSync(tmpPath, this.filePath);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// ============================================================================
|
|
167
|
-
// Resolve memory package path (local dev or npm installed)
|
|
168
|
-
// ============================================================================
|
|
169
|
-
|
|
170
|
-
async function loadMemoryPackage() {
|
|
171
|
-
// Strategy 1: Local dev (built dist)
|
|
172
|
-
const localDist = join(PROJECT_ROOT, 'packages/@monomind/memory/dist/index.js');
|
|
173
|
-
if (existsSync(localDist)) {
|
|
174
|
-
try {
|
|
175
|
-
return await import(`file://${localDist}`);
|
|
176
|
-
} catch { /* fall through */ }
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Strategy 2: Use createRequire for CJS-style resolution (handles nested node_modules
|
|
180
|
-
// when installed as a transitive dependency via npx monomind / npx monomind)
|
|
181
|
-
try {
|
|
182
|
-
const { createRequire } = await import('module');
|
|
183
|
-
const require = createRequire(join(PROJECT_ROOT, 'package.json'));
|
|
184
|
-
return require('@monomind/memory');
|
|
185
|
-
} catch { /* fall through */ }
|
|
186
|
-
|
|
187
|
-
// Strategy 3: ESM import (works when @monomind/memory is a direct dependency)
|
|
188
|
-
try {
|
|
189
|
-
return await import('@monomind/memory');
|
|
190
|
-
} catch { /* fall through */ }
|
|
191
|
-
|
|
192
|
-
// Strategy 4: Walk up from PROJECT_ROOT looking for @monomind/memory in any node_modules
|
|
193
|
-
let searchDir = PROJECT_ROOT;
|
|
194
|
-
const { parse } = await import('path');
|
|
195
|
-
while (searchDir !== parse(searchDir).root) {
|
|
196
|
-
const candidate = join(searchDir, 'node_modules', '@monoes', 'memory', 'dist', 'index.js');
|
|
197
|
-
if (existsSync(candidate)) {
|
|
198
|
-
try {
|
|
199
|
-
return await import(`file://${candidate}`);
|
|
200
|
-
} catch { /* fall through */ }
|
|
201
|
-
}
|
|
202
|
-
searchDir = dirname(searchDir);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return null;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// ============================================================================
|
|
209
|
-
// Read config from .monomind/config.yaml
|
|
210
|
-
// ============================================================================
|
|
211
|
-
|
|
212
|
-
function readConfig() {
|
|
213
|
-
const configPath = join(PROJECT_ROOT, '.monomind', 'config.yaml');
|
|
214
|
-
const defaults = {
|
|
215
|
-
learningBridge: { enabled: true, sonaMode: 'balanced', confidenceDecayRate: 0.005, accessBoostAmount: 0.03, consolidationThreshold: 10 },
|
|
216
|
-
memoryGraph: { enabled: true, pageRankDamping: 0.85, maxNodes: 5000, similarityThreshold: 0.8 },
|
|
217
|
-
agentScopes: { enabled: true, defaultScope: 'project' },
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
if (!existsSync(configPath)) return defaults;
|
|
221
|
-
|
|
222
|
-
try {
|
|
223
|
-
const MAX_CONFIG_BYTES = 1 * 1024 * 1024; // 1 MiB
|
|
224
|
-
if (statSync(configPath).size > MAX_CONFIG_BYTES) return defaults;
|
|
225
|
-
const yaml = readFileSync(configPath, 'utf-8');
|
|
226
|
-
// Simple YAML parser for the memory section
|
|
227
|
-
const getBool = (key) => {
|
|
228
|
-
const match = yaml.match(new RegExp(`${key}:\\s*(true|false)`, 'i'));
|
|
229
|
-
return match ? match[1] === 'true' : undefined;
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
const lbEnabled = getBool('learningBridge[\\s\\S]*?enabled');
|
|
233
|
-
if (lbEnabled !== undefined) defaults.learningBridge.enabled = lbEnabled;
|
|
234
|
-
|
|
235
|
-
const mgEnabled = getBool('memoryGraph[\\s\\S]*?enabled');
|
|
236
|
-
if (mgEnabled !== undefined) defaults.memoryGraph.enabled = mgEnabled;
|
|
237
|
-
|
|
238
|
-
const asEnabled = getBool('agentScopes[\\s\\S]*?enabled');
|
|
239
|
-
if (asEnabled !== undefined) defaults.agentScopes.enabled = asEnabled;
|
|
240
|
-
|
|
241
|
-
return defaults;
|
|
242
|
-
} catch {
|
|
243
|
-
return defaults;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// ============================================================================
|
|
248
|
-
// Commands
|
|
249
|
-
// ============================================================================
|
|
250
|
-
|
|
251
|
-
async function doImport() {
|
|
252
|
-
log('Importing auto memory files into bridge...');
|
|
253
|
-
|
|
254
|
-
const memPkg = await loadMemoryPackage();
|
|
255
|
-
if (!memPkg || !memPkg.AutoMemoryBridge) {
|
|
256
|
-
dim('Memory package not available — skipping auto memory import');
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
const config = readConfig();
|
|
261
|
-
const backend = new JsonFileBackend(STORE_PATH);
|
|
262
|
-
await backend.initialize();
|
|
263
|
-
|
|
264
|
-
const bridgeConfig = {
|
|
265
|
-
workingDir: PROJECT_ROOT,
|
|
266
|
-
syncMode: 'on-session-end',
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
// Wire learning if enabled and available
|
|
270
|
-
if (config.learningBridge.enabled && memPkg.LearningBridge) {
|
|
271
|
-
bridgeConfig.learning = {
|
|
272
|
-
sonaMode: config.learningBridge.sonaMode,
|
|
273
|
-
confidenceDecayRate: config.learningBridge.confidenceDecayRate,
|
|
274
|
-
accessBoostAmount: config.learningBridge.accessBoostAmount,
|
|
275
|
-
consolidationThreshold: config.learningBridge.consolidationThreshold,
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// Wire graph if enabled and available
|
|
280
|
-
if (config.memoryGraph.enabled && memPkg.MemoryGraph) {
|
|
281
|
-
bridgeConfig.graph = {
|
|
282
|
-
pageRankDamping: config.memoryGraph.pageRankDamping,
|
|
283
|
-
maxNodes: config.memoryGraph.maxNodes,
|
|
284
|
-
similarityThreshold: config.memoryGraph.similarityThreshold,
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
const bridge = new memPkg.AutoMemoryBridge(backend, bridgeConfig);
|
|
289
|
-
|
|
290
|
-
// Wire episodic store so [memory:*] ops flow into traces during import
|
|
291
|
-
if (memPkg.EpisodicStore) {
|
|
292
|
-
try {
|
|
293
|
-
const episodicPath = join(PROJECT_ROOT, '.monomind', 'episodic', 'episodes.jsonl');
|
|
294
|
-
const episodicDir = dirname(episodicPath);
|
|
295
|
-
if (!existsSync(episodicDir)) mkdirSync(episodicDir, { recursive: true });
|
|
296
|
-
const epStore = new memPkg.EpisodicStore({ filePath: episodicPath, maxRunsPerEpisode: 20 });
|
|
297
|
-
bridge.setEpisodicStore(epStore);
|
|
298
|
-
} catch { /* non-fatal */ }
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
try {
|
|
302
|
-
const result = await bridge.importFromAutoMemory();
|
|
303
|
-
success(`Imported ${result.imported} entries (${result.skipped} skipped)`);
|
|
304
|
-
dim(`├─ Backend entries: ${await backend.count()}`);
|
|
305
|
-
dim(`├─ Learning: ${config.learningBridge.enabled ? 'active' : 'disabled'}`);
|
|
306
|
-
dim(`├─ Graph: ${config.memoryGraph.enabled ? 'active' : 'disabled'}`);
|
|
307
|
-
dim(`└─ Agent scopes: ${config.agentScopes.enabled ? 'active' : 'disabled'}`);
|
|
308
|
-
} catch (err) {
|
|
309
|
-
dim(`Import failed (non-critical): ${err.message}`);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// Second Brain: re-index new/changed documents on session start
|
|
313
|
-
try {
|
|
314
|
-
const capFile = join(PROJECT_ROOT, '.monomind', 'capabilities.json');
|
|
315
|
-
if (existsSync(capFile)) {
|
|
316
|
-
const caps = JSON.parse(readFileSync(capFile, 'utf-8'));
|
|
317
|
-
const hasDocsCap = Array.isArray(caps) ? caps.includes('documents') : (caps && caps.documents);
|
|
318
|
-
if (hasDocsCap) {
|
|
319
|
-
const { ingestDirectory } = await import(join(PROJECT_ROOT, 'packages/@monomind/cli/dist/src/knowledge/document-pipeline.js'));
|
|
320
|
-
const docResult = await ingestDirectory(PROJECT_ROOT, 'shared', { rootDir: PROJECT_ROOT });
|
|
321
|
-
if (docResult.filesProcessed > 0) {
|
|
322
|
-
dim(`├─ Second Brain: indexed ${docResult.totalChunks} new chunks from ${docResult.filesProcessed} docs`);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
} catch { /* non-fatal — knowledge indexing is best-effort */ }
|
|
327
|
-
|
|
328
|
-
await backend.shutdown();
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
async function doSync() {
|
|
332
|
-
log('Syncing insights to auto memory files...');
|
|
333
|
-
|
|
334
|
-
const memPkg = await loadMemoryPackage();
|
|
335
|
-
if (!memPkg || !memPkg.AutoMemoryBridge) {
|
|
336
|
-
dim('Memory package not available — skipping sync');
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
const config = readConfig();
|
|
341
|
-
const backend = new JsonFileBackend(STORE_PATH);
|
|
342
|
-
await backend.initialize();
|
|
343
|
-
|
|
344
|
-
const entryCount = await backend.count();
|
|
345
|
-
if (entryCount === 0) {
|
|
346
|
-
dim('No entries to sync');
|
|
347
|
-
await backend.shutdown();
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
const bridgeConfig = {
|
|
352
|
-
workingDir: PROJECT_ROOT,
|
|
353
|
-
syncMode: 'on-session-end',
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
if (config.learningBridge.enabled && memPkg.LearningBridge) {
|
|
357
|
-
bridgeConfig.learning = {
|
|
358
|
-
sonaMode: config.learningBridge.sonaMode,
|
|
359
|
-
confidenceDecayRate: config.learningBridge.confidenceDecayRate,
|
|
360
|
-
consolidationThreshold: config.learningBridge.consolidationThreshold,
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
if (config.memoryGraph.enabled && memPkg.MemoryGraph) {
|
|
365
|
-
bridgeConfig.graph = {
|
|
366
|
-
pageRankDamping: config.memoryGraph.pageRankDamping,
|
|
367
|
-
maxNodes: config.memoryGraph.maxNodes,
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
const bridge = new memPkg.AutoMemoryBridge(backend, bridgeConfig);
|
|
372
|
-
|
|
373
|
-
// Wire episodic store so [memory:*] ops flow into traces during sync
|
|
374
|
-
if (memPkg.EpisodicStore) {
|
|
375
|
-
try {
|
|
376
|
-
const episodicPath = join(PROJECT_ROOT, '.monomind', 'episodic', 'episodes.jsonl');
|
|
377
|
-
if (existsSync(dirname(episodicPath))) {
|
|
378
|
-
const epStore = new memPkg.EpisodicStore({ filePath: episodicPath, maxRunsPerEpisode: 20 });
|
|
379
|
-
bridge.setEpisodicStore(epStore);
|
|
380
|
-
}
|
|
381
|
-
} catch { /* non-fatal */ }
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
try {
|
|
385
|
-
const syncResult = await bridge.syncToAutoMemory();
|
|
386
|
-
success(`Synced ${syncResult.synced} entries to auto memory`);
|
|
387
|
-
dim(`├─ Categories updated: ${syncResult.categories?.join(', ') || 'none'}`);
|
|
388
|
-
dim(`└─ Backend entries: ${entryCount}`);
|
|
389
|
-
|
|
390
|
-
// Curate MEMORY.md index with graph-aware ordering
|
|
391
|
-
await bridge.curateIndex();
|
|
392
|
-
success('Curated MEMORY.md index');
|
|
393
|
-
} catch (err) {
|
|
394
|
-
dim(`Sync failed (non-critical): ${err.message}`);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
if (bridge.destroy) bridge.destroy();
|
|
398
|
-
await backend.shutdown();
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
async function doStatus() {
|
|
402
|
-
const memPkg = await loadMemoryPackage();
|
|
403
|
-
const config = readConfig();
|
|
404
|
-
|
|
405
|
-
console.log('\n=== Auto Memory Bridge Status ===\n');
|
|
406
|
-
console.log(` Package: ${memPkg ? '✅ Available' : '❌ Not found'}`);
|
|
407
|
-
console.log(` Store: ${existsSync(STORE_PATH) ? '✅ ' + STORE_PATH : '⏸ Not initialized'}`);
|
|
408
|
-
console.log(` LearningBridge: ${config.learningBridge.enabled ? '✅ Enabled' : '⏸ Disabled'}`);
|
|
409
|
-
console.log(` MemoryGraph: ${config.memoryGraph.enabled ? '✅ Enabled' : '⏸ Disabled'}`);
|
|
410
|
-
console.log(` AgentScopes: ${config.agentScopes.enabled ? '✅ Enabled' : '⏸ Disabled'}`);
|
|
411
|
-
|
|
412
|
-
if (existsSync(STORE_PATH)) {
|
|
413
|
-
try {
|
|
414
|
-
const MAX_STORE_BYTES = 50 * 1024 * 1024; // 50 MiB
|
|
415
|
-
if (statSync(STORE_PATH).size <= MAX_STORE_BYTES) {
|
|
416
|
-
const data = JSON.parse(readFileSync(STORE_PATH, 'utf-8'));
|
|
417
|
-
console.log(` Entries: ${Array.isArray(data) ? data.length : 0}`);
|
|
418
|
-
} else {
|
|
419
|
-
console.log(` Entries: (store too large to count)`);
|
|
420
|
-
}
|
|
421
|
-
} catch { /* ignore */ }
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
// AutoMem diagnostics (arXiv:2607.01224)
|
|
425
|
-
console.log('\n=== AutoMem Learning Loop Status ===\n');
|
|
426
|
-
|
|
427
|
-
// Episodic trace stats
|
|
428
|
-
const episodicPath = join(PROJECT_ROOT, '.monomind', 'episodic', 'episodes.jsonl');
|
|
429
|
-
if (existsSync(episodicPath) && memPkg && memPkg.EpisodicStore) {
|
|
430
|
-
try {
|
|
431
|
-
const epStore = new memPkg.EpisodicStore({ filePath: episodicPath, maxRunsPerEpisode: 20 });
|
|
432
|
-
const episodes = epStore.readAll();
|
|
433
|
-
let memOps = 0, skipDups = 0, writes = 0, searches = 0;
|
|
434
|
-
for (const ep of episodes) {
|
|
435
|
-
for (const line of (ep.summary || '').split('\n')) {
|
|
436
|
-
if (line.startsWith('[memory:')) {
|
|
437
|
-
memOps++;
|
|
438
|
-
if (line.includes('skip-duplicate')) skipDups++;
|
|
439
|
-
else if (line.includes('write]')) writes++;
|
|
440
|
-
else if (line.includes('search]')) searches++;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
console.log(` Episodes: ${episodes.length}`);
|
|
445
|
-
console.log(` Memory ops: ${memOps} (${writes} writes, ${searches} searches, ${skipDups} skipped dups)`);
|
|
446
|
-
if (writes + searches > 0) {
|
|
447
|
-
const ratio = searches > 0 ? (writes / searches).toFixed(2) : 'N/A';
|
|
448
|
-
const dupRate = memOps > 0 ? Math.round(skipDups / memOps * 100) : 0;
|
|
449
|
-
console.log(` Write/search: ${ratio} | Dup rate: ${dupRate}%`);
|
|
450
|
-
}
|
|
451
|
-
} catch { console.log(' Episodes: (error reading)'); }
|
|
452
|
-
} else {
|
|
453
|
-
console.log(' Episodes: ⏸ No episodic traces yet');
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
// Scaffold optimizer history
|
|
457
|
-
const scaffoldPath = join(PROJECT_ROOT, '.monomind', 'data', 'scaffold-revisions.jsonl');
|
|
458
|
-
if (existsSync(scaffoldPath)) {
|
|
459
|
-
try {
|
|
460
|
-
const lines = readFileSync(scaffoldPath, 'utf-8').trim().split('\n').filter(Boolean);
|
|
461
|
-
console.log(` Scaffold revs: ${lines.length} revision(s) applied`);
|
|
462
|
-
} catch { /* ignore */ }
|
|
463
|
-
} else {
|
|
464
|
-
console.log(' Scaffold revs: ⏸ No revisions yet');
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// Curated decisions
|
|
468
|
-
const backend2 = new JsonFileBackend(STORE_PATH);
|
|
469
|
-
await backend2.initialize();
|
|
470
|
-
try {
|
|
471
|
-
const curated = await backend2.query({ namespace: 'memory-training', limit: 10000 });
|
|
472
|
-
console.log(` Curated: ${curated.length} training decision(s)`);
|
|
473
|
-
} catch { console.log(' Curated: ⏸ No curated decisions'); }
|
|
474
|
-
await backend2.shutdown();
|
|
475
|
-
|
|
476
|
-
console.log('');
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
// ============================================================================
|
|
480
|
-
// Main
|
|
481
|
-
// ============================================================================
|
|
482
|
-
|
|
483
|
-
const command = process.argv[2] || 'status';
|
|
484
|
-
|
|
485
|
-
// Suppress unhandled rejection warnings from dynamic import() failures
|
|
486
|
-
// which can cause non-zero exit codes even when caught
|
|
487
|
-
process.once('unhandledRejection', () => {});
|
|
488
|
-
|
|
489
|
-
try {
|
|
490
|
-
switch (command) {
|
|
491
|
-
case 'import': await doImport(); break;
|
|
492
|
-
case 'sync': await doSync(); break;
|
|
493
|
-
case 'status': await doStatus(); break;
|
|
494
|
-
default:
|
|
495
|
-
console.log('Usage: auto-memory-hook.mjs <import|sync|status>');
|
|
496
|
-
process.exit(1);
|
|
497
|
-
}
|
|
498
|
-
} catch (err) {
|
|
499
|
-
// Hooks must never crash Claude Code - fail silently
|
|
500
|
-
dim(`Error (non-critical): ${err.message}`);
|
|
501
|
-
}
|
|
502
|
-
// Ensure clean exit for Claude Code hooks (exit 0 = success, no stderr = no error)
|
|
503
|
-
process.exit(0);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI Deployment Command
|
|
3
|
-
* Deployment management, environments, rollbacks
|
|
4
|
-
*
|
|
5
|
-
* github.com/monoes/monomind
|
|
6
|
-
*/
|
|
7
|
-
import type { Command } from '../types.js';
|
|
8
|
-
export declare const deploymentCommand: Command;
|
|
9
|
-
export default deploymentCommand;
|
|
10
|
-
//# sourceMappingURL=deployment.d.ts.map
|