@tekmidian/pai 0.9.9 → 0.9.11

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 (46) hide show
  1. package/ARCHITECTURE.md +73 -1
  2. package/README.md +54 -2
  3. package/dist/{auto-route-CruBrTf-.mjs → auto-route-DL4ViDKC.mjs} +2 -2
  4. package/dist/{auto-route-CruBrTf-.mjs.map → auto-route-DL4ViDKC.mjs.map} +1 -1
  5. package/dist/cli/index.mjs +250 -16
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/daemon/index.mjs +7 -6
  8. package/dist/daemon/index.mjs.map +1 -1
  9. package/dist/{daemon-WQY1kwOF.mjs → daemon-dYymOnwd.mjs} +39 -19
  10. package/dist/daemon-dYymOnwd.mjs.map +1 -0
  11. package/dist/daemon-mcp/index.mjs +46 -0
  12. package/dist/daemon-mcp/index.mjs.map +1 -1
  13. package/dist/{db-DdUperSl.mjs → db-CYmBWcjh.mjs} +35 -13
  14. package/dist/db-CYmBWcjh.mjs.map +1 -0
  15. package/dist/{detector-CNU3zCwP.mjs → detector-AzVtGLtL.mjs} +2 -2
  16. package/dist/{detector-CNU3zCwP.mjs.map → detector-AzVtGLtL.mjs.map} +1 -1
  17. package/dist/{factory-DKDPRhAN.mjs → factory-BDBIfTDC.mjs} +3 -3
  18. package/dist/{factory-DKDPRhAN.mjs.map → factory-BDBIfTDC.mjs.map} +1 -1
  19. package/dist/hooks/session-commands.mjs +17 -0
  20. package/dist/hooks/session-commands.mjs.map +7 -0
  21. package/dist/hooks/whisper-rules.mjs +12 -11
  22. package/dist/hooks/whisper-rules.mjs.map +2 -2
  23. package/dist/index.d.mts +3 -1
  24. package/dist/index.d.mts.map +1 -1
  25. package/dist/index.mjs +2 -2
  26. package/dist/kg-entity-D5v7RCDi.mjs +176 -0
  27. package/dist/kg-entity-D5v7RCDi.mjs.map +1 -0
  28. package/dist/{kg-extraction-BlGM40q7.mjs → kg-extraction-Uvr9fTlz.mjs} +56 -21
  29. package/dist/kg-extraction-Uvr9fTlz.mjs.map +1 -0
  30. package/dist/{search-DC1qhkKn.mjs → search-i2nlQ-JM.mjs} +48 -19
  31. package/dist/search-i2nlQ-JM.mjs.map +1 -0
  32. package/dist/{sqlite-BJrME_vg.mjs → sqlite-xUe94oUZ.mjs} +9 -2
  33. package/dist/sqlite-xUe94oUZ.mjs.map +1 -0
  34. package/dist/{tools-gMHdjmHC.mjs → tools-BNBvJNph.mjs} +285 -7
  35. package/dist/tools-BNBvJNph.mjs.map +1 -0
  36. package/package.json +1 -1
  37. package/src/hooks/ts/session-start/session-commands.ts +26 -0
  38. package/src/hooks/ts/user-prompt/whisper-rules.ts +12 -11
  39. package/dist/daemon-WQY1kwOF.mjs.map +0 -1
  40. package/dist/db-DdUperSl.mjs.map +0 -1
  41. package/dist/kg-B5ysyRLC.mjs +0 -94
  42. package/dist/kg-B5ysyRLC.mjs.map +0 -1
  43. package/dist/kg-extraction-BlGM40q7.mjs.map +0 -1
  44. package/dist/search-DC1qhkKn.mjs.map +0 -1
  45. package/dist/sqlite-BJrME_vg.mjs.map +0 -1
  46. package/dist/tools-gMHdjmHC.mjs.map +0 -1
@@ -4860,6 +4860,52 @@ async function startShim() {
4860
4860
  min_occurrences: number().int().min(1).optional().describe("Minimum total chunk occurrences across all projects. Default: 3."),
4861
4861
  limit: number().int().min(1).max(100).optional().describe("Maximum number of tunnels to return. Default: 20.")
4862
4862
  }, async (args) => proxyTool("memory_tunnels", args));
4863
+ server.tool("memory_feedback", [
4864
+ "Apply relevance feedback to memory chunks to improve future search ranking.",
4865
+ "",
4866
+ "After reading search results, rate their relevance to adjust the EMA-based",
4867
+ "feedback weights. Higher-rated chunks will score better in future searches",
4868
+ "via the multiplier: final_score *= (0.5 + relevance_score).",
4869
+ "",
4870
+ "Also updates feedback weights on KG entities mentioned in those chunks.",
4871
+ "",
4872
+ "Rating scale: 1 = not relevant, 3 = somewhat relevant, 5 = highly relevant.",
4873
+ "",
4874
+ "Use chunk IDs from memory_search compact format results."
4875
+ ].join("\n"), {
4876
+ chunk_ids: array(string()).describe("Array of chunk IDs to apply feedback to (from memory_search results)."),
4877
+ rating: number().min(1).max(5).describe("Relevance rating from 1 (not relevant) to 5 (highly relevant)."),
4878
+ tenant_id: string().optional().describe("Tenant ID for entity feedback scoping. Default: 'default'.")
4879
+ }, async (args) => proxyTool("memory_feedback", args));
4880
+ server.tool("memory_kg_search", [
4881
+ "Graph-completion search: combines vector search with knowledge-graph neighborhood expansion.",
4882
+ "",
4883
+ "Algorithm:",
4884
+ " Phase 1: Wide vector search (seed chunks) using the query embedding",
4885
+ " Phase 2: Extract entity mentions from seed chunks (matched against kg_entities)",
4886
+ " Phase 3: BFS neighborhood expansion in kg_triples (1-2 hops from matched entities)",
4887
+ " Phase 4: Re-rank all collected triples against the query embedding",
4888
+ "",
4889
+ "Returns ranked KG triples with relevance scores, surfacing graph-derived context",
4890
+ "that pure vector search would miss — relationships, facts, and entity connections.",
4891
+ "",
4892
+ "Requires Postgres backend with a populated kg_triples table.",
4893
+ "Use kg_add to populate the knowledge graph, or rely on automatic extraction.",
4894
+ "",
4895
+ "Parameters:",
4896
+ " query — Free-text query (converted to embedding for Phase 1)",
4897
+ " project_id — Restrict seed search to a specific project (optional)",
4898
+ " wide_k — Number of seed chunks from Phase 1 (default: 50)",
4899
+ " neighborhood_depth — BFS hop depth for KG expansion (default: 1, max: 2)",
4900
+ " top_k — Maximum triples to return after re-ranking (default: 20)"
4901
+ ].join("\n"), {
4902
+ query: string().describe("Free-text search query — used to generate embedding for Phase 1 vector search."),
4903
+ project_id: number().int().optional().describe("Restrict seed vector search to a specific project ID. Omit to search all projects."),
4904
+ wide_k: number().int().min(1).max(200).optional().describe("Number of seed chunks to fetch in Phase 1 vector search. Default: 50."),
4905
+ neighborhood_depth: number().int().min(1).max(2).optional().describe("BFS hop depth for KG neighborhood expansion. Default: 1. Max: 2."),
4906
+ top_k: number().int().min(1).max(100).optional().describe("Maximum KG triples to return after re-ranking. Default: 20."),
4907
+ tenant_id: string().optional().describe("Tenant ID for entity lookup scoping. Default: 'default'.")
4908
+ }, async (args) => proxyTool("memory_kg_search", args));
4863
4909
  const transport = new StdioServerTransport();
4864
4910
  await server.connect(transport);
4865
4911
  }