@swarmvaultai/engine 0.1.5 → 0.1.7
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 +44 -15
- package/dist/chunk-HFU5S5NO.js +838 -0
- package/dist/index.d.ts +371 -13
- package/dist/index.js +5256 -1201
- package/dist/registry-U76DBOV3.js +12 -0
- package/dist/viewer/assets/index-mRA-6D-Z.css +1 -0
- package/dist/viewer/assets/index-sMKSYq5V.js +330 -0
- package/dist/viewer/index.html +2 -2
- package/dist/viewer/lib.d.ts +121 -1
- package/dist/viewer/lib.js +154 -1
- package/package.json +2 -1
- package/dist/viewer/assets/index-9TSXS8Kg.css +0 -1
- package/dist/viewer/assets/index-DJuffpAB.js +0 -329
package/dist/viewer/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>SwarmVault Graph</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-sMKSYq5V.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="/assets/index-mRA-6D-Z.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="root"></div>
|
package/dist/viewer/lib.d.ts
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
|
+
type ViewerOutputAsset = {
|
|
2
|
+
id: string;
|
|
3
|
+
role: string;
|
|
4
|
+
path: string;
|
|
5
|
+
mimeType: string;
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
dataPath?: string;
|
|
9
|
+
dataUrl?: string;
|
|
10
|
+
};
|
|
1
11
|
type ViewerGraphNode = {
|
|
2
12
|
id: string;
|
|
3
13
|
type: string;
|
|
4
14
|
label: string;
|
|
5
15
|
sourceIds: string[];
|
|
16
|
+
projectIds: string[];
|
|
17
|
+
pageId?: string;
|
|
18
|
+
language?: string;
|
|
19
|
+
moduleId?: string;
|
|
20
|
+
symbolKind?: string;
|
|
21
|
+
communityId?: string;
|
|
22
|
+
degree?: number;
|
|
23
|
+
bridgeScore?: number;
|
|
24
|
+
isGodNode?: boolean;
|
|
6
25
|
};
|
|
7
26
|
type ViewerGraphEdge = {
|
|
8
27
|
id: string;
|
|
@@ -10,12 +29,113 @@ type ViewerGraphEdge = {
|
|
|
10
29
|
target: string;
|
|
11
30
|
relation: string;
|
|
12
31
|
status: string;
|
|
32
|
+
confidence?: number;
|
|
33
|
+
};
|
|
34
|
+
type ViewerGraphPage = {
|
|
35
|
+
pageId: string;
|
|
36
|
+
path: string;
|
|
37
|
+
title: string;
|
|
38
|
+
kind: string;
|
|
39
|
+
status: string;
|
|
40
|
+
projectIds: string[];
|
|
41
|
+
content: string;
|
|
42
|
+
assets: ViewerOutputAsset[];
|
|
13
43
|
};
|
|
14
44
|
type ViewerGraphArtifact = {
|
|
15
45
|
generatedAt: string;
|
|
16
46
|
nodes: ViewerGraphNode[];
|
|
17
47
|
edges: ViewerGraphEdge[];
|
|
48
|
+
communities?: Array<{
|
|
49
|
+
id: string;
|
|
50
|
+
label: string;
|
|
51
|
+
nodeIds: string[];
|
|
52
|
+
}>;
|
|
53
|
+
pages?: Array<{
|
|
54
|
+
id: string;
|
|
55
|
+
path: string;
|
|
56
|
+
title: string;
|
|
57
|
+
kind: string;
|
|
58
|
+
status: string;
|
|
59
|
+
projectIds: string[];
|
|
60
|
+
nodeIds: string[];
|
|
61
|
+
backlinks: string[];
|
|
62
|
+
relatedPageIds: string[];
|
|
63
|
+
}>;
|
|
64
|
+
};
|
|
65
|
+
type ViewerSearchResult = {
|
|
66
|
+
pageId: string;
|
|
67
|
+
path: string;
|
|
68
|
+
title: string;
|
|
69
|
+
snippet: string;
|
|
70
|
+
rank: number;
|
|
71
|
+
kind?: string;
|
|
72
|
+
status?: string;
|
|
73
|
+
projectIds: string[];
|
|
74
|
+
};
|
|
75
|
+
type ViewerPagePayload = {
|
|
76
|
+
path: string;
|
|
77
|
+
title: string;
|
|
78
|
+
frontmatter: Record<string, unknown>;
|
|
79
|
+
content: string;
|
|
80
|
+
assets: ViewerOutputAsset[];
|
|
81
|
+
};
|
|
82
|
+
type ViewerApprovalSummary = {
|
|
83
|
+
approvalId: string;
|
|
84
|
+
createdAt: string;
|
|
85
|
+
entryCount: number;
|
|
86
|
+
pendingCount: number;
|
|
87
|
+
acceptedCount: number;
|
|
88
|
+
rejectedCount: number;
|
|
89
|
+
};
|
|
90
|
+
type ViewerApprovalEntry = {
|
|
91
|
+
pageId: string;
|
|
92
|
+
title: string;
|
|
93
|
+
kind: string;
|
|
94
|
+
changeType: string;
|
|
95
|
+
status: string;
|
|
96
|
+
sourceIds: string[];
|
|
97
|
+
nextPath?: string;
|
|
98
|
+
previousPath?: string;
|
|
99
|
+
currentContent?: string;
|
|
100
|
+
stagedContent?: string;
|
|
101
|
+
};
|
|
102
|
+
type ViewerApprovalDetail = ViewerApprovalSummary & {
|
|
103
|
+
entries: ViewerApprovalEntry[];
|
|
104
|
+
};
|
|
105
|
+
type ViewerReviewActionResult = ViewerApprovalSummary & {
|
|
106
|
+
updatedEntries: string[];
|
|
107
|
+
};
|
|
108
|
+
type ViewerCandidateRecord = {
|
|
109
|
+
pageId: string;
|
|
110
|
+
title: string;
|
|
111
|
+
kind: "concept" | "entity";
|
|
112
|
+
path: string;
|
|
113
|
+
activePath: string;
|
|
114
|
+
sourceIds: string[];
|
|
115
|
+
createdAt: string;
|
|
116
|
+
updatedAt: string;
|
|
117
|
+
};
|
|
118
|
+
declare global {
|
|
119
|
+
interface Window {
|
|
120
|
+
__SWARMVAULT_EMBEDDED_DATA__?: {
|
|
121
|
+
graph: ViewerGraphArtifact;
|
|
122
|
+
pages: ViewerGraphPage[];
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
type ViewerSearchOptions = {
|
|
127
|
+
limit?: number;
|
|
128
|
+
kind?: string;
|
|
129
|
+
status?: string;
|
|
130
|
+
project?: string;
|
|
18
131
|
};
|
|
19
132
|
declare function fetchGraphArtifact(input?: string, init?: RequestInit): Promise<ViewerGraphArtifact>;
|
|
133
|
+
declare function searchViewerPages(query: string, options?: ViewerSearchOptions): Promise<ViewerSearchResult[]>;
|
|
134
|
+
declare function fetchViewerPage(path: string): Promise<ViewerPagePayload>;
|
|
135
|
+
declare function fetchApprovals(): Promise<ViewerApprovalSummary[]>;
|
|
136
|
+
declare function fetchApprovalDetail(approvalId: string): Promise<ViewerApprovalDetail>;
|
|
137
|
+
declare function applyReviewAction(approvalId: string, action: "accept" | "reject", targets?: string[]): Promise<ViewerReviewActionResult>;
|
|
138
|
+
declare function fetchCandidates(): Promise<ViewerCandidateRecord[]>;
|
|
139
|
+
declare function applyCandidateAction(target: string, action: "promote" | "archive"): Promise<ViewerCandidateRecord>;
|
|
20
140
|
|
|
21
|
-
export { type ViewerGraphArtifact, type ViewerGraphEdge, type ViewerGraphNode, fetchGraphArtifact };
|
|
141
|
+
export { type ViewerApprovalDetail, type ViewerApprovalEntry, type ViewerApprovalSummary, type ViewerCandidateRecord, type ViewerGraphArtifact, type ViewerGraphEdge, type ViewerGraphNode, type ViewerGraphPage, type ViewerOutputAsset, type ViewerPagePayload, type ViewerReviewActionResult, type ViewerSearchOptions, type ViewerSearchResult, applyCandidateAction, applyReviewAction, fetchApprovalDetail, fetchApprovals, fetchCandidates, fetchGraphArtifact, fetchViewerPage, searchViewerPages };
|
package/dist/viewer/lib.js
CHANGED
|
@@ -1,11 +1,164 @@
|
|
|
1
1
|
// src/lib.ts
|
|
2
|
+
function embeddedData() {
|
|
3
|
+
return typeof window !== "undefined" ? window.__SWARMVAULT_EMBEDDED_DATA__ : void 0;
|
|
4
|
+
}
|
|
5
|
+
function normalizeSnippet(content, query) {
|
|
6
|
+
const normalized = content.replace(/\s+/g, " ").trim();
|
|
7
|
+
if (!query) {
|
|
8
|
+
return normalized.slice(0, 160);
|
|
9
|
+
}
|
|
10
|
+
const index = normalized.toLowerCase().indexOf(query.toLowerCase());
|
|
11
|
+
if (index < 0) {
|
|
12
|
+
return normalized.slice(0, 160);
|
|
13
|
+
}
|
|
14
|
+
const start = Math.max(0, index - 50);
|
|
15
|
+
const end = Math.min(normalized.length, index + Math.max(query.length, 40));
|
|
16
|
+
return `${start > 0 ? "..." : ""}${normalized.slice(start, end)}${end < normalized.length ? "..." : ""}`;
|
|
17
|
+
}
|
|
2
18
|
async function fetchGraphArtifact(input = "/api/graph", init) {
|
|
19
|
+
const embedded = embeddedData();
|
|
20
|
+
if (embedded) {
|
|
21
|
+
return embedded.graph;
|
|
22
|
+
}
|
|
3
23
|
const response = await fetch(input, init);
|
|
4
24
|
if (!response.ok) {
|
|
5
25
|
throw new Error(`Failed to load graph artifact: ${response.status} ${response.statusText}`);
|
|
6
26
|
}
|
|
7
27
|
return response.json();
|
|
8
28
|
}
|
|
29
|
+
async function searchViewerPages(query, options = {}) {
|
|
30
|
+
const embedded = embeddedData();
|
|
31
|
+
const limit = options.limit ?? 10;
|
|
32
|
+
const kind = options.kind ?? "all";
|
|
33
|
+
const status = options.status ?? "all";
|
|
34
|
+
const project = options.project ?? "all";
|
|
35
|
+
if (embedded) {
|
|
36
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
37
|
+
if (!normalizedQuery) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
return embedded.pages.filter((page) => kind === "all" ? true : page.kind === kind).filter((page) => status === "all" ? true : page.status === status).filter(
|
|
41
|
+
(page) => project === "all" ? true : project === "unassigned" ? page.projectIds.length === 0 : page.projectIds.includes(project)
|
|
42
|
+
).map((page) => {
|
|
43
|
+
const haystack = `${page.title}
|
|
44
|
+
${page.content}`.toLowerCase();
|
|
45
|
+
const score = haystack.includes(normalizedQuery) ? haystack.indexOf(normalizedQuery) : Number.POSITIVE_INFINITY;
|
|
46
|
+
return {
|
|
47
|
+
pageId: page.pageId,
|
|
48
|
+
path: page.path,
|
|
49
|
+
title: page.title,
|
|
50
|
+
snippet: normalizeSnippet(page.content, query),
|
|
51
|
+
rank: score,
|
|
52
|
+
kind: page.kind,
|
|
53
|
+
status: page.status,
|
|
54
|
+
projectIds: page.projectIds
|
|
55
|
+
};
|
|
56
|
+
}).filter((page) => Number.isFinite(page.rank)).sort((left, right) => left.rank - right.rank || left.title.localeCompare(right.title)).slice(0, limit);
|
|
57
|
+
}
|
|
58
|
+
const params = new URLSearchParams({
|
|
59
|
+
q: query,
|
|
60
|
+
limit: String(limit),
|
|
61
|
+
kind,
|
|
62
|
+
status,
|
|
63
|
+
project
|
|
64
|
+
});
|
|
65
|
+
const response = await fetch(`/api/search?${params.toString()}`);
|
|
66
|
+
if (!response.ok) {
|
|
67
|
+
throw new Error(`Failed to search pages: ${response.status} ${response.statusText}`);
|
|
68
|
+
}
|
|
69
|
+
return response.json();
|
|
70
|
+
}
|
|
71
|
+
async function fetchViewerPage(path) {
|
|
72
|
+
const embedded = embeddedData();
|
|
73
|
+
if (embedded) {
|
|
74
|
+
const page = embedded.pages.find((candidate) => candidate.path === path);
|
|
75
|
+
if (!page) {
|
|
76
|
+
throw new Error(`Page not found: ${path}`);
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
path: page.path,
|
|
80
|
+
title: page.title,
|
|
81
|
+
frontmatter: {
|
|
82
|
+
page_id: page.pageId,
|
|
83
|
+
kind: page.kind,
|
|
84
|
+
status: page.status,
|
|
85
|
+
project_ids: page.projectIds
|
|
86
|
+
},
|
|
87
|
+
content: page.content,
|
|
88
|
+
assets: page.assets ?? []
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const response = await fetch(`/api/page?path=${encodeURIComponent(path)}`);
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
throw new Error(`Failed to load page: ${response.status} ${response.statusText}`);
|
|
94
|
+
}
|
|
95
|
+
return response.json();
|
|
96
|
+
}
|
|
97
|
+
async function fetchApprovals() {
|
|
98
|
+
if (embeddedData()) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
const response = await fetch("/api/reviews");
|
|
102
|
+
if (!response.ok) {
|
|
103
|
+
throw new Error(`Failed to load approvals: ${response.status} ${response.statusText}`);
|
|
104
|
+
}
|
|
105
|
+
return response.json();
|
|
106
|
+
}
|
|
107
|
+
async function fetchApprovalDetail(approvalId) {
|
|
108
|
+
if (embeddedData()) {
|
|
109
|
+
throw new Error("Review actions are unavailable in standalone exports.");
|
|
110
|
+
}
|
|
111
|
+
const response = await fetch(`/api/review?id=${encodeURIComponent(approvalId)}`);
|
|
112
|
+
if (!response.ok) {
|
|
113
|
+
throw new Error(`Failed to load approval detail: ${response.status} ${response.statusText}`);
|
|
114
|
+
}
|
|
115
|
+
return response.json();
|
|
116
|
+
}
|
|
117
|
+
async function applyReviewAction(approvalId, action, targets = []) {
|
|
118
|
+
if (embeddedData()) {
|
|
119
|
+
throw new Error("Review actions are unavailable in standalone exports.");
|
|
120
|
+
}
|
|
121
|
+
const response = await fetch(`/api/review?action=${action}`, {
|
|
122
|
+
method: "POST",
|
|
123
|
+
headers: { "content-type": "application/json" },
|
|
124
|
+
body: JSON.stringify({ approvalId, targets })
|
|
125
|
+
});
|
|
126
|
+
if (!response.ok) {
|
|
127
|
+
throw new Error(`Failed to ${action} review entries: ${response.status} ${response.statusText}`);
|
|
128
|
+
}
|
|
129
|
+
return response.json();
|
|
130
|
+
}
|
|
131
|
+
async function fetchCandidates() {
|
|
132
|
+
if (embeddedData()) {
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
const response = await fetch("/api/candidates");
|
|
136
|
+
if (!response.ok) {
|
|
137
|
+
throw new Error(`Failed to load candidates: ${response.status} ${response.statusText}`);
|
|
138
|
+
}
|
|
139
|
+
return response.json();
|
|
140
|
+
}
|
|
141
|
+
async function applyCandidateAction(target, action) {
|
|
142
|
+
if (embeddedData()) {
|
|
143
|
+
throw new Error("Candidate actions are unavailable in standalone exports.");
|
|
144
|
+
}
|
|
145
|
+
const response = await fetch(`/api/candidate?action=${action}`, {
|
|
146
|
+
method: "POST",
|
|
147
|
+
headers: { "content-type": "application/json" },
|
|
148
|
+
body: JSON.stringify({ target })
|
|
149
|
+
});
|
|
150
|
+
if (!response.ok) {
|
|
151
|
+
throw new Error(`Failed to ${action} candidate: ${response.status} ${response.statusText}`);
|
|
152
|
+
}
|
|
153
|
+
return response.json();
|
|
154
|
+
}
|
|
9
155
|
export {
|
|
10
|
-
|
|
156
|
+
applyCandidateAction,
|
|
157
|
+
applyReviewAction,
|
|
158
|
+
fetchApprovalDetail,
|
|
159
|
+
fetchApprovals,
|
|
160
|
+
fetchCandidates,
|
|
161
|
+
fetchGraphArtifact,
|
|
162
|
+
fetchViewerPage,
|
|
163
|
+
searchViewerPages
|
|
11
164
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swarmvaultai/engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Core engine for SwarmVault: ingest, compile, query, lint, and provider abstractions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"gray-matter": "^4.0.3",
|
|
47
47
|
"jsdom": "^27.0.0",
|
|
48
48
|
"mime-types": "^3.0.1",
|
|
49
|
+
"typescript": "^5.9.3",
|
|
49
50
|
"turndown": "^7.2.1",
|
|
50
51
|
"zod": "^4.1.8"
|
|
51
52
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
:root{color-scheme:dark;font-family:Avenir Next,Segoe UI,sans-serif;background:radial-gradient(circle at top left,rgba(14,165,233,.18),transparent 30%),radial-gradient(circle at right,rgba(245,158,11,.14),transparent 28%),linear-gradient(180deg,#020617,#0f172a);color:#e2e8f0}*{box-sizing:border-box}body{margin:0;min-height:100vh}#root{min-height:100vh}.app-shell{min-height:100vh;padding:24px;display:grid;gap:20px}.app-header,.stats,.workspace,.panel,.filter,article{border:1px solid rgba(148,163,184,.16);background:#0f172ab8;-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);border-radius:22px}.app-header{padding:24px;display:flex;justify-content:space-between;gap:24px;align-items:start}.app-header h1{margin:0 0 8px;font-size:clamp(2rem,4vw,3.4rem);line-height:.95;max-width:12ch}.eyebrow{margin:0 0 12px;text-transform:uppercase;letter-spacing:.14em;color:#7dd3fc;font-size:.78rem}.lede{margin:0;max-width:56ch;color:#cbd5e1}.filter{display:grid;gap:10px;padding:16px;min-width:180px}.filter select{background:#020617;color:#f8fafc;border:1px solid rgba(148,163,184,.28);border-radius:12px;padding:10px 12px}.stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;padding:14px}.stats article{padding:16px}.stats span,.panel-label{display:block;color:#94a3b8;font-size:.82rem;text-transform:uppercase;letter-spacing:.08em;margin-bottom:8px}.stats strong{font-size:1.25rem}.workspace{display:grid;grid-template-columns:minmax(0,1fr) 320px;gap:16px;padding:16px;min-height:60vh}.canvas{min-height:60vh;border-radius:18px;overflow:hidden;background:linear-gradient(180deg,#020617eb,#0f172aeb),repeating-linear-gradient(90deg,rgba(148,163,184,.04),rgba(148,163,184,.04) 1px,transparent 1px,transparent 44px)}.panel{padding:20px}.panel h2,.panel h3{margin-top:0}.panel code{font-family:IBM Plex Mono,SFMono-Regular,monospace;font-size:.88rem}@media(max-width:900px){.app-header,.workspace,.stats{grid-template-columns:1fr}.app-header{flex-direction:column}}
|