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,165 +0,0 @@
1
- // Federation: Sharing Control
2
- // 노드별 공유 범위 관리 — 태그/폴더/문서 단위로 공개/비공개 설정
3
-
4
- import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
5
- import { join } from 'node:path';
6
- import { homedir } from 'node:os';
7
-
8
- export interface SharingConfig {
9
- mode: 'whitelist' | 'blacklist'; // whitelist=명시적 공개만, blacklist=명시적 비공개만
10
-
11
- // 태그 기반
12
- allowedTags: string[]; // whitelist 모드: 이 태그가 있는 문서만 공개
13
- blockedTags: string[]; // blacklist 모드: 이 태그가 있는 문서 제외
14
-
15
- // 폴더 기반
16
- allowedFolders: string[]; // whitelist 모드: 이 폴더만 공개
17
- blockedFolders: string[]; // blacklist 모드: 이 폴더 제외
18
-
19
- // 문서 단위
20
- blockedDocIds: string[]; // 개별 문서 ID 차단 (둘 다 적용)
21
-
22
- // 콘텐츠 필터
23
- blockSensitivePatterns: boolean; // 이메일, 전화번호, API키 패턴 자동 감지→차단
24
- }
25
-
26
- const SHARING_FILE = join(homedir(), '.stellavault', 'federation', 'sharing.json');
27
-
28
- const DEFAULT_CONFIG: SharingConfig = {
29
- mode: 'blacklist',
30
- allowedTags: [],
31
- blockedTags: ['personal', 'private', 'secret', 'diary', 'salary', 'password', 'credential'],
32
- allowedFolders: [],
33
- blockedFolders: ['03_Daily', '06_Archive', '.obsidian'],
34
- blockedDocIds: [],
35
- blockSensitivePatterns: true,
36
- };
37
-
38
- // 민감 패턴
39
- const SENSITIVE_PATTERNS = [
40
- /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/, // 이메일
41
- /\b\d{3}[-.]?\d{4}[-.]?\d{4}\b/, // 전화번호
42
- /\b(sk-|pk-|api[_-]?key|token|secret)[a-zA-Z0-9_-]{10,}\b/i, // API 키
43
- /\bpassword\s*[:=]\s*\S+/i, // password=xxx
44
- /\b\d{6}[-]\d{7}\b/, // 주민번호 패턴
45
- ];
46
-
47
- export function loadSharingConfig(): SharingConfig {
48
- if (existsSync(SHARING_FILE)) {
49
- const raw = JSON.parse(readFileSync(SHARING_FILE, 'utf-8'));
50
- return { ...DEFAULT_CONFIG, ...raw };
51
- }
52
- return { ...DEFAULT_CONFIG };
53
- }
54
-
55
- export function saveSharingConfig(config: SharingConfig): void {
56
- mkdirSync(join(homedir(), '.stellavault', 'federation'), { recursive: true });
57
- writeFileSync(SHARING_FILE, JSON.stringify(config, null, 2), 'utf-8');
58
- }
59
-
60
- // 문서가 공유 가능한지 확인
61
- export function isDocumentShareable(
62
- doc: { tags: string[]; filePath: string; id: string; content: string },
63
- config?: SharingConfig,
64
- ): boolean {
65
- const cfg = config ?? loadSharingConfig();
66
-
67
- // 1. 개별 차단 확인
68
- if (cfg.blockedDocIds.includes(doc.id)) return false;
69
-
70
- // 2. 폴더 기반 필터
71
- const folder = doc.filePath.split('/')[0] ?? '';
72
- if (cfg.mode === 'whitelist') {
73
- if (cfg.allowedFolders.length > 0 && !cfg.allowedFolders.some(f => doc.filePath.startsWith(f))) {
74
- return false;
75
- }
76
- } else {
77
- if (cfg.blockedFolders.some(f => doc.filePath.startsWith(f))) {
78
- return false;
79
- }
80
- }
81
-
82
- // 3. 태그 기반 필터
83
- const docTags = doc.tags.map(t => t.toLowerCase());
84
- if (cfg.mode === 'whitelist') {
85
- if (cfg.allowedTags.length > 0 && !cfg.allowedTags.some(t => docTags.includes(t.toLowerCase()))) {
86
- return false;
87
- }
88
- } else {
89
- if (cfg.blockedTags.some(t => docTags.includes(t.toLowerCase()))) {
90
- return false;
91
- }
92
- }
93
-
94
- // 4. 민감 패턴 감지
95
- if (cfg.blockSensitivePatterns) {
96
- for (const pattern of SENSITIVE_PATTERNS) {
97
- if (pattern.test(doc.content)) return false;
98
- }
99
- }
100
-
101
- return true;
102
- }
103
-
104
- // 스니펫에서 민감 정보 제거
105
- export function sanitizeSnippet(snippet: string): string {
106
- let safe = snippet;
107
- for (const pattern of SENSITIVE_PATTERNS) {
108
- safe = safe.replace(pattern, '[REDACTED]');
109
- }
110
- return safe;
111
- }
112
-
113
- // CLI 헬퍼: 현재 공유 설정 요약
114
- export function getSharingSummary(config?: SharingConfig): string {
115
- const cfg = config ?? loadSharingConfig();
116
- const lines: string[] = [];
117
- lines.push(`Mode: ${cfg.mode}`);
118
- if (cfg.mode === 'blacklist') {
119
- lines.push(`Blocked tags: ${cfg.blockedTags.join(', ') || 'none'}`);
120
- lines.push(`Blocked folders: ${cfg.blockedFolders.join(', ') || 'none'}`);
121
- } else {
122
- lines.push(`Allowed tags: ${cfg.allowedTags.join(', ') || 'all'}`);
123
- lines.push(`Allowed folders: ${cfg.allowedFolders.join(', ') || 'all'}`);
124
- }
125
- lines.push(`Blocked docs: ${cfg.blockedDocIds.length}`);
126
- lines.push(`Sensitive pattern filter: ${cfg.blockSensitivePatterns ? 'ON' : 'OFF'}`);
127
- return lines.join('\n');
128
- }
129
-
130
- // 태그 추가/제거 헬퍼
131
- export function addBlockedTag(tag: string): void {
132
- const cfg = loadSharingConfig();
133
- if (!cfg.blockedTags.includes(tag.toLowerCase())) {
134
- cfg.blockedTags.push(tag.toLowerCase());
135
- saveSharingConfig(cfg);
136
- }
137
- }
138
-
139
- export function removeBlockedTag(tag: string): void {
140
- const cfg = loadSharingConfig();
141
- cfg.blockedTags = cfg.blockedTags.filter(t => t !== tag.toLowerCase());
142
- saveSharingConfig(cfg);
143
- }
144
-
145
- export function addBlockedFolder(folder: string): void {
146
- const cfg = loadSharingConfig();
147
- if (!cfg.blockedFolders.includes(folder)) {
148
- cfg.blockedFolders.push(folder);
149
- saveSharingConfig(cfg);
150
- }
151
- }
152
-
153
- export function blockDocument(docId: string): void {
154
- const cfg = loadSharingConfig();
155
- if (!cfg.blockedDocIds.includes(docId)) {
156
- cfg.blockedDocIds.push(docId);
157
- saveSharingConfig(cfg);
158
- }
159
- }
160
-
161
- export function unblockDocument(docId: string): void {
162
- const cfg = loadSharingConfig();
163
- cfg.blockedDocIds = cfg.blockedDocIds.filter(id => id !== docId);
164
- saveSharingConfig(cfg);
165
- }
@@ -1,76 +0,0 @@
1
- // Federation Phase 2: Web of Trust
2
- // vouch/revoke/block — 노드 간 상호 신뢰 관리
3
-
4
- import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
5
- import { join } from 'node:path';
6
- import { homedir } from 'node:os';
7
-
8
- export interface TrustEntry {
9
- peerId: string;
10
- displayName: string;
11
- level: 'vouched' | 'neutral' | 'blocked';
12
- reason?: string;
13
- updatedAt: string;
14
- }
15
-
16
- const TRUST_FILE = join(homedir(), '.stellavault', 'federation', 'trust.json');
17
-
18
- function loadTrustDb(): Map<string, TrustEntry> {
19
- if (!existsSync(TRUST_FILE)) return new Map();
20
- const raw = JSON.parse(readFileSync(TRUST_FILE, 'utf-8')) as TrustEntry[];
21
- return new Map(raw.map(e => [e.peerId, e]));
22
- }
23
-
24
- function saveTrustDb(db: Map<string, TrustEntry>): void {
25
- mkdirSync(join(homedir(), '.stellavault', 'federation'), { recursive: true });
26
- writeFileSync(TRUST_FILE, JSON.stringify([...db.values()], null, 2), 'utf-8');
27
- }
28
-
29
- export function vouch(peerId: string, displayName: string, reason?: string): TrustEntry {
30
- const db = loadTrustDb();
31
- const entry: TrustEntry = { peerId, displayName, level: 'vouched', reason, updatedAt: new Date().toISOString() };
32
- db.set(peerId, entry);
33
- saveTrustDb(db);
34
- return entry;
35
- }
36
-
37
- export function revoke(peerId: string): boolean {
38
- const db = loadTrustDb();
39
- const entry = db.get(peerId);
40
- if (!entry) return false;
41
- entry.level = 'neutral';
42
- entry.updatedAt = new Date().toISOString();
43
- saveTrustDb(db);
44
- return true;
45
- }
46
-
47
- export function block(peerId: string, displayName: string, reason?: string): TrustEntry {
48
- const db = loadTrustDb();
49
- const entry: TrustEntry = { peerId, displayName, level: 'blocked', reason, updatedAt: new Date().toISOString() };
50
- db.set(peerId, entry);
51
- saveTrustDb(db);
52
- return entry;
53
- }
54
-
55
- export function getTrustLevel(peerId: string): TrustEntry['level'] {
56
- const db = loadTrustDb();
57
- return db.get(peerId)?.level ?? 'neutral';
58
- }
59
-
60
- export function isBlocked(peerId: string): boolean {
61
- return getTrustLevel(peerId) === 'blocked';
62
- }
63
-
64
- export function listTrusted(): TrustEntry[] {
65
- return [...loadTrustDb().values()];
66
- }
67
-
68
- // 신뢰 점수 계산 (0-100)
69
- export function computeTrustScore(peerId: string): number {
70
- const level = getTrustLevel(peerId);
71
- switch (level) {
72
- case 'vouched': return 80;
73
- case 'neutral': return 50;
74
- case 'blocked': return 0;
75
- }
76
- }
@@ -1,25 +0,0 @@
1
- // Design Ref: §2.2 — Federation 공유 타입 정의
2
-
3
- export interface PeerInfo {
4
- peerId: string;
5
- displayName: string;
6
- documentCount: number;
7
- topTopics: string[];
8
- joinedAt: string;
9
- lastSeen: string;
10
- }
11
-
12
- export interface FederatedSearchResult {
13
- title: string;
14
- similarity: number;
15
- snippet: string; // 원문 첫 50자
16
- peerId: string;
17
- peerName: string;
18
- }
19
-
20
- // Design Ref: §7 — 메시지 프로토콜 (JSON + newline delimiter)
21
- export type FederationMessage =
22
- | { type: 'handshake'; peerId: string; displayName: string; version: string; documentCount: number; topTopics: string[] }
23
- | { type: 'search_query'; queryId: string; embedding: number[]; limit: number }
24
- | { type: 'search_result'; queryId: string; results: Array<{ title: string; similarity: number; snippet: string }> }
25
- | { type: 'leave'; peerId: string };
@@ -1,85 +0,0 @@
1
- // i18n Foundation (F-A19)
2
- // Simple string externalization for CLI and Graph UI
3
-
4
- export type Locale = 'en' | 'ko' | 'ja' | 'zh';
5
-
6
- const strings: Record<Locale, Record<string, string>> = {
7
- en: {
8
- 'init.welcome': 'Stellavault Setup Wizard',
9
- 'init.tagline': "Notes die in folders. Let's bring yours to life.",
10
- 'init.step1': 'Where is your Obsidian vault?',
11
- 'init.step2': 'Indexing your vault',
12
- 'init.step3': 'Try your first search',
13
- 'init.done': 'Setup complete!',
14
- 'index.complete': 'Indexing complete',
15
- 'search.no_results': 'No results found.',
16
- 'decay.report_title': 'Knowledge Decay Report',
17
- 'decay.tip': 'Search a topic to refresh decaying knowledge',
18
- 'learn.title': 'Your Learning Path',
19
- 'learn.all_clear': 'All clear! Your knowledge is in great shape.',
20
- 'contradictions.title': 'potential contradictions found',
21
- 'contradictions.none': 'No contradictions detected. Your knowledge is consistent!',
22
- 'graph.title': 'Stellavault',
23
- 'graph.subtitle': 'Neural Knowledge Graph',
24
- 'error.vault_not_found': 'Vault not found',
25
- 'error.db_init_failed': 'Database initialization failed',
26
- 'error.embedder_failed': 'Embedding model failed to load',
27
- },
28
- ko: {
29
- 'init.welcome': 'Stellavault 설정 마법사',
30
- 'init.tagline': '노트는 폴더에서 죽습니다. 당신의 지식을 살려봅시다.',
31
- 'init.step1': 'Obsidian vault 경로가 어디인가요?',
32
- 'init.step2': 'vault 인덱싱 중',
33
- 'init.step3': '첫 번째 검색을 해보세요',
34
- 'init.done': '설정 완료!',
35
- 'index.complete': '인덱싱 완료',
36
- 'search.no_results': '검색 결과가 없습니다.',
37
- 'decay.report_title': '지식 감쇠 리포트',
38
- 'decay.tip': '검색하면 감쇠 중인 지식이 리프레시됩니다',
39
- 'learn.title': '당신의 학습 경로',
40
- 'learn.all_clear': '모든 지식이 건강합니다!',
41
- 'contradictions.title': '개의 잠재적 모순 발견',
42
- 'contradictions.none': '모순이 없습니다. 지식이 일관됩니다!',
43
- 'graph.title': 'Stellavault',
44
- 'graph.subtitle': '뉴럴 지식 그래프',
45
- 'error.vault_not_found': 'vault를 찾을 수 없습니다',
46
- 'error.db_init_failed': '데이터베이스 초기화 실패',
47
- 'error.embedder_failed': '임베딩 모델 로딩 실패',
48
- },
49
- ja: {
50
- 'init.welcome': 'Stellavault セットアップウィザード',
51
- 'init.tagline': 'ノートはフォルダで死にます。あなたの知識を生かしましょう。',
52
- 'graph.title': 'Stellavault',
53
- 'graph.subtitle': 'ニューラルナレッジグラフ',
54
- 'search.no_results': '検索結果がありません。',
55
- },
56
- zh: {
57
- 'init.welcome': 'Stellavault 设置向导',
58
- 'init.tagline': '笔记在文件夹中消亡。让你的知识活起来。',
59
- 'graph.title': 'Stellavault',
60
- 'graph.subtitle': '神经知识图谱',
61
- 'search.no_results': '没有搜索结果。',
62
- },
63
- };
64
-
65
- let currentLocale: Locale = 'en';
66
-
67
- export function setLocale(locale: Locale): void {
68
- currentLocale = locale;
69
- }
70
-
71
- export function getLocale(): Locale {
72
- return currentLocale;
73
- }
74
-
75
- export function t(key: string, fallback?: string): string {
76
- return strings[currentLocale]?.[key] ?? strings.en[key] ?? fallback ?? key;
77
- }
78
-
79
- export function detectLocale(): Locale {
80
- const env = process.env.LANG || process.env.LANGUAGE || process.env.LC_ALL || '';
81
- if (env.startsWith('ko')) return 'ko';
82
- if (env.startsWith('ja')) return 'ja';
83
- if (env.startsWith('zh')) return 'zh';
84
- return 'en';
85
- }
@@ -1,180 +0,0 @@
1
- // Design Ref: §6.1 — Chunking Strategy (heading 기반 + 오버랩)
2
-
3
- import type { Chunk } from '../types/chunk.js';
4
-
5
- export interface ChunkOptions {
6
- maxTokens: number; // default: 300
7
- overlap: number; // default: 50
8
- minTokens: number; // default: 50
9
- }
10
-
11
- const DEFAULT_OPTIONS: ChunkOptions = {
12
- maxTokens: 300,
13
- overlap: 50,
14
- minTokens: 50,
15
- };
16
-
17
- /**
18
- * 문서를 heading 기반으로 청킹합니다.
19
- * Step 1: heading 분할 → Step 2: 길이 검사 → Step 3: 메타데이터 → Step 4: 짧은 청크 병합
20
- */
21
- export function chunkDocument(
22
- documentId: string,
23
- content: string,
24
- options: Partial<ChunkOptions> = {},
25
- ): Chunk[] {
26
- const opts = { ...DEFAULT_OPTIONS, ...options };
27
- const lines = content.split('\n');
28
-
29
- // Step 1: heading 기반 섹션 분할
30
- const sections = splitByHeadings(lines);
31
-
32
- // Step 2-3: 길이 검사 + 메타데이터
33
- const rawChunks: Chunk[] = [];
34
- for (const section of sections) {
35
- const tokenCount = estimateTokens(section.content);
36
-
37
- if (tokenCount <= opts.maxTokens) {
38
- rawChunks.push(makeChunk(documentId, rawChunks.length, section));
39
- } else {
40
- // 긴 섹션은 문장 단위로 재분할 + 오버랩
41
- const subChunks = splitByTokenLimit(section, opts.maxTokens, opts.overlap);
42
- for (const sub of subChunks) {
43
- rawChunks.push(makeChunk(documentId, rawChunks.length, sub));
44
- }
45
- }
46
- }
47
-
48
- // Step 4: 짧은 청크 병합
49
- return mergeShortChunks(rawChunks, opts.minTokens);
50
- }
51
-
52
- interface Section {
53
- heading: string;
54
- content: string;
55
- startLine: number;
56
- endLine: number;
57
- }
58
-
59
- function splitByHeadings(lines: string[]): Section[] {
60
- const sections: Section[] = [];
61
- let currentHeading = '';
62
- let currentLines: string[] = [];
63
- let startLine = 0;
64
-
65
- for (let i = 0; i < lines.length; i++) {
66
- const line = lines[i];
67
- if (/^#{1,6}\s/.test(line)) {
68
- if (currentLines.length > 0) {
69
- sections.push({
70
- heading: currentHeading,
71
- content: currentLines.join('\n').trim(),
72
- startLine,
73
- endLine: i - 1,
74
- });
75
- }
76
- currentHeading = line.replace(/^#{1,6}\s+/, '').trim();
77
- currentLines = [line];
78
- startLine = i;
79
- } else {
80
- currentLines.push(line);
81
- }
82
- }
83
-
84
- if (currentLines.length > 0) {
85
- sections.push({
86
- heading: currentHeading,
87
- content: currentLines.join('\n').trim(),
88
- startLine,
89
- endLine: lines.length - 1,
90
- });
91
- }
92
-
93
- return sections.filter(s => s.content.length > 0);
94
- }
95
-
96
- function splitByTokenLimit(section: Section, maxTokens: number, overlap: number): Section[] {
97
- const sentences = section.content.split(/(?<=[.!?。]\s)/);
98
- const results: Section[] = [];
99
- let current: string[] = [];
100
- let currentTokens = 0;
101
-
102
- for (const sentence of sentences) {
103
- const sentenceTokens = estimateTokens(sentence);
104
- if (currentTokens + sentenceTokens > maxTokens && current.length > 0) {
105
- results.push({
106
- heading: section.heading,
107
- content: current.join('').trim(),
108
- startLine: section.startLine,
109
- endLine: section.endLine,
110
- });
111
- // 오버랩: 마지막 문장들을 다음 청크에 포함
112
- const overlapText = getOverlapText(current, overlap);
113
- current = overlapText ? [overlapText, sentence] : [sentence];
114
- currentTokens = estimateTokens(current.join(''));
115
- } else {
116
- current.push(sentence);
117
- currentTokens += sentenceTokens;
118
- }
119
- }
120
-
121
- if (current.length > 0) {
122
- results.push({
123
- heading: section.heading,
124
- content: current.join('').trim(),
125
- startLine: section.startLine,
126
- endLine: section.endLine,
127
- });
128
- }
129
-
130
- return results;
131
- }
132
-
133
- function getOverlapText(sentences: string[], overlapTokens: number): string {
134
- let tokens = 0;
135
- const overlap: string[] = [];
136
- for (let i = sentences.length - 1; i >= 0; i--) {
137
- const t = estimateTokens(sentences[i]);
138
- if (tokens + t > overlapTokens) break;
139
- overlap.unshift(sentences[i]);
140
- tokens += t;
141
- }
142
- return overlap.join('');
143
- }
144
-
145
- function mergeShortChunks(chunks: Chunk[], minTokens: number): Chunk[] {
146
- if (chunks.length <= 1) return chunks;
147
- const result: Chunk[] = [];
148
-
149
- for (const chunk of chunks) {
150
- if (result.length > 0 && chunk.tokenCount < minTokens) {
151
- const prev = result[result.length - 1];
152
- prev.content += '\n\n' + chunk.content;
153
- prev.endLine = chunk.endLine;
154
- prev.tokenCount += chunk.tokenCount;
155
- } else {
156
- result.push({ ...chunk });
157
- }
158
- }
159
-
160
- return result;
161
- }
162
-
163
- function makeChunk(documentId: string, index: number, section: Section): Chunk {
164
- return {
165
- id: `${documentId}#${index}`,
166
- documentId,
167
- content: section.content,
168
- heading: section.heading,
169
- startLine: section.startLine,
170
- endLine: section.endLine,
171
- tokenCount: estimateTokens(section.content),
172
- };
173
- }
174
-
175
- /** 간단한 토큰 수 추정 (영어: ~4chars/token, 한국어: ~2chars/token) */
176
- export function estimateTokens(text: string): number {
177
- const koreanChars = (text.match(/[가-힣]/g) || []).length;
178
- const otherChars = text.length - koreanChars;
179
- return Math.ceil(koreanChars / 2 + otherChars / 4);
180
- }
@@ -1,9 +0,0 @@
1
- // Design Ref: §3.2 — 교체 가능 설계 (Embedder 인터페이스)
2
-
3
- export interface Embedder {
4
- initialize(): Promise<void>;
5
- embed(text: string): Promise<number[]>;
6
- embedBatch(texts: string[]): Promise<number[][]>;
7
- readonly dimensions: number;
8
- readonly modelName: string;
9
- }
@@ -1,113 +0,0 @@
1
- // Design Ref: §6.3 — Incremental Indexing + Pipeline
2
-
3
- import type { Embedder } from './embedder.js';
4
- import type { VectorStore } from '../store/types.js';
5
- import type { Document } from '../types/document.js';
6
- import type { Chunk } from '../types/chunk.js';
7
- import { scanVault } from './scanner.js';
8
- import { chunkDocument, type ChunkOptions } from './chunker.js';
9
- import { withRetry, errors } from '../utils/retry.js';
10
-
11
- export { type Embedder } from './embedder.js';
12
- export { createLocalEmbedder } from './local-embedder.js';
13
- export { scanVault } from './scanner.js';
14
- export { chunkDocument, estimateTokens } from './chunker.js';
15
- export { createWatcher } from './watcher.js';
16
-
17
- export interface IndexerOptions {
18
- store: VectorStore;
19
- embedder: Embedder;
20
- chunkOptions?: Partial<ChunkOptions>;
21
- onProgress?: (current: number, total: number, doc: Document) => void;
22
- }
23
-
24
- export interface IndexResult {
25
- indexed: number;
26
- skipped: number;
27
- deleted: number;
28
- failed: number;
29
- totalChunks: number;
30
- elapsedMs: number;
31
- }
32
-
33
- /**
34
- * vault를 스캔하여 변경된 문서만 벡터화하는 증분 인덱서
35
- */
36
- export async function indexVault(
37
- vaultPath: string,
38
- options: IndexerOptions,
39
- ): Promise<IndexResult> {
40
- const start = Date.now();
41
- const { store, embedder, chunkOptions, onProgress } = options;
42
-
43
- // 1. 스캔
44
- const { documents } = scanVault(vaultPath);
45
-
46
- // 2. 기존 인덱스 상태 조회
47
- const existingDocs = await store.getAllDocuments();
48
- const existingMap = new Map(existingDocs.map(d => [d.id, d.contentHash]));
49
-
50
- let indexed = 0;
51
- let skipped = 0;
52
- let failed = 0;
53
- let totalChunks = 0;
54
-
55
- // 3. 증분 처리 (에러 복구 포함)
56
- const scannedIds = new Set<string>();
57
- for (let i = 0; i < documents.length; i++) {
58
- const doc = documents[i];
59
- scannedIds.add(doc.id);
60
- onProgress?.(i + 1, documents.length, doc);
61
-
62
- // content_hash 비교 → 변경 없으면 SKIP
63
- if (existingMap.get(doc.id) === doc.contentHash) {
64
- skipped++;
65
- continue;
66
- }
67
-
68
- try {
69
- // 청킹
70
- const chunks = chunkDocument(doc.id, doc.content, chunkOptions);
71
-
72
- // 임베딩 (retry with backoff)
73
- const texts = chunks.map(c => c.content);
74
- const embeddings = await withRetry(
75
- () => embedder.embedBatch(texts),
76
- { maxRetries: 2, baseDelayMs: 1000 },
77
- );
78
- const chunksWithEmbeddings: Chunk[] = chunks.map((c, j) => ({
79
- ...c,
80
- embedding: embeddings[j],
81
- }));
82
-
83
- // 저장 (document → chunks)
84
- await store.upsertDocument(doc);
85
- await store.upsertChunks(chunksWithEmbeddings);
86
-
87
- indexed++;
88
- totalChunks += chunks.length;
89
- } catch (err) {
90
- // Graceful degradation: skip failed file, continue with rest
91
- failed++;
92
- console.error(errors.indexingFailed(doc.filePath, err).format());
93
- }
94
- }
95
-
96
- // 4. 삭제된 파일 처리
97
- let deleted = 0;
98
- for (const [existingId] of existingMap) {
99
- if (!scannedIds.has(existingId)) {
100
- await store.deleteByDocumentId(existingId);
101
- deleted++;
102
- }
103
- }
104
-
105
- return {
106
- indexed,
107
- skipped,
108
- deleted,
109
- failed,
110
- totalChunks,
111
- elapsedMs: Date.now() - start,
112
- };
113
- }
@@ -1,35 +0,0 @@
1
- // Design Ref: §3.2 — Embedder 로컬 구현 (nomic-embed-text via @xenova/transformers)
2
-
3
- import type { Embedder } from './embedder.js';
4
-
5
- export function createLocalEmbedder(modelName: string = 'nomic-embed-text-v1.5'): Embedder {
6
- let pipeline: any;
7
- // all-MiniLM-L6-v2: 384, nomic-embed-text: 768
8
- let dims = modelName.includes('MiniLM') ? 384 : 768;
9
-
10
- return {
11
- async initialize() {
12
- const { pipeline: createPipeline } = await import('@xenova/transformers');
13
- pipeline = await createPipeline('feature-extraction', `Xenova/${modelName}`, {
14
- quantized: true,
15
- });
16
- },
17
-
18
- async embed(text: string): Promise<number[]> {
19
- const output = await pipeline(text, { pooling: 'mean', normalize: true });
20
- return Array.from(output.data as Float32Array).slice(0, dims);
21
- },
22
-
23
- async embedBatch(texts: string[]): Promise<number[][]> {
24
- const results: number[][] = [];
25
- // 순차 처리 (메모리 절약)
26
- for (const text of texts) {
27
- results.push(await this.embed(text));
28
- }
29
- return results;
30
- },
31
-
32
- get dimensions() { return dims; },
33
- get modelName() { return modelName; },
34
- };
35
- }