grov 0.5.11 → 0.6.13

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 (190) hide show
  1. package/dist/cli/agents/registry.d.ts +17 -0
  2. package/dist/cli/agents/registry.js +132 -0
  3. package/dist/cli/commands/agents.d.ts +1 -0
  4. package/dist/cli/commands/agents.js +48 -0
  5. package/dist/cli/commands/disable.d.ts +1 -0
  6. package/dist/cli/commands/disable.js +179 -0
  7. package/dist/cli/commands/doctor.d.ts +1 -0
  8. package/dist/cli/commands/doctor.js +157 -0
  9. package/dist/{commands → cli/commands}/drift-test.js +39 -26
  10. package/dist/cli/commands/init.d.ts +1 -0
  11. package/dist/cli/commands/init.js +90 -0
  12. package/dist/{commands → cli/commands}/login.js +19 -18
  13. package/dist/{commands → cli/commands}/logout.js +1 -1
  14. package/dist/{commands → cli/commands}/proxy-status.js +1 -1
  15. package/dist/cli/commands/setup.d.ts +6 -0
  16. package/dist/cli/commands/setup.js +309 -0
  17. package/dist/{commands → cli/commands}/status.js +1 -1
  18. package/dist/{commands → cli/commands}/sync.d.ts +1 -0
  19. package/dist/{commands → cli/commands}/sync.js +59 -4
  20. package/dist/{commands → cli/commands}/uninstall.js +2 -2
  21. package/dist/cli/index.js +270 -0
  22. package/dist/{lib → core/cloud}/cloud-sync.d.ts +3 -3
  23. package/dist/{lib → core/cloud}/cloud-sync.js +10 -10
  24. package/dist/{lib → core/extraction}/correction-builder-proxy.d.ts +1 -1
  25. package/dist/{lib → core/extraction}/correction-builder-proxy.js +0 -4
  26. package/dist/{lib → core/extraction}/drift-checker-proxy.d.ts +13 -9
  27. package/dist/core/extraction/drift-checker-proxy.js +510 -0
  28. package/dist/{lib → core/extraction}/llm-extractor.d.ts +8 -38
  29. package/dist/{lib → core/extraction}/llm-extractor.js +132 -220
  30. package/dist/{lib → core}/store/sessions.js +3 -19
  31. package/dist/core/store/store.d.ts +1 -0
  32. package/dist/{lib → core/store}/store.js +1 -1
  33. package/dist/{lib → core}/store/types.d.ts +0 -4
  34. package/dist/integrations/mcp/cache.d.ts +27 -0
  35. package/dist/integrations/mcp/cache.js +106 -0
  36. package/dist/integrations/mcp/capture/antigravity-parser.d.ts +26 -0
  37. package/dist/integrations/mcp/capture/antigravity-parser.js +272 -0
  38. package/dist/integrations/mcp/capture/antigravity-scanner.d.ts +24 -0
  39. package/dist/integrations/mcp/capture/antigravity-scanner.js +153 -0
  40. package/dist/integrations/mcp/capture/antigravity-sync-tracker.d.ts +29 -0
  41. package/dist/integrations/mcp/capture/antigravity-sync-tracker.js +115 -0
  42. package/dist/integrations/mcp/capture/cli-extractor.d.ts +18 -0
  43. package/dist/integrations/mcp/capture/cli-extractor.js +258 -0
  44. package/dist/integrations/mcp/capture/cli-synced.d.ts +4 -0
  45. package/dist/integrations/mcp/capture/cli-synced.js +62 -0
  46. package/dist/integrations/mcp/capture/cli-transform.d.ts +30 -0
  47. package/dist/integrations/mcp/capture/cli-transform.js +62 -0
  48. package/dist/integrations/mcp/capture/cli-watcher.d.ts +31 -0
  49. package/dist/integrations/mcp/capture/cli-watcher.js +106 -0
  50. package/dist/integrations/mcp/capture/hook-handler.d.ts +2 -0
  51. package/dist/integrations/mcp/capture/hook-handler.js +157 -0
  52. package/dist/integrations/mcp/capture/sqlite-reader.d.ts +35 -0
  53. package/dist/integrations/mcp/capture/sqlite-reader.js +388 -0
  54. package/dist/integrations/mcp/capture/sync-tracker.d.ts +16 -0
  55. package/dist/integrations/mcp/capture/sync-tracker.js +102 -0
  56. package/dist/integrations/mcp/clients/cursor/rules-installer.d.ts +19 -0
  57. package/dist/integrations/mcp/clients/cursor/rules-installer.js +123 -0
  58. package/dist/integrations/mcp/index.d.ts +1 -0
  59. package/dist/integrations/mcp/index.js +94 -0
  60. package/dist/integrations/mcp/logger.d.ts +8 -0
  61. package/dist/integrations/mcp/logger.js +50 -0
  62. package/dist/integrations/mcp/server.d.ts +5 -0
  63. package/dist/integrations/mcp/server.js +58 -0
  64. package/dist/integrations/mcp/tools/expand.d.ts +1 -0
  65. package/dist/integrations/mcp/tools/expand.js +53 -0
  66. package/dist/integrations/mcp/tools/preview.d.ts +1 -0
  67. package/dist/integrations/mcp/tools/preview.js +64 -0
  68. package/dist/integrations/proxy/agents/base.d.ts +43 -0
  69. package/dist/integrations/proxy/agents/base.js +13 -0
  70. package/dist/{proxy/utils → integrations/proxy/agents/claude}/extractors.d.ts +4 -8
  71. package/dist/{proxy/utils → integrations/proxy/agents/claude}/extractors.js +4 -33
  72. package/dist/{proxy → integrations/proxy/agents/claude}/forwarder.d.ts +1 -1
  73. package/dist/{proxy → integrations/proxy/agents/claude}/forwarder.js +22 -6
  74. package/dist/integrations/proxy/agents/claude/index.d.ts +43 -0
  75. package/dist/integrations/proxy/agents/claude/index.js +386 -0
  76. package/dist/{proxy/action-parser.d.ts → integrations/proxy/agents/claude/parser.d.ts} +1 -1
  77. package/dist/integrations/proxy/agents/codex/extractors.d.ts +6 -0
  78. package/dist/integrations/proxy/agents/codex/extractors.js +49 -0
  79. package/dist/integrations/proxy/agents/codex/forwarder.d.ts +9 -0
  80. package/dist/integrations/proxy/agents/codex/forwarder.js +125 -0
  81. package/dist/integrations/proxy/agents/codex/index.d.ts +44 -0
  82. package/dist/integrations/proxy/agents/codex/index.js +371 -0
  83. package/dist/integrations/proxy/agents/codex/parser.d.ts +11 -0
  84. package/dist/integrations/proxy/agents/codex/parser.js +104 -0
  85. package/dist/integrations/proxy/agents/codex/patch.d.ts +12 -0
  86. package/dist/integrations/proxy/agents/codex/patch.js +40 -0
  87. package/dist/integrations/proxy/agents/codex/settings.d.ts +18 -0
  88. package/dist/integrations/proxy/agents/codex/settings.js +73 -0
  89. package/dist/integrations/proxy/agents/codex/types.d.ts +59 -0
  90. package/dist/integrations/proxy/agents/codex/types.js +2 -0
  91. package/dist/integrations/proxy/agents/index.d.ts +11 -0
  92. package/dist/integrations/proxy/agents/index.js +25 -0
  93. package/dist/integrations/proxy/agents/types.d.ts +77 -0
  94. package/dist/integrations/proxy/agents/types.js +2 -0
  95. package/dist/{proxy → integrations/proxy/cache}/extended-cache.js +2 -6
  96. package/dist/{proxy → integrations/proxy}/config.js +1 -1
  97. package/dist/{proxy → integrations/proxy}/handlers/preprocess.d.ts +3 -3
  98. package/dist/integrations/proxy/handlers/preprocess.js +194 -0
  99. package/dist/integrations/proxy/index.js +20 -0
  100. package/dist/integrations/proxy/injection/memory-injection.d.ts +56 -0
  101. package/dist/integrations/proxy/injection/memory-injection.js +252 -0
  102. package/dist/integrations/proxy/orchestrator.d.ts +30 -0
  103. package/dist/integrations/proxy/orchestrator.js +954 -0
  104. package/dist/integrations/proxy/request-processor.d.ts +14 -0
  105. package/dist/integrations/proxy/request-processor.js +68 -0
  106. package/dist/{proxy → integrations/proxy}/response-processor.d.ts +4 -3
  107. package/dist/{proxy → integrations/proxy}/response-processor.js +51 -43
  108. package/dist/{proxy → integrations/proxy}/server.d.ts +0 -1
  109. package/dist/integrations/proxy/server.js +146 -0
  110. package/dist/{proxy → integrations/proxy}/types.d.ts +4 -0
  111. package/dist/{proxy → integrations/proxy}/utils/logging.d.ts +1 -0
  112. package/dist/{proxy → integrations/proxy}/utils/logging.js +5 -0
  113. package/package.json +31 -10
  114. package/postinstall.js +62 -6
  115. package/dist/cli.js +0 -149
  116. package/dist/commands/capture.d.ts +0 -6
  117. package/dist/commands/capture.js +0 -324
  118. package/dist/commands/disable.d.ts +0 -1
  119. package/dist/commands/disable.js +0 -14
  120. package/dist/commands/doctor.d.ts +0 -1
  121. package/dist/commands/doctor.js +0 -89
  122. package/dist/commands/init.d.ts +0 -1
  123. package/dist/commands/init.js +0 -52
  124. package/dist/commands/inject.d.ts +0 -5
  125. package/dist/commands/inject.js +0 -88
  126. package/dist/commands/prompt-inject.d.ts +0 -4
  127. package/dist/commands/prompt-inject.js +0 -451
  128. package/dist/commands/unregister.d.ts +0 -1
  129. package/dist/commands/unregister.js +0 -28
  130. package/dist/lib/anchor-extractor.d.ts +0 -30
  131. package/dist/lib/anchor-extractor.js +0 -296
  132. package/dist/lib/correction-builder.d.ts +0 -10
  133. package/dist/lib/correction-builder.js +0 -226
  134. package/dist/lib/drift-checker-proxy.js +0 -373
  135. package/dist/lib/drift-checker.d.ts +0 -66
  136. package/dist/lib/drift-checker.js +0 -341
  137. package/dist/lib/hooks.d.ts +0 -38
  138. package/dist/lib/hooks.js +0 -291
  139. package/dist/lib/jsonl-parser.d.ts +0 -87
  140. package/dist/lib/jsonl-parser.js +0 -281
  141. package/dist/lib/session-parser.d.ts +0 -44
  142. package/dist/lib/session-parser.js +0 -256
  143. package/dist/lib/store.d.ts +0 -1
  144. package/dist/proxy/cache.d.ts +0 -32
  145. package/dist/proxy/cache.js +0 -47
  146. package/dist/proxy/handlers/preprocess.js +0 -186
  147. package/dist/proxy/index.js +0 -30
  148. package/dist/proxy/injection/delta-tracking.d.ts +0 -11
  149. package/dist/proxy/injection/delta-tracking.js +0 -94
  150. package/dist/proxy/injection/injectors.d.ts +0 -7
  151. package/dist/proxy/injection/injectors.js +0 -139
  152. package/dist/proxy/request-processor.d.ts +0 -27
  153. package/dist/proxy/request-processor.js +0 -233
  154. package/dist/proxy/server.js +0 -1289
  155. /package/dist/{commands → cli/commands}/drift-test.d.ts +0 -0
  156. /package/dist/{commands → cli/commands}/login.d.ts +0 -0
  157. /package/dist/{commands → cli/commands}/logout.d.ts +0 -0
  158. /package/dist/{commands → cli/commands}/proxy-status.d.ts +0 -0
  159. /package/dist/{commands → cli/commands}/status.d.ts +0 -0
  160. /package/dist/{commands → cli/commands}/uninstall.d.ts +0 -0
  161. /package/dist/{cli.d.ts → cli/index.d.ts} +0 -0
  162. /package/dist/{lib → core/cloud}/api-client.d.ts +0 -0
  163. /package/dist/{lib → core/cloud}/api-client.js +0 -0
  164. /package/dist/{lib → core/cloud}/credentials.d.ts +0 -0
  165. /package/dist/{lib → core/cloud}/credentials.js +0 -0
  166. /package/dist/{lib → core}/store/convenience.d.ts +0 -0
  167. /package/dist/{lib → core}/store/convenience.js +0 -0
  168. /package/dist/{lib → core}/store/database.d.ts +0 -0
  169. /package/dist/{lib → core}/store/database.js +0 -0
  170. /package/dist/{lib → core}/store/drift.d.ts +0 -0
  171. /package/dist/{lib → core}/store/drift.js +0 -0
  172. /package/dist/{lib → core}/store/index.d.ts +0 -0
  173. /package/dist/{lib → core}/store/index.js +0 -0
  174. /package/dist/{lib → core}/store/sessions.d.ts +0 -0
  175. /package/dist/{lib → core}/store/steps.d.ts +0 -0
  176. /package/dist/{lib → core}/store/steps.js +0 -0
  177. /package/dist/{lib → core}/store/tasks.d.ts +0 -0
  178. /package/dist/{lib → core}/store/tasks.js +0 -0
  179. /package/dist/{lib → core}/store/types.js +0 -0
  180. /package/dist/{proxy/action-parser.js → integrations/proxy/agents/claude/parser.js} +0 -0
  181. /package/dist/{lib → integrations/proxy/agents/claude}/settings.d.ts +0 -0
  182. /package/dist/{lib → integrations/proxy/agents/claude}/settings.js +0 -0
  183. /package/dist/{proxy → integrations/proxy/cache}/extended-cache.d.ts +0 -0
  184. /package/dist/{proxy → integrations/proxy}/config.d.ts +0 -0
  185. /package/dist/{proxy → integrations/proxy}/index.d.ts +0 -0
  186. /package/dist/{proxy → integrations/proxy}/types.js +0 -0
  187. /package/dist/{lib → utils}/debug.d.ts +0 -0
  188. /package/dist/{lib → utils}/debug.js +0 -0
  189. /package/dist/{lib → utils}/utils.d.ts +0 -0
  190. /package/dist/{lib → utils}/utils.js +0 -0
@@ -1,233 +0,0 @@
1
- // Request processor - handles context injection from team memory
2
- // Reference: plan_proxy_local.md Section 2.1
3
- import { truncate } from '../lib/utils.js';
4
- import { fetchTeamMemories } from '../lib/api-client.js';
5
- import { isDebugMode } from './utils/logging.js';
6
- /**
7
- * Build context from CLOUD team memory for injection
8
- * Fetches memories from Supabase via API (cloud-first approach)
9
- * Uses hybrid search (semantic + lexical) when userPrompt is provided
10
- *
11
- * @param teamId - Team UUID from sync configuration
12
- * @param projectPath - Project path to filter by
13
- * @param mentionedFiles - Files mentioned in user messages (for boost)
14
- * @param userPrompt - User's prompt for semantic search (optional)
15
- * @returns Formatted context string or null if no memories found
16
- */
17
- export async function buildTeamMemoryContextCloud(teamId, projectPath, mentionedFiles, userPrompt) {
18
- const hasContext = userPrompt && userPrompt.trim().length > 0;
19
- try {
20
- // Fetch memories from cloud API (hybrid search if context provided)
21
- const memories = await fetchTeamMemories(teamId, projectPath, {
22
- status: 'complete',
23
- limit: 5,
24
- files: mentionedFiles.length > 0 ? mentionedFiles : undefined,
25
- context: hasContext ? userPrompt : undefined,
26
- current_files: mentionedFiles.length > 0 ? mentionedFiles : undefined,
27
- });
28
- if (memories.length === 0) {
29
- return null;
30
- }
31
- // Log injected memories (debug mode only)
32
- if (isDebugMode()) {
33
- for (const m of memories) {
34
- const label = m.goal || m.original_query;
35
- const sem = m.semantic_score?.toFixed(2) || '-';
36
- const lex = m.lexical_score?.toFixed(2) || '-';
37
- const comb = m.combined_score?.toFixed(2) || '-';
38
- console.log(`[INJECT] ${label.substring(0, 50)}... (${comb}|${sem}|${lex})`);
39
- }
40
- }
41
- // Convert Memory[] to Task[] format for the existing formatter
42
- const tasks = memories.map(memoryToTask);
43
- // Reuse existing formatter
44
- const context = formatTeamMemoryContext(tasks, [], mentionedFiles);
45
- return context;
46
- }
47
- catch (err) {
48
- return null; // Fail silent - don't block Claude Code
49
- }
50
- }
51
- /**
52
- * Convert Memory (cloud format) to Task (local format)
53
- * Used to reuse existing formatTeamMemoryContext function
54
- */
55
- function memoryToTask(memory) {
56
- return {
57
- id: memory.id,
58
- project_path: memory.project_path,
59
- user: memory.user_id || undefined,
60
- original_query: memory.original_query,
61
- goal: memory.goal || undefined,
62
- reasoning_trace: memory.reasoning_trace || [],
63
- files_touched: memory.files_touched || [],
64
- decisions: memory.decisions || [],
65
- constraints: memory.constraints || [],
66
- status: memory.status,
67
- tags: memory.tags || [],
68
- linked_commit: memory.linked_commit || undefined,
69
- created_at: memory.created_at,
70
- };
71
- }
72
- /**
73
- * Format team memory context for injection
74
- */
75
- function formatTeamMemoryContext(tasks, fileReasonings, files) {
76
- const lines = [];
77
- lines.push('=== VERIFIED TEAM KNOWLEDGE (from previous sessions) ===');
78
- lines.push('');
79
- lines.push('IMPORTANT: This context has been verified. USE IT to answer directly.');
80
- lines.push('DO NOT launch Explore agents or re-investigate files mentioned below.');
81
- lines.push('');
82
- // File-level context
83
- if (fileReasonings.length > 0) {
84
- lines.push('File-level context:');
85
- for (const fr of fileReasonings.slice(0, 5)) {
86
- const anchor = fr.anchor ? ` (${fr.anchor})` : '';
87
- lines.push(`- ${fr.file_path}${anchor}: ${truncate(fr.reasoning, 100)}`);
88
- }
89
- lines.push('');
90
- }
91
- // Task context with knowledge pairs and decisions
92
- // Inject up to 5 pairs (10 entries) per task for rich context
93
- if (tasks.length > 0) {
94
- lines.push('Related past tasks:');
95
- for (const task of tasks.slice(0, 5)) { // Limit to 5 tasks (Convex Combination top results)
96
- lines.push(`- ${truncate(task.original_query, 60)}`);
97
- if (task.files_touched.length > 0) {
98
- const fileList = task.files_touched.slice(0, 5).map(f => f.split('/').pop()).join(', ');
99
- lines.push(` Files: ${fileList}`);
100
- }
101
- // Inject knowledge pairs - handle both formats:
102
- // Old format: string[] interleaved (conclusion, insight, conclusion, insight...)
103
- // New format: Array<{ tags?, conclusion, insight? }> objects
104
- if (task.reasoning_trace.length > 0) {
105
- lines.push(' Knowledge:');
106
- const maxPairs = 5;
107
- const entries = task.reasoning_trace.slice(0, maxPairs);
108
- for (const entry of entries) {
109
- if (typeof entry === 'string') {
110
- // Old format: plain string - just remove prefix and show
111
- const text = entry.replace(/^(CONCLUSION|INSIGHT):\s*/i, '');
112
- if (text) {
113
- lines.push(` • ${truncate(text, 120)}`);
114
- }
115
- }
116
- else if (typeof entry === 'object' && entry !== null) {
117
- // New format: object with tags, conclusion, insight
118
- const cText = entry.conclusion?.replace(/^CONCLUSION:\s*/i, '') || '';
119
- if (cText) {
120
- const prefix = entry.tags ? `[${entry.tags}] ` : '';
121
- lines.push(` • ${prefix}${truncate(cText, 110)}`);
122
- }
123
- if (entry.insight) {
124
- const iText = entry.insight.replace(/^INSIGHT:\s*/i, '');
125
- lines.push(` → ${truncate(iText, 100)}`);
126
- }
127
- }
128
- }
129
- }
130
- // Include decisions (up to 2 per task)
131
- if (task.decisions && task.decisions.length > 0) {
132
- const decisionsToShow = task.decisions.slice(0, 2);
133
- for (const decision of decisionsToShow) {
134
- lines.push(` Decision: ${truncate(decision.choice, 60)} (${truncate(decision.reason, 50)})`);
135
- }
136
- }
137
- // Include constraints if available
138
- if (task.constraints && task.constraints.length > 0) {
139
- lines.push(` Constraints: ${task.constraints.slice(0, 2).join(', ')}`);
140
- }
141
- }
142
- lines.push('');
143
- }
144
- if (files.length > 0) {
145
- lines.push(`Files with existing context: ${files.join(', ')}`);
146
- }
147
- lines.push('');
148
- lines.push('Answer the user\'s question using the knowledge above. Skip exploration.');
149
- lines.push('=== END VERIFIED TEAM KNOWLEDGE ===');
150
- return lines.join('\n');
151
- }
152
- /**
153
- * Extract file paths from messages (user messages only, clean text)
154
- */
155
- export function extractFilesFromMessages(messages) {
156
- const files = [];
157
- // Pattern matches filenames with extensions, allowing common punctuation after
158
- const filePattern = /(?:^|\s|["'`])([\/\w.-]+\.[a-zA-Z]{1,10})(?:["'`]|\s|$|[:)\]?!,;])/g;
159
- for (const msg of messages) {
160
- // Only scan user messages for file mentions
161
- if (msg.role !== 'user')
162
- continue;
163
- let textContent = '';
164
- // Handle string content
165
- if (typeof msg.content === 'string') {
166
- textContent = msg.content;
167
- }
168
- // Handle array content (Claude Code API format)
169
- if (Array.isArray(msg.content)) {
170
- for (const block of msg.content) {
171
- if (block && typeof block === 'object' && 'type' in block && block.type === 'text' && 'text' in block && typeof block.text === 'string') {
172
- textContent += block.text + '\n';
173
- }
174
- }
175
- }
176
- // Strip system-reminder tags to get clean user content
177
- const cleanContent = textContent
178
- .replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, '')
179
- .trim();
180
- if (cleanContent) {
181
- let match;
182
- while ((match = filePattern.exec(cleanContent)) !== null) {
183
- const path = match[1];
184
- // Filter out common false positives
185
- if (!path.includes('http') && !path.startsWith('.') && path.length > 3) {
186
- files.push(path);
187
- }
188
- }
189
- }
190
- }
191
- return [...new Set(files)];
192
- }
193
- /**
194
- * Extract the last user prompt from messages for semantic search
195
- * Returns clean text without system tags
196
- */
197
- export function extractLastUserPrompt(messages) {
198
- // Find last user message
199
- for (let i = messages.length - 1; i >= 0; i--) {
200
- const msg = messages[i];
201
- if (msg.role !== 'user')
202
- continue;
203
- let textContent = '';
204
- // Handle string content
205
- if (typeof msg.content === 'string') {
206
- textContent = msg.content;
207
- }
208
- // Handle array content (Claude Code API format)
209
- if (Array.isArray(msg.content)) {
210
- for (const block of msg.content) {
211
- if (block && typeof block === 'object' && 'type' in block && block.type === 'text' && 'text' in block && typeof block.text === 'string') {
212
- textContent += block.text + '\n';
213
- }
214
- }
215
- }
216
- // Strip system-reminder tags and continuation artifacts to get clean user content
217
- const cleanContent = textContent
218
- // Remove actual system-reminder tags
219
- .replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, '')
220
- // Remove escaped/broken system-reminder artifacts from continuation summaries
221
- .replace(/\\n["']?\s*<\/system-reminder>/g, '')
222
- .replace(/<\/system-reminder>/g, '')
223
- // Remove continuation summary header if it's the entire content
224
- .replace(/^This session is being continued from a previous conversation[\s\S]*?Summary:/gi, '')
225
- // Clean up leading noise (newlines, quotes, whitespace)
226
- .replace(/^[\s\n"'\\]+/, '')
227
- .trim();
228
- if (cleanContent && cleanContent.length > 5) {
229
- return cleanContent;
230
- }
231
- }
232
- return undefined;
233
- }