gitmem-mcp 1.0.2 → 1.0.4

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 (299) hide show
  1. package/CHANGELOG.md +20 -6
  2. package/README.md +30 -9
  3. package/dist/commands/check.d.ts +1 -1
  4. package/dist/commands/check.js +4 -3
  5. package/dist/diagnostics/anonymizer.d.ts +1 -1
  6. package/dist/diagnostics/anonymizer.js +1 -1
  7. package/dist/diagnostics/channels.d.ts +1 -1
  8. package/dist/diagnostics/channels.js +1 -1
  9. package/dist/diagnostics/collector.d.ts +1 -1
  10. package/dist/diagnostics/collector.js +1 -1
  11. package/dist/diagnostics/index.d.ts +1 -1
  12. package/dist/diagnostics/index.js +1 -1
  13. package/dist/hooks/quick-retrieve.js +2 -1
  14. package/dist/index.js +0 -0
  15. package/dist/schemas/active-sessions.d.ts +9 -9
  16. package/dist/schemas/active-sessions.js +1 -1
  17. package/dist/schemas/common.d.ts +2 -5
  18. package/dist/schemas/common.js +13 -7
  19. package/dist/schemas/create-learning.d.ts +4 -4
  20. package/dist/schemas/create-learning.js +1 -1
  21. package/dist/schemas/session-close.d.ts +5 -8
  22. package/dist/schemas/session-close.js +7 -3
  23. package/dist/schemas/session-start.d.ts +4 -4
  24. package/dist/schemas/session-start.js +1 -1
  25. package/dist/schemas/thread.d.ts +1 -1
  26. package/dist/schemas/thread.js +1 -1
  27. package/dist/server.d.ts +2 -2
  28. package/dist/server.js +21 -10
  29. package/dist/services/active-sessions.js +3 -2
  30. package/dist/services/agent-briefing.d.ts +12 -0
  31. package/dist/services/agent-briefing.js +81 -0
  32. package/dist/services/agent-detection.d.ts +2 -1
  33. package/dist/services/agent-detection.js +23 -14
  34. package/dist/services/analytics.d.ts +1 -1
  35. package/dist/services/analytics.js +3 -3
  36. package/dist/services/behavioral-decay.js +2 -2
  37. package/dist/services/cache.d.ts +1 -1
  38. package/dist/services/cache.js +1 -1
  39. package/dist/services/compliance-validator.d.ts +1 -1
  40. package/dist/services/compliance-validator.js +5 -5
  41. package/dist/services/config.d.ts +1 -1
  42. package/dist/services/config.js +1 -1
  43. package/dist/services/file-lock.js +12 -0
  44. package/dist/services/gitmem-dir.d.ts +17 -4
  45. package/dist/services/gitmem-dir.js +43 -9
  46. package/dist/services/local-file-storage.d.ts +1 -1
  47. package/dist/services/local-file-storage.js +16 -10
  48. package/dist/services/local-vector-search.d.ts +1 -1
  49. package/dist/services/local-vector-search.js +2 -2
  50. package/dist/services/metrics.d.ts +6 -6
  51. package/dist/services/metrics.js +8 -8
  52. package/dist/services/session-state.d.ts +7 -7
  53. package/dist/services/session-state.js +19 -7
  54. package/dist/services/startup.d.ts +1 -1
  55. package/dist/services/startup.js +3 -2
  56. package/dist/services/supabase-client.d.ts +17 -6
  57. package/dist/services/supabase-client.js +44 -8
  58. package/dist/services/thread-manager.d.ts +1 -1
  59. package/dist/services/thread-manager.js +5 -5
  60. package/dist/services/thread-supabase.d.ts +1 -1
  61. package/dist/services/thread-supabase.js +2 -2
  62. package/dist/services/tier.d.ts +2 -0
  63. package/dist/services/tier.js +4 -0
  64. package/dist/services/transcript-chunker.d.ts +1 -1
  65. package/dist/services/transcript-chunker.js +1 -1
  66. package/dist/services/triple-writer.d.ts +4 -4
  67. package/dist/services/triple-writer.js +11 -20
  68. package/dist/services/variant-assignment.d.ts +6 -6
  69. package/dist/services/variant-assignment.js +9 -8
  70. package/dist/tools/analyze.d.ts +2 -2
  71. package/dist/tools/analyze.js +2 -2
  72. package/dist/tools/archive-learning.js +36 -22
  73. package/dist/tools/confirm-scars.js +4 -0
  74. package/dist/tools/create-decision.d.ts +1 -1
  75. package/dist/tools/create-decision.js +2 -2
  76. package/dist/tools/create-learning.d.ts +1 -1
  77. package/dist/tools/create-learning.js +4 -4
  78. package/dist/tools/create-linear-issue.d.ts +18 -0
  79. package/dist/tools/create-linear-issue.js +197 -0
  80. package/dist/tools/create-thread.d.ts +1 -1
  81. package/dist/tools/create-thread.js +2 -2
  82. package/dist/tools/definitions.d.ts +280 -58
  83. package/dist/tools/definitions.js +127 -87
  84. package/dist/tools/get-transcript.d.ts +1 -1
  85. package/dist/tools/get-transcript.js +1 -1
  86. package/dist/tools/graph-traverse.d.ts +1 -1
  87. package/dist/tools/graph-traverse.js +20 -17
  88. package/dist/tools/list-threads.d.ts +2 -2
  89. package/dist/tools/list-threads.js +4 -4
  90. package/dist/tools/log.d.ts +1 -1
  91. package/dist/tools/log.js +1 -1
  92. package/dist/tools/prepare-context.d.ts +1 -1
  93. package/dist/tools/prepare-context.js +2 -2
  94. package/dist/tools/recall.d.ts +5 -4
  95. package/dist/tools/recall.js +37 -28
  96. package/dist/tools/record-scar-usage-batch.js +2 -2
  97. package/dist/tools/record-scar-usage.d.ts +1 -1
  98. package/dist/tools/record-scar-usage.js +3 -3
  99. package/dist/tools/resolve-thread.d.ts +2 -2
  100. package/dist/tools/resolve-thread.js +3 -3
  101. package/dist/tools/save-transcript.d.ts +1 -1
  102. package/dist/tools/save-transcript.js +1 -1
  103. package/dist/tools/search.d.ts +1 -1
  104. package/dist/tools/search.js +1 -1
  105. package/dist/tools/session-close.d.ts +1 -1
  106. package/dist/tools/session-close.js +58 -57
  107. package/dist/tools/session-start.d.ts +5 -5
  108. package/dist/tools/session-start.js +63 -61
  109. package/dist/types/index.d.ts +17 -13
  110. package/hooks/.claude-plugin/plugin.json +1 -1
  111. package/hooks/scripts/post-tool-use.sh +1 -1
  112. package/hooks/scripts/recall-check.sh +1 -1
  113. package/hooks/scripts/session-close-check.sh +1 -1
  114. package/hooks/scripts/session-start.sh +1 -1
  115. package/package.json +6 -3
  116. package/schema/starter-scars.json +3 -153
  117. package/dist/commands/check.d.ts.map +0 -1
  118. package/dist/commands/check.js.map +0 -1
  119. package/dist/constants/closing-questions.d.ts.map +0 -1
  120. package/dist/constants/closing-questions.js.map +0 -1
  121. package/dist/diagnostics/anonymizer.d.ts.map +0 -1
  122. package/dist/diagnostics/anonymizer.js.map +0 -1
  123. package/dist/diagnostics/channels.d.ts.map +0 -1
  124. package/dist/diagnostics/channels.js.map +0 -1
  125. package/dist/diagnostics/collector.d.ts.map +0 -1
  126. package/dist/diagnostics/collector.js.map +0 -1
  127. package/dist/diagnostics/index.d.ts.map +0 -1
  128. package/dist/diagnostics/index.js.map +0 -1
  129. package/dist/hooks/format-utils.d.ts.map +0 -1
  130. package/dist/hooks/format-utils.js.map +0 -1
  131. package/dist/hooks/quick-retrieve.d.ts.map +0 -1
  132. package/dist/hooks/quick-retrieve.js.map +0 -1
  133. package/dist/index.d.ts.map +0 -1
  134. package/dist/index.js.map +0 -1
  135. package/dist/schemas/absorb-observations.d.ts.map +0 -1
  136. package/dist/schemas/absorb-observations.js.map +0 -1
  137. package/dist/schemas/active-sessions.d.ts.map +0 -1
  138. package/dist/schemas/active-sessions.js.map +0 -1
  139. package/dist/schemas/analyze.d.ts.map +0 -1
  140. package/dist/schemas/analyze.js.map +0 -1
  141. package/dist/schemas/common.d.ts.map +0 -1
  142. package/dist/schemas/common.js.map +0 -1
  143. package/dist/schemas/create-decision.d.ts.map +0 -1
  144. package/dist/schemas/create-decision.js.map +0 -1
  145. package/dist/schemas/create-learning.d.ts.map +0 -1
  146. package/dist/schemas/create-learning.js.map +0 -1
  147. package/dist/schemas/get-transcript.d.ts.map +0 -1
  148. package/dist/schemas/get-transcript.js.map +0 -1
  149. package/dist/schemas/index.d.ts.map +0 -1
  150. package/dist/schemas/index.js.map +0 -1
  151. package/dist/schemas/log.d.ts.map +0 -1
  152. package/dist/schemas/log.js.map +0 -1
  153. package/dist/schemas/prepare-context.d.ts.map +0 -1
  154. package/dist/schemas/prepare-context.js.map +0 -1
  155. package/dist/schemas/recall.d.ts.map +0 -1
  156. package/dist/schemas/recall.js.map +0 -1
  157. package/dist/schemas/record-scar-usage-batch.d.ts.map +0 -1
  158. package/dist/schemas/record-scar-usage-batch.js.map +0 -1
  159. package/dist/schemas/record-scar-usage.d.ts.map +0 -1
  160. package/dist/schemas/record-scar-usage.js.map +0 -1
  161. package/dist/schemas/registry.d.ts.map +0 -1
  162. package/dist/schemas/registry.js.map +0 -1
  163. package/dist/schemas/save-transcript.d.ts.map +0 -1
  164. package/dist/schemas/save-transcript.js.map +0 -1
  165. package/dist/schemas/search-transcripts.d.ts.map +0 -1
  166. package/dist/schemas/search-transcripts.js.map +0 -1
  167. package/dist/schemas/search.d.ts.map +0 -1
  168. package/dist/schemas/search.js.map +0 -1
  169. package/dist/schemas/session-close.d.ts.map +0 -1
  170. package/dist/schemas/session-close.js.map +0 -1
  171. package/dist/schemas/session-start.d.ts.map +0 -1
  172. package/dist/schemas/session-start.js.map +0 -1
  173. package/dist/schemas/thread.d.ts.map +0 -1
  174. package/dist/schemas/thread.js.map +0 -1
  175. package/dist/server.d.ts.map +0 -1
  176. package/dist/server.js.map +0 -1
  177. package/dist/services/active-sessions.d.ts.map +0 -1
  178. package/dist/services/active-sessions.js.map +0 -1
  179. package/dist/services/agent-detection.d.ts.map +0 -1
  180. package/dist/services/agent-detection.js.map +0 -1
  181. package/dist/services/analytics.d.ts.map +0 -1
  182. package/dist/services/analytics.js.map +0 -1
  183. package/dist/services/behavioral-decay.d.ts.map +0 -1
  184. package/dist/services/behavioral-decay.js.map +0 -1
  185. package/dist/services/bm25.d.ts.map +0 -1
  186. package/dist/services/bm25.js.map +0 -1
  187. package/dist/services/cache.d.ts.map +0 -1
  188. package/dist/services/cache.js.map +0 -1
  189. package/dist/services/cache.test.d.ts +0 -8
  190. package/dist/services/cache.test.d.ts.map +0 -1
  191. package/dist/services/cache.test.js +0 -267
  192. package/dist/services/cache.test.js.map +0 -1
  193. package/dist/services/compliance-validator.d.ts.map +0 -1
  194. package/dist/services/compliance-validator.js.map +0 -1
  195. package/dist/services/config.d.ts.map +0 -1
  196. package/dist/services/config.js.map +0 -1
  197. package/dist/services/display-protocol.d.ts.map +0 -1
  198. package/dist/services/display-protocol.js.map +0 -1
  199. package/dist/services/effect-tracker.d.ts.map +0 -1
  200. package/dist/services/effect-tracker.js.map +0 -1
  201. package/dist/services/embedding.d.ts.map +0 -1
  202. package/dist/services/embedding.js.map +0 -1
  203. package/dist/services/file-lock.d.ts.map +0 -1
  204. package/dist/services/file-lock.js.map +0 -1
  205. package/dist/services/gitmem-dir.d.ts.map +0 -1
  206. package/dist/services/gitmem-dir.js.map +0 -1
  207. package/dist/services/local-file-storage.d.ts.map +0 -1
  208. package/dist/services/local-file-storage.js.map +0 -1
  209. package/dist/services/local-vector-search.d.ts.map +0 -1
  210. package/dist/services/local-vector-search.js.map +0 -1
  211. package/dist/services/metrics.d.ts.map +0 -1
  212. package/dist/services/metrics.js.map +0 -1
  213. package/dist/services/session-state.d.ts.map +0 -1
  214. package/dist/services/session-state.js.map +0 -1
  215. package/dist/services/startup.d.ts.map +0 -1
  216. package/dist/services/startup.js.map +0 -1
  217. package/dist/services/storage.d.ts.map +0 -1
  218. package/dist/services/storage.js.map +0 -1
  219. package/dist/services/supabase-client.d.ts.map +0 -1
  220. package/dist/services/supabase-client.js.map +0 -1
  221. package/dist/services/thread-dedup.d.ts.map +0 -1
  222. package/dist/services/thread-dedup.js.map +0 -1
  223. package/dist/services/thread-manager.d.ts.map +0 -1
  224. package/dist/services/thread-manager.js.map +0 -1
  225. package/dist/services/thread-suggestions.d.ts.map +0 -1
  226. package/dist/services/thread-suggestions.js.map +0 -1
  227. package/dist/services/thread-supabase.d.ts.map +0 -1
  228. package/dist/services/thread-supabase.js.map +0 -1
  229. package/dist/services/thread-vitality.d.ts.map +0 -1
  230. package/dist/services/thread-vitality.js.map +0 -1
  231. package/dist/services/tier.d.ts.map +0 -1
  232. package/dist/services/tier.js.map +0 -1
  233. package/dist/services/timezone.d.ts.map +0 -1
  234. package/dist/services/timezone.js.map +0 -1
  235. package/dist/services/transcript-chunker.d.ts.map +0 -1
  236. package/dist/services/transcript-chunker.js.map +0 -1
  237. package/dist/services/triple-writer.d.ts.map +0 -1
  238. package/dist/services/triple-writer.js.map +0 -1
  239. package/dist/services/variant-assignment.d.ts.map +0 -1
  240. package/dist/services/variant-assignment.js.map +0 -1
  241. package/dist/services/variant-generation.d.ts.map +0 -1
  242. package/dist/services/variant-generation.js.map +0 -1
  243. package/dist/tools/absorb-observations.d.ts.map +0 -1
  244. package/dist/tools/absorb-observations.js.map +0 -1
  245. package/dist/tools/analyze.d.ts.map +0 -1
  246. package/dist/tools/analyze.js.map +0 -1
  247. package/dist/tools/archive-learning.d.ts.map +0 -1
  248. package/dist/tools/archive-learning.js.map +0 -1
  249. package/dist/tools/cleanup-threads.d.ts.map +0 -1
  250. package/dist/tools/cleanup-threads.js.map +0 -1
  251. package/dist/tools/confirm-scars.d.ts.map +0 -1
  252. package/dist/tools/confirm-scars.js.map +0 -1
  253. package/dist/tools/create-decision.d.ts.map +0 -1
  254. package/dist/tools/create-decision.js.map +0 -1
  255. package/dist/tools/create-learning.d.ts.map +0 -1
  256. package/dist/tools/create-learning.js.map +0 -1
  257. package/dist/tools/create-thread.d.ts.map +0 -1
  258. package/dist/tools/create-thread.js.map +0 -1
  259. package/dist/tools/definitions.d.ts.map +0 -1
  260. package/dist/tools/definitions.js.map +0 -1
  261. package/dist/tools/dismiss-suggestion.d.ts.map +0 -1
  262. package/dist/tools/dismiss-suggestion.js.map +0 -1
  263. package/dist/tools/get-transcript.d.ts.map +0 -1
  264. package/dist/tools/get-transcript.js.map +0 -1
  265. package/dist/tools/graph-traverse.d.ts.map +0 -1
  266. package/dist/tools/graph-traverse.js.map +0 -1
  267. package/dist/tools/list-threads.d.ts.map +0 -1
  268. package/dist/tools/list-threads.js.map +0 -1
  269. package/dist/tools/log.d.ts.map +0 -1
  270. package/dist/tools/log.js.map +0 -1
  271. package/dist/tools/prepare-context.d.ts.map +0 -1
  272. package/dist/tools/prepare-context.js.map +0 -1
  273. package/dist/tools/promote-suggestion.d.ts.map +0 -1
  274. package/dist/tools/promote-suggestion.js.map +0 -1
  275. package/dist/tools/recall.d.ts.map +0 -1
  276. package/dist/tools/recall.js.map +0 -1
  277. package/dist/tools/recall.test.d.ts +0 -5
  278. package/dist/tools/recall.test.d.ts.map +0 -1
  279. package/dist/tools/recall.test.js +0 -155
  280. package/dist/tools/recall.test.js.map +0 -1
  281. package/dist/tools/record-scar-usage-batch.d.ts.map +0 -1
  282. package/dist/tools/record-scar-usage-batch.js.map +0 -1
  283. package/dist/tools/record-scar-usage.d.ts.map +0 -1
  284. package/dist/tools/record-scar-usage.js.map +0 -1
  285. package/dist/tools/resolve-thread.d.ts.map +0 -1
  286. package/dist/tools/resolve-thread.js.map +0 -1
  287. package/dist/tools/save-transcript.d.ts.map +0 -1
  288. package/dist/tools/save-transcript.js.map +0 -1
  289. package/dist/tools/search-transcripts.d.ts.map +0 -1
  290. package/dist/tools/search-transcripts.js.map +0 -1
  291. package/dist/tools/search.d.ts.map +0 -1
  292. package/dist/tools/search.js.map +0 -1
  293. package/dist/tools/session-close.d.ts.map +0 -1
  294. package/dist/tools/session-close.js.map +0 -1
  295. package/dist/tools/session-start.d.ts.map +0 -1
  296. package/dist/tools/session-start.js.map +0 -1
  297. package/dist/types/index.d.ts.map +0 -1
  298. package/dist/types/index.js.map +0 -1
  299. package/hooks/tests/test-hooks.sh +0 -577
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Retrieve a session transcript from Supabase storage.
5
5
  *
6
- * Issue: OD-467
6
+ *
7
7
  */
8
8
  import type { PerformanceData } from "../types/index.js";
9
9
  export interface GetTranscriptParams {
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Retrieve a session transcript from Supabase storage.
5
5
  *
6
- * Issue: OD-467
6
+ *
7
7
  */
8
8
  import * as supabase from "../services/supabase-client.js";
9
9
  import { Timer, buildPerformanceData } from "../services/metrics.js";
@@ -14,7 +14,7 @@ import type { Project, PerformanceData } from "../types/index.js";
14
14
  export type GraphTraverseLens = "connected_to" | "produced_by" | "provenance" | "stats";
15
15
  export interface GraphTraverseParams {
16
16
  lens: GraphTraverseLens;
17
- /** Starting node. Examples: "OD-466", "CLI", "Elena", "Scar: Done ≠ Deployed" */
17
+ /** Starting node. Examples: "PROJ-123", "cli", "Scar: Done ≠ Deployed" */
18
18
  node?: string;
19
19
  /** Filter by predicate */
20
20
  predicate?: string;
@@ -17,28 +17,31 @@ import { Timer, buildPerformanceData, } from "../services/metrics.js";
17
17
  import { wrapDisplay } from "../services/display-protocol.js";
18
18
  // --- Constants ---
19
19
  const SELECT_COLS = "id,subject,predicate,object,event_time,decay_weight,source_type,source_id,source_linear_issue,created_by";
20
- const KNOWN_AGENTS = ["CLI", "DAC", "CODA-1", "Brain_Local", "Brain_Cloud"];
21
- const KNOWN_PERSONAS = ["Elena", "Marcus", "Reiko", "Jax", "Chris Crawford"];
20
+ const KNOWN_AGENTS = ["cli", "desktop", "autonomous", "local", "cloud", "CLI", "DAC", "CODA-1", "Brain_Local", "Brain_Cloud"];
21
+ /** Persona names are resolved dynamically via triple-writer's normalizePersonaLabel */
22
+ const KNOWN_PERSONAS = [];
22
23
  function normalizeNode(input) {
23
24
  const trimmed = input.trim();
24
- // Already prefixed: "Scar: Title", "Issue: OD-466", etc.
25
- if (/^(Scar|Win|Decision|Pattern|Anti-Pattern|Issue|Agent|Persona|Thread):/.test(trimmed)) {
26
- return { pattern: `*${trimmed}*`, type: trimmed.split(":")[0] };
25
+ // Sanitize: strip PostgREST structural chars that could escape ilike/or expressions
26
+ const safe = trimmed.replace(/[(),\0]/g, "");
27
+ // Already prefixed: "Scar: Title", "Issue: PROJ-123", etc.
28
+ if (/^(Scar|Win|Decision|Pattern|Anti-Pattern|Issue|Agent|Persona|Thread):/.test(safe)) {
29
+ return { pattern: `*${safe}*`, type: safe.split(":")[0] };
27
30
  }
28
- // OD-XXX issue pattern
29
- if (/^OD-\d+$/i.test(trimmed)) {
30
- return { pattern: `*${trimmed.toUpperCase()}*`, type: "Issue" };
31
+ // Issue identifier pattern (e.g., PROJ-123, ENG-456)
32
+ if (/^[A-Z]+-\d+$/i.test(safe)) {
33
+ return { pattern: `*${safe.toUpperCase()}*`, type: "Issue" };
31
34
  }
32
35
  // Known agent names
33
- if (KNOWN_AGENTS.includes(trimmed)) {
34
- return { pattern: `*Agent: ${trimmed}*`, type: "Agent" };
36
+ if (KNOWN_AGENTS.includes(safe)) {
37
+ return { pattern: `*Agent: ${safe}*`, type: "Agent" };
35
38
  }
36
39
  // Known persona names
37
- if (KNOWN_PERSONAS.includes(trimmed)) {
38
- return { pattern: `*Persona: ${trimmed}*`, type: "Persona" };
40
+ if (KNOWN_PERSONAS.includes(safe)) {
41
+ return { pattern: `*Persona: ${safe}*`, type: "Persona" };
39
42
  }
40
43
  // Fallback: fuzzy search
41
- return { pattern: `*${trimmed}*`, type: "Unknown" };
44
+ return { pattern: `*${safe}*`, type: "Unknown" };
42
45
  }
43
46
  /** Detect the type label from a subject/object string */
44
47
  function detectNodeType(label) {
@@ -282,13 +285,13 @@ async function stats(params, timer) {
282
285
  for (const t of allTriples) {
283
286
  objectCounts[t.object] = (objectCounts[t.object] || 0) + 1;
284
287
  }
285
- // Issues by learning count (objects matching "Issue: OD-*")
288
+ // Issues by learning count (objects matching "Issue: *")
286
289
  const issueCounts = {};
287
290
  for (const t of allTriples) {
288
- if (t.object.startsWith("Issue: OD-")) {
291
+ if (t.object.startsWith("Issue: ")) {
289
292
  issueCounts[t.object] = (issueCounts[t.object] || 0) + 1;
290
293
  }
291
- if (t.subject.startsWith("Issue: OD-")) {
294
+ if (t.subject.startsWith("Issue: ")) {
292
295
  issueCounts[t.subject] = (issueCounts[t.subject] || 0) + 1;
293
296
  }
294
297
  }
@@ -358,7 +361,7 @@ export async function graphTraverse(params) {
358
361
  }
359
362
  // Validate: node required for all lenses except stats
360
363
  if (lens !== "stats" && !params.node) {
361
- const missingNodeMsg = `The '${lens}' lens requires a 'node' parameter (e.g., "OD-466", "CLI", "Elena")`;
364
+ const missingNodeMsg = `The '${lens}' lens requires a 'node' parameter (e.g., "PROJ-123", "cli", "Scar: Done ≠ Deployed")`;
362
365
  return {
363
366
  success: false,
364
367
  lens,
@@ -1,10 +1,10 @@
1
1
  /**
2
- * list_threads Tool (OD-thread-lifecycle, OD-622)
2
+ * list_threads Tool
3
3
  *
4
4
  * List open threads across recent sessions. Shows unresolved work items
5
5
  * that carry over between sessions, with IDs for resolution.
6
6
  *
7
- * OD-622: Primary read from Supabase (source of truth).
7
+ * Primary read from Supabase (source of truth).
8
8
  * Falls back to session-based aggregation (same as session_start),
9
9
  * then in-memory session state, then .gitmem/threads.json.
10
10
  *
@@ -1,10 +1,10 @@
1
1
  /**
2
- * list_threads Tool (OD-thread-lifecycle, OD-622)
2
+ * list_threads Tool
3
3
  *
4
4
  * List open threads across recent sessions. Shows unresolved work items
5
5
  * that carry over between sessions, with IDs for resolution.
6
6
  *
7
- * OD-622: Primary read from Supabase (source of truth).
7
+ * Primary read from Supabase (source of truth).
8
8
  * Falls back to session-based aggregation (same as session_start),
9
9
  * then in-memory session state, then .gitmem/threads.json.
10
10
  *
@@ -14,7 +14,7 @@ import { v4 as uuidv4 } from "uuid";
14
14
  import { hasSupabase } from "../services/tier.js";
15
15
  import { getProject } from "../services/session-state.js";
16
16
  import { aggregateThreads, loadThreadsFile, mergeThreadStates } from "../services/thread-manager.js";
17
- import { deduplicateThreadList } from "../services/thread-dedup.js"; // OD-641
17
+ import { deduplicateThreadList } from "../services/thread-dedup.js";
18
18
  import { listThreadsFromSupabase } from "../services/thread-supabase.js";
19
19
  import * as supabase from "../services/supabase-client.js";
20
20
  import { Timer, recordMetrics, buildPerformanceData, } from "../services/metrics.js";
@@ -67,7 +67,7 @@ export async function listThreads(params) {
67
67
  const project = params.project || getProject() || "default";
68
68
  let allThreads = null;
69
69
  let source = "file";
70
- // OD-622: Try Supabase first (source of truth)
70
+ // Try Supabase first (source of truth)
71
71
  const supabaseThreads = await listThreadsFromSupabase(project, {
72
72
  statusFilter: includeResolved ? undefined : statusFilter,
73
73
  includeResolved,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * log Tool (OD-561)
2
+ * log Tool
3
3
  *
4
4
  * Chronological listing of recent learnings, like `git log`.
5
5
  * Pure read-only operation with no side effects.
package/dist/tools/log.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * log Tool (OD-561)
2
+ * log Tool
3
3
  *
4
4
  * Chronological listing of recent learnings, like `git log`.
5
5
  * Pure read-only operation with no side effects.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * prepare_context Tool (GitMem v2 Phase 1 — OD-593)
2
+ * prepare_context Tool
3
3
  *
4
4
  * Bridge between global memory and agents that can't call recall directly.
5
5
  * The lead agent calls this to generate a portable memory payload that
@@ -1,5 +1,5 @@
1
1
  /**
2
- * prepare_context Tool (GitMem v2 Phase 1 — OD-593)
2
+ * prepare_context Tool
3
3
  *
4
4
  * Bridge between global memory and agents that can't call recall directly.
5
5
  * The lead agent calls this to generate a portable memory payload that
@@ -36,7 +36,7 @@ function formatFull(scars, plan) {
36
36
  Proceed with caution — this may be new territory without documented lessons.`;
37
37
  }
38
38
  const lines = [
39
- "⚠️ INSTITUTIONAL MEMORY ACTIVATED",
39
+ "🧠 INSTITUTIONAL MEMORY ACTIVATED",
40
40
  "",
41
41
  `Found ${scars.length} relevant scar${scars.length === 1 ? "" : "s"} for your plan:`,
42
42
  "",
@@ -4,12 +4,12 @@
4
4
  * Check institutional memory for relevant scars before taking action.
5
5
  * Core GitMem MVP tool that enables "check before act" workflow.
6
6
  *
7
- * Performance target: <2000ms response time (OD-429)
7
+ * Performance target: <2000ms response time
8
8
  *
9
- * OD-489: Uses local vector search when available for speed,
9
+ * Uses local vector search when available for speed,
10
10
  * falls back to Supabase scar_search when local cache isn't ready.
11
11
  *
12
- * OD-466: After scar search, fetches related knowledge triples and
12
+ * After scar search, fetches related knowledge triples and
13
13
  * includes them in the formatted response for relationship context.
14
14
  */
15
15
  import type { KnowledgeTriple } from "../services/supabase-client.js";
@@ -23,9 +23,10 @@ export interface RecallParams {
23
23
  project?: Project;
24
24
  match_count?: number;
25
25
  issue_id?: string;
26
+ similarity_threshold?: number;
26
27
  }
27
28
  /**
28
- * Required verification block for enforcement gate (OD-487)
29
+ * Required verification block for enforcement gate
29
30
  */
30
31
  interface RequiredVerification {
31
32
  when: string;
@@ -4,12 +4,12 @@
4
4
  * Check institutional memory for relevant scars before taking action.
5
5
  * Core GitMem MVP tool that enables "check before act" workflow.
6
6
  *
7
- * Performance target: <2000ms response time (OD-429)
7
+ * Performance target: <2000ms response time
8
8
  *
9
- * OD-489: Uses local vector search when available for speed,
9
+ * Uses local vector search when available for speed,
10
10
  * falls back to Supabase scar_search when local cache isn't ready.
11
11
  *
12
- * OD-466: After scar search, fetches related knowledge triples and
12
+ * After scar search, fetches related knowledge triples and
13
13
  * includes them in the formatted response for relationship context.
14
14
  */
15
15
  import * as supabase from "../services/supabase-client.js";
@@ -19,8 +19,8 @@ import { getProject } from "../services/session-state.js";
19
19
  import { getStorage } from "../services/storage.js";
20
20
  import { Timer, recordMetrics, buildPerformanceData, buildComponentPerformance, calculateContextBytes, } from "../services/metrics.js";
21
21
  import { getOrAssignVariant, formatVariantEnforcement, } from "../services/variant-assignment.js";
22
- import { addSurfacedScars, getCurrentSession } from "../services/session-state.js"; // OD-552
23
- import { getAgentIdentity } from "../services/agent-detection.js"; // OD-547
22
+ import { addSurfacedScars, getCurrentSession } from "../services/session-state.js";
23
+ import { getAgentIdentity } from "../services/agent-detection.js";
24
24
  import { v4 as uuidv4 } from "uuid";
25
25
  import * as fs from "fs";
26
26
  import { getSessionPath } from "../services/gitmem-dir.js";
@@ -33,17 +33,17 @@ function formatResponse(scars, plan, dismissals) {
33
33
  if (scars.length === 0) {
34
34
  return `No relevant scars found for: "${plan.slice(0, 100)}..."
35
35
 
36
- Proceed with caution - this may be new territory without documented lessons.`;
36
+ No past lessons match this plan closely enough. Scars accumulate as you work — create learnings during session close to build institutional memory.`;
37
37
  }
38
- // OD-487: Check if any scars have required_verification (blocking gates)
38
+ // Check if any scars have required_verification (blocking gates)
39
39
  const scarsWithVerification = scars.filter((s) => s.required_verification?.blocking);
40
40
  const lines = [
41
- "⚠️ INSTITUTIONAL MEMORY ACTIVATED",
41
+ "🧠 INSTITUTIONAL MEMORY ACTIVATED",
42
42
  "",
43
43
  `Found ${scars.length} relevant scar${scars.length === 1 ? "" : "s"} for your plan:`,
44
44
  "",
45
45
  ];
46
- // OD-487: Display blocking verification requirements FIRST and prominently
46
+ // Display blocking verification requirements FIRST and prominently
47
47
  if (scarsWithVerification.length > 0) {
48
48
  lines.push("═══════════════════════════════════════════════════════════════");
49
49
  lines.push("🚨 **VERIFICATION REQUIRED BEFORE PROCEEDING**");
@@ -84,7 +84,7 @@ Proceed with caution - this may be new territory without documented lessons.`;
84
84
  lines.push(` _[${counts.dismissed}x dismissed — consider archiving with gm-archive]_`);
85
85
  }
86
86
  }
87
- // OD-525: Use variant enforcement text if available (blind to variant name)
87
+ // Use variant enforcement text if available (blind to variant name)
88
88
  if (scar.variant_info?.has_variants && scar.variant_info.variant) {
89
89
  const variantText = formatVariantEnforcement(scar.variant_info.variant, scar.title);
90
90
  lines.push(variantText);
@@ -104,7 +104,7 @@ Proceed with caution - this may be new territory without documented lessons.`;
104
104
  lines.push("");
105
105
  lines.push("*Applies when:* " + scar.applies_when.slice(0, 3).join(", "));
106
106
  }
107
- // OD-530: Render LLM-cooperative enforcement fields (OD-508)
107
+ // Render LLM-cooperative enforcement fields
108
108
  if (scar.why_this_matters) {
109
109
  lines.push("");
110
110
  lines.push(`**Why this matters:** ${scar.why_this_matters}`);
@@ -123,7 +123,7 @@ Proceed with caution - this may be new territory without documented lessons.`;
123
123
  lines.push(` - [ ] ${criterion}`);
124
124
  }
125
125
  }
126
- // OD-466: Render related knowledge triples
126
+ // Render related knowledge triples
127
127
  if (scar.related_triples && scar.related_triples.length > 0) {
128
128
  lines.push("");
129
129
  lines.push("*Related knowledge:*");
@@ -170,14 +170,18 @@ export async function recall(params) {
170
170
  }
171
171
  const project = params.project || getProject() || "default";
172
172
  const matchCount = params.match_count || 3;
173
- const issueId = params.issue_id; // OD-525: For variant assignment
173
+ const issueId = params.issue_id; // For variant assignment
174
+ // Similarity threshold — suppress weak matches
175
+ const defaultThreshold = hasSupabase() ? 0.35 : 0.4;
176
+ const similarityThreshold = params.similarity_threshold ?? defaultThreshold;
174
177
  // Free tier: use local keyword search
175
178
  if (!hasSupabase()) {
176
179
  try {
177
180
  const searchTimer = new Timer();
178
181
  const rawScars = await getStorage().search(plan, matchCount);
179
182
  const searchLatencyMs = searchTimer.stop();
180
- const scars = rawScars.map((scar) => ({
183
+ const scars = rawScars
184
+ .map((scar) => ({
181
185
  id: scar.id,
182
186
  title: scar.title,
183
187
  learning_type: scar.learning_type || "scar",
@@ -186,7 +190,9 @@ export async function recall(params) {
186
190
  counter_arguments: scar.counter_arguments || [],
187
191
  applies_when: [],
188
192
  similarity: scar.similarity || 0,
189
- }));
193
+ }))
194
+ // Filter below threshold
195
+ .filter((scar) => scar.similarity >= similarityThreshold);
190
196
  const latencyMs = timer.stop();
191
197
  const perfData = buildPerformanceData("recall", latencyMs, scars.length, {
192
198
  memoriesSurfaced: scars.map((s) => s.id),
@@ -247,7 +253,7 @@ export async function recall(params) {
247
253
  let cache_age_ms;
248
254
  let search_mode = "remote";
249
255
  let network_call = true; // Assume network call until proven otherwise
250
- // OD-489: Try local vector search first (fast, no Supabase hit)
256
+ // Try local vector search first (fast, no Supabase hit)
251
257
  // Falls back to Supabase scar_search if local cache isn't ready
252
258
  const searchTimer = new Timer();
253
259
  if (isLocalSearchReady(project)) {
@@ -269,7 +275,7 @@ export async function recall(params) {
269
275
  cache_age_ms = supabaseResult.cache_age_ms;
270
276
  }
271
277
  const searchLatencyMs = searchTimer.stop();
272
- // OD-547: Assign variants for A/B testing (dev tier only)
278
+ // Assign variants for A/B testing (dev tier only)
273
279
  // Agent identity is always available, so variants are always assigned
274
280
  const variantTimer = new Timer();
275
281
  const variantResults = new Map();
@@ -290,7 +296,7 @@ export async function recall(params) {
290
296
  for (const { scarId, variantInfo } of results) {
291
297
  variantResults.set(scarId, variantInfo);
292
298
  }
293
- // OD-525: Record enforcement metrics for variants (dev only)
299
+ // Record enforcement metrics for variants (dev only)
294
300
  if (hasMetrics()) {
295
301
  const metricsPromises = results
296
302
  .filter(({ variantInfo }) => variantInfo.has_variants && variantInfo.variant)
@@ -316,7 +322,7 @@ export async function recall(params) {
316
322
  }
317
323
  }
318
324
  const variantLatencyMs = variantTimer.stop();
319
- // OD-466: Fetch related knowledge triples for surfaced scars
325
+ // Fetch related knowledge triples for surfaced scars
320
326
  const tripleTimer = new Timer();
321
327
  const scarIds = rawScars.map((s) => s.id);
322
328
  const triplesMap = await supabase.fetchRelatedTriples(scarIds);
@@ -333,7 +339,8 @@ export async function recall(params) {
333
339
  console.warn("[recall] Dismissal count fetch failed (non-fatal):", err);
334
340
  }
335
341
  // Format scars for response
336
- const scars = rawScars.map((scar) => ({
342
+ const scars = rawScars
343
+ .map((scar) => ({
337
344
  id: scar.id,
338
345
  title: scar.title,
339
346
  learning_type: scar.learning_type || "scar",
@@ -344,17 +351,19 @@ export async function recall(params) {
344
351
  source_issue: scar.source_linear_issue,
345
352
  similarity: scar.similarity || 0,
346
353
  required_verification: scar.required_verification,
347
- variant_info: variantResults.get(scar.id), // OD-525
348
- // OD-508: LLM-cooperative enforcement fields
354
+ variant_info: variantResults.get(scar.id),
355
+ // LLM-cooperative enforcement fields
349
356
  why_this_matters: scar.why_this_matters,
350
357
  action_protocol: scar.action_protocol,
351
358
  self_check_criteria: scar.self_check_criteria,
352
- // OD-466: Knowledge triples
359
+ // Knowledge triples
353
360
  related_triples: triplesMap.get(scar.id),
354
361
  // Behavioral decay
355
362
  decay_multiplier: scar.decay_multiplier,
356
- }));
357
- // OD-552: Track surfaced scars for auto-bridge at session close
363
+ }))
364
+ // Filter below threshold
365
+ .filter((scar) => scar.similarity >= similarityThreshold);
366
+ // Track surfaced scars for auto-bridge at session close
358
367
  const recallSurfacedAt = new Date().toISOString();
359
368
  const recallSurfacedScars = scars.map((scar) => ({
360
369
  scar_id: scar.id,
@@ -365,7 +374,7 @@ export async function recall(params) {
365
374
  variant_id: variantResults.get(scar.id)?.assignment?.variant_id,
366
375
  }));
367
376
  addSurfacedScars(recallSurfacedScars);
368
- // OD-552: Update per-session dir with accumulated surfaced scars
377
+ // Update per-session dir with accumulated surfaced scars
369
378
  try {
370
379
  const session = getCurrentSession();
371
380
  if (session) {
@@ -384,7 +393,7 @@ export async function recall(params) {
384
393
  const latencyMs = timer.stop();
385
394
  const memoriesSurfaced = scars.map((s) => s.id);
386
395
  const similarityScores = scars.map((s) => s.similarity);
387
- // OD-489: Build detailed performance breakdown for test harness
396
+ // Build detailed performance breakdown for test harness
388
397
  const breakdown = {
389
398
  scar_search: buildComponentPerformance(searchLatencyMs, search_mode === "local" ? "local_cache" : "supabase", network_call, network_call ? "miss" : "hit"),
390
399
  };
@@ -427,7 +436,7 @@ export async function recall(params) {
427
436
  cache_hit,
428
437
  cache_age_ms,
429
438
  search_mode,
430
- // OD-489: Detailed instrumentation
439
+ // Detailed instrumentation
431
440
  network_calls_made: perfData.network_calls_made,
432
441
  fully_local: perfData.fully_local,
433
442
  },
@@ -94,8 +94,8 @@ export async function recordScarUsageBatch(params) {
94
94
  scar_id: scarId,
95
95
  issue_id: entry.issue_id || null,
96
96
  issue_identifier: entry.issue_identifier || null,
97
- session_id: entry.session_id || null, // OD-552: Session tracking
98
- agent: entry.agent || null, // OD-552: Agent identity
97
+ session_id: entry.session_id || null, // Session tracking
98
+ agent: entry.agent || null, // Agent identity
99
99
  surfaced_at: entry.surfaced_at,
100
100
  acknowledged_at: entry.acknowledged_at || null,
101
101
  referenced: entry.reference_type !== "none",
@@ -4,7 +4,7 @@
4
4
  * Track scar application for effectiveness measurement.
5
5
  * Records to scar_usage table.
6
6
  *
7
- * Performance target: <1000ms (OD-429)
7
+ * Performance target: <1000ms
8
8
  */
9
9
  import type { RecordScarUsageParams, RecordScarUsageResult } from "../types/index.js";
10
10
  /**
@@ -4,7 +4,7 @@
4
4
  * Track scar application for effectiveness measurement.
5
5
  * Records to scar_usage table.
6
6
  *
7
- * Performance target: <1000ms (OD-429)
7
+ * Performance target: <1000ms
8
8
  */
9
9
  import { v4 as uuidv4 } from "uuid";
10
10
  import { wrapDisplay } from "../services/display-protocol.js";
@@ -24,8 +24,8 @@ export async function recordScarUsage(params) {
24
24
  scar_id: params.scar_id,
25
25
  issue_id: params.issue_id || null,
26
26
  issue_identifier: params.issue_identifier || null,
27
- session_id: params.session_id || null, // OD-552: Session tracking
28
- agent: params.agent || null, // OD-552: Agent identity
27
+ session_id: params.session_id || null, // Session tracking
28
+ agent: params.agent || null, // Agent identity
29
29
  surfaced_at: params.surfaced_at,
30
30
  acknowledged_at: params.acknowledged_at || null,
31
31
  referenced: params.reference_type !== "none",
@@ -1,11 +1,11 @@
1
1
  /**
2
- * resolve_thread Tool (OD-thread-lifecycle, OD-621)
2
+ * resolve_thread Tool
3
3
  *
4
4
  * Mark an open thread as resolved. Supports resolution by:
5
5
  * - thread_id: exact match (preferred)
6
6
  * - text_match: case-insensitive substring match (fallback)
7
7
  *
8
- * OD-621: Updates Supabase (source of truth) + local file (cache).
8
+ * Updates Supabase (source of truth) + local file (cache).
9
9
  * Falls back to local-only if Supabase is unavailable or thread
10
10
  * doesn't exist in Supabase.
11
11
  *
@@ -1,11 +1,11 @@
1
1
  /**
2
- * resolve_thread Tool (OD-thread-lifecycle, OD-621)
2
+ * resolve_thread Tool
3
3
  *
4
4
  * Mark an open thread as resolved. Supports resolution by:
5
5
  * - thread_id: exact match (preferred)
6
6
  * - text_match: case-insensitive substring match (fallback)
7
7
  *
8
- * OD-621: Updates Supabase (source of truth) + local file (cache).
8
+ * Updates Supabase (source of truth) + local file (cache).
9
9
  * Falls back to local-only if Supabase is unavailable or thread
10
10
  * doesn't exist in Supabase.
11
11
  *
@@ -82,7 +82,7 @@ export async function resolveThread(params) {
82
82
  }
83
83
  // Persist to local file (cache)
84
84
  saveThreadsFile(threads);
85
- // OD-621: Update Supabase (source of truth) — graceful fallback on failure
85
+ // Update Supabase (source of truth) — graceful fallback on failure
86
86
  let supabaseSynced = false;
87
87
  const supabaseSuccess = await resolveThreadInSupabase(resolved.id, {
88
88
  resolvedAt: resolved.resolved_at,
@@ -4,7 +4,7 @@
4
4
  * Save full session transcript to Supabase storage for training data,
5
5
  * post-mortems, and pattern mining.
6
6
  *
7
- * Issue: OD-467
7
+ *
8
8
  */
9
9
  import type { Project, PerformanceData } from "../types/index.js";
10
10
  export interface SaveTranscriptParams {
@@ -4,7 +4,7 @@
4
4
  * Save full session transcript to Supabase storage for training data,
5
5
  * post-mortems, and pattern mining.
6
6
  *
7
- * Issue: OD-467
7
+ *
8
8
  */
9
9
  import { detectAgent } from "../services/agent-detection.js";
10
10
  import * as supabase from "../services/supabase-client.js";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * search Tool (OD-560)
2
+ * search Tool
3
3
  *
4
4
  * Semantic search of institutional memory without action context.
5
5
  * Unlike recall (which is "I'm about to do X, warn me"), search is
@@ -1,5 +1,5 @@
1
1
  /**
2
- * search Tool (OD-560)
2
+ * search Tool
3
3
  *
4
4
  * Semantic search of institutional memory without action context.
5
5
  * Unlike recall (which is "I'm about to do X, warn me"), search is
@@ -4,7 +4,7 @@
4
4
  * Persist session with compliance validation.
5
5
  * Validates that required fields are present based on close type.
6
6
  *
7
- * Performance target: <3000ms (OD-429)
7
+ * Performance target: <3000ms
8
8
  */
9
9
  import type { SessionCloseParams, SessionCloseResult } from "../types/index.js";
10
10
  /**