toolnet-memory 0.2.1 → 0.2.3

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 (342) hide show
  1. package/README.md +55 -28
  2. package/bin/toolnet-memory +55 -55
  3. package/bundle/agy.js +88 -0
  4. package/bundle/codex.js +92 -0
  5. package/bundle/context-runtime.js +56 -0
  6. package/bundle/context.js +62 -0
  7. package/bundle/doctor.js +3 -0
  8. package/bundle/full-index.js +8 -0
  9. package/bundle/learner.js +8 -0
  10. package/bundle/mcp.js +7 -0
  11. package/bundle/opencode.js +314 -0
  12. package/bundle/project-manual.js +54 -0
  13. package/bundle/setup.js +31 -0
  14. package/bundle/snapshot.js +4 -0
  15. package/bundle/work-continuity.js +12 -0
  16. package/package.json +9 -6
  17. package/dist/packages/cli/commands.js +0 -1
  18. package/dist/packages/cli/index.js +0 -1
  19. package/dist/packages/sdk/client.js +0 -78
  20. package/dist/packages/sdk/index.js +0 -1
  21. package/dist/packages/sdk/types.js +0 -1
  22. package/dist/src/api/index.js +0 -1
  23. package/dist/src/api/routes/health.js +0 -1
  24. package/dist/src/api/routes/index.js +0 -1
  25. package/dist/src/api/routes/memory.js +0 -1
  26. package/dist/src/api/routes/projects.js +0 -1
  27. package/dist/src/api/routes/search.js +0 -1
  28. package/dist/src/api/server.js +0 -1
  29. package/dist/src/capture/activity-capture.js +0 -21
  30. package/dist/src/capture/command-capture.js +0 -12
  31. package/dist/src/capture/error-capture.js +0 -14
  32. package/dist/src/capture/event-deduplicator.js +0 -28
  33. package/dist/src/capture/event-queue.js +0 -20
  34. package/dist/src/capture/file-capture.js +0 -23
  35. package/dist/src/capture/index.js +0 -8
  36. package/dist/src/capture/session-capture.js +0 -18
  37. package/dist/src/capture/tool-capture.js +0 -13
  38. package/dist/src/code-intelligence/analysis/analysis-engine.js +0 -26
  39. package/dist/src/code-intelligence/analysis/dead-code-analyzer.js +0 -127
  40. package/dist/src/code-intelligence/analysis/dependency-analyzer.js +0 -66
  41. package/dist/src/code-intelligence/analysis/index.js +0 -4
  42. package/dist/src/code-intelligence/analysis/types.js +0 -1
  43. package/dist/src/code-intelligence/architecture/architecture-engine.js +0 -48
  44. package/dist/src/code-intelligence/architecture/clusters.js +0 -322
  45. package/dist/src/code-intelligence/architecture/entry-points.js +0 -150
  46. package/dist/src/code-intelligence/architecture/hotspots.js +0 -136
  47. package/dist/src/code-intelligence/architecture/index.js +0 -6
  48. package/dist/src/code-intelligence/architecture/layers.js +0 -197
  49. package/dist/src/code-intelligence/architecture/types.js +0 -1
  50. package/dist/src/code-intelligence/chunks/index.js +0 -2
  51. package/dist/src/code-intelligence/chunks/smart-chunker.js +0 -125
  52. package/dist/src/code-intelligence/chunks/types.js +0 -1
  53. package/dist/src/code-intelligence/git/git-diff.js +0 -109
  54. package/dist/src/code-intelligence/git/index.js +0 -1
  55. package/dist/src/code-intelligence/graph/architecture.js +0 -26
  56. package/dist/src/code-intelligence/graph/graph-builder.js +0 -213
  57. package/dist/src/code-intelligence/graph/graph-store.js +0 -57
  58. package/dist/src/code-intelligence/graph/index.js +0 -1
  59. package/dist/src/code-intelligence/graph/relationships.js +0 -1
  60. package/dist/src/code-intelligence/graph/trace.js +0 -65
  61. package/dist/src/code-intelligence/impact/blast-radius.js +0 -160
  62. package/dist/src/code-intelligence/impact/change-mapper.js +0 -69
  63. package/dist/src/code-intelligence/impact/edit-tool-detector.js +0 -92
  64. package/dist/src/code-intelligence/impact/impact-analyzer.js +0 -60
  65. package/dist/src/code-intelligence/impact/impact-guard.js +0 -33
  66. package/dist/src/code-intelligence/impact/index.js +0 -5
  67. package/dist/src/code-intelligence/incremental/file-hash.js +0 -8
  68. package/dist/src/code-intelligence/incremental/incremental-indexer.js +0 -106
  69. package/dist/src/code-intelligence/incremental/manifest-builder.js +0 -19
  70. package/dist/src/code-intelligence/incremental/manifest.js +0 -31
  71. package/dist/src/code-intelligence/index.js +0 -23
  72. package/dist/src/code-intelligence/indexer/file-watcher.js +0 -1
  73. package/dist/src/code-intelligence/indexer/incremental-indexer.js +0 -1
  74. package/dist/src/code-intelligence/indexer/index.js +0 -1
  75. package/dist/src/code-intelligence/indexer/repository-indexer.js +0 -31
  76. package/dist/src/code-intelligence/indexer/repository-scanner.js +0 -50
  77. package/dist/src/code-intelligence/parsers/index.js +0 -1
  78. package/dist/src/code-intelligence/parsers/tree-sitter/index.js +0 -1
  79. package/dist/src/code-intelligence/parsers/tree-sitter/languages.js +0 -1
  80. package/dist/src/code-intelligence/parsers/tree-sitter/parser.js +0 -1
  81. package/dist/src/code-intelligence/parsers/typescript-parser.js +0 -190
  82. package/dist/src/code-intelligence/query/graph-query-engine.js +0 -275
  83. package/dist/src/code-intelligence/query/index.js +0 -2
  84. package/dist/src/code-intelligence/query/types.js +0 -1
  85. package/dist/src/code-intelligence/resolution/index.js +0 -2
  86. package/dist/src/code-intelligence/resolution/types.js +0 -1
  87. package/dist/src/code-intelligence/resolution/typescript-resolver.js +0 -316
  88. package/dist/src/code-intelligence/rich/index.js +0 -1
  89. package/dist/src/code-intelligence/rich/rich-graph-enricher.js +0 -463
  90. package/dist/src/code-intelligence/semantic/index.js +0 -2
  91. package/dist/src/code-intelligence/semantic/semantic-code-engine.js +0 -213
  92. package/dist/src/code-intelligence/semantic/source-priority.js +0 -22
  93. package/dist/src/code-intelligence/symbols/index.js +0 -1
  94. package/dist/src/code-intelligence/symbols/reference-resolver.js +0 -21
  95. package/dist/src/code-intelligence/symbols/symbol-extractor.js +0 -1
  96. package/dist/src/code-intelligence/test-analysis.js +0 -72
  97. package/dist/src/code-intelligence/test-architecture.js +0 -67
  98. package/dist/src/code-intelligence/test-impact.js +0 -47
  99. package/dist/src/code-intelligence/test-incremental.js +0 -24
  100. package/dist/src/code-intelligence/test-index.js +0 -39
  101. package/dist/src/code-intelligence/test-resolution.js +0 -54
  102. package/dist/src/code-intelligence/test-rich-graph.js +0 -48
  103. package/dist/src/code-intelligence/test-semantic.js +0 -57
  104. package/dist/src/code-intelligence/test-visualization.js +0 -36
  105. package/dist/src/code-intelligence/types.js +0 -1
  106. package/dist/src/code-intelligence/visualization/index.js +0 -2
  107. package/dist/src/code-intelligence/visualization/types.js +0 -1
  108. package/dist/src/code-intelligence/visualization/visualization-builder.js +0 -104
  109. package/dist/src/core/config.js +0 -66
  110. package/dist/src/core/global-env.js +0 -70
  111. package/dist/src/core/importance.js +0 -30
  112. package/dist/src/core/index.js +0 -5
  113. package/dist/src/core/memory-engine.js +0 -183
  114. package/dist/src/core/project-manager.js +0 -243
  115. package/dist/src/core/types.js +0 -1
  116. package/dist/src/embeddings/batch-embedder.js +0 -1
  117. package/dist/src/embeddings/cache.js +0 -1
  118. package/dist/src/embeddings/embedder.js +0 -51
  119. package/dist/src/embeddings/index.js +0 -4
  120. package/dist/src/embeddings/local.js +0 -37
  121. package/dist/src/embeddings/provider.js +0 -1
  122. package/dist/src/embeddings/remote.js +0 -76
  123. package/dist/src/embeddings/test-connection.js +0 -16
  124. package/dist/src/hooks/after-edit.js +0 -3
  125. package/dist/src/hooks/after-tool.js +0 -3
  126. package/dist/src/hooks/auto-context.js +0 -68
  127. package/dist/src/hooks/auto-impact-guard.js +0 -94
  128. package/dist/src/hooks/auto-retrieval.js +0 -27
  129. package/dist/src/hooks/before-agent.js +0 -18
  130. package/dist/src/hooks/before-compact.js +0 -3
  131. package/dist/src/hooks/before-edit.js +0 -20
  132. package/dist/src/hooks/index.js +0 -11
  133. package/dist/src/hooks/runtime.js +0 -110
  134. package/dist/src/hooks/session-end.js +0 -3
  135. package/dist/src/hooks/session-start.js +0 -3
  136. package/dist/src/index.js +0 -22
  137. package/dist/src/mcp/bootstrap.js +0 -68
  138. package/dist/src/mcp/context.js +0 -1
  139. package/dist/src/mcp/index.js +0 -3
  140. package/dist/src/mcp/server.js +0 -45
  141. package/dist/src/mcp/tools/analyze-impact.js +0 -41
  142. package/dist/src/mcp/tools/dead-code.js +0 -55
  143. package/dist/src/mcp/tools/find-callers.js +0 -24
  144. package/dist/src/mcp/tools/find-dependencies.js +0 -57
  145. package/dist/src/mcp/tools/find-symbol.js +0 -7
  146. package/dist/src/mcp/tools/get-architecture.js +0 -11
  147. package/dist/src/mcp/tools/graph-dependents.js +0 -24
  148. package/dist/src/mcp/tools/graph-neighborhood.js +0 -58
  149. package/dist/src/mcp/tools/graph-path.js +0 -43
  150. package/dist/src/mcp/tools/graph-query-utils.js +0 -32
  151. package/dist/src/mcp/tools/impact-guard.js +0 -34
  152. package/dist/src/mcp/tools/index-repository.js +0 -1
  153. package/dist/src/mcp/tools/index.js +0 -20
  154. package/dist/src/mcp/tools/memory-decisions.js +0 -1
  155. package/dist/src/mcp/tools/memory-forget.js +0 -14
  156. package/dist/src/mcp/tools/memory-recent.js +0 -1
  157. package/dist/src/mcp/tools/memory-remember.js +0 -33
  158. package/dist/src/mcp/tools/memory-rules.js +0 -1
  159. package/dist/src/mcp/tools/memory-search.js +0 -18
  160. package/dist/src/mcp/tools/memory-todos.js +0 -1
  161. package/dist/src/mcp/tools/project-context.js +0 -25
  162. package/dist/src/mcp/tools/search-code.js +0 -21
  163. package/dist/src/mcp/tools/semantic-code-search.js +0 -33
  164. package/dist/src/mcp/tools/snapshot-create.js +0 -13
  165. package/dist/src/mcp/tools/snapshot-list.js +0 -7
  166. package/dist/src/mcp/tools/snapshot-restore.js +0 -13
  167. package/dist/src/mcp/tools/trace-calls.js +0 -37
  168. package/dist/src/memory/activity.js +0 -5
  169. package/dist/src/memory/conflict-detector.js +0 -105
  170. package/dist/src/memory/consolidator.js +0 -104
  171. package/dist/src/memory/decay.js +0 -59
  172. package/dist/src/memory/decisions.js +0 -3
  173. package/dist/src/memory/deduplicate.js +0 -25
  174. package/dist/src/memory/index.js +0 -11
  175. package/dist/src/memory/maintenance.js +0 -16
  176. package/dist/src/memory/remember.js +0 -3
  177. package/dist/src/memory/rules.js +0 -3
  178. package/dist/src/memory/search.js +0 -3
  179. package/dist/src/memory/summaries.js +0 -1
  180. package/dist/src/memory/todos.js +0 -3
  181. package/dist/src/processor/decision-extractor.js +0 -13
  182. package/dist/src/processor/importance-scorer.js +0 -22
  183. package/dist/src/processor/index.js +0 -7
  184. package/dist/src/processor/memory-extractor.js +0 -59
  185. package/dist/src/processor/memory-processor.js +0 -105
  186. package/dist/src/processor/rule-extractor.js +0 -13
  187. package/dist/src/processor/summarizer.js +0 -71
  188. package/dist/src/processor/todo-extractor.js +0 -12
  189. package/dist/src/production/config-check.js +0 -34
  190. package/dist/src/production/doctor.js +0 -58
  191. package/dist/src/production/full-index.js +0 -114
  192. package/dist/src/production/health.js +0 -58
  193. package/dist/src/production/index-pipeline.js +0 -151
  194. package/dist/src/production/index.js +0 -4
  195. package/dist/src/production/project-lock.js +0 -95
  196. package/dist/src/production/project-status.js +0 -16
  197. package/dist/src/production/recovery.js +0 -15
  198. package/dist/src/production/setup.js +0 -219
  199. package/dist/src/production/snapshot-cli.js +0 -58
  200. package/dist/src/project-manual/cli.js +0 -77
  201. package/dist/src/project-manual/index.js +0 -2
  202. package/dist/src/project-manual/manager.js +0 -147
  203. package/dist/src/project-manual/types.js +0 -1
  204. package/dist/src/retrieval/bm25/index.js +0 -1
  205. package/dist/src/retrieval/bm25/search.js +0 -1
  206. package/dist/src/retrieval/bm25.js +0 -30
  207. package/dist/src/retrieval/context-budget.js +0 -1
  208. package/dist/src/retrieval/context-builder.js +0 -22
  209. package/dist/src/retrieval/graph/index.js +0 -1
  210. package/dist/src/retrieval/graph/search.js +0 -1
  211. package/dist/src/retrieval/hybrid/hybrid-search.js +0 -1
  212. package/dist/src/retrieval/hybrid/index.js +0 -1
  213. package/dist/src/retrieval/hybrid-search.js +0 -68
  214. package/dist/src/retrieval/importance.js +0 -16
  215. package/dist/src/retrieval/index.js +0 -12
  216. package/dist/src/retrieval/query-analyzer.js +0 -32
  217. package/dist/src/retrieval/query-classifier.js +0 -1
  218. package/dist/src/retrieval/query-expansion.js +0 -1
  219. package/dist/src/retrieval/recency.js +0 -12
  220. package/dist/src/retrieval/reranker/index.js +0 -1
  221. package/dist/src/retrieval/reranker/reranker.js +0 -1
  222. package/dist/src/retrieval/retrieval-engine.js +0 -17
  223. package/dist/src/retrieval/tokenizer.js +0 -9
  224. package/dist/src/retrieval/type-priority.js +0 -10
  225. package/dist/src/retrieval/types.js +0 -1
  226. package/dist/src/retrieval/vector/index.js +0 -4
  227. package/dist/src/retrieval/vector/metadata-filter.js +0 -1
  228. package/dist/src/retrieval/vector/persistence.js +0 -67
  229. package/dist/src/retrieval/vector/search.js +0 -12
  230. package/dist/src/retrieval/vector/test-persistence.js +0 -36
  231. package/dist/src/retrieval/vector/upsert.js +0 -40
  232. package/dist/src/retrieval/vector/vector-store.js +0 -89
  233. package/dist/src/retrieval/vector-hybrid-engine.js +0 -91
  234. package/dist/src/runtime/bootstrap.js +0 -28
  235. package/dist/src/runtime/graceful.js +0 -17
  236. package/dist/src/runtime/index.js +0 -3
  237. package/dist/src/runtime/toolnet-memory-runtime.js +0 -156
  238. package/dist/src/security/encryption.js +0 -1
  239. package/dist/src/security/file-filter.js +0 -30
  240. package/dist/src/security/index.js +0 -3
  241. package/dist/src/security/sanitizer.js +0 -49
  242. package/dist/src/security/secret-scanner.js +0 -56
  243. package/dist/src/session/agy/adapter.js +0 -159
  244. package/dist/src/session/agy/cli.js +0 -87
  245. package/dist/src/session/agy/hook-installer.js +0 -62
  246. package/dist/src/session/agy/hook.js +0 -167
  247. package/dist/src/session/agy/index.js +0 -5
  248. package/dist/src/session/agy/project-resolver.js +0 -27
  249. package/dist/src/session/agy/recovery.js +0 -112
  250. package/dist/src/session/agy/transcript.js +0 -191
  251. package/dist/src/session/codex/adapter.js +0 -138
  252. package/dist/src/session/codex/cli.js +0 -236
  253. package/dist/src/session/codex/context-hook-installer.js +0 -70
  254. package/dist/src/session/codex/context-hook.js +0 -69
  255. package/dist/src/session/codex/discovery.js +0 -138
  256. package/dist/src/session/codex/index.js +0 -6
  257. package/dist/src/session/codex/notify-installer.js +0 -135
  258. package/dist/src/session/codex/project-resolver.js +0 -25
  259. package/dist/src/session/codex/recovery.js +0 -27
  260. package/dist/src/session/codex/rollout.js +0 -186
  261. package/dist/src/session/core.js +0 -239
  262. package/dist/src/session/identity.js +0 -57
  263. package/dist/src/session/index.js +0 -9
  264. package/dist/src/session/learner/cli.js +0 -62
  265. package/dist/src/session/learner/extractor.js +0 -461
  266. package/dist/src/session/learner/index.js +0 -4
  267. package/dist/src/session/learner/journal.js +0 -159
  268. package/dist/src/session/learner/learner.js +0 -124
  269. package/dist/src/session/learner/types.js +0 -1
  270. package/dist/src/session/opencode/adapter.js +0 -553
  271. package/dist/src/session/opencode/cli.js +0 -121
  272. package/dist/src/session/opencode/index.js +0 -2
  273. package/dist/src/session/opencode/plugin-installer.js +0 -230
  274. package/dist/src/session/store.js +0 -242
  275. package/dist/src/session/types.js +0 -1
  276. package/dist/src/session/utils.js +0 -47
  277. package/dist/src/session/wal.js +0 -303
  278. package/dist/src/snapshot/index.js +0 -2
  279. package/dist/src/snapshot/manager.js +0 -130
  280. package/dist/src/snapshot/test-snapshot.js +0 -28
  281. package/dist/src/snapshot/types.js +0 -1
  282. package/dist/src/storage/architecture-store.js +0 -37
  283. package/dist/src/storage/cleanup-health.js +0 -20
  284. package/dist/src/storage/code-analysis-store.js +0 -35
  285. package/dist/src/storage/code-chunk-store.js +0 -25
  286. package/dist/src/storage/code-graph-store.js +0 -24
  287. package/dist/src/storage/code-manifest-store.js +0 -24
  288. package/dist/src/storage/code-vector-store.js +0 -25
  289. package/dist/src/storage/github/client.js +0 -1
  290. package/dist/src/storage/github/index.js +0 -1
  291. package/dist/src/storage/google-drive/client.js +0 -1
  292. package/dist/src/storage/google-drive/index.js +0 -1
  293. package/dist/src/storage/huggingface/client.js +0 -116
  294. package/dist/src/storage/huggingface/index.js +0 -1
  295. package/dist/src/storage/index.js +0 -16
  296. package/dist/src/storage/list-bucket-raw.js +0 -14
  297. package/dist/src/storage/list-bucket-tree.js +0 -38
  298. package/dist/src/storage/local/client.js +0 -99
  299. package/dist/src/storage/local/index.js +0 -1
  300. package/dist/src/storage/memory-store.js +0 -30
  301. package/dist/src/storage/project/cleanup-layout-v1.js +0 -72
  302. package/dist/src/storage/project/folder.js +0 -15
  303. package/dist/src/storage/project/index.js +0 -3
  304. package/dist/src/storage/project/layout.js +0 -74
  305. package/dist/src/storage/project/migrate-layout-v2.js +0 -101
  306. package/dist/src/storage/project/migrate.js +0 -73
  307. package/dist/src/storage/project/scoped-provider.js +0 -165
  308. package/dist/src/storage/provider.js +0 -26
  309. package/dist/src/storage/retrying-provider.js +0 -23
  310. package/dist/src/storage/test-connection.js +0 -32
  311. package/dist/src/storage/type-resolution-store.js +0 -26
  312. package/dist/src/storage/types.js +0 -1
  313. package/dist/src/storage/vector-store.js +0 -30
  314. package/dist/src/storage/visualization-store.js +0 -25
  315. package/dist/src/sync/compressor.js +0 -1
  316. package/dist/src/sync/conflict-resolver.js +0 -1
  317. package/dist/src/sync/downloader.js +0 -1
  318. package/dist/src/sync/index.js +0 -1
  319. package/dist/src/sync/sync-engine.js +0 -1
  320. package/dist/src/sync/upload-queue.js +0 -1
  321. package/dist/src/utils/retry.js +0 -29
  322. package/dist/src/visualization/server.js +0 -270
  323. package/dist/src/work-continuity/brief-cache.js +0 -107
  324. package/dist/src/work-continuity/brief.js +0 -349
  325. package/dist/src/work-continuity/cli.js +0 -96
  326. package/dist/src/work-continuity/context-cli.js +0 -106
  327. package/dist/src/work-continuity/context-runtime-cli.js +0 -88
  328. package/dist/src/work-continuity/extractor.js +0 -339
  329. package/dist/src/work-continuity/handoff.js +0 -185
  330. package/dist/src/work-continuity/index.js +0 -14
  331. package/dist/src/work-continuity/injection.js +0 -84
  332. package/dist/src/work-continuity/journal.js +0 -49
  333. package/dist/src/work-continuity/learner.js +0 -127
  334. package/dist/src/work-continuity/reducer.js +0 -316
  335. package/dist/src/work-continuity/semantic-extractor.js +0 -360
  336. package/dist/src/work-continuity/semantic-journal.js +0 -55
  337. package/dist/src/work-continuity/semantic-learner.js +0 -125
  338. package/dist/src/work-continuity/semantic-reducer.js +0 -268
  339. package/dist/src/work-continuity/semantic-types.js +0 -1
  340. package/dist/src/work-continuity/types.js +0 -1
  341. package/dist/visualization/public/index.html +0 -2896
  342. package/dist/visualization/public/vendor/3d-force-graph.min.js +0 -5
@@ -1,34 +0,0 @@
1
- export function checkProductionConfig() {
2
- const errors = [];
3
- const warnings = [];
4
- const provider = process.env
5
- .MEMORY_STORAGE_PROVIDER ??
6
- "local";
7
- if (provider ===
8
- "huggingface") {
9
- const required = [
10
- "HF_NAMESPACE",
11
- "HF_BUCKET",
12
- "HF_S3_ACCESS_KEY_ID",
13
- "HF_S3_SECRET_ACCESS_KEY",
14
- ];
15
- for (const key of required) {
16
- if (!process.env[key]) {
17
- errors.push(`Missing ${key}`);
18
- }
19
- }
20
- if (!process.env.HF_TOKEN) {
21
- warnings.push("HF_TOKEN missing: semantic embedding will use fallback");
22
- }
23
- }
24
- const model = process.env
25
- .HF_EMBEDDING_MODEL;
26
- if (!model) {
27
- warnings.push("HF_EMBEDDING_MODEL not set; default model will be used");
28
- }
29
- return {
30
- ok: errors.length === 0,
31
- errors,
32
- warnings,
33
- };
34
- }
@@ -1,58 +0,0 @@
1
- import "dotenv/config";
2
- import { loadConfig, ProjectManager, } from "../core/index.js";
3
- import { createStorageProvider, withStorageRetry, MemoryStore, PersistentCodeGraphStore, PersistentVectorStore, PersistentCodeChunkStore, PersistentCodeVectorStore, } from "../storage/index.js";
4
- import { createEmbeddingProvider, } from "../embeddings/index.js";
5
- import { SnapshotManager, } from "../snapshot/index.js";
6
- import { checkProductionConfig, } from "./config-check.js";
7
- import { ProductionHealth, } from "./health.js";
8
- async function main() {
9
- const configCheck = checkProductionConfig();
10
- if (!configCheck.ok) {
11
- console.log({
12
- ok: false,
13
- config: configCheck,
14
- });
15
- process.exit(1);
16
- }
17
- const config = loadConfig();
18
- const project = new ProjectManager()
19
- .detect();
20
- const storage = withStorageRetry(createStorageProvider({
21
- provider: config.storage.provider,
22
- huggingface: config.storage.huggingface,
23
- localRoot: config.storage.localRoot,
24
- }), {
25
- attempts: 3,
26
- });
27
- const embeddings = createEmbeddingProvider();
28
- const health = await new ProductionHealth(storage, embeddings).run();
29
- const memories = await new MemoryStore(storage).load(project.id);
30
- const graph = await new PersistentCodeGraphStore(storage).load(project.id);
31
- const vectors = await new PersistentVectorStore(storage).load(project.id);
32
- const chunks = await new PersistentCodeChunkStore(storage).load(project.id);
33
- const codeVectors = await new PersistentCodeVectorStore(storage).load(project.id);
34
- const snapshots = await new SnapshotManager(storage).list(project.id);
35
- console.log({
36
- ok: health.ok,
37
- project: project.name,
38
- storage: health.storage,
39
- embedding: health.embedding,
40
- memory: memories.length,
41
- graphSymbols: graph?.symbols.length ?? 0,
42
- graphEdges: graph?.edges.length ?? 0,
43
- memoryVectors: vectors?.records.length ?? 0,
44
- codeChunks: chunks?.chunks.length ?? 0,
45
- codeVectors: codeVectors?.records.length ?? 0,
46
- snapshots: snapshots.length,
47
- warnings: configCheck.warnings,
48
- });
49
- if (!health.ok) {
50
- process.exit(1);
51
- }
52
- }
53
- main().catch((error) => {
54
- console.error(error instanceof Error
55
- ? error.message
56
- : error);
57
- process.exit(1);
58
- });
@@ -1,114 +0,0 @@
1
- import { closeSync, mkdirSync, openSync, rmSync, writeFileSync, } from "node:fs";
2
- import { join, } from "node:path";
3
- import { ProjectManager, } from "../core/index.js";
4
- import { runProductionIndex, } from "./index-pipeline.js";
5
- const project = new ProjectManager()
6
- .detect();
7
- const toolnetDir = join(project.rootPath, ".toolnet");
8
- const lockFile = join(toolnetDir, "index.lock");
9
- const statusFile = join(toolnetDir, "last-index.json");
10
- mkdirSync(toolnetDir, {
11
- recursive: true,
12
- });
13
- function writeStatus(value) {
14
- writeFileSync(statusFile, JSON.stringify(value, null, 2) + "\n", {
15
- encoding: "utf8",
16
- mode: 0o600,
17
- });
18
- }
19
- let lockFd;
20
- try {
21
- lockFd =
22
- openSync(lockFile, "wx", 0o600);
23
- }
24
- catch {
25
- console.error("❌ Index already running for this project.");
26
- console.error(`Lock: ${lockFile}`);
27
- process.exit(2);
28
- }
29
- const startedAt = new Date()
30
- .toISOString();
31
- const completedStages = [];
32
- try {
33
- console.log();
34
- console.log("==============================================");
35
- console.log(" ToolNet Production Index");
36
- console.log("==============================================");
37
- console.log(`Project : ${project.name}`);
38
- console.log(`Remote : projects/${project.remote ??
39
- project.name}/`);
40
- console.log("Runtime : production/dist");
41
- console.log("Snapshot: disabled");
42
- writeStatus({
43
- version: 2,
44
- state: "running",
45
- startedAt,
46
- completedStages,
47
- project,
48
- });
49
- const result = await runProductionIndex(project, {
50
- onStage: async (event) => {
51
- if (event.state ===
52
- "start") {
53
- console.log();
54
- console.log(`===== ${event.title} =====`);
55
- }
56
- else {
57
- completedStages.push(event.id);
58
- console.log(`✅ ${event.title} (${((event.durationMs ??
59
- 0) /
60
- 1000).toFixed(1)}s)`);
61
- }
62
- writeStatus({
63
- version: 2,
64
- state: "running",
65
- startedAt,
66
- currentStage: event.id,
67
- completedStages: [
68
- ...completedStages,
69
- ],
70
- project,
71
- });
72
- },
73
- });
74
- writeStatus({
75
- version: 2,
76
- state: "complete",
77
- startedAt,
78
- finishedAt: new Date()
79
- .toISOString(),
80
- completedStages,
81
- result,
82
- });
83
- console.log();
84
- console.log("==============================================");
85
- console.log(" FULL INDEX COMPLETE ✅");
86
- console.log("==============================================");
87
- console.log(JSON.stringify(result, null, 2));
88
- }
89
- catch (error) {
90
- writeStatus({
91
- version: 2,
92
- state: "failed",
93
- startedAt,
94
- failedAt: new Date()
95
- .toISOString(),
96
- completedStages,
97
- error: error instanceof Error
98
- ? error.message
99
- : String(error),
100
- });
101
- console.error("FULL INDEX FAILED ❌");
102
- console.error(error);
103
- process.exitCode =
104
- 1;
105
- }
106
- finally {
107
- if (lockFd !==
108
- undefined) {
109
- closeSync(lockFd);
110
- }
111
- rmSync(lockFile, {
112
- force: true,
113
- });
114
- }
@@ -1,58 +0,0 @@
1
- import { randomUUID, } from "node:crypto";
2
- export class ProductionHealth {
3
- storage;
4
- embeddings;
5
- constructor(storage, embeddings) {
6
- this.storage = storage;
7
- this.embeddings = embeddings;
8
- }
9
- async run() {
10
- const key = `_health/production-${randomUUID()}.txt`;
11
- const payload = `toolnet-memory:${Date.now()}`;
12
- let storageOk = false;
13
- try {
14
- await this.storage.put(key, payload, "text/plain");
15
- const value = await this.storage.getText(key);
16
- storageOk =
17
- value === payload;
18
- }
19
- finally {
20
- try {
21
- await this.storage.delete(key);
22
- }
23
- catch {
24
- // cleanup only
25
- }
26
- }
27
- let embedding = null;
28
- if (this.embeddings) {
29
- try {
30
- const vector = await this.embeddings.embed("ToolNet Memory production health check");
31
- embedding = {
32
- ok: vector.length > 0,
33
- dimensions: vector.length,
34
- mode: vector.length === 384
35
- ? "huggingface"
36
- : "fallback-or-custom",
37
- };
38
- }
39
- catch {
40
- embedding = {
41
- ok: false,
42
- dimensions: 0,
43
- mode: "failed",
44
- };
45
- }
46
- }
47
- return {
48
- ok: storageOk &&
49
- (embedding === null ||
50
- embedding.ok),
51
- storage: {
52
- ok: storageOk,
53
- provider: this.storage.name,
54
- },
55
- embedding,
56
- };
57
- }
58
- }
@@ -1,151 +0,0 @@
1
- import { loadConfig, } from "../core/index.js";
2
- import { createEmbeddingProvider, } from "../embeddings/index.js";
3
- import { ArchitectureEngine, CodeAnalysisEngine, RepositoryIndexer, RichGraphEnricher, SemanticCodeEngine, TypeScriptTypeResolver, VisualizationBuilder, } from "../code-intelligence/index.js";
4
- import { createStorageProvider, PersistentArchitectureStore, PersistentCodeAnalysisStore, PersistentCodeGraphStore, PersistentTypeResolutionStore, PersistentVisualizationStore, ProjectScopedStorageProvider, withStorageRetry, } from "../storage/index.js";
5
- export async function runProductionIndex(project, options = {}) {
6
- const started = Date.now();
7
- async function stage(id, title, run) {
8
- await options.onStage?.({
9
- id,
10
- title,
11
- state: "start",
12
- });
13
- const stageStarted = Date.now();
14
- const result = await run();
15
- await options.onStage?.({
16
- id,
17
- title,
18
- state: "complete",
19
- durationMs: Date.now() -
20
- stageStarted,
21
- });
22
- return result;
23
- }
24
- const config = loadConfig();
25
- const rawStorage = withStorageRetry(createStorageProvider({
26
- provider: config.storage.provider,
27
- huggingface: config.storage.huggingface,
28
- localRoot: config.storage.localRoot,
29
- }), {
30
- attempts: 3,
31
- });
32
- const storage = new ProjectScopedStorageProvider(rawStorage, project.id, project.name, project.remote ??
33
- project.name);
34
- const graphStore = new PersistentCodeGraphStore(storage);
35
- /*
36
- * 1. SOURCE INDEX
37
- */
38
- const indexed = await stage("source-index", "Source Index", async () => {
39
- const result = await new RepositoryIndexer()
40
- .index(project.id, project.rootPath);
41
- await graphStore.save({
42
- version: 1,
43
- projectId: project.id,
44
- updatedAt: new Date()
45
- .toISOString(),
46
- files: result.files,
47
- symbols: result.graph
48
- .allSymbols(project.id),
49
- edges: result.graph
50
- .allEdges(project.id),
51
- });
52
- return result;
53
- });
54
- const graph = indexed.graph;
55
- /*
56
- * 2. TYPE RESOLUTION
57
- */
58
- const resolution = await stage("type-resolution", "Type Resolution", async () => {
59
- const result = await new TypeScriptTypeResolver(graph).resolveProject(project.id, project.rootPath);
60
- await new PersistentTypeResolutionStore(storage).save(result);
61
- return result;
62
- });
63
- /*
64
- * 3. RICH GRAPH
65
- */
66
- await stage("rich-graph", "Rich Graph", async () => {
67
- const stats = new RichGraphEnricher(graph).enrich(project.id, project.rootPath, resolution);
68
- const symbols = graph.allSymbols(project.id);
69
- const edges = graph.allEdges(project.id);
70
- await graphStore.save({
71
- version: 1,
72
- projectId: project.id,
73
- updatedAt: new Date()
74
- .toISOString(),
75
- files: symbols.filter(item => item.type ===
76
- "file").length,
77
- symbols,
78
- edges,
79
- });
80
- return stats;
81
- });
82
- /*
83
- * 4. SEMANTIC INDEX
84
- */
85
- const semantic = await stage("semantic-index", "Semantic Code Index", async () => {
86
- const engine = new SemanticCodeEngine({
87
- projectId: project.id,
88
- rootPath: project.rootPath,
89
- model: process.env
90
- .HF_EMBEDDING_MODEL ??
91
- "sentence-transformers/all-MiniLM-L6-v2",
92
- storage,
93
- embeddings: createEmbeddingProvider(),
94
- graph,
95
- });
96
- return engine.initialize();
97
- });
98
- /*
99
- * 5. ARCHITECTURE
100
- */
101
- const architecture = await stage("architecture", "Architecture Intelligence", async () => {
102
- const result = new ArchitectureEngine(graph).analyze(project.id);
103
- await new PersistentArchitectureStore(storage).save(result);
104
- return result;
105
- });
106
- /*
107
- * 6. ANALYSIS
108
- */
109
- const analysis = await stage("analysis", "Graph Analysis", async () => {
110
- const result = new CodeAnalysisEngine(graph).analyze(project.id);
111
- await new PersistentCodeAnalysisStore(storage).save(result);
112
- return result;
113
- });
114
- /*
115
- * 7. VISUALIZATION
116
- */
117
- const visualization = await stage("visualization", "3D Visualization Dataset", async () => {
118
- const result = new VisualizationBuilder(graph).build(project.id, architecture, analysis);
119
- await new PersistentVisualizationStore(storage).save(result);
120
- return result;
121
- });
122
- return {
123
- project: {
124
- id: project.id,
125
- name: project.name,
126
- remote: project.remote ??
127
- project.name,
128
- },
129
- storage: storage.name,
130
- durationMs: Date.now() -
131
- started,
132
- graph: {
133
- symbols: graph
134
- .allSymbols(project.id)
135
- .length,
136
- edges: graph
137
- .allEdges(project.id)
138
- .length,
139
- },
140
- resolution: {
141
- total: resolution.total,
142
- exact: resolution.exact,
143
- high: resolution.high,
144
- fallback: resolution.fallback,
145
- },
146
- semantic,
147
- architecture: architecture.summary,
148
- analysis: analysis.summary,
149
- visualization: visualization.summary,
150
- };
151
- }
@@ -1,4 +0,0 @@
1
- export * from "./project-lock.js";
2
- export * from "./config-check.js";
3
- export * from "./health.js";
4
- export * from "./recovery.js";
@@ -1,95 +0,0 @@
1
- import { closeSync, mkdirSync, openSync, readFileSync, unlinkSync, writeFileSync, } from "node:fs";
2
- import { tmpdir, } from "node:os";
3
- import { join, } from "node:path";
4
- function processAlive(pid) {
5
- try {
6
- process.kill(pid, 0);
7
- return true;
8
- }
9
- catch (error) {
10
- return (error?.code ===
11
- "EPERM");
12
- }
13
- }
14
- export class ProjectLock {
15
- acquired = false;
16
- path;
17
- exitHandler = () => {
18
- this.releaseSync();
19
- };
20
- constructor(projectId) {
21
- const root = join(tmpdir(), "toolnet-memory-locks");
22
- mkdirSync(root, {
23
- recursive: true,
24
- });
25
- const safeId = projectId.replace(/[^A-Za-z0-9_.-]/g, "_");
26
- this.path =
27
- join(root, `${safeId}.lock`);
28
- }
29
- async acquire() {
30
- if (this.acquired) {
31
- return;
32
- }
33
- for (let attempt = 0; attempt < 2; attempt++) {
34
- try {
35
- const fd = openSync(this.path, "wx");
36
- writeFileSync(fd, JSON.stringify({
37
- pid: process.pid,
38
- createdAt: new Date()
39
- .toISOString(),
40
- }));
41
- closeSync(fd);
42
- this.acquired =
43
- true;
44
- process.once("exit", this.exitHandler);
45
- return;
46
- }
47
- catch (error) {
48
- if (error?.code !==
49
- "EEXIST") {
50
- throw error;
51
- }
52
- let stale = true;
53
- try {
54
- const data = JSON.parse(readFileSync(this.path, "utf8"));
55
- if (Number.isInteger(data.pid) &&
56
- processAlive(data.pid)) {
57
- stale =
58
- false;
59
- }
60
- }
61
- catch {
62
- stale =
63
- true;
64
- }
65
- if (!stale) {
66
- throw new Error("ToolNet Memory is already running for this project");
67
- }
68
- try {
69
- unlinkSync(this.path);
70
- }
71
- catch {
72
- // retry once
73
- }
74
- }
75
- }
76
- throw new Error("Unable to acquire ToolNet Memory project lock");
77
- }
78
- async release() {
79
- this.releaseSync();
80
- }
81
- releaseSync() {
82
- if (!this.acquired) {
83
- return;
84
- }
85
- try {
86
- unlinkSync(this.path);
87
- }
88
- catch {
89
- // already removed
90
- }
91
- this.acquired =
92
- false;
93
- process.off("exit", this.exitHandler);
94
- }
95
- }
@@ -1,16 +0,0 @@
1
- import { join, } from "node:path";
2
- import { ProjectManager, } from "../core/index.js";
3
- import { sanitizeProjectFolder, } from "../storage/project/folder.js";
4
- const project = new ProjectManager()
5
- .detect();
6
- const remote = sanitizeProjectFolder(project.remote ??
7
- project.name);
8
- console.log(JSON.stringify({
9
- id: project.id,
10
- name: project.name,
11
- remote,
12
- rootPath: project.rootPath,
13
- localManifest: join(project.rootPath, ".toolnet", "project.json"),
14
- remoteNamespace: `projects/${remote}/`,
15
- isolation: "1 folder = 1 project = 1 remote namespace",
16
- }, null, 2));
@@ -1,15 +0,0 @@
1
- import { SnapshotManager, } from "../snapshot/index.js";
2
- export async function restoreLatestSnapshot(storage, projectId) {
3
- const manager = new SnapshotManager(storage);
4
- const snapshots = await manager.list(projectId);
5
- const latest = snapshots[0];
6
- if (!latest) {
7
- throw new Error("No snapshot available");
8
- }
9
- const result = await manager.restore(projectId, latest.id);
10
- return {
11
- snapshot: latest.id,
12
- createdAt: latest.createdAt,
13
- ...result,
14
- };
15
- }