monomind 2.2.0 → 2.3.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/package.json +2 -2
- package/packages/@monomind/cli/.claude/commands/mastermind/createorg.md +24 -16
- package/packages/@monomind/cli/.claude/commands/mastermind/master.md +23 -7
- package/packages/@monomind/cli/.claude/commands/mastermind/runorg.md +3 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/stoporg.md +6 -3
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/code-quality-reviewer-prompt.md +3 -3
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/createorg.md +19 -24
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/debug.md +49 -4
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/design.md +11 -10
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/final-reviewer-prompt.md +144 -0
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/implementer-prompt.md +9 -4
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/org-settings.md +20 -2
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/orgs.md +40 -19
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/orgstatus.md +90 -41
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/plan.md +19 -0
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/skill-builder.md +171 -0
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/spec-reviewer-prompt.md +19 -2
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/stoporg.md +7 -5
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/taskdev.md +83 -15
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/tdd.md +30 -0
- package/packages/@monomind/cli/dist/src/autopilot-state.js +6 -4
- package/packages/@monomind/cli/dist/src/browser/dashboard/server.js +4 -1
- package/packages/@monomind/cli/dist/src/capabilities/manager.js +3 -1
- package/packages/@monomind/cli/dist/src/commands/agent-lifecycle.js +26 -0
- package/packages/@monomind/cli/dist/src/commands/agent-ops.js +28 -46
- package/packages/@monomind/cli/dist/src/commands/cleanup.d.ts +18 -0
- package/packages/@monomind/cli/dist/src/commands/cleanup.js +120 -0
- package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.js +13 -4
- package/packages/@monomind/cli/dist/src/commands/hooks-routing-commands.js +34 -18
- package/packages/@monomind/cli/dist/src/commands/hooks-workers.js +8 -2
- package/packages/@monomind/cli/dist/src/commands/hooks.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/mcp.js +4 -1
- package/packages/@monomind/cli/dist/src/commands/memory-admin.js +7 -1
- package/packages/@monomind/cli/dist/src/commands/org-observe.d.ts +18 -0
- package/packages/@monomind/cli/dist/src/commands/org-observe.js +295 -0
- package/packages/@monomind/cli/dist/src/commands/org.d.ts +9 -1
- package/packages/@monomind/cli/dist/src/commands/org.js +191 -9
- package/packages/@monomind/cli/dist/src/commands/performance.js +4 -1
- package/packages/@monomind/cli/dist/src/commands/platforms.js +4 -1
- package/packages/@monomind/cli/dist/src/commands/security-scan.js +8 -2
- package/packages/@monomind/cli/dist/src/commands/start.js +4 -1
- package/packages/@monomind/cli/dist/src/commands/swarm.js +3 -2
- package/packages/@monomind/cli/dist/src/index.js +13 -3
- package/packages/@monomind/cli/dist/src/init/executor.js +19 -5
- package/packages/@monomind/cli/dist/src/knowledge/document-pipeline.js +3 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.d.ts +1 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +63 -20
- package/packages/@monomind/cli/dist/src/mcp-tools/claims-tools.js +3 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/config-tools.js +3 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/daa-tools.js +3 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/embeddings-tools.js +6 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/github-tools.js +35 -10
- package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +24 -7
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-embedding.js +13 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-intelligence.js +9 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-routing.d.ts +1 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-routing.js +112 -10
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-tools.js +2 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +8 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/performance-tools.js +3 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/session-tools.js +15 -5
- package/packages/@monomind/cli/dist/src/mcp-tools/swarm-tools.js +4 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/system-tools.js +6 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/task-tools.d.ts +20 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/task-tools.js +38 -16
- package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.d.ts +2 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.js +41 -24
- package/packages/@monomind/cli/dist/src/memory/ewc-consolidation.js +6 -2
- package/packages/@monomind/cli/dist/src/memory/intelligence.js +32 -10
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +16 -4
- package/packages/@monomind/cli/dist/src/memory/memory-crud.js +26 -2
- package/packages/@monomind/cli/dist/src/memory/memory-initializer.js +3 -2
- package/packages/@monomind/cli/dist/src/memory/memory-migrations.js +2 -0
- package/packages/@monomind/cli/dist/src/monovector/command-outcomes.js +4 -1
- package/packages/@monomind/cli/dist/src/orgrt/bus.js +4 -1
- package/packages/@monomind/cli/dist/src/orgrt/daemon.js +74 -19
- package/packages/@monomind/cli/dist/src/orgrt/inbox.js +3 -1
- package/packages/@monomind/cli/dist/src/orgrt/reporting.d.ts +40 -0
- package/packages/@monomind/cli/dist/src/orgrt/reporting.js +127 -0
- package/packages/@monomind/cli/dist/src/orgrt/session.d.ts +2 -0
- package/packages/@monomind/cli/dist/src/orgrt/session.js +10 -2
- package/packages/@monomind/cli/dist/src/orgrt/templates.d.ts +16 -0
- package/packages/@monomind/cli/dist/src/orgrt/templates.js +57 -0
- package/packages/@monomind/cli/dist/src/services/config-file-manager.js +10 -1
- package/packages/@monomind/cli/dist/src/transfer/storage/gcs.js +6 -2
- package/packages/@monomind/cli/dist/src/ui/orgs.html +32 -0
- package/packages/@monomind/cli/dist/src/ui/server.mjs +25 -0
- package/packages/@monomind/cli/dist/src/update/executor.js +3 -1
- package/packages/@monomind/cli/dist/src/update/rate-limiter.js +3 -1
- package/packages/@monomind/cli/package.json +2 -2
|
@@ -28,8 +28,10 @@ function loadClaims() {
|
|
|
28
28
|
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
catch {
|
|
31
|
+
catch (e) {
|
|
32
32
|
// Return empty store on error
|
|
33
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
34
|
+
console.error('[claims-tools] failed to load claims.json, starting fresh:', e);
|
|
33
35
|
}
|
|
34
36
|
return { claims: {}, stealable: {}, contests: {} };
|
|
35
37
|
}
|
|
@@ -52,8 +52,9 @@ function loadConfigStore() {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
catch {
|
|
56
|
-
|
|
55
|
+
catch (e) {
|
|
56
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
57
|
+
console.error('[config-tools] failed to load config store, using defaults:', e);
|
|
57
58
|
}
|
|
58
59
|
return {
|
|
59
60
|
values: { ...DEFAULT_CONFIG },
|
|
@@ -40,8 +40,9 @@ function loadDAAStore() {
|
|
|
40
40
|
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
catch {
|
|
44
|
-
|
|
43
|
+
catch (e) {
|
|
44
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
45
|
+
console.error('[daa-tools] failed to load DAA store, using empty store:', e);
|
|
45
46
|
}
|
|
46
47
|
return { agents: {}, workflows: {}, knowledge: {}, version: '3.0.0' };
|
|
47
48
|
}
|
|
@@ -54,8 +54,10 @@ function loadConfig() {
|
|
|
54
54
|
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
catch {
|
|
57
|
+
catch (e) {
|
|
58
58
|
// Return null on error
|
|
59
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
60
|
+
console.error('[embeddings-tools] config read/parse failed:', e);
|
|
59
61
|
}
|
|
60
62
|
return null;
|
|
61
63
|
}
|
|
@@ -457,8 +459,10 @@ export const embeddingsTools = [
|
|
|
457
459
|
},
|
|
458
460
|
};
|
|
459
461
|
}
|
|
460
|
-
catch {
|
|
462
|
+
catch (e) {
|
|
461
463
|
// Database not available - return empty but truthful
|
|
464
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
465
|
+
console.error('[embeddings-tools] search failed:', e);
|
|
462
466
|
const searchTime = (performance.now() - startTime).toFixed(2);
|
|
463
467
|
return {
|
|
464
468
|
success: true,
|
|
@@ -31,8 +31,9 @@ function loadGitHubStore() {
|
|
|
31
31
|
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
catch {
|
|
35
|
-
|
|
34
|
+
catch (e) {
|
|
35
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
36
|
+
console.error('[github-tools] failed to parse store.json, using empty store:', e);
|
|
36
37
|
}
|
|
37
38
|
return { repos: {}, prs: {}, issues: {}, version: '3.0.0' };
|
|
38
39
|
}
|
|
@@ -199,7 +200,10 @@ export const githubTools = [
|
|
|
199
200
|
const prs = JSON.parse(raw);
|
|
200
201
|
return { success: true, _real: true, source: 'gh-cli', pullRequests: prs, total: prs.length };
|
|
201
202
|
}
|
|
202
|
-
catch {
|
|
203
|
+
catch (e) {
|
|
204
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
205
|
+
console.error('[github-tools] failed to parse gh pr list output:', e);
|
|
206
|
+
}
|
|
203
207
|
}
|
|
204
208
|
}
|
|
205
209
|
const prs = Object.values(store.prs);
|
|
@@ -247,7 +251,10 @@ export const githubTools = [
|
|
|
247
251
|
try {
|
|
248
252
|
return { success: true, _real: true, action: 'review', pullRequest: JSON.parse(raw) };
|
|
249
253
|
}
|
|
250
|
-
catch {
|
|
254
|
+
catch (e) {
|
|
255
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
256
|
+
console.error('[github-tools] failed to parse gh pr view output:', e);
|
|
257
|
+
}
|
|
251
258
|
}
|
|
252
259
|
}
|
|
253
260
|
return { success: false, error: 'gh CLI not available or PR not found. Install gh: https://cli.github.com' };
|
|
@@ -325,7 +332,10 @@ export const githubTools = [
|
|
|
325
332
|
const issues = JSON.parse(raw);
|
|
326
333
|
return { success: true, _real: true, source: 'gh-cli', issues, total: issues.length };
|
|
327
334
|
}
|
|
328
|
-
catch {
|
|
335
|
+
catch (e) {
|
|
336
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
337
|
+
console.error('[github-tools] failed to parse gh issue list output:', e);
|
|
338
|
+
}
|
|
329
339
|
}
|
|
330
340
|
}
|
|
331
341
|
const issues = Object.values(store.issues);
|
|
@@ -436,14 +446,20 @@ export const githubTools = [
|
|
|
436
446
|
try {
|
|
437
447
|
return { success: true, _real: true, runs: JSON.parse(raw) };
|
|
438
448
|
}
|
|
439
|
-
catch {
|
|
449
|
+
catch (e) {
|
|
450
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
451
|
+
console.error('[github-tools] failed to parse gh run list output:', e);
|
|
452
|
+
}
|
|
440
453
|
}
|
|
441
454
|
const workflows = run('gh workflow list --json id,name,state');
|
|
442
455
|
if (workflows) {
|
|
443
456
|
try {
|
|
444
457
|
return { success: true, _real: true, workflows: JSON.parse(workflows) };
|
|
445
458
|
}
|
|
446
|
-
catch {
|
|
459
|
+
catch (e) {
|
|
460
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
461
|
+
console.error('[github-tools] failed to parse gh workflow list output:', e);
|
|
462
|
+
}
|
|
447
463
|
}
|
|
448
464
|
}
|
|
449
465
|
if (action === 'status') {
|
|
@@ -454,7 +470,10 @@ export const githubTools = [
|
|
|
454
470
|
try {
|
|
455
471
|
return { success: true, _real: true, run: JSON.parse(raw) };
|
|
456
472
|
}
|
|
457
|
-
catch {
|
|
473
|
+
catch (e) {
|
|
474
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
475
|
+
console.error('[github-tools] failed to parse gh run view output:', e);
|
|
476
|
+
}
|
|
458
477
|
}
|
|
459
478
|
}
|
|
460
479
|
// List recent runs as fallback
|
|
@@ -463,7 +482,10 @@ export const githubTools = [
|
|
|
463
482
|
try {
|
|
464
483
|
return { success: true, _real: true, recentRuns: JSON.parse(recent) };
|
|
465
484
|
}
|
|
466
|
-
catch {
|
|
485
|
+
catch (e) {
|
|
486
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
487
|
+
console.error('[github-tools] failed to parse gh run list (recent) output:', e);
|
|
488
|
+
}
|
|
467
489
|
}
|
|
468
490
|
}
|
|
469
491
|
if (action === 'trigger') {
|
|
@@ -538,7 +560,10 @@ export const githubTools = [
|
|
|
538
560
|
try {
|
|
539
561
|
result.releases = JSON.parse(raw);
|
|
540
562
|
}
|
|
541
|
-
catch {
|
|
563
|
+
catch (e) {
|
|
564
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
565
|
+
console.error('[github-tools] failed to parse gh release list output:', e);
|
|
566
|
+
}
|
|
542
567
|
}
|
|
543
568
|
}
|
|
544
569
|
if (!result.releases) {
|
|
@@ -18,7 +18,7 @@ import { weightedTally } from '../consensus/tally.js';
|
|
|
18
18
|
// Reuse agent-tools.ts's hardened store loader (50MB size cap + __proto__
|
|
19
19
|
// rejection) instead of maintaining a second, weaker copy that reads the
|
|
20
20
|
// same physical file — see loadAgentStore export note there.
|
|
21
|
-
import { loadAgentStore } from './agent-tools.js';
|
|
21
|
+
import { loadAgentStore, loadAgentStoreOrNull } from './agent-tools.js';
|
|
22
22
|
// Storage paths
|
|
23
23
|
const STORAGE_DIR = '.monomind';
|
|
24
24
|
const HIVE_DIR = 'hive-mind';
|
|
@@ -117,8 +117,9 @@ function loadHiveState() {
|
|
|
117
117
|
return JSON.parse(data);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
catch {
|
|
121
|
-
|
|
120
|
+
catch (e) {
|
|
121
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
122
|
+
console.error('[hive-mind-tools] failed to parse hive state.json — resetting to default state:', e);
|
|
122
123
|
}
|
|
123
124
|
return {
|
|
124
125
|
initialized: false,
|
|
@@ -226,7 +227,13 @@ export const hiveMindTools = [
|
|
|
226
227
|
const rawPrefix = input.prefix || 'hive-worker';
|
|
227
228
|
const prefix = typeof rawPrefix === 'string' && rawPrefix.length > MAX_HIVE_PREFIX_LEN
|
|
228
229
|
? rawPrefix.slice(0, MAX_HIVE_PREFIX_LEN) : rawPrefix;
|
|
229
|
-
|
|
230
|
+
// Must use the null-aware loader here (this handler mutates and saves)
|
|
231
|
+
// — loadAgentStore() on a corrupt/oversized store.json now returns the
|
|
232
|
+
// empty default, and saving that back would wipe every real agent.
|
|
233
|
+
const agentStore = loadAgentStoreOrNull();
|
|
234
|
+
if (!agentStore) {
|
|
235
|
+
return { success: false, error: 'Agent store is unreadable/corrupt — refusing to spawn hive workers to avoid overwriting real agent data.' };
|
|
236
|
+
}
|
|
230
237
|
const spawnedWorkers = [];
|
|
231
238
|
for (let i = 0; i < count; i++) {
|
|
232
239
|
const agentId = `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
@@ -375,7 +382,10 @@ export const hiveMindTools = [
|
|
|
375
382
|
}
|
|
376
383
|
}
|
|
377
384
|
}
|
|
378
|
-
catch {
|
|
385
|
+
catch (e) {
|
|
386
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
387
|
+
console.error('[hive-mind-tools] failed to parse task store — task counts default to 0:', e);
|
|
388
|
+
}
|
|
379
389
|
const workerCount = Math.max(1, state.workers.length);
|
|
380
390
|
const realLoad = activeTaskCount / workerCount;
|
|
381
391
|
const status = {
|
|
@@ -1000,8 +1010,15 @@ export const hiveMindTools = [
|
|
|
1000
1010
|
workerCount,
|
|
1001
1011
|
};
|
|
1002
1012
|
}
|
|
1003
|
-
// Clear workers from agent store
|
|
1004
|
-
|
|
1013
|
+
// Clear workers from agent store. Must use the null-aware loader here
|
|
1014
|
+
// (this handler mutates and saves) — loadAgentStore() on a corrupt/
|
|
1015
|
+
// oversized store.json now returns the empty default, and deleting
|
|
1016
|
+
// from + saving that back would wipe every real agent, not just the
|
|
1017
|
+
// hive workers being shut down.
|
|
1018
|
+
const agentStore = loadAgentStoreOrNull();
|
|
1019
|
+
if (!agentStore) {
|
|
1020
|
+
return { success: false, error: 'Agent store is unreadable/corrupt — refusing to shut down to avoid overwriting real agent data.', pendingConsensus, workerCount };
|
|
1021
|
+
}
|
|
1005
1022
|
for (const workerId of state.workers) {
|
|
1006
1023
|
if (agentStore.agents[workerId]) {
|
|
1007
1024
|
delete agentStore.agents[workerId];
|
|
@@ -141,7 +141,11 @@ export function loadRoutingOutcomes() {
|
|
|
141
141
|
return data.outcomes || [];
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
catch {
|
|
144
|
+
catch (e) {
|
|
145
|
+
/* corrupt file, start fresh */
|
|
146
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
147
|
+
console.error('[hooks-embedding] routing-outcomes.json read/parse failed:', e);
|
|
148
|
+
}
|
|
145
149
|
return [];
|
|
146
150
|
}
|
|
147
151
|
export function saveRoutingOutcomes(outcomes) {
|
|
@@ -155,7 +159,11 @@ export function saveRoutingOutcomes(outcomes) {
|
|
|
155
159
|
writeFileSync(tmp, JSON.stringify({ outcomes: capped }, null, 2));
|
|
156
160
|
renameSync(tmp, getRoutingOutcomesPath());
|
|
157
161
|
}
|
|
158
|
-
catch {
|
|
162
|
+
catch (e) {
|
|
163
|
+
/* non-critical */
|
|
164
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
165
|
+
console.error('[hooks-embedding] routing-outcomes.json write failed:', e);
|
|
166
|
+
}
|
|
159
167
|
}
|
|
160
168
|
/**
|
|
161
169
|
* Build learned routing patterns from successful task outcomes.
|
|
@@ -265,8 +273,10 @@ export function loadMemoryStore() {
|
|
|
265
273
|
return JSON.parse(data);
|
|
266
274
|
}
|
|
267
275
|
}
|
|
268
|
-
catch {
|
|
276
|
+
catch (e) {
|
|
269
277
|
// Return empty store on error
|
|
278
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
279
|
+
console.error('[hooks-embedding] memory store.json read/parse failed:', e);
|
|
270
280
|
}
|
|
271
281
|
return { entries: {}, version: '3.0.0' };
|
|
272
282
|
}
|
|
@@ -260,9 +260,11 @@ export const hooksTrajectoryEnd = {
|
|
|
260
260
|
},
|
|
261
261
|
});
|
|
262
262
|
}
|
|
263
|
-
catch {
|
|
263
|
+
catch (e) {
|
|
264
264
|
// Non-fatal: intelligence bridge unavailable, trajectory is still
|
|
265
265
|
// persisted via the legacy store above.
|
|
266
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
267
|
+
console.error('[hooks-intelligence] intelligence bridge recordStep failed:', e);
|
|
266
268
|
}
|
|
267
269
|
}
|
|
268
270
|
// SONA Learning - process trajectory outcome for routing optimization
|
|
@@ -295,8 +297,10 @@ export const hooksTrajectoryEnd = {
|
|
|
295
297
|
confidence: result.confidence,
|
|
296
298
|
};
|
|
297
299
|
}
|
|
298
|
-
catch {
|
|
300
|
+
catch (e) {
|
|
299
301
|
// SONA learning failed, continue without it
|
|
302
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
303
|
+
console.error('[hooks-intelligence] SONA processTrajectoryOutcome failed:', e);
|
|
300
304
|
}
|
|
301
305
|
}
|
|
302
306
|
// Try EWC++ consolidation on successful trajectories
|
|
@@ -314,8 +318,10 @@ export const hooksTrajectoryEnd = {
|
|
|
314
318
|
penalty: stats.avgPenalty,
|
|
315
319
|
};
|
|
316
320
|
}
|
|
317
|
-
catch {
|
|
321
|
+
catch (e) {
|
|
318
322
|
// EWC consolidation failed, continue without it
|
|
323
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
324
|
+
console.error('[hooks-intelligence] EWC consolidation failed:', e);
|
|
319
325
|
}
|
|
320
326
|
}
|
|
321
327
|
}
|
|
@@ -20,6 +20,7 @@ export declare const hooksPretrain: MCPTool;
|
|
|
20
20
|
export declare const hooksBuildAgents: MCPTool;
|
|
21
21
|
export declare const hooksTransfer: MCPTool;
|
|
22
22
|
export declare const hooksSessionStart: MCPTool;
|
|
23
|
+
export declare const hooksSessionRestore: MCPTool;
|
|
23
24
|
export declare const hooksSessionEnd: MCPTool;
|
|
24
25
|
export declare const hooksIntelligence: MCPTool;
|
|
25
26
|
//# sourceMappingURL=hooks-routing.d.ts.map
|
|
@@ -97,8 +97,10 @@ export const hooksPostEdit = {
|
|
|
97
97
|
confidence: success ? 0.85 : 0.3,
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
-
catch {
|
|
100
|
+
catch (e) {
|
|
101
101
|
// Bridge not available — continue with basic response
|
|
102
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
103
|
+
console.error('[hooks-post-edit] memory bridge feedback failed:', e);
|
|
102
104
|
}
|
|
103
105
|
return {
|
|
104
106
|
recorded: true,
|
|
@@ -738,8 +740,10 @@ export const hooksPostTask = {
|
|
|
738
740
|
metadata: { taskId, duration: params.duration || undefined, patterns: params.patterns || undefined },
|
|
739
741
|
});
|
|
740
742
|
}
|
|
741
|
-
catch {
|
|
743
|
+
catch (e) {
|
|
742
744
|
// Bridge not available — continue with basic response
|
|
745
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
746
|
+
console.error('[hooks-post-task] memory bridge feedback failed:', e);
|
|
743
747
|
}
|
|
744
748
|
// Phase 3: Record causal edge (task → outcome)
|
|
745
749
|
try {
|
|
@@ -751,8 +755,10 @@ export const hooksPostTask = {
|
|
|
751
755
|
strength: quality,
|
|
752
756
|
});
|
|
753
757
|
}
|
|
754
|
-
catch {
|
|
758
|
+
catch (e) {
|
|
755
759
|
// Non-fatal
|
|
760
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
761
|
+
console.error('[hooks-post-task] causal edge record failed:', e);
|
|
756
762
|
}
|
|
757
763
|
// Persist routing outcome for runtime learning (file-based, always reliable).
|
|
758
764
|
// B1.3: also gate this sibling learning sink on a known outcome — an unverified
|
|
@@ -938,8 +944,10 @@ export const hooksExplain = {
|
|
|
938
944
|
}
|
|
939
945
|
}
|
|
940
946
|
}
|
|
941
|
-
catch {
|
|
942
|
-
// File unreadable; leave as null
|
|
947
|
+
catch (e) {
|
|
948
|
+
// File unreadable or corrupt; leave as null
|
|
949
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
950
|
+
console.error('[hooks-explain] routing outcomes file read/parse failed:', e);
|
|
943
951
|
}
|
|
944
952
|
return {
|
|
945
953
|
task,
|
|
@@ -1059,7 +1067,11 @@ export const hooksPretrain = {
|
|
|
1059
1067
|
});
|
|
1060
1068
|
patternsStored = patterns.length;
|
|
1061
1069
|
}
|
|
1062
|
-
catch {
|
|
1070
|
+
catch (e) {
|
|
1071
|
+
/* memory backend unavailable */
|
|
1072
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
1073
|
+
console.error('[hooks-pretrain] pattern store failed:', e);
|
|
1074
|
+
}
|
|
1063
1075
|
// Feed extracted import patterns into the neural training system so
|
|
1064
1076
|
// pretrain actually trains, not just scans.
|
|
1065
1077
|
let neuralPatternsLearned = 0;
|
|
@@ -1077,7 +1089,11 @@ export const hooksPretrain = {
|
|
|
1077
1089
|
intel.flushPatterns();
|
|
1078
1090
|
neuralPatternsLearned = steps.length;
|
|
1079
1091
|
}
|
|
1080
|
-
catch {
|
|
1092
|
+
catch (e) {
|
|
1093
|
+
/* intelligence not available */
|
|
1094
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
1095
|
+
console.error('[hooks-pretrain] intelligence training failed:', e);
|
|
1096
|
+
}
|
|
1081
1097
|
}
|
|
1082
1098
|
return {
|
|
1083
1099
|
success: true,
|
|
@@ -1215,8 +1231,10 @@ export const hooksTransfer = {
|
|
|
1215
1231
|
sourceStore = JSON.parse(readFileSync(sourceMemoryPath, 'utf-8'));
|
|
1216
1232
|
}
|
|
1217
1233
|
}
|
|
1218
|
-
catch {
|
|
1234
|
+
catch (e) {
|
|
1219
1235
|
// Fall back to empty store
|
|
1236
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
1237
|
+
console.error('[hooks-transfer] source memory store read/parse failed:', e);
|
|
1220
1238
|
}
|
|
1221
1239
|
const sourceEntries = Object.values(sourceStore.entries);
|
|
1222
1240
|
// Count patterns by type from source
|
|
@@ -1282,8 +1300,10 @@ export const hooksSessionStart = {
|
|
|
1282
1300
|
};
|
|
1283
1301
|
}
|
|
1284
1302
|
}
|
|
1285
|
-
catch {
|
|
1303
|
+
catch (e) {
|
|
1286
1304
|
// Bridge not available
|
|
1305
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
1306
|
+
console.error('[hooks-session-start] memory bridge failed:', e);
|
|
1287
1307
|
}
|
|
1288
1308
|
return {
|
|
1289
1309
|
sessionId,
|
|
@@ -1303,6 +1323,86 @@ export const hooksSessionStart = {
|
|
|
1303
1323
|
};
|
|
1304
1324
|
},
|
|
1305
1325
|
};
|
|
1326
|
+
// Session restore hook — hooks.ts's `hooks session-restore` (and its
|
|
1327
|
+
// `session-start` alias) called this tool name, but it was never registered
|
|
1328
|
+
// anywhere in the tool registry, so both always failed. This repo has no
|
|
1329
|
+
// per-session snapshot of agents/tasks to restore from, so "restore" here
|
|
1330
|
+
// means: report the currently-live (non-terminated/non-terminal) agents and
|
|
1331
|
+
// tasks as "carried forward", and reinitialize the memory-bridge session
|
|
1332
|
+
// context the same way hooks_session-start does — an honest, working
|
|
1333
|
+
// implementation rather than a fabricated one.
|
|
1334
|
+
export const hooksSessionRestore = {
|
|
1335
|
+
name: 'hooks_session-restore',
|
|
1336
|
+
description: 'Restore a previous session — reports currently-live agents/tasks and reinitializes memory-bridge session context',
|
|
1337
|
+
inputSchema: {
|
|
1338
|
+
type: 'object',
|
|
1339
|
+
properties: {
|
|
1340
|
+
sessionId: { type: 'string', description: 'Session ID to restore, or "latest"' },
|
|
1341
|
+
restoreAgents: { type: 'boolean', description: 'Include a count of currently-live agents (default true)' },
|
|
1342
|
+
restoreTasks: { type: 'boolean', description: 'Include a count of currently-live tasks (default true)' },
|
|
1343
|
+
},
|
|
1344
|
+
},
|
|
1345
|
+
handler: async (params) => {
|
|
1346
|
+
const originalSessionId = params.sessionId || 'latest';
|
|
1347
|
+
const newSessionId = `session-${Date.now()}`;
|
|
1348
|
+
const warnings = [];
|
|
1349
|
+
let agentsRestored = 0;
|
|
1350
|
+
if (params.restoreAgents !== false) {
|
|
1351
|
+
try {
|
|
1352
|
+
const { loadAgentStore } = await import('./agent-tools.js');
|
|
1353
|
+
const store = loadAgentStore();
|
|
1354
|
+
agentsRestored = Object.values(store.agents).filter((a) => a.status !== 'terminated').length;
|
|
1355
|
+
}
|
|
1356
|
+
catch (e) {
|
|
1357
|
+
warnings.push('Agent store unavailable — agent count not restored');
|
|
1358
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
1359
|
+
console.error('[hooks-session-restore] agent store read failed:', e);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
let tasksRestored = 0;
|
|
1363
|
+
if (params.restoreTasks !== false) {
|
|
1364
|
+
try {
|
|
1365
|
+
const { loadTaskStore } = await import('./task-tools.js');
|
|
1366
|
+
const store = loadTaskStore();
|
|
1367
|
+
tasksRestored = Object.values(store.tasks).filter((t) => t.status === 'pending' || t.status === 'in_progress').length;
|
|
1368
|
+
}
|
|
1369
|
+
catch (e) {
|
|
1370
|
+
warnings.push('Task store unavailable — task count not restored');
|
|
1371
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
1372
|
+
console.error('[hooks-session-restore] task store read failed:', e);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
// bridgeSessionStart only stores a new "session active" marker entry —
|
|
1376
|
+
// it has no pattern-restoration data to count, so there is no real
|
|
1377
|
+
// "memoryRestored" number to report. Track whether the bridge itself
|
|
1378
|
+
// came up instead of faking a count.
|
|
1379
|
+
let memoryBridgeInitialized = false;
|
|
1380
|
+
try {
|
|
1381
|
+
const bridge = await import('../memory/memory-bridge.js');
|
|
1382
|
+
const result = await bridge.bridgeSessionStart({
|
|
1383
|
+
sessionId: newSessionId,
|
|
1384
|
+
metadata: { context: 'restore previous session patterns' },
|
|
1385
|
+
});
|
|
1386
|
+
if (result) {
|
|
1387
|
+
memoryBridgeInitialized = result.success;
|
|
1388
|
+
}
|
|
1389
|
+
else {
|
|
1390
|
+
warnings.push('Memory bridge unavailable — pattern restoration skipped');
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
catch (e) {
|
|
1394
|
+
warnings.push('Memory bridge failed to initialize');
|
|
1395
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
1396
|
+
console.error('[hooks-session-restore] memory bridge failed:', e);
|
|
1397
|
+
}
|
|
1398
|
+
return {
|
|
1399
|
+
sessionId: newSessionId,
|
|
1400
|
+
originalSessionId,
|
|
1401
|
+
restoredState: { tasksRestored, agentsRestored, memoryBridgeInitialized },
|
|
1402
|
+
warnings: warnings.length > 0 ? warnings : undefined,
|
|
1403
|
+
};
|
|
1404
|
+
},
|
|
1405
|
+
};
|
|
1306
1406
|
// Session end hook - persists state
|
|
1307
1407
|
export const hooksSessionEnd = {
|
|
1308
1408
|
name: 'hooks_session-end',
|
|
@@ -1356,8 +1456,10 @@ export const hooksSessionEnd = {
|
|
|
1356
1456
|
};
|
|
1357
1457
|
}
|
|
1358
1458
|
}
|
|
1359
|
-
catch {
|
|
1459
|
+
catch (e) {
|
|
1360
1460
|
// Bridge not available
|
|
1461
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
1462
|
+
console.error('[hooks-session-end] memory bridge failed:', e);
|
|
1361
1463
|
}
|
|
1362
1464
|
return {
|
|
1363
1465
|
sessionId,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Thin registration module that aggregates all hooks MCP tools into a single array.
|
|
4
4
|
* Business logic lives in hooks-embedding.ts, hooks-routing.ts, and hooks-intelligence.ts.
|
|
5
5
|
*/
|
|
6
|
-
import { hooksPreEdit, hooksPostEdit, hooksPreCommand, hooksPostCommand, hooksRoute, hooksRouteSemantic, hooksMetrics, hooksList, hooksPreTask, hooksPostTask, hooksExplain, hooksPretrain, hooksBuildAgents, hooksTransfer, hooksSessionStart, hooksSessionEnd, hooksIntelligence, } from './hooks-routing.js';
|
|
6
|
+
import { hooksPreEdit, hooksPostEdit, hooksPreCommand, hooksPostCommand, hooksRoute, hooksRouteSemantic, hooksMetrics, hooksList, hooksPreTask, hooksPostTask, hooksExplain, hooksPretrain, hooksBuildAgents, hooksTransfer, hooksSessionStart, hooksSessionRestore, hooksSessionEnd, hooksIntelligence, } from './hooks-routing.js';
|
|
7
7
|
import { hooksIntelligenceReset, hooksTrajectoryStart, hooksTrajectoryStep, hooksTrajectoryEnd, hooksPatternStore, hooksPatternSearch, hooksIntelligenceStats, hooksIntelligenceLearn, hooksIntelligenceAttention, hooksModelRoute, hooksModelOutcome, hooksModelStats, } from './hooks-intelligence.js';
|
|
8
8
|
// Export all hooks tools
|
|
9
9
|
export const hooksTools = [
|
|
@@ -23,6 +23,7 @@ export const hooksTools = [
|
|
|
23
23
|
hooksBuildAgents,
|
|
24
24
|
hooksTransfer,
|
|
25
25
|
hooksSessionStart,
|
|
26
|
+
hooksSessionRestore,
|
|
26
27
|
hooksSessionEnd,
|
|
27
28
|
hooksIntelligence,
|
|
28
29
|
hooksIntelligenceReset,
|
|
@@ -639,7 +639,10 @@ const monographWatchTool = {
|
|
|
639
639
|
}
|
|
640
640
|
const watcher = new MonographWatcher(repoPath);
|
|
641
641
|
watcher.on('monograph:updated', (_paths) => {
|
|
642
|
-
import('@monoes/monograph').then(({ buildAsync }) => buildAsync(repoPath)).catch(() => {
|
|
642
|
+
import('@monoes/monograph').then(({ buildAsync }) => buildAsync(repoPath)).catch((e) => {
|
|
643
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
644
|
+
console.error('[monograph_watch] background rebuild failed:', e);
|
|
645
|
+
});
|
|
643
646
|
});
|
|
644
647
|
await watcher.start();
|
|
645
648
|
_activeWatchers.set(repoPath, watcher);
|
|
@@ -776,7 +779,10 @@ function triggerBackgroundBuildIfNeeded(repoPath, commitsBehind, threshold = STA
|
|
|
776
779
|
_buildInProgress = true;
|
|
777
780
|
void import('@monoes/monograph')
|
|
778
781
|
.then(({ buildAsync }) => buildAsync(repoPath, { codeOnly: true }))
|
|
779
|
-
.catch(() => {
|
|
782
|
+
.catch((e) => {
|
|
783
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
784
|
+
console.error('[triggerBackgroundBuildIfNeeded] staleness-triggered rebuild failed:', e);
|
|
785
|
+
})
|
|
780
786
|
.finally(() => { _buildInProgress = false; });
|
|
781
787
|
return true;
|
|
782
788
|
}
|
|
@@ -40,8 +40,9 @@ function loadPerfStore() {
|
|
|
40
40
|
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
catch {
|
|
44
|
-
|
|
43
|
+
catch (e) {
|
|
44
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
45
|
+
console.error('[performance-tools] failed to load perf store, using empty store:', e);
|
|
45
46
|
}
|
|
46
47
|
return { metrics: [], benchmarks: {}, version: '3.0.0' };
|
|
47
48
|
}
|
|
@@ -34,8 +34,9 @@ function loadSession(sessionId) {
|
|
|
34
34
|
return JSON.parse(data);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
catch {
|
|
38
|
-
|
|
37
|
+
catch (e) {
|
|
38
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
39
|
+
console.error('[session-tools] loadSession failed:', e);
|
|
39
40
|
}
|
|
40
41
|
return null;
|
|
41
42
|
}
|
|
@@ -90,7 +91,10 @@ function loadRelatedStores(options) {
|
|
|
90
91
|
data.memory = JSON.parse(readFileSync(memoryPath, 'utf-8'));
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
|
-
catch {
|
|
94
|
+
catch (e) {
|
|
95
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
96
|
+
console.error('[session-tools] failed to load memory store:', e);
|
|
97
|
+
}
|
|
94
98
|
}
|
|
95
99
|
if (options.includeTasks) {
|
|
96
100
|
try {
|
|
@@ -99,7 +103,10 @@ function loadRelatedStores(options) {
|
|
|
99
103
|
data.tasks = JSON.parse(readFileSync(taskPath, 'utf-8'));
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
|
-
catch {
|
|
106
|
+
catch (e) {
|
|
107
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
108
|
+
console.error('[session-tools] failed to load task store:', e);
|
|
109
|
+
}
|
|
103
110
|
}
|
|
104
111
|
if (options.includeAgents) {
|
|
105
112
|
try {
|
|
@@ -108,7 +115,10 @@ function loadRelatedStores(options) {
|
|
|
108
115
|
data.agents = JSON.parse(readFileSync(agentPath, 'utf-8'));
|
|
109
116
|
}
|
|
110
117
|
}
|
|
111
|
-
catch {
|
|
118
|
+
catch (e) {
|
|
119
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
120
|
+
console.error('[session-tools] failed to load agent store:', e);
|
|
121
|
+
}
|
|
112
122
|
}
|
|
113
123
|
return data;
|
|
114
124
|
}
|
|
@@ -36,7 +36,10 @@ function loadSwarmStore() {
|
|
|
36
36
|
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
catch {
|
|
39
|
+
catch (e) {
|
|
40
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
41
|
+
console.error('[swarm-tools] failed to parse swarm-state.json — resetting to empty store:', e);
|
|
42
|
+
}
|
|
40
43
|
return { swarms: {}, version: '3.0.0' };
|
|
41
44
|
}
|
|
42
45
|
function saveSwarmStore(store) {
|
|
@@ -51,8 +51,9 @@ function loadMetrics() {
|
|
|
51
51
|
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
catch {
|
|
55
|
-
|
|
54
|
+
catch (e) {
|
|
55
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
56
|
+
console.error('[loadMetrics] failed to read/parse metrics.json, using defaults:', e);
|
|
56
57
|
}
|
|
57
58
|
return {
|
|
58
59
|
startTime: new Date().toISOString(),
|
|
@@ -543,8 +544,9 @@ export const systemTools = [
|
|
|
543
544
|
tasks = Object.values(store.tasks || {});
|
|
544
545
|
}
|
|
545
546
|
}
|
|
546
|
-
catch {
|
|
547
|
-
|
|
547
|
+
catch (e) {
|
|
548
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
549
|
+
console.error('[task_summary] failed to read/parse task store:', e);
|
|
548
550
|
}
|
|
549
551
|
return {
|
|
550
552
|
total: tasks.length,
|