kontexta 5.1.3 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (543) hide show
  1. package/bundle/standalone/CHANGELOG.md +51 -0
  2. package/bundle/standalone/apps/web/.next/BUILD_ID +1 -1
  3. package/bundle/standalone/apps/web/.next/app-build-manifest.json +99 -92
  4. package/bundle/standalone/apps/web/.next/app-path-routes-manifest.json +13 -12
  5. package/bundle/standalone/apps/web/.next/build-manifest.json +2 -2
  6. package/bundle/standalone/apps/web/.next/prerender-manifest.json +3 -3
  7. package/bundle/standalone/apps/web/.next/required-server-files.json +1 -0
  8. package/bundle/standalone/apps/web/.next/routes-manifest.json +8 -0
  9. package/bundle/standalone/apps/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  10. package/bundle/standalone/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  11. package/bundle/standalone/apps/web/.next/server/app/_not-found.html +1 -1
  12. package/bundle/standalone/apps/web/.next/server/app/_not-found.rsc +4 -4
  13. package/bundle/standalone/apps/web/.next/server/app/api/about/route.js.nft.json +1 -1
  14. package/bundle/standalone/apps/web/.next/server/app/api/about/route_client-reference-manifest.js +1 -1
  15. package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/hooks/route.js +1 -1
  16. package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/hooks/route.js.nft.json +1 -1
  17. package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/hooks/route_client-reference-manifest.js +1 -1
  18. package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/mcp/route.js +1 -0
  19. package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/mcp/route.js.nft.json +1 -0
  20. package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/mcp/route_client-reference-manifest.js +1 -0
  21. package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/route.js +1 -1
  22. package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/route.js.nft.json +1 -1
  23. package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/route_client-reference-manifest.js +1 -1
  24. package/bundle/standalone/apps/web/.next/server/app/api/agents/route.js +1 -1
  25. package/bundle/standalone/apps/web/.next/server/app/api/agents/route.js.nft.json +1 -1
  26. package/bundle/standalone/apps/web/.next/server/app/api/agents/route_client-reference-manifest.js +1 -1
  27. package/bundle/standalone/apps/web/.next/server/app/api/auth/login/route.js.nft.json +1 -1
  28. package/bundle/standalone/apps/web/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  29. package/bundle/standalone/apps/web/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
  30. package/bundle/standalone/apps/web/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  31. package/bundle/standalone/apps/web/.next/server/app/api/auth/setup/route.js.nft.json +1 -1
  32. package/bundle/standalone/apps/web/.next/server/app/api/auth/setup/route_client-reference-manifest.js +1 -1
  33. package/bundle/standalone/apps/web/.next/server/app/api/auth/status/route.js.nft.json +1 -1
  34. package/bundle/standalone/apps/web/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  35. package/bundle/standalone/apps/web/.next/server/app/api/auth/token/route.js.nft.json +1 -1
  36. package/bundle/standalone/apps/web/.next/server/app/api/auth/token/route_client-reference-manifest.js +1 -1
  37. package/bundle/standalone/apps/web/.next/server/app/api/calendar/conflicts/route.js.nft.json +1 -1
  38. package/bundle/standalone/apps/web/.next/server/app/api/calendar/conflicts/route_client-reference-manifest.js +1 -1
  39. package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/[id]/route.js.nft.json +1 -1
  40. package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/[id]/route_client-reference-manifest.js +1 -1
  41. package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/route.js.nft.json +1 -1
  42. package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/route_client-reference-manifest.js +1 -1
  43. package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/[id]/route.js.nft.json +1 -1
  44. package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/[id]/route_client-reference-manifest.js +1 -1
  45. package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/route.js.nft.json +1 -1
  46. package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/route_client-reference-manifest.js +1 -1
  47. package/bundle/standalone/apps/web/.next/server/app/api/calendar/ics/route.js.nft.json +1 -1
  48. package/bundle/standalone/apps/web/.next/server/app/api/calendar/ics/route_client-reference-manifest.js +1 -1
  49. package/bundle/standalone/apps/web/.next/server/app/api/calendar/links/route.js.nft.json +1 -1
  50. package/bundle/standalone/apps/web/.next/server/app/api/calendar/links/route_client-reference-manifest.js +1 -1
  51. package/bundle/standalone/apps/web/.next/server/app/api/calendar/settings/route.js.nft.json +1 -1
  52. package/bundle/standalone/apps/web/.next/server/app/api/calendar/settings/route_client-reference-manifest.js +1 -1
  53. package/bundle/standalone/apps/web/.next/server/app/api/clip/route.js.nft.json +1 -1
  54. package/bundle/standalone/apps/web/.next/server/app/api/clip/route_client-reference-manifest.js +1 -1
  55. package/bundle/standalone/apps/web/.next/server/app/api/docker-config/route.js.nft.json +1 -1
  56. package/bundle/standalone/apps/web/.next/server/app/api/docker-config/route_client-reference-manifest.js +1 -1
  57. package/bundle/standalone/apps/web/.next/server/app/api/export/zip/route.js.nft.json +1 -1
  58. package/bundle/standalone/apps/web/.next/server/app/api/export/zip/route_client-reference-manifest.js +1 -1
  59. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/backlinks/route.js.nft.json +1 -1
  60. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/backlinks/route_client-reference-manifest.js +1 -1
  61. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/download/route.js.nft.json +1 -1
  62. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/download/route_client-reference-manifest.js +1 -1
  63. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-html/route.js.nft.json +1 -1
  64. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-html/route_client-reference-manifest.js +1 -1
  65. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-pdf/route.js.nft.json +1 -1
  66. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-pdf/route_client-reference-manifest.js +1 -1
  67. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/restore/route.js.nft.json +1 -1
  68. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/restore/route_client-reference-manifest.js +1 -1
  69. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/route.js.nft.json +1 -1
  70. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/route_client-reference-manifest.js +1 -1
  71. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/move/route.js.nft.json +1 -1
  72. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/move/route_client-reference-manifest.js +1 -1
  73. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/route.js.nft.json +1 -1
  74. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/route_client-reference-manifest.js +1 -1
  75. package/bundle/standalone/apps/web/.next/server/app/api/files/route.js.nft.json +1 -1
  76. package/bundle/standalone/apps/web/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
  77. package/bundle/standalone/apps/web/.next/server/app/api/files/upload/route.js.nft.json +1 -1
  78. package/bundle/standalone/apps/web/.next/server/app/api/files/upload/route_client-reference-manifest.js +1 -1
  79. package/bundle/standalone/apps/web/.next/server/app/api/folders/route.js +1 -1
  80. package/bundle/standalone/apps/web/.next/server/app/api/folders/route.js.nft.json +1 -1
  81. package/bundle/standalone/apps/web/.next/server/app/api/folders/route_client-reference-manifest.js +1 -1
  82. package/bundle/standalone/apps/web/.next/server/app/api/git/remote/route.js.nft.json +1 -1
  83. package/bundle/standalone/apps/web/.next/server/app/api/git/remote/route_client-reference-manifest.js +1 -1
  84. package/bundle/standalone/apps/web/.next/server/app/api/git/sync-all/route.js +1 -1
  85. package/bundle/standalone/apps/web/.next/server/app/api/git/sync-all/route.js.nft.json +1 -1
  86. package/bundle/standalone/apps/web/.next/server/app/api/git/sync-all/route_client-reference-manifest.js +1 -1
  87. package/bundle/standalone/apps/web/.next/server/app/api/hands/test-pattern/route.js.nft.json +1 -1
  88. package/bundle/standalone/apps/web/.next/server/app/api/hands/test-pattern/route_client-reference-manifest.js +1 -1
  89. package/bundle/standalone/apps/web/.next/server/app/api/hands/validate/route.js.nft.json +1 -1
  90. package/bundle/standalone/apps/web/.next/server/app/api/hands/validate/route_client-reference-manifest.js +1 -1
  91. package/bundle/standalone/apps/web/.next/server/app/api/health/route.js.nft.json +1 -1
  92. package/bundle/standalone/apps/web/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
  93. package/bundle/standalone/apps/web/.next/server/app/api/install-snippets/route.js +9 -9
  94. package/bundle/standalone/apps/web/.next/server/app/api/install-snippets/route.js.nft.json +1 -1
  95. package/bundle/standalone/apps/web/.next/server/app/api/install-snippets/route_client-reference-manifest.js +1 -1
  96. package/bundle/standalone/apps/web/.next/server/app/api/mcp-tools/route.js +1 -1
  97. package/bundle/standalone/apps/web/.next/server/app/api/mcp-tools/route.js.nft.json +1 -1
  98. package/bundle/standalone/apps/web/.next/server/app/api/mcp-tools/route_client-reference-manifest.js +1 -1
  99. package/bundle/standalone/apps/web/.next/server/app/api/profile/route.js.nft.json +1 -1
  100. package/bundle/standalone/apps/web/.next/server/app/api/profile/route_client-reference-manifest.js +1 -1
  101. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/hands-config/route.js.nft.json +1 -1
  102. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/hands-config/route_client-reference-manifest.js +1 -1
  103. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-config/route.js.nft.json +1 -1
  104. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-config/route_client-reference-manifest.js +1 -1
  105. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-status/route.js.nft.json +1 -1
  106. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-status/route_client-reference-manifest.js +1 -1
  107. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/onboard/route.js.nft.json +1 -1
  108. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/onboard/route_client-reference-manifest.js +1 -1
  109. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/refresh/route.js.nft.json +1 -1
  110. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/refresh/route_client-reference-manifest.js +1 -1
  111. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/route.js.nft.json +1 -1
  112. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/route_client-reference-manifest.js +1 -1
  113. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/sync/route.js.nft.json +1 -1
  114. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/sync/route_client-reference-manifest.js +1 -1
  115. package/bundle/standalone/apps/web/.next/server/app/api/projects/onboard/route.js.nft.json +1 -1
  116. package/bundle/standalone/apps/web/.next/server/app/api/projects/onboard/route_client-reference-manifest.js +1 -1
  117. package/bundle/standalone/apps/web/.next/server/app/api/projects/route.js.nft.json +1 -1
  118. package/bundle/standalone/apps/web/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
  119. package/bundle/standalone/apps/web/.next/server/app/api/publish/html/route.js.nft.json +1 -1
  120. package/bundle/standalone/apps/web/.next/server/app/api/publish/html/route_client-reference-manifest.js +1 -1
  121. package/bundle/standalone/apps/web/.next/server/app/api/publish/route.js.nft.json +1 -1
  122. package/bundle/standalone/apps/web/.next/server/app/api/publish/route_client-reference-manifest.js +1 -1
  123. package/bundle/standalone/apps/web/.next/server/app/api/refresh/route.js.nft.json +1 -1
  124. package/bundle/standalone/apps/web/.next/server/app/api/refresh/route_client-reference-manifest.js +1 -1
  125. package/bundle/standalone/apps/web/.next/server/app/api/reindex/route.js.nft.json +1 -1
  126. package/bundle/standalone/apps/web/.next/server/app/api/reindex/route_client-reference-manifest.js +1 -1
  127. package/bundle/standalone/apps/web/.next/server/app/api/reports/resources/[name]/route.js.nft.json +1 -1
  128. package/bundle/standalone/apps/web/.next/server/app/api/reports/resources/[name]/route_client-reference-manifest.js +1 -1
  129. package/bundle/standalone/apps/web/.next/server/app/api/search/route.js.nft.json +1 -1
  130. package/bundle/standalone/apps/web/.next/server/app/api/search/route_client-reference-manifest.js +1 -1
  131. package/bundle/standalone/apps/web/.next/server/app/api/tags/route.js.nft.json +1 -1
  132. package/bundle/standalone/apps/web/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
  133. package/bundle/standalone/apps/web/.next/server/app/api/version-check/route.js.nft.json +1 -1
  134. package/bundle/standalone/apps/web/.next/server/app/api/version-check/route_client-reference-manifest.js +1 -1
  135. package/bundle/standalone/apps/web/.next/server/app/api/welcome/route.js.nft.json +1 -1
  136. package/bundle/standalone/apps/web/.next/server/app/api/welcome/route_client-reference-manifest.js +1 -1
  137. package/bundle/standalone/apps/web/.next/server/app/api/ws-config/route.js.nft.json +1 -1
  138. package/bundle/standalone/apps/web/.next/server/app/api/ws-config/route_client-reference-manifest.js +1 -1
  139. package/bundle/standalone/apps/web/.next/server/app/apple-icon.png/route.js.nft.json +1 -1
  140. package/bundle/standalone/apps/web/.next/server/app/calendar/page.js +1 -1
  141. package/bundle/standalone/apps/web/.next/server/app/calendar/page.js.nft.json +1 -1
  142. package/bundle/standalone/apps/web/.next/server/app/calendar/page_client-reference-manifest.js +1 -1
  143. package/bundle/standalone/apps/web/.next/server/app/favicon.ico/route.js.nft.json +1 -1
  144. package/bundle/standalone/apps/web/.next/server/app/icon.png/route.js.nft.json +1 -1
  145. package/bundle/standalone/apps/web/.next/server/app/login/page.js.nft.json +1 -1
  146. package/bundle/standalone/apps/web/.next/server/app/login/page_client-reference-manifest.js +1 -1
  147. package/bundle/standalone/apps/web/.next/server/app/page.js +4 -4
  148. package/bundle/standalone/apps/web/.next/server/app/page.js.nft.json +1 -1
  149. package/bundle/standalone/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
  150. package/bundle/standalone/apps/web/.next/server/app/preview/motifs/page.js.nft.json +1 -1
  151. package/bundle/standalone/apps/web/.next/server/app/preview/motifs/page_client-reference-manifest.js +1 -1
  152. package/bundle/standalone/apps/web/.next/server/app/preview/motifs.html +2 -2
  153. package/bundle/standalone/apps/web/.next/server/app/preview/motifs.rsc +4 -4
  154. package/bundle/standalone/apps/web/.next/server/app-paths-manifest.json +13 -12
  155. package/bundle/standalone/apps/web/.next/server/chunks/3668.js +2 -2
  156. package/bundle/standalone/apps/web/.next/server/pages/404.html +1 -1
  157. package/bundle/standalone/apps/web/.next/server/pages/500.html +1 -1
  158. package/bundle/standalone/apps/web/.next/server/pages/_app.js.nft.json +1 -1
  159. package/bundle/standalone/apps/web/.next/server/pages/_document.js.nft.json +1 -1
  160. package/bundle/standalone/apps/web/.next/server/pages/_error.js.nft.json +1 -1
  161. package/bundle/standalone/apps/web/.next/server/server-reference-manifest.json +1 -1
  162. package/bundle/standalone/apps/web/.next/static/chunks/app/api/about/route-e920054b7eb00274.js +1 -0
  163. package/bundle/standalone/apps/web/.next/static/chunks/app/api/agents/[id]/hooks/route-e920054b7eb00274.js +1 -0
  164. package/bundle/standalone/apps/web/.next/static/chunks/app/api/agents/[id]/mcp/route-e920054b7eb00274.js +1 -0
  165. package/bundle/standalone/apps/web/.next/static/chunks/app/api/agents/[id]/route-e920054b7eb00274.js +1 -0
  166. package/bundle/standalone/apps/web/.next/static/chunks/app/api/agents/route-e920054b7eb00274.js +1 -0
  167. package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/login/route-e920054b7eb00274.js +1 -0
  168. package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/logout/route-e920054b7eb00274.js +1 -0
  169. package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/setup/route-e920054b7eb00274.js +1 -0
  170. package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/status/route-e920054b7eb00274.js +1 -0
  171. package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/token/route-e920054b7eb00274.js +1 -0
  172. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/conflicts/route-e920054b7eb00274.js +1 -0
  173. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/entities/[id]/route-e920054b7eb00274.js +1 -0
  174. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/entities/route-e920054b7eb00274.js +1 -0
  175. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/events/[id]/route-e920054b7eb00274.js +1 -0
  176. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/events/route-e920054b7eb00274.js +1 -0
  177. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/ics/route-e920054b7eb00274.js +1 -0
  178. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/links/route-e920054b7eb00274.js +1 -0
  179. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/settings/route-e920054b7eb00274.js +1 -0
  180. package/bundle/standalone/apps/web/.next/static/chunks/app/api/clip/route-e920054b7eb00274.js +1 -0
  181. package/bundle/standalone/apps/web/.next/static/chunks/app/api/docker-config/route-e920054b7eb00274.js +1 -0
  182. package/bundle/standalone/apps/web/.next/static/chunks/app/api/export/zip/route-e920054b7eb00274.js +1 -0
  183. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/backlinks/route-e920054b7eb00274.js +1 -0
  184. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/download/route-e920054b7eb00274.js +1 -0
  185. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/export-html/route-e920054b7eb00274.js +1 -0
  186. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/export-pdf/route-e920054b7eb00274.js +1 -0
  187. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/history/restore/route-e920054b7eb00274.js +1 -0
  188. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/history/route-e920054b7eb00274.js +1 -0
  189. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/move/route-e920054b7eb00274.js +1 -0
  190. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/route-e920054b7eb00274.js +1 -0
  191. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/route-e920054b7eb00274.js +1 -0
  192. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/upload/route-e920054b7eb00274.js +1 -0
  193. package/bundle/standalone/apps/web/.next/static/chunks/app/api/folders/route-e920054b7eb00274.js +1 -0
  194. package/bundle/standalone/apps/web/.next/static/chunks/app/api/git/remote/route-e920054b7eb00274.js +1 -0
  195. package/bundle/standalone/apps/web/.next/static/chunks/app/api/git/sync-all/route-e920054b7eb00274.js +1 -0
  196. package/bundle/standalone/apps/web/.next/static/chunks/app/api/hands/test-pattern/route-e920054b7eb00274.js +1 -0
  197. package/bundle/standalone/apps/web/.next/static/chunks/app/api/hands/validate/route-e920054b7eb00274.js +1 -0
  198. package/bundle/standalone/apps/web/.next/static/chunks/app/api/health/route-e920054b7eb00274.js +1 -0
  199. package/bundle/standalone/apps/web/.next/static/chunks/app/api/install-snippets/route-e920054b7eb00274.js +1 -0
  200. package/bundle/standalone/apps/web/.next/static/chunks/app/api/mcp-tools/route-e920054b7eb00274.js +1 -0
  201. package/bundle/standalone/apps/web/.next/static/chunks/app/api/profile/route-e920054b7eb00274.js +1 -0
  202. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/hands-config/route-e920054b7eb00274.js +1 -0
  203. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/journal-config/route-e920054b7eb00274.js +1 -0
  204. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/journal-status/route-e920054b7eb00274.js +1 -0
  205. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/onboard/route-e920054b7eb00274.js +1 -0
  206. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/refresh/route-e920054b7eb00274.js +1 -0
  207. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/route-e920054b7eb00274.js +1 -0
  208. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/sync/route-e920054b7eb00274.js +1 -0
  209. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/onboard/route-e920054b7eb00274.js +1 -0
  210. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/route-e920054b7eb00274.js +1 -0
  211. package/bundle/standalone/apps/web/.next/static/chunks/app/api/publish/html/route-e920054b7eb00274.js +1 -0
  212. package/bundle/standalone/apps/web/.next/static/chunks/app/api/publish/route-e920054b7eb00274.js +1 -0
  213. package/bundle/standalone/apps/web/.next/static/chunks/app/api/refresh/route-e920054b7eb00274.js +1 -0
  214. package/bundle/standalone/apps/web/.next/static/chunks/app/api/reindex/route-e920054b7eb00274.js +1 -0
  215. package/bundle/standalone/apps/web/.next/static/chunks/app/api/reports/resources/[name]/route-e920054b7eb00274.js +1 -0
  216. package/bundle/standalone/apps/web/.next/static/chunks/app/api/search/route-e920054b7eb00274.js +1 -0
  217. package/bundle/standalone/apps/web/.next/static/chunks/app/api/tags/route-e920054b7eb00274.js +1 -0
  218. package/bundle/standalone/apps/web/.next/static/chunks/app/api/version-check/route-e920054b7eb00274.js +1 -0
  219. package/bundle/standalone/apps/web/.next/static/chunks/app/api/welcome/route-e920054b7eb00274.js +1 -0
  220. package/bundle/standalone/apps/web/.next/static/chunks/app/api/ws-config/route-e920054b7eb00274.js +1 -0
  221. package/bundle/standalone/apps/web/.next/static/chunks/app/calendar/page-7d520da68bac245d.js +1 -0
  222. package/bundle/standalone/apps/web/.next/static/chunks/app/{layout-da10917c290d5da7.js → layout-b3fc3a7cf96952bd.js} +1 -1
  223. package/bundle/standalone/apps/web/.next/static/chunks/app/page-f2e6293531d0db55.js +1 -0
  224. package/bundle/standalone/apps/web/.next/static/chunks/app/preview/motifs/page-e920054b7eb00274.js +1 -0
  225. package/bundle/standalone/apps/web/.next/static/css/{c2dc6e054d3457fa.css → c9d10f1f97d629ff.css} +2 -2
  226. package/bundle/standalone/apps/web/package.json +6 -5
  227. package/bundle/standalone/apps/web/server.js +1 -1
  228. package/bundle/standalone/apps/web/src/lib/mcp-tools.json +126 -118
  229. package/bundle/standalone/node_modules/kontexta-mcp/dist/agent-rules/rules-block.md +28 -185
  230. package/bundle/standalone/node_modules/kontexta-mcp/dist/agent-rules/rules-reference.md +207 -0
  231. package/bundle/standalone/node_modules/kontexta-mcp/dist/calendar-tools.js +20 -20
  232. package/bundle/standalone/node_modules/kontexta-mcp/dist/calendar-tools.js.map +1 -1
  233. package/bundle/standalone/node_modules/kontexta-mcp/dist/connect-cli.d.ts +3 -0
  234. package/bundle/standalone/node_modules/kontexta-mcp/dist/connect-cli.d.ts.map +1 -0
  235. package/bundle/standalone/node_modules/kontexta-mcp/dist/connect-cli.js +166 -0
  236. package/bundle/standalone/node_modules/kontexta-mcp/dist/connect-cli.js.map +1 -0
  237. package/bundle/standalone/node_modules/kontexta-mcp/dist/hands/executor.js +1 -1
  238. package/bundle/standalone/node_modules/kontexta-mcp/dist/hands/executor.js.map +1 -1
  239. package/bundle/standalone/node_modules/kontexta-mcp/dist/hands/formatter.js +1 -1
  240. package/bundle/standalone/node_modules/kontexta-mcp/dist/hands/loader.js +1 -1
  241. package/bundle/standalone/node_modules/kontexta-mcp/dist/hands/loader.js.map +1 -1
  242. package/bundle/standalone/node_modules/kontexta-mcp/dist/hands/sanitizer.js +2 -2
  243. package/bundle/standalone/node_modules/kontexta-mcp/dist/hands/sanitizer.js.map +1 -1
  244. package/bundle/standalone/node_modules/kontexta-mcp/dist/hands/schema-doc.js +26 -26
  245. package/bundle/standalone/node_modules/kontexta-mcp/dist/hooks/emit.mjs +39 -2
  246. package/bundle/standalone/node_modules/kontexta-mcp/dist/hooks-block.js +1 -1
  247. package/bundle/standalone/node_modules/kontexta-mcp/dist/hooks-block.js.map +1 -1
  248. package/bundle/standalone/node_modules/kontexta-mcp/dist/hooks-cli.js +2 -2
  249. package/bundle/standalone/node_modules/kontexta-mcp/dist/hooks-cli.js.map +1 -1
  250. package/bundle/standalone/node_modules/kontexta-mcp/dist/index.js +240 -94
  251. package/bundle/standalone/node_modules/kontexta-mcp/dist/index.js.map +1 -1
  252. package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-capture.js +8 -8
  253. package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-capture.js.map +1 -1
  254. package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-commit-upgrades-tool.js +1 -1
  255. package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-housekeep-tool.js +1 -1
  256. package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-tools.js +2 -2
  257. package/bundle/standalone/node_modules/kontexta-mcp/dist/migrations/011-journal-files-in-kb.sql +2 -0
  258. package/bundle/standalone/node_modules/kontexta-mcp/dist/migrations/012-agents-mcp.sql +6 -0
  259. package/bundle/standalone/node_modules/kontexta-mcp/dist/profile-tool.js +1 -1
  260. package/bundle/standalone/node_modules/kontexta-mcp/dist/profile-tool.js.map +1 -1
  261. package/bundle/standalone/node_modules/kontexta-mcp/dist/repo-write-guard.d.ts +7 -0
  262. package/bundle/standalone/node_modules/kontexta-mcp/dist/repo-write-guard.d.ts.map +1 -0
  263. package/bundle/standalone/node_modules/kontexta-mcp/dist/repo-write-guard.js +13 -0
  264. package/bundle/standalone/node_modules/kontexta-mcp/dist/repo-write-guard.js.map +1 -0
  265. package/bundle/standalone/node_modules/kontexta-mcp/package.json +5 -2
  266. package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/index.d.ts +5 -0
  267. package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/index.d.ts.map +1 -1
  268. package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/index.js +84 -25
  269. package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/index.js.map +1 -1
  270. package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/rules-block.md +28 -185
  271. package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/rules-reference.md +207 -0
  272. package/bundle/standalone/node_modules/kxta-core/dist/bundle/index.d.ts +25 -1
  273. package/bundle/standalone/node_modules/kxta-core/dist/bundle/index.d.ts.map +1 -1
  274. package/bundle/standalone/node_modules/kxta-core/dist/bundle/index.js +159 -32
  275. package/bundle/standalone/node_modules/kxta-core/dist/bundle/index.js.map +1 -1
  276. package/bundle/standalone/node_modules/kxta-core/dist/db/migrations/011-journal-files-in-kb.sql +2 -0
  277. package/bundle/standalone/node_modules/kxta-core/dist/db/migrations/012-agents-mcp.sql +6 -0
  278. package/bundle/standalone/node_modules/kxta-core/dist/decision/engine.d.ts +71 -0
  279. package/bundle/standalone/node_modules/kxta-core/dist/decision/engine.d.ts.map +1 -0
  280. package/bundle/standalone/node_modules/kxta-core/dist/decision/engine.js +192 -0
  281. package/bundle/standalone/node_modules/kxta-core/dist/decision/engine.js.map +1 -0
  282. package/bundle/standalone/node_modules/kxta-core/dist/decision/index.d.ts +9 -0
  283. package/bundle/standalone/node_modules/kxta-core/dist/decision/index.d.ts.map +1 -0
  284. package/bundle/standalone/node_modules/kxta-core/dist/decision/index.js +10 -0
  285. package/bundle/standalone/node_modules/kxta-core/dist/decision/index.js.map +1 -0
  286. package/bundle/standalone/node_modules/kxta-core/dist/decision/intent-router.d.ts +20 -0
  287. package/bundle/standalone/node_modules/kxta-core/dist/decision/intent-router.d.ts.map +1 -0
  288. package/bundle/standalone/node_modules/kxta-core/dist/decision/intent-router.js +124 -0
  289. package/bundle/standalone/node_modules/kxta-core/dist/decision/intent-router.js.map +1 -0
  290. package/bundle/standalone/node_modules/kxta-core/dist/decision/pruning.d.ts +20 -0
  291. package/bundle/standalone/node_modules/kxta-core/dist/decision/pruning.d.ts.map +1 -0
  292. package/bundle/standalone/node_modules/kxta-core/dist/decision/pruning.js +28 -0
  293. package/bundle/standalone/node_modules/kxta-core/dist/decision/pruning.js.map +1 -0
  294. package/bundle/standalone/node_modules/kxta-core/dist/decision/sufficiency.d.ts +30 -0
  295. package/bundle/standalone/node_modules/kxta-core/dist/decision/sufficiency.d.ts.map +1 -0
  296. package/bundle/standalone/node_modules/kxta-core/dist/decision/sufficiency.js +57 -0
  297. package/bundle/standalone/node_modules/kxta-core/dist/decision/sufficiency.js.map +1 -0
  298. package/bundle/standalone/node_modules/kxta-core/dist/decision/types.d.ts +42 -0
  299. package/bundle/standalone/node_modules/kxta-core/dist/decision/types.d.ts.map +1 -0
  300. package/bundle/standalone/node_modules/kxta-core/dist/decision/types.js +7 -0
  301. package/bundle/standalone/node_modules/kxta-core/dist/decision/types.js.map +1 -0
  302. package/bundle/standalone/node_modules/kxta-core/dist/files/index.d.ts +3 -1
  303. package/bundle/standalone/node_modules/kxta-core/dist/files/index.d.ts.map +1 -1
  304. package/bundle/standalone/node_modules/kxta-core/dist/files/index.js +10 -1
  305. package/bundle/standalone/node_modules/kxta-core/dist/files/index.js.map +1 -1
  306. package/bundle/standalone/node_modules/kxta-core/dist/hooks/agents.d.ts +19 -2
  307. package/bundle/standalone/node_modules/kxta-core/dist/hooks/agents.d.ts.map +1 -1
  308. package/bundle/standalone/node_modules/kxta-core/dist/hooks/agents.js +15 -15
  309. package/bundle/standalone/node_modules/kxta-core/dist/hooks/agents.js.map +1 -1
  310. package/bundle/standalone/node_modules/kxta-core/dist/hooks/alerts.d.ts +2 -0
  311. package/bundle/standalone/node_modules/kxta-core/dist/hooks/alerts.d.ts.map +1 -1
  312. package/bundle/standalone/node_modules/kxta-core/dist/hooks/alerts.js +5 -5
  313. package/bundle/standalone/node_modules/kxta-core/dist/hooks/alerts.js.map +1 -1
  314. package/bundle/standalone/node_modules/kxta-core/dist/hooks/emit.mjs +39 -2
  315. package/bundle/standalone/node_modules/kxta-core/dist/hooks/index.d.ts +2 -2
  316. package/bundle/standalone/node_modules/kxta-core/dist/hooks/index.d.ts.map +1 -1
  317. package/bundle/standalone/node_modules/kxta-core/dist/hooks/index.js +1 -1
  318. package/bundle/standalone/node_modules/kxta-core/dist/hooks/index.js.map +1 -1
  319. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/antigravity.d.ts +3 -0
  320. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/antigravity.d.ts.map +1 -0
  321. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/antigravity.js +75 -0
  322. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/antigravity.js.map +1 -0
  323. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/codex.js +1 -1
  324. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/codex.js.map +1 -1
  325. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/copilot.d.ts.map +1 -1
  326. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/copilot.js +4 -3
  327. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/copilot.js.map +1 -1
  328. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/gemini.d.ts.map +1 -1
  329. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/gemini.js +0 -1
  330. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/gemini.js.map +1 -1
  331. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/hermes.d.ts +3 -0
  332. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/hermes.d.ts.map +1 -0
  333. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/hermes.js +107 -0
  334. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/hermes.js.map +1 -0
  335. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/index.d.ts.map +1 -1
  336. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/index.js +4 -0
  337. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/index.js.map +1 -1
  338. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/json-config.d.ts +2 -0
  339. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/json-config.d.ts.map +1 -1
  340. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/json-config.js +27 -13
  341. package/bundle/standalone/node_modules/kxta-core/dist/hooks/installers/json-config.js.map +1 -1
  342. package/bundle/standalone/node_modules/kxta-core/dist/hooks/registry.d.ts +11 -0
  343. package/bundle/standalone/node_modules/kxta-core/dist/hooks/registry.d.ts.map +1 -1
  344. package/bundle/standalone/node_modules/kxta-core/dist/hooks/registry.js +29 -3
  345. package/bundle/standalone/node_modules/kxta-core/dist/hooks/registry.js.map +1 -1
  346. package/bundle/standalone/node_modules/kxta-core/dist/index.d.ts +5 -1
  347. package/bundle/standalone/node_modules/kxta-core/dist/index.d.ts.map +1 -1
  348. package/bundle/standalone/node_modules/kxta-core/dist/index.js +5 -1
  349. package/bundle/standalone/node_modules/kxta-core/dist/index.js.map +1 -1
  350. package/bundle/standalone/node_modules/kxta-core/dist/inference/bundled.d.ts +3 -0
  351. package/bundle/standalone/node_modules/kxta-core/dist/inference/bundled.d.ts.map +1 -0
  352. package/bundle/standalone/node_modules/kxta-core/dist/inference/bundled.js +27 -0
  353. package/bundle/standalone/node_modules/kxta-core/dist/inference/bundled.js.map +1 -0
  354. package/bundle/standalone/node_modules/kxta-core/dist/inference/cache-manager.d.ts +41 -0
  355. package/bundle/standalone/node_modules/kxta-core/dist/inference/cache-manager.d.ts.map +1 -0
  356. package/bundle/standalone/node_modules/kxta-core/dist/inference/cache-manager.js +140 -0
  357. package/bundle/standalone/node_modules/kxta-core/dist/inference/cache-manager.js.map +1 -0
  358. package/bundle/standalone/node_modules/kxta-core/dist/inference/index.d.ts +14 -0
  359. package/bundle/standalone/node_modules/kxta-core/dist/inference/index.d.ts.map +1 -0
  360. package/bundle/standalone/node_modules/kxta-core/dist/inference/index.js +15 -0
  361. package/bundle/standalone/node_modules/kxta-core/dist/inference/index.js.map +1 -0
  362. package/bundle/standalone/node_modules/kxta-core/dist/inference/runtime.d.ts +132 -0
  363. package/bundle/standalone/node_modules/kxta-core/dist/inference/runtime.d.ts.map +1 -0
  364. package/bundle/standalone/node_modules/kxta-core/dist/inference/runtime.js +311 -0
  365. package/bundle/standalone/node_modules/kxta-core/dist/inference/runtime.js.map +1 -0
  366. package/bundle/standalone/node_modules/kxta-core/dist/inference/types.d.ts +53 -0
  367. package/bundle/standalone/node_modules/kxta-core/dist/inference/types.d.ts.map +1 -0
  368. package/bundle/standalone/node_modules/kxta-core/dist/inference/types.js +6 -0
  369. package/bundle/standalone/node_modules/kxta-core/dist/inference/types.js.map +1 -0
  370. package/bundle/standalone/node_modules/kxta-core/dist/journal/distill.js +26 -10
  371. package/bundle/standalone/node_modules/kxta-core/dist/journal/distill.js.map +1 -1
  372. package/bundle/standalone/node_modules/kxta-core/dist/journal/event-triage.d.ts +31 -0
  373. package/bundle/standalone/node_modules/kxta-core/dist/journal/event-triage.d.ts.map +1 -0
  374. package/bundle/standalone/node_modules/kxta-core/dist/journal/event-triage.js +94 -0
  375. package/bundle/standalone/node_modules/kxta-core/dist/journal/event-triage.js.map +1 -0
  376. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/refactor.js +2 -2
  377. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/refactor.js.map +1 -1
  378. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tagging-pass.d.ts.map +1 -1
  379. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tagging-pass.js +5 -0
  380. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tagging-pass.js.map +1 -1
  381. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tool-classes.d.ts.map +1 -1
  382. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tool-classes.js +30 -5
  383. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tool-classes.js.map +1 -1
  384. package/bundle/standalone/node_modules/kxta-core/dist/journal/strict-mode.js +2 -2
  385. package/bundle/standalone/node_modules/kxta-core/dist/journal/topic-detector.d.ts +34 -0
  386. package/bundle/standalone/node_modules/kxta-core/dist/journal/topic-detector.d.ts.map +1 -1
  387. package/bundle/standalone/node_modules/kxta-core/dist/journal/topic-detector.js +251 -6
  388. package/bundle/standalone/node_modules/kxta-core/dist/journal/topic-detector.js.map +1 -1
  389. package/bundle/standalone/node_modules/kxta-core/dist/journal/types.d.ts +1 -0
  390. package/bundle/standalone/node_modules/kxta-core/dist/journal/types.d.ts.map +1 -1
  391. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/alerts.d.ts +8 -0
  392. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/alerts.d.ts.map +1 -0
  393. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/alerts.js +8 -0
  394. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/alerts.js.map +1 -0
  395. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/entry.d.ts +31 -0
  396. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/entry.d.ts.map +1 -0
  397. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/entry.js +55 -0
  398. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/entry.js.map +1 -0
  399. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/index.d.ts +10 -0
  400. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/index.d.ts.map +1 -0
  401. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/index.js +7 -0
  402. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/index.js.map +1 -0
  403. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/install.d.ts +46 -0
  404. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/install.d.ts.map +1 -0
  405. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/install.js +113 -0
  406. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/install.js.map +1 -0
  407. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/claude-code.d.ts +3 -0
  408. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/claude-code.d.ts.map +1 -0
  409. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/claude-code.js +115 -0
  410. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/claude-code.js.map +1 -0
  411. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/codex.d.ts +3 -0
  412. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/codex.d.ts.map +1 -0
  413. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/codex.js +76 -0
  414. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/codex.js.map +1 -0
  415. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/continue.d.ts +3 -0
  416. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/continue.d.ts.map +1 -0
  417. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/continue.js +64 -0
  418. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/continue.js.map +1 -0
  419. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/hermes.d.ts +3 -0
  420. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/hermes.d.ts.map +1 -0
  421. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/hermes.js +90 -0
  422. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/hermes.js.map +1 -0
  423. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/index.d.ts +3 -0
  424. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/index.d.ts.map +1 -0
  425. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/index.js +17 -0
  426. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/index.js.map +1 -0
  427. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/json-servers.d.ts +31 -0
  428. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/json-servers.d.ts.map +1 -0
  429. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/json-servers.js +136 -0
  430. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/installers/json-servers.js.map +1 -0
  431. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/rules.d.ts +5 -0
  432. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/rules.d.ts.map +1 -0
  433. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/rules.js +19 -0
  434. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/rules.js.map +1 -0
  435. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/tools.generated.d.ts +5 -0
  436. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/tools.generated.d.ts.map +1 -0
  437. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/tools.generated.js +62 -0
  438. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/tools.generated.js.map +1 -0
  439. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/types.d.ts +55 -0
  440. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/types.d.ts.map +1 -0
  441. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/types.js +2 -0
  442. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/types.js.map +1 -0
  443. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/write.d.ts +3 -0
  444. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/write.d.ts.map +1 -0
  445. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/write.js +25 -0
  446. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/write.js.map +1 -0
  447. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/yaml-config.d.ts +5 -0
  448. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/yaml-config.d.ts.map +1 -0
  449. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/yaml-config.js +17 -0
  450. package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/yaml-config.js.map +1 -0
  451. package/bundle/standalone/node_modules/kxta-core/dist/metadata/index.d.ts.map +1 -1
  452. package/bundle/standalone/node_modules/kxta-core/dist/metadata/index.js +12 -1
  453. package/bundle/standalone/node_modules/kxta-core/dist/metadata/index.js.map +1 -1
  454. package/bundle/standalone/node_modules/kxta-core/dist/project-map/index.js +1 -1
  455. package/bundle/standalone/node_modules/kxta-core/dist/rerank/arbitrator.d.ts +29 -0
  456. package/bundle/standalone/node_modules/kxta-core/dist/rerank/arbitrator.d.ts.map +1 -0
  457. package/bundle/standalone/node_modules/kxta-core/dist/rerank/arbitrator.js +68 -0
  458. package/bundle/standalone/node_modules/kxta-core/dist/rerank/arbitrator.js.map +1 -0
  459. package/bundle/standalone/node_modules/kxta-core/dist/rerank/engine.d.ts +57 -0
  460. package/bundle/standalone/node_modules/kxta-core/dist/rerank/engine.d.ts.map +1 -0
  461. package/bundle/standalone/node_modules/kxta-core/dist/rerank/engine.js +199 -0
  462. package/bundle/standalone/node_modules/kxta-core/dist/rerank/engine.js.map +1 -0
  463. package/bundle/standalone/node_modules/kxta-core/dist/rerank/index.d.ts +7 -0
  464. package/bundle/standalone/node_modules/kxta-core/dist/rerank/index.d.ts.map +1 -0
  465. package/bundle/standalone/node_modules/kxta-core/dist/rerank/index.js +8 -0
  466. package/bundle/standalone/node_modules/kxta-core/dist/rerank/index.js.map +1 -0
  467. package/bundle/standalone/node_modules/kxta-core/dist/rerank/types.d.ts +50 -0
  468. package/bundle/standalone/node_modules/kxta-core/dist/rerank/types.d.ts.map +1 -0
  469. package/bundle/standalone/node_modules/kxta-core/dist/rerank/types.js +2 -0
  470. package/bundle/standalone/node_modules/kxta-core/dist/rerank/types.js.map +1 -0
  471. package/bundle/standalone/node_modules/kxta-core/dist/types.d.ts +5 -0
  472. package/bundle/standalone/node_modules/kxta-core/dist/types.d.ts.map +1 -1
  473. package/bundle/standalone/node_modules/kxta-core/dist/util/paths.js +1 -1
  474. package/bundle/standalone/node_modules/kxta-core/package.json +7 -3
  475. package/bundle/standalone/node_modules/kxta-publish/package.json +3 -3
  476. package/bundle/standalone/package.json +3 -2
  477. package/dist/connect-AL5DTU3K.js +22 -0
  478. package/dist/index.js +7 -1
  479. package/dist/{start-RJVUJT4B.js → start-GP4ERBBP.js} +7 -0
  480. package/package.json +6 -2
  481. package/bundle/standalone/apps/web/.next/static/chunks/app/api/about/route-0cc6597bb67aea3b.js +0 -1
  482. package/bundle/standalone/apps/web/.next/static/chunks/app/api/agents/[id]/hooks/route-0cc6597bb67aea3b.js +0 -1
  483. package/bundle/standalone/apps/web/.next/static/chunks/app/api/agents/[id]/route-0cc6597bb67aea3b.js +0 -1
  484. package/bundle/standalone/apps/web/.next/static/chunks/app/api/agents/route-0cc6597bb67aea3b.js +0 -1
  485. package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/login/route-0cc6597bb67aea3b.js +0 -1
  486. package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/logout/route-0cc6597bb67aea3b.js +0 -1
  487. package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/setup/route-0cc6597bb67aea3b.js +0 -1
  488. package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/status/route-0cc6597bb67aea3b.js +0 -1
  489. package/bundle/standalone/apps/web/.next/static/chunks/app/api/auth/token/route-0cc6597bb67aea3b.js +0 -1
  490. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/conflicts/route-0cc6597bb67aea3b.js +0 -1
  491. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/entities/[id]/route-0cc6597bb67aea3b.js +0 -1
  492. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/entities/route-0cc6597bb67aea3b.js +0 -1
  493. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/events/[id]/route-0cc6597bb67aea3b.js +0 -1
  494. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/events/route-0cc6597bb67aea3b.js +0 -1
  495. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/ics/route-0cc6597bb67aea3b.js +0 -1
  496. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/links/route-0cc6597bb67aea3b.js +0 -1
  497. package/bundle/standalone/apps/web/.next/static/chunks/app/api/calendar/settings/route-0cc6597bb67aea3b.js +0 -1
  498. package/bundle/standalone/apps/web/.next/static/chunks/app/api/clip/route-0cc6597bb67aea3b.js +0 -1
  499. package/bundle/standalone/apps/web/.next/static/chunks/app/api/docker-config/route-0cc6597bb67aea3b.js +0 -1
  500. package/bundle/standalone/apps/web/.next/static/chunks/app/api/export/zip/route-0cc6597bb67aea3b.js +0 -1
  501. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/backlinks/route-0cc6597bb67aea3b.js +0 -1
  502. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/download/route-0cc6597bb67aea3b.js +0 -1
  503. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/export-html/route-0cc6597bb67aea3b.js +0 -1
  504. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/export-pdf/route-0cc6597bb67aea3b.js +0 -1
  505. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/history/restore/route-0cc6597bb67aea3b.js +0 -1
  506. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/history/route-0cc6597bb67aea3b.js +0 -1
  507. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/move/route-0cc6597bb67aea3b.js +0 -1
  508. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/[id]/route-0cc6597bb67aea3b.js +0 -1
  509. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/route-0cc6597bb67aea3b.js +0 -1
  510. package/bundle/standalone/apps/web/.next/static/chunks/app/api/files/upload/route-0cc6597bb67aea3b.js +0 -1
  511. package/bundle/standalone/apps/web/.next/static/chunks/app/api/folders/route-0cc6597bb67aea3b.js +0 -1
  512. package/bundle/standalone/apps/web/.next/static/chunks/app/api/git/remote/route-0cc6597bb67aea3b.js +0 -1
  513. package/bundle/standalone/apps/web/.next/static/chunks/app/api/git/sync-all/route-0cc6597bb67aea3b.js +0 -1
  514. package/bundle/standalone/apps/web/.next/static/chunks/app/api/hands/test-pattern/route-0cc6597bb67aea3b.js +0 -1
  515. package/bundle/standalone/apps/web/.next/static/chunks/app/api/hands/validate/route-0cc6597bb67aea3b.js +0 -1
  516. package/bundle/standalone/apps/web/.next/static/chunks/app/api/health/route-0cc6597bb67aea3b.js +0 -1
  517. package/bundle/standalone/apps/web/.next/static/chunks/app/api/install-snippets/route-0cc6597bb67aea3b.js +0 -1
  518. package/bundle/standalone/apps/web/.next/static/chunks/app/api/mcp-tools/route-0cc6597bb67aea3b.js +0 -1
  519. package/bundle/standalone/apps/web/.next/static/chunks/app/api/profile/route-0cc6597bb67aea3b.js +0 -1
  520. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/hands-config/route-0cc6597bb67aea3b.js +0 -1
  521. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/journal-config/route-0cc6597bb67aea3b.js +0 -1
  522. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/journal-status/route-0cc6597bb67aea3b.js +0 -1
  523. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/onboard/route-0cc6597bb67aea3b.js +0 -1
  524. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/refresh/route-0cc6597bb67aea3b.js +0 -1
  525. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/route-0cc6597bb67aea3b.js +0 -1
  526. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/[id]/sync/route-0cc6597bb67aea3b.js +0 -1
  527. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/onboard/route-0cc6597bb67aea3b.js +0 -1
  528. package/bundle/standalone/apps/web/.next/static/chunks/app/api/projects/route-0cc6597bb67aea3b.js +0 -1
  529. package/bundle/standalone/apps/web/.next/static/chunks/app/api/publish/html/route-0cc6597bb67aea3b.js +0 -1
  530. package/bundle/standalone/apps/web/.next/static/chunks/app/api/publish/route-0cc6597bb67aea3b.js +0 -1
  531. package/bundle/standalone/apps/web/.next/static/chunks/app/api/refresh/route-0cc6597bb67aea3b.js +0 -1
  532. package/bundle/standalone/apps/web/.next/static/chunks/app/api/reindex/route-0cc6597bb67aea3b.js +0 -1
  533. package/bundle/standalone/apps/web/.next/static/chunks/app/api/reports/resources/[name]/route-0cc6597bb67aea3b.js +0 -1
  534. package/bundle/standalone/apps/web/.next/static/chunks/app/api/search/route-0cc6597bb67aea3b.js +0 -1
  535. package/bundle/standalone/apps/web/.next/static/chunks/app/api/tags/route-0cc6597bb67aea3b.js +0 -1
  536. package/bundle/standalone/apps/web/.next/static/chunks/app/api/version-check/route-0cc6597bb67aea3b.js +0 -1
  537. package/bundle/standalone/apps/web/.next/static/chunks/app/api/welcome/route-0cc6597bb67aea3b.js +0 -1
  538. package/bundle/standalone/apps/web/.next/static/chunks/app/api/ws-config/route-0cc6597bb67aea3b.js +0 -1
  539. package/bundle/standalone/apps/web/.next/static/chunks/app/calendar/page-f9542f9f518f9257.js +0 -1
  540. package/bundle/standalone/apps/web/.next/static/chunks/app/page-19695d4fd9fa5c0a.js +0 -1
  541. package/bundle/standalone/apps/web/.next/static/chunks/app/preview/motifs/page-0cc6597bb67aea3b.js +0 -1
  542. /package/bundle/standalone/apps/web/.next/static/{KgyobLEcr42ig4jXUMcNO → olhhWqI4356zOu5Kz_S1K}/_buildManifest.js +0 -0
  543. /package/bundle/standalone/apps/web/.next/static/{KgyobLEcr42ig4jXUMcNO → olhhWqI4356zOu5Kz_S1K}/_ssgManifest.js +0 -0
@@ -2,7 +2,7 @@
2
2
  import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { z } from "zod";
5
- import { createFile, readFile, updateFile, deleteFile, listFiles, addTags, removeTags, setFavorite, search, FtsQueryError, registerProject, discoverFiles, refreshIndex, listTags, listProjects, syncBackup, bundleSearch, estimateTokensFromBuffer, clipUrl, ClipError, getHistory, getDiff, getDatabase, findRelated, whatsNew, projectMap, getTagsForFiles, restoreVersion, parseOutline, findSection, replaceSection, listProjectFolders, createFolder, deleteFolder, moveFile, detectAgentContextFiles, assertPathInside, syncAgentRules, checkAgentRulesStatus, RULE_BLOCK_VERSION, gracefulShutdown, startDistillEngine, writeResource, listResources, deleteResource, syncAgentRows, } from "kxta-core";
5
+ import { createFile, readFile, updateFile, deleteFile, listFiles, addTags, removeTags, setFavorite, search, FtsQueryError, registerProject, discoverFiles, refreshIndex, listTags, listProjects, syncBackup, bundleSearch, estimateTokensFromBuffer, clipUrl, ClipError, getHistory, getDiff, getDatabase, findRelated, whatsNew, projectMap, getTagsForFiles, restoreVersion, parseOutline, findSection, replaceSection, listProjectFolders, createFolder, deleteFolder, moveFile, detectAgentContextFiles, assertPathInside, syncAgentRules, checkAgentRulesStatus, RULE_BLOCK_VERSION, gracefulShutdown, startDistillEngine, writeResource, listResources, deleteResource, syncAgentRows, getAllStatuses, rerankCandidates, arbitrateCandidates, setInferenceDevice, setModelCacheDirOverride, rerankEngine, } from "kxta-core";
6
6
  import RE2Class from "./re2-compat.js";
7
7
  import { isAbsolute, join, relative, resolve, sep, dirname } from "node:path";
8
8
  import { statSync, lstatSync, openSync, readSync, closeSync, readFileSync, existsSync, realpathSync } from "node:fs";
@@ -13,6 +13,7 @@ import { buildSchemaDoc } from "./hands/schema-doc.js";
13
13
  import { formatExecResult } from "./hands/formatter.js";
14
14
  import { killAllActiveChildren } from "./hands/executor.js";
15
15
  import { initCapture, shutdownCapture, wrapHandler, startGitPoller, appendVoluntaryEvent, getCurrentAgent, getCurrentSid } from "./journal-capture.js";
16
+ import { refuseProjectDestination, refuseRepoFile, refuseProjectFolder } from "./repo-write-guard.js";
16
17
  import { registerJournalTools } from "./journal-tools.js";
17
18
  import { currentHooksBlock, enableAndInstallHooks } from "./hooks-block.js";
18
19
  import { registerCommitUpgradesTool } from "./journal-commit-upgrades-tool.js";
@@ -22,6 +23,44 @@ import { handleGetProfile } from "./profile-tool.js";
22
23
  import { getDataDir, profileRelPath, getEmptySections, listEvents, findConflicts, getEntity } from "kxta-core";
23
24
  const dataDir = getDataDir();
24
25
  const PROJECT_TOKEN_WARN_THRESHOLD = Number(process.env.KONTEXTA_PROJECT_TOKEN_WARN ?? 100_000);
26
+ let _kontextaConfigCache = null;
27
+ function readKontextaConfig() {
28
+ const now = Date.now();
29
+ if (_kontextaConfigCache && now - _kontextaConfigCache.ts < 5000) {
30
+ return _kontextaConfigCache.config;
31
+ }
32
+ const paths = [
33
+ `${getDataDir()}/kontexta.json`,
34
+ `${process.cwd()}/kontexta.json`,
35
+ ];
36
+ let config = {};
37
+ for (const p of paths) {
38
+ if (existsSync(p)) {
39
+ try {
40
+ config = JSON.parse(readFileSync(p, "utf8"));
41
+ break;
42
+ }
43
+ catch { }
44
+ }
45
+ }
46
+ _kontextaConfigCache = { config, ts: now };
47
+ return config;
48
+ }
49
+ /**
50
+ * Apply system1 device/cache_dir config to the inference runtime.
51
+ * Idempotent: safe to call on every read since the setters are cheap.
52
+ */
53
+ function applySystem1Config() {
54
+ const cfg = readKontextaConfig();
55
+ const device = cfg.system1?.device;
56
+ if (device) {
57
+ setInferenceDevice(device === "auto" ? null : device);
58
+ }
59
+ const cacheDir = cfg.system1?.cache_dir;
60
+ if (cacheDir) {
61
+ setModelCacheDirOverride(resolve(process.cwd(), cacheDir));
62
+ }
63
+ }
25
64
  function getAgentRulesWarning(projectId) {
26
65
  try {
27
66
  const db = getDatabase();
@@ -36,11 +75,11 @@ function getAgentRulesWarning(projectId) {
36
75
  else {
37
76
  projects = db.prepare("SELECT id, path, name FROM projects").all();
38
77
  }
39
- // Projects with zero detected context files have NEVER been onboarded —
78
+ // Projects with zero detected context files have NEVER been onboarded,
40
79
  // distinct from "outdated" (a file exists but predates the current
41
- // rulesVersion). Both need admin.onboard_agent, so both are surfaced
80
+ // rulesVersion). Both need admin_onboard_agent, so both are surfaced
42
81
  // here; without this, a project that skipped its one-shot
43
- // projects.register nudge would never get flagged again.
82
+ // projects_register nudge would never get flagged again.
44
83
  const missingProjects = [];
45
84
  const outdatedProjects = [];
46
85
  for (const p of projects) {
@@ -71,7 +110,7 @@ function getAgentRulesWarning(projectId) {
71
110
  }
72
111
  if (sentences.length === 0)
73
112
  return null;
74
- sentences.push("Run admin.onboard_agent to fix.");
113
+ sentences.push("Run admin_onboard_agent to fix.");
75
114
  return sentences.join(" ");
76
115
  }
77
116
  catch (e) {
@@ -164,11 +203,11 @@ if (!pkgVersionFound) {
164
203
  function resolveKindFolder({ destination, folder, kind, format, title }) {
165
204
  if (destination !== "knowledge") {
166
205
  // HTML reports only make sense in the KB's html/ bucket (see
167
- // resources.export_report) — silently allowing destination='project'
206
+ // resources_export_report): silently allowing destination='project'
168
207
  // here means a report lands inside the user's own repo instead, with
169
208
  // no error and no way to find it via the reports UI.
170
209
  if (format === "html") {
171
- return { error: "format='html' requires destination='knowledge' — HTML reports must live in the KB's html/ bucket, not a project or kontexta destination." };
210
+ return { error: "format='html' requires destination='knowledge', HTML reports must live in the KB's html/ bucket, not a project or kontexta destination." };
172
211
  }
173
212
  return { folder };
174
213
  }
@@ -181,7 +220,7 @@ function resolveKindFolder({ destination, folder, kind, format, title }) {
181
220
  }
182
221
  // HTML reports always live under html/, never nested inside
183
222
  // knowledge/dictionary or knowledge/notes (layout.ts requires .md
184
- // there). `kind` doesn't apply — content_class for html/ paths is
223
+ // there). `kind` doesn't apply: content_class for html/ paths is
185
224
  // inferred as "note" from the path alone (see computeContentClass).
186
225
  if (format === "html") {
187
226
  const alreadyHtmlScoped = norm === "html" || norm.startsWith("html/");
@@ -191,14 +230,14 @@ function resolveKindFolder({ destination, folder, kind, format, title }) {
191
230
  // (layout.ts), so an unrouted .mmd file would always fail at write
192
231
  // time. Unlike html, mermaid diagrams committed inside a project's own
193
232
  // repo are a legitimate use case, so this only applies to destination
194
- // === "knowledge" — no destination restriction like html has.
233
+ // === "knowledge": no destination restriction like html has.
195
234
  if (format === "mmd") {
196
235
  const alreadyMermaidScoped = norm === "mermaid" || norm.startsWith("mermaid/");
197
236
  return { folder: alreadyMermaidScoped ? folder : (norm ? `mermaid/${norm}` : "mermaid") };
198
237
  }
199
238
  if (!kind)
200
239
  return { error: "kind is required for destination='knowledge': must be 'dictionary' or 'note'" };
201
- // Non-KB buckets (html/mermaid) also skip rewrite — their layout forbids nesting under knowledge/.
240
+ // Non-KB buckets (html/mermaid) also skip rewrite: their layout forbids nesting under knowledge/.
202
241
  const CLASS_PREFIXES = ["knowledge/dictionary", "knowledge/notes", "knowledge/urlclips", "journal", "html", "mermaid"];
203
242
  const alreadyClassScoped = CLASS_PREFIXES.some((p) => norm === p || norm.startsWith(p + "/"));
204
243
  if (alreadyClassScoped) {
@@ -206,14 +245,14 @@ function resolveKindFolder({ destination, folder, kind, format, title }) {
206
245
  const impliedNote = norm.startsWith("knowledge/notes");
207
246
  const impliedClass = impliedDict ? "dictionary" : impliedNote ? "note" : null;
208
247
  if (impliedClass && impliedClass !== kind) {
209
- return { folder, warning: `kind='${kind}' but folder targets '${impliedClass}' tree — path wins; content_class will be '${impliedClass}'.` };
248
+ return { folder, warning: `kind='${kind}' but folder targets '${impliedClass}' tree, path wins; content_class will be '${impliedClass}'.` };
210
249
  }
211
250
  return { folder };
212
251
  }
213
252
  const classRoot = kind === "dictionary" ? "knowledge/dictionary" : "knowledge/notes";
214
253
  return { folder: norm ? `${classRoot}/${norm}` : classRoot };
215
254
  }
216
- // Format as UTC — server/user timezone divergence would silently mislead otherwise.
255
+ // Format as UTC: server/user timezone divergence would silently mislead otherwise.
217
256
  function fmtWhen(iso) {
218
257
  const d = new Date(iso);
219
258
  if (isNaN(d.getTime()))
@@ -249,7 +288,7 @@ function buildCalendarSection(now) {
249
288
  lines.push("");
250
289
  lines.push(`⚠️ CONFLICTS (${conflicts.length})`);
251
290
  for (const c of conflicts.slice(0, 5)) {
252
- lines.push(` ${c.kind}: "${c.event_a.title}" (${entityName(c.event_a.entity_id)}) vs "${c.event_b.title}" (${entityName(c.event_b.entity_id)}) — ${c.reason}`);
291
+ lines.push(` ${c.kind}: "${c.event_a.title}" (${entityName(c.event_a.entity_id)}) vs "${c.event_b.title}" (${entityName(c.event_b.entity_id)}), ${c.reason}`);
253
292
  }
254
293
  }
255
294
  return lines.join("\n");
@@ -281,17 +320,17 @@ function loadProfileInstructions() {
281
320
  const profileExists = existsSync(path);
282
321
  const content = profileExists ? readFileSync(path, "utf8").trim() : "";
283
322
  const empty = profileExists ? getEmptySections(content) : [];
284
- const header = `👋 Kontexta welcome — ${today}\n\n` +
285
- `This is the user's session context. Read and honor it for the rest of this session — especially "Session coding style" (comment style, git etiquette, review-before-push) and "Team members and roles" (who's who when writing updates or referencing people).`;
323
+ const header = `👋 Kontexta welcome: ${today}\n\n` +
324
+ `This is the user's session context. Read and honor it for the rest of this session: especially "Session coding style" (comment style, git etiquette, review-before-push) and "Team members and roles" (who's who when writing updates or referencing people).`;
286
325
  const profileBlock = profileExists && content
287
326
  ? `📋 PROFILE (knowledge/profile.md)\n${content}`
288
- : `📋 PROFILE\n (not set up yet — nudge the user to fill it in at knowledge/profile.md or the dashboard's profile pane)`;
327
+ : `📋 PROFILE\n (not set up yet, nudge the user to fill it in at knowledge/profile.md or the dashboard's profile pane)`;
289
328
  const calendarBlock = buildCalendarSection(now);
290
329
  const freshness = profileExists ? profileFreshnessNote(path, empty) : "";
291
- // Recurring nudge — projects.register's onboarding prompt fires once, at
330
+ // Recurring nudge: projects_register's onboarding prompt fires once, at
292
331
  // register time; if the calling agent doesn't relay it in the moment
293
332
  // there was previously no second chance to see it. Surfacing it here
294
- // means it comes back every session until admin.onboard_agent is run.
333
+ // means it comes back every session until admin_onboard_agent is run.
295
334
  const rulesWarning = getAgentRulesWarning();
296
335
  const rulesBlock = rulesWarning ? `\n⚠️ ${rulesWarning}` : "";
297
336
  const hooksNudge = currentHooksBlock(pkgVersion)?.prompt;
@@ -299,7 +338,7 @@ function loadProfileInstructions() {
299
338
  return [header, "", profileBlock, "", calendarBlock, freshness, rulesBlock, hooksLine].filter(Boolean).join("\n");
300
339
  }
301
340
  const server = new McpServer({ name: "kontexta", version: pkgVersion }, { instructions: loadProfileInstructions() });
302
- server.tool("admin.refresh_session_context", "Re-read the session context (profile, upcoming events within 7d, conflicts, freshness nudge) as it stands NOW. Call this when the user just edited their profile or added/moved calendar events and you want the current picture instead of the snapshot taken at session start. Read-only; no side effects. Returns the same block Kontexta sent as MCP instructions at session start.", {}, async () => ({
341
+ server.tool("admin_refresh_session_context", "Re-read the session context (profile, upcoming events within 7d, conflicts, freshness nudge) as it stands NOW. Call this when the user just edited their profile or added/moved calendar events and you want the current picture instead of the snapshot taken at session start. Read-only; no side effects. Returns the same block Kontexta sent as MCP instructions at session start.", {}, async () => ({
303
342
  content: [{ type: "text", text: loadProfileInstructions() ?? "(no session context available)" }],
304
343
  }));
305
344
  const handsRegistry = new HandsRegistry(server);
@@ -357,12 +396,12 @@ process.on("SIGTERM", () => { if (!_shutdownInFlight) {
357
396
  _shutdownInFlight = true;
358
397
  void handleShutdownSignal("SIGTERM");
359
398
  } });
360
- // Auto-wrap every tool registration that follows. journal.write is excluded
361
- // because the auto-wrap re-enters journal recording, and journal.write itself
362
- // records journal events — including it would loop.
399
+ // Auto-wrap every tool registration that follows. journal_write is excluded
400
+ // because the auto-wrap re-enters journal recording, and journal_write itself
401
+ // records journal events: including it would loop.
363
402
  const _origServerTool = server.tool.bind(server);
364
403
  server.tool = function (name, ...rest) {
365
- if (name === "journal.write") {
404
+ if (name === "journal_write") {
366
405
  return _origServerTool(name, ...rest);
367
406
  }
368
407
  const handler = rest[rest.length - 1];
@@ -372,8 +411,8 @@ server.tool = function (name, ...rest) {
372
411
  return _origServerTool(name, ...rest);
373
412
  };
374
413
  // Excluded from wrapHandler (see above) so it does NOT get the
375
- // journal-backlog envelope injected — it IS the journal write path.
376
- server.tool("journal.write", "Write one event to the current project's journal. `kind: 'append'` = timestamped entry in today's daily journal file in the Knowledge Base (creates the file if it doesn't exist; both calls on the same calendar day return the same file_id; returns `{file_id}`). `kind: 'note'` = free-form decision/abandonment/observation, stored as an `agent_note` event in Layer 1 (surfaces in distilled task entries; returns `{ok, recorded_at}`). `kind: 'intent'` = topic/intent pivot — use when the user redirects what you're working on so the distillation step splits task buckets correctly (returns `{ok, recorded_at}`). Required fields depend on `kind`: 'append'/'note' need `text`; 'intent' needs `summary`.", {
414
+ // journal-backlog envelope injected: it IS the journal write path.
415
+ server.tool("journal_write", "Write one event to the current project's journal. `kind: 'append'` = timestamped entry in today's daily journal file in the Knowledge Base (creates the file if it doesn't exist; both calls on the same calendar day return the same file_id; returns `{file_id}`). `kind: 'note'` = free-form decision/abandonment/observation, stored as an `agent_note` event in Layer 1 (surfaces in distilled task entries; returns `{ok, recorded_at}`). `kind: 'intent'` = topic/intent pivot, use when the user redirects what you're working on so the distillation step splits task buckets correctly (returns `{ok, recorded_at}`). Required fields depend on `kind`: 'append'/'note' need `text`; 'intent' needs `summary`.", {
377
416
  kind: z.enum(["append", "note", "intent"]).describe("Event kind. Selects which body fields are required and how the event is stored."),
378
417
  text: z.string().optional().describe("Required for kind='append' or kind='note'. Body of the entry."),
379
418
  summary: z.string().optional().describe("Required for kind='intent'. One-line summary of the new intent."),
@@ -408,7 +447,7 @@ server.tool("journal.write", "Write one event to the current project's journal.
408
447
  else {
409
448
  // Create a new daily journal file.
410
449
  const timestamp = new Date().toISOString().replace("T", " ").slice(0, 19);
411
- const content = `# Journal — ${today}\n\n---\n**${timestamp}** ${text}\n`;
450
+ const content = `# Journal: ${today}\n\n---\n**${timestamp}** ${text}\n`;
412
451
  const result = await createFile({
413
452
  title,
414
453
  content,
@@ -457,7 +496,7 @@ server.tool("journal.write", "Write one event to the current project's journal.
457
496
  appendVoluntaryEvent(ev);
458
497
  return { content: [{ type: "text", text: JSON.stringify({ ok: true, recorded_at: ev.ts }) }] };
459
498
  });
460
- server.tool("files.create", "Create one or more markdown, mermaid, or HTML files in the knowledge base or project (up to 200 per call). Pass a single-element `files` array for the one-file case. This operation writes each file to disk and adds it to the local SQLite FTS5 index. Destination can be 'knowledge' (global KB), 'project' (reference file inside a project repo), or 'kontexta' (internal Kontexta schema file). If destination is 'project' or 'kontexta', project_id is strictly required. If destination is 'knowledge', 'kind' is strictly required for md files — pick 'dictionary' (authoritative source-of-truth) or 'note' (informational snapshot); see the kind param for the rubric. No external auth required. Rate limits do not apply (local operation). Per-item failures are isolated to `errors[]` — the rest of the batch still commits; a single-item call still reports its failure the same way. Returns `{created_count, error_count, created, errors}`. If a destination directory does not exist, it will be created automatically. To modify an existing file, use 'files.update' instead. Pass format='mmd' on an item to create a Mermaid diagram file (.mmd) — for destination='knowledge' it's auto-routed to the KB's `mermaid/` bucket (`kind` ignored, not required); for destination='project' it's written wherever `folder` says, same as any project file. Pass format='html' for an HTML report — `destination` MUST be 'knowledge' (html reports are auto-routed to the KB's `html/` bucket; `kind` is ignored and not required for html). Format defaults to 'md'.", {
499
+ server.tool("files_create", "Create one or more markdown, mermaid, or HTML files in the knowledge base or project (up to 200 per call). Pass a single-element `files` array for the one-file case. This operation writes each file to disk and adds it to the local SQLite FTS5 index. Destination is 'knowledge' (global KB) or 'kontexta' (internal Kontexta schema file, project_id required). 'project' is REFUSED: nothing created through kxta is written into a project repo. If destination is 'knowledge', 'kind' is strictly required for md files, pick 'dictionary' (authoritative source-of-truth) or 'note' (informational snapshot); see the kind param for the rubric. No external auth required. Rate limits do not apply (local operation). Per-item failures are isolated to `errors[]`, the rest of the batch still commits; a single-item call still reports its failure the same way. Returns `{created_count, error_count, created, errors}`. If a destination directory does not exist, it will be created automatically. To modify an existing file, use 'files_update' instead. Pass format='mmd' on an item to create a Mermaid diagram file (.mmd), for destination='knowledge' it's auto-routed to the KB's `mermaid/` bucket (`kind` ignored, not required); Pass format='html' for an HTML report, `destination` MUST be 'knowledge' (html reports are auto-routed to the KB's `html/` bucket; `kind` is ignored and not required for html). Format defaults to 'md'.", {
461
500
  files: z
462
501
  .array(z.object({
463
502
  title: z.string().describe("Title of the file"),
@@ -479,6 +518,11 @@ server.tool("files.create", "Create one or more markdown, mermaid, or HTML files
479
518
  for (let i = 0; i < files.length; i++) {
480
519
  const f = files[i];
481
520
  try {
521
+ const refusal = refuseProjectDestination(f.destination);
522
+ if (refusal) {
523
+ errors.push({ index: i, title: f.title, error: refusal });
524
+ continue;
525
+ }
482
526
  const resolved = resolveKindFolder({ destination: f.destination, folder: f.folder, kind: f.kind, format: f.format, title: f.title });
483
527
  if ("error" in resolved) {
484
528
  errors.push({ index: i, title: f.title, error: resolved.error });
@@ -512,22 +556,22 @@ server.tool("files.create", "Create one or more markdown, mermaid, or HTML files
512
556
  ],
513
557
  };
514
558
  });
515
- server.tool("resources.add_report", "Write an image or other binary resource into the shared reports/resources/ folder. Returns { filename, size, src, url } — embed the report's <img>/<a> tags with `src` exactly as given (e.g. `<img src=\"resources/chart.png\">`); it is the only form that resolves correctly both in the dashboard viewer and in PDF/PNG export. Do not use `url` inside report HTML — it only works in the dashboard. Bytes are passed base64-encoded.", {
559
+ server.tool("resources_add_report", "Write an image or other binary resource into the shared reports/resources/ folder. Returns { filename, size, src, url }: embed the report's <img>/<a> tags with `src` exactly as given (e.g. `<img src=\"resources/chart.png\">`); it is the only form that resolves correctly both in the dashboard viewer and in PDF/PNG export. Do not use `url` inside report HTML: it only works in the dashboard. Bytes are passed base64-encoded.", {
516
560
  filename: z.string().describe("Requested filename with extension"),
517
561
  bytes_base64: z.string().describe("Base64-encoded file bytes"),
518
562
  }, async ({ filename, bytes_base64 }) => {
519
563
  const info = writeResource(dataDir, filename, Buffer.from(bytes_base64, "base64"));
520
564
  return { content: [{ type: "text", text: JSON.stringify(info, null, 2) }] };
521
565
  });
522
- server.tool("resources.list_reports", "List all files currently stored under reports/resources/. Returns filename, size in bytes, and served URL.", {}, async () => {
566
+ server.tool("resources_list_reports", "List all files currently stored under reports/resources/. Returns filename, size in bytes, and served URL.", {}, async () => {
523
567
  const items = listResources(dataDir);
524
568
  return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
525
569
  });
526
- server.tool("resources.delete_report", "Delete a file from reports/resources/. No-op if it doesn't exist.", { filename: z.string().describe("Filename (relative) of the resource to delete from reports/resources/.") }, async ({ filename }) => {
570
+ server.tool("resources_delete_report", "Delete a file from reports/resources/. No-op if it doesn't exist.", { filename: z.string().describe("Filename (relative) of the resource to delete from reports/resources/.") }, async ({ filename }) => {
527
571
  deleteResource(dataDir, filename);
528
572
  return { content: [{ type: "text", text: JSON.stringify({ ok: true, filename }, null, 2) }] };
529
573
  });
530
- server.tool("resources.export_report", "Export an existing HTML report as PDF or PNG. Returns { url } for the web-served download (requires an authenticated dashboard request) by default. Set inline_bytes=true to render in-process and get { bytes_base64 } instead — only available when running via the full `kontexta` CLI, not the standalone kontexta-mcp package; falls back to { url } with a note if unavailable.", {
574
+ server.tool("resources_export_report", "Export an existing HTML report as PDF or PNG. Returns { url } for the web-served download (requires an authenticated dashboard request) by default. Set inline_bytes=true to render in-process and get { bytes_base64 } instead: only available when running via the full `kontexta` CLI, not the standalone kontexta-mcp package; falls back to { url } with a note if unavailable.", {
531
575
  id: z.number().describe("File ID of the HTML report to export."),
532
576
  format: z.enum(["pdf", "png"]).default("pdf").describe("Output format: 'pdf' or 'png'."),
533
577
  inline_bytes: z.boolean().optional().default(false).describe("If true, render in-process and return raw bytes (base64). Only available in the full kontexta CLI bundle; falls back to {url} otherwise."),
@@ -537,7 +581,7 @@ server.tool("resources.export_report", "Export an existing HTML report as PDF or
537
581
  return { content: [{ type: "text", text: JSON.stringify({ url }, null, 2) }] };
538
582
  try {
539
583
  const { readFile } = await import("kxta-core");
540
- // kxta-publish is intentionally undeclared here (private/workspace-only) — only resolves under the bundled `kontexta` CLI; the catch below covers the standalone package.
584
+ // kxta-publish is intentionally undeclared here (private/workspace-only): only resolves under the bundled `kontexta` CLI; the catch below covers the standalone package.
541
585
  const mod = await import("kxta-publish/render/html-export");
542
586
  const { join } = await import("node:path");
543
587
  const f = readFile(id);
@@ -550,7 +594,7 @@ server.tool("resources.export_report", "Export an existing HTML report as PDF or
550
594
  return { content: [{ type: "text", text: JSON.stringify({ url, note: `inline_bytes unavailable in this install: ${e?.message ?? String(e)}` }, null, 2) }] };
551
595
  }
552
596
  });
553
- server.tool("files.read", "Read one or more files, in full or in part. Modes: single-by-id (`id`), single-by-path (`path`, absolute on-disk path — must be exactly as indexed), batch-by-id (`ids`, up to 200), partial-by-heading (`id`+`section`), partial-by-line-range (`id`+`lines`). Exactly one of `id`/`path`/`ids` is required. `section` and `lines` are mutually exclusive and only valid with `id` (not `ids` or `path`). Read-only; no side effects, auth, or rate limits. Response shape: a single file object (with `content`, tags, est_tokens) for `id`/`path`; a partial-content object for `section`/`lines`; `{files, total_est_tokens, error_count, errors}` for `ids` (per-ID failures isolated, batch never partial-throws). Prefer `files.describe` to inspect without paying body tokens.", {
597
+ server.tool("files_read", "Read one or more files, in full or in part. Modes: single-by-id (`id`), single-by-path (`path`, absolute on-disk path, must be exactly as indexed), batch-by-id (`ids`, up to 200), partial-by-heading (`id`+`section`), partial-by-line-range (`id`+`lines`). Exactly one of `id`/`path`/`ids` is required. `section` and `lines` are mutually exclusive and only valid with `id` (not `ids` or `path`). Read-only; no side effects, auth, or rate limits. Response shape: a single file object (with `content`, tags, est_tokens) for `id`/`path`; a partial-content object for `section`/`lines`; `{files, total_est_tokens, error_count, errors}` for `ids` (per-ID failures isolated, batch never partial-throws). Prefer `files_describe` to inspect without paying body tokens.", {
554
598
  id: z.number().int().positive().optional().describe("Single file by ID."),
555
599
  path: z.string().optional().describe("Single file by absolute on-disk path (must match exactly what Kontexta indexed)."),
556
600
  ids: z.array(z.number()).min(1).max(200).optional().describe("Batch mode: multiple file IDs (max 200 per call); returns an array plus aggregate token cost."),
@@ -647,7 +691,7 @@ server.tool("files.read", "Read one or more files, in full or in part. Modes: si
647
691
  };
648
692
  }
649
693
  });
650
- server.tool("files.describe", "Return everything ABOUT a file without pulling its content (no token cost from the body). Tags, size, est_tokens, history depth, related-file ids, backlinks, project, folder, last edited. Operates locally with no auth or rate limits. Use this when you'd otherwise chain files.read + tags.list + files.get_history + files.find_related just to decide whether to actually read the file. Parameters: 'id' must be a valid integer file ID.", {
694
+ server.tool("files_describe", "Return everything ABOUT a file without pulling its content (no token cost from the body). Tags, size, est_tokens, history depth, related-file ids, backlinks, project, folder, last edited. Operates locally with no auth or rate limits. Use this when you'd otherwise chain files_read + tags_list + files_get_history + files_find_related just to decide whether to actually read the file. Parameters: 'id' must be a valid integer file ID.", {
651
695
  id: z.number().describe("File ID"),
652
696
  }, async ({ id }) => {
653
697
  try {
@@ -767,7 +811,7 @@ server.tool("files.describe", "Return everything ABOUT a file without pulling it
767
811
  };
768
812
  }
769
813
  });
770
- server.tool("files.regex_search", "Match a JS regex against file bodies. Default mode scans every file in scope (project, KB, or all) and returns per-file hits with line numbers — slower than FTS `files.search` because it reads each file's content; use only when FTS misses substrings, URLs, or code identifiers. Pass `file_id` to instead scan just that one file (catches what FTS misses within a single known file); response shape changes to `{file_id, path, pattern, match_count, truncated, matches}`. Read-only; no side effects, auth, or rate limits. Multi-file mode capped at 500 files / 10 hits per file by default (`files_truncated` reports the cap); single-file mode capped at 100 hits by default, max 500. `project_id`/`kind` are ignored when `file_id` is set. Invalid regex throws.", {
814
+ server.tool("files_regex_search", "Match a JS regex against file bodies. Default mode scans every file in scope (project, KB, or all) and returns per-file hits with line numbers: slower than FTS `files_search` because it reads each file's content; use only when FTS misses substrings, URLs, or code identifiers. Pass `file_id` to instead scan just that one file (catches what FTS misses within a single known file); response shape changes to `{file_id, path, pattern, match_count, truncated, matches}`. Read-only; no side effects, auth, or rate limits. Multi-file mode capped at 500 files / 10 hits per file by default (`files_truncated` reports the cap); single-file mode capped at 100 hits by default, max 500. `project_id`/`kind` are ignored when `file_id` is set. Invalid regex throws.", {
771
815
  pattern: z.string().describe("JavaScript RegExp source"),
772
816
  file_id: z.number().optional().describe("Scan only this file instead of every file in scope. When set, `project_id`/`kind`/`max_files`/`max_matches_per_file` are ignored in favor of `max_matches`."),
773
817
  project_id: z.number().nullable().optional().describe("Scope to one project, null for KB-only, omit for everything. Ignored when `file_id` is set."),
@@ -881,16 +925,19 @@ server.tool("files.regex_search", "Match a JS regex against file bodies. Default
881
925
  };
882
926
  }
883
927
  });
884
- server.tool("files.update", "Rewrite a file. Default = full-body replacement: `content` becomes the entire file, triggering disk write + FTS5 re-index. Pass `section` to instead rewrite ONLY that heading's body (case-insensitive exact-string after trim; the heading line itself is preserved, siblings untouched) — saves context budget vs resending the whole file. Throws if `section` is set but the heading doesn't exist (this mode will NOT create a new section — append the section text via a full-body update first). Operates locally with no external auth or rate limits. Returns the updated file metadata including new estimated token counts.", {
928
+ server.tool("files_update", "Rewrite a KB file (project-repo files are refused: kxta never writes into a repo). Default = full-body replacement: `content` becomes the entire file, triggering disk write + FTS5 re-index. Pass `section` to instead rewrite ONLY that heading's body (case-insensitive exact-string after trim; the heading line itself is preserved, siblings untouched), saves context budget vs resending the whole file. Throws if `section` is set but the heading doesn't exist (this mode will NOT create a new section, append the section text via a full-body update first). Operates locally with no external auth or rate limits. Returns the updated file metadata including new estimated token counts.", {
885
929
  id: z.number().describe("File ID"),
886
930
  content: z.string().describe("New content. With `section` set, this replaces just that heading's body; otherwise it becomes the entire file body."),
887
931
  section: z.string().optional().describe("Case-insensitive exact-string heading. When set, only this heading's body is rewritten instead of the whole file."),
888
932
  }, async ({ id, content, section }) => {
889
933
  try {
934
+ const target = readFile(id);
935
+ const refusal = refuseRepoFile(target);
936
+ if (refusal)
937
+ throw new Error(refusal);
890
938
  let newBody = content;
891
939
  if (section !== undefined) {
892
- const file = readFile(id);
893
- newBody = replaceSection(file.content, section, content);
940
+ newBody = replaceSection(target.content, section, content);
894
941
  }
895
942
  const result = await updateFile(id, newBody, dataDir);
896
943
  return {
@@ -904,7 +951,7 @@ server.tool("files.update", "Rewrite a file. Default = full-body replacement: `c
904
951
  };
905
952
  }
906
953
  });
907
- server.tool("files.delete", "DESTRUCTIVE. Permanently delete one or more files by ID (up to 500 per call). Pass a single-element `ids` array for the one-file case. KB files are unlinked from disk AND removed from the FTS5 index; project reference files only have their index entry removed (the file on disk is left alone so the watcher does not fight your editor). Not idempotent — deleting an unknown ID surfaces as a per-item error. No external auth or rate limits. Per-ID failures are isolated to `errors[]` and the rest of the batch still commits — partial success is the norm, always inspect `error_count`. Returns `{deleted_count, error_count, deleted, errors}`. Use only when the file is truly obsolete; to deprioritise without losing data, untag (`tags.remove`) or unfavorite (`tags.set_favorite`) instead. To preview the set before deleting, run `files.list` with the same filter and confirm the IDs.", {
954
+ server.tool("files_delete", "DESTRUCTIVE. Permanently delete one or more files by ID (up to 500 per call). Pass a single-element `ids` array for the one-file case. KB files are unlinked from disk AND removed from the FTS5 index; project reference files only have their index entry removed (the file on disk is left alone so the watcher does not fight your editor). Not idempotent: deleting an unknown ID surfaces as a per-item error. No external auth or rate limits. Per-ID failures are isolated to `errors[]` and the rest of the batch still commits: partial success is the norm, always inspect `error_count`. Returns `{deleted_count, error_count, deleted, errors}`. Use only when the file is truly obsolete; to deprioritise without losing data, untag (`tags_remove`) or unfavorite (`tags_set_favorite`) instead. To preview the set before deleting, run `files_list` with the same filter and confirm the IDs.", {
908
955
  ids: z.array(z.number()).min(1).max(500).describe("File IDs to delete. Single-element array = one-file case. Max 500 per call."),
909
956
  }, async ({ ids }) => {
910
957
  const deleted = [];
@@ -927,7 +974,7 @@ server.tool("files.delete", "DESTRUCTIVE. Permanently delete one or more files b
927
974
  ],
928
975
  };
929
976
  });
930
- server.tool("files.list", "List file metadata with optional filters (project_id, tag, favorite, folder, untagged, kind) and pagination. Read-only; no side effects, auth, or rate limits. Each row is annotated with tags, est_tokens, size_bytes, and content_class; the response includes `total_est_tokens` so you can budget before reading bodies. `project_id: null` returns ONLY Knowledge Base files; omit the field to span everything; `kind` narrows to one content class. Use to browse known structure; for keyword/content lookup use `files.search`; for a denser whole-vault dump use `projects.map`.", {
977
+ server.tool("files_list", "List file metadata with optional filters (project_id, tag, favorite, folder, untagged, kind) and pagination. Read-only; no side effects, auth, or rate limits. Each row is annotated with tags, est_tokens, size_bytes, and content_class; the response includes `total_est_tokens` so you can budget before reading bodies. `project_id: null` returns ONLY Knowledge Base files; omit the field to span everything; `kind` narrows to one content class. Use to browse known structure; for keyword/content lookup use `files_search`; for a denser whole-vault dump use `projects_map`.", {
931
978
  project_id: z.number().nullable().optional().describe("Filter by project ID. Pass null to list ONLY Knowledge Base files (project_id IS NULL)."),
932
979
  tag: z.string().optional().describe("Filter by tag name"),
933
980
  favorite: z.boolean().optional().describe("Filter by favorite status"),
@@ -962,7 +1009,7 @@ server.tool("files.list", "List file metadata with optional filters (project_id,
962
1009
  content: [{ type: "text", text: JSON.stringify({ files: annotated, total_est_tokens }, null, 2) }],
963
1010
  };
964
1011
  });
965
- server.tool("files.search", "Full-text (SQLite FTS5) keyword search across files. Default mode returns ranked matches with inline match_excerpt and title_highlight (no follow-up `files.read` needed for snippets) plus tags, est_tokens, size_bytes, content_class, and aggregate `total_est_tokens`. Pass `include_bodies: true` to instead get a single prompt-ready bundle: matched bodies concatenated into XML `<document>` blocks or markdown headers + fences (see `format`/`max_tokens`), capped at the token budget — files are added in rank order until the next would exceed it, the rest going to `meta.skipped[]`. Use `include_bodies` instead of `files.search` + N×`files.read` when you need several related files as one context blob. Read-only; no side effects, auth, or rate limits. Ordering: dictionary hits sort above everything else for the same query (dictionary-wins on conflict), then BM25 rank. FTS is tokenised: it WILL miss URLs, hyphenated terms, and partial substrings — fall back to `files.regex_search` for those. `project_id: null` searches only the KB; omit the field to span everything; `tags[]` requires ALL listed tags to match; `kind` narrows to one content class.", {
1012
+ server.tool("files_search", "Full-text (SQLite FTS5) keyword search across files. Default mode returns ranked matches with inline match_excerpt and title_highlight (no follow-up `files_read` needed for snippets) plus tags, est_tokens, size_bytes, content_class, and aggregate `total_est_tokens`. Pass `include_bodies: true` to instead get a single prompt-ready bundle: matched bodies concatenated into XML `<document>` blocks or markdown headers + fences (see `format`/`max_tokens`), capped at the token budget, files are added in rank order until the next would exceed it, the rest going to `meta.skipped[]`. Use `include_bodies` instead of `files_search` + N×`files_read` when you need several related files as one context blob. Read-only; no side effects, auth, or rate limits. Ordering: dictionary hits sort above everything else for the same query (dictionary-wins on conflict), then BM25 rank. FTS is tokenised: it WILL miss URLs, hyphenated terms, and partial substrings, fall back to `files_regex_search` for those. `project_id: null` searches only the KB; omit the field to span everything; `tags[]` requires ALL listed tags to match; `kind` narrows to one content class.", {
966
1013
  query: z.string().describe("Search query"),
967
1014
  project_id: z.number().nullable().optional().describe("Filter by project ID. Pass null to search ONLY Knowledge Base files."),
968
1015
  tags: z.array(z.string()).optional().describe("Filter by tags (all must match)"),
@@ -971,8 +1018,10 @@ server.tool("files.search", "Full-text (SQLite FTS5) keyword search across files
971
1018
  .describe("Filter by content class. dictionary = authoritative KB (system IDs, mappings, glossaries), note = informational KB, journal = time-log, project = project file. Omit to see all classes with dictionary-first ordering."),
972
1019
  include_bodies: z.boolean().optional().describe("If true, return a single prompt-ready bundle of matched bodies instead of a match list. Response shape changes to `{bundle, meta: {included, skipped, ...}}`. Default false."),
973
1020
  format: z.enum(["xml", "markdown"]).optional().describe("Bundle format when `include_bodies` is true. xml = Anthropic-recommended <document> tags (default); markdown = ## headers + fenced blocks. Ignored otherwise."),
974
- max_tokens: z.number().int().positive().optional().describe("Token budget when `include_bodies` is true (default 50000). Files added in rank order until the next would exceed; remainder go to `meta.skipped[]`. Ignored otherwise."),
975
- }, async ({ query, project_id, tags, favorite, kind, include_bodies, format, max_tokens }) => {
1021
+ max_tokens: z.number().int().positive().optional().describe("Token budget when `include_bodies` is true (default 12000). Files added in rank order until the next would exceed; remainder go to `meta.skipped[]`. Ignored otherwise."),
1022
+ rerank: z.boolean().optional().describe("When true, rerank search matches using local cross-encoder neural model and soft content-class arbitration. Defaults to kontexta.json search.rerank.enabled (or true if model available)."),
1023
+ check_sufficiency: z.boolean().optional().describe("When include_bodies is true, evaluate retrieval sufficiency with non-autoregressive decision model. Default true."),
1024
+ }, async ({ query, project_id, tags, favorite, kind, include_bodies, format, max_tokens, rerank, check_sufficiency }) => {
976
1025
  const filters = { query };
977
1026
  if (project_id !== undefined)
978
1027
  filters.project_id = project_id;
@@ -982,10 +1031,30 @@ server.tool("files.search", "Full-text (SQLite FTS5) keyword search across files
982
1031
  filters.favorite = favorite;
983
1032
  if (kind !== undefined)
984
1033
  filters.content_class = kind;
1034
+ const cfg = readKontextaConfig();
1035
+ applySystem1Config();
1036
+ const shouldRerank = rerank ?? cfg.search?.rerank?.enabled ?? true;
1037
+ const shouldCheckSufficiency = check_sufficiency ?? cfg.search?.verdicts?.sufficiency_check ?? true;
1038
+ const candidateLimit = cfg.search?.rerank?.candidate_limit ?? 30;
1039
+ const dictionaryBoost = cfg.search?.rerank?.dictionary_boost;
1040
+ const relevanceFloor = cfg.search?.verdicts?.relevance_floor;
1041
+ const rerankModel = cfg.search?.rerank?.model;
1042
+ const rerankTimeoutMs = cfg.search?.rerank?.timeout_ms;
985
1043
  if (include_bodies) {
986
1044
  let bundleResult;
987
1045
  try {
988
- bundleResult = await bundleSearch(filters, { format: format ?? "xml", max_tokens: max_tokens ?? 50000 });
1046
+ bundleResult = await bundleSearch(filters, {
1047
+ format: format ?? "xml",
1048
+ max_tokens: max_tokens ?? 12000,
1049
+ rerank: shouldRerank,
1050
+ check_sufficiency: shouldCheckSufficiency,
1051
+ candidate_limit: candidateLimit,
1052
+ dictionary_boost: dictionaryBoost,
1053
+ relevance_floor: relevanceFloor,
1054
+ intent_routing: cfg.search?.verdicts?.intent_routing,
1055
+ model: rerankModel,
1056
+ timeout_ms: rerankTimeoutMs,
1057
+ });
989
1058
  }
990
1059
  catch (e) {
991
1060
  if (e instanceof FtsQueryError) {
@@ -998,8 +1067,66 @@ server.tool("files.search", "Full-text (SQLite FTS5) keyword search across files
998
1067
  };
999
1068
  }
1000
1069
  let result;
1070
+ let rerankFallback = false;
1001
1071
  try {
1002
- result = search(filters);
1072
+ if (shouldRerank) {
1073
+ const rawHits = search({ ...filters, limit: candidateLimit, raw_bm25_order: true });
1074
+ if (rawHits.length > 1) {
1075
+ const candidates = rawHits.map((h) => {
1076
+ let content = "";
1077
+ try {
1078
+ content = readFile(h.id).content;
1079
+ }
1080
+ catch { }
1081
+ return {
1082
+ id: h.id,
1083
+ title: h.title,
1084
+ path: h.path,
1085
+ content,
1086
+ content_class: h.content_class ?? null,
1087
+ project_id: h.project_id ?? null,
1088
+ bm25_rank: h.rank,
1089
+ };
1090
+ });
1091
+ const scored = await rerankCandidates(filters.query, candidates, {
1092
+ model: rerankModel,
1093
+ timeout_ms: rerankTimeoutMs,
1094
+ candidate_limit: candidateLimit,
1095
+ dictionary_boost: dictionaryBoost,
1096
+ });
1097
+ if (scored && scored.length > 0) {
1098
+ let arbitrated = arbitrateCandidates(scored, { dictionary_boost: dictionaryBoost });
1099
+ // Apply the configured relevance floor (default 0.15) to the
1100
+ // reranked list. If the floor prunes everything, keep the full
1101
+ // ranked set rather than returning an empty result for a query
1102
+ // that clearly has matches.
1103
+ if (relevanceFloor !== undefined) {
1104
+ const kept = arbitrated.filter((a) => a.final_score >= relevanceFloor);
1105
+ if (kept.length > 0)
1106
+ arbitrated = kept;
1107
+ }
1108
+ const scoreMap = new Map(arbitrated.map((a) => [a.id, a.final_score]));
1109
+ rawHits.sort((a, b) => (scoreMap.get(b.id) ?? 0) - (scoreMap.get(a.id) ?? 0));
1110
+ result = rawHits.map((h) => ({
1111
+ ...h,
1112
+ rerank_score: scoreMap.get(h.id),
1113
+ }));
1114
+ }
1115
+ else {
1116
+ // Reranker unavailable (model missing, timeout, or error):
1117
+ // fall back to the FULL legacy search so recall is not capped
1118
+ // at the candidate pool size.
1119
+ rerankFallback = true;
1120
+ result = search(filters);
1121
+ }
1122
+ }
1123
+ else {
1124
+ result = rawHits;
1125
+ }
1126
+ }
1127
+ else {
1128
+ result = search(filters);
1129
+ }
1003
1130
  }
1004
1131
  catch (e) {
1005
1132
  if (e instanceof FtsQueryError) {
@@ -1010,10 +1137,10 @@ server.tool("files.search", "Full-text (SQLite FTS5) keyword search across files
1010
1137
  const annotated = attachTags(result.map(annotateTokens));
1011
1138
  const total_est_tokens = annotated.reduce((s, f) => s + (f.est_tokens ?? 0), 0);
1012
1139
  return {
1013
- content: [{ type: "text", text: JSON.stringify({ matches: annotated, total_est_tokens }, null, 2) }],
1140
+ content: [{ type: "text", text: JSON.stringify({ matches: annotated, total_est_tokens, ...(rerankFallback ? { rerank_fallback: true, note: "reranker unavailable; results in BM25 order" } : {}) }, null, 2) }],
1014
1141
  };
1015
1142
  });
1016
- server.tool("tags.add", "Append tags to ONE file. Additive — existing tags are preserved; re-adding an existing tag is a no-op (idempotent per tag). New tag names auto-create rows in the global `tags` table. Persists to local SQLite. No external auth or rate limits. Returns `{success: true}`; throws if file_id is unknown. Use to label a single file. To tag every file matching a query in one call use `tags.search`; to remove tags use `tags.remove`.", {
1143
+ server.tool("tags_add", "Append tags to ONE file. Additive: existing tags are preserved; re-adding an existing tag is a no-op (idempotent per tag). New tag names auto-create rows in the global `tags` table. Persists to local SQLite. No external auth or rate limits. Returns `{success: true}`; throws if file_id is unknown. Use to label a single file. To tag every file matching a query in one call use `tags_search`; to remove tags use `tags_remove`.", {
1017
1144
  file_id: z.number().describe("File ID"),
1018
1145
  tags: z.array(z.string()).describe("Array of tag names to add"),
1019
1146
  }, async ({ file_id, tags }) => {
@@ -1022,7 +1149,7 @@ server.tool("tags.add", "Append tags to ONE file. Additive — existing tags are
1022
1149
  content: [{ type: "text", text: JSON.stringify({ success: true }, null, 2) }],
1023
1150
  };
1024
1151
  });
1025
- server.tool("tags.remove", "Detach one or more tag IDs from ONE file. Destructive on the link only — does NOT delete the file or the global tag definition (orphan tags survive in `tags.list`). Idempotent: removing an already-absent tag is a no-op. No external auth or rate limits. Returns `{success: true}`. Note: takes tag IDs (integers), not names — fetch them via `tags.list`. To remove ALL tags from many files via a query, see `tags.search` (additive only) — there is no bulk-untag-by-query tool.", {
1152
+ server.tool("tags_remove", "Detach one or more tag IDs from ONE file. Destructive on the link only: does NOT delete the file or the global tag definition (orphan tags survive in `tags_list`). Idempotent: removing an already-absent tag is a no-op. No external auth or rate limits. Returns `{success: true}`. Note: takes tag IDs (integers), not names, fetch them via `tags_list`. To remove ALL tags from many files via a query, see `tags_search` (additive only), there is no bulk-untag-by-query tool.", {
1026
1153
  file_id: z.number().describe("File ID"),
1027
1154
  tag_ids: z.array(z.number()).describe("Array of tag IDs to remove"),
1028
1155
  }, async ({ file_id, tag_ids }) => {
@@ -1031,7 +1158,7 @@ server.tool("tags.remove", "Detach one or more tag IDs from ONE file. Destructiv
1031
1158
  content: [{ type: "text", text: JSON.stringify({ success: true }, null, 2) }],
1032
1159
  };
1033
1160
  });
1034
- server.tool("tags.set_favorite", "Set or clear the favorite flag on one file (idempotent — re-setting the same value is a no-op; not a toggle, you pass the desired state). Persists to local SQLite. No external auth or rate limits. Returns `{success: true}`. Use to curate quick-access pins; `files.list` / `files.search` accept `favorite: true` to filter to the pinned set.", {
1161
+ server.tool("tags_set_favorite", "Set or clear the favorite flag on one file (idempotent: re-setting the same value is a no-op; not a toggle, you pass the desired state). Persists to local SQLite. No external auth or rate limits. Returns `{success: true}`. Use to curate quick-access pins; `files_list` / `files_search` accept `favorite: true` to filter to the pinned set.", {
1035
1162
  file_id: z.number().describe("File ID"),
1036
1163
  favorite: z.boolean().describe("Favorite status"),
1037
1164
  }, async ({ file_id, favorite }) => {
@@ -1040,13 +1167,13 @@ server.tool("tags.set_favorite", "Set or clear the favorite flag on one file (id
1040
1167
  content: [{ type: "text", text: JSON.stringify({ success: true }, null, 2) }],
1041
1168
  };
1042
1169
  });
1043
- server.tool("tags.list", "List every tag in the global SQLite database with id, name, and applied count. Read-only; no side effects, auth, or rate limits. Returns the entire taxonomy (not paginated). Use to discover existing labels before tagging (so you reuse rather than fork) or to find tag IDs to feed into `tags.remove`. For tags on a specific file, use `files.describe`.", {}, async () => {
1170
+ server.tool("tags_list", "List every tag in the global SQLite database with id, name, and applied count. Read-only; no side effects, auth, or rate limits. Returns the entire taxonomy (not paginated). Use to discover existing labels before tagging (so you reuse rather than fork) or to find tag IDs to feed into `tags_remove`. For tags on a specific file, use `files_describe`.", {}, async () => {
1044
1171
  const result = listTags();
1045
1172
  return {
1046
1173
  content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
1047
1174
  };
1048
1175
  });
1049
- server.tool("projects.list", "List every registered project with id, name, absolute path, and a derived `has_hands` flag (true when the path exists on disk AND contains a `kontexta.json`). Read-only; no side effects, auth, or rate limits. Use to find the project_id to pass to scoped tools (`files.search`, `files.list`, `admin.commit_backup`, `projects.refresh_index`, etc.). To register a new project use `projects.register`; to inspect its Hands tools use `hands.list`.", {}, async () => {
1176
+ server.tool("projects_list", "List every registered project with id, name, absolute path, and a derived `has_hands` flag (true when the path exists on disk AND contains a `kontexta.json`). Read-only; no side effects, auth, or rate limits. Use to find the project_id to pass to scoped tools (`files_search`, `files_list`, `admin_commit_backup`, `projects_refresh_index`, etc.). To register a new project use `projects_register`; to inspect its Hands tools use `hands_list`.", {}, async () => {
1050
1177
  const result = listProjects();
1051
1178
  const augmented = result.map((p) => {
1052
1179
  const has_hands = !!(p.path && existsSync(p.path) && existsSync(`${p.path}/kontexta.json`));
@@ -1066,9 +1193,9 @@ server.tool("projects.list", "List every registered project with id, name, absol
1066
1193
  content: [{ type: "text", text: JSON.stringify(augmented, null, 2) }],
1067
1194
  };
1068
1195
  });
1069
- server.tool("projects.register", `Register a new project and link it to the Kontexta knowledge system.
1196
+ server.tool("projects_register", `Register a new project and link it to the Kontexta knowledge system.
1070
1197
 
1071
- SIDE EFFECTS: Writes project metadata to disk (persisted in the Kontexta data directory). Scans the project root recursively to discover and index all markdown files into the local database. Registers any kontexta.json-declared Hands tools found in the project root. This operation is idempotent — re-registering an existing project updates its metadata without data loss.
1198
+ SIDE EFFECTS: Writes project metadata to disk (persisted in the Kontexta data directory). Scans the project root recursively to discover and index all markdown files into the local database. Registers any kontexta.json-declared Hands tools found in the project root. This operation is idempotent, re-registering an existing project updates its metadata without data loss.
1072
1199
 
1073
1200
  AUTH / RATE LIMITS: None. Operates entirely on the local file system.
1074
1201
 
@@ -1128,41 +1255,41 @@ ERROR CONDITIONS: Returns isError=true if path is missing or unresolvable. Scan
1128
1255
  .map((s) => `${s.path} (found ${s.version ?? "none"})`)
1129
1256
  .join(", ");
1130
1257
  recommendationReason =
1131
- `Your project's agent instructions file is out of date — it still references kontexta workflow rules from an older release. ` +
1258
+ `Your project's agent instructions file is out of date: it still references kontexta workflow rules from an older release. ` +
1132
1259
  `Files needing an update: ${versions}. Latest rules version is v${RULE_BLOCK_VERSION}. ` +
1133
- `Run admin.onboard_agent to refresh the kontexta rules block in-place (your existing project content is preserved).`;
1260
+ `Run admin_onboard_agent to refresh the kontexta rules block in-place (your existing project content is preserved).`;
1134
1261
  }
1135
1262
  else {
1136
1263
  recommendationReason =
1137
- `Found ${detected.join(", ")} with kontexta workflow rules already at the latest version (v${RULE_BLOCK_VERSION}). No action needed — your AI agent will load these rules automatically every session.`;
1264
+ `Found ${detected.join(", ")} with kontexta workflow rules already at the latest version (v${RULE_BLOCK_VERSION}). No action needed: your AI agent will load these rules automatically every session.`;
1138
1265
  }
1139
1266
  }
1140
1267
  else {
1141
1268
  recommendationReason =
1142
1269
  `No AI agent instructions file (e.g. CLAUDE.md, AGENTS.md, GEMINI.md, ANTIGRAVITY.md, .cursor/rules, .continue/rules, .aider/kontexta.md) was found in this project. ` +
1143
1270
  `These files are how coding agents (Claude Code, Codex, Cursor, Gemini, Aider, etc.) load project-specific context at the start of every session. ` +
1144
- `Without one, your agent won't know this project is registered with kontexta and will skip the search/read/journal workflow — wasting tokens re-reading files it could have looked up. ` +
1145
- `Run admin.onboard_agent with target_agent set to your coding tool to scaffold the right file (CLAUDE.md for Claude Code, .aider/kontexta.md for Aider, etc.) pre-populated with kontexta workflow rules.`;
1271
+ `Without one, your agent won't know this project is registered with kontexta and will skip the search/read/journal workflow: wasting tokens re-reading files it could have looked up. ` +
1272
+ `Run admin_onboard_agent with target_agent set to your coding tool to scaffold the right file (CLAUDE.md for Claude Code, .aider/kontexta.md for Aider, etc.) pre-populated with kontexta workflow rules.`;
1146
1273
  }
1147
1274
  const needsOnboarding = outdated.length > 0 || detected.length === 0;
1148
1275
  const recommendation = detected.length > 0
1149
1276
  ? {
1150
- kind: "admin.onboard_agent",
1277
+ kind: "admin_onboard_agent",
1151
1278
  mode: "update",
1152
1279
  reason: recommendationReason,
1153
1280
  target_files: detected,
1154
- next_tool: "admin.onboard_agent",
1281
+ next_tool: "admin_onboard_agent",
1155
1282
  next_args: { project_id: project.id },
1156
1283
  prompt: outdated.length > 0
1157
1284
  ? `Update the kontexta rules block in ${detected.join(", ")} to v${RULE_BLOCK_VERSION} now? (Your existing project-specific content above/below the rules block will be left untouched.)`
1158
1285
  : null,
1159
1286
  }
1160
1287
  : {
1161
- kind: "admin.onboard_agent",
1288
+ kind: "admin_onboard_agent",
1162
1289
  mode: "create",
1163
1290
  reason: recommendationReason,
1164
1291
  target_files: [],
1165
- next_tool: "admin.onboard_agent",
1292
+ next_tool: "admin_onboard_agent",
1166
1293
  next_args: {
1167
1294
  project_id: project.id,
1168
1295
  target_agent: "<pass your agent: claude-code | codex | gemini | antigravity | cursor | continue | aider | cline | copilot>",
@@ -1203,7 +1330,7 @@ ERROR CONDITIONS: Returns isError=true if path is missing or unresolvable. Scan
1203
1330
  };
1204
1331
  }
1205
1332
  });
1206
- server.tool("admin.onboard_agent", `Write or update the kontexta workflow rules block in a project's agent context file(s). Idempotent — uses fenced markers + version to skip no-op writes.
1333
+ server.tool("admin_onboard_agent", `Write or update the kontexta workflow rules block in a project's agent context file(s). Idempotent: uses fenced markers + version to skip no-op writes.
1207
1334
 
1208
1335
  MANDATORY: This tool modifies project configuration files. You MUST seek explicit user consent before calling this tool. Set 'confirm: true' only after the user has agreed.
1209
1336
 
@@ -1283,7 +1410,7 @@ RETURNS: { written: [{ path, action: created|updated|skipped, version }], skippe
1283
1410
  };
1284
1411
  }
1285
1412
  });
1286
- server.tool("admin.transfer_agent_context", `COPY existing agent context files (CLAUDE.md, AGENTS.md, .cursor/rules/*.mdc, etc.) from a project's repo into Kontexta's per-project knowledge base so they're indexed by FTS5 and can be git-synced through Kontexta's own backup engine.
1413
+ server.tool("admin_transfer_agent_context", `COPY existing agent context files (CLAUDE.md, AGENTS.md, .cursor/rules/*.mdc, etc.) from a project's repo into Kontexta's per-project knowledge base so they're indexed by FTS5 and can be git-synced through Kontexta's own backup engine.
1287
1414
 
1288
1415
  This tool ONLY COPIES. It never deletes or modifies the originals in your repo. After a successful transfer, the response includes the list of source paths so the user can manually remove them if desired. No tool argument, no flag, and no code path in this tool ever calls a destructive filesystem operation against \`project.path\`.
1289
1416
 
@@ -1297,7 +1424,7 @@ PARAMETERS:
1297
1424
  RETURNS: { transferred: [{ source_path, kb_id, kb_path, est_tokens }], skipped: [{ source_path, reason }], next_action }
1298
1425
  Skip reasons: "missing" | "symlink" | "outside_project" | "already_transferred_same_content" | "read_error" | "write_error".
1299
1426
 
1300
- IDEMPOTENT: re-running with the same files copies nothing if the content is unchanged — duplicate transfers are detected via SHA-256 hash comparison against existing project KB rows.`, {
1427
+ IDEMPOTENT: re-running with the same files copies nothing if the content is unchanged, duplicate transfers are detected via SHA-256 hash comparison against existing project KB rows.`, {
1301
1428
  project_id: z.number().describe("Project ID returned from register_project"),
1302
1429
  confirm: z.boolean().describe("MANDATORY: Set to true only after obtaining explicit user consent."),
1303
1430
  files: z.array(z.string()).optional().describe("Project-relative paths to transfer. Omit to transfer all detected context files."),
@@ -1334,7 +1461,7 @@ IDEMPOTENT: re-running with the same files copies nothing if the content is unch
1334
1461
  const transferred = [];
1335
1462
  const skipped = [];
1336
1463
  for (const rel of targetRels) {
1337
- // Containment check — reject absolute paths, "..", null bytes.
1464
+ // Containment check: reject absolute paths, "..", null bytes.
1338
1465
  let abs;
1339
1466
  try {
1340
1467
  abs = assertPathInside(projectPath, rel);
@@ -1418,7 +1545,7 @@ IDEMPOTENT: re-running with the same files copies nothing if the content is unch
1418
1545
  };
1419
1546
  }
1420
1547
  });
1421
- server.tool("admin.commit_backup", "SIDE-EFFECTFUL — TOUCHES THE NETWORK. Sync the project's KB data into its git backup directory, create a commit, and `git push` to `origin`. AUTH: relies on the local user's git credentials (SSH agent, credential helper, etc.) — there is no in-server auth. Kontexta does not rate-limit, but the remote may. Idempotent in steady state: a no-op commit is skipped, but the push still runs. Throws if the project has no configured backup repo or if push fails (network, auth, conflict). Returns `{success, copied_files_count, copied_paths}`. Use after a batch of KB writes to get changes off-machine.", {
1548
+ server.tool("admin_commit_backup", "SIDE-EFFECTFUL: TOUCHES THE NETWORK. Sync the project's KB data into its git backup directory, create a commit, and `git push` to `origin`. AUTH: relies on the local user's git credentials (SSH agent, credential helper, etc.), there is no in-server auth. Kontexta does not rate-limit, but the remote may. Idempotent in steady state: a no-op commit is skipped, but the push still runs. Throws if the project has no configured backup repo or if push fails (network, auth, conflict). Returns `{success, copied_files_count, copied_paths}`. Use after a batch of KB writes to get changes off-machine.", {
1422
1549
  project_id: z.number().describe("Project ID"),
1423
1550
  }, async ({ project_id }) => {
1424
1551
  try {
@@ -1443,7 +1570,7 @@ server.tool("admin.commit_backup", "SIDE-EFFECTFUL — TOUCHES THE NETWORK. Sync
1443
1570
  };
1444
1571
  }
1445
1572
  });
1446
- server.tool("resources.clip_url", "SIDE-EFFECTFUL — fetches an EXTERNAL URL and writes a NEW KB file. Downloads the page, extracts the main article via Readability, converts to markdown, and saves it under `knowledge/urlclips/`. Auto-classified as content_class='dictionary' (clipped external references are treated as authoritative reference material). NOT idempotent / no de-dup — re-clipping the same URL creates a second file. AUTH: anonymous by default; pass `headers` (e.g. `{Cookie: 'session=...'}` or `{Authorization: 'Bearer ...'}`) to clip behind logins. Kontexta does not rate-limit but the upstream may throttle. On auth-required pages returns isError with `code: AUTH_REQUIRED`, optional `login_url`, and a hint to retry with `headers`. Returns `{file_id, path, title, source}`. Use to ingest external docs into the KB.", {
1573
+ server.tool("resources_clip_url", "SIDE-EFFECTFUL: fetches an EXTERNAL URL and writes a NEW KB file. Downloads the page, extracts the main article via Readability, converts to markdown, and saves it under `knowledge/urlclips/`. Auto-classified as content_class='dictionary' (clipped external references are treated as authoritative reference material). NOT idempotent / no de-dup: re-clipping the same URL creates a second file. AUTH: anonymous by default; pass `headers` (e.g. `{Cookie: 'session=...'}` or `{Authorization: 'Bearer ...'}`) to clip behind logins. Kontexta does not rate-limit but the upstream may throttle. On auth-required pages returns isError with `code: AUTH_REQUIRED`, optional `login_url`, and a hint to retry with `headers`. Returns `{file_id, path, title, source}`. Use to ingest external docs into the KB.", {
1447
1574
  url: z.string().url().describe("The URL to clip"),
1448
1575
  title: z.string().optional().describe("Optional title override (defaults to the page's <title>)"),
1449
1576
  headers: z
@@ -1497,7 +1624,7 @@ function repoDirForFile(file) {
1497
1624
  }
1498
1625
  return dataDir;
1499
1626
  }
1500
- server.tool("files.get_history", "Return the git commit history for one file (newest first), each entry with hash, message, date, and author. Reads the file's owning repo: the project's git repo for project files, the KB backup repo for KB files. Read-only; no side effects, auth, or rate limits. Returns `{file_id, path, history}`; an empty array means the file has not been committed yet. Use to understand a file's evolution before editing or restoring. Pair with `files.get_diff` to see exact line changes; use `files.restore` to roll back.", {
1627
+ server.tool("files_get_history", "Return the git commit history for one file (newest first), each entry with hash, message, date, and author. Reads the file's owning repo: the project's git repo for project files, the KB backup repo for KB files. Read-only; no side effects, auth, or rate limits. Returns `{file_id, path, history}`; an empty array means the file has not been committed yet. Use to understand a file's evolution before editing or restoring. Pair with `files_get_diff` to see exact line changes; use `files_restore` to roll back.", {
1501
1628
  file_id: z.number().describe("ID of the file"),
1502
1629
  }, async ({ file_id }) => {
1503
1630
  const file = readFile(file_id);
@@ -1511,7 +1638,7 @@ server.tool("files.get_history", "Return the git commit history for one file (ne
1511
1638
  ],
1512
1639
  };
1513
1640
  });
1514
- server.tool("files.get_diff", "Return the unified diff of one file between two commit hashes (typically obtained from `files.get_history` for the same file). Read-only; no side effects, auth, or rate limits. Order matters — `commit_a` is treated as the earlier side; reversing the args inverts the diff. Throws if either hash is unknown to the file's repo. Use after `files.get_history` to see WHAT changed, not just THAT it changed.", {
1641
+ server.tool("files_get_diff", "Return the unified diff of one file between two commit hashes (typically obtained from `files_get_history` for the same file). Read-only; no side effects, auth, or rate limits. Order matters: `commit_a` is treated as the earlier side; reversing the args inverts the diff. Throws if either hash is unknown to the file's repo. Use after `files_get_history` to see WHAT changed, not just THAT it changed.", {
1515
1642
  file_id: z.number().describe("ID of the file"),
1516
1643
  commit_a: z.string().describe("Earlier commit hash (from get_history)"),
1517
1644
  commit_b: z.string().describe("Later commit hash (from get_history)"),
@@ -1527,12 +1654,15 @@ server.tool("files.get_diff", "Return the unified diff of one file between two c
1527
1654
  ],
1528
1655
  };
1529
1656
  });
1530
- server.tool("files.restore", "DESTRUCTIVE. Overwrite a file's current on-disk content with the version recorded at a specific git commit, then re-index FTS. The hash MUST come from `files.get_history` for THIS file (foreign hashes throw). The current uncommitted content is lost unless it was already committed elsewhere. The file watcher may also pick up the change before this returns. No external auth or rate limits. Returns `{file_id, path, hash, success, message}`. Use only to undo accidental edits or recover a known-good version.", {
1657
+ server.tool("files_restore", "DESTRUCTIVE. Overwrite a file's current on-disk content with the version recorded at a specific git commit, then re-index FTS. The hash MUST come from `files_get_history` for THIS file (foreign hashes throw). The current uncommitted content is lost unless it was already committed elsewhere. The file watcher may also pick up the change before this returns. No external auth or rate limits. Returns `{file_id, path, hash, success, message}`. Use only to undo accidental edits or recover a known-good version.", {
1531
1658
  file_id: z.number().describe("ID of the file"),
1532
1659
  hash: z.string().describe("Commit hash to restore from (from get_history)"),
1533
1660
  }, async ({ file_id, hash }) => {
1534
1661
  try {
1535
1662
  const file = readFile(file_id);
1663
+ const refusal = refuseRepoFile(file);
1664
+ if (refusal)
1665
+ throw new Error(refusal);
1536
1666
  const content = await restoreVersion(repoDirForFile(file), file.path, hash);
1537
1667
  return {
1538
1668
  content: [
@@ -1556,7 +1686,7 @@ server.tool("files.restore", "DESTRUCTIVE. Overwrite a file's current on-disk co
1556
1686
  };
1557
1687
  }
1558
1688
  });
1559
- server.tool("files.read_outline", "Return a flat list of markdown headings for one file (level, text, line, byteStart, byteEnd). Read-only; no side effects, auth, or rate limits. Use as a cheap probe before `files.read({ id, section })` or `files.update({ file_id, section, content })` so you don't spend tokens on the full body just to learn what sections exist. Empty outline means the file has no markdown headings (it may still have content — fall back to `files.read` in full or `files.read({ id, lines })`).", {
1689
+ server.tool("files_read_outline", "Return a flat list of markdown headings for one file (level, text, line, byteStart, byteEnd). Read-only; no side effects, auth, or rate limits. Use as a cheap probe before `files_read({ id, section })` or `files_update({ file_id, section, content })` so you don't spend tokens on the full body just to learn what sections exist. Empty outline means the file has no markdown headings (it may still have content: fall back to `files_read` in full or `files_read({ id, lines })`).", {
1560
1690
  file_id: z.number().describe("File ID"),
1561
1691
  }, async ({ file_id }) => {
1562
1692
  try {
@@ -1609,7 +1739,7 @@ function validateFolderName(name) {
1609
1739
  throw new Error("name must not contain '..' segments");
1610
1740
  }
1611
1741
  }
1612
- server.tool("folders.list", "List folder paths under a project root (or the Knowledge Base when `project_id` is null/omitted). Returns `{folders: string[], base_path}` where `folders` are RELATIVE to `base_path`. Read-only; no side effects, auth, or rate limits. Throws if `project_id` references an unknown project. Use to discover where to drop a new file via `files.create`'s `folder` argument or to navigate vault structure; to actually create one use `folders.create`.", {
1742
+ server.tool("folders_list", "List folder paths under a project root (or the Knowledge Base when `project_id` is null/omitted). Returns `{folders: string[], base_path}` where `folders` are RELATIVE to `base_path`. Read-only; no side effects, auth, or rate limits. Throws if `project_id` references an unknown project. Use to discover where to drop a new file via `files_create`'s `folder` argument or to navigate vault structure; to actually create one use `folders_create`.", {
1613
1743
  project_id: z.number().nullable().optional().describe("Project ID. Pass null or omit to list KB folders."),
1614
1744
  }, async ({ project_id }) => {
1615
1745
  try {
@@ -1627,12 +1757,15 @@ server.tool("folders.list", "List folder paths under a project root (or the Know
1627
1757
  };
1628
1758
  }
1629
1759
  });
1630
- server.tool("folders.create", "Create a folder under a project root or the KB. Idempotent — creating an existing folder succeeds. Nested paths like `notes/inbox` create intermediates. REJECTS: empty names, null bytes, leading path separators, and any segment equal to `..` (the call returns isError, no folder is touched). Side effect: a directory is mkdir'd on disk; no DB rows are written until a file lands inside. No external auth or rate limits. Returns `{path, base_path}`.", {
1760
+ server.tool("folders_create", "Create a folder in the KB (a `project_id` is refused: kxta never writes into a project repo). Idempotent, creating an existing folder succeeds. Nested paths like `notes/inbox` create intermediates. REJECTS: empty names, null bytes, leading path separators, and any segment equal to `..` (the call returns isError, no folder is touched). Side effect: a directory is mkdir'd on disk; no DB rows are written until a file lands inside. No external auth or rate limits. Returns `{path, base_path}`.", {
1631
1761
  project_id: z.number().nullable().optional().describe("Project ID. Pass null or omit to create the folder under the KB."),
1632
1762
  name: z.string().describe("Folder name (relative; supports nested paths via '/')"),
1633
1763
  }, async ({ project_id, name }) => {
1634
1764
  try {
1635
1765
  validateFolderName(name);
1766
+ const refusal = refuseProjectFolder(project_id);
1767
+ if (refusal)
1768
+ throw new Error(refusal);
1636
1769
  const base = resolveFolderBase(project_id);
1637
1770
  const path = createFolder(base, name, { dataDir });
1638
1771
  return {
@@ -1646,7 +1779,7 @@ server.tool("folders.create", "Create a folder under a project root or the KB. I
1646
1779
  };
1647
1780
  }
1648
1781
  });
1649
- server.tool("folders.delete", "DESTRUCTIVE — recursively delete a folder under the KB AND every file inside it (disk + FTS rows). REFUSES (returns isError) when `project_id` is supplied: deleting inside a registered project would race the file watcher and re-ingest the contents — remove project content via your editor instead. Same name validation as `folders.create`. Not recoverable from Kontexta after the call (only the git backup, if configured, retains it). No external auth or rate limits. Returns `{success: true}`.", {
1782
+ server.tool("folders_delete", "DESTRUCTIVE: recursively delete a folder under the KB AND every file inside it (disk + FTS rows). REFUSES (returns isError) when `project_id` is supplied: deleting inside a registered project would race the file watcher and re-ingest the contents, remove project content via your editor instead. Same name validation as `folders_create`. Not recoverable from Kontexta after the call (only the git backup, if configured, retains it). No external auth or rate limits. Returns `{success: true}`.", {
1650
1783
  project_id: z.number().nullable().optional().describe("Project ID. Pass null or omit to delete from the KB. Project IDs are rejected."),
1651
1784
  name: z.string().describe("Folder name (relative)"),
1652
1785
  }, async ({ project_id, name }) => {
@@ -1665,13 +1798,13 @@ server.tool("folders.delete", "DESTRUCTIVE — recursively delete a folder under
1665
1798
  ],
1666
1799
  };
1667
1800
  }
1668
- // Refuse deleting a bare bucket name — would wipe the whole bucket and orphan DB rows.
1669
- const KB_BUCKETS_TOP = new Set(["journal", "knowledge", "mermaid", "html"]);
1801
+ // Refuse deleting root knowledge folders: would wipe fixed buckets or the whole KB.
1670
1802
  const segments = name.split(/[/\\]/).filter(Boolean);
1671
- if (segments.length === 1 && KB_BUCKETS_TOP.has(segments[0])) {
1803
+ if (segments.length <= 1) {
1804
+ const top = segments[0] || name;
1672
1805
  return {
1673
1806
  isError: true,
1674
- content: [{ type: "text", text: JSON.stringify({ error: `Cannot delete the '${segments[0]}' bucket — part of the fixed KB layout.` }, null, 2) }],
1807
+ content: [{ type: "text", text: JSON.stringify({ error: `Cannot delete root knowledge folder '${top}', part of the fixed KB layout. Delete subfolders inside it instead.` }, null, 2) }],
1675
1808
  };
1676
1809
  }
1677
1810
  const base = resolveFolderBase(null);
@@ -1687,7 +1820,7 @@ server.tool("folders.delete", "DESTRUCTIVE — recursively delete a folder under
1687
1820
  };
1688
1821
  }
1689
1822
  });
1690
- server.tool("files.move", "Move/rename a file. Destination 'new_path' must be absolute and resolve INSIDE the file's owning project or global knowledge directory. Cross-project moves are rejected. Alternative: pass `kind='dictionary'|'note'` (with no `new_path`) to move a KB file into the mirrored path in the other class tree — subfolder path is preserved. Operates locally with no auth or limits.", {
1823
+ server.tool("files_move", "Move/rename a KB file (project-repo files are refused). Destination 'new_path' must be absolute and resolve INSIDE the file's owning project or global knowledge directory. Cross-project moves are rejected. Alternative: pass `kind='dictionary'|'note'` (with no `new_path`) to move a KB file into the mirrored path in the other class tree, subfolder path is preserved. Operates locally with no auth or limits.", {
1691
1824
  file_id: z.number().describe("File ID"),
1692
1825
  new_path: z.string().optional().describe("Absolute destination path"),
1693
1826
  kind: z.enum(["dictionary", "note"]).optional()
@@ -1695,6 +1828,9 @@ server.tool("files.move", "Move/rename a file. Destination 'new_path' must be ab
1695
1828
  }, async ({ file_id, new_path, kind }) => {
1696
1829
  try {
1697
1830
  const file = readFile(file_id);
1831
+ const refusal = refuseRepoFile(file);
1832
+ if (refusal)
1833
+ throw new Error(refusal);
1698
1834
  if (kind && !new_path) {
1699
1835
  if (file.storage_type !== "local") {
1700
1836
  throw new Error("move_file with kind is only supported for KB files (storage_type='local')");
@@ -1728,7 +1864,7 @@ server.tool("files.move", "Move/rename a file. Destination 'new_path' must be ab
1728
1864
  else {
1729
1865
  base = join(dataDir, "knowledge");
1730
1866
  }
1731
- // Use realpath to follow symlinks before the containment check —
1867
+ // Use realpath to follow symlinks before the containment check,
1732
1868
  // path.resolve() only normalises `.`/`..`, so a symlink inside the
1733
1869
  // vault pointing outside (e.g. knowledge/escape -> /etc) would let
1734
1870
  // moveFile write through it. realpath the dest's PARENT since the
@@ -1755,7 +1891,7 @@ server.tool("files.move", "Move/rename a file. Destination 'new_path' must be ab
1755
1891
  }
1756
1892
  // Defense-in-depth: also confirm the SOURCE lives under the same base.
1757
1893
  // If a project was re-registered to a new path after this file was
1758
- // ingested, fileRecord.path can point outside the current base — and
1894
+ // ingested, fileRecord.path can point outside the current base: and
1759
1895
  // without this check moveFile would relocate that orphan into the
1760
1896
  // project root.
1761
1897
  let srcResolved;
@@ -1780,7 +1916,7 @@ server.tool("files.move", "Move/rename a file. Destination 'new_path' must be ab
1780
1916
  };
1781
1917
  }
1782
1918
  });
1783
- server.tool("files.find_related", "Find other files sharing tags with the given file, ranked by `shared_tag_count` descending. Read-only; no side effects, auth, or rate limits. Returns annotated file rows with `shared_tag_count` and `shared_tags`. Empty result means the file has no tags or no other file shares them — try `files.search`/`files.regex_search` for content-based discovery, or `tags.suggest` to bootstrap labels first. `kind` narrows to one content class. Default limit 10.", {
1919
+ server.tool("files_find_related", "Find other files sharing tags with the given file, ranked by `shared_tag_count` descending. Read-only; no side effects, auth, or rate limits. Returns annotated file rows with `shared_tag_count` and `shared_tags`. Empty result means the file has no tags or no other file shares them: try `files_search`/`files_regex_search` for content-based discovery, or `tags_suggest` to bootstrap labels first. `kind` narrows to one content class. Default limit 10.", {
1784
1920
  file_id: z.number().describe("ID of the file to find relations for"),
1785
1921
  limit: z.number().optional().describe("Maximum number of related files to return (default 10)"),
1786
1922
  kind: z.enum(["dictionary", "note", "journal", "project"]).optional()
@@ -1803,11 +1939,11 @@ server.tool("files.find_related", "Find other files sharing tags with the given
1803
1939
  ],
1804
1940
  };
1805
1941
  });
1806
- server.tool("tags.search", "Bulk-tag — run an FTS `search` and append `add_tags` to every matching file in one call. Side effect: each match gets `addTags` applied (additive, idempotent per tag); the matched files themselves are NOT modified beyond their tag links. Per-file failures isolated to `errors[]`. No external auth or rate limits. There is NO dry-run flag, so ALWAYS run `files.search` with the same query first to verify the match set before tagging. The `tags[]` filter requires existing tags to ALL match (it scopes the search; it does not control which tags get added). Returns `{matched_count, tagged_count, tags_applied, tagged_ids, errors}`.", {
1942
+ server.tool("tags_search", "Bulk-tag: run an FTS `search` and append `add_tags` to every matching file in one call. Side effect: each match gets `addTags` applied (additive, idempotent per tag); the matched files themselves are NOT modified beyond their tag links. Per-file failures isolated to `errors[]`. No external auth or rate limits. There is NO dry-run flag, so ALWAYS run `files_search` with the same query first to verify the match set before tagging. The `tags[]` filter requires existing tags to ALL match (it scopes the search; it does not control which tags get added). Returns `{matched_count, tagged_count, tags_applied, tagged_ids, errors}`.", {
1807
1943
  query: z.string().describe("Full-text search query"),
1808
1944
  add_tags: z.array(z.string()).min(1).describe("Tags to add to every matching file"),
1809
1945
  project_id: z.number().nullable().optional().describe("Scope search to a specific project. Pass null for KB-only results."),
1810
- tags: z.array(z.string()).optional().describe("Filter — only matches that already carry ALL of these tags"),
1946
+ tags: z.array(z.string()).optional().describe("Filter, only matches that already carry ALL of these tags"),
1811
1947
  favorite: z.boolean().optional().describe("If true, restrict to favorited files only."),
1812
1948
  }, async ({ query, add_tags, project_id, tags, favorite }) => {
1813
1949
  const filters = { query };
@@ -1853,7 +1989,7 @@ server.tool("tags.search", "Bulk-tag — run an FTS `search` and append `add_tag
1853
1989
  ],
1854
1990
  };
1855
1991
  });
1856
- server.tool("admin.overview", "Vault-state snapshot. `mode: 'stats'` = aggregate counts for a scope: `file_count`, `untagged_count`, `favorite_count`, `top_tags`. With `project_id` omitted (everything), also returns `by_project` breakdown. `include_token_total: true` stat()s every matching file on disk to compute a body-size estimate — measurably slower on large vaults; default false. `mode: 'whats_new'` = list files created or modified since a checkpoint (`since`, REQUIRED for this mode — ISO-8601 like `2025-01-15T00:00:00Z` or relative durations like `1h`/`7d`/`2w`; invalid formats throw); CAVEAT: hard-deleted files are NOT surfaced, only mtime-driven changes. Both modes: `project_id: null` = KB only; omit = everything. Read-only; no side effects, auth, or rate limits. Use `stats` as a cheap dashboard or to spot untagged content for cleanup (for live disk-vs-index drift use `files.diff_against_disk`); use `whats_new` at session start to catch up.", {
1992
+ server.tool("admin_overview", "Vault-state snapshot. `mode: 'stats'` = aggregate counts for a scope: `file_count`, `untagged_count`, `favorite_count`, `top_tags`. With `project_id` omitted (everything), also returns `by_project` breakdown. `include_token_total: true` stat()s every matching file on disk to compute a body-size estimate, measurably slower on large vaults; default false. `mode: 'whats_new'` = list files created or modified since a checkpoint (`since`, REQUIRED for this mode, ISO-8601 like `2025-01-15T00:00:00Z` or relative durations like `1h`/`7d`/`2w`; invalid formats throw); CAVEAT: hard-deleted files are NOT surfaced, only mtime-driven changes. Both modes: `project_id: null` = KB only; omit = everything. Read-only; no side effects, auth, or rate limits. Use `stats` as a cheap dashboard or to spot untagged content for cleanup (for live disk-vs-index drift use `files_diff_against_disk`); use `whats_new` at session start to catch up.", {
1857
1993
  mode: z.enum(["stats", "whats_new"]).describe("Which snapshot to return. 'whats_new' requires `since`."),
1858
1994
  project_id: z.number().nullable().optional().describe("Filter to a single project. Pass null for KB-only. Omit for everything."),
1859
1995
  top_tags: z.number().int().positive().max(100).optional().describe("mode='stats' only: how many top tags to return (default 10)"),
@@ -1972,6 +2108,16 @@ server.tool("admin.overview", "Vault-state snapshot. `mode: 'stats'` = aggregate
1972
2108
  ...(byProject ? { by_project: byProject } : {}),
1973
2109
  ...(totalEstTokens !== null ? { total_est_tokens: totalEstTokens } : {}),
1974
2110
  rules_warning: getAgentRulesWarning(project_id),
2111
+ system1: (() => {
2112
+ const st = rerankEngine.getStatus();
2113
+ return {
2114
+ ready: st.loaded,
2115
+ device: st.device,
2116
+ model: st.model,
2117
+ cache_dir: st.cache_dir,
2118
+ loaded_models: getAllStatuses().map((s) => s.modelId),
2119
+ };
2120
+ })(),
1975
2121
  }, null, 2),
1976
2122
  },
1977
2123
  ],
@@ -1984,7 +2130,7 @@ server.tool("admin.overview", "Vault-state snapshot. `mode: 'stats'` = aggregate
1984
2130
  };
1985
2131
  }
1986
2132
  });
1987
- server.tool("tags.suggest", "Propose tags for a file by mining the existing tag corpus via FTS — picks distinctive terms from the file (≥4 chars, stopword-filtered) and returns tags applied to other files that score high on those terms. No LLM, no network. Already-applied tags are excluded so the suggestions are net-new. Read-only; no side effects, auth, or rate limits. Returns `{file_id, path, existing_tags, suggestions: [{tag, score, sources}]}`. Empty suggestions = no distinctive terms or no overlap with the existing taxonomy yet — bootstrap with `tags.add` first. Default limit 10, max 50. Suggestions are NOT auto-applied.", {
2133
+ server.tool("tags_suggest", "Propose tags for a file by mining the existing tag corpus via FTS: picks distinctive terms from the file (≥4 chars, stopword-filtered) and returns tags applied to other files that score high on those terms. No LLM, no network. Already-applied tags are excluded so the suggestions are net-new. Read-only; no side effects, auth, or rate limits. Returns `{file_id, path, existing_tags, suggestions: [{tag, score, sources}]}`. Empty suggestions = no distinctive terms or no overlap with the existing taxonomy yet, bootstrap with `tags_add` first. Default limit 10, max 50. Suggestions are NOT auto-applied.", {
1988
2134
  file_id: z.number().describe("File ID to suggest tags for"),
1989
2135
  limit: z.number().int().positive().max(50).optional().describe("Max suggestions to return (default 10)"),
1990
2136
  }, async ({ file_id, limit }) => {
@@ -2064,7 +2210,7 @@ server.tool("tags.suggest", "Propose tags for a file by mining the existing tag
2064
2210
  };
2065
2211
  }
2066
2212
  });
2067
- server.tool("files.diff_against_disk", "Diagnose drift between one file's disk content and its FTS index. Status is one of `in_sync`, `diverged`, `disk_unreadable`, or `no_index_row`. On divergence returns sizes, line counts, the first divergent line number, and the disk vs index sample for that line — NOT a full diff (use `files.get_diff` for full diffs between commits). Read-only; no side effects, auth, or rate limits. Use when search results look stale; if status is `diverged` or `no_index_row`, run `projects.refresh_index` to fix.", {
2213
+ server.tool("files_diff_against_disk", "Diagnose drift between one file's disk content and its FTS index. Status is one of `in_sync`, `diverged`, `disk_unreadable`, or `no_index_row`. On divergence returns sizes, line counts, the first divergent line number, and the disk vs index sample for that line: NOT a full diff (use `files_get_diff` for full diffs between commits). Read-only; no side effects, auth, or rate limits. Use when search results look stale; if status is `diverged` or `no_index_row`, run `projects_refresh_index` to fix.", {
2068
2214
  file_id: z.number().describe("File ID"),
2069
2215
  }, async ({ file_id }) => {
2070
2216
  try {
@@ -2171,7 +2317,7 @@ server.tool("files.diff_against_disk", "Diagnose drift between one file's disk c
2171
2317
  };
2172
2318
  }
2173
2319
  });
2174
- server.tool("projects.refresh_index", "Reconcile the FTS index against disk. For a project (`project_id` set), re-runs `discoverFiles`. For the KB (`project_id` null/omitted), walks `knowledge/`, ingests new .md files, reindexes any whose content hash drifted, and PRUNES rows for files no longer on disk. SIDE-EFFECTFUL: writes/updates/deletes file and FTS rows (the prune is destructive on stale index rows but never deletes files from disk). Idempotent — running twice is a near no-op. Skips files >5MB and standard junk dirs (`node_modules`, `.git`, `dist`, `build`, etc.). No external auth or rate limits. Returns `{scope, newly_indexed, refreshed, pruned}`. Use after editing files outside Kontexta, or when `files.diff_against_disk` reports drift.", {
2320
+ server.tool("projects_refresh_index", "Reconcile the FTS index against disk. For a project (`project_id` set), re-runs `discoverFiles`. For the KB (`project_id` null/omitted), walks `knowledge/`, ingests new .md files, reindexes any whose content hash drifted, and PRUNES rows for files no longer on disk. SIDE-EFFECTFUL: writes/updates/deletes file and FTS rows (the prune is destructive on stale index rows but never deletes files from disk). Idempotent, running twice is a near no-op. Skips files >5MB and standard junk dirs (`node_modules`, `.git`, `dist`, `build`, etc.). No external auth or rate limits. Returns `{scope, newly_indexed, refreshed, pruned}`. Use after editing files outside Kontexta, or when `files_diff_against_disk` reports drift.", {
2175
2321
  project_id: z.number().nullable().optional().describe("Project ID. Pass null or omit to reindex the Knowledge Base."),
2176
2322
  }, async ({ project_id }) => {
2177
2323
  try {
@@ -2192,7 +2338,7 @@ server.tool("projects.refresh_index", "Reconcile the FTS index against disk. For
2192
2338
  };
2193
2339
  }
2194
2340
  });
2195
- server.tool("projects.map", "Return a compact indented outline of folders, file titles, tags, and IDs in a single dense block — substantially fewer tokens than the equivalent `files.list` JSON for the same scope. Read-only; no side effects, auth, or rate limits. Capped at `max_lines` (default 5000); the response reports `est_tokens` and emits a `warning` field if it exceeds `KONTEXTA_PROJECT_TOKEN_WARN`. `project_id: null` = KB only; omit = everything. Defaults: include_tags=true, show_titles=true. Use to orient yourself in an unfamiliar vault or project; for keyword lookup use `files.search`.", {
2341
+ server.tool("projects_map", "Return a compact indented outline of folders, file titles, tags, and IDs in a single dense block: substantially fewer tokens than the equivalent `files_list` JSON for the same scope. Read-only; no side effects, auth, or rate limits. Capped at `max_lines` (default 5000); the response reports `est_tokens` and emits a `warning` field if it exceeds `KONTEXTA_PROJECT_TOKEN_WARN`. `project_id: null` = KB only; omit = everything. Defaults: include_tags=true, show_titles=true. Use to orient yourself in an unfamiliar vault or project; for keyword lookup use `files_search`.", {
2196
2342
  project_id: z.number().nullable().optional().describe("Restrict to a single project. Pass null for knowledge-base-only files. Omit for everything."),
2197
2343
  include_tags: z.boolean().optional().describe("Append #tags inline. Default true. Set false to shrink the outline."),
2198
2344
  show_titles: z.boolean().optional().describe("Show file titles instead of filenames. Default true."),
@@ -2271,7 +2417,7 @@ server.resource("File Content", new ResourceTemplate("kontexta://files/{id}", {
2271
2417
  ],
2272
2418
  };
2273
2419
  });
2274
- server.tool("hands.list", "List every Hands command tool currently registered, with project scope, tool name, danger level, confirmation flag, and description. Hands tools come from per-project `kontexta.json` files loaded at register time. Pass `schema: true` to instead get the complete `kontexta.json` authoring reference (JSON schema, validation rules, security guarantees, limitations, annotated example) — a static document, unrelated to any specific registered hand. Read-only; no side effects, auth, or rate limits. Use the default list mode to discover what side-effectful project commands the agent is permitted to run; use `schema: true` when helping a user write or fix a `kontexta.json`; reload after editing one with `hands.reload`.", {
2420
+ server.tool("hands_list", "List every Hands command tool currently registered, with project scope, tool name, danger level, confirmation flag, and description. Hands tools come from per-project `kontexta.json` files loaded at register time. Pass `schema: true` to instead get the complete `kontexta.json` authoring reference (JSON schema, validation rules, security guarantees, limitations, annotated example), a static document, unrelated to any specific registered hand. Read-only; no side effects, auth, or rate limits. Use the default list mode to discover what side-effectful project commands the agent is permitted to run; use `schema: true` when helping a user write or fix a `kontexta.json`; reload after editing one with `hands_reload`.", {
2275
2421
  schema: z.boolean().optional().describe("If true, return the kontexta.json authoring reference document instead of the registered-hands list. Default false."),
2276
2422
  }, async ({ schema }) => {
2277
2423
  if (schema) {
@@ -2280,14 +2426,14 @@ server.tool("hands.list", "List every Hands command tool currently registered, w
2280
2426
  const items = handsRegistry.list();
2281
2427
  return { content: [{ type: "text", text: JSON.stringify({ hands: items }, null, 2) }] };
2282
2428
  });
2283
- server.tool("hands.reload", "Re-scan every registered project's `kontexta.json` and rebuild the live Hands tool registry — newly-declared tools become callable immediately, removed tools disappear from `tools/list`. SIDE EFFECT is on the running MCP session's tool inventory only (no disk writes). Idempotent. No external auth or rate limits. Takes no parameters. Returns per-project load results (counts of registered/disabled tools and any validation warnings). Use after editing a `kontexta.json` mid-session; for the schema see `hands.list({ schema: true })`.", {}, async () => {
2429
+ server.tool("hands_reload", "Re-scan every registered project's `kontexta.json` and rebuild the live Hands tool registry: newly-declared tools become callable immediately, removed tools disappear from `tools/list`. SIDE EFFECT is on the running MCP session's tool inventory only (no disk writes). Idempotent. No external auth or rate limits. Takes no parameters. Returns per-project load results (counts of registered/disabled tools and any validation warnings). Use after editing a `kontexta.json` mid-session; for the schema see `hands_list({ schema: true })`.", {}, async () => {
2284
2430
  const projects = listProjects()
2285
2431
  .filter((p) => p.path && existsSync(p.path))
2286
2432
  .map((p) => ({ name: p.name, root: p.path }));
2287
2433
  const r = handsRegistry.reloadAll(projects);
2288
2434
  return { content: [{ type: "text", text: JSON.stringify(r, null, 2) }] };
2289
2435
  });
2290
- server.tool("hands.confirm", "Approve and EXECUTE a previously-issued Hands invocation by its single-use approval token. The token is returned by any confirm-required Hands tool; tokens expire after 60 seconds and CANNOT be reused. Side effect equals whatever the underlying Hand does — this can be highly destructive (running arbitrary shell commands, modifying files, etc.), so only call when the user has authorised the pending action. The token IS the auth (no external auth, no rate limits). Invalid, expired, or already-consumed tokens return an inert text response, NOT an error.", { token: z.string().describe("The approval token from the pending response") }, async ({ token }) => {
2436
+ server.tool("hands_confirm", "Approve and EXECUTE a previously-issued Hands invocation by its single-use approval token. The token is returned by any confirm-required Hands tool; tokens expire after 60 seconds and CANNOT be reused. Side effect equals whatever the underlying Hand does: this can be highly destructive (running arbitrary shell commands, modifying files, etc.), so only call when the user has authorised the pending action. The token IS the auth (no external auth, no rate limits). Invalid, expired, or already-consumed tokens return an inert text response, NOT an error.", { token: z.string().describe("The approval token from the pending response") }, async ({ token }) => {
2291
2437
  const pending = handsRegistry.getConfirmStore().consume(token);
2292
2438
  if (!pending) {
2293
2439
  return { content: [{ type: "text", text: "Token invalid, expired, or already consumed." }] };
@@ -2300,7 +2446,7 @@ server.tool("hands.confirm", "Approve and EXECUTE a previously-issued Hands invo
2300
2446
  return { content: [{ type: "text", text: `Execution failed after approval: ${e?.message ?? e}` }] };
2301
2447
  }
2302
2448
  });
2303
- server.tool("admin.get_profile", "Return the user profile stored in the Knowledge Base. The profile helps AI agents understand the user's context, role, preferences, and goals. Read-only; no side effects, auth, or rate limits. Returns existence status, full content, list of missing required sections, and a hint for new users. Use at session start to understand who you're working with.", {}, async () => {
2449
+ server.tool("admin_get_profile", "Return the user profile stored in the Knowledge Base. The profile helps AI agents understand the user's context, role, preferences, and goals. Read-only; no side effects, auth, or rate limits. Returns existence status, full content, list of missing required sections, and a hint for new users. Use at session start to understand who you're working with.", {}, async () => {
2304
2450
  const result = handleGetProfile(dataDir);
2305
2451
  return {
2306
2452
  content: [{ type: "text", text: JSON.stringify(result, null, 2) }],