@swarmvaultai/engine 1.4.0 → 3.0.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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  `@swarmvaultai/engine` is the runtime library behind SwarmVault.
4
4
 
5
- It exposes the primitives for initializing a workspace, ingesting sources, importing an inbox, compiling a wiki, querying the vault, running lint, serving the graph viewer, watching the inbox, and exposing the vault over MCP.
5
+ It exposes the primitives for initializing a workspace, ingesting sources, importing an inbox, compiling a wiki, querying the vault, recording agent tasks, maintaining retrieval, running lint, serving the graph viewer, watching the inbox, and exposing the vault over MCP.
6
6
 
7
7
  ## Who This Is For
8
8
 
@@ -22,16 +22,21 @@ import {
22
22
  addInput,
23
23
  addManagedSource,
24
24
  benchmarkVault,
25
+ buildContextPack,
25
26
  compileVault,
26
27
  createMcpServer,
27
28
  createWebSearchAdapter,
29
+ deleteContextPack,
28
30
  deleteManagedSource,
29
31
  defaultVaultConfig,
30
32
  defaultVaultSchema,
33
+ doctorRetrieval,
31
34
  exploreVault,
32
35
  exportGraphFormat,
33
36
  exportGraphHtml,
34
37
  explainGraphVault,
38
+ finishMemoryTask,
39
+ getRetrievalStatus,
35
40
  getWatchStatus,
36
41
  getGitHookStatus,
37
42
  importInbox,
@@ -42,6 +47,8 @@ import {
42
47
  getWebSearchAdapterForTask,
43
48
  lintVault,
44
49
  listGodNodes,
50
+ listContextPacks,
51
+ listMemoryTasks,
45
52
  listManagedSourceRecords,
46
53
  listSchedules,
47
54
  loadVaultConfig,
@@ -51,20 +58,26 @@ import {
51
58
  pushGraphNeo4j,
52
59
  queryGraphVault,
53
60
  queryVault,
61
+ readContextPack,
62
+ readMemoryTask,
63
+ rebuildRetrievalIndex,
54
64
  reloadManagedSources,
65
+ resumeMemoryTask,
55
66
  runWatchCycle,
56
67
  runSchedule,
57
68
  searchVault,
58
69
  serveSchedules,
59
70
  startGraphServer,
71
+ startMemoryTask,
60
72
  startMcpServer,
61
73
  syncTrackedRepos,
62
74
  uninstallGitHooks,
75
+ updateMemoryTask,
63
76
  watchVault,
64
77
  } from "@swarmvaultai/engine";
65
78
  ```
66
79
 
67
- The engine also exports the main runtime types for providers, graph artifacts, pages, manifests, query results, lint findings, and watch records.
80
+ The engine also exports the main runtime types for providers, graph artifacts, pages, manifests, query results, task records, retrieval status, lint findings, and watch records.
68
81
 
69
82
  ## Example
70
83
 
@@ -73,21 +86,31 @@ import {
73
86
  addInput,
74
87
  addManagedSource,
75
88
  benchmarkVault,
89
+ buildContextPack,
76
90
  compileVault,
91
+ doctorRetrieval,
77
92
  exploreVault,
78
93
  exportGraphHtml,
79
94
  exportGraphFormat,
95
+ finishMemoryTask,
96
+ getRetrievalStatus,
80
97
  getWatchStatus,
81
98
  importInbox,
82
99
  initVault,
83
100
  installGitHooks,
101
+ listMemoryTasks,
84
102
  listManagedSourceRecords,
85
103
  loadVaultSchemas,
86
104
  pushGraphNeo4j,
87
105
  queryGraphVault,
88
106
  queryVault,
107
+ readContextPack,
108
+ rebuildRetrievalIndex,
109
+ resumeMemoryTask,
89
110
  reloadManagedSources,
90
111
  runWatchCycle,
112
+ startMemoryTask,
113
+ updateMemoryTask,
91
114
  watchVault
92
115
  } from "@swarmvaultai/engine";
93
116
 
@@ -106,6 +129,31 @@ console.log(benchmark.avgQueryTokens);
106
129
 
107
130
  const saved = await queryVault(rootDir, { question: "What changed most recently?" });
108
131
  console.log(saved.savedPath);
132
+ console.log(await getRetrievalStatus(rootDir));
133
+
134
+ const contextPack = await buildContextPack(rootDir, {
135
+ goal: "Implement the auth refactor",
136
+ target: "./src",
137
+ budgetTokens: 8000
138
+ });
139
+ console.log(contextPack.markdownPath);
140
+
141
+ const memory = await startMemoryTask(rootDir, {
142
+ goal: "Implement the auth refactor",
143
+ target: "./src",
144
+ agent: "codex"
145
+ });
146
+ await updateMemoryTask(rootDir, memory.task.id, {
147
+ decision: "Keep the implementation local-first and file-backed.",
148
+ changedPath: "packages/engine/src/memory.ts"
149
+ });
150
+ await finishMemoryTask(rootDir, memory.task.id, {
151
+ outcome: "Task ledger shipped behind CLI, MCP, graph, and viewer surfaces."
152
+ });
153
+ console.log((await readMemoryTask(rootDir, memory.task.id)).status);
154
+ console.log((await listMemoryTasks(rootDir)).length);
155
+ console.log((await resumeMemoryTask(rootDir, memory.task.id)).content);
156
+ console.log(await doctorRetrieval(rootDir));
109
157
 
110
158
  const graphQuery = await queryGraphVault(rootDir, "Which nodes bridge the biggest communities?");
111
159
  console.log(graphQuery.summary);
@@ -211,6 +259,7 @@ This matters because many "OpenAI-compatible" backends only implement part of th
211
259
  - `benchmarkVault(rootDir, { questions })` writes `state/benchmark.json` and folds the latest benchmark summary into `wiki/graph/report.md` and `wiki/graph/report.json`
212
260
  - semantic graph query and embedding-backed similarity enrichment cache vectors under `state/embeddings.json` so graph-semantic refresh stays incremental
213
261
  - `queryVault(rootDir, { question, save, format, review })` answers against the compiled vault using the same schema layer and saves by default
262
+ - `buildContextPack(rootDir, { goal, target, budgetTokens, format })` builds an agent-ready evidence bundle with relevant pages, graph nodes, edges, hyperedges, citations, token-budget accounting, and explicit omitted entries
214
263
  - `exploreVault(rootDir, { question, steps, format, review })` runs a save-first multi-step exploration loop and writes a hub page plus step outputs
215
264
  - `searchVault(rootDir, query, limit)` searches compiled pages directly
216
265
  - `queryGraphVault(rootDir, question, { traversal, budget })` runs deterministic local graph search, preferring semantic seed matches from `tasks.embeddingProvider` when configured and falling back to lexical search plus matching group patterns otherwise
@@ -219,6 +268,7 @@ This matters because many "OpenAI-compatible" backends only implement part of th
219
268
  - `listGraphHyperedges(rootDir, target?, limit?)` returns graph hyperedges globally or for a specific node/page target
220
269
  - `listGodNodes(rootDir, limit)` returns the most connected bridge-heavy graph nodes
221
270
  - `buildGraphShareArtifact(...)`, `renderGraphShareMarkdown(...)`, `renderGraphShareSvg(...)`, `renderGraphSharePreviewHtml(...)`, and `renderGraphShareBundleFiles(...)` produce the post-ready text, 1200x630 visual card, self-contained HTML preview, and portable share kit used by `wiki/graph/share-card.md`, `wiki/graph/share-card.svg`, `wiki/graph/share-kit/`, and the CLI `graph share` command
271
+ - `listContextPacks(rootDir)`, `readContextPack(rootDir, id)`, and `deleteContextPack(rootDir, id)` manage saved context-pack artifacts under `state/context-packs/`
222
272
  - project-aware compile also builds `wiki/projects/index.md` plus `wiki/projects/<project>/index.md` rollups without duplicating page trees
223
273
  - human-authored insight pages in `wiki/insights/` are indexed into search and available to query without being rewritten by compile
224
274
  - `chart` and `image` formats save wrapper markdown pages plus local output assets under `wiki/outputs/assets/<slug>/`
@@ -252,7 +302,7 @@ This matters because many "OpenAI-compatible" backends only implement part of th
252
302
  - `exportGraphFormat(rootDir, "svg" | "graphml" | "cypher", outputPath)` exports the graph into interoperable file formats
253
303
  - `pushGraphNeo4j(rootDir, options)` upserts the current graph into Neo4j over Bolt/Aura with shared-database-safe `vaultId` namespacing
254
304
 
255
- The MCP surface includes tools for workspace info, page search, page reads, source listing, querying, ingestion, compile, lint, graph report reads, hyperedge reads, and graph-native read operations such as graph query, node explain, neighbor lookup, shortest path, and god-node listing, along with resources for config, graph, manifests, schema, page content, and session artifacts.
305
+ The MCP surface includes tools for workspace info, page search, page reads, source listing, querying, context-pack build/read/list, task start/update/finish/list/read/resume, compatibility memory task tools, retrieval status/rebuild/doctor, ingestion, compile, lint, graph report reads, hyperedge reads, and graph-native read operations such as graph query, node explain, neighbor lookup, shortest path, and god-node listing, along with resources for config, graph, manifests, schema, page content, context-pack listings, task listings, compatibility memory task listings, and session artifacts.
256
306
 
257
307
  ## Artifacts
258
308
 
@@ -264,6 +314,8 @@ Running the engine produces a local workspace with these main areas:
264
314
  - `raw/assets/`: copied attachments referenced by ingested markdown bundles and remote URL ingests
265
315
  - `wiki/`: generated markdown pages, the append-only `log.md` activity trail, staged candidates, saved query outputs, exploration hub pages, and a human-only `insights/` area
266
316
  - `wiki/graph/`: generated graph report pages, markdown/SVG share cards, the portable `share-kit/`, and per-community summaries derived from `state/graph.json`
317
+ - `wiki/context/`: markdown companions for saved context packs
318
+ - `wiki/memory/`: markdown index and task pages for the agent task ledger
267
319
  - `wiki/graph/report.json`: machine-readable graph report data used by the viewer and export surfaces
268
320
  - `wiki/outputs/assets/`: local chart/image artifacts and JSON manifests for saved visual outputs
269
321
  - `wiki/code/`: generated module pages for ingested code sources
@@ -277,7 +329,9 @@ Running the engine produces a local workspace with these main areas:
277
329
  - `state/code-index.json`: repo-aware code module aliases and local resolution data
278
330
  - `state/benchmark.json`: latest benchmark/trust summary for the current vault
279
331
  - `state/graph.json`: compiled graph, including semantic-similarity edges and hyperedge-style group patterns
280
- - `state/search.sqlite`: full-text index
332
+ - `state/context-packs/`: JSON context-pack artifacts for agent kickoff, review, and handoff workflows
333
+ - `state/memory/tasks/`: JSON task records for the agent task ledger
334
+ - `state/retrieval/`: local retrieval index directory, including the SQLite FTS shard and manifest
281
335
  - `state/sessions/`: canonical session artifacts
282
336
  - `state/approvals/`: staged review bundles from `compileVault({ approve: true })`
283
337
  - `state/schedules/`: persisted schedule state and leases