@monoes/monomindcli 1.11.10 → 1.11.12
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/commands/mastermind/idea.md +1 -1
- package/.claude/commands/mastermind/master.md +1 -1
- package/.claude/skills/mastermind/_protocol.md +4 -4
- package/.claude/skills/mastermind/architect.md +7 -4
- package/.claude/skills/mastermind/autodev.md +4 -2
- package/.claude/skills/mastermind/build.md +3 -3
- package/.claude/skills/mastermind/content.md +3 -3
- package/.claude/skills/mastermind/createorg.md +2 -2
- package/.claude/skills/mastermind/finance.md +3 -3
- package/.claude/skills/mastermind/idea.md +8 -0
- package/.claude/skills/mastermind/marketing.md +3 -3
- package/.claude/skills/mastermind/ops.md +3 -3
- package/.claude/skills/mastermind/release.md +3 -3
- package/.claude/skills/mastermind/research.md +3 -3
- package/.claude/skills/mastermind/review.md +3 -3
- package/.claude/skills/mastermind/sales.md +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +19 -14
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/statusline-generator.js +3 -3
- package/dist/src/observability/replay-reader.d.ts +1 -1
- package/dist/src/observability/replay-reader.d.ts.map +1 -1
- package/dist/src/update/checker.d.ts.map +1 -1
- package/dist/src/update/checker.js +24 -7
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/index.d.ts +10 -0
- package/dist/src/update/index.d.ts.map +1 -1
- package/dist/src/update/index.js +29 -2
- package/dist/src/update/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/agents/halt-signal.d.ts +0 -25
- package/dist/src/agents/halt-signal.d.ts.map +0 -1
- package/dist/src/agents/halt-signal.js +0 -76
- package/dist/src/agents/halt-signal.js.map +0 -1
- package/dist/src/agents/index.d.ts +0 -18
- package/dist/src/agents/index.d.ts.map +0 -1
- package/dist/src/agents/index.js +0 -13
- package/dist/src/agents/index.js.map +0 -1
- package/dist/src/agents/managed-agent.d.ts +0 -41
- package/dist/src/agents/managed-agent.d.ts.map +0 -1
- package/dist/src/agents/managed-agent.js +0 -69
- package/dist/src/agents/managed-agent.js.map +0 -1
- package/dist/src/agents/prompt-experiment.d.ts +0 -23
- package/dist/src/agents/prompt-experiment.d.ts.map +0 -1
- package/dist/src/agents/prompt-experiment.js +0 -49
- package/dist/src/agents/prompt-experiment.js.map +0 -1
- package/dist/src/agents/prompt-version-manager.d.ts +0 -22
- package/dist/src/agents/prompt-version-manager.d.ts.map +0 -1
- package/dist/src/agents/prompt-version-manager.js +0 -80
- package/dist/src/agents/prompt-version-manager.js.map +0 -1
- package/dist/src/agents/registry-query.d.ts +0 -71
- package/dist/src/agents/registry-query.d.ts.map +0 -1
- package/dist/src/agents/registry-query.js +0 -125
- package/dist/src/agents/registry-query.js.map +0 -1
- package/dist/src/agents/score-decay.d.ts +0 -19
- package/dist/src/agents/score-decay.d.ts.map +0 -1
- package/dist/src/agents/score-decay.js +0 -22
- package/dist/src/agents/score-decay.js.map +0 -1
- package/dist/src/agents/shared-instructions-loader.d.ts +0 -13
- package/dist/src/agents/shared-instructions-loader.d.ts.map +0 -1
- package/dist/src/agents/shared-instructions-loader.js +0 -40
- package/dist/src/agents/shared-instructions-loader.js.map +0 -1
- package/dist/src/agents/specialization-scorer.d.ts +0 -54
- package/dist/src/agents/specialization-scorer.d.ts.map +0 -1
- package/dist/src/agents/specialization-scorer.js +0 -212
- package/dist/src/agents/specialization-scorer.js.map +0 -1
- package/dist/src/agents/termination-watcher.d.ts +0 -30
- package/dist/src/agents/termination-watcher.d.ts.map +0 -1
- package/dist/src/agents/termination-watcher.js +0 -84
- package/dist/src/agents/termination-watcher.js.map +0 -1
- package/dist/src/agents/trigger-index.d.ts +0 -20
- package/dist/src/agents/trigger-index.d.ts.map +0 -1
- package/dist/src/agents/trigger-index.js +0 -38
- package/dist/src/agents/trigger-index.js.map +0 -1
- package/dist/src/agents/trigger-scanner.d.ts +0 -64
- package/dist/src/agents/trigger-scanner.d.ts.map +0 -1
- package/dist/src/agents/trigger-scanner.js +0 -308
- package/dist/src/agents/trigger-scanner.js.map +0 -1
- package/dist/src/agents/version-diff.d.ts +0 -18
- package/dist/src/agents/version-diff.d.ts.map +0 -1
- package/dist/src/agents/version-diff.js +0 -64
- package/dist/src/agents/version-diff.js.map +0 -1
- package/dist/src/agents/version-store.d.ts +0 -60
- package/dist/src/agents/version-store.d.ts.map +0 -1
- package/dist/src/agents/version-store.js +0 -235
- package/dist/src/agents/version-store.js.map +0 -1
- package/dist/src/benchmarks/pretrain/index.d.ts +0 -45
- package/dist/src/benchmarks/pretrain/index.d.ts.map +0 -1
- package/dist/src/benchmarks/pretrain/index.js +0 -404
- package/dist/src/benchmarks/pretrain/index.js.map +0 -1
- package/dist/src/commands/agent-wasm.d.ts +0 -14
- package/dist/src/commands/agent-wasm.d.ts.map +0 -1
- package/dist/src/commands/agent-wasm.js +0 -333
- package/dist/src/commands/agent-wasm.js.map +0 -1
- package/dist/src/commands/embeddings.d.ts.map +0 -1
- package/dist/src/commands/embeddings.js.map +0 -1
- package/dist/src/commands/ui.js +0 -68
- package/dist/src/consensus/index.d.ts +0 -7
- package/dist/src/consensus/index.d.ts.map +0 -1
- package/dist/src/consensus/index.js +0 -6
- package/dist/src/consensus/index.js.map +0 -1
- package/dist/src/context/context-provider.d.ts +0 -44
- package/dist/src/context/context-provider.d.ts.map +0 -1
- package/dist/src/context/context-provider.js +0 -25
- package/dist/src/context/context-provider.js.map +0 -1
- package/dist/src/context/git-state-provider.d.ts +0 -12
- package/dist/src/context/git-state-provider.d.ts.map +0 -1
- package/dist/src/context/git-state-provider.js +0 -34
- package/dist/src/context/git-state-provider.js.map +0 -1
- package/dist/src/context/index.d.ts +0 -12
- package/dist/src/context/index.d.ts.map +0 -1
- package/dist/src/context/index.js +0 -12
- package/dist/src/context/index.js.map +0 -1
- package/dist/src/context/project-conventions-provider.d.ts +0 -15
- package/dist/src/context/project-conventions-provider.d.ts.map +0 -1
- package/dist/src/context/project-conventions-provider.js +0 -19
- package/dist/src/context/project-conventions-provider.js.map +0 -1
- package/dist/src/context/prompt-assembler.d.ts +0 -26
- package/dist/src/context/prompt-assembler.d.ts.map +0 -1
- package/dist/src/context/prompt-assembler.js +0 -93
- package/dist/src/context/prompt-assembler.js.map +0 -1
- package/dist/src/context/task-history-provider.d.ts +0 -24
- package/dist/src/context/task-history-provider.d.ts.map +0 -1
- package/dist/src/context/task-history-provider.js +0 -32
- package/dist/src/context/task-history-provider.js.map +0 -1
- package/dist/src/context/user-preferences-provider.d.ts +0 -14
- package/dist/src/context/user-preferences-provider.d.ts.map +0 -1
- package/dist/src/context/user-preferences-provider.js +0 -27
- package/dist/src/context/user-preferences-provider.js.map +0 -1
- package/dist/src/dlq/dlq-reader.d.ts +0 -31
- package/dist/src/dlq/dlq-reader.d.ts.map +0 -1
- package/dist/src/dlq/dlq-reader.js +0 -81
- package/dist/src/dlq/dlq-reader.js.map +0 -1
- package/dist/src/dlq/dlq-writer.d.ts +0 -24
- package/dist/src/dlq/dlq-writer.d.ts.map +0 -1
- package/dist/src/dlq/dlq-writer.js +0 -65
- package/dist/src/dlq/dlq-writer.js.map +0 -1
- package/dist/src/dlq/index.d.ts +0 -10
- package/dist/src/dlq/index.d.ts.map +0 -1
- package/dist/src/dlq/index.js +0 -7
- package/dist/src/dlq/index.js.map +0 -1
- package/dist/src/eval/dataset-manager.d.ts +0 -33
- package/dist/src/eval/dataset-manager.d.ts.map +0 -1
- package/dist/src/eval/dataset-manager.js +0 -107
- package/dist/src/eval/dataset-manager.js.map +0 -1
- package/dist/src/eval/dataset-runner.d.ts +0 -23
- package/dist/src/eval/dataset-runner.d.ts.map +0 -1
- package/dist/src/eval/dataset-runner.js +0 -59
- package/dist/src/eval/dataset-runner.js.map +0 -1
- package/dist/src/eval/index.d.ts +0 -10
- package/dist/src/eval/index.d.ts.map +0 -1
- package/dist/src/eval/index.js +0 -7
- package/dist/src/eval/index.js.map +0 -1
- package/dist/src/eval/trace-collector.d.ts +0 -40
- package/dist/src/eval/trace-collector.d.ts.map +0 -1
- package/dist/src/eval/trace-collector.js +0 -102
- package/dist/src/eval/trace-collector.js.map +0 -1
- package/dist/src/graph/enrich.mjs +0 -362
- package/dist/src/infrastructure/in-memory-repositories.d.ts +0 -68
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +0 -1
- package/dist/src/infrastructure/in-memory-repositories.js +0 -264
- package/dist/src/infrastructure/in-memory-repositories.js.map +0 -1
- package/dist/src/interactive/interrupt.d.ts +0 -22
- package/dist/src/interactive/interrupt.d.ts.map +0 -1
- package/dist/src/interactive/interrupt.js +0 -71
- package/dist/src/interactive/interrupt.js.map +0 -1
- package/dist/src/mcp/deprecation-injector.d.ts +0 -25
- package/dist/src/mcp/deprecation-injector.d.ts.map +0 -1
- package/dist/src/mcp/deprecation-injector.js +0 -48
- package/dist/src/mcp/deprecation-injector.js.map +0 -1
- package/dist/src/mcp/tool-registry.d.ts +0 -61
- package/dist/src/mcp/tool-registry.d.ts.map +0 -1
- package/dist/src/mcp/tool-registry.js +0 -246
- package/dist/src/mcp/tool-registry.js.map +0 -1
- package/dist/src/mcp-tools/wasm-agent-tools.d.ts +0 -9
- package/dist/src/mcp-tools/wasm-agent-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/wasm-agent-tools.js +0 -230
- package/dist/src/mcp-tools/wasm-agent-tools.js.map +0 -1
- package/dist/src/model/complexity-scorer.d.ts +0 -21
- package/dist/src/model/complexity-scorer.d.ts.map +0 -1
- package/dist/src/model/complexity-scorer.js +0 -106
- package/dist/src/model/complexity-scorer.js.map +0 -1
- package/dist/src/model/index.d.ts +0 -4
- package/dist/src/model/index.d.ts.map +0 -1
- package/dist/src/model/index.js +0 -4
- package/dist/src/model/index.js.map +0 -1
- package/dist/src/model/model-settings.d.ts +0 -22
- package/dist/src/model/model-settings.d.ts.map +0 -1
- package/dist/src/model/model-settings.js +0 -33
- package/dist/src/model/model-settings.js.map +0 -1
- package/dist/src/model/model-tier-resolver.d.ts +0 -24
- package/dist/src/model/model-tier-resolver.d.ts.map +0 -1
- package/dist/src/model/model-tier-resolver.js +0 -65
- package/dist/src/model/model-tier-resolver.js.map +0 -1
- package/dist/src/monovector/capabilities.d.ts +0 -34
- package/dist/src/monovector/capabilities.d.ts.map +0 -1
- package/dist/src/monovector/capabilities.js +0 -37
- package/dist/src/monovector/capabilities.js.map +0 -1
- package/dist/src/orchestration/index.d.ts +0 -7
- package/dist/src/orchestration/index.d.ts.map +0 -1
- package/dist/src/orchestration/index.js +0 -6
- package/dist/src/orchestration/index.js.map +0 -1
- package/dist/src/orchestration/mode-dispatcher.d.ts +0 -11
- package/dist/src/orchestration/mode-dispatcher.d.ts.map +0 -1
- package/dist/src/orchestration/mode-dispatcher.js +0 -31
- package/dist/src/orchestration/mode-dispatcher.js.map +0 -1
- package/dist/src/orchestration/routing-modes.d.ts +0 -68
- package/dist/src/orchestration/routing-modes.d.ts.map +0 -1
- package/dist/src/orchestration/routing-modes.js +0 -180
- package/dist/src/orchestration/routing-modes.js.map +0 -1
- package/dist/src/plugins/tests/demo-plugin-store.d.ts +0 -7
- package/dist/src/plugins/tests/demo-plugin-store.d.ts.map +0 -1
- package/dist/src/plugins/tests/demo-plugin-store.js +0 -126
- package/dist/src/plugins/tests/demo-plugin-store.js.map +0 -1
- package/dist/src/plugins/tests/standalone-test.d.ts +0 -12
- package/dist/src/plugins/tests/standalone-test.d.ts.map +0 -1
- package/dist/src/plugins/tests/standalone-test.js +0 -188
- package/dist/src/plugins/tests/standalone-test.js.map +0 -1
- package/dist/src/plugins/tests/test-plugin-store.d.ts +0 -7
- package/dist/src/plugins/tests/test-plugin-store.d.ts.map +0 -1
- package/dist/src/plugins/tests/test-plugin-store.js +0 -206
- package/dist/src/plugins/tests/test-plugin-store.js.map +0 -1
- package/dist/src/runtime/headless.d.ts +0 -60
- package/dist/src/runtime/headless.d.ts.map +0 -1
- package/dist/src/runtime/headless.js +0 -284
- package/dist/src/runtime/headless.js.map +0 -1
- package/dist/src/services/agentic-flow-bridge.d.ts +0 -50
- package/dist/src/services/agentic-flow-bridge.d.ts.map +0 -1
- package/dist/src/services/agentic-flow-bridge.js +0 -95
- package/dist/src/services/agentic-flow-bridge.js.map +0 -1
- package/dist/src/services/container-worker-pool.d.ts +0 -197
- package/dist/src/services/container-worker-pool.d.ts.map +0 -1
- package/dist/src/services/container-worker-pool.js +0 -623
- package/dist/src/services/container-worker-pool.js.map +0 -1
- package/dist/src/services/index.d.ts +0 -13
- package/dist/src/services/index.d.ts.map +0 -1
- package/dist/src/services/index.js +0 -11
- package/dist/src/services/index.js.map +0 -1
- package/dist/src/services/worker-queue.d.ts +0 -201
- package/dist/src/services/worker-queue.d.ts.map +0 -1
- package/dist/src/services/worker-queue.js +0 -594
- package/dist/src/services/worker-queue.js.map +0 -1
- package/dist/src/swarm/communication-graph.d.ts +0 -25
- package/dist/src/swarm/communication-graph.d.ts.map +0 -1
- package/dist/src/swarm/communication-graph.js +0 -77
- package/dist/src/swarm/communication-graph.js.map +0 -1
- package/dist/src/swarm/flow-enforcer.d.ts +0 -31
- package/dist/src/swarm/flow-enforcer.d.ts.map +0 -1
- package/dist/src/swarm/flow-enforcer.js +0 -61
- package/dist/src/swarm/flow-enforcer.js.map +0 -1
- package/dist/src/swarm/flow-visualizer.d.ts +0 -19
- package/dist/src/swarm/flow-visualizer.d.ts.map +0 -1
- package/dist/src/swarm/flow-visualizer.js +0 -68
- package/dist/src/swarm/flow-visualizer.js.map +0 -1
- package/dist/src/transfer/deploy-seraphine.d.ts +0 -13
- package/dist/src/transfer/deploy-seraphine.d.ts.map +0 -1
- package/dist/src/transfer/deploy-seraphine.js +0 -205
- package/dist/src/transfer/deploy-seraphine.js.map +0 -1
- package/dist/src/transfer/store/tests/standalone-test.d.ts +0 -12
- package/dist/src/transfer/store/tests/standalone-test.d.ts.map +0 -1
- package/dist/src/transfer/store/tests/standalone-test.js +0 -190
- package/dist/src/transfer/store/tests/standalone-test.js.map +0 -1
- package/dist/src/transfer/test-seraphine.d.ts +0 -6
- package/dist/src/transfer/test-seraphine.d.ts.map +0 -1
- package/dist/src/transfer/test-seraphine.js +0 -105
- package/dist/src/transfer/test-seraphine.js.map +0 -1
- package/dist/src/transfer/tests/test-store.d.ts +0 -7
- package/dist/src/transfer/tests/test-store.d.ts.map +0 -1
- package/dist/src/transfer/tests/test-store.js +0 -214
- package/dist/src/transfer/tests/test-store.js.map +0 -1
- package/dist/src/ui/.monomind/data/pending-insights.jsonl +0 -0
- package/dist/src/ui/.monomind/data/ranked-context.json +0 -5
- package/dist/src/ui/.monomind/loops/mastermind-review-1778664132789.json +0 -16
- package/dist/src/ui/.monomind/sessions/current.json +0 -13
- package/dist/src/ui/.monomind/sessions/session-1776778451399.json +0 -15
- package/dist/src/ui/collector.mjs +0 -646
- package/dist/src/ui/dashboard.html +0 -9694
- package/dist/src/ui/data/mastermind-events.jsonl +0 -59
- package/dist/src/ui/data/mastermind-sessions.json +0 -1
- package/dist/src/ui/orgs.html +0 -1360
- package/dist/src/ui/server.mjs +0 -4334
- package/dist/src/workflow/condition-evaluator.d.ts +0 -10
- package/dist/src/workflow/condition-evaluator.d.ts.map +0 -1
- package/dist/src/workflow/condition-evaluator.js +0 -82
- package/dist/src/workflow/condition-evaluator.js.map +0 -1
- package/dist/src/workflow/context-resolver.d.ts +0 -12
- package/dist/src/workflow/context-resolver.d.ts.map +0 -1
- package/dist/src/workflow/context-resolver.js +0 -23
- package/dist/src/workflow/context-resolver.js.map +0 -1
- package/dist/src/workflow/dag-builder.d.ts +0 -17
- package/dist/src/workflow/dag-builder.d.ts.map +0 -1
- package/dist/src/workflow/dag-builder.js +0 -129
- package/dist/src/workflow/dag-builder.js.map +0 -1
- package/dist/src/workflow/dag-executor.d.ts +0 -9
- package/dist/src/workflow/dag-executor.d.ts.map +0 -1
- package/dist/src/workflow/dag-executor.js +0 -116
- package/dist/src/workflow/dag-executor.js.map +0 -1
- package/dist/src/workflow/dag-types.d.ts +0 -41
- package/dist/src/workflow/dag-types.d.ts.map +0 -1
- package/dist/src/workflow/dag-types.js +0 -8
- package/dist/src/workflow/dag-types.js.map +0 -1
- package/dist/src/workflow/dsl-parser.d.ts +0 -12
- package/dist/src/workflow/dsl-parser.d.ts.map +0 -1
- package/dist/src/workflow/dsl-parser.js +0 -20
- package/dist/src/workflow/dsl-parser.js.map +0 -1
- package/dist/src/workflow/dsl-schema.d.ts +0 -165
- package/dist/src/workflow/dsl-schema.d.ts.map +0 -1
- package/dist/src/workflow/dsl-schema.js +0 -82
- package/dist/src/workflow/dsl-schema.js.map +0 -1
- package/dist/src/workflow/index.d.ts +0 -13
- package/dist/src/workflow/index.d.ts.map +0 -1
- package/dist/src/workflow/index.js +0 -11
- package/dist/src/workflow/index.js.map +0 -1
- package/dist/src/workflow/template-engine.d.ts +0 -11
- package/dist/src/workflow/template-engine.d.ts.map +0 -1
- package/dist/src/workflow/template-engine.js +0 -40
- package/dist/src/workflow/template-engine.js.map +0 -1
- package/dist/src/workflow/workflow-executor.d.ts +0 -29
- package/dist/src/workflow/workflow-executor.d.ts.map +0 -1
- package/dist/src/workflow/workflow-executor.js +0 -227
- package/dist/src/workflow/workflow-executor.js.map +0 -1
|
@@ -1,646 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import os from 'os';
|
|
4
|
-
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
// Helpers
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
function readJSON(filePath) {
|
|
10
|
-
try {
|
|
11
|
-
const raw = fs.readFileSync(filePath, 'utf8');
|
|
12
|
-
return JSON.parse(raw);
|
|
13
|
-
} catch {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function readJSONL(filePath, last) {
|
|
19
|
-
try {
|
|
20
|
-
const raw = fs.readFileSync(filePath, 'utf8');
|
|
21
|
-
const lines = raw.split('\n').filter(Boolean);
|
|
22
|
-
const slice = last != null ? lines.slice(-last) : lines;
|
|
23
|
-
return slice.map(line => {
|
|
24
|
-
try {
|
|
25
|
-
return JSON.parse(line);
|
|
26
|
-
} catch {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}).filter(Boolean);
|
|
30
|
-
} catch {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function countJSONLLines(filePath) {
|
|
36
|
-
try {
|
|
37
|
-
const raw = fs.readFileSync(filePath, 'utf8');
|
|
38
|
-
return raw.split('\n').filter(Boolean).length;
|
|
39
|
-
} catch {
|
|
40
|
-
return 0;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function fileExists(filePath) {
|
|
45
|
-
try {
|
|
46
|
-
fs.accessSync(filePath);
|
|
47
|
-
return true;
|
|
48
|
-
} catch {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function fileStat(filePath) {
|
|
54
|
-
try {
|
|
55
|
-
return fs.statSync(filePath);
|
|
56
|
-
} catch {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function listDir(dirPath) {
|
|
62
|
-
try {
|
|
63
|
-
return fs.readdirSync(dirPath);
|
|
64
|
-
} catch {
|
|
65
|
-
return [];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ---------------------------------------------------------------------------
|
|
70
|
-
// Section collectors
|
|
71
|
-
// ---------------------------------------------------------------------------
|
|
72
|
-
|
|
73
|
-
function collectProject(projectDir) {
|
|
74
|
-
let name = path.basename(projectDir);
|
|
75
|
-
const pkgPath = path.join(projectDir, 'package.json');
|
|
76
|
-
const pkg = readJSON(pkgPath);
|
|
77
|
-
if (pkg && pkg.name) {
|
|
78
|
-
name = pkg.name;
|
|
79
|
-
}
|
|
80
|
-
return { dir: projectDir, name };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function getClaudeProjectSessionsDir(projectDir) {
|
|
84
|
-
// Claude Code stores sessions in ~/.claude/projects/<slug>/ not in the project itself
|
|
85
|
-
const homeDir = os.homedir();
|
|
86
|
-
const slug = projectDir.replace(/\//g, '-');
|
|
87
|
-
const globalSessions = path.join(homeDir, '.claude', 'projects', slug);
|
|
88
|
-
if (fs.existsSync(globalSessions)) return globalSessions;
|
|
89
|
-
// Fallback to local .claude/sessions
|
|
90
|
-
return path.join(projectDir, '.claude', 'sessions');
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function collectSessions(projectDir) {
|
|
94
|
-
const sessionsDir = getClaudeProjectSessionsDir(projectDir);
|
|
95
|
-
const entries = listDir(sessionsDir);
|
|
96
|
-
const list = entries
|
|
97
|
-
.filter(f => f.endsWith('.json') || f.endsWith('.jsonl'))
|
|
98
|
-
.map(f => {
|
|
99
|
-
const filePath = path.join(sessionsDir, f);
|
|
100
|
-
const stat = fileStat(filePath);
|
|
101
|
-
const id = path.basename(f, path.extname(f));
|
|
102
|
-
return {
|
|
103
|
-
id,
|
|
104
|
-
file: filePath,
|
|
105
|
-
mtime: stat ? stat.mtimeMs : null,
|
|
106
|
-
size: stat ? stat.size : null
|
|
107
|
-
};
|
|
108
|
-
})
|
|
109
|
-
.sort((a, b) => (b.mtime || 0) - (a.mtime || 0));
|
|
110
|
-
|
|
111
|
-
const memFiles = collectMemoryFiles(projectDir);
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
list,
|
|
115
|
-
count: list.length,
|
|
116
|
-
palace: {
|
|
117
|
-
count: memFiles.length
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const _appendedSwarmIds = new Set();
|
|
123
|
-
|
|
124
|
-
function collectSwarm(projectDir) {
|
|
125
|
-
const base = path.join(projectDir, '.monomind');
|
|
126
|
-
const state = readJSON(path.join(base, 'swarm', 'swarm-state.json')) || {};
|
|
127
|
-
const dotSwarmState = readJSON(path.join(projectDir, '.swarm', 'state.json')) || {};
|
|
128
|
-
const merged = { ...dotSwarmState, ...state };
|
|
129
|
-
|
|
130
|
-
const terminalStatuses = ['stopped', 'terminated', 'completed', 'error'];
|
|
131
|
-
const swarmId = merged.swarmId || merged.id;
|
|
132
|
-
if (swarmId && terminalStatuses.includes(merged.status) && !_appendedSwarmIds.has(swarmId)) {
|
|
133
|
-
_appendedSwarmIds.add(swarmId);
|
|
134
|
-
const agents = (merged.agents || merged.agentPlan || []).map(a => ({
|
|
135
|
-
id: a.id || a.type || a.role,
|
|
136
|
-
type: a.type || a.role || '?',
|
|
137
|
-
role: a.role || 'worker',
|
|
138
|
-
tasksCompleted: a.tasksCompleted || a.count || 0,
|
|
139
|
-
tasksFailed: a.tasksFailed || 0,
|
|
140
|
-
messageCount: a.messageCount || 0,
|
|
141
|
-
utilization: a.utilization || 0,
|
|
142
|
-
}));
|
|
143
|
-
const entry = {
|
|
144
|
-
swarmId,
|
|
145
|
-
topology: merged.topology || '—',
|
|
146
|
-
consensus: merged.consensus || '—',
|
|
147
|
-
strategy: merged.strategy || '—',
|
|
148
|
-
status: merged.status,
|
|
149
|
-
agents,
|
|
150
|
-
messages: merged.messages || [],
|
|
151
|
-
errors: merged.errors || [],
|
|
152
|
-
findings: merged.findings || [],
|
|
153
|
-
taskCount: merged.taskCount || 0,
|
|
154
|
-
completedTasks: merged.completedTasks || 0,
|
|
155
|
-
failedTasks: merged.failedTasks || 0,
|
|
156
|
-
startedAt: merged.startedAt || merged.createdAt || new Date().toISOString(),
|
|
157
|
-
endedAt: merged.stoppedAt || merged.endedAt || new Date().toISOString(),
|
|
158
|
-
durationMs: 0,
|
|
159
|
-
};
|
|
160
|
-
if (entry.startedAt && entry.endedAt) {
|
|
161
|
-
entry.durationMs = new Date(entry.endedAt).getTime() - new Date(entry.startedAt).getTime();
|
|
162
|
-
}
|
|
163
|
-
try { appendSwarmHistory(projectDir, entry); } catch {}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return {
|
|
167
|
-
state: merged,
|
|
168
|
-
activity: readJSON(path.join(base, 'metrics', 'swarm-activity.json')) || {},
|
|
169
|
-
suggestion: {},
|
|
170
|
-
config: readJSON(path.join(base, 'swarm-config.json')) || {},
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function collectSwarmHistory(projectDir) {
|
|
175
|
-
const historyPath = path.join(projectDir, '.monomind', 'swarm', 'history.jsonl');
|
|
176
|
-
const byId = new Map();
|
|
177
|
-
|
|
178
|
-
// 1. Persisted history (if any swarm ever appended on terminal status)
|
|
179
|
-
for (const e of readJSONL(historyPath)) {
|
|
180
|
-
const id = e && (e.swarmId || e.id);
|
|
181
|
-
if (id) byId.set(id, e);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// 2. Derive from the live swarm-state.json. The writer stores a NESTED
|
|
185
|
-
// { swarms: { <id>: {...} } } map, but collectSwarm() only appends to
|
|
186
|
-
// history.jsonl when a FLAT top-level swarmId/status is present — which
|
|
187
|
-
// this format never has. So without this fallback the tab is empty even
|
|
188
|
-
// though swarms exist. Derive entries directly from the map here.
|
|
189
|
-
try {
|
|
190
|
-
const state = readJSON(path.join(projectDir, '.monomind', 'swarm', 'swarm-state.json')) || {};
|
|
191
|
-
const swarmsMap = state.swarms || (state.swarmId ? { [state.swarmId]: state } : {});
|
|
192
|
-
for (const [key, s] of Object.entries(swarmsMap)) {
|
|
193
|
-
if (!s || typeof s !== 'object') continue;
|
|
194
|
-
const sid = s.swarmId || s.id || key;
|
|
195
|
-
if (byId.has(sid)) continue; // a real history entry wins over derived
|
|
196
|
-
const cfg = s.config || {};
|
|
197
|
-
const agents = Array.isArray(s.agents) ? s.agents : [];
|
|
198
|
-
byId.set(sid, {
|
|
199
|
-
swarmId: sid,
|
|
200
|
-
topology: s.topology || cfg.topology || '—',
|
|
201
|
-
consensus: s.consensus || cfg.consensusMechanism || '—',
|
|
202
|
-
strategy: s.strategy || cfg.strategy || '—',
|
|
203
|
-
status: s.status || 'unknown',
|
|
204
|
-
agentCount: agents.length || s.maxAgents || cfg.maxAgents || 0,
|
|
205
|
-
agents,
|
|
206
|
-
taskCount: Array.isArray(s.tasks) ? s.tasks.length : (s.taskCount || 0),
|
|
207
|
-
startedAt: s.createdAt || s.startedAt || null,
|
|
208
|
-
endedAt: s.updatedAt || s.endedAt || null,
|
|
209
|
-
derived: true,
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
} catch {}
|
|
213
|
-
|
|
214
|
-
// newest-first
|
|
215
|
-
return Array.from(byId.values()).sort((a, b) =>
|
|
216
|
-
new Date(b.startedAt || 0).getTime() - new Date(a.startedAt || 0).getTime());
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function appendSwarmHistory(projectDir, entry) {
|
|
220
|
-
const dir = path.join(projectDir, '.monomind', 'swarm');
|
|
221
|
-
if (!fs.existsSync(dir)) {
|
|
222
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
223
|
-
}
|
|
224
|
-
const historyPath = path.join(dir, 'history.jsonl');
|
|
225
|
-
fs.appendFileSync(historyPath, JSON.stringify(entry) + '\n');
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function collectSwarmEvents(projectDir, opts = {}) {
|
|
229
|
-
const eventsPath = path.join(projectDir, '.monomind', 'swarm', 'events.jsonl');
|
|
230
|
-
const events = readJSONL(eventsPath, opts.last || null);
|
|
231
|
-
if (opts.swarmId) return events.filter(e => e.swarmId === opts.swarmId);
|
|
232
|
-
if (opts.agentId) return events.filter(e => e.agentId === opts.agentId);
|
|
233
|
-
return events;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
function getSwarmDataSize(projectDir) {
|
|
237
|
-
const dir = path.join(projectDir, '.monomind', 'swarm');
|
|
238
|
-
let totalBytes = 0;
|
|
239
|
-
let fileCount = 0;
|
|
240
|
-
const files = ['history.jsonl', 'events.jsonl'];
|
|
241
|
-
for (const f of files) {
|
|
242
|
-
const stat = fileStat(path.join(dir, f));
|
|
243
|
-
if (stat) { totalBytes += stat.size; fileCount++; }
|
|
244
|
-
}
|
|
245
|
-
return { totalBytes, fileCount, humanSize: totalBytes < 1024 ? totalBytes + ' B' : totalBytes < 1048576 ? (totalBytes / 1024).toFixed(1) + ' KB' : (totalBytes / 1048576).toFixed(1) + ' MB' };
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function cleanSwarmData(projectDir) {
|
|
249
|
-
const dir = path.join(projectDir, '.monomind', 'swarm');
|
|
250
|
-
const files = ['history.jsonl', 'events.jsonl'];
|
|
251
|
-
let removed = 0;
|
|
252
|
-
for (const f of files) {
|
|
253
|
-
const fp = path.join(dir, f);
|
|
254
|
-
try { fs.unlinkSync(fp); removed++; } catch {}
|
|
255
|
-
}
|
|
256
|
-
_appendedSwarmIds.clear();
|
|
257
|
-
return { removed, files };
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function collectAgents(projectDir) {
|
|
261
|
-
const base = path.join(projectDir, '.monomind');
|
|
262
|
-
const regsDir = path.join(base, 'agents', 'registrations');
|
|
263
|
-
const regFiles = listDir(regsDir).filter(f => f.endsWith('.json'));
|
|
264
|
-
const registrations = regFiles.map(f => {
|
|
265
|
-
return readJSON(path.join(regsDir, f));
|
|
266
|
-
}).filter(Boolean);
|
|
267
|
-
|
|
268
|
-
const registry = readJSON(path.join(base, 'registry.json')) || {};
|
|
269
|
-
|
|
270
|
-
return {
|
|
271
|
-
registrations,
|
|
272
|
-
registry,
|
|
273
|
-
count: registrations.length
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function collectTokens(projectDir) {
|
|
278
|
-
const base = path.join(projectDir, '.monomind', 'metrics');
|
|
279
|
-
const summary = readJSON(path.join(base, 'token-summary.json')) || {};
|
|
280
|
-
const sessionsPath = path.join(base, 'token-sessions.json');
|
|
281
|
-
let sessions = [];
|
|
282
|
-
try {
|
|
283
|
-
const raw = readJSON(sessionsPath);
|
|
284
|
-
sessions = Array.isArray(raw) ? raw : [];
|
|
285
|
-
} catch {
|
|
286
|
-
sessions = [];
|
|
287
|
-
}
|
|
288
|
-
return { summary, sessions };
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function collectHooks(projectDir) {
|
|
292
|
-
const base = path.join(projectDir, '.monomind');
|
|
293
|
-
const lastRoute = readJSON(path.join(base, 'last-route.json')) || {};
|
|
294
|
-
const feedback = readJSONL(path.join(base, 'routing-feedback.jsonl'), 10);
|
|
295
|
-
|
|
296
|
-
const workerDispatchDir = path.join(base, 'worker-dispatch');
|
|
297
|
-
const workerDispatch = listDir(workerDispatchDir).filter(f => f.startsWith('pending-') && f.endsWith('.json'));
|
|
298
|
-
|
|
299
|
-
return { lastRoute, feedback, workerDispatch };
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
function collectKnowledge(projectDir) {
|
|
303
|
-
const base = path.join(projectDir, '.monomind');
|
|
304
|
-
const chunksPath = path.join(base, 'knowledge', 'chunks.jsonl');
|
|
305
|
-
const skillsPath = path.join(base, 'skills.jsonl');
|
|
306
|
-
|
|
307
|
-
// Read chunks.jsonl once; derive count and recent slice together
|
|
308
|
-
let chunks = 0;
|
|
309
|
-
let recent = [];
|
|
310
|
-
try {
|
|
311
|
-
const raw = fs.readFileSync(chunksPath, 'utf8');
|
|
312
|
-
const lines = raw.split('\n').filter(Boolean);
|
|
313
|
-
chunks = lines.length;
|
|
314
|
-
recent = lines.slice(-5).map(line => { try { return JSON.parse(line); } catch { return null; } }).filter(Boolean);
|
|
315
|
-
} catch {}
|
|
316
|
-
const skills = countJSONLLines(skillsPath);
|
|
317
|
-
|
|
318
|
-
return { chunks, skills, recent };
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function collectMetrics(projectDir) {
|
|
322
|
-
const base = path.join(projectDir, '.monomind');
|
|
323
|
-
const swarmActivity = readJSON(path.join(base, 'metrics', 'swarm-activity.json')) || {};
|
|
324
|
-
const tokenSummary = readJSON(path.join(base, 'metrics', 'token-summary.json')) || {};
|
|
325
|
-
|
|
326
|
-
// Derive routing stats from feedback log (cap at 1000 to avoid reading unbounded file)
|
|
327
|
-
const feedbackAll = readJSONL(path.join(base, 'routing-feedback.jsonl'), 1000);
|
|
328
|
-
const routingTotal = feedbackAll.length;
|
|
329
|
-
let routingConfSum = 0, routingConfCount = 0;
|
|
330
|
-
const agentCounts = {};
|
|
331
|
-
for (const fb of feedbackAll) {
|
|
332
|
-
if (fb.confidence != null) { routingConfSum += fb.confidence; routingConfCount++; }
|
|
333
|
-
const a = fb.suggestedAgent || fb.agent;
|
|
334
|
-
if (a) agentCounts[a] = (agentCounts[a] || 0) + 1;
|
|
335
|
-
}
|
|
336
|
-
const avgConf = routingConfCount > 0 ? Math.round((routingConfSum / routingConfCount) * 100) : null;
|
|
337
|
-
const topAgent = Object.entries(agentCounts).sort((a, b) => b[1] - a[1])[0];
|
|
338
|
-
|
|
339
|
-
return {
|
|
340
|
-
routing: {
|
|
341
|
-
total: routingTotal,
|
|
342
|
-
avgConfidence: avgConf,
|
|
343
|
-
topAgent: topAgent ? topAgent[0] : null,
|
|
344
|
-
topAgentCount: topAgent ? topAgent[1] : null,
|
|
345
|
-
},
|
|
346
|
-
swarm: {
|
|
347
|
-
active: swarmActivity.swarm && swarmActivity.swarm.active,
|
|
348
|
-
agentCount: swarmActivity.swarm && swarmActivity.swarm.agent_count,
|
|
349
|
-
lastActive: swarmActivity.timestamp || null,
|
|
350
|
-
},
|
|
351
|
-
tokens: {
|
|
352
|
-
todayCost: tokenSummary.todayCost,
|
|
353
|
-
todayCalls: tokenSummary.todayCalls,
|
|
354
|
-
monthCost: tokenSummary.monthCost,
|
|
355
|
-
monthCalls: tokenSummary.monthCalls,
|
|
356
|
-
},
|
|
357
|
-
security: readJSON(path.join(base, 'security', 'audit-status.json')) || {}
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
function collectTriggers(projectDir) {
|
|
362
|
-
return readJSON(path.join(projectDir, '.monomind', 'trigger-index.json')) || {};
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
function collectMemoryFiles(projectDir) {
|
|
366
|
-
const homeDir = os.homedir();
|
|
367
|
-
const slug = path.resolve(projectDir).replace(/\//g, '-');
|
|
368
|
-
const memDir = path.join(homeDir, '.claude', 'projects', slug, 'memory');
|
|
369
|
-
let files = [];
|
|
370
|
-
try { files = fs.readdirSync(memDir).filter(f => f.endsWith('.md') && f !== 'MEMORY.md'); } catch {}
|
|
371
|
-
return files.map(fname => {
|
|
372
|
-
const fp = path.join(memDir, fname);
|
|
373
|
-
let raw = ''; try { raw = fs.readFileSync(fp, 'utf8').replace(/\r\n/g, '\n'); } catch {}
|
|
374
|
-
let name = fname.replace('.md', ''), description = '', type = 'project';
|
|
375
|
-
const fm = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
376
|
-
if (fm) {
|
|
377
|
-
for (const line of fm[1].split('\n')) {
|
|
378
|
-
const m2 = line.match(/^(\w+):\s*(.+)$/);
|
|
379
|
-
if (m2) {
|
|
380
|
-
if (m2[1] === 'name') name = m2[2].trim();
|
|
381
|
-
if (m2[1] === 'description') description = m2[2].trim();
|
|
382
|
-
if (m2[1] === 'type') type = m2[2].trim();
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
let stat = null; try { stat = fs.statSync(fp); } catch {}
|
|
387
|
-
return { filename: fname, name, description, type, mtime: stat ? stat.mtimeMs : null };
|
|
388
|
-
}).sort((a, b) => (b.mtime || 0) - (a.mtime || 0));
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// Probe candidate paths in priority order, return first existing file's stat
|
|
392
|
-
function probeFile(...candidates) {
|
|
393
|
-
for (const p of candidates) {
|
|
394
|
-
const s = fileStat(p);
|
|
395
|
-
if (s && s.size > 0) return { path: p, size: s.size };
|
|
396
|
-
}
|
|
397
|
-
return null;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
function collectMemory(projectDir) {
|
|
401
|
-
const d = path.resolve(projectDir);
|
|
402
|
-
const monomindDir = path.join(d, '.monomind');
|
|
403
|
-
|
|
404
|
-
// AgentDB — check all known locations across different init styles
|
|
405
|
-
const dbCandidates = [
|
|
406
|
-
path.join(d, 'data', 'memory.db'), // custom --path ./data/memory.db
|
|
407
|
-
path.join(d, '.swarm', 'memory.db'), // default init path
|
|
408
|
-
path.join(monomindDir, 'memory.db'), // legacy .monomind path
|
|
409
|
-
path.join(d, '.claude', 'memory.db'), // .claude dir (some setups)
|
|
410
|
-
];
|
|
411
|
-
const dbHit = probeFile(...dbCandidates);
|
|
412
|
-
const dbSize = dbHit ? dbHit.size : 0;
|
|
413
|
-
const dbPath = dbHit ? dbHit.path : null;
|
|
414
|
-
|
|
415
|
-
// HNSW — lives alongside the DB or at the .swarm default
|
|
416
|
-
const hnswCandidates = dbPath ? [
|
|
417
|
-
path.join(path.dirname(dbPath), 'memory.graph'), // alongside DB (hybrid backend)
|
|
418
|
-
path.join(path.dirname(dbPath), 'hnsw.index'), // default init name
|
|
419
|
-
] : [
|
|
420
|
-
path.join(d, 'data', 'memory.graph'),
|
|
421
|
-
path.join(d, '.swarm', 'hnsw.index'),
|
|
422
|
-
];
|
|
423
|
-
const hnswHit = probeFile(...hnswCandidates);
|
|
424
|
-
const hnsw = !!hnswHit;
|
|
425
|
-
|
|
426
|
-
// MonoVector DB
|
|
427
|
-
const monovectorHit = probeFile(
|
|
428
|
-
path.join(monomindDir, 'data', 'monovector.db'),
|
|
429
|
-
path.join(d, 'data', 'monovector.db'),
|
|
430
|
-
);
|
|
431
|
-
const monovectorSize = monovectorHit ? monovectorHit.size : 0;
|
|
432
|
-
const monovectorExists = !!monovectorHit;
|
|
433
|
-
|
|
434
|
-
let monovectorPatterns = 0;
|
|
435
|
-
const ranked = readJSON(path.join(monomindDir, 'data', 'ranked-context.json'));
|
|
436
|
-
if (ranked && ranked.entries) monovectorPatterns = ranked.entries.length;
|
|
437
|
-
|
|
438
|
-
const files = collectMemoryFiles(projectDir);
|
|
439
|
-
|
|
440
|
-
return { dbSize, dbPath, hnsw, monovectorSize, monovectorExists, monovectorPatterns, files, count: files.length };
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
function collectSystem() {
|
|
444
|
-
return {
|
|
445
|
-
nodeVersion: process.version,
|
|
446
|
-
uptime: process.uptime(),
|
|
447
|
-
platform: process.platform,
|
|
448
|
-
memoryMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024)
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
// ---------------------------------------------------------------------------
|
|
453
|
-
// Global: all projects on this machine (~/.claude/projects/)
|
|
454
|
-
// ---------------------------------------------------------------------------
|
|
455
|
-
|
|
456
|
-
function slugToPath(slug) {
|
|
457
|
-
return resolveSlugPath(slug);
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// Reconstruct the real filesystem path from a Claude project slug.
|
|
461
|
-
// Slugs encode the path with every '/' replaced by '-', which is lossy when
|
|
462
|
-
// directory names contain literal hyphens (e.g. /Desktop/agent-f/accounting).
|
|
463
|
-
// Strategy: naive replace first; if not found, greedy DFS through the filesystem
|
|
464
|
-
// trying longest-possible segment (with embedded hyphens) at each level.
|
|
465
|
-
function resolveSlugPath(slug) {
|
|
466
|
-
const naive = '/' + slug.replace(/^-/, '').replace(/-/g, '/');
|
|
467
|
-
try { if (fs.existsSync(naive)) return naive; } catch {}
|
|
468
|
-
|
|
469
|
-
const tokens = slug.replace(/^-/, '').split('-').filter(Boolean);
|
|
470
|
-
|
|
471
|
-
function walk(idx, dir) {
|
|
472
|
-
if (idx === tokens.length) return dir;
|
|
473
|
-
// Try longest span first (greedy) so "agent-f" is preferred over "agent"+"f"
|
|
474
|
-
for (let end = tokens.length; end > idx; end--) {
|
|
475
|
-
const segment = tokens.slice(idx, end).join('-');
|
|
476
|
-
const candidate = path.join(dir, segment);
|
|
477
|
-
try {
|
|
478
|
-
if (fs.statSync(candidate).isDirectory()) {
|
|
479
|
-
const result = walk(end, candidate);
|
|
480
|
-
if (result !== null) return result;
|
|
481
|
-
}
|
|
482
|
-
} catch {}
|
|
483
|
-
}
|
|
484
|
-
return null;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
return walk(0, '/') || naive;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
let _apCache = null;
|
|
491
|
-
let _apCacheTs = 0;
|
|
492
|
-
const AP_TTL = 5_000;
|
|
493
|
-
|
|
494
|
-
export function collectAllProjects() {
|
|
495
|
-
const now = Date.now();
|
|
496
|
-
if (_apCache !== null && now - _apCacheTs < AP_TTL) return _apCache;
|
|
497
|
-
const homeDir = os.homedir();
|
|
498
|
-
const projectsRoot = path.join(homeDir, '.claude', 'projects');
|
|
499
|
-
const result = [];
|
|
500
|
-
|
|
501
|
-
let slugs = [];
|
|
502
|
-
try { slugs = fs.readdirSync(projectsRoot); } catch { return result; }
|
|
503
|
-
|
|
504
|
-
for (const slug of slugs) {
|
|
505
|
-
const projectClaudeDir = path.join(projectsRoot, slug);
|
|
506
|
-
let stat;
|
|
507
|
-
try { stat = fs.statSync(projectClaudeDir); } catch { continue; }
|
|
508
|
-
if (!stat.isDirectory()) continue;
|
|
509
|
-
|
|
510
|
-
// Find session files (.jsonl) and subdirs (session folders)
|
|
511
|
-
let entries = [];
|
|
512
|
-
try { entries = fs.readdirSync(projectClaudeDir); } catch { continue; }
|
|
513
|
-
|
|
514
|
-
const sessionFiles = entries.filter(e => e.endsWith('.jsonl'));
|
|
515
|
-
const sessions = sessionFiles.map(f => {
|
|
516
|
-
const fp = path.join(projectClaudeDir, f);
|
|
517
|
-
let fstat = null;
|
|
518
|
-
try { fstat = fs.statSync(fp); } catch {}
|
|
519
|
-
// Peek at first line for model/type info
|
|
520
|
-
let firstTurn = null;
|
|
521
|
-
try {
|
|
522
|
-
const buf = Buffer.alloc(512);
|
|
523
|
-
const fd = fs.openSync(fp, 'r');
|
|
524
|
-
try {
|
|
525
|
-
fs.readSync(fd, buf, 0, 512, 0);
|
|
526
|
-
} finally {
|
|
527
|
-
fs.closeSync(fd);
|
|
528
|
-
}
|
|
529
|
-
const line = buf.toString('utf8').split('\n')[0];
|
|
530
|
-
firstTurn = JSON.parse(line);
|
|
531
|
-
} catch {}
|
|
532
|
-
return {
|
|
533
|
-
id: path.basename(f, '.jsonl'),
|
|
534
|
-
file: fp,
|
|
535
|
-
mtime: fstat ? fstat.mtimeMs : null,
|
|
536
|
-
size: fstat ? fstat.size : null,
|
|
537
|
-
lines: null, // skip line count for perf
|
|
538
|
-
model: firstTurn && firstTurn.model ? firstTurn.model : null,
|
|
539
|
-
};
|
|
540
|
-
}).sort((a, b) => (b.mtime || 0) - (a.mtime || 0));
|
|
541
|
-
|
|
542
|
-
// Resolve the actual filesystem path (handles hyphens in directory names)
|
|
543
|
-
const diskPath = resolveSlugPath(slug);
|
|
544
|
-
const parts = diskPath.split('/').filter(Boolean);
|
|
545
|
-
const name = parts[parts.length - 1] || slug;
|
|
546
|
-
const exists = fs.existsSync(diskPath);
|
|
547
|
-
|
|
548
|
-
// Last activity = most recent session mtime
|
|
549
|
-
const lastActivity = sessions.length ? sessions[0].mtime : null;
|
|
550
|
-
|
|
551
|
-
// Count auto-memory files from ~/.claude/projects/<slug>/memory/
|
|
552
|
-
let memoryCount = 0;
|
|
553
|
-
try {
|
|
554
|
-
const memDir = path.join(os.homedir(), '.claude', 'projects', slug, 'memory');
|
|
555
|
-
if (fs.existsSync(memDir)) {
|
|
556
|
-
memoryCount = fs.readdirSync(memDir).filter(f => f.endsWith('.md') && f !== 'MEMORY.md').length;
|
|
557
|
-
}
|
|
558
|
-
} catch {}
|
|
559
|
-
|
|
560
|
-
result.push({
|
|
561
|
-
slug,
|
|
562
|
-
name,
|
|
563
|
-
path: diskPath,
|
|
564
|
-
exists,
|
|
565
|
-
sessionCount: sessions.length,
|
|
566
|
-
sessions: sessions.slice(0, 5), // top 5 most recent
|
|
567
|
-
lastActivity,
|
|
568
|
-
memoryCount,
|
|
569
|
-
totalSize: sessions.reduce((sum, s) => sum + (s.size || 0), 0),
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// Sort by most recently active
|
|
574
|
-
result.sort((a, b) => (b.lastActivity || 0) - (a.lastActivity || 0));
|
|
575
|
-
_apCache = result;
|
|
576
|
-
_apCacheTs = Date.now();
|
|
577
|
-
return result;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
// ---------------------------------------------------------------------------
|
|
581
|
-
// Public API
|
|
582
|
-
// ---------------------------------------------------------------------------
|
|
583
|
-
|
|
584
|
-
export function collectAll(projectDir) {
|
|
585
|
-
const resolvedDir = path.resolve(projectDir);
|
|
586
|
-
|
|
587
|
-
return {
|
|
588
|
-
timestamp: Date.now(),
|
|
589
|
-
project: collectProject(resolvedDir),
|
|
590
|
-
sessions: collectSessions(resolvedDir),
|
|
591
|
-
swarm: collectSwarm(resolvedDir),
|
|
592
|
-
agents: collectAgents(resolvedDir),
|
|
593
|
-
tokens: collectTokens(resolvedDir),
|
|
594
|
-
hooks: collectHooks(resolvedDir),
|
|
595
|
-
knowledge: collectKnowledge(resolvedDir),
|
|
596
|
-
metrics: collectMetrics(resolvedDir),
|
|
597
|
-
triggers: collectTriggers(resolvedDir),
|
|
598
|
-
memory: collectMemory(resolvedDir),
|
|
599
|
-
system: collectSystem(),
|
|
600
|
-
allProjects: collectAllProjects(),
|
|
601
|
-
};
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
export { collectProject, collectSessions, collectSwarm, collectSwarmHistory, appendSwarmHistory, collectSwarmEvents, getSwarmDataSize, cleanSwarmData, collectAgents, collectTokens, collectHooks, collectKnowledge, collectMetrics, collectMemory, collectMemoryFiles, collectSystem };
|
|
605
|
-
|
|
606
|
-
export function getWatchPaths(projectDir) {
|
|
607
|
-
const resolvedDir = path.resolve(projectDir);
|
|
608
|
-
const m = path.join(resolvedDir, '.monomind');
|
|
609
|
-
const c = path.join(resolvedDir, '.claude');
|
|
610
|
-
|
|
611
|
-
return [
|
|
612
|
-
// Swarm
|
|
613
|
-
path.join(m, 'swarm', 'swarm-state.json'),
|
|
614
|
-
path.join(m, 'swarm', 'history.jsonl'),
|
|
615
|
-
path.join(m, 'swarm-config.json'),
|
|
616
|
-
// Metrics
|
|
617
|
-
path.join(m, 'metrics', 'swarm-activity.json'),
|
|
618
|
-
path.join(m, 'metrics', 'token-summary.json'),
|
|
619
|
-
path.join(m, 'metrics', 'token-sessions.json'),
|
|
620
|
-
path.join(m, 'metrics', 'ddd-progress.json'),
|
|
621
|
-
path.join(m, 'metrics', 'learning.json'),
|
|
622
|
-
// Agents
|
|
623
|
-
path.join(m, 'registry.json'),
|
|
624
|
-
path.join(m, 'agents', 'registrations'),
|
|
625
|
-
// Hooks / routing
|
|
626
|
-
path.join(m, 'last-route.json'),
|
|
627
|
-
path.join(m, 'routing-feedback.jsonl'),
|
|
628
|
-
path.join(m, 'worker-dispatch'),
|
|
629
|
-
// Knowledge
|
|
630
|
-
path.join(m, 'knowledge', 'chunks.jsonl'),
|
|
631
|
-
path.join(m, 'skills.jsonl'),
|
|
632
|
-
// Security
|
|
633
|
-
path.join(m, 'security', 'audit-status.json'),
|
|
634
|
-
// Triggers & memory — watch all candidate locations
|
|
635
|
-
path.join(m, 'trigger-index.json'),
|
|
636
|
-
path.join(resolvedDir, 'data', 'memory.db'),
|
|
637
|
-
path.join(resolvedDir, 'data', 'memory.graph'),
|
|
638
|
-
path.join(resolvedDir, '.swarm', 'memory.db'),
|
|
639
|
-
path.join(resolvedDir, '.swarm', 'hnsw.index'),
|
|
640
|
-
path.join(m, 'memory.db'),
|
|
641
|
-
path.join(m, 'data', 'monovector.db'),
|
|
642
|
-
path.join(m, 'data', 'ranked-context.json'),
|
|
643
|
-
// Sessions
|
|
644
|
-
path.join(c, 'sessions')
|
|
645
|
-
];
|
|
646
|
-
}
|