universal-agent-protocol 0.5.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 (415) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +462 -0
  3. package/dist/analyzers/index.d.ts +3 -0
  4. package/dist/analyzers/index.d.ts.map +1 -0
  5. package/dist/analyzers/index.js +656 -0
  6. package/dist/analyzers/index.js.map +1 -0
  7. package/dist/bin/cli.d.ts +3 -0
  8. package/dist/bin/cli.d.ts.map +1 -0
  9. package/dist/bin/cli.js +506 -0
  10. package/dist/bin/cli.js.map +1 -0
  11. package/dist/bin/tool-calls.d.ts +3 -0
  12. package/dist/bin/tool-calls.d.ts.map +1 -0
  13. package/dist/bin/tool-calls.js +4 -0
  14. package/dist/bin/tool-calls.js.map +1 -0
  15. package/dist/cli/agent.d.ts +20 -0
  16. package/dist/cli/agent.d.ts.map +1 -0
  17. package/dist/cli/agent.js +434 -0
  18. package/dist/cli/agent.js.map +1 -0
  19. package/dist/cli/analyze.d.ts +7 -0
  20. package/dist/cli/analyze.d.ts.map +1 -0
  21. package/dist/cli/analyze.js +103 -0
  22. package/dist/cli/analyze.js.map +1 -0
  23. package/dist/cli/coord.d.ts +7 -0
  24. package/dist/cli/coord.d.ts.map +1 -0
  25. package/dist/cli/coord.js +138 -0
  26. package/dist/cli/coord.js.map +1 -0
  27. package/dist/cli/dashboard.d.ts +8 -0
  28. package/dist/cli/dashboard.d.ts.map +1 -0
  29. package/dist/cli/dashboard.js +704 -0
  30. package/dist/cli/dashboard.js.map +1 -0
  31. package/dist/cli/deploy.d.ts +19 -0
  32. package/dist/cli/deploy.d.ts.map +1 -0
  33. package/dist/cli/deploy.js +267 -0
  34. package/dist/cli/deploy.js.map +1 -0
  35. package/dist/cli/droids.d.ts +9 -0
  36. package/dist/cli/droids.d.ts.map +1 -0
  37. package/dist/cli/droids.js +227 -0
  38. package/dist/cli/droids.js.map +1 -0
  39. package/dist/cli/generate.d.ts +17 -0
  40. package/dist/cli/generate.d.ts.map +1 -0
  41. package/dist/cli/generate.js +432 -0
  42. package/dist/cli/generate.js.map +1 -0
  43. package/dist/cli/hooks.d.ts +9 -0
  44. package/dist/cli/hooks.d.ts.map +1 -0
  45. package/dist/cli/hooks.js +374 -0
  46. package/dist/cli/hooks.js.map +1 -0
  47. package/dist/cli/init.d.ts +11 -0
  48. package/dist/cli/init.d.ts.map +1 -0
  49. package/dist/cli/init.js +316 -0
  50. package/dist/cli/init.js.map +1 -0
  51. package/dist/cli/mcp-router.d.ts +16 -0
  52. package/dist/cli/mcp-router.d.ts.map +1 -0
  53. package/dist/cli/mcp-router.js +143 -0
  54. package/dist/cli/mcp-router.js.map +1 -0
  55. package/dist/cli/memory.d.ts +24 -0
  56. package/dist/cli/memory.d.ts.map +1 -0
  57. package/dist/cli/memory.js +877 -0
  58. package/dist/cli/memory.js.map +1 -0
  59. package/dist/cli/model.d.ts +15 -0
  60. package/dist/cli/model.d.ts.map +1 -0
  61. package/dist/cli/model.js +270 -0
  62. package/dist/cli/model.js.map +1 -0
  63. package/dist/cli/patterns.d.ts +26 -0
  64. package/dist/cli/patterns.d.ts.map +1 -0
  65. package/dist/cli/patterns.js +587 -0
  66. package/dist/cli/patterns.js.map +1 -0
  67. package/dist/cli/setup-mcp-router.d.ts +8 -0
  68. package/dist/cli/setup-mcp-router.d.ts.map +1 -0
  69. package/dist/cli/setup-mcp-router.js +163 -0
  70. package/dist/cli/setup-mcp-router.js.map +1 -0
  71. package/dist/cli/setup.d.ts +13 -0
  72. package/dist/cli/setup.d.ts.map +1 -0
  73. package/dist/cli/setup.js +146 -0
  74. package/dist/cli/setup.js.map +1 -0
  75. package/dist/cli/sync.d.ts +7 -0
  76. package/dist/cli/sync.d.ts.map +1 -0
  77. package/dist/cli/sync.js +26 -0
  78. package/dist/cli/sync.js.map +1 -0
  79. package/dist/cli/task.d.ts +33 -0
  80. package/dist/cli/task.d.ts.map +1 -0
  81. package/dist/cli/task.js +616 -0
  82. package/dist/cli/task.js.map +1 -0
  83. package/dist/cli/tool-calls.d.ts +8 -0
  84. package/dist/cli/tool-calls.d.ts.map +1 -0
  85. package/dist/cli/tool-calls.js +239 -0
  86. package/dist/cli/tool-calls.js.map +1 -0
  87. package/dist/cli/update.d.ts +10 -0
  88. package/dist/cli/update.d.ts.map +1 -0
  89. package/dist/cli/update.js +300 -0
  90. package/dist/cli/update.js.map +1 -0
  91. package/dist/cli/visualize.d.ts +77 -0
  92. package/dist/cli/visualize.d.ts.map +1 -0
  93. package/dist/cli/visualize.js +287 -0
  94. package/dist/cli/visualize.js.map +1 -0
  95. package/dist/cli/worktree.d.ts +9 -0
  96. package/dist/cli/worktree.d.ts.map +1 -0
  97. package/dist/cli/worktree.js +175 -0
  98. package/dist/cli/worktree.js.map +1 -0
  99. package/dist/coordination/capability-router.d.ts +79 -0
  100. package/dist/coordination/capability-router.d.ts.map +1 -0
  101. package/dist/coordination/capability-router.js +324 -0
  102. package/dist/coordination/capability-router.js.map +1 -0
  103. package/dist/coordination/database.d.ts +13 -0
  104. package/dist/coordination/database.d.ts.map +1 -0
  105. package/dist/coordination/database.js +131 -0
  106. package/dist/coordination/database.js.map +1 -0
  107. package/dist/coordination/deploy-batcher.d.ts +101 -0
  108. package/dist/coordination/deploy-batcher.d.ts.map +1 -0
  109. package/dist/coordination/deploy-batcher.js +565 -0
  110. package/dist/coordination/deploy-batcher.js.map +1 -0
  111. package/dist/coordination/index.d.ts +5 -0
  112. package/dist/coordination/index.d.ts.map +1 -0
  113. package/dist/coordination/index.js +5 -0
  114. package/dist/coordination/index.js.map +1 -0
  115. package/dist/coordination/service.d.ts +81 -0
  116. package/dist/coordination/service.d.ts.map +1 -0
  117. package/dist/coordination/service.js +603 -0
  118. package/dist/coordination/service.js.map +1 -0
  119. package/dist/generators/claude-md.d.ts +3 -0
  120. package/dist/generators/claude-md.d.ts.map +1 -0
  121. package/dist/generators/claude-md.js +977 -0
  122. package/dist/generators/claude-md.js.map +1 -0
  123. package/dist/generators/template-loader.d.ts +105 -0
  124. package/dist/generators/template-loader.d.ts.map +1 -0
  125. package/dist/generators/template-loader.js +291 -0
  126. package/dist/generators/template-loader.js.map +1 -0
  127. package/dist/index.d.ts +47 -0
  128. package/dist/index.d.ts.map +1 -0
  129. package/dist/index.js +59 -0
  130. package/dist/index.js.map +1 -0
  131. package/dist/mcp-router/config/parser.d.ts +9 -0
  132. package/dist/mcp-router/config/parser.d.ts.map +1 -0
  133. package/dist/mcp-router/config/parser.js +174 -0
  134. package/dist/mcp-router/config/parser.js.map +1 -0
  135. package/dist/mcp-router/executor/client.d.ts +31 -0
  136. package/dist/mcp-router/executor/client.d.ts.map +1 -0
  137. package/dist/mcp-router/executor/client.js +187 -0
  138. package/dist/mcp-router/executor/client.js.map +1 -0
  139. package/dist/mcp-router/index.d.ts +22 -0
  140. package/dist/mcp-router/index.d.ts.map +1 -0
  141. package/dist/mcp-router/index.js +18 -0
  142. package/dist/mcp-router/index.js.map +1 -0
  143. package/dist/mcp-router/output-compressor.d.ts +26 -0
  144. package/dist/mcp-router/output-compressor.d.ts.map +1 -0
  145. package/dist/mcp-router/output-compressor.js +236 -0
  146. package/dist/mcp-router/output-compressor.js.map +1 -0
  147. package/dist/mcp-router/search/fuzzy.d.ts +26 -0
  148. package/dist/mcp-router/search/fuzzy.d.ts.map +1 -0
  149. package/dist/mcp-router/search/fuzzy.js +94 -0
  150. package/dist/mcp-router/search/fuzzy.js.map +1 -0
  151. package/dist/mcp-router/server.d.ts +50 -0
  152. package/dist/mcp-router/server.d.ts.map +1 -0
  153. package/dist/mcp-router/server.js +229 -0
  154. package/dist/mcp-router/server.js.map +1 -0
  155. package/dist/mcp-router/session-stats.d.ts +37 -0
  156. package/dist/mcp-router/session-stats.d.ts.map +1 -0
  157. package/dist/mcp-router/session-stats.js +56 -0
  158. package/dist/mcp-router/session-stats.js.map +1 -0
  159. package/dist/mcp-router/tools/discover.d.ts +37 -0
  160. package/dist/mcp-router/tools/discover.d.ts.map +1 -0
  161. package/dist/mcp-router/tools/discover.js +65 -0
  162. package/dist/mcp-router/tools/discover.js.map +1 -0
  163. package/dist/mcp-router/tools/execute.d.ts +43 -0
  164. package/dist/mcp-router/tools/execute.d.ts.map +1 -0
  165. package/dist/mcp-router/tools/execute.js +103 -0
  166. package/dist/mcp-router/tools/execute.js.map +1 -0
  167. package/dist/mcp-router/types.d.ts +62 -0
  168. package/dist/mcp-router/types.d.ts.map +1 -0
  169. package/dist/mcp-router/types.js +6 -0
  170. package/dist/mcp-router/types.js.map +1 -0
  171. package/dist/memory/adaptive-context.d.ts +146 -0
  172. package/dist/memory/adaptive-context.d.ts.map +1 -0
  173. package/dist/memory/adaptive-context.js +1022 -0
  174. package/dist/memory/adaptive-context.js.map +1 -0
  175. package/dist/memory/agent-scoped-memory.d.ts +67 -0
  176. package/dist/memory/agent-scoped-memory.d.ts.map +1 -0
  177. package/dist/memory/agent-scoped-memory.js +126 -0
  178. package/dist/memory/agent-scoped-memory.js.map +1 -0
  179. package/dist/memory/backends/base.d.ts +18 -0
  180. package/dist/memory/backends/base.d.ts.map +1 -0
  181. package/dist/memory/backends/base.js +2 -0
  182. package/dist/memory/backends/base.js.map +1 -0
  183. package/dist/memory/backends/factory.d.ts +4 -0
  184. package/dist/memory/backends/factory.d.ts.map +1 -0
  185. package/dist/memory/backends/factory.js +53 -0
  186. package/dist/memory/backends/factory.js.map +1 -0
  187. package/dist/memory/backends/github.d.ts +22 -0
  188. package/dist/memory/backends/github.d.ts.map +1 -0
  189. package/dist/memory/backends/github.js +118 -0
  190. package/dist/memory/backends/github.js.map +1 -0
  191. package/dist/memory/backends/qdrant-cloud.d.ts +32 -0
  192. package/dist/memory/backends/qdrant-cloud.d.ts.map +1 -0
  193. package/dist/memory/backends/qdrant-cloud.js +168 -0
  194. package/dist/memory/backends/qdrant-cloud.js.map +1 -0
  195. package/dist/memory/context-compressor.d.ts +74 -0
  196. package/dist/memory/context-compressor.d.ts.map +1 -0
  197. package/dist/memory/context-compressor.js +289 -0
  198. package/dist/memory/context-compressor.js.map +1 -0
  199. package/dist/memory/correction-propagator.d.ts +44 -0
  200. package/dist/memory/correction-propagator.d.ts.map +1 -0
  201. package/dist/memory/correction-propagator.js +156 -0
  202. package/dist/memory/correction-propagator.js.map +1 -0
  203. package/dist/memory/daily-log.d.ts +67 -0
  204. package/dist/memory/daily-log.d.ts.map +1 -0
  205. package/dist/memory/daily-log.js +143 -0
  206. package/dist/memory/daily-log.js.map +1 -0
  207. package/dist/memory/dynamic-retrieval.d.ts +110 -0
  208. package/dist/memory/dynamic-retrieval.d.ts.map +1 -0
  209. package/dist/memory/dynamic-retrieval.js +688 -0
  210. package/dist/memory/dynamic-retrieval.js.map +1 -0
  211. package/dist/memory/embeddings.d.ts +116 -0
  212. package/dist/memory/embeddings.d.ts.map +1 -0
  213. package/dist/memory/embeddings.js +461 -0
  214. package/dist/memory/embeddings.js.map +1 -0
  215. package/dist/memory/hierarchical-memory.d.ts +141 -0
  216. package/dist/memory/hierarchical-memory.d.ts.map +1 -0
  217. package/dist/memory/hierarchical-memory.js +477 -0
  218. package/dist/memory/hierarchical-memory.js.map +1 -0
  219. package/dist/memory/memory-consolidator.d.ts +124 -0
  220. package/dist/memory/memory-consolidator.d.ts.map +1 -0
  221. package/dist/memory/memory-consolidator.js +514 -0
  222. package/dist/memory/memory-consolidator.js.map +1 -0
  223. package/dist/memory/memory-maintenance.d.ts +39 -0
  224. package/dist/memory/memory-maintenance.d.ts.map +1 -0
  225. package/dist/memory/memory-maintenance.js +305 -0
  226. package/dist/memory/memory-maintenance.js.map +1 -0
  227. package/dist/memory/model-router.d.ts +102 -0
  228. package/dist/memory/model-router.d.ts.map +1 -0
  229. package/dist/memory/model-router.js +448 -0
  230. package/dist/memory/model-router.js.map +1 -0
  231. package/dist/memory/multi-view-memory.d.ts +134 -0
  232. package/dist/memory/multi-view-memory.d.ts.map +1 -0
  233. package/dist/memory/multi-view-memory.js +420 -0
  234. package/dist/memory/multi-view-memory.js.map +1 -0
  235. package/dist/memory/prepopulate.d.ts +76 -0
  236. package/dist/memory/prepopulate.d.ts.map +1 -0
  237. package/dist/memory/prepopulate.js +815 -0
  238. package/dist/memory/prepopulate.js.map +1 -0
  239. package/dist/memory/semantic-compression.d.ts +77 -0
  240. package/dist/memory/semantic-compression.d.ts.map +1 -0
  241. package/dist/memory/semantic-compression.js +348 -0
  242. package/dist/memory/semantic-compression.js.map +1 -0
  243. package/dist/memory/serverless-qdrant.d.ts +102 -0
  244. package/dist/memory/serverless-qdrant.d.ts.map +1 -0
  245. package/dist/memory/serverless-qdrant.js +369 -0
  246. package/dist/memory/serverless-qdrant.js.map +1 -0
  247. package/dist/memory/short-term/factory.d.ts +26 -0
  248. package/dist/memory/short-term/factory.d.ts.map +1 -0
  249. package/dist/memory/short-term/factory.js +28 -0
  250. package/dist/memory/short-term/factory.js.map +1 -0
  251. package/dist/memory/short-term/indexeddb.d.ts +25 -0
  252. package/dist/memory/short-term/indexeddb.d.ts.map +1 -0
  253. package/dist/memory/short-term/indexeddb.js +64 -0
  254. package/dist/memory/short-term/indexeddb.js.map +1 -0
  255. package/dist/memory/short-term/schema.d.ts +6 -0
  256. package/dist/memory/short-term/schema.d.ts.map +1 -0
  257. package/dist/memory/short-term/schema.js +119 -0
  258. package/dist/memory/short-term/schema.js.map +1 -0
  259. package/dist/memory/short-term/sqlite.d.ts +50 -0
  260. package/dist/memory/short-term/sqlite.d.ts.map +1 -0
  261. package/dist/memory/short-term/sqlite.js +221 -0
  262. package/dist/memory/short-term/sqlite.js.map +1 -0
  263. package/dist/memory/speculative-cache.d.ts +111 -0
  264. package/dist/memory/speculative-cache.d.ts.map +1 -0
  265. package/dist/memory/speculative-cache.js +409 -0
  266. package/dist/memory/speculative-cache.js.map +1 -0
  267. package/dist/memory/task-classifier.d.ts +34 -0
  268. package/dist/memory/task-classifier.d.ts.map +1 -0
  269. package/dist/memory/task-classifier.js +300 -0
  270. package/dist/memory/task-classifier.js.map +1 -0
  271. package/dist/memory/terminal-bench-knowledge.d.ts +48 -0
  272. package/dist/memory/terminal-bench-knowledge.d.ts.map +1 -0
  273. package/dist/memory/terminal-bench-knowledge.js +399 -0
  274. package/dist/memory/terminal-bench-knowledge.js.map +1 -0
  275. package/dist/memory/write-gate.d.ts +39 -0
  276. package/dist/memory/write-gate.d.ts.map +1 -0
  277. package/dist/memory/write-gate.js +190 -0
  278. package/dist/memory/write-gate.js.map +1 -0
  279. package/dist/models/executor.d.ts +130 -0
  280. package/dist/models/executor.d.ts.map +1 -0
  281. package/dist/models/executor.js +383 -0
  282. package/dist/models/executor.js.map +1 -0
  283. package/dist/models/index.d.ts +15 -0
  284. package/dist/models/index.d.ts.map +1 -0
  285. package/dist/models/index.js +17 -0
  286. package/dist/models/index.js.map +1 -0
  287. package/dist/models/planner.d.ts +71 -0
  288. package/dist/models/planner.d.ts.map +1 -0
  289. package/dist/models/planner.js +344 -0
  290. package/dist/models/planner.js.map +1 -0
  291. package/dist/models/router.d.ts +75 -0
  292. package/dist/models/router.d.ts.map +1 -0
  293. package/dist/models/router.js +344 -0
  294. package/dist/models/router.js.map +1 -0
  295. package/dist/models/types.d.ts +370 -0
  296. package/dist/models/types.d.ts.map +1 -0
  297. package/dist/models/types.js +181 -0
  298. package/dist/models/types.js.map +1 -0
  299. package/dist/tasks/coordination.d.ts +74 -0
  300. package/dist/tasks/coordination.d.ts.map +1 -0
  301. package/dist/tasks/coordination.js +237 -0
  302. package/dist/tasks/coordination.js.map +1 -0
  303. package/dist/tasks/database.d.ts +14 -0
  304. package/dist/tasks/database.d.ts.map +1 -0
  305. package/dist/tasks/database.js +128 -0
  306. package/dist/tasks/database.js.map +1 -0
  307. package/dist/tasks/index.d.ts +5 -0
  308. package/dist/tasks/index.d.ts.map +1 -0
  309. package/dist/tasks/index.js +5 -0
  310. package/dist/tasks/index.js.map +1 -0
  311. package/dist/tasks/service.d.ts +39 -0
  312. package/dist/tasks/service.d.ts.map +1 -0
  313. package/dist/tasks/service.js +582 -0
  314. package/dist/tasks/service.js.map +1 -0
  315. package/dist/tasks/types.d.ts +224 -0
  316. package/dist/tasks/types.d.ts.map +1 -0
  317. package/dist/tasks/types.js +64 -0
  318. package/dist/tasks/types.js.map +1 -0
  319. package/dist/types/analysis.d.ts +82 -0
  320. package/dist/types/analysis.d.ts.map +1 -0
  321. package/dist/types/analysis.js +2 -0
  322. package/dist/types/analysis.js.map +1 -0
  323. package/dist/types/config.d.ts +3023 -0
  324. package/dist/types/config.d.ts.map +1 -0
  325. package/dist/types/config.js +292 -0
  326. package/dist/types/config.js.map +1 -0
  327. package/dist/types/coordination.d.ts +240 -0
  328. package/dist/types/coordination.d.ts.map +1 -0
  329. package/dist/types/coordination.js +43 -0
  330. package/dist/types/coordination.js.map +1 -0
  331. package/dist/types/index.d.ts +4 -0
  332. package/dist/types/index.d.ts.map +1 -0
  333. package/dist/types/index.js +4 -0
  334. package/dist/types/index.js.map +1 -0
  335. package/dist/utils/calculate-average.d.ts +15 -0
  336. package/dist/utils/calculate-average.d.ts.map +1 -0
  337. package/dist/utils/calculate-average.js +21 -0
  338. package/dist/utils/calculate-average.js.map +1 -0
  339. package/dist/utils/config-manager.d.ts +30 -0
  340. package/dist/utils/config-manager.d.ts.map +1 -0
  341. package/dist/utils/config-manager.js +41 -0
  342. package/dist/utils/config-manager.js.map +1 -0
  343. package/dist/utils/dijkstra.d.ts +17 -0
  344. package/dist/utils/dijkstra.d.ts.map +1 -0
  345. package/dist/utils/dijkstra.js +91 -0
  346. package/dist/utils/dijkstra.js.map +1 -0
  347. package/dist/utils/fetch-with-retry.d.ts +5 -0
  348. package/dist/utils/fetch-with-retry.d.ts.map +1 -0
  349. package/dist/utils/fetch-with-retry.js +61 -0
  350. package/dist/utils/fetch-with-retry.js.map +1 -0
  351. package/dist/utils/merge-claude-md.d.ts +28 -0
  352. package/dist/utils/merge-claude-md.d.ts.map +1 -0
  353. package/dist/utils/merge-claude-md.js +342 -0
  354. package/dist/utils/merge-claude-md.js.map +1 -0
  355. package/dist/utils/order-processor-refactored.d.ts +126 -0
  356. package/dist/utils/order-processor-refactored.d.ts.map +1 -0
  357. package/dist/utils/order-processor-refactored.js +165 -0
  358. package/dist/utils/order-processor-refactored.js.map +1 -0
  359. package/dist/utils/order-processor-strategy.d.ts +72 -0
  360. package/dist/utils/order-processor-strategy.d.ts.map +1 -0
  361. package/dist/utils/order-processor-strategy.js +158 -0
  362. package/dist/utils/order-processor-strategy.js.map +1 -0
  363. package/dist/utils/order-processor.d.ts +242 -0
  364. package/dist/utils/order-processor.d.ts.map +1 -0
  365. package/dist/utils/order-processor.js +370 -0
  366. package/dist/utils/order-processor.js.map +1 -0
  367. package/dist/utils/rate-limiter-simple.d.ts +58 -0
  368. package/dist/utils/rate-limiter-simple.d.ts.map +1 -0
  369. package/dist/utils/rate-limiter-simple.js +100 -0
  370. package/dist/utils/rate-limiter-simple.js.map +1 -0
  371. package/dist/utils/rate-limiter.d.ts +62 -0
  372. package/dist/utils/rate-limiter.d.ts.map +1 -0
  373. package/dist/utils/rate-limiter.js +150 -0
  374. package/dist/utils/rate-limiter.js.map +1 -0
  375. package/dist/utils/string-similarity.d.ts +37 -0
  376. package/dist/utils/string-similarity.d.ts.map +1 -0
  377. package/dist/utils/string-similarity.js +114 -0
  378. package/dist/utils/string-similarity.js.map +1 -0
  379. package/dist/utils/validate-json.d.ts +51 -0
  380. package/dist/utils/validate-json.d.ts.map +1 -0
  381. package/dist/utils/validate-json.js +99 -0
  382. package/dist/utils/validate-json.js.map +1 -0
  383. package/package.json +96 -0
  384. package/templates/CLAUDE.template.md +11 -0
  385. package/templates/CLAUDE_ARCHITECTURE.template.md +103 -0
  386. package/templates/CLAUDE_CODING.template.md +125 -0
  387. package/templates/CLAUDE_DROIDS.template.md +109 -0
  388. package/templates/CLAUDE_MEMORY.template.md +130 -0
  389. package/templates/CLAUDE_WORKFLOWS.template.md +136 -0
  390. package/templates/PROJECT.template.md +209 -0
  391. package/templates/SCHEMA.md +57 -0
  392. package/templates/archive/CLAUDE.template.root-v6.md +762 -0
  393. package/templates/archive/CLAUDE.template.v6.md +762 -0
  394. package/templates/hooks/pre-compact.sh +68 -0
  395. package/templates/hooks/session-start.sh +106 -0
  396. package/tools/agents/README.md +224 -0
  397. package/tools/agents/UAP/README.md +351 -0
  398. package/tools/agents/UAP/__init__.py +9 -0
  399. package/tools/agents/UAP/cli.py +675 -0
  400. package/tools/agents/UAP/version.py +2 -0
  401. package/tools/agents/benchmarks/benchmark_memory_systems.py +637 -0
  402. package/tools/agents/benchmarks/results/benchmark_20260106_064817.json +170 -0
  403. package/tools/agents/benchmarks/results/benchmark_20260106_064817.md +51 -0
  404. package/tools/agents/config/chat_template.jinja +172 -0
  405. package/tools/agents/docker-compose.qdrant.yml +24 -0
  406. package/tools/agents/migrations/apply.py +256 -0
  407. package/tools/agents/scripts/fix_qwen_chat_template.py +314 -0
  408. package/tools/agents/scripts/init_qdrant.py +151 -0
  409. package/tools/agents/scripts/memory_migration.py +518 -0
  410. package/tools/agents/scripts/migrate_memory_to_qdrant.py +113 -0
  411. package/tools/agents/scripts/query_memory.py +189 -0
  412. package/tools/agents/scripts/qwen_tool_call_test.py +419 -0
  413. package/tools/agents/scripts/qwen_tool_call_wrapper.py +517 -0
  414. package/tools/agents/scripts/start-services.sh +96 -0
  415. package/tools/agents/tests/test_uap_compliance.py +257 -0
@@ -0,0 +1,314 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Qwen3.5 Chat Template Patch Script
4
+
5
+ Fixes the broken Jinja2 template that causes tool calling failures
6
+ after the first 1-2 tool calls.
7
+
8
+ Issue: Unclosed conditional blocks in tool call argument rendering
9
+ Source: Hugging Face Discussion #4
10
+
11
+ Usage:
12
+ python3 fix_qwen_chat_template.py [template_file]
13
+
14
+ If no template file specified, looks for:
15
+ - chat_template.jinja
16
+ - .opencode/agent/chat_template.jinja
17
+ - llama.cpp templates
18
+ """
19
+
20
+ import sys
21
+ import os
22
+ import re
23
+ from pathlib import Path
24
+ from datetime import datetime
25
+
26
+ # Template fix patterns
27
+ FIXES = [
28
+ {
29
+ "name": "Add conditional wrapper for tool call arguments",
30
+ "pattern": r"{%- for args_name, args_value in tool_call\.arguments \| items %}",
31
+ "replacement": "{%- if tool_call.arguments is mapping %}\n {%- for args_name in tool_call.arguments %}",
32
+ "description": "Wraps tool call iteration in conditional to prevent errors",
33
+ },
34
+ {
35
+ "name": "Add missing endif after tool call loop",
36
+ "pattern": r"(\{%- endfor %\}\s*)(?!\{%- endif %\})",
37
+ "replacement": r"\1{%- endif %}",
38
+ "description": "Closes the conditional block for tool call arguments",
39
+ },
40
+ {
41
+ "name": "Fix unclosed thinking tags",
42
+ "pattern": r"(<thinking>.*?)(?!</thinking>)\s*(?=<function|</function>)",
43
+ "replacement": r"\1</thinking>",
44
+ "description": "Ensures thinking tags are properly closed",
45
+ "flags": re.DOTALL,
46
+ },
47
+ ]
48
+
49
+
50
+ def find_template_files():
51
+ """Search for Qwen3.5 chat template files"""
52
+ search_paths = [
53
+ Path("."),
54
+ Path(".opencode/agent"),
55
+ Path("llama.cpp"),
56
+ Path("tools/agents"),
57
+ Path("infra/k8s"),
58
+ Path("templates"),
59
+ ]
60
+
61
+ template_files = []
62
+
63
+ for search_path in search_paths:
64
+ if not search_path.exists():
65
+ continue
66
+
67
+ # Look for template files
68
+ patterns = ["chat_template.jinja", "chat_template.txt", "qwen*.jinja"]
69
+
70
+ for pattern in patterns:
71
+ found = list(search_path.glob(pattern))
72
+ template_files.extend(found)
73
+
74
+ # Also check for files with Qwen in name
75
+ if (search_path / "tokenizer_config.json").exists():
76
+ template_files.append(search_path / "tokenizer_config.json")
77
+
78
+ # Remove duplicates and sort by path length (prefer more specific paths)
79
+ unique_files = list(set(template_files))
80
+ unique_files.sort(key=lambda x: len(str(x)))
81
+
82
+ return unique_files
83
+
84
+
85
+ def read_template(filepath):
86
+ """Read template file content"""
87
+ try:
88
+ with open(filepath, "r", encoding="utf-8") as f:
89
+ return f.read()
90
+ except Exception as e:
91
+ print(f"āŒ Error reading {filepath}: {e}")
92
+ return None
93
+
94
+
95
+ def write_template(filepath, content):
96
+ """Write content to template file"""
97
+ try:
98
+ with open(filepath, "w", encoding="utf-8") as f:
99
+ f.write(content)
100
+ return True
101
+ except Exception as e:
102
+ print(f"āŒ Error writing {filepath}: {e}")
103
+ return False
104
+
105
+
106
+ def backup_template(filepath):
107
+ """Create backup of template file"""
108
+ backup_path = f"{filepath}.backup.{datetime.now().strftime('%Y%m%d_%H%M%S')}"
109
+
110
+ try:
111
+ with open(filepath, "r", encoding="utf-8") as src:
112
+ with open(backup_path, "w", encoding="utf-8") as dst:
113
+ dst.write(src.read())
114
+ print(f"āœ… Backup created: {backup_path}")
115
+ return backup_path
116
+ except Exception as e:
117
+ print(f"āŒ Error creating backup: {e}")
118
+ return None
119
+
120
+
121
+ def apply_fix(template_content, fix):
122
+ """Apply a single fix to template content"""
123
+ name = fix["name"]
124
+ pattern = fix["pattern"]
125
+ replacement = fix["replacement"]
126
+ flags = fix.get("flags", 0)
127
+
128
+ try:
129
+ # Check if pattern exists in template
130
+ if re.search(pattern, template_content, flags):
131
+ # Apply fix
132
+ new_content = re.sub(pattern, replacement, template_content, flags=flags)
133
+
134
+ # Check if fix was actually applied
135
+ if new_content != template_content:
136
+ print(f" āœ“ Applied: {name}")
137
+ return new_content, True
138
+ else:
139
+ print(f" - Skipped: {name} (pattern not found)")
140
+ return template_content, False
141
+ else:
142
+ print(f" - Skipped: {name} (pattern not found)")
143
+ return template_content, False
144
+
145
+ except Exception as e:
146
+ print(f" āœ— Error applying {name}: {e}")
147
+ return template_content, False
148
+
149
+
150
+ def validate_template(template_content):
151
+ """Validate template structure"""
152
+ issues = []
153
+
154
+ # Check for balanced braces
155
+ if_template_count = template_content.count("{%- if ")
156
+ endif_count = template_content.count("{%- endif %}")
157
+
158
+ if if_template_count != endif_count:
159
+ issues.append(
160
+ f"Unbalanced if/endif: {if_template_count} if, {endif_count} endif"
161
+ )
162
+
163
+ # Check for tool call arguments pattern
164
+ if "tool_call.arguments" in template_content:
165
+ if "if tool_call.arguments is mapping" not in template_content:
166
+ issues.append("Missing conditional wrapper for tool_call.arguments")
167
+
168
+ # Check for thinking tags
169
+ thinking_open = template_content.count("<thinking>")
170
+ thinking_close = template_content.count("</thinking>")
171
+
172
+ if thinking_open != thinking_close:
173
+ issues.append(
174
+ f"Unbalanced thinking tags: {thinking_open} open, {thinking_close} close"
175
+ )
176
+
177
+ return issues
178
+
179
+
180
+ def print_template_diff(old_content, new_content):
181
+ """Print simplified diff showing key changes"""
182
+ old_lines = old_content.split("\n")
183
+ new_lines = new_content.split("\n")
184
+
185
+ print("\n" + "=" * 70)
186
+ print("KEY CHANGES:")
187
+ print("=" * 70)
188
+
189
+ # Find lines with tool call arguments
190
+ for i, line in enumerate(new_lines):
191
+ if "tool_call.arguments" in line and ("if" in line or "for" in line):
192
+ print(f"Line {i + 1}: {line.strip()}")
193
+
194
+ # Find endif additions
195
+ for i, line in enumerate(new_lines):
196
+ if "{%- endif %}" in line:
197
+ # Check if preceded by endfor
198
+ if i > 0 and "{%- endfor %}" in new_lines[i - 1]:
199
+ print(f"Line {i + 1}: {line.strip()} (closing tool call conditional)")
200
+
201
+ print("=" * 70 + "\n")
202
+
203
+
204
+ def main():
205
+ """Main execution"""
206
+ print("=" * 70)
207
+ print("Qwen3.5 Chat Template Patch Script")
208
+ print("=" * 70)
209
+
210
+ # Get template file
211
+ if len(sys.argv) > 1:
212
+ template_file = Path(sys.argv[1])
213
+ if not template_file.exists():
214
+ print(f"āŒ Template file not found: {template_file}")
215
+ sys.exit(1)
216
+ else:
217
+ print("Searching for template files...")
218
+ template_files = find_template_files()
219
+
220
+ if not template_files:
221
+ print("āŒ No template files found")
222
+ print("\nPlease specify template file manually:")
223
+ print(" python3 fix_qwen_chat_template.py /path/to/chat_template.jinja")
224
+ sys.exit(1)
225
+
226
+ print(f"Found {len(template_files)} potential template file(s):")
227
+ for i, tf in enumerate(template_files, 1):
228
+ print(f" {i}. {tf}")
229
+
230
+ # Use the most specific one (first in list)
231
+ template_file = template_files[0]
232
+ print(f"\nUsing: {template_file}\n")
233
+
234
+ # Read template
235
+ print(f"Reading template: {template_file}")
236
+ original_content = read_template(template_file)
237
+
238
+ if not original_content:
239
+ sys.exit(1)
240
+
241
+ # Create backup
242
+ backup_path = backup_template(template_file)
243
+ if not backup_path:
244
+ sys.exit(1)
245
+
246
+ # Validate before fix
247
+ print("\nValidating template before fix:")
248
+ issues_before = validate_template(original_content)
249
+ if issues_before:
250
+ print(" Issues found:")
251
+ for issue in issues_before:
252
+ print(f" - {issue}")
253
+ else:
254
+ print(" No obvious issues detected")
255
+
256
+ # Apply fixes
257
+ print("\nApplying fixes:")
258
+ fixed_content = original_content
259
+
260
+ for fix in FIXES:
261
+ fixed_content, applied = apply_fix(fixed_content, fix)
262
+
263
+ # Validate after fix
264
+ print("\nValidating template after fix:")
265
+ issues_after = validate_template(fixed_content)
266
+ if issues_after:
267
+ print(" Remaining issues:")
268
+ for issue in issues_after:
269
+ print(f" - {issue}")
270
+ else:
271
+ print(" āœ“ No obvious issues detected")
272
+
273
+ # Write fixed template
274
+ if fixed_content != original_content:
275
+ print(f"\nWriting fixed template: {template_file}")
276
+ if write_template(template_file, fixed_content):
277
+ print("āœ… Template patch applied successfully!")
278
+ else:
279
+ print("āŒ Failed to write template")
280
+ sys.exit(1)
281
+ else:
282
+ print("\nāš ļø No changes were made - template may already be fixed")
283
+
284
+ # Print summary
285
+ print_template_diff(original_content, fixed_content)
286
+
287
+ # Print instructions
288
+ print("\n" + "=" * 70)
289
+ print("NEXT STEPS:")
290
+ print("=" * 70)
291
+ print("1. Verify the template was patched correctly:")
292
+ print(f" grep -n 'if tool_call.arguments is mapping' {template_file}")
293
+ print("\n2. Restart llama.cpp server with the fixed template:")
294
+ print(" ./llama.cpp/llama-server \\")
295
+ print(" --chat-template-file chat_template.jinja \\")
296
+ print(" --jinja \\")
297
+ print(" --port 8080")
298
+ print("\n3. Test tool calling:")
299
+ print(" python3 qwen_tool_call_test.py")
300
+ print("=" * 70)
301
+
302
+
303
+ if __name__ == "__main__":
304
+ try:
305
+ main()
306
+ except KeyboardInterrupt:
307
+ print("\nāŒ Interrupted by user")
308
+ sys.exit(1)
309
+ except Exception as e:
310
+ print(f"\nāŒ Unexpected error: {e}")
311
+ import traceback
312
+
313
+ traceback.print_exc()
314
+ sys.exit(1)
@@ -0,0 +1,151 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Qdrant Vector Database Initialization Script
4
+
5
+ This script initializes the Qdrant collection for semantic memory.
6
+
7
+ Usage:
8
+ tools/agents/scripts/init_qdrant.py
9
+ """
10
+
11
+ import sys
12
+ from pathlib import Path
13
+
14
+ try:
15
+ from sentence_transformers import SentenceTransformer
16
+ from qdrant_client import QdrantClient
17
+ from qdrant_client.models import (
18
+ Distance,
19
+ VectorParams,
20
+ PointStruct,
21
+ )
22
+ except ImportError:
23
+ print("āŒ Required packages not installed")
24
+ print("\nInstall with:")
25
+ print(" tools/agents/.venv/bin/pip install sentence-transformers qdrant-client")
26
+ sys.exit(1)
27
+
28
+
29
+ def get_project_root():
30
+ """Get project root directory."""
31
+ return Path(__file__).parent.parent.parent
32
+
33
+
34
+ def init_collection():
35
+ """Initialize Qdrant collection for UAM memory."""
36
+ print("=== Initializing Qdrant Vector Database ===\n")
37
+
38
+ # Connect to Qdrant
39
+ client = QdrantClient(host="localhost", port=6333)
40
+
41
+ # Check if collection exists
42
+ collections = client.get_collections().collections
43
+ collection_name = "uam_memory"
44
+
45
+ if any(c.name == collection_name for c in collections):
46
+ print(f"āš ļø Collection '{collection_name}' already exists")
47
+ response = input("Delete and recreate? (y/N): ").strip().lower()
48
+ if response != "y":
49
+ print("Skipping initialization")
50
+ return 0
51
+
52
+ # Load embedding model
53
+ print("šŸ“¦ Loading embedding model (this may take a minute)...")
54
+ model = SentenceTransformer("all-MiniLM-L6-v2")
55
+ vector_size = len(model.encode("test"))
56
+ print(f" āœ… Model loaded, vector size: {vector_size}")
57
+
58
+ # Create collection
59
+ print(f"\nšŸ“¦ Creating collection '{collection_name}'...")
60
+ client.create_collection(
61
+ collection_name=collection_name,
62
+ vectors=VectorParams(size=vector_size, distance=Distance.COSINE),
63
+ )
64
+ print(" āœ… Collection created")
65
+
66
+ # Create payload index for metadata filtering
67
+ print("\nšŸ“¦ Creating payload indexes...")
68
+ client.create_payload_index(
69
+ collection_name=collection_name,
70
+ field_name="type",
71
+ field_schema="keyword",
72
+ )
73
+ client.create_payload_index(
74
+ collection_name=collection_name,
75
+ field_name="tags",
76
+ field_schema="keyword",
77
+ )
78
+ client.create_payload_index(
79
+ collection_name=collection_name,
80
+ field_name="importance",
81
+ field_schema="integer",
82
+ )
83
+ print(" āœ… Payload indexes created")
84
+
85
+ # Migrate existing JSON memories
86
+ json_memory_path = get_project_root() / "agents/data/memory/long_term.json"
87
+ if json_memory_path.exists():
88
+ print(f"\nšŸ“¦ Migrating memories from {json_memory_path}...")
89
+
90
+ import json
91
+
92
+ with open(json_memory_path, "r") as f:
93
+ data = json.load(f)
94
+
95
+ memories = data.get("memories", [])
96
+ points = []
97
+
98
+ for mem in memories:
99
+ embedding = model.encode(mem["content"]).tolist()
100
+
101
+ point = PointStruct(
102
+ id=mem.get("id", hash(mem["content"]) % 1000000),
103
+ vector=embedding,
104
+ payload={
105
+ "original_id": mem.get("id"),
106
+ "type": mem.get("type"),
107
+ "tags": mem.get("tags", []),
108
+ "importance": mem.get("importance", 5),
109
+ "content": mem.get("content"),
110
+ "timestamp": mem.get("timestamp"),
111
+ },
112
+ )
113
+ points.append(point)
114
+
115
+ if points:
116
+ client.upsert(collection_name=collection_name, points=points)
117
+ print(f" āœ… Migrated {len(points)} memories")
118
+ else:
119
+ print(" āš ļø No memories to migrate")
120
+ else:
121
+ print("\nāš ļø No long_term.json found (skipping migration)")
122
+
123
+ # Test query
124
+ print("\nšŸ“¦ Testing collection...")
125
+ test_query = "architecture"
126
+ test_embedding = model.encode(test_query).tolist()
127
+
128
+ results = client.search(
129
+ collection_name=collection_name,
130
+ query_vector=test_embedding,
131
+ limit=3,
132
+ )
133
+
134
+ print(f" āœ… Query successful: {len(results)} results found")
135
+
136
+ print("\n" + "=" * 50)
137
+ print("āœ… Qdrant initialization completed!")
138
+ print("=" * 50)
139
+ print("\nCollection details:")
140
+ print(f" Name: {collection_name}")
141
+ print(f" Vector size: {vector_size}")
142
+ print(f" Distance: COSINE")
143
+ print(f" REST API: http://localhost:6333")
144
+ print(f"\nTo query:")
145
+ print(' tools/agents/scripts/query_memory.py long "<query>"')
146
+
147
+ return 0
148
+
149
+
150
+ if __name__ == "__main__":
151
+ sys.exit(init_collection())