stellavault 0.2.0 → 0.3.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.
Files changed (400) hide show
  1. package/package.json +1 -1
  2. package/packages/core/dist/api/dashboard.d.ts +3 -0
  3. package/packages/core/{src/api/dashboard.ts → dist/api/dashboard.js} +8 -11
  4. package/packages/core/dist/api/graph-data.d.ts +11 -0
  5. package/packages/core/dist/api/graph-data.js +255 -0
  6. package/packages/core/dist/api/pwa.d.ts +3 -0
  7. package/packages/core/{src/api/pwa.ts → dist/api/pwa.js} +27 -32
  8. package/packages/core/dist/api/server.d.ts +16 -0
  9. package/packages/core/dist/api/server.js +718 -0
  10. package/packages/core/dist/capture/voice.d.ts +24 -0
  11. package/packages/core/dist/capture/voice.js +135 -0
  12. package/packages/core/{src/cloud/index.ts → dist/cloud/index.d.ts} +1 -0
  13. package/packages/core/dist/cloud/index.js +2 -0
  14. package/packages/core/dist/cloud/sync.d.ts +29 -0
  15. package/packages/core/dist/cloud/sync.js +137 -0
  16. package/packages/core/dist/config.d.ts +27 -0
  17. package/packages/core/dist/config.js +55 -0
  18. package/packages/core/dist/federation/credits.d.ts +26 -0
  19. package/packages/core/dist/federation/credits.js +56 -0
  20. package/packages/core/dist/federation/identity.d.ts +14 -0
  21. package/packages/core/dist/federation/identity.js +74 -0
  22. package/packages/core/{src/federation/index.ts → dist/federation/index.d.ts} +1 -2
  23. package/packages/core/dist/federation/index.js +5 -0
  24. package/packages/core/dist/federation/node.d.ts +31 -0
  25. package/packages/core/dist/federation/node.js +216 -0
  26. package/packages/core/dist/federation/privacy.d.ts +8 -0
  27. package/packages/core/dist/federation/privacy.js +40 -0
  28. package/packages/core/dist/federation/reputation.d.ts +37 -0
  29. package/packages/core/dist/federation/reputation.js +139 -0
  30. package/packages/core/dist/federation/search.d.ts +19 -0
  31. package/packages/core/dist/federation/search.js +101 -0
  32. package/packages/core/dist/federation/sharing.d.ts +72 -0
  33. package/packages/core/dist/federation/sharing.js +246 -0
  34. package/packages/core/dist/federation/trust.d.ts +15 -0
  35. package/packages/core/dist/federation/trust.js +60 -0
  36. package/packages/core/dist/federation/types.d.ts +40 -0
  37. package/packages/core/dist/federation/types.js +3 -0
  38. package/packages/core/dist/i18n/index.d.ts +6 -0
  39. package/packages/core/dist/i18n/index.js +81 -0
  40. package/packages/core/{src/index.ts → dist/index.d.ts} +46 -65
  41. package/packages/core/dist/index.js +69 -0
  42. package/packages/core/dist/indexer/chunker.d.ts +14 -0
  43. package/packages/core/dist/indexer/chunker.js +148 -0
  44. package/packages/core/dist/indexer/embedder.d.ts +8 -0
  45. package/packages/core/dist/indexer/embedder.js +3 -0
  46. package/packages/core/dist/indexer/index.d.ts +28 -0
  47. package/packages/core/dist/indexer/index.js +74 -0
  48. package/packages/core/dist/indexer/local-embedder.d.ts +3 -0
  49. package/packages/core/dist/indexer/local-embedder.js +29 -0
  50. package/packages/core/dist/indexer/scanner.d.ts +11 -0
  51. package/packages/core/dist/indexer/scanner.js +137 -0
  52. package/packages/core/dist/indexer/watcher.d.ts +19 -0
  53. package/packages/core/dist/indexer/watcher.js +49 -0
  54. package/packages/core/dist/intelligence/code-linker.d.ts +20 -0
  55. package/packages/core/dist/intelligence/code-linker.js +88 -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 +151 -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/detect-gaps.d.ts +24 -0
  91. package/packages/core/dist/mcp/tools/detect-gaps.js +47 -0
  92. package/packages/core/dist/mcp/tools/export.d.ts +29 -0
  93. package/packages/core/dist/mcp/tools/export.js +60 -0
  94. package/packages/core/dist/mcp/tools/federated-search.d.ts +29 -0
  95. package/packages/core/dist/mcp/tools/federated-search.js +36 -0
  96. package/packages/core/dist/mcp/tools/generate-claude-md.d.ts +35 -0
  97. package/packages/core/dist/mcp/tools/generate-claude-md.js +107 -0
  98. package/packages/core/dist/mcp/tools/get-document.d.ts +35 -0
  99. package/packages/core/dist/mcp/tools/get-document.js +25 -0
  100. package/packages/core/dist/mcp/tools/get-evolution.d.ts +28 -0
  101. package/packages/core/dist/mcp/tools/get-evolution.js +70 -0
  102. package/packages/core/dist/mcp/tools/get-related.d.ts +32 -0
  103. package/packages/core/dist/mcp/tools/get-related.js +33 -0
  104. package/packages/core/dist/mcp/tools/learning-path.d.ts +23 -0
  105. package/packages/core/dist/mcp/tools/learning-path.js +45 -0
  106. package/packages/core/dist/mcp/tools/link-code.d.ts +34 -0
  107. package/packages/core/dist/mcp/tools/link-code.js +44 -0
  108. package/packages/core/dist/mcp/tools/list-topics.d.ts +15 -0
  109. package/packages/core/dist/mcp/tools/list-topics.js +18 -0
  110. package/packages/core/dist/mcp/tools/search.d.ts +39 -0
  111. package/packages/core/dist/mcp/tools/search.js +29 -0
  112. package/packages/core/dist/mcp/tools/snapshot.d.ts +47 -0
  113. package/packages/core/dist/mcp/tools/snapshot.js +84 -0
  114. package/packages/core/dist/multi-vault/index.d.ts +26 -0
  115. package/packages/core/dist/multi-vault/index.js +80 -0
  116. package/packages/core/dist/pack/creator.d.ts +21 -0
  117. package/packages/core/dist/pack/creator.js +105 -0
  118. package/packages/core/dist/pack/exporter.d.ts +4 -0
  119. package/packages/core/dist/pack/exporter.js +18 -0
  120. package/packages/core/dist/pack/importer.d.ts +10 -0
  121. package/packages/core/dist/pack/importer.js +55 -0
  122. package/packages/core/{src/pack/index.ts → dist/pack/index.d.ts} +1 -0
  123. package/packages/core/dist/pack/index.js +5 -0
  124. package/packages/core/dist/pack/marketplace.d.ts +14 -0
  125. package/packages/core/dist/pack/marketplace.js +90 -0
  126. package/packages/core/dist/pack/pii-masker.d.ts +7 -0
  127. package/packages/core/dist/pack/pii-masker.js +29 -0
  128. package/packages/core/dist/pack/types.d.ts +36 -0
  129. package/packages/core/dist/pack/types.js +3 -0
  130. package/packages/core/dist/plugins/index.d.ts +35 -0
  131. package/packages/core/dist/plugins/index.js +57 -0
  132. package/packages/core/dist/plugins/webhooks.d.ts +30 -0
  133. package/packages/core/dist/plugins/webhooks.js +79 -0
  134. package/packages/core/dist/search/adaptive.d.ts +16 -0
  135. package/packages/core/dist/search/adaptive.js +67 -0
  136. package/packages/core/dist/search/bm25.d.ts +4 -0
  137. package/packages/core/dist/search/bm25.js +10 -0
  138. package/packages/core/dist/search/index.d.ts +15 -0
  139. package/packages/core/dist/search/index.js +64 -0
  140. package/packages/core/dist/search/rrf.d.ts +7 -0
  141. package/packages/core/dist/search/rrf.js +21 -0
  142. package/packages/core/dist/search/semantic.d.ts +5 -0
  143. package/packages/core/dist/search/semantic.js +6 -0
  144. package/packages/core/{src/store/index.ts → dist/store/index.d.ts} +1 -0
  145. package/packages/core/dist/store/index.js +2 -0
  146. package/packages/core/dist/store/sqlite-vec.d.ts +6 -0
  147. package/packages/core/dist/store/sqlite-vec.js +251 -0
  148. package/packages/core/dist/store/types.d.ts +20 -0
  149. package/packages/core/dist/store/types.js +3 -0
  150. package/packages/core/dist/team/index.d.ts +25 -0
  151. package/packages/core/dist/team/index.js +97 -0
  152. package/packages/core/dist/types/chunk.d.ts +23 -0
  153. package/packages/core/dist/types/chunk.js +3 -0
  154. package/packages/core/dist/types/document.d.ts +23 -0
  155. package/packages/core/dist/types/document.js +3 -0
  156. package/packages/core/dist/types/graph.d.ts +39 -0
  157. package/packages/core/dist/types/graph.js +3 -0
  158. package/packages/core/dist/types/index.d.ts +5 -0
  159. package/packages/core/dist/types/index.js +2 -0
  160. package/packages/core/dist/types/search.d.ts +39 -0
  161. package/packages/core/dist/types/search.js +3 -0
  162. package/packages/core/dist/utils/retry.d.ts +25 -0
  163. package/packages/core/dist/utils/retry.js +59 -0
  164. package/.github/workflows/pages.yml +0 -37
  165. package/memory/MEMORY.md +0 -25
  166. package/packages/cli/dist/commands/brief-cmd.d.ts.map +0 -1
  167. package/packages/cli/dist/commands/brief-cmd.js.map +0 -1
  168. package/packages/cli/dist/commands/capture-cmd.d.ts.map +0 -1
  169. package/packages/cli/dist/commands/capture-cmd.js.map +0 -1
  170. package/packages/cli/dist/commands/card-cmd.d.ts.map +0 -1
  171. package/packages/cli/dist/commands/card-cmd.js.map +0 -1
  172. package/packages/cli/dist/commands/clip-cmd.d.ts.map +0 -1
  173. package/packages/cli/dist/commands/clip-cmd.js.map +0 -1
  174. package/packages/cli/dist/commands/cloud-cmd.d.ts.map +0 -1
  175. package/packages/cli/dist/commands/cloud-cmd.js.map +0 -1
  176. package/packages/cli/dist/commands/contradictions-cmd.d.ts.map +0 -1
  177. package/packages/cli/dist/commands/contradictions-cmd.js.map +0 -1
  178. package/packages/cli/dist/commands/decay-cmd.d.ts.map +0 -1
  179. package/packages/cli/dist/commands/decay-cmd.js.map +0 -1
  180. package/packages/cli/dist/commands/digest-cmd.d.ts.map +0 -1
  181. package/packages/cli/dist/commands/digest-cmd.js.map +0 -1
  182. package/packages/cli/dist/commands/duplicates-cmd.d.ts.map +0 -1
  183. package/packages/cli/dist/commands/duplicates-cmd.js.map +0 -1
  184. package/packages/cli/dist/commands/federate-cmd.d.ts.map +0 -1
  185. package/packages/cli/dist/commands/federate-cmd.js.map +0 -1
  186. package/packages/cli/dist/commands/gaps-cmd.d.ts.map +0 -1
  187. package/packages/cli/dist/commands/gaps-cmd.js.map +0 -1
  188. package/packages/cli/dist/commands/graph-cmd.d.ts.map +0 -1
  189. package/packages/cli/dist/commands/graph-cmd.js.map +0 -1
  190. package/packages/cli/dist/commands/index-cmd.d.ts.map +0 -1
  191. package/packages/cli/dist/commands/index-cmd.js.map +0 -1
  192. package/packages/cli/dist/commands/init-cmd.d.ts.map +0 -1
  193. package/packages/cli/dist/commands/init-cmd.js.map +0 -1
  194. package/packages/cli/dist/commands/learn-cmd.d.ts.map +0 -1
  195. package/packages/cli/dist/commands/learn-cmd.js.map +0 -1
  196. package/packages/cli/dist/commands/pack-cmd.d.ts.map +0 -1
  197. package/packages/cli/dist/commands/pack-cmd.js.map +0 -1
  198. package/packages/cli/dist/commands/review-cmd.d.ts.map +0 -1
  199. package/packages/cli/dist/commands/review-cmd.js.map +0 -1
  200. package/packages/cli/dist/commands/search-cmd.d.ts.map +0 -1
  201. package/packages/cli/dist/commands/search-cmd.js.map +0 -1
  202. package/packages/cli/dist/commands/serve-cmd.d.ts.map +0 -1
  203. package/packages/cli/dist/commands/serve-cmd.js.map +0 -1
  204. package/packages/cli/dist/commands/status-cmd.d.ts.map +0 -1
  205. package/packages/cli/dist/commands/status-cmd.js.map +0 -1
  206. package/packages/cli/dist/commands/sync-cmd.d.ts.map +0 -1
  207. package/packages/cli/dist/commands/sync-cmd.js.map +0 -1
  208. package/packages/cli/dist/commands/vault-cmd.d.ts.map +0 -1
  209. package/packages/cli/dist/commands/vault-cmd.js.map +0 -1
  210. package/packages/cli/dist/index.d.ts.map +0 -1
  211. package/packages/cli/dist/index.js.map +0 -1
  212. package/packages/cli/src/commands/brief-cmd.ts +0 -87
  213. package/packages/cli/src/commands/capture-cmd.ts +0 -34
  214. package/packages/cli/src/commands/card-cmd.ts +0 -29
  215. package/packages/cli/src/commands/clip-cmd.ts +0 -172
  216. package/packages/cli/src/commands/cloud-cmd.ts +0 -75
  217. package/packages/cli/src/commands/contradictions-cmd.ts +0 -41
  218. package/packages/cli/src/commands/decay-cmd.ts +0 -57
  219. package/packages/cli/src/commands/digest-cmd.ts +0 -89
  220. package/packages/cli/src/commands/duplicates-cmd.ts +0 -38
  221. package/packages/cli/src/commands/federate-cmd.ts +0 -256
  222. package/packages/cli/src/commands/gaps-cmd.ts +0 -40
  223. package/packages/cli/src/commands/graph-cmd.ts +0 -88
  224. package/packages/cli/src/commands/index-cmd.ts +0 -65
  225. package/packages/cli/src/commands/init-cmd.ts +0 -145
  226. package/packages/cli/src/commands/learn-cmd.ts +0 -56
  227. package/packages/cli/src/commands/pack-cmd.ts +0 -121
  228. package/packages/cli/src/commands/review-cmd.ts +0 -125
  229. package/packages/cli/src/commands/search-cmd.ts +0 -45
  230. package/packages/cli/src/commands/serve-cmd.ts +0 -17
  231. package/packages/cli/src/commands/status-cmd.ts +0 -37
  232. package/packages/cli/src/commands/sync-cmd.ts +0 -68
  233. package/packages/cli/src/commands/vault-cmd.ts +0 -64
  234. package/packages/cli/src/index.ts +0 -187
  235. package/packages/core/src/api/graph-data.ts +0 -286
  236. package/packages/core/src/api/server.ts +0 -660
  237. package/packages/core/src/capture/voice.ts +0 -168
  238. package/packages/core/src/cloud/sync.ts +0 -167
  239. package/packages/core/src/config.ts +0 -82
  240. package/packages/core/src/federation/credits.ts +0 -80
  241. package/packages/core/src/federation/hyperswarm.d.ts +0 -19
  242. package/packages/core/src/federation/identity.ts +0 -90
  243. package/packages/core/src/federation/node.ts +0 -235
  244. package/packages/core/src/federation/privacy.ts +0 -52
  245. package/packages/core/src/federation/reputation.ts +0 -202
  246. package/packages/core/src/federation/search.ts +0 -129
  247. package/packages/core/src/federation/sharing.ts +0 -315
  248. package/packages/core/src/federation/trust.ts +0 -76
  249. package/packages/core/src/federation/types.ts +0 -25
  250. package/packages/core/src/i18n/index.ts +0 -85
  251. package/packages/core/src/indexer/chunker.ts +0 -180
  252. package/packages/core/src/indexer/embedder.ts +0 -9
  253. package/packages/core/src/indexer/index.ts +0 -113
  254. package/packages/core/src/indexer/local-embedder.ts +0 -35
  255. package/packages/core/src/indexer/scanner.ts +0 -142
  256. package/packages/core/src/indexer/watcher.ts +0 -62
  257. package/packages/core/src/intelligence/contradiction-detector.ts +0 -134
  258. package/packages/core/src/intelligence/decay-engine.ts +0 -229
  259. package/packages/core/src/intelligence/duplicate-detector.ts +0 -71
  260. package/packages/core/src/intelligence/fsrs.ts +0 -79
  261. package/packages/core/src/intelligence/gap-detector.ts +0 -109
  262. package/packages/core/src/intelligence/learning-path.ts +0 -86
  263. package/packages/core/src/intelligence/notifications.ts +0 -106
  264. package/packages/core/src/intelligence/predictive-gaps.ts +0 -94
  265. package/packages/core/src/intelligence/semantic-versioning.ts +0 -97
  266. package/packages/core/src/intelligence/types.ts +0 -28
  267. package/packages/core/src/mcp/custom-tools.ts +0 -97
  268. package/packages/core/src/mcp/server.ts +0 -142
  269. package/packages/core/src/mcp/tools/agentic-graph.ts +0 -96
  270. package/packages/core/src/mcp/tools/brief.ts +0 -49
  271. package/packages/core/src/mcp/tools/decay.ts +0 -40
  272. package/packages/core/src/mcp/tools/decision-journal.ts +0 -95
  273. package/packages/core/src/mcp/tools/export.ts +0 -72
  274. package/packages/core/src/mcp/tools/federated-search.ts +0 -43
  275. package/packages/core/src/mcp/tools/generate-claude-md.ts +0 -130
  276. package/packages/core/src/mcp/tools/get-document.ts +0 -26
  277. package/packages/core/src/mcp/tools/get-related.ts +0 -41
  278. package/packages/core/src/mcp/tools/learning-path.ts +0 -52
  279. package/packages/core/src/mcp/tools/list-topics.ts +0 -20
  280. package/packages/core/src/mcp/tools/search.ts +0 -35
  281. package/packages/core/src/mcp/tools/snapshot.ts +0 -98
  282. package/packages/core/src/multi-vault/index.ts +0 -118
  283. package/packages/core/src/pack/creator.ts +0 -127
  284. package/packages/core/src/pack/exporter.ts +0 -21
  285. package/packages/core/src/pack/importer.ts +0 -82
  286. package/packages/core/src/pack/marketplace.ts +0 -103
  287. package/packages/core/src/pack/pii-masker.ts +0 -38
  288. package/packages/core/src/pack/types.ts +0 -39
  289. package/packages/core/src/plugins/index.ts +0 -100
  290. package/packages/core/src/plugins/webhooks.ts +0 -110
  291. package/packages/core/src/search/bm25.ts +0 -16
  292. package/packages/core/src/search/index.ts +0 -83
  293. package/packages/core/src/search/rrf.ts +0 -31
  294. package/packages/core/src/search/semantic.ts +0 -15
  295. package/packages/core/src/store/sqlite-vec.ts +0 -290
  296. package/packages/core/src/store/types.ts +0 -22
  297. package/packages/core/src/team/index.ts +0 -126
  298. package/packages/core/src/types/chunk.ts +0 -25
  299. package/packages/core/src/types/document.ts +0 -24
  300. package/packages/core/src/types/graph.ts +0 -44
  301. package/packages/core/src/types/index.ts +0 -15
  302. package/packages/core/src/types/search.ts +0 -38
  303. package/packages/core/src/utils/retry.ts +0 -85
  304. package/packages/core/tests/api-card.test.ts +0 -60
  305. package/packages/core/tests/api-routes.test.ts +0 -98
  306. package/packages/core/tests/bm25.test.ts +0 -87
  307. package/packages/core/tests/chunker.test.ts +0 -48
  308. package/packages/core/tests/cluster.test.ts +0 -75
  309. package/packages/core/tests/constellation.test.ts +0 -77
  310. package/packages/core/tests/export-utils.test.ts +0 -97
  311. package/packages/core/tests/fsrs.test.ts +0 -96
  312. package/packages/core/tests/gesture-detector.test.ts +0 -45
  313. package/packages/core/tests/graph-data.test.ts +0 -87
  314. package/packages/core/tests/layout.test.ts +0 -83
  315. package/packages/core/tests/mcp.test.ts +0 -148
  316. package/packages/core/tests/pack.test.ts +0 -127
  317. package/packages/core/tests/pii-masker.test.ts +0 -42
  318. package/packages/core/tests/profile-card.test.ts +0 -62
  319. package/packages/core/tests/rrf.test.ts +0 -29
  320. package/packages/core/tests/search-integration.test.ts +0 -139
  321. package/packages/core/tests/store.test.ts +0 -80
  322. package/packages/graph/click-result.png +0 -0
  323. package/packages/graph/dist/assets/camera_utils-BMxqtvoZ.js +0 -1
  324. package/packages/graph/dist/assets/hands-DXA01_mx.js +0 -18
  325. package/packages/graph/dist/assets/index-DMEe2diW.js +0 -4192
  326. package/packages/graph/dist/assets/layout.worker-DbKCEFTz.js +0 -1
  327. package/packages/graph/dist/index.html +0 -17
  328. package/packages/graph/index.html +0 -17
  329. package/packages/graph/package.json +0 -32
  330. package/packages/graph/src/App.tsx +0 -7
  331. package/packages/graph/src/api/client.ts +0 -39
  332. package/packages/graph/src/components/ClusterFilter.tsx +0 -73
  333. package/packages/graph/src/components/ConstellationView.tsx +0 -232
  334. package/packages/graph/src/components/ExportPanel.tsx +0 -177
  335. package/packages/graph/src/components/Graph3D.tsx +0 -230
  336. package/packages/graph/src/components/GraphEdges.tsx +0 -100
  337. package/packages/graph/src/components/GraphNodes.tsx +0 -386
  338. package/packages/graph/src/components/HealthDashboard.tsx +0 -173
  339. package/packages/graph/src/components/Layout.tsx +0 -214
  340. package/packages/graph/src/components/MotionOverlay.tsx +0 -81
  341. package/packages/graph/src/components/MotionToggle.tsx +0 -33
  342. package/packages/graph/src/components/MultiverseView.tsx +0 -286
  343. package/packages/graph/src/components/NodeDetail.tsx +0 -232
  344. package/packages/graph/src/components/PulseParticle.tsx +0 -232
  345. package/packages/graph/src/components/SearchBar.tsx +0 -107
  346. package/packages/graph/src/components/StarField.tsx +0 -197
  347. package/packages/graph/src/components/StatusBar.tsx +0 -53
  348. package/packages/graph/src/components/Timeline.tsx +0 -148
  349. package/packages/graph/src/components/ToolsPanel.tsx +0 -512
  350. package/packages/graph/src/components/Tooltip.tsx +0 -100
  351. package/packages/graph/src/components/TypeFilter.tsx +0 -131
  352. package/packages/graph/src/embed/EmbedGraph.tsx +0 -144
  353. package/packages/graph/src/hooks/useConstellationLOD.ts +0 -76
  354. package/packages/graph/src/hooks/useDecay.ts +0 -37
  355. package/packages/graph/src/hooks/useExport.ts +0 -165
  356. package/packages/graph/src/hooks/useGraph.ts +0 -69
  357. package/packages/graph/src/hooks/useKeyboardNav.ts +0 -122
  358. package/packages/graph/src/hooks/useLayout.ts +0 -45
  359. package/packages/graph/src/hooks/useMotion.ts +0 -120
  360. package/packages/graph/src/hooks/usePulse.ts +0 -58
  361. package/packages/graph/src/hooks/useSearch.ts +0 -71
  362. package/packages/graph/src/lib/constellation.ts +0 -107
  363. package/packages/graph/src/lib/export-utils.ts +0 -48
  364. package/packages/graph/src/lib/gesture-detector.ts +0 -123
  365. package/packages/graph/src/lib/layout.worker.ts +0 -153
  366. package/packages/graph/src/lib/motion-controller.ts +0 -83
  367. package/packages/graph/src/lib/profile-card.ts +0 -122
  368. package/packages/graph/src/main.tsx +0 -4
  369. package/packages/graph/src/stores/graph-store.ts +0 -155
  370. package/packages/graph/success.png +0 -0
  371. package/packages/graph/test-click.mjs +0 -49
  372. package/packages/graph/test-explore.mjs +0 -102
  373. package/packages/graph/test-final.mjs +0 -61
  374. package/packages/graph/test-graph.mjs +0 -139
  375. package/packages/graph/test-hover.mjs +0 -48
  376. package/packages/graph/test-pulse.mjs +0 -68
  377. package/packages/graph/test-screenshot.mjs +0 -56
  378. package/packages/graph/test-v2.mjs +0 -97
  379. package/packages/graph/tsconfig.tsbuildinfo +0 -1
  380. package/packages/graph/vite.config.ts +0 -15
  381. package/packages/sync/.env.example +0 -11
  382. package/packages/sync/.sync-state.json +0 -317
  383. package/packages/sync/.upload-state.json +0 -1009
  384. package/packages/sync/create-stella-network-notion.mjs +0 -151
  385. package/packages/sync/create-stellavault-project-notion.mjs +0 -322
  386. package/packages/sync/logs/sync-2026-03-28.log +0 -6
  387. package/packages/sync/logs/sync-2026-03-29.log +0 -12
  388. package/packages/sync/logs/sync-2026-03-30.log +0 -6
  389. package/packages/sync/logs/sync-2026-03-31.log +0 -6
  390. package/packages/sync/logs/sync-2026-04-01.log +0 -6
  391. package/packages/sync/logs/sync-2026-04-02.log +0 -6
  392. package/packages/sync/package-lock.json +0 -373
  393. package/packages/sync/package.json +0 -16
  394. package/packages/sync/run-sync.bat +0 -18
  395. package/packages/sync/run-sync.mjs +0 -46
  396. package/packages/sync/setup-scheduler.mjs +0 -119
  397. package/packages/sync/structured-sync.mjs +0 -187
  398. package/packages/sync/sync-to-obsidian.mjs +0 -264
  399. package/packages/sync/upload-pdca-to-notion.mjs +0 -495
  400. package/tsconfig.base.json +0 -18
@@ -1,110 +0,0 @@
1
- // Webhook/Event System (F-A17)
2
- // Emit events on index, decay, gap detection → deliver via HTTP webhook
3
-
4
- import type { PluginEvent } from './index.js';
5
-
6
- export interface WebhookConfig {
7
- url: string;
8
- events: PluginEvent[];
9
- secret?: string; // HMAC-SHA256 signing key
10
- retries?: number;
11
- }
12
-
13
- export interface WebhookDelivery {
14
- id: string;
15
- event: PluginEvent;
16
- url: string;
17
- status: 'pending' | 'success' | 'failed';
18
- attempts: number;
19
- lastAttempt?: string;
20
- response?: { status: number; body: string };
21
- }
22
-
23
- export class WebhookManager {
24
- private configs: WebhookConfig[] = [];
25
- private deliveries: WebhookDelivery[] = [];
26
-
27
- register(config: WebhookConfig): void {
28
- // MED: webhook URL 검증
29
- try {
30
- const parsed = new URL(config.url);
31
- if (!['http:', 'https:'].includes(parsed.protocol)) throw new Error('Invalid protocol');
32
- const host = parsed.hostname.toLowerCase();
33
- if (host === 'localhost' || host === '127.0.0.1' || host.startsWith('192.168.') || host.startsWith('10.')) {
34
- throw new Error('Internal URLs not allowed for webhooks');
35
- }
36
- } catch (e) { throw new Error(`Invalid webhook URL: ${e instanceof Error ? e.message : e}`); }
37
- this.configs.push(config);
38
- }
39
-
40
- unregister(url: string): void {
41
- this.configs = this.configs.filter(c => c.url !== url);
42
- }
43
-
44
- async emit(event: PluginEvent, data: unknown): Promise<WebhookDelivery[]> {
45
- const matching = this.configs.filter(c => c.events.includes(event));
46
- const results: WebhookDelivery[] = [];
47
-
48
- for (const config of matching) {
49
- const delivery = await this.deliver(config, event, data);
50
- results.push(delivery);
51
- this.deliveries.push(delivery);
52
- }
53
-
54
- // Keep last 100 deliveries
55
- if (this.deliveries.length > 100) {
56
- this.deliveries = this.deliveries.slice(-100);
57
- }
58
-
59
- return results;
60
- }
61
-
62
- private async deliver(config: WebhookConfig, event: PluginEvent, data: unknown): Promise<WebhookDelivery> {
63
- const id = `wh-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
64
- const maxRetries = config.retries ?? 3;
65
- const delivery: WebhookDelivery = { id, event, url: config.url, status: 'pending', attempts: 0 };
66
-
67
- const payload = JSON.stringify({ event, data, timestamp: new Date().toISOString(), source: 'stellavault' });
68
-
69
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
70
- delivery.attempts = attempt + 1;
71
- delivery.lastAttempt = new Date().toISOString();
72
-
73
- try {
74
- const headers: Record<string, string> = { 'Content-Type': 'application/json', 'User-Agent': 'stellavault-webhook/1.0' };
75
-
76
- if (config.secret) {
77
- const { createHmac } = await import('node:crypto');
78
- const sig = createHmac('sha256', config.secret).update(payload).digest('hex');
79
- headers['X-Stellavault-Signature'] = `sha256=${sig}`;
80
- }
81
-
82
- const res = await fetch(config.url, { method: 'POST', headers, body: payload, signal: AbortSignal.timeout(10000) });
83
- delivery.response = { status: res.status, body: (await res.text()).slice(0, 500) };
84
-
85
- if (res.ok) {
86
- delivery.status = 'success';
87
- return delivery;
88
- }
89
- } catch (err) {
90
- delivery.response = { status: 0, body: err instanceof Error ? err.message : String(err) };
91
- }
92
-
93
- // Exponential backoff
94
- if (attempt < maxRetries) {
95
- await new Promise(r => setTimeout(r, 1000 * Math.pow(2, attempt)));
96
- }
97
- }
98
-
99
- delivery.status = 'failed';
100
- return delivery;
101
- }
102
-
103
- getRecentDeliveries(limit = 20): WebhookDelivery[] {
104
- return this.deliveries.slice(-limit).reverse();
105
- }
106
-
107
- listWebhooks(): WebhookConfig[] {
108
- return [...this.configs];
109
- }
110
- }
@@ -1,16 +0,0 @@
1
- // Design Ref: §6.2 — BM25 키워드 검색 (FTS5)
2
-
3
- import type { VectorStore } from '../store/types.js';
4
- import type { ScoredChunk } from '../types/chunk.js';
5
-
6
- export async function searchBm25(
7
- store: VectorStore,
8
- query: string,
9
- limit: number,
10
- ): Promise<ScoredChunk[]> {
11
- // FTS5 쿼리 전처리: 특수문자 제거, 공백으로 OR 검색
12
- const sanitized = query.replace(/[^\w\s가-힣]/g, ' ').trim();
13
- if (!sanitized) return [];
14
- const ftsQuery = sanitized.split(/\s+/).join(' OR ');
15
- return store.searchKeyword(ftsQuery, limit);
16
- }
@@ -1,83 +0,0 @@
1
- // Design Ref: §4.2 — createSearchEngine
2
-
3
- import type { Embedder } from '../indexer/embedder.js';
4
- import type { VectorStore } from '../store/types.js';
5
- import type { SearchResult, SearchOptions } from '../types/search.js';
6
- import { searchBm25 } from './bm25.js';
7
- import { searchSemantic } from './semantic.js';
8
- import { rrfFusion } from './rrf.js';
9
-
10
- export { rrfFusion } from './rrf.js';
11
-
12
- export interface SearchEngine {
13
- search(options: SearchOptions): Promise<SearchResult[]>;
14
- }
15
-
16
- export function createSearchEngine(deps: {
17
- store: VectorStore;
18
- embedder: Embedder;
19
- rrfK?: number;
20
- }): SearchEngine {
21
- const { store, embedder, rrfK = 60 } = deps;
22
- const FETCH_LIMIT = 30; // 각 검색에서 가져올 후보 수
23
-
24
- return {
25
- async search(options: SearchOptions): Promise<SearchResult[]> {
26
- const { query, limit = 10, threshold = 0.0, tags } = options;
27
-
28
- // 병렬로 BM25 + Semantic 검색
29
- const [bm25Results, semanticResults] = await Promise.all([
30
- searchBm25(store, query, FETCH_LIMIT),
31
- searchSemantic(store, embedder, query, FETCH_LIMIT),
32
- ]);
33
-
34
- // RRF Fusion
35
- const fused = rrfFusion(semanticResults, bm25Results, rrfK, limit * 2);
36
-
37
- // 청크+문서 조회 + 필터링
38
- const results: SearchResult[] = [];
39
- for (const scored of fused) {
40
- if (scored.score < threshold) continue;
41
-
42
- const chunk = await store.getChunk(scored.chunkId);
43
- if (!chunk) continue;
44
-
45
- const document = await store.getDocument(chunk.documentId);
46
- if (!document) continue;
47
-
48
- // 태그 필터
49
- if (tags && tags.length > 0) {
50
- const docTags = new Set(document.tags);
51
- if (!tags.some(t => docTags.has(t))) continue;
52
- }
53
-
54
- results.push({
55
- chunk,
56
- document,
57
- score: scored.score,
58
- highlights: extractHighlights(chunk.content, query),
59
- });
60
-
61
- if (results.length >= limit) break;
62
- }
63
-
64
- return results;
65
- },
66
- };
67
- }
68
-
69
- function extractHighlights(content: string, query: string): string[] {
70
- const words = query.toLowerCase().split(/\s+/).filter(w => w.length > 1);
71
- const lines = content.split('\n');
72
- const highlights: string[] = [];
73
-
74
- for (const line of lines) {
75
- const lower = line.toLowerCase();
76
- if (words.some(w => lower.includes(w))) {
77
- highlights.push(line.trim());
78
- if (highlights.length >= 3) break;
79
- }
80
- }
81
-
82
- return highlights;
83
- }
@@ -1,31 +0,0 @@
1
- // Design Ref: §6.2 — Reciprocal Rank Fusion (k=60)
2
-
3
- import type { ScoredChunk } from '../types/chunk.js';
4
-
5
- /**
6
- * RRF: 두 랭킹 리스트를 통합하여 최종 점수를 산출합니다.
7
- * score(d) = Σ 1/(k + rank_i) for each ranker i
8
- */
9
- export function rrfFusion(
10
- listA: ScoredChunk[],
11
- listB: ScoredChunk[],
12
- k: number = 60,
13
- limit: number = 10,
14
- ): ScoredChunk[] {
15
- const scores = new Map<string, number>();
16
-
17
- for (let i = 0; i < listA.length; i++) {
18
- const id = listA[i].chunkId;
19
- scores.set(id, (scores.get(id) ?? 0) + 1 / (k + i + 1));
20
- }
21
-
22
- for (let i = 0; i < listB.length; i++) {
23
- const id = listB[i].chunkId;
24
- scores.set(id, (scores.get(id) ?? 0) + 1 / (k + i + 1));
25
- }
26
-
27
- return [...scores.entries()]
28
- .sort((a, b) => b[1] - a[1])
29
- .slice(0, limit)
30
- .map(([chunkId, score]) => ({ chunkId, score }));
31
- }
@@ -1,15 +0,0 @@
1
- // Design Ref: §6.2 — 시맨틱 벡터 검색
2
-
3
- import type { Embedder } from '../indexer/embedder.js';
4
- import type { VectorStore } from '../store/types.js';
5
- import type { ScoredChunk } from '../types/chunk.js';
6
-
7
- export async function searchSemantic(
8
- store: VectorStore,
9
- embedder: Embedder,
10
- query: string,
11
- limit: number,
12
- ): Promise<ScoredChunk[]> {
13
- const embedding = await embedder.embed(query);
14
- return store.searchSemantic(embedding, limit);
15
- }
@@ -1,290 +0,0 @@
1
- // Design Ref: §3.3 — SQLite-vec 스키마
2
- // Design Ref: §3.2 — VectorStore 인터페이스 구현
3
-
4
- import Database from 'better-sqlite3';
5
- import * as sqliteVec from 'sqlite-vec';
6
- import { mkdirSync } from 'node:fs';
7
- import { dirname } from 'node:path';
8
- import type { VectorStore } from './types.js';
9
- import type { Chunk, ScoredChunk, Document, TopicInfo, StoreStats } from '../types/index.js';
10
-
11
- export function createSqliteVecStore(dbPath: string, dimensions: number = 384): VectorStore {
12
- let db: Database.Database;
13
-
14
- return {
15
- async initialize() {
16
- mkdirSync(dirname(dbPath), { recursive: true });
17
- db = new Database(dbPath);
18
- sqliteVec.load(db);
19
- db.pragma('journal_mode = WAL');
20
- db.pragma('foreign_keys = ON');
21
- createTables(db, dimensions);
22
- },
23
-
24
- async upsertDocument(doc: Document) {
25
- db.prepare(`
26
- INSERT OR REPLACE INTO documents (id, file_path, title, content, frontmatter, tags, last_modified, content_hash, indexed_at, source, type)
27
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
28
- `).run(
29
- doc.id, doc.filePath, doc.title, doc.content,
30
- JSON.stringify(doc.frontmatter), JSON.stringify(doc.tags),
31
- doc.lastModified, doc.contentHash, new Date().toISOString(),
32
- doc.source ?? 'local', doc.type ?? 'note'
33
- );
34
- },
35
-
36
- async upsertChunks(chunks: Chunk[]) {
37
- if (chunks.length === 0) return;
38
- const docId = chunks[0].documentId;
39
-
40
- const tx = db.transaction(() => {
41
- // 기존 청크 삭제 (문서 단위 교체)
42
- // 새로 삽입할 chunk ID들도 미리 삭제 (다른 문서에서 온 중복 방지)
43
- const newChunkIds = chunks.map(c => c.id);
44
- db.prepare('DELETE FROM chunk_embeddings WHERE chunk_id IN (SELECT id FROM chunks WHERE document_id = ?)').run(docId);
45
- db.prepare('DELETE FROM chunks WHERE document_id = ?').run(docId);
46
- for (const cid of newChunkIds) {
47
- db.prepare('DELETE FROM chunk_embeddings WHERE chunk_id = ?').run(cid);
48
- db.prepare('DELETE FROM chunks WHERE id = ?').run(cid);
49
- }
50
-
51
- const insertChunk = db.prepare(`
52
- INSERT INTO chunks (id, document_id, content, heading, start_line, end_line, token_count)
53
- VALUES (?, ?, ?, ?, ?, ?, ?)
54
- `);
55
- const insertEmbedding = db.prepare(`
56
- INSERT INTO chunk_embeddings (chunk_id, embedding)
57
- VALUES (?, ?)
58
- `);
59
-
60
- for (const chunk of chunks) {
61
- insertChunk.run(
62
- chunk.id, chunk.documentId, chunk.content,
63
- chunk.heading, chunk.startLine, chunk.endLine, chunk.tokenCount
64
- );
65
- if (chunk.embedding) {
66
- insertEmbedding.run(chunk.id, float32Buffer(chunk.embedding));
67
- }
68
- }
69
- });
70
- tx();
71
- },
72
-
73
- async deleteByDocumentId(documentId: string) {
74
- const tx = db.transaction(() => {
75
- db.prepare('DELETE FROM chunk_embeddings WHERE chunk_id IN (SELECT id FROM chunks WHERE document_id = ?)').run(documentId);
76
- db.prepare('DELETE FROM chunks WHERE document_id = ?').run(documentId);
77
- db.prepare('DELETE FROM documents WHERE id = ?').run(documentId);
78
- });
79
- tx();
80
- },
81
-
82
- async searchSemantic(embedding: number[], limit: number): Promise<ScoredChunk[]> {
83
- const rows = db.prepare(`
84
- SELECT chunk_id, distance
85
- FROM chunk_embeddings
86
- WHERE embedding MATCH ?
87
- ORDER BY distance
88
- LIMIT ?
89
- `).all(float32Buffer(embedding), limit) as Array<{ chunk_id: string; distance: number }>;
90
-
91
- return rows.map(r => ({
92
- chunkId: r.chunk_id,
93
- score: 1 / (1 + r.distance), // distance → similarity score
94
- }));
95
- },
96
-
97
- async searchKeyword(query: string, limit: number): Promise<ScoredChunk[]> {
98
- const rows = db.prepare(`
99
- SELECT c.id as chunk_id, rank
100
- FROM chunks_fts f
101
- JOIN chunks c ON c.rowid = f.rowid
102
- WHERE chunks_fts MATCH ?
103
- ORDER BY rank
104
- LIMIT ?
105
- `).all(query, limit) as Array<{ chunk_id: string; rank: number }>;
106
-
107
- return rows.map(r => ({
108
- chunkId: r.chunk_id,
109
- score: -r.rank, // FTS5 rank is negative (lower = better)
110
- }));
111
- },
112
-
113
- async getDocument(documentId: string): Promise<Document | null> {
114
- const row = db.prepare('SELECT * FROM documents WHERE id = ?').get(documentId) as any;
115
- if (!row) return null;
116
- return rowToDocument(row);
117
- },
118
-
119
- async getChunk(chunkId: string): Promise<Chunk | null> {
120
- const row = db.prepare('SELECT * FROM chunks WHERE id = ?').get(chunkId) as any;
121
- if (!row) return null;
122
- return rowToChunk(row);
123
- },
124
-
125
- async getAllDocuments(): Promise<Document[]> {
126
- const rows = db.prepare('SELECT * FROM documents ORDER BY last_modified DESC').all() as any[];
127
- return rows.map(rowToDocument);
128
- },
129
-
130
- async getTopics(): Promise<TopicInfo[]> {
131
- const rows = db.prepare(`
132
- SELECT je.value as tag, COUNT(DISTINCT d.id) as count
133
- FROM documents d, json_each(d.tags) je
134
- GROUP BY je.value
135
- ORDER BY count DESC
136
- `).all() as Array<{ tag: string; count: number }>;
137
-
138
- return rows.map(r => ({
139
- topic: r.tag,
140
- count: r.count,
141
- recentDocuments: [],
142
- }));
143
- },
144
-
145
- async getStats(): Promise<StoreStats> {
146
- const docCount = (db.prepare('SELECT COUNT(*) as c FROM documents').get() as any).c;
147
- const chunkCount = (db.prepare('SELECT COUNT(*) as c FROM chunks').get() as any).c;
148
- const lastRow = db.prepare('SELECT indexed_at FROM documents ORDER BY indexed_at DESC LIMIT 1').get() as any;
149
- return {
150
- documentCount: docCount,
151
- chunkCount: chunkCount,
152
- dbSizeBytes: 0, // 나중에 파일 크기 조회
153
- lastIndexed: lastRow?.indexed_at ?? null,
154
- };
155
- },
156
-
157
- async getDocumentEmbeddings(): Promise<Map<string, number[]>> {
158
- // 각 문서의 첫 청크 임베딩을 문서 대표 벡터로 사용
159
- const rows = db.prepare(`
160
- SELECT c.document_id, ce.embedding
161
- FROM chunks c
162
- JOIN chunk_embeddings ce ON ce.chunk_id = c.id
163
- WHERE c.id IN (
164
- SELECT MIN(id) FROM chunks GROUP BY document_id
165
- )
166
- `).all() as Array<{ document_id: string; embedding: Buffer }>;
167
-
168
- const result = new Map<string, number[]>();
169
- for (const row of rows) {
170
- result.set(row.document_id, bufferToFloat32(row.embedding));
171
- }
172
- return result;
173
- },
174
-
175
- async close() {
176
- db.close();
177
- },
178
-
179
- getDb() {
180
- return db;
181
- },
182
- };
183
- }
184
-
185
- function bufferToFloat32(buf: Buffer): number[] {
186
- const float32 = new Float32Array(buf.buffer, buf.byteOffset, buf.byteLength / 4);
187
- return Array.from(float32);
188
- }
189
-
190
- function createTables(db: Database.Database, dimensions: number = 384) {
191
- // 기존 DB 마이그레이션: source/type 컬럼 추가
192
- try {
193
- db.exec(`ALTER TABLE documents ADD COLUMN source TEXT DEFAULT 'local'`);
194
- } catch { /* 이미 존재 */ }
195
- try {
196
- db.exec(`ALTER TABLE documents ADD COLUMN type TEXT DEFAULT 'note'`);
197
- } catch { /* 이미 존재 */ }
198
-
199
- db.exec(`
200
- CREATE TABLE IF NOT EXISTS documents (
201
- id TEXT PRIMARY KEY,
202
- file_path TEXT NOT NULL UNIQUE,
203
- title TEXT NOT NULL,
204
- content TEXT NOT NULL,
205
- frontmatter TEXT,
206
- tags TEXT DEFAULT '[]',
207
- last_modified TEXT NOT NULL,
208
- content_hash TEXT NOT NULL,
209
- indexed_at TEXT NOT NULL,
210
- source TEXT DEFAULT 'local',
211
- type TEXT DEFAULT 'note'
212
- );
213
-
214
- CREATE TABLE IF NOT EXISTS chunks (
215
- id TEXT PRIMARY KEY,
216
- document_id TEXT NOT NULL REFERENCES documents(id) ON DELETE CASCADE,
217
- content TEXT NOT NULL,
218
- heading TEXT,
219
- start_line INTEGER,
220
- end_line INTEGER,
221
- token_count INTEGER
222
- );
223
-
224
- CREATE VIRTUAL TABLE IF NOT EXISTS chunk_embeddings USING vec0(
225
- chunk_id TEXT PRIMARY KEY,
226
- embedding FLOAT[${dimensions}]
227
- );
228
-
229
- CREATE VIRTUAL TABLE IF NOT EXISTS chunks_fts USING fts5(
230
- content,
231
- heading,
232
- content='chunks',
233
- content_rowid='rowid'
234
- );
235
-
236
- CREATE INDEX IF NOT EXISTS idx_chunks_document_id ON chunks(document_id);
237
- CREATE INDEX IF NOT EXISTS idx_documents_content_hash ON documents(content_hash);
238
- `);
239
-
240
- // FTS5 트리거: chunks INSERT/DELETE 시 자동 동기화
241
- db.exec(`
242
- CREATE TRIGGER IF NOT EXISTS chunks_ai AFTER INSERT ON chunks BEGIN
243
- INSERT INTO chunks_fts(rowid, content, heading) VALUES (new.rowid, new.content, new.heading);
244
- END;
245
- CREATE TRIGGER IF NOT EXISTS chunks_ad AFTER DELETE ON chunks BEGIN
246
- INSERT INTO chunks_fts(chunks_fts, rowid, content, heading) VALUES('delete', old.rowid, old.content, old.heading);
247
- END;
248
- `);
249
- }
250
-
251
- // Document 헬퍼: upsertDocument는 indexer에서 호출
252
- export function upsertDocument(db: Database.Database, doc: Document) {
253
- db.prepare(`
254
- INSERT OR REPLACE INTO documents (id, file_path, title, content, frontmatter, tags, last_modified, content_hash, indexed_at)
255
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
256
- `).run(
257
- doc.id, doc.filePath, doc.title, doc.content,
258
- JSON.stringify(doc.frontmatter), JSON.stringify(doc.tags),
259
- doc.lastModified, doc.contentHash, new Date().toISOString()
260
- );
261
- }
262
-
263
- function rowToDocument(row: any): Document {
264
- return {
265
- id: row.id,
266
- filePath: row.file_path,
267
- title: row.title,
268
- content: row.content,
269
- frontmatter: JSON.parse(row.frontmatter || '{}'),
270
- tags: JSON.parse(row.tags || '[]'),
271
- lastModified: row.last_modified,
272
- contentHash: row.content_hash,
273
- };
274
- }
275
-
276
- function rowToChunk(row: any): Chunk {
277
- return {
278
- id: row.id,
279
- documentId: row.document_id,
280
- content: row.content,
281
- heading: row.heading ?? '',
282
- startLine: row.start_line,
283
- endLine: row.end_line,
284
- tokenCount: row.token_count,
285
- };
286
- }
287
-
288
- function float32Buffer(arr: number[]): Buffer {
289
- return Buffer.from(new Float32Array(arr).buffer);
290
- }
@@ -1,22 +0,0 @@
1
- // Design Ref: §3.2 — 교체 가능 설계 (VectorStore 인터페이스)
2
-
3
- import type { Chunk, ScoredChunk, Document, TopicInfo, StoreStats } from '../types/index.js';
4
-
5
- export interface VectorStore {
6
- initialize(): Promise<void>;
7
- upsertDocument(doc: Document): Promise<void>;
8
- upsertChunks(chunks: Chunk[]): Promise<void>;
9
- deleteByDocumentId(documentId: string): Promise<void>;
10
- searchSemantic(embedding: number[], limit: number): Promise<ScoredChunk[]>;
11
- searchKeyword(query: string, limit: number): Promise<ScoredChunk[]>;
12
- getDocument(documentId: string): Promise<Document | null>;
13
- getChunk(chunkId: string): Promise<Chunk | null>;
14
- getAllDocuments(): Promise<Document[]>;
15
- getTopics(): Promise<TopicInfo[]>;
16
- getStats(): Promise<StoreStats>;
17
- /** 각 문서의 첫 청크 임베딩 반환 (graph용) */
18
- getDocumentEmbeddings(): Promise<Map<string, number[]>>;
19
- close(): Promise<void>;
20
- /** 내부 DB 인스턴스 접근 (Intelligence Layer용) */
21
- getDb(): unknown;
22
- }
@@ -1,126 +0,0 @@
1
- // Team Vault (F-A06) — Bearer 토큰 인증 + RBAC
2
- // MCP Streamable HTTP에 인증 레이어 추가
3
-
4
- import { randomBytes, createHash } from 'node:crypto';
5
- import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
6
- import { join } from 'node:path';
7
- import { homedir } from 'node:os';
8
-
9
- export type TeamRole = 'admin' | 'editor' | 'viewer';
10
-
11
- export interface TeamMember {
12
- token: string; // Bearer token (SHA256 hash stored)
13
- tokenHash: string; // stored version
14
- displayName: string;
15
- role: TeamRole;
16
- createdAt: string;
17
- lastAccess?: string;
18
- }
19
-
20
- export interface TeamConfig {
21
- teamName: string;
22
- members: TeamMember[];
23
- }
24
-
25
- const TEAM_DIR = join(homedir(), '.stellavault', 'team');
26
- const TEAM_FILE = join(TEAM_DIR, 'team.json');
27
-
28
- export function loadTeamConfig(): TeamConfig {
29
- if (existsSync(TEAM_FILE)) {
30
- return JSON.parse(readFileSync(TEAM_FILE, 'utf-8'));
31
- }
32
- return { teamName: 'My Team', members: [] };
33
- }
34
-
35
- function saveTeamConfig(config: TeamConfig): void {
36
- mkdirSync(TEAM_DIR, { recursive: true });
37
- writeFileSync(TEAM_FILE, JSON.stringify(config, null, 2), 'utf-8');
38
- }
39
-
40
- // 토큰 생성
41
- export function generateToken(): string {
42
- return `sv_${randomBytes(24).toString('hex')}`;
43
- }
44
-
45
- function hashToken(token: string): string {
46
- return createHash('sha256').update(token).digest('hex');
47
- }
48
-
49
- // 멤버 초대 → 토큰 반환
50
- export function inviteMember(displayName: string, role: TeamRole = 'viewer'): { token: string; member: TeamMember } {
51
- const config = loadTeamConfig();
52
- const token = generateToken();
53
- const member: TeamMember = {
54
- token: '', // 클리어 토큰은 저장 안 함
55
- tokenHash: hashToken(token),
56
- displayName,
57
- role,
58
- createdAt: new Date().toISOString(),
59
- };
60
- config.members.push(member);
61
- saveTeamConfig(config);
62
- return { token, member }; // 토큰은 이때만 보여줌
63
- }
64
-
65
- // 토큰으로 멤버 인증
66
- export function authenticateMember(token: string): TeamMember | null {
67
- const config = loadTeamConfig();
68
- const hash = hashToken(token);
69
- const member = config.members.find(m => m.tokenHash === hash);
70
- if (member) {
71
- member.lastAccess = new Date().toISOString();
72
- saveTeamConfig(config);
73
- }
74
- return member ?? null;
75
- }
76
-
77
- // RBAC 권한 확인
78
- export function hasPermission(member: TeamMember, action: 'read' | 'write' | 'admin'): boolean {
79
- switch (action) {
80
- case 'read': return true; // 모든 역할 읽기 가능
81
- case 'write': return member.role === 'admin' || member.role === 'editor';
82
- case 'admin': return member.role === 'admin';
83
- }
84
- }
85
-
86
- // 멤버 목록
87
- export function listMembers(): TeamMember[] {
88
- return loadTeamConfig().members;
89
- }
90
-
91
- // 멤버 제거
92
- export function removeMember(displayName: string): boolean {
93
- const config = loadTeamConfig();
94
- const before = config.members.length;
95
- config.members = config.members.filter(m => m.displayName !== displayName);
96
- if (config.members.length < before) {
97
- saveTeamConfig(config);
98
- return true;
99
- }
100
- return false;
101
- }
102
-
103
- // Express 미들웨어: Bearer 토큰 인증
104
- export function createAuthMiddleware() {
105
- return (req: any, res: any, next: any) => {
106
- const authHeader = req.headers.authorization;
107
- if (!authHeader?.startsWith('Bearer ')) {
108
- // HIGH-01: localhost는 editor 권한만 (admin은 토큰 필수)
109
- const ip = req.ip || req.connection?.remoteAddress;
110
- if (ip === '127.0.0.1' || ip === '::1' || ip === '::ffff:127.0.0.1') {
111
- req.teamMember = { displayName: 'local', role: 'editor' } as TeamMember;
112
- return next();
113
- }
114
- return res.status(401).json({ error: 'Bearer token required' });
115
- }
116
-
117
- const token = authHeader.slice(7);
118
- const member = authenticateMember(token);
119
- if (!member) {
120
- return res.status(403).json({ error: 'Invalid token' });
121
- }
122
-
123
- req.teamMember = member;
124
- next();
125
- };
126
- }