stellavault 0.1.0 → 0.2.1

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.
Files changed (385) hide show
  1. package/package.json +1 -1
  2. package/packages/cli/bin/ekh.js +2 -2
  3. package/packages/cli/dist/commands/federate-cmd.js +61 -31
  4. package/packages/core/dist/api/dashboard.d.ts +3 -0
  5. package/packages/core/{src/api/dashboard.ts → dist/api/dashboard.js} +8 -11
  6. package/packages/core/dist/api/graph-data.d.ts +11 -0
  7. package/packages/core/dist/api/graph-data.js +255 -0
  8. package/packages/core/dist/api/pwa.d.ts +3 -0
  9. package/packages/core/{src/api/pwa.ts → dist/api/pwa.js} +27 -32
  10. package/packages/core/dist/api/server.d.ts +16 -0
  11. package/packages/core/dist/api/server.js +647 -0
  12. package/packages/core/dist/capture/voice.d.ts +24 -0
  13. package/packages/core/dist/capture/voice.js +135 -0
  14. package/packages/core/{src/cloud/index.ts → dist/cloud/index.d.ts} +1 -0
  15. package/packages/core/dist/cloud/index.js +2 -0
  16. package/packages/core/dist/cloud/sync.d.ts +29 -0
  17. package/packages/core/dist/cloud/sync.js +137 -0
  18. package/packages/core/dist/config.d.ts +27 -0
  19. package/packages/core/dist/config.js +55 -0
  20. package/packages/core/dist/federation/credits.d.ts +26 -0
  21. package/packages/core/dist/federation/credits.js +56 -0
  22. package/packages/core/dist/federation/identity.d.ts +14 -0
  23. package/packages/core/dist/federation/identity.js +74 -0
  24. package/packages/core/{src/federation/index.ts → dist/federation/index.d.ts} +1 -2
  25. package/packages/core/dist/federation/index.js +5 -0
  26. package/packages/core/dist/federation/node.d.ts +31 -0
  27. package/packages/core/dist/federation/node.js +216 -0
  28. package/packages/core/dist/federation/privacy.d.ts +8 -0
  29. package/packages/core/dist/federation/privacy.js +40 -0
  30. package/packages/core/dist/federation/reputation.d.ts +37 -0
  31. package/packages/core/dist/federation/reputation.js +139 -0
  32. package/packages/core/dist/federation/search.d.ts +19 -0
  33. package/packages/core/dist/federation/search.js +101 -0
  34. package/packages/core/dist/federation/sharing.d.ts +72 -0
  35. package/packages/core/dist/federation/sharing.js +246 -0
  36. package/packages/core/dist/federation/trust.d.ts +15 -0
  37. package/packages/core/dist/federation/trust.js +60 -0
  38. package/packages/core/dist/federation/types.d.ts +40 -0
  39. package/packages/core/dist/federation/types.js +3 -0
  40. package/packages/core/dist/i18n/index.d.ts +6 -0
  41. package/packages/core/dist/i18n/index.js +81 -0
  42. package/packages/core/{src/index.ts → dist/index.d.ts} +48 -67
  43. package/packages/core/dist/index.js +69 -0
  44. package/packages/core/dist/indexer/chunker.d.ts +14 -0
  45. package/packages/core/dist/indexer/chunker.js +148 -0
  46. package/packages/core/dist/indexer/embedder.d.ts +8 -0
  47. package/packages/core/dist/indexer/embedder.js +3 -0
  48. package/packages/core/dist/indexer/index.d.ts +28 -0
  49. package/packages/core/dist/indexer/index.js +74 -0
  50. package/packages/core/dist/indexer/local-embedder.d.ts +3 -0
  51. package/packages/core/dist/indexer/local-embedder.js +29 -0
  52. package/packages/core/dist/indexer/scanner.d.ts +11 -0
  53. package/packages/core/dist/indexer/scanner.js +137 -0
  54. package/packages/core/dist/indexer/watcher.d.ts +19 -0
  55. package/packages/core/dist/indexer/watcher.js +49 -0
  56. package/packages/core/dist/intelligence/contradiction-detector.d.ts +20 -0
  57. package/packages/core/dist/intelligence/contradiction-detector.js +115 -0
  58. package/packages/core/dist/intelligence/decay-engine.d.ts +27 -0
  59. package/packages/core/dist/intelligence/decay-engine.js +190 -0
  60. package/packages/core/dist/intelligence/duplicate-detector.d.ts +20 -0
  61. package/packages/core/dist/intelligence/duplicate-detector.js +55 -0
  62. package/packages/core/dist/intelligence/fsrs.d.ts +43 -0
  63. package/packages/core/dist/intelligence/fsrs.js +70 -0
  64. package/packages/core/dist/intelligence/gap-detector.d.ts +25 -0
  65. package/packages/core/dist/intelligence/gap-detector.js +78 -0
  66. package/packages/core/dist/intelligence/learning-path.d.ts +31 -0
  67. package/packages/core/dist/intelligence/learning-path.js +53 -0
  68. package/packages/core/dist/intelligence/notifications.d.ts +31 -0
  69. package/packages/core/dist/intelligence/notifications.js +65 -0
  70. package/packages/core/dist/intelligence/predictive-gaps.d.ts +14 -0
  71. package/packages/core/dist/intelligence/predictive-gaps.js +74 -0
  72. package/packages/core/dist/intelligence/semantic-versioning.d.ts +37 -0
  73. package/packages/core/dist/intelligence/semantic-versioning.js +68 -0
  74. package/packages/core/dist/intelligence/types.d.ts +28 -0
  75. package/packages/core/dist/intelligence/types.js +3 -0
  76. package/packages/core/dist/mcp/custom-tools.d.ts +29 -0
  77. package/packages/core/dist/mcp/custom-tools.js +70 -0
  78. package/packages/core/{src/mcp/index.ts → dist/mcp/index.d.ts} +1 -0
  79. package/packages/core/dist/mcp/index.js +2 -0
  80. package/packages/core/dist/mcp/server.d.ts +49 -0
  81. package/packages/core/dist/mcp/server.js +133 -0
  82. package/packages/core/dist/mcp/tools/agentic-graph.d.ts +87 -0
  83. package/packages/core/dist/mcp/tools/agentic-graph.js +88 -0
  84. package/packages/core/dist/mcp/tools/brief.d.ts +31 -0
  85. package/packages/core/dist/mcp/tools/brief.js +39 -0
  86. package/packages/core/dist/mcp/tools/decay.d.ts +33 -0
  87. package/packages/core/dist/mcp/tools/decay.js +32 -0
  88. package/packages/core/dist/mcp/tools/decision-journal.d.ts +78 -0
  89. package/packages/core/dist/mcp/tools/decision-journal.js +79 -0
  90. package/packages/core/dist/mcp/tools/export.d.ts +29 -0
  91. package/packages/core/dist/mcp/tools/export.js +60 -0
  92. package/packages/core/dist/mcp/tools/federated-search.d.ts +29 -0
  93. package/packages/core/dist/mcp/tools/federated-search.js +36 -0
  94. package/packages/core/dist/mcp/tools/generate-claude-md.d.ts +35 -0
  95. package/packages/core/dist/mcp/tools/generate-claude-md.js +107 -0
  96. package/packages/core/dist/mcp/tools/get-document.d.ts +35 -0
  97. package/packages/core/dist/mcp/tools/get-document.js +25 -0
  98. package/packages/core/dist/mcp/tools/get-related.d.ts +32 -0
  99. package/packages/core/dist/mcp/tools/get-related.js +33 -0
  100. package/packages/core/dist/mcp/tools/learning-path.d.ts +23 -0
  101. package/packages/core/dist/mcp/tools/learning-path.js +45 -0
  102. package/packages/core/dist/mcp/tools/list-topics.d.ts +15 -0
  103. package/packages/core/dist/mcp/tools/list-topics.js +18 -0
  104. package/packages/core/dist/mcp/tools/search.d.ts +39 -0
  105. package/packages/core/dist/mcp/tools/search.js +29 -0
  106. package/packages/core/dist/mcp/tools/snapshot.d.ts +47 -0
  107. package/packages/core/dist/mcp/tools/snapshot.js +84 -0
  108. package/packages/core/dist/multi-vault/index.d.ts +26 -0
  109. package/packages/core/dist/multi-vault/index.js +80 -0
  110. package/packages/core/dist/pack/creator.d.ts +21 -0
  111. package/packages/core/dist/pack/creator.js +105 -0
  112. package/packages/core/dist/pack/exporter.d.ts +4 -0
  113. package/packages/core/dist/pack/exporter.js +18 -0
  114. package/packages/core/dist/pack/importer.d.ts +10 -0
  115. package/packages/core/dist/pack/importer.js +55 -0
  116. package/packages/core/{src/pack/index.ts → dist/pack/index.d.ts} +1 -0
  117. package/packages/core/dist/pack/index.js +5 -0
  118. package/packages/core/dist/pack/marketplace.d.ts +14 -0
  119. package/packages/core/dist/pack/marketplace.js +90 -0
  120. package/packages/core/dist/pack/pii-masker.d.ts +7 -0
  121. package/packages/core/dist/pack/pii-masker.js +29 -0
  122. package/packages/core/dist/pack/types.d.ts +36 -0
  123. package/packages/core/dist/pack/types.js +3 -0
  124. package/packages/core/dist/plugins/index.d.ts +35 -0
  125. package/packages/core/dist/plugins/index.js +57 -0
  126. package/packages/core/dist/plugins/webhooks.d.ts +30 -0
  127. package/packages/core/dist/plugins/webhooks.js +79 -0
  128. package/packages/core/dist/search/bm25.d.ts +4 -0
  129. package/packages/core/dist/search/bm25.js +10 -0
  130. package/packages/core/dist/search/index.d.ts +13 -0
  131. package/packages/core/dist/search/index.js +63 -0
  132. package/packages/core/dist/search/rrf.d.ts +7 -0
  133. package/packages/core/dist/search/rrf.js +21 -0
  134. package/packages/core/dist/search/semantic.d.ts +5 -0
  135. package/packages/core/dist/search/semantic.js +6 -0
  136. package/packages/core/{src/store/index.ts → dist/store/index.d.ts} +1 -0
  137. package/packages/core/dist/store/index.js +2 -0
  138. package/packages/core/dist/store/sqlite-vec.d.ts +6 -0
  139. package/packages/core/dist/store/sqlite-vec.js +251 -0
  140. package/packages/core/dist/store/types.d.ts +20 -0
  141. package/packages/core/dist/store/types.js +3 -0
  142. package/packages/core/dist/team/index.d.ts +25 -0
  143. package/packages/core/dist/team/index.js +97 -0
  144. package/packages/core/dist/types/chunk.d.ts +23 -0
  145. package/packages/core/dist/types/chunk.js +3 -0
  146. package/packages/core/dist/types/document.d.ts +23 -0
  147. package/packages/core/dist/types/document.js +3 -0
  148. package/packages/core/dist/types/graph.d.ts +39 -0
  149. package/packages/core/dist/types/graph.js +3 -0
  150. package/packages/core/dist/types/index.d.ts +5 -0
  151. package/packages/core/dist/types/index.js +2 -0
  152. package/packages/core/dist/types/search.d.ts +39 -0
  153. package/packages/core/dist/types/search.js +3 -0
  154. package/packages/core/dist/utils/retry.d.ts +25 -0
  155. package/packages/core/dist/utils/retry.js +59 -0
  156. package/memory/MEMORY.md +0 -25
  157. package/packages/cli/dist/commands/brief-cmd.d.ts.map +0 -1
  158. package/packages/cli/dist/commands/brief-cmd.js.map +0 -1
  159. package/packages/cli/dist/commands/capture-cmd.d.ts.map +0 -1
  160. package/packages/cli/dist/commands/capture-cmd.js.map +0 -1
  161. package/packages/cli/dist/commands/card-cmd.d.ts.map +0 -1
  162. package/packages/cli/dist/commands/card-cmd.js.map +0 -1
  163. package/packages/cli/dist/commands/clip-cmd.d.ts.map +0 -1
  164. package/packages/cli/dist/commands/clip-cmd.js.map +0 -1
  165. package/packages/cli/dist/commands/cloud-cmd.d.ts.map +0 -1
  166. package/packages/cli/dist/commands/cloud-cmd.js.map +0 -1
  167. package/packages/cli/dist/commands/contradictions-cmd.d.ts.map +0 -1
  168. package/packages/cli/dist/commands/contradictions-cmd.js.map +0 -1
  169. package/packages/cli/dist/commands/decay-cmd.d.ts.map +0 -1
  170. package/packages/cli/dist/commands/decay-cmd.js.map +0 -1
  171. package/packages/cli/dist/commands/digest-cmd.d.ts.map +0 -1
  172. package/packages/cli/dist/commands/digest-cmd.js.map +0 -1
  173. package/packages/cli/dist/commands/duplicates-cmd.d.ts.map +0 -1
  174. package/packages/cli/dist/commands/duplicates-cmd.js.map +0 -1
  175. package/packages/cli/dist/commands/federate-cmd.d.ts.map +0 -1
  176. package/packages/cli/dist/commands/federate-cmd.js.map +0 -1
  177. package/packages/cli/dist/commands/gaps-cmd.d.ts.map +0 -1
  178. package/packages/cli/dist/commands/gaps-cmd.js.map +0 -1
  179. package/packages/cli/dist/commands/graph-cmd.d.ts.map +0 -1
  180. package/packages/cli/dist/commands/graph-cmd.js.map +0 -1
  181. package/packages/cli/dist/commands/index-cmd.d.ts.map +0 -1
  182. package/packages/cli/dist/commands/index-cmd.js.map +0 -1
  183. package/packages/cli/dist/commands/init-cmd.d.ts.map +0 -1
  184. package/packages/cli/dist/commands/init-cmd.js.map +0 -1
  185. package/packages/cli/dist/commands/learn-cmd.d.ts.map +0 -1
  186. package/packages/cli/dist/commands/learn-cmd.js.map +0 -1
  187. package/packages/cli/dist/commands/pack-cmd.d.ts.map +0 -1
  188. package/packages/cli/dist/commands/pack-cmd.js.map +0 -1
  189. package/packages/cli/dist/commands/review-cmd.d.ts.map +0 -1
  190. package/packages/cli/dist/commands/review-cmd.js.map +0 -1
  191. package/packages/cli/dist/commands/search-cmd.d.ts.map +0 -1
  192. package/packages/cli/dist/commands/search-cmd.js.map +0 -1
  193. package/packages/cli/dist/commands/serve-cmd.d.ts.map +0 -1
  194. package/packages/cli/dist/commands/serve-cmd.js.map +0 -1
  195. package/packages/cli/dist/commands/status-cmd.d.ts.map +0 -1
  196. package/packages/cli/dist/commands/status-cmd.js.map +0 -1
  197. package/packages/cli/dist/commands/sync-cmd.d.ts.map +0 -1
  198. package/packages/cli/dist/commands/sync-cmd.js.map +0 -1
  199. package/packages/cli/dist/commands/vault-cmd.d.ts.map +0 -1
  200. package/packages/cli/dist/commands/vault-cmd.js.map +0 -1
  201. package/packages/cli/dist/index.d.ts.map +0 -1
  202. package/packages/cli/dist/index.js.map +0 -1
  203. package/packages/cli/src/commands/brief-cmd.ts +0 -87
  204. package/packages/cli/src/commands/capture-cmd.ts +0 -34
  205. package/packages/cli/src/commands/card-cmd.ts +0 -29
  206. package/packages/cli/src/commands/clip-cmd.ts +0 -172
  207. package/packages/cli/src/commands/cloud-cmd.ts +0 -75
  208. package/packages/cli/src/commands/contradictions-cmd.ts +0 -41
  209. package/packages/cli/src/commands/decay-cmd.ts +0 -57
  210. package/packages/cli/src/commands/digest-cmd.ts +0 -89
  211. package/packages/cli/src/commands/duplicates-cmd.ts +0 -38
  212. package/packages/cli/src/commands/federate-cmd.ts +0 -236
  213. package/packages/cli/src/commands/gaps-cmd.ts +0 -40
  214. package/packages/cli/src/commands/graph-cmd.ts +0 -88
  215. package/packages/cli/src/commands/index-cmd.ts +0 -65
  216. package/packages/cli/src/commands/init-cmd.ts +0 -145
  217. package/packages/cli/src/commands/learn-cmd.ts +0 -56
  218. package/packages/cli/src/commands/pack-cmd.ts +0 -121
  219. package/packages/cli/src/commands/review-cmd.ts +0 -125
  220. package/packages/cli/src/commands/search-cmd.ts +0 -45
  221. package/packages/cli/src/commands/serve-cmd.ts +0 -17
  222. package/packages/cli/src/commands/status-cmd.ts +0 -37
  223. package/packages/cli/src/commands/sync-cmd.ts +0 -68
  224. package/packages/cli/src/commands/vault-cmd.ts +0 -64
  225. package/packages/cli/src/index.ts +0 -187
  226. package/packages/core/src/api/graph-data.ts +0 -286
  227. package/packages/core/src/api/server.ts +0 -660
  228. package/packages/core/src/capture/voice.ts +0 -168
  229. package/packages/core/src/cloud/sync.ts +0 -167
  230. package/packages/core/src/config.ts +0 -82
  231. package/packages/core/src/federation/credits.ts +0 -80
  232. package/packages/core/src/federation/hyperswarm.d.ts +0 -19
  233. package/packages/core/src/federation/identity.ts +0 -90
  234. package/packages/core/src/federation/node.ts +0 -235
  235. package/packages/core/src/federation/privacy.ts +0 -52
  236. package/packages/core/src/federation/reputation.ts +0 -202
  237. package/packages/core/src/federation/search.ts +0 -129
  238. package/packages/core/src/federation/sharing.ts +0 -165
  239. package/packages/core/src/federation/trust.ts +0 -76
  240. package/packages/core/src/federation/types.ts +0 -25
  241. package/packages/core/src/i18n/index.ts +0 -85
  242. package/packages/core/src/indexer/chunker.ts +0 -180
  243. package/packages/core/src/indexer/embedder.ts +0 -9
  244. package/packages/core/src/indexer/index.ts +0 -113
  245. package/packages/core/src/indexer/local-embedder.ts +0 -35
  246. package/packages/core/src/indexer/scanner.ts +0 -142
  247. package/packages/core/src/indexer/watcher.ts +0 -62
  248. package/packages/core/src/intelligence/contradiction-detector.ts +0 -134
  249. package/packages/core/src/intelligence/decay-engine.ts +0 -229
  250. package/packages/core/src/intelligence/duplicate-detector.ts +0 -71
  251. package/packages/core/src/intelligence/fsrs.ts +0 -79
  252. package/packages/core/src/intelligence/gap-detector.ts +0 -109
  253. package/packages/core/src/intelligence/learning-path.ts +0 -86
  254. package/packages/core/src/intelligence/notifications.ts +0 -106
  255. package/packages/core/src/intelligence/predictive-gaps.ts +0 -94
  256. package/packages/core/src/intelligence/semantic-versioning.ts +0 -97
  257. package/packages/core/src/intelligence/types.ts +0 -28
  258. package/packages/core/src/mcp/custom-tools.ts +0 -97
  259. package/packages/core/src/mcp/server.ts +0 -142
  260. package/packages/core/src/mcp/tools/agentic-graph.ts +0 -96
  261. package/packages/core/src/mcp/tools/brief.ts +0 -49
  262. package/packages/core/src/mcp/tools/decay.ts +0 -40
  263. package/packages/core/src/mcp/tools/decision-journal.ts +0 -95
  264. package/packages/core/src/mcp/tools/export.ts +0 -72
  265. package/packages/core/src/mcp/tools/federated-search.ts +0 -43
  266. package/packages/core/src/mcp/tools/generate-claude-md.ts +0 -130
  267. package/packages/core/src/mcp/tools/get-document.ts +0 -26
  268. package/packages/core/src/mcp/tools/get-related.ts +0 -41
  269. package/packages/core/src/mcp/tools/learning-path.ts +0 -52
  270. package/packages/core/src/mcp/tools/list-topics.ts +0 -20
  271. package/packages/core/src/mcp/tools/search.ts +0 -35
  272. package/packages/core/src/mcp/tools/snapshot.ts +0 -98
  273. package/packages/core/src/multi-vault/index.ts +0 -118
  274. package/packages/core/src/pack/creator.ts +0 -127
  275. package/packages/core/src/pack/exporter.ts +0 -21
  276. package/packages/core/src/pack/importer.ts +0 -82
  277. package/packages/core/src/pack/marketplace.ts +0 -103
  278. package/packages/core/src/pack/pii-masker.ts +0 -38
  279. package/packages/core/src/pack/types.ts +0 -39
  280. package/packages/core/src/plugins/index.ts +0 -100
  281. package/packages/core/src/plugins/webhooks.ts +0 -110
  282. package/packages/core/src/search/bm25.ts +0 -16
  283. package/packages/core/src/search/index.ts +0 -83
  284. package/packages/core/src/search/rrf.ts +0 -31
  285. package/packages/core/src/search/semantic.ts +0 -15
  286. package/packages/core/src/store/sqlite-vec.ts +0 -290
  287. package/packages/core/src/store/types.ts +0 -22
  288. package/packages/core/src/team/index.ts +0 -126
  289. package/packages/core/src/types/chunk.ts +0 -25
  290. package/packages/core/src/types/document.ts +0 -24
  291. package/packages/core/src/types/graph.ts +0 -44
  292. package/packages/core/src/types/index.ts +0 -15
  293. package/packages/core/src/types/search.ts +0 -38
  294. package/packages/core/src/utils/retry.ts +0 -85
  295. package/packages/core/tests/api-card.test.ts +0 -60
  296. package/packages/core/tests/api-routes.test.ts +0 -98
  297. package/packages/core/tests/bm25.test.ts +0 -87
  298. package/packages/core/tests/chunker.test.ts +0 -48
  299. package/packages/core/tests/cluster.test.ts +0 -75
  300. package/packages/core/tests/constellation.test.ts +0 -77
  301. package/packages/core/tests/export-utils.test.ts +0 -97
  302. package/packages/core/tests/fsrs.test.ts +0 -96
  303. package/packages/core/tests/gesture-detector.test.ts +0 -45
  304. package/packages/core/tests/graph-data.test.ts +0 -87
  305. package/packages/core/tests/layout.test.ts +0 -83
  306. package/packages/core/tests/mcp.test.ts +0 -148
  307. package/packages/core/tests/pack.test.ts +0 -127
  308. package/packages/core/tests/pii-masker.test.ts +0 -42
  309. package/packages/core/tests/profile-card.test.ts +0 -62
  310. package/packages/core/tests/rrf.test.ts +0 -29
  311. package/packages/core/tests/search-integration.test.ts +0 -139
  312. package/packages/core/tests/store.test.ts +0 -80
  313. package/packages/graph/click-result.png +0 -0
  314. package/packages/graph/index.html +0 -17
  315. package/packages/graph/package.json +0 -32
  316. package/packages/graph/src/App.tsx +0 -7
  317. package/packages/graph/src/api/client.ts +0 -39
  318. package/packages/graph/src/components/ClusterFilter.tsx +0 -73
  319. package/packages/graph/src/components/ConstellationView.tsx +0 -232
  320. package/packages/graph/src/components/ExportPanel.tsx +0 -177
  321. package/packages/graph/src/components/Graph3D.tsx +0 -230
  322. package/packages/graph/src/components/GraphEdges.tsx +0 -100
  323. package/packages/graph/src/components/GraphNodes.tsx +0 -386
  324. package/packages/graph/src/components/HealthDashboard.tsx +0 -173
  325. package/packages/graph/src/components/Layout.tsx +0 -214
  326. package/packages/graph/src/components/MotionOverlay.tsx +0 -81
  327. package/packages/graph/src/components/MotionToggle.tsx +0 -33
  328. package/packages/graph/src/components/MultiverseView.tsx +0 -286
  329. package/packages/graph/src/components/NodeDetail.tsx +0 -232
  330. package/packages/graph/src/components/PulseParticle.tsx +0 -232
  331. package/packages/graph/src/components/SearchBar.tsx +0 -107
  332. package/packages/graph/src/components/StarField.tsx +0 -197
  333. package/packages/graph/src/components/StatusBar.tsx +0 -53
  334. package/packages/graph/src/components/Timeline.tsx +0 -148
  335. package/packages/graph/src/components/ToolsPanel.tsx +0 -512
  336. package/packages/graph/src/components/Tooltip.tsx +0 -100
  337. package/packages/graph/src/components/TypeFilter.tsx +0 -131
  338. package/packages/graph/src/embed/EmbedGraph.tsx +0 -144
  339. package/packages/graph/src/hooks/useConstellationLOD.ts +0 -76
  340. package/packages/graph/src/hooks/useDecay.ts +0 -37
  341. package/packages/graph/src/hooks/useExport.ts +0 -165
  342. package/packages/graph/src/hooks/useGraph.ts +0 -69
  343. package/packages/graph/src/hooks/useKeyboardNav.ts +0 -122
  344. package/packages/graph/src/hooks/useLayout.ts +0 -45
  345. package/packages/graph/src/hooks/useMotion.ts +0 -120
  346. package/packages/graph/src/hooks/usePulse.ts +0 -58
  347. package/packages/graph/src/hooks/useSearch.ts +0 -71
  348. package/packages/graph/src/lib/constellation.ts +0 -107
  349. package/packages/graph/src/lib/export-utils.ts +0 -48
  350. package/packages/graph/src/lib/gesture-detector.ts +0 -123
  351. package/packages/graph/src/lib/layout.worker.ts +0 -153
  352. package/packages/graph/src/lib/motion-controller.ts +0 -83
  353. package/packages/graph/src/lib/profile-card.ts +0 -122
  354. package/packages/graph/src/main.tsx +0 -4
  355. package/packages/graph/src/stores/graph-store.ts +0 -155
  356. package/packages/graph/success.png +0 -0
  357. package/packages/graph/test-click.mjs +0 -49
  358. package/packages/graph/test-explore.mjs +0 -102
  359. package/packages/graph/test-final.mjs +0 -61
  360. package/packages/graph/test-graph.mjs +0 -139
  361. package/packages/graph/test-hover.mjs +0 -48
  362. package/packages/graph/test-pulse.mjs +0 -68
  363. package/packages/graph/test-screenshot.mjs +0 -56
  364. package/packages/graph/test-v2.mjs +0 -97
  365. package/packages/graph/vite.config.ts +0 -15
  366. package/packages/sync/.env.example +0 -11
  367. package/packages/sync/.sync-state.json +0 -317
  368. package/packages/sync/.upload-state.json +0 -1009
  369. package/packages/sync/create-stella-network-notion.mjs +0 -151
  370. package/packages/sync/create-stellavault-project-notion.mjs +0 -322
  371. package/packages/sync/logs/sync-2026-03-28.log +0 -6
  372. package/packages/sync/logs/sync-2026-03-29.log +0 -12
  373. package/packages/sync/logs/sync-2026-03-30.log +0 -6
  374. package/packages/sync/logs/sync-2026-03-31.log +0 -6
  375. package/packages/sync/logs/sync-2026-04-01.log +0 -6
  376. package/packages/sync/logs/sync-2026-04-02.log +0 -6
  377. package/packages/sync/package-lock.json +0 -373
  378. package/packages/sync/package.json +0 -16
  379. package/packages/sync/run-sync.bat +0 -18
  380. package/packages/sync/run-sync.mjs +0 -46
  381. package/packages/sync/setup-scheduler.mjs +0 -119
  382. package/packages/sync/structured-sync.mjs +0 -187
  383. package/packages/sync/sync-to-obsidian.mjs +0 -264
  384. package/packages/sync/upload-pdca-to-notion.mjs +0 -495
  385. package/tsconfig.base.json +0 -18
@@ -1,26 +0,0 @@
1
- import type { VectorStore } from '../../store/types.js';
2
-
3
- export const getDocumentToolDef = {
4
- name: 'get-document',
5
- description: '문서 ID 또는 파일 경로로 전체 문서 내용을 가져옵니다.',
6
- inputSchema: {
7
- type: 'object' as const,
8
- properties: {
9
- id: { type: 'string', description: '문서 ID 또는 파일 경로' },
10
- },
11
- required: ['id'],
12
- },
13
- };
14
-
15
- export async function handleGetDocument(store: VectorStore, args: { id: string }) {
16
- const doc = await store.getDocument(args.id);
17
- if (!doc) return { error: `Document not found: ${args.id}` };
18
- return {
19
- title: doc.title,
20
- filePath: doc.filePath,
21
- content: doc.content,
22
- tags: doc.tags,
23
- frontmatter: doc.frontmatter,
24
- lastModified: doc.lastModified,
25
- };
26
- }
@@ -1,41 +0,0 @@
1
- import type { SearchEngine } from '../../search/index.js';
2
- import type { VectorStore } from '../../store/types.js';
3
-
4
- export const getRelatedToolDef = {
5
- name: 'get-related',
6
- description: '특정 문서와 의미적으로 관련된 문서들을 반환합니다.',
7
- inputSchema: {
8
- type: 'object' as const,
9
- properties: {
10
- id: { type: 'string', description: '기준 문서 ID 또는 파일 경로' },
11
- limit: { type: 'number', description: '반환할 관련 문서 수 (기본: 5)' },
12
- },
13
- required: ['id'],
14
- },
15
- };
16
-
17
- export async function handleGetRelated(
18
- store: VectorStore,
19
- searchEngine: SearchEngine,
20
- args: { id: string; limit?: number },
21
- ) {
22
- const doc = await store.getDocument(args.id);
23
- if (!doc) return { error: `Document not found: ${args.id}` };
24
-
25
- // 문서 제목+내용 일부를 쿼리로 사용하여 관련 문서 검색
26
- const query = `${doc.title} ${doc.content.slice(0, 200)}`;
27
- const results = await searchEngine.search({
28
- query,
29
- limit: (args.limit ?? 5) + 1, // 자기 자신 제외용 +1
30
- });
31
-
32
- return results
33
- .filter(r => r.document.id !== args.id)
34
- .slice(0, args.limit ?? 5)
35
- .map(r => ({
36
- title: r.document.title,
37
- filePath: r.document.filePath,
38
- score: Math.round(r.score * 1000) / 1000,
39
- tags: r.document.tags,
40
- }));
41
- }
@@ -1,52 +0,0 @@
1
- // MCP Tool: get-learning-path (F-A11)
2
-
3
- import type { VectorStore } from '../../store/types.js';
4
- import { DecayEngine } from '../../intelligence/decay-engine.js';
5
- import { detectKnowledgeGaps } from '../../intelligence/gap-detector.js';
6
- import { generateLearningPath } from '../../intelligence/learning-path.js';
7
-
8
- export function createLearningPathTool(store: VectorStore) {
9
- return {
10
- name: 'get-learning-path',
11
- description: 'Generate a personalized learning path based on knowledge decay and gaps. Returns prioritized list of what to review, explore, or bridge.',
12
- inputSchema: {
13
- type: 'object' as const,
14
- properties: {
15
- limit: { type: 'number', description: 'Max items to return (default: 10)' },
16
- },
17
- },
18
- async handler(args: { limit?: number }) {
19
- const limit = args.limit ?? 10;
20
- const db = store.getDb() as any;
21
- if (!db) return { content: [{ type: 'text' as const, text: 'Database not available' }] };
22
-
23
- const decayEngine = new DecayEngine(db);
24
- const decayReport = await decayEngine.computeAll();
25
-
26
- let gaps: any[] = [];
27
- try {
28
- const gapReport = await detectKnowledgeGaps(store);
29
- gaps = gapReport.gaps ?? [];
30
- } catch { /* ignore */ }
31
-
32
- const path = generateLearningPath({ decayReport, gaps }, limit);
33
-
34
- const lines = [
35
- `🎯 Learning Path (${path.items.length} items, ~${path.summary.estimatedMinutes}min)`,
36
- '',
37
- ];
38
-
39
- for (const item of path.items) {
40
- const icon = item.category === 'review' ? '📖' : item.category === 'bridge' ? '🌉' : '🔭';
41
- lines.push(`${icon} [${item.priority}] ${item.title} (${item.score}pt)`);
42
- lines.push(` ${item.reason}`);
43
- }
44
-
45
- if (path.items.length === 0) {
46
- lines.push('All clear! Knowledge is in great shape.');
47
- }
48
-
49
- return { content: [{ type: 'text' as const, text: lines.join('\n') }] };
50
- },
51
- };
52
- }
@@ -1,20 +0,0 @@
1
- import type { VectorStore } from '../../store/types.js';
2
-
3
- export const listTopicsToolDef = {
4
- name: 'list-topics',
5
- description: '지식 베이스의 전체 토픽/태그 목록과 문서 수를 반환합니다.',
6
- inputSchema: {
7
- type: 'object' as const,
8
- properties: {},
9
- },
10
- };
11
-
12
- export async function handleListTopics(store: VectorStore) {
13
- const topics = await store.getTopics();
14
- const stats = await store.getStats();
15
- return {
16
- topics,
17
- totalDocuments: stats.documentCount,
18
- totalChunks: stats.chunkCount,
19
- };
20
- }
@@ -1,35 +0,0 @@
1
- import type { SearchEngine } from '../../search/index.js';
2
-
3
- export const searchToolDef = {
4
- name: 'search',
5
- description: '개인 지식 베이스에서 관련 문서/청크를 검색합니다. 자연어 쿼리와 키워드 모두 지원합니다.',
6
- inputSchema: {
7
- type: 'object' as const,
8
- properties: {
9
- query: { type: 'string', description: '검색 쿼리 (자연어 또는 키워드)' },
10
- limit: { type: 'number', description: '반환할 결과 수 (기본: 5)' },
11
- tags: { type: 'array', items: { type: 'string' }, description: '태그 필터' },
12
- },
13
- required: ['query'],
14
- },
15
- };
16
-
17
- export async function handleSearch(
18
- searchEngine: SearchEngine,
19
- args: { query: string; limit?: number; tags?: string[] },
20
- ) {
21
- const results = await searchEngine.search({
22
- query: args.query,
23
- limit: args.limit ?? 5,
24
- tags: args.tags,
25
- });
26
-
27
- return results.map(r => ({
28
- title: r.document.title,
29
- filePath: r.document.filePath,
30
- heading: r.chunk.heading,
31
- content: r.chunk.content,
32
- score: Math.round(r.score * 1000) / 1000,
33
- tags: r.document.tags,
34
- }));
35
- }
@@ -1,98 +0,0 @@
1
- // Design Ref: §12.1 F10 — 컨텍스트 스냅샷 (프로젝트별 지식 묶음)
2
-
3
- import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
4
- import { join, resolve, relative } from 'node:path';
5
- import { homedir } from 'node:os';
6
- import type { SearchEngine } from '../../search/index.js';
7
-
8
- const SNAPSHOT_DIR = join(homedir(), '.stellavault', 'snapshots');
9
-
10
- function sanitizeName(name: string): string {
11
- const sanitized = name.replace(/[^a-zA-Z0-9가-힣_-]/g, '');
12
- if (!sanitized) throw new Error('Invalid snapshot name');
13
- return sanitized;
14
- }
15
-
16
- function ensureWithinDir(dir: string, filePath: string): string {
17
- const resolved = resolve(dir, filePath);
18
- if (!resolved.startsWith(resolve(dir))) {
19
- throw new Error('Path traversal detected');
20
- }
21
- return resolved;
22
- }
23
-
24
- export const createSnapshotToolDef = {
25
- name: 'create-snapshot',
26
- description: '현재 프로젝트 관련 지식을 스냅샷으로 저장합니다. 나중에 load-snapshot으로 즉시 컨텍스트 복원.',
27
- inputSchema: {
28
- type: 'object' as const,
29
- properties: {
30
- name: { type: 'string', description: '스냅샷 이름 (예: my-project-v1)' },
31
- queries: { type: 'array', items: { type: 'string' }, description: '관련 지식 검색 쿼리들' },
32
- },
33
- required: ['name', 'queries'],
34
- },
35
- };
36
-
37
- export const loadSnapshotToolDef = {
38
- name: 'load-snapshot',
39
- description: '저장된 스냅샷을 로드하여 프로젝트 컨텍스트를 즉시 복원합니다.',
40
- inputSchema: {
41
- type: 'object' as const,
42
- properties: {
43
- name: { type: 'string', description: '스냅샷 이름' },
44
- },
45
- required: ['name'],
46
- },
47
- };
48
-
49
- export async function handleCreateSnapshot(
50
- searchEngine: SearchEngine,
51
- args: { name: string; queries: string[] },
52
- ) {
53
- mkdirSync(SNAPSHOT_DIR, { recursive: true });
54
-
55
- const results = [];
56
- for (const query of args.queries) {
57
- const hits = await searchEngine.search({ query, limit: 5 });
58
- results.push(...hits.map(r => ({
59
- query,
60
- title: r.document.title,
61
- filePath: r.document.filePath,
62
- heading: r.chunk.heading,
63
- content: r.chunk.content.slice(0, 500),
64
- score: r.score,
65
- })));
66
- }
67
-
68
- // 중복 제거
69
- const seen = new Set<string>();
70
- const unique = results.filter(r => {
71
- const key = `${r.filePath}:${r.heading}`;
72
- if (seen.has(key)) return false;
73
- seen.add(key);
74
- return true;
75
- });
76
-
77
- const snapshot = {
78
- name: args.name,
79
- createdAt: new Date().toISOString(),
80
- queries: args.queries,
81
- results: unique,
82
- };
83
-
84
- const safeName = sanitizeName(args.name);
85
- const filePath = ensureWithinDir(SNAPSHOT_DIR, `${safeName}.json`);
86
- writeFileSync(filePath, JSON.stringify(snapshot, null, 2), 'utf-8');
87
-
88
- return { saved: filePath, resultCount: unique.length };
89
- }
90
-
91
- export async function handleLoadSnapshot(args: { name: string }) {
92
- const safeName = sanitizeName(args.name);
93
- const filePath = ensureWithinDir(SNAPSHOT_DIR, `${safeName}.json`);
94
- if (!existsSync(filePath)) {
95
- return { error: `Snapshot not found: ${args.name}` };
96
- }
97
- return JSON.parse(readFileSync(filePath, 'utf-8'));
98
- }
@@ -1,118 +0,0 @@
1
- // Cross-Vault Federation (P3-F24)
2
- // 한 사람의 여러 vault를 통합 검색
3
-
4
- import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
5
- import { join } from 'node:path';
6
- import { homedir } from 'node:os';
7
- import type { VectorStore } from '../store/types.js';
8
- import type { Embedder } from '../indexer/embedder.js';
9
- import type { ScoredChunk } from '../types/chunk.js';
10
-
11
- export interface VaultEntry {
12
- id: string; // short alias
13
- name: string; // display name
14
- path: string; // vault path
15
- dbPath: string; // index.db path
16
- shared: boolean; // 공유 허용 여부 (Federation에서)
17
- addedAt: string;
18
- }
19
-
20
- export interface CrossVaultSearchResult {
21
- vaultId: string;
22
- vaultName: string;
23
- title: string;
24
- score: number;
25
- snippet: string;
26
- filePath: string;
27
- }
28
-
29
- const VAULTS_FILE = join(homedir(), '.stellavault', 'vaults.json');
30
-
31
- function loadVaults(): VaultEntry[] {
32
- if (!existsSync(VAULTS_FILE)) return [];
33
- return JSON.parse(readFileSync(VAULTS_FILE, 'utf-8'));
34
- }
35
-
36
- function saveVaults(vaults: VaultEntry[]): void {
37
- mkdirSync(join(homedir(), '.stellavault'), { recursive: true });
38
- writeFileSync(VAULTS_FILE, JSON.stringify(vaults, null, 2), 'utf-8');
39
- }
40
-
41
- export function addVault(id: string, name: string, vaultPath: string, dbPath: string, shared = false): VaultEntry {
42
- const vaults = loadVaults();
43
- if (vaults.some(v => v.id === id)) {
44
- throw new Error(`Vault "${id}" already exists`);
45
- }
46
- const entry: VaultEntry = { id, name, path: vaultPath, dbPath, shared, addedAt: new Date().toISOString() };
47
- vaults.push(entry);
48
- saveVaults(vaults);
49
- return entry;
50
- }
51
-
52
- export function removeVault(id: string): boolean {
53
- const vaults = loadVaults();
54
- const filtered = vaults.filter(v => v.id !== id);
55
- if (filtered.length === vaults.length) return false;
56
- saveVaults(filtered);
57
- return true;
58
- }
59
-
60
- export function listVaults(): VaultEntry[] {
61
- return loadVaults();
62
- }
63
-
64
- export function getVault(id: string): VaultEntry | undefined {
65
- return loadVaults().find(v => v.id === id);
66
- }
67
-
68
- // 모든 vault를 통합 검색
69
- export async function searchAllVaults(
70
- query: string,
71
- embedder: Embedder,
72
- createStore: (dbPath: string) => VectorStore,
73
- options: { limit?: number } = {},
74
- ): Promise<CrossVaultSearchResult[]> {
75
- const { limit = 10 } = options;
76
- const vaults = loadVaults();
77
- const results: CrossVaultSearchResult[] = [];
78
-
79
- // 쿼리 임베딩 (한 번만)
80
- const embedding = await embedder.embed(query);
81
-
82
- // 각 vault에서 병렬 검색
83
- const searches = vaults.map(async (vault) => {
84
- try {
85
- if (!existsSync(vault.dbPath)) return;
86
-
87
- const store = createStore(vault.dbPath);
88
- await store.initialize();
89
-
90
- const scored = await store.searchSemantic(embedding, limit);
91
-
92
- for (const s of scored) {
93
- const chunk = await store.getChunk(s.chunkId);
94
- if (!chunk) continue;
95
- const doc = await store.getDocument(chunk.documentId);
96
-
97
- results.push({
98
- vaultId: vault.id,
99
- vaultName: vault.name,
100
- title: doc?.title ?? 'Untitled',
101
- score: s.score,
102
- snippet: chunk.content.slice(0, 80),
103
- filePath: doc?.filePath ?? '',
104
- });
105
- }
106
-
107
- await store.close();
108
- } catch {
109
- // vault 접근 실패 시 건너뜀
110
- }
111
- });
112
-
113
- await Promise.allSettled(searches);
114
-
115
- return results
116
- .sort((a, b) => b.score - a.score)
117
- .slice(0, limit);
118
- }
@@ -1,127 +0,0 @@
1
- // Design Ref: Phase 3 FR-01~03 — 검색/클러스터 기반 팩 생성
2
-
3
- import type { VectorStore } from '../store/types.js';
4
- import type { SearchEngine } from '../search/index.js';
5
- import type { Embedder } from '../indexer/embedder.js';
6
- import type { KnowledgePack, PackChunk } from './types.js';
7
- import { maskPII } from './pii-masker.js';
8
-
9
- export interface CreatePackOptions {
10
- name: string;
11
- author?: string;
12
- license?: string;
13
- description?: string;
14
- fromSearch?: string;
15
- fromCluster?: number;
16
- limit?: number;
17
- }
18
-
19
- export async function createPack(
20
- store: VectorStore,
21
- searchEngine: SearchEngine,
22
- embedder: Embedder,
23
- options: CreatePackOptions,
24
- ): Promise<{ pack: KnowledgePack; piiReport: { redactedCount: number; types: string[] } }> {
25
- const { name, author = 'anonymous', license = 'CC-BY-4.0', description = '', limit = 100 } = options;
26
-
27
- let chunkIds: string[] = [];
28
-
29
- if (options.fromSearch) {
30
- // 검색 결과에서 청크 수집
31
- const results = await searchEngine.search({ query: options.fromSearch, limit });
32
- chunkIds = results.map(r => r.chunk.id);
33
- } else if (options.fromCluster !== undefined) {
34
- // 클러스터의 문서에서 청크 수집
35
- const docs = await store.getAllDocuments();
36
- const embeddings = await store.getDocumentEmbeddings();
37
-
38
- // 간단한 클러스터 매칭: graph-data의 K-means 결과를 재활용할 수 없으므로
39
- // 해당 클러스터 문서의 모든 청크를 가져옴
40
- // 여기서는 fromSearch를 권장하되, fromCluster는 문서 ID 기반으로 처리
41
- const clusterDocs = docs.slice(0, limit);
42
- for (const doc of clusterDocs) {
43
- const chunk = await store.getChunk(`${doc.id}#0`);
44
- if (chunk) chunkIds.push(chunk.id);
45
- }
46
- }
47
-
48
- // 청크 데이터 수집 + PII 마스킹
49
- const chunks: PackChunk[] = [];
50
- let totalRedacted = 0;
51
- const allTypes = new Set<string>();
52
-
53
- for (const chunkId of chunkIds) {
54
- const chunk = await store.getChunk(chunkId);
55
- if (!chunk) continue;
56
-
57
- const doc = await store.getDocument(chunk.documentId);
58
- if (!doc) continue;
59
-
60
- // PII 마스킹
61
- const { masked, redactedCount, redactedTypes } = maskPII(chunk.content);
62
- totalRedacted += redactedCount;
63
- redactedTypes.forEach(t => allTypes.add(t));
64
-
65
- // 임베딩 재생성 (마스킹된 텍스트로)
66
- const embedding = await embedder.embed(masked);
67
-
68
- chunks.push({
69
- id: chunkId,
70
- content: masked,
71
- heading: chunk.heading,
72
- embedding,
73
- metadata: {
74
- sourceFile: doc.filePath,
75
- category: detectCategory(doc.filePath, chunk.content),
76
- language: detectLanguage(chunk.content),
77
- },
78
- });
79
- }
80
-
81
- const pack: KnowledgePack = {
82
- name,
83
- version: '1.0.0',
84
- author,
85
- license,
86
- description: description || `Knowledge pack: ${name}`,
87
- tags: extractPackTags(chunks),
88
- embeddingModel: embedder.modelName,
89
- embeddingDimensions: embedder.dimensions,
90
- schemaVersion: '1.0',
91
- chunks,
92
- createdAt: new Date().toISOString(),
93
- };
94
-
95
- return {
96
- pack,
97
- piiReport: { redactedCount: totalRedacted, types: [...allTypes] },
98
- };
99
- }
100
-
101
- function detectCategory(filePath: string, content: string): string {
102
- const lower = filePath.toLowerCase() + ' ' + content.slice(0, 200).toLowerCase();
103
- if (lower.includes('lesson') || lower.includes('교훈')) return 'lesson';
104
- if (lower.includes('pattern') || lower.includes('패턴')) return 'pattern';
105
- if (lower.includes('decision') || lower.includes('결정')) return 'decision';
106
- if (lower.includes('design') || lower.includes('설계')) return 'reference';
107
- return 'reference';
108
- }
109
-
110
- function detectLanguage(content: string): string | undefined {
111
- if (content.includes('typescript') || content.includes('.ts')) return 'typescript';
112
- if (content.includes('python') || content.includes('.py')) return 'python';
113
- if (content.includes('react') || content.includes('jsx')) return 'react';
114
- return undefined;
115
- }
116
-
117
- function extractPackTags(chunks: PackChunk[]): string[] {
118
- const wordCounts = new Map<string, number>();
119
- for (const c of chunks) {
120
- const words = c.heading.split(/\s+/).filter(w => w.length > 2);
121
- for (const w of words) wordCounts.set(w, (wordCounts.get(w) ?? 0) + 1);
122
- }
123
- return [...wordCounts.entries()]
124
- .sort((a, b) => b[1] - a[1])
125
- .slice(0, 10)
126
- .map(([w]) => w);
127
- }
@@ -1,21 +0,0 @@
1
- // Design Ref: Phase 3 FR-05 — .sv-pack 파일 내보내기
2
-
3
- import { writeFileSync, mkdirSync } from 'node:fs';
4
- import { dirname } from 'node:path';
5
- import type { KnowledgePack } from './types.js';
6
-
7
- export function exportPack(pack: KnowledgePack, outputPath: string): void {
8
- mkdirSync(dirname(outputPath), { recursive: true });
9
- writeFileSync(outputPath, JSON.stringify(pack, null, 2), 'utf-8');
10
- }
11
-
12
- export function packToSummary(pack: KnowledgePack): string {
13
- return [
14
- `Name: ${pack.name} v${pack.version}`,
15
- `Author: ${pack.author} (${pack.license})`,
16
- `Chunks: ${pack.chunks.length}`,
17
- `Model: ${pack.embeddingModel} (${pack.embeddingDimensions}d)`,
18
- `Tags: ${pack.tags.join(', ')}`,
19
- `Created: ${pack.createdAt}`,
20
- ].join('\n');
21
- }
@@ -1,82 +0,0 @@
1
- // Design Ref: Phase 3 FR-06~07 — .sv-pack 가져오기 + 벡터 DB 병합
2
-
3
- import { readFileSync } from 'node:fs';
4
- import type { VectorStore } from '../store/types.js';
5
- import type { Embedder } from '../indexer/embedder.js';
6
- import type { KnowledgePack } from './types.js';
7
-
8
- export interface ImportResult {
9
- imported: number;
10
- skipped: number;
11
- reEmbedded: number;
12
- modelMismatch: boolean;
13
- }
14
-
15
- export async function importPack(
16
- store: VectorStore,
17
- embedder: Embedder,
18
- filePath: string,
19
- ): Promise<ImportResult> {
20
- const raw = readFileSync(filePath, 'utf-8');
21
- const pack: KnowledgePack = JSON.parse(raw);
22
-
23
- // 임베딩 모델 불일치 감지
24
- const modelMismatch = pack.embeddingModel !== embedder.modelName ||
25
- pack.embeddingDimensions !== embedder.dimensions;
26
-
27
- let imported = 0;
28
- let skipped = 0;
29
- let reEmbedded = 0;
30
-
31
- // 팩 문서를 pack_{name} prefix로 저장
32
- const packDocId = `pack_${pack.name}`;
33
-
34
- await store.upsertDocument({
35
- id: packDocId,
36
- filePath: `[pack] ${pack.name}`,
37
- title: `${pack.name} (Knowledge Pack)`,
38
- content: `Imported pack: ${pack.description}\nChunks: ${pack.chunks.length}\nAuthor: ${pack.author}`,
39
- frontmatter: { pack: pack.name, license: pack.license },
40
- tags: pack.tags,
41
- lastModified: pack.createdAt,
42
- contentHash: `pack_${pack.name}_${pack.version}`,
43
- });
44
-
45
- const chunks = [];
46
- for (let i = 0; i < pack.chunks.length; i++) {
47
- const pc = pack.chunks[i];
48
-
49
- let embedding = pc.embedding;
50
-
51
- // 모델 불일치 시 재임베딩
52
- if (modelMismatch) {
53
- embedding = await embedder.embed(pc.content);
54
- reEmbedded++;
55
- }
56
-
57
- // 차원 검증
58
- if (embedding.length !== embedder.dimensions) {
59
- skipped++;
60
- continue;
61
- }
62
-
63
- chunks.push({
64
- id: `${packDocId}#${i}`,
65
- documentId: packDocId,
66
- content: pc.content,
67
- heading: pc.heading || pack.name,
68
- startLine: 0,
69
- endLine: 0,
70
- tokenCount: Math.ceil(pc.content.length / 4),
71
- embedding,
72
- });
73
-
74
- imported++;
75
- }
76
-
77
- if (chunks.length > 0) {
78
- await store.upsertChunks(chunks);
79
- }
80
-
81
- return { imported, skipped, reEmbedded, modelMismatch };
82
- }