@swarmvaultai/engine 3.3.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/chunk-HKU2T5JX.js +25213 -0
- package/dist/hooks/codex.js +180 -0
- package/dist/index.d.ts +73 -1
- package/dist/index.js +58 -3
- package/dist/memory-K3NL5E3K.js +32 -0
- package/dist/viewer/assets/{index-KHPMdnQT.js → index-Cq5HAlrV.js} +44 -44
- package/dist/viewer/assets/index-CxosWf8Q.css +1 -0
- package/dist/viewer/index.html +2 -2
- package/dist/viewer/lib.d.ts +13 -1
- package/package.json +2 -2
- package/dist/viewer/assets/index-B0uvRPDV.css +0 -1
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/hooks/marker-state.ts
|
|
4
|
+
import crypto from "crypto";
|
|
5
|
+
import fs from "fs/promises";
|
|
6
|
+
import os from "os";
|
|
7
|
+
import path from "path";
|
|
8
|
+
function markerState(cwd, agentKey) {
|
|
9
|
+
const hash = crypto.createHash("sha256").update(cwd).digest("hex");
|
|
10
|
+
const dir = path.join(os.tmpdir(), "swarmvault-agent-hooks", agentKey, hash);
|
|
11
|
+
return {
|
|
12
|
+
dir,
|
|
13
|
+
markerPath: path.join(dir, "report-read")
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function isReportPath(value, cwd) {
|
|
17
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const reportSuffix = path.join("wiki", "graph", "report.md");
|
|
21
|
+
const normalized = value.replaceAll("\\", "/");
|
|
22
|
+
const reportNormalized = reportSuffix.replaceAll("\\", "/");
|
|
23
|
+
if (normalized.endsWith(reportNormalized)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return path.resolve(cwd, value) === path.resolve(cwd, reportSuffix);
|
|
27
|
+
}
|
|
28
|
+
function collectCandidatePaths(node, acc = []) {
|
|
29
|
+
if (typeof node === "string") {
|
|
30
|
+
acc.push(node);
|
|
31
|
+
return acc;
|
|
32
|
+
}
|
|
33
|
+
if (!node || typeof node !== "object") {
|
|
34
|
+
return acc;
|
|
35
|
+
}
|
|
36
|
+
if (Array.isArray(node)) {
|
|
37
|
+
for (const item of node) {
|
|
38
|
+
collectCandidatePaths(item, acc);
|
|
39
|
+
}
|
|
40
|
+
return acc;
|
|
41
|
+
}
|
|
42
|
+
for (const [key, value] of Object.entries(node)) {
|
|
43
|
+
if (["path", "filePath", "file_path", "paths", "target", "targets"].includes(key)) {
|
|
44
|
+
collectCandidatePaths(value, acc);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
collectCandidatePaths(value, acc);
|
|
48
|
+
}
|
|
49
|
+
return acc;
|
|
50
|
+
}
|
|
51
|
+
function resolveInputCwd(input) {
|
|
52
|
+
const shaped = input ?? {};
|
|
53
|
+
const candidate = typeof shaped.cwd === "string" && shaped.cwd || typeof shaped.directory === "string" && shaped.directory || typeof shaped.workspace?.cwd === "string" && shaped.workspace.cwd || typeof shaped.toolInput?.cwd === "string" && shaped.toolInput.cwd || process.cwd();
|
|
54
|
+
return path.resolve(candidate);
|
|
55
|
+
}
|
|
56
|
+
function resolveToolName(input) {
|
|
57
|
+
const shaped = input ?? {};
|
|
58
|
+
return String(shaped.toolName ?? shaped.tool_name ?? shaped.tool?.name ?? shaped.name ?? "");
|
|
59
|
+
}
|
|
60
|
+
async function hasReport(cwd) {
|
|
61
|
+
try {
|
|
62
|
+
await fs.access(path.join(cwd, "wiki", "graph", "report.md"));
|
|
63
|
+
return true;
|
|
64
|
+
} catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function markReportRead(cwd, agentKey) {
|
|
69
|
+
const state = markerState(cwd, agentKey);
|
|
70
|
+
await fs.mkdir(state.dir, { recursive: true });
|
|
71
|
+
await fs.writeFile(state.markerPath, "seen\n", "utf8");
|
|
72
|
+
}
|
|
73
|
+
async function hasSeenReport(cwd, agentKey) {
|
|
74
|
+
const state = markerState(cwd, agentKey);
|
|
75
|
+
try {
|
|
76
|
+
await fs.access(state.markerPath);
|
|
77
|
+
return true;
|
|
78
|
+
} catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function resetSession(cwd, agentKey) {
|
|
83
|
+
const state = markerState(cwd, agentKey);
|
|
84
|
+
await fs.rm(state.dir, { recursive: true, force: true });
|
|
85
|
+
}
|
|
86
|
+
function isBroadSearchTool(toolName) {
|
|
87
|
+
return /grep|glob|search|find/i.test(toolName);
|
|
88
|
+
}
|
|
89
|
+
function collectCommandCandidates(node, acc = []) {
|
|
90
|
+
if (!node || typeof node !== "object") {
|
|
91
|
+
return acc;
|
|
92
|
+
}
|
|
93
|
+
if (Array.isArray(node)) {
|
|
94
|
+
for (const item of node) {
|
|
95
|
+
collectCommandCandidates(item, acc);
|
|
96
|
+
}
|
|
97
|
+
return acc;
|
|
98
|
+
}
|
|
99
|
+
for (const [key, value] of Object.entries(node)) {
|
|
100
|
+
if (["command", "cmd", "script", "bash", "shell"].includes(key) && typeof value === "string") {
|
|
101
|
+
acc.push(value);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
collectCommandCandidates(value, acc);
|
|
105
|
+
}
|
|
106
|
+
return acc;
|
|
107
|
+
}
|
|
108
|
+
function commandLooksLikeBroadSearch(command) {
|
|
109
|
+
const tokens = command.replace(/[;&|()]/g, " ").split(/\s+/).map((token) => path.basename(token.replace(/^['"]|['"]$/g, ""))).filter(Boolean);
|
|
110
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
111
|
+
const token = tokens[index];
|
|
112
|
+
if (["rg", "grep", "find", "fd", "ag", "ack"].includes(token)) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
if (token === "git" && tokens[index + 1] === "grep") {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
function isBroadSearchInput(input) {
|
|
122
|
+
const toolName = resolveToolName(input);
|
|
123
|
+
if (isBroadSearchTool(toolName)) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
return collectCommandCandidates(input).some(commandLooksLikeBroadSearch);
|
|
127
|
+
}
|
|
128
|
+
async function readHookInput() {
|
|
129
|
+
let body = "";
|
|
130
|
+
for await (const chunk of process.stdin) {
|
|
131
|
+
body += chunk;
|
|
132
|
+
}
|
|
133
|
+
if (!body.trim()) {
|
|
134
|
+
return {};
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
return JSON.parse(body);
|
|
138
|
+
} catch {
|
|
139
|
+
return {};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
var REPORT_NOTE = "SwarmVault graph report exists at wiki/graph/report.md. Read it before broad grep/glob searching.";
|
|
143
|
+
|
|
144
|
+
// src/hooks/codex.ts
|
|
145
|
+
var AGENT_KEY = "codex";
|
|
146
|
+
function emit(value) {
|
|
147
|
+
process.stdout.write(`${JSON.stringify(value)}
|
|
148
|
+
`);
|
|
149
|
+
}
|
|
150
|
+
function note() {
|
|
151
|
+
return {
|
|
152
|
+
priority: "IMPORTANT",
|
|
153
|
+
message: REPORT_NOTE
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
async function main() {
|
|
157
|
+
const mode = process.argv[2] ?? "";
|
|
158
|
+
const input = await readHookInput();
|
|
159
|
+
const cwd = resolveInputCwd(input);
|
|
160
|
+
if (!await hasReport(cwd)) {
|
|
161
|
+
emit({});
|
|
162
|
+
process.exit(0);
|
|
163
|
+
}
|
|
164
|
+
if (mode === "session-start") {
|
|
165
|
+
await resetSession(cwd, AGENT_KEY);
|
|
166
|
+
emit(note());
|
|
167
|
+
process.exit(0);
|
|
168
|
+
}
|
|
169
|
+
if (collectCandidatePaths(input).some((value) => isReportPath(value, cwd))) {
|
|
170
|
+
await markReportRead(cwd, AGENT_KEY);
|
|
171
|
+
emit({});
|
|
172
|
+
process.exit(0);
|
|
173
|
+
}
|
|
174
|
+
if (isBroadSearchInput(input) && !await hasSeenReport(cwd, AGENT_KEY)) {
|
|
175
|
+
emit(note());
|
|
176
|
+
process.exit(0);
|
|
177
|
+
}
|
|
178
|
+
emit({});
|
|
179
|
+
}
|
|
180
|
+
await main();
|
package/dist/index.d.ts
CHANGED
|
@@ -872,6 +872,62 @@ interface GraphArtifact {
|
|
|
872
872
|
sources: SourceManifest[];
|
|
873
873
|
pages: GraphPage[];
|
|
874
874
|
}
|
|
875
|
+
interface GraphStatsResult {
|
|
876
|
+
generatedAt: string;
|
|
877
|
+
counts: {
|
|
878
|
+
sources: number;
|
|
879
|
+
pages: number;
|
|
880
|
+
nodes: number;
|
|
881
|
+
edges: number;
|
|
882
|
+
hyperedges: number;
|
|
883
|
+
communities: number;
|
|
884
|
+
};
|
|
885
|
+
nodeTypes: Partial<Record<GraphNode["type"], number>>;
|
|
886
|
+
evidenceClasses: Partial<Record<EvidenceClass, number>>;
|
|
887
|
+
sourceClasses: Record<SourceClass, {
|
|
888
|
+
sources: number;
|
|
889
|
+
pages: number;
|
|
890
|
+
nodes: number;
|
|
891
|
+
}>;
|
|
892
|
+
edgeRelations: Record<string, number>;
|
|
893
|
+
hyperedgeRelations: Record<string, number>;
|
|
894
|
+
}
|
|
895
|
+
interface GraphCommunityResult {
|
|
896
|
+
generatedAt: string;
|
|
897
|
+
id: string;
|
|
898
|
+
label: string;
|
|
899
|
+
nodeCount: number;
|
|
900
|
+
pageCount: number;
|
|
901
|
+
edgeCount: number;
|
|
902
|
+
nodes: Array<{
|
|
903
|
+
id: string;
|
|
904
|
+
type: GraphNode["type"];
|
|
905
|
+
label: string;
|
|
906
|
+
pageId?: string;
|
|
907
|
+
sourceClass?: SourceClass;
|
|
908
|
+
degree?: number;
|
|
909
|
+
bridgeScore?: number;
|
|
910
|
+
confidence?: number;
|
|
911
|
+
}>;
|
|
912
|
+
pages: Array<{
|
|
913
|
+
id: string;
|
|
914
|
+
path: string;
|
|
915
|
+
title: string;
|
|
916
|
+
kind: PageKind;
|
|
917
|
+
sourceClass?: SourceClass;
|
|
918
|
+
freshness: Freshness;
|
|
919
|
+
}>;
|
|
920
|
+
edges: Array<{
|
|
921
|
+
id: string;
|
|
922
|
+
source: string;
|
|
923
|
+
target: string;
|
|
924
|
+
sourceLabel?: string;
|
|
925
|
+
targetLabel?: string;
|
|
926
|
+
relation: string;
|
|
927
|
+
evidenceClass: EvidenceClass;
|
|
928
|
+
confidence: number;
|
|
929
|
+
}>;
|
|
930
|
+
}
|
|
875
931
|
interface GraphQueryMatch {
|
|
876
932
|
type: "node" | "page" | "hyperedge";
|
|
877
933
|
id: string;
|
|
@@ -1303,6 +1359,19 @@ interface VaultDoctorAction {
|
|
|
1303
1359
|
description: string;
|
|
1304
1360
|
destructive?: boolean;
|
|
1305
1361
|
}
|
|
1362
|
+
type VaultDoctorRecommendationPriority = "high" | "medium" | "low";
|
|
1363
|
+
type VaultDoctorSafeAction = "doctor:repair";
|
|
1364
|
+
interface VaultDoctorRecommendation {
|
|
1365
|
+
id: string;
|
|
1366
|
+
label: string;
|
|
1367
|
+
summary: string;
|
|
1368
|
+
priority: VaultDoctorRecommendationPriority;
|
|
1369
|
+
status: VaultDoctorStatus;
|
|
1370
|
+
sourceCheckId: string;
|
|
1371
|
+
command?: string;
|
|
1372
|
+
description?: string;
|
|
1373
|
+
safeAction?: VaultDoctorSafeAction;
|
|
1374
|
+
}
|
|
1306
1375
|
interface VaultDoctorCheck {
|
|
1307
1376
|
id: string;
|
|
1308
1377
|
label: string;
|
|
@@ -1330,6 +1399,7 @@ interface VaultDoctorReport {
|
|
|
1330
1399
|
version: string;
|
|
1331
1400
|
counts: VaultDoctorCounts;
|
|
1332
1401
|
checks: VaultDoctorCheck[];
|
|
1402
|
+
recommendations: VaultDoctorRecommendation[];
|
|
1333
1403
|
repaired: string[];
|
|
1334
1404
|
}
|
|
1335
1405
|
interface QueryOptions {
|
|
@@ -2846,6 +2916,8 @@ declare function benchmarkVault(rootDir: string, options?: BenchmarkOptions): Pr
|
|
|
2846
2916
|
declare function pathGraphVault(rootDir: string, from: string, to: string): Promise<GraphPathResult>;
|
|
2847
2917
|
declare function explainGraphVault(rootDir: string, target: string): Promise<GraphExplainResult>;
|
|
2848
2918
|
declare function listGraphHyperedges(rootDir: string, target?: string, limit?: number): Promise<GraphHyperedge[]>;
|
|
2919
|
+
declare function graphStatsVault(rootDir: string): Promise<GraphStatsResult>;
|
|
2920
|
+
declare function getGraphCommunityVault(rootDir: string, target: string, limit?: number): Promise<GraphCommunityResult>;
|
|
2849
2921
|
declare function readGraphReport(rootDir: string): Promise<GraphReportArtifact | null>;
|
|
2850
2922
|
declare function listGodNodes(rootDir: string, limit?: number): Promise<GraphNode[]>;
|
|
2851
2923
|
declare function blastRadiusVault(rootDir: string, target: string, options?: {
|
|
@@ -2945,4 +3017,4 @@ declare function createWebSearchAdapter(id: string, config: WebSearchProviderCon
|
|
|
2945
3017
|
type WebSearchTaskId = "deepLintProvider" | "queryProvider" | "exploreProvider";
|
|
2946
3018
|
declare function getWebSearchAdapterForTask(rootDir: string, task: WebSearchTaskId): Promise<WebSearchAdapter>;
|
|
2947
3019
|
|
|
2948
|
-
export { ALL_MIGRATIONS, type AddOptions, type AddResult, type AgentMemoryDecision, type AgentMemoryNote, type AgentMemoryResumeFormat, type AgentMemoryTask, type AgentMemoryTaskResult, type AgentMemoryTaskStatus, type AgentMemoryTaskSummary, type AgentType, type AnalyzedTerm, type ApprovalBundleType, type ApprovalChangeType, type ApprovalDetail, type ApprovalDiffHunk, type ApprovalDiffLine, type ApprovalEntry, type ApprovalEntryDetail, type ApprovalEntryLabel, type ApprovalEntryStatus, type ApprovalFrontmatterChange, type ApprovalManifest, type ApprovalStructuredDiff, type ApprovalSummary, type AudioTranscriptionRequest, type AudioTranscriptionResponse, type BenchmarkArtifact, type BenchmarkByClassEntry, type BenchmarkOptions, type BenchmarkQuestionResult, type BenchmarkSummary, type BlastRadiusResult, type BuildContextPackOptions, type BuildContextPackResult, type CandidatePromotionConfig, type CandidateRecord, type ChartDatum, type ChartSpec, type ClaimStatus, type CodeAnalysis, type CodeDiagnostic, type CodeImport, type CodeIndexArtifact, type CodeIndexEntry, type CodeLanguage, type CodeSymbol, type CodeSymbolKind, type CommandRoleExecutorConfig, type CompileOptions, type CompileResult, type CompileState, type ConsolidationConfig, type ConsolidationPromotion, type ConsolidationResult, type ContextPack, type ContextPackFormat, type ContextPackItem, type ContextPackItemKind, type ContextPackOmittedItem, type ContextPackSummary, DEFAULT_CONSOLIDATION_CONFIG, DEFAULT_HALF_LIFE_DAYS, DEFAULT_HALF_LIFE_DAYS_BY_SOURCE_CLASS, DEFAULT_PROMOTION_CONFIG, DEFAULT_REDACTION_PATTERNS, DEFAULT_STALE_THRESHOLD, type DegradationOutcome, type DirectoryIngestFailure, type DirectoryIngestResult, type DirectoryIngestSkip, type EmbeddingCacheArtifact, type EmbeddingCacheEntry, type EvidenceClass, type ExploreOptions, type ExploreResult, type ExploreStepResult, type ExtractionClaim, type ExtractionKind, type ExtractionTerm, type FinishMemoryTaskOptions, type Freshness, type FreshnessConfig, type GenerationAttachment, type GenerationRequest, type GenerationResponse, type GitHookStatus, type GraphArtifact, type GraphDiffResult, type GraphEdge, type GraphExplainNeighbor, type GraphExplainResult, type GraphExportFormat, type GraphExportResult, type GraphHyperedge, type GraphNode, type GraphPage, type GraphPathResult, type GraphPushCounts, type GraphPushNeo4jOptions, type GraphPushResult, type GraphQueryMatch, type GraphQueryResult, type GraphReportArtifact, type GraphShareArtifact, type GraphShareBundleFile, type GuidedSessionMode, type GuidedSourceSessionAnswers, type GuidedSourceSessionQuestion, type GuidedSourceSessionRecord, type GuidedSourceSessionStatus, type ImageGenerationRequest, type ImageGenerationResponse, type ImageVisionExtraction, type InboxImportResult, type InboxImportSkip, type IngestOptions, type InitOptions, type InputIngestResult, type InstallAgentOptions, type InstallAgentResult, LARGE_REPO_NODE_THRESHOLD, LOCAL_WHISPER_MODEL_SIZES, type LintFinding, type LintOptions, type LocalWhisperAdapterOptions, type LocalWhisperBinaryDiscovery, LocalWhisperProviderAdapter, type LocalWhisperSetupStatus, type ManagedSourceAddOptions, type ManagedSourceAddResult, type ManagedSourceDeleteResult, type ManagedSourceKind, type ManagedSourceRecord, type ManagedSourceReloadOptions, type ManagedSourceReloadResult, type ManagedSourceStatus, type ManagedSourceSyncCounts, type ManagedSourcesArtifact, type MemoryTier, type MigrationPlan, type MigrationResult, type MigrationStep, type Neo4jGraphSinkConfig, OPENAI_COMPATIBLE_CAPABILITY_MATRIX, type OpenAiCompatiblePresetId, type OrchestrationConfig, type OrchestrationFinding, type OrchestrationProposal, type OrchestrationRole, type OrchestrationRoleConfig, type OrchestrationRoleResult, type OutputAsset, type OutputAssetRole, type OutputFormat, type OutputOrigin, type PageKind, type PageManager, type PageStatus, type PendingSemanticRefreshEntry, type Polarity, type PromotionDecision, type PromotionGateKind, type PromotionGateResult, type PromotionSession, type ProviderAdapter, type ProviderCapability, type ProviderConfig, type ProviderPresetCapability, type ProviderRegistrationOptions, type ProviderRegistrationResult, type ProviderRoleExecutorConfig, type ProviderType, type QueryOptions, type QueryResult, type RedactionMatchSummary, type RedactionPatternConfig, type RedactionSettings, type RedactionSummary, type RepoSyncResult, type ResolvedLargeRepoDefaults, type ResolvedPaths, type ResumeMemoryTaskOptions, type ResumeMemoryTaskResult, type RetrievalConfig, type RetrievalDoctorResult, type RetrievalManifest, type RetrievalStatus, type ReviewActionResult, type RoleExecutorConfig, type SceneElement, type SceneSpec, type ScheduleController, type ScheduleJobConfig, type ScheduleStateRecord, type ScheduleTriggerConfig, type ScheduledCompileTask, type ScheduledConsolidateTask, type ScheduledExploreTask, type ScheduledLintTask, type ScheduledQueryTask, type ScheduledRunResult, type ScheduledTaskConfig, type SearchResult, type SourceAnalysis, type SourceAttachment, type SourceCaptureType, type SourceClaim, type SourceClass, type SourceExtractionArtifact, type SourceGuideResult, type SourceKind, type SourceManifest, type SourceRationale, type SourceReviewResult, type StartMemoryTaskOptions, type SynthesizedHubEdge, type SynthesizedHubNode, type SynthesizedHyperedgeHubs, type UpdateMemoryTaskOptions, type VaultConfig, type VaultDashboardPack, type VaultDoctorAction, type VaultDoctorCheck, type VaultDoctorCounts, type VaultDoctorReport, type VaultDoctorStatus, type VaultProfileConfig, type VaultProfilePreset, type VaultVersionRecord, type WatchConfig, type WatchController, type WatchOptions, type WatchRepoSyncResult, type WatchRunRecord, type WatchStatusResult, type WebSearchAdapter, type WebSearchProviderConfig, type WebSearchProviderType, type WebSearchResult, type WhisperRunResult, type WhisperRunner, acceptApproval, addInput, addManagedSource, addWatchedRoot, agentTypeSchema, applyDecayToPages, archiveCandidate, assertProviderCapability, autoCommitWikiChanges, benchmarkVault, blastRadius, blastRadiusVault, bootstrapDemo, buildConfiguredRedactor, buildContextPack, buildGraphShareArtifact, buildMemoryGraphElements, buildRedactor, compileVault, computeDecayScore, consolidateVault, createMcpServer, createProvider, createSupersessionEdge, createWebSearchAdapter, defaultVaultConfig, defaultVaultSchema, deleteContextPack, deleteManagedSource, detectVaultVersion, discoverLocalWhisperBinary, doctorRetrieval, doctorVault, downloadWhisperModel, ensureMemoryLedger, estimatePageTokens, estimateTokens, evaluateCandidateForPromotion, expectedModelPath, explainGraphVault, exploreVault, exportGraphFormat, exportGraphHtml, exportGraphReportHtml, exportObsidianCanvas, exportObsidianVault, finishMemoryTask, getGitHookStatus, getProviderForTask, getRetrievalStatus, getWatchStatus, getWebSearchAdapterForTask, getWorkspaceInfo, graphDiff, guideManagedSource, guideSourceScope, importInbox, ingestDirectory, ingestInput, ingestInputDetailed, initVault, initWorkspace, installAgent, installConfiguredAgents, installGitHooks, lintVault, listApprovals, listCandidates, listContextPacks, listGodNodes, listGraphHyperedges, listManagedSourceRecords, listManifests, listMemoryTasks, listPages, listSchedules, listTrackedRepoRoots, listWatchedRoots, loadMemoryTaskPages, loadVaultConfig, loadVaultSchema, loadVaultSchemas, lookupPresetCapabilities, markSuperseded, memoryTaskHashes, modelDownloadUrl, pathGraphVault, persistDecayFrontmatter, planMigration, previewCandidatePromotions, promoteCandidate, providerCapabilitySchema, providerTypeSchema, pushGraphNeo4j, queryGraphVault, queryVault, readApproval, readContextPack, readExtractedText, readGraphReport, readMemoryTask, readPage, rebuildRetrievalIndex, registerLocalWhisperProvider, rejectApproval, reloadManagedSources, removeWatchedRoot, renderContextPackLlms, renderContextPackMarkdown, renderGraphShareBundleFiles, renderGraphShareMarkdown, renderGraphSharePreviewHtml, renderGraphShareSvg, renderMemoryTaskMarkdown, resetDecay, resolveConsolidationConfig, resolveDecayConfig, resolveLargeRepoDefaults, resolvePaths, resolveRedactionPatterns, resolveRetrievalConfig, resolveWatchedRepoRoots, resumeMemoryTask, resumeSourceSession, reviewManagedSource, reviewSourceScope, runAutoPromotion, runConsolidation, runDecayPass, runMigration, runSchedule, runWatchCycle, searchVault, serveSchedules, stageGeneratedOutputPages, startGraphServer, startMcpServer, startMemoryTask, summarizeLocalWhisperSetup, syncTrackedRepos, syncTrackedReposForWatch, synthesizeHyperedgeHubs, trimToTokenBudget, uninstallGitHooks, updateMemoryTask, watchVault, webSearchProviderTypeSchema, withCapabilityFallback, writeRetrievalManifest };
|
|
3020
|
+
export { ALL_MIGRATIONS, type AddOptions, type AddResult, type AgentMemoryDecision, type AgentMemoryNote, type AgentMemoryResumeFormat, type AgentMemoryTask, type AgentMemoryTaskResult, type AgentMemoryTaskStatus, type AgentMemoryTaskSummary, type AgentType, type AnalyzedTerm, type ApprovalBundleType, type ApprovalChangeType, type ApprovalDetail, type ApprovalDiffHunk, type ApprovalDiffLine, type ApprovalEntry, type ApprovalEntryDetail, type ApprovalEntryLabel, type ApprovalEntryStatus, type ApprovalFrontmatterChange, type ApprovalManifest, type ApprovalStructuredDiff, type ApprovalSummary, type AudioTranscriptionRequest, type AudioTranscriptionResponse, type BenchmarkArtifact, type BenchmarkByClassEntry, type BenchmarkOptions, type BenchmarkQuestionResult, type BenchmarkSummary, type BlastRadiusResult, type BuildContextPackOptions, type BuildContextPackResult, type CandidatePromotionConfig, type CandidateRecord, type ChartDatum, type ChartSpec, type ClaimStatus, type CodeAnalysis, type CodeDiagnostic, type CodeImport, type CodeIndexArtifact, type CodeIndexEntry, type CodeLanguage, type CodeSymbol, type CodeSymbolKind, type CommandRoleExecutorConfig, type CompileOptions, type CompileResult, type CompileState, type ConsolidationConfig, type ConsolidationPromotion, type ConsolidationResult, type ContextPack, type ContextPackFormat, type ContextPackItem, type ContextPackItemKind, type ContextPackOmittedItem, type ContextPackSummary, DEFAULT_CONSOLIDATION_CONFIG, DEFAULT_HALF_LIFE_DAYS, DEFAULT_HALF_LIFE_DAYS_BY_SOURCE_CLASS, DEFAULT_PROMOTION_CONFIG, DEFAULT_REDACTION_PATTERNS, DEFAULT_STALE_THRESHOLD, type DegradationOutcome, type DirectoryIngestFailure, type DirectoryIngestResult, type DirectoryIngestSkip, type EmbeddingCacheArtifact, type EmbeddingCacheEntry, type EvidenceClass, type ExploreOptions, type ExploreResult, type ExploreStepResult, type ExtractionClaim, type ExtractionKind, type ExtractionTerm, type FinishMemoryTaskOptions, type Freshness, type FreshnessConfig, type GenerationAttachment, type GenerationRequest, type GenerationResponse, type GitHookStatus, type GraphArtifact, type GraphCommunityResult, type GraphDiffResult, type GraphEdge, type GraphExplainNeighbor, type GraphExplainResult, type GraphExportFormat, type GraphExportResult, type GraphHyperedge, type GraphNode, type GraphPage, type GraphPathResult, type GraphPushCounts, type GraphPushNeo4jOptions, type GraphPushResult, type GraphQueryMatch, type GraphQueryResult, type GraphReportArtifact, type GraphShareArtifact, type GraphShareBundleFile, type GraphStatsResult, type GuidedSessionMode, type GuidedSourceSessionAnswers, type GuidedSourceSessionQuestion, type GuidedSourceSessionRecord, type GuidedSourceSessionStatus, type ImageGenerationRequest, type ImageGenerationResponse, type ImageVisionExtraction, type InboxImportResult, type InboxImportSkip, type IngestOptions, type InitOptions, type InputIngestResult, type InstallAgentOptions, type InstallAgentResult, LARGE_REPO_NODE_THRESHOLD, LOCAL_WHISPER_MODEL_SIZES, type LintFinding, type LintOptions, type LocalWhisperAdapterOptions, type LocalWhisperBinaryDiscovery, LocalWhisperProviderAdapter, type LocalWhisperSetupStatus, type ManagedSourceAddOptions, type ManagedSourceAddResult, type ManagedSourceDeleteResult, type ManagedSourceKind, type ManagedSourceRecord, type ManagedSourceReloadOptions, type ManagedSourceReloadResult, type ManagedSourceStatus, type ManagedSourceSyncCounts, type ManagedSourcesArtifact, type MemoryTier, type MigrationPlan, type MigrationResult, type MigrationStep, type Neo4jGraphSinkConfig, OPENAI_COMPATIBLE_CAPABILITY_MATRIX, type OpenAiCompatiblePresetId, type OrchestrationConfig, type OrchestrationFinding, type OrchestrationProposal, type OrchestrationRole, type OrchestrationRoleConfig, type OrchestrationRoleResult, type OutputAsset, type OutputAssetRole, type OutputFormat, type OutputOrigin, type PageKind, type PageManager, type PageStatus, type PendingSemanticRefreshEntry, type Polarity, type PromotionDecision, type PromotionGateKind, type PromotionGateResult, type PromotionSession, type ProviderAdapter, type ProviderCapability, type ProviderConfig, type ProviderPresetCapability, type ProviderRegistrationOptions, type ProviderRegistrationResult, type ProviderRoleExecutorConfig, type ProviderType, type QueryOptions, type QueryResult, type RedactionMatchSummary, type RedactionPatternConfig, type RedactionSettings, type RedactionSummary, type RepoSyncResult, type ResolvedLargeRepoDefaults, type ResolvedPaths, type ResumeMemoryTaskOptions, type ResumeMemoryTaskResult, type RetrievalConfig, type RetrievalDoctorResult, type RetrievalManifest, type RetrievalStatus, type ReviewActionResult, type RoleExecutorConfig, type SceneElement, type SceneSpec, type ScheduleController, type ScheduleJobConfig, type ScheduleStateRecord, type ScheduleTriggerConfig, type ScheduledCompileTask, type ScheduledConsolidateTask, type ScheduledExploreTask, type ScheduledLintTask, type ScheduledQueryTask, type ScheduledRunResult, type ScheduledTaskConfig, type SearchResult, type SourceAnalysis, type SourceAttachment, type SourceCaptureType, type SourceClaim, type SourceClass, type SourceExtractionArtifact, type SourceGuideResult, type SourceKind, type SourceManifest, type SourceRationale, type SourceReviewResult, type StartMemoryTaskOptions, type SynthesizedHubEdge, type SynthesizedHubNode, type SynthesizedHyperedgeHubs, type UpdateMemoryTaskOptions, type VaultConfig, type VaultDashboardPack, type VaultDoctorAction, type VaultDoctorCheck, type VaultDoctorCounts, type VaultDoctorRecommendation, type VaultDoctorRecommendationPriority, type VaultDoctorReport, type VaultDoctorSafeAction, type VaultDoctorStatus, type VaultProfileConfig, type VaultProfilePreset, type VaultVersionRecord, type WatchConfig, type WatchController, type WatchOptions, type WatchRepoSyncResult, type WatchRunRecord, type WatchStatusResult, type WebSearchAdapter, type WebSearchProviderConfig, type WebSearchProviderType, type WebSearchResult, type WhisperRunResult, type WhisperRunner, acceptApproval, addInput, addManagedSource, addWatchedRoot, agentTypeSchema, applyDecayToPages, archiveCandidate, assertProviderCapability, autoCommitWikiChanges, benchmarkVault, blastRadius, blastRadiusVault, bootstrapDemo, buildConfiguredRedactor, buildContextPack, buildGraphShareArtifact, buildMemoryGraphElements, buildRedactor, compileVault, computeDecayScore, consolidateVault, createMcpServer, createProvider, createSupersessionEdge, createWebSearchAdapter, defaultVaultConfig, defaultVaultSchema, deleteContextPack, deleteManagedSource, detectVaultVersion, discoverLocalWhisperBinary, doctorRetrieval, doctorVault, downloadWhisperModel, ensureMemoryLedger, estimatePageTokens, estimateTokens, evaluateCandidateForPromotion, expectedModelPath, explainGraphVault, exploreVault, exportGraphFormat, exportGraphHtml, exportGraphReportHtml, exportObsidianCanvas, exportObsidianVault, finishMemoryTask, getGitHookStatus, getGraphCommunityVault, getProviderForTask, getRetrievalStatus, getWatchStatus, getWebSearchAdapterForTask, getWorkspaceInfo, graphDiff, graphStatsVault, guideManagedSource, guideSourceScope, importInbox, ingestDirectory, ingestInput, ingestInputDetailed, initVault, initWorkspace, installAgent, installConfiguredAgents, installGitHooks, lintVault, listApprovals, listCandidates, listContextPacks, listGodNodes, listGraphHyperedges, listManagedSourceRecords, listManifests, listMemoryTasks, listPages, listSchedules, listTrackedRepoRoots, listWatchedRoots, loadMemoryTaskPages, loadVaultConfig, loadVaultSchema, loadVaultSchemas, lookupPresetCapabilities, markSuperseded, memoryTaskHashes, modelDownloadUrl, pathGraphVault, persistDecayFrontmatter, planMigration, previewCandidatePromotions, promoteCandidate, providerCapabilitySchema, providerTypeSchema, pushGraphNeo4j, queryGraphVault, queryVault, readApproval, readContextPack, readExtractedText, readGraphReport, readMemoryTask, readPage, rebuildRetrievalIndex, registerLocalWhisperProvider, rejectApproval, reloadManagedSources, removeWatchedRoot, renderContextPackLlms, renderContextPackMarkdown, renderGraphShareBundleFiles, renderGraphShareMarkdown, renderGraphSharePreviewHtml, renderGraphShareSvg, renderMemoryTaskMarkdown, resetDecay, resolveConsolidationConfig, resolveDecayConfig, resolveLargeRepoDefaults, resolvePaths, resolveRedactionPatterns, resolveRetrievalConfig, resolveWatchedRepoRoots, resumeMemoryTask, resumeSourceSession, reviewManagedSource, reviewSourceScope, runAutoPromotion, runConsolidation, runDecayPass, runMigration, runSchedule, runWatchCycle, searchVault, serveSchedules, stageGeneratedOutputPages, startGraphServer, startMcpServer, startMemoryTask, summarizeLocalWhisperSetup, syncTrackedRepos, syncTrackedReposForWatch, synthesizeHyperedgeHubs, trimToTokenBudget, uninstallGitHooks, updateMemoryTask, watchVault, webSearchProviderTypeSchema, withCapabilityFallback, writeRetrievalManifest };
|
package/dist/index.js
CHANGED
|
@@ -38,11 +38,13 @@ import {
|
|
|
38
38
|
exploreVault,
|
|
39
39
|
findLatestGuidedSourceSessionByScope,
|
|
40
40
|
finishMemoryTask,
|
|
41
|
+
getGraphCommunityVault,
|
|
41
42
|
getRetrievalStatus,
|
|
42
43
|
getWebSearchAdapterForTask,
|
|
43
44
|
getWorkspaceInfo,
|
|
44
45
|
graphDiff,
|
|
45
46
|
graphHash,
|
|
47
|
+
graphStatsVault,
|
|
46
48
|
guidedSourceSessionStatePath,
|
|
47
49
|
importInbox,
|
|
48
50
|
ingestDirectory,
|
|
@@ -121,7 +123,7 @@ import {
|
|
|
121
123
|
writeGuidedSourceSession,
|
|
122
124
|
writeRetrievalManifest,
|
|
123
125
|
writeWatchStatusArtifact
|
|
124
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-HKU2T5JX.js";
|
|
125
127
|
import {
|
|
126
128
|
LocalWhisperProviderAdapter,
|
|
127
129
|
appendJsonLine,
|
|
@@ -1128,6 +1130,33 @@ function worstStatus(checks) {
|
|
|
1128
1130
|
if (checks.some((check) => check.status === "warning")) return "warning";
|
|
1129
1131
|
return "ok";
|
|
1130
1132
|
}
|
|
1133
|
+
function recommendationPriority(status) {
|
|
1134
|
+
if (status === "error") return "high";
|
|
1135
|
+
if (status === "warning") return "medium";
|
|
1136
|
+
return "low";
|
|
1137
|
+
}
|
|
1138
|
+
function safeActionFor(checkId, command) {
|
|
1139
|
+
if (checkId === "retrieval" && command === "swarmvault retrieval doctor --repair") {
|
|
1140
|
+
return "doctor:repair";
|
|
1141
|
+
}
|
|
1142
|
+
return void 0;
|
|
1143
|
+
}
|
|
1144
|
+
function buildRecommendations(checks) {
|
|
1145
|
+
const rank = { high: 0, medium: 1, low: 2 };
|
|
1146
|
+
return checks.filter((check) => check.status !== "ok").flatMap(
|
|
1147
|
+
(check) => (check.actions ?? []).map((action) => ({
|
|
1148
|
+
id: `${check.id}:${action.command}`,
|
|
1149
|
+
label: `Fix ${check.label}`,
|
|
1150
|
+
summary: check.summary,
|
|
1151
|
+
priority: recommendationPriority(check.status),
|
|
1152
|
+
status: check.status,
|
|
1153
|
+
sourceCheckId: check.id,
|
|
1154
|
+
command: action.command,
|
|
1155
|
+
description: action.description,
|
|
1156
|
+
safeAction: safeActionFor(check.id, action.command)
|
|
1157
|
+
}))
|
|
1158
|
+
).sort((left, right) => rank[left.priority] - rank[right.priority] || left.label.localeCompare(right.label));
|
|
1159
|
+
}
|
|
1131
1160
|
async function currentPackageVersion2() {
|
|
1132
1161
|
try {
|
|
1133
1162
|
const raw = await fs3.readFile(new URL("../package.json", import.meta.url), "utf8");
|
|
@@ -1287,6 +1316,7 @@ async function doctorVault(rootDir, options = {}) {
|
|
|
1287
1316
|
] : []
|
|
1288
1317
|
});
|
|
1289
1318
|
const status = worstStatus(checks);
|
|
1319
|
+
const recommendations = buildRecommendations(checks);
|
|
1290
1320
|
return {
|
|
1291
1321
|
ok: status === "ok",
|
|
1292
1322
|
status,
|
|
@@ -1305,6 +1335,7 @@ async function doctorVault(rootDir, options = {}) {
|
|
|
1305
1335
|
pendingSemanticRefresh: watchStatus.pendingSemanticRefresh.length
|
|
1306
1336
|
},
|
|
1307
1337
|
checks,
|
|
1338
|
+
recommendations,
|
|
1308
1339
|
repaired
|
|
1309
1340
|
};
|
|
1310
1341
|
}
|
|
@@ -4033,7 +4064,7 @@ import path7 from "path";
|
|
|
4033
4064
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4034
4065
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4035
4066
|
import { z } from "zod";
|
|
4036
|
-
var SERVER_VERSION = "3.
|
|
4067
|
+
var SERVER_VERSION = "3.5.0";
|
|
4037
4068
|
async function createMcpServer(rootDir) {
|
|
4038
4069
|
const server = new McpServer({
|
|
4039
4070
|
name: "swarmvault",
|
|
@@ -4162,6 +4193,15 @@ async function createMcpServer(rootDir) {
|
|
|
4162
4193
|
return asToolText(await readGraphReport(rootDir) ?? { error: "Graph report not found. Run `swarmvault compile` first." });
|
|
4163
4194
|
})
|
|
4164
4195
|
);
|
|
4196
|
+
server.registerTool(
|
|
4197
|
+
"graph_stats",
|
|
4198
|
+
{
|
|
4199
|
+
description: "Return lightweight counts for graph nodes, evidence classes, source classes, communities, pages, and edges."
|
|
4200
|
+
},
|
|
4201
|
+
safeHandler(async () => {
|
|
4202
|
+
return asToolText(await graphStatsVault(rootDir));
|
|
4203
|
+
})
|
|
4204
|
+
);
|
|
4165
4205
|
server.registerTool(
|
|
4166
4206
|
"get_node",
|
|
4167
4207
|
{
|
|
@@ -4174,6 +4214,19 @@ async function createMcpServer(rootDir) {
|
|
|
4174
4214
|
return asToolText(await explainGraphVault(rootDir, target));
|
|
4175
4215
|
})
|
|
4176
4216
|
);
|
|
4217
|
+
server.registerTool(
|
|
4218
|
+
"get_community",
|
|
4219
|
+
{
|
|
4220
|
+
description: "Return members, pages, and top evidence edges for a graph community by id or label.",
|
|
4221
|
+
inputSchema: {
|
|
4222
|
+
target: z.string().min(1).describe("Community id or label"),
|
|
4223
|
+
limit: z.number().int().min(1).max(100).optional().describe("Maximum evidence edges to return")
|
|
4224
|
+
}
|
|
4225
|
+
},
|
|
4226
|
+
safeHandler(async ({ target, limit }) => {
|
|
4227
|
+
return asToolText(await getGraphCommunityVault(rootDir, target, limit ?? 25));
|
|
4228
|
+
})
|
|
4229
|
+
);
|
|
4177
4230
|
server.registerTool(
|
|
4178
4231
|
"get_hyperedges",
|
|
4179
4232
|
{
|
|
@@ -7839,7 +7892,7 @@ async function startGraphServer(rootDir, port, options = {}) {
|
|
|
7839
7892
|
return;
|
|
7840
7893
|
}
|
|
7841
7894
|
if (url.pathname === "/api/bookmarklet") {
|
|
7842
|
-
const script = `javascript:void(fetch('http://localhost:${effectivePort}/api/clip',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(
|
|
7895
|
+
const script = `javascript:void((async()=>{const selection=String(getSelection()||'').trim();const payload={url:location.href,title:document.title,sourceMode:selection?'inbox':'add'};if(selection)payload.selectionText=selection;const response=await fetch('http://localhost:${effectivePort}/api/clip',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(payload)});const data=await response.json();if(!response.ok)throw new Error(data.error||response.statusText);alert('Clipped: '+(data.title||data.sourceId));})().catch(e=>alert('Clip failed: '+e.message)))`;
|
|
7843
7896
|
response.writeHead(200, { "content-type": "text/html" });
|
|
7844
7897
|
response.end(
|
|
7845
7898
|
[
|
|
@@ -8025,12 +8078,14 @@ export {
|
|
|
8025
8078
|
exportObsidianVault,
|
|
8026
8079
|
finishMemoryTask,
|
|
8027
8080
|
getGitHookStatus,
|
|
8081
|
+
getGraphCommunityVault,
|
|
8028
8082
|
getProviderForTask,
|
|
8029
8083
|
getRetrievalStatus,
|
|
8030
8084
|
getWatchStatus,
|
|
8031
8085
|
getWebSearchAdapterForTask,
|
|
8032
8086
|
getWorkspaceInfo,
|
|
8033
8087
|
graphDiff,
|
|
8088
|
+
graphStatsVault,
|
|
8034
8089
|
guideManagedSource,
|
|
8035
8090
|
guideSourceScope,
|
|
8036
8091
|
importInbox,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildMemoryGraphElements,
|
|
3
|
+
ensureMemoryLedger,
|
|
4
|
+
estimateMemoryTaskTokens,
|
|
5
|
+
finishMemoryTask,
|
|
6
|
+
listMemoryTasks,
|
|
7
|
+
loadMemoryTaskPages,
|
|
8
|
+
memoryTaskHashes,
|
|
9
|
+
memoryTaskPageRecord,
|
|
10
|
+
readMemoryTask,
|
|
11
|
+
renderMemoryTaskMarkdown,
|
|
12
|
+
resumeMemoryTask,
|
|
13
|
+
startMemoryTask,
|
|
14
|
+
updateMemoryTask
|
|
15
|
+
} from "./chunk-HKU2T5JX.js";
|
|
16
|
+
import "./chunk-7QHDATCQ.js";
|
|
17
|
+
import "./chunk-NAIERP4C.js";
|
|
18
|
+
export {
|
|
19
|
+
buildMemoryGraphElements,
|
|
20
|
+
ensureMemoryLedger,
|
|
21
|
+
estimateMemoryTaskTokens,
|
|
22
|
+
finishMemoryTask,
|
|
23
|
+
listMemoryTasks,
|
|
24
|
+
loadMemoryTaskPages,
|
|
25
|
+
memoryTaskHashes,
|
|
26
|
+
memoryTaskPageRecord,
|
|
27
|
+
readMemoryTask,
|
|
28
|
+
renderMemoryTaskMarkdown,
|
|
29
|
+
resumeMemoryTask,
|
|
30
|
+
startMemoryTask,
|
|
31
|
+
updateMemoryTask
|
|
32
|
+
};
|