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
@@ -0,0 +1,270 @@
1
+ #!/usr/bin/env node
2
+ import 'dotenv/config';
3
+ import { Command } from 'commander';
4
+ import { createRequire } from 'module';
5
+ import { closeDatabase } from '../core/store/store.js';
6
+ const require = createRequire(import.meta.url);
7
+ const pkg = require('../../package.json');
8
+ // SECURITY: Global error handlers to catch unhandled rejections from dynamic imports
9
+ process.on('unhandledRejection', (reason) => {
10
+ console.error('Error:', reason instanceof Error ? reason.message : 'Unknown error');
11
+ closeDatabase();
12
+ process.exit(1);
13
+ });
14
+ process.on('uncaughtException', (error) => {
15
+ console.error('Error:', error.message);
16
+ closeDatabase();
17
+ process.exit(1);
18
+ });
19
+ const program = new Command();
20
+ /**
21
+ * Wrap async action with error handling and cleanup.
22
+ * Ensures database connections are closed and errors are handled gracefully.
23
+ */
24
+ function safeAction(fn) {
25
+ return async (options) => {
26
+ try {
27
+ await fn(options);
28
+ }
29
+ catch (error) {
30
+ console.error('Error:', error instanceof Error ? error.message : 'Unknown error');
31
+ process.exit(1);
32
+ }
33
+ finally {
34
+ closeDatabase();
35
+ }
36
+ };
37
+ }
38
+ program
39
+ .name('grov')
40
+ .description('Collective AI memory for engineering teams')
41
+ .version(pkg.version);
42
+ program
43
+ .command('init [agent]')
44
+ .description('Configure AI agent (claude, codex, cursor, antigravity, or zed)')
45
+ .action(safeAction(async (agent) => {
46
+ const { init } = await import('./commands/init.js');
47
+ if (agent === 'cursor') {
48
+ await init('cursor');
49
+ }
50
+ else if (agent === 'antigravity') {
51
+ await init('antigravity');
52
+ }
53
+ else if (agent === 'zed') {
54
+ await init('zed');
55
+ }
56
+ else {
57
+ const agentName = (agent === 'codex' ? 'codex' : 'claude');
58
+ await init(agentName);
59
+ }
60
+ }));
61
+ program
62
+ .command('disable [agent]')
63
+ .description('Disable grov for AI agent (claude, codex, cursor, antigravity, or zed)')
64
+ .action(safeAction(async (agent) => {
65
+ const { disable } = await import('./commands/disable.js');
66
+ if (agent === 'cursor') {
67
+ await disable('cursor');
68
+ }
69
+ else if (agent === 'antigravity') {
70
+ await disable('antigravity');
71
+ }
72
+ else if (agent === 'zed') {
73
+ await disable('zed');
74
+ }
75
+ else {
76
+ const agentName = (agent === 'codex' ? 'codex' : 'claude');
77
+ await disable(agentName);
78
+ }
79
+ }));
80
+ // grov status - Show stored reasoning for current project
81
+ program
82
+ .command('status')
83
+ .description('Show stored reasoning for current project')
84
+ .option('--all', 'Show all tasks, not just completed')
85
+ .action(safeAction(async (options) => {
86
+ const { status } = await import('./commands/status.js');
87
+ await status(options);
88
+ }));
89
+ // grov drift-test - Test drift detection on a prompt (internal/debug)
90
+ program
91
+ .command('drift-test', { hidden: true })
92
+ .description('Test drift detection on a prompt (debug command)')
93
+ .argument('<prompt>', 'The prompt to test for drift')
94
+ .option('--session <id>', 'Session ID to use for context')
95
+ .option('--goal <text>', 'Original goal (if no session provided)')
96
+ .option('-v, --verbose', 'Show verbose output')
97
+ .action(async (prompt, options) => {
98
+ const { driftTest } = await import('./commands/drift-test.js');
99
+ await driftTest(prompt, options);
100
+ });
101
+ // grov proxy - Start the proxy server
102
+ program
103
+ .command('proxy')
104
+ .description('Start the Grov proxy server (intercepts Claude API calls)')
105
+ .option('-d, --debug', 'Enable debug logging to grov-proxy.log')
106
+ .option('--extended-cache', 'Keep Anthropic cache alive during idle (sends requests on your behalf)')
107
+ .action(async (options) => {
108
+ if (options.extendedCache) {
109
+ process.env.GROV_EXTENDED_CACHE = 'true';
110
+ console.log('\n⚠️ Extended Cache Enabled');
111
+ console.log(' By using --extended-cache, you consent to Grov making');
112
+ console.log(' minimal keep-alive requests on your behalf to preserve');
113
+ console.log(' Anthropic\'s prompt cache during idle periods.\n');
114
+ }
115
+ const { startServer } = await import('../integrations/proxy/server.js');
116
+ await startServer({ debug: options.debug ?? false });
117
+ });
118
+ // grov proxy-status - Show active proxy sessions
119
+ program
120
+ .command('proxy-status')
121
+ .description('Show active proxy sessions')
122
+ .action(safeAction(async () => {
123
+ const { proxyStatus } = await import('./commands/proxy-status.js');
124
+ await proxyStatus();
125
+ }));
126
+ // grov login - Authenticate with Grov cloud
127
+ program
128
+ .command('login')
129
+ .description('Login to Grov cloud (opens browser for authentication)')
130
+ .action(safeAction(async () => {
131
+ const { login } = await import('./commands/login.js');
132
+ await login();
133
+ }));
134
+ // grov logout - Clear stored credentials
135
+ program
136
+ .command('logout')
137
+ .description('Logout from Grov cloud')
138
+ .action(safeAction(async () => {
139
+ const { logout } = await import('./commands/logout.js');
140
+ await logout();
141
+ }));
142
+ // grov uninstall - Full cleanup
143
+ program
144
+ .command('uninstall')
145
+ .description('Remove all grov data and configuration')
146
+ .action(safeAction(async () => {
147
+ const { uninstall } = await import('./commands/uninstall.js');
148
+ await uninstall();
149
+ }));
150
+ // grov sync - Configure cloud sync
151
+ program
152
+ .command('sync')
153
+ .description('Configure cloud sync to team dashboard')
154
+ .option('--enable', 'Enable cloud sync')
155
+ .option('--disable', 'Disable cloud sync')
156
+ .option('--team <id>', 'Set team ID for sync')
157
+ .option('--status', 'Show sync status')
158
+ .option('--push', 'Upload any unsynced local tasks to the team')
159
+ .option('--antigravity', 'Sync Antigravity sessions to cloud')
160
+ .action(safeAction(async (options) => {
161
+ const { sync } = await import('./commands/sync.js');
162
+ await sync(options);
163
+ }));
164
+ // grov doctor - Diagnose setup issues
165
+ program
166
+ .command('doctor [agent]')
167
+ .description('Check grov setup and diagnose issues (optional: claude, codex)')
168
+ .action(safeAction(async (agent) => {
169
+ const { doctor } = await import('./commands/doctor.js');
170
+ const agentName = agent === 'claude' || agent === 'codex' ? agent : undefined;
171
+ await doctor(agentName);
172
+ }));
173
+ // grov agents - List supported agents
174
+ program
175
+ .command('agents')
176
+ .description('List supported AI agents and setup instructions')
177
+ .action(safeAction(async () => {
178
+ const { agents } = await import('./commands/agents.js');
179
+ agents();
180
+ }));
181
+ // grov setup - Interactive setup wizard
182
+ program
183
+ .command('setup')
184
+ .description('Interactive setup wizard for new users')
185
+ .action(safeAction(async () => {
186
+ const { setup } = await import('./commands/setup.js');
187
+ await setup();
188
+ }));
189
+ // grov mcp - Start MCP server (called by Cursor, not user)
190
+ program
191
+ .command('mcp', { hidden: true })
192
+ .description('Start MCP server for Cursor integration')
193
+ .action(async () => {
194
+ const { startMcpServer } = await import('../integrations/mcp/index.js');
195
+ await startMcpServer();
196
+ });
197
+ // grov capture-hook - Called by Cursor stop hook (internal)
198
+ program
199
+ .command('capture-hook', { hidden: true })
200
+ .description('Internal: Called by Cursor stop hook to capture conversations')
201
+ .action(async () => {
202
+ await import('../integrations/mcp/capture/hook-handler.js');
203
+ });
204
+ // Smart no-args behavior: show "get started" or status
205
+ async function showSmartDefault() {
206
+ const { isAuthenticated, getSyncStatus } = await import('../core/cloud/credentials.js');
207
+ const { isAnyAgentConfigured, getFirstConfiguredAgent } = await import('./agents/registry.js');
208
+ const loggedIn = isAuthenticated();
209
+ const agentConfigured = isAnyAgentConfigured();
210
+ if (!loggedIn && !agentConfigured) {
211
+ // First run - show get started
212
+ console.log('\ngrov - Collective AI memory for engineering teams\n');
213
+ console.log('┌─────────────────────────────────────────────────────────────┐');
214
+ console.log('│ GET STARTED │');
215
+ console.log('│ │');
216
+ console.log('│ Run: grov setup │');
217
+ console.log('│ │');
218
+ console.log('│ This will: │');
219
+ console.log('│ • Connect to your team dashboard │');
220
+ console.log('│ • Configure your AI agent (Claude, Codex, Cursor, etc.) │');
221
+ console.log('│ • Show you exactly how to use grov │');
222
+ console.log('└─────────────────────────────────────────────────────────────┘');
223
+ console.log('\nOr see all commands: grov --help\n');
224
+ return;
225
+ }
226
+ // Setup done - show status dashboard
227
+ console.log('\ngrov - Collective AI memory for engineering teams\n');
228
+ console.log('STATUS');
229
+ const agent = getFirstConfiguredAgent();
230
+ if (agent) {
231
+ console.log(`\x1b[32m●\x1b[0m ${agent.name} Configured`);
232
+ }
233
+ else {
234
+ console.log('\x1b[90m○\x1b[0m Agent Not configured');
235
+ }
236
+ const syncStatus = getSyncStatus();
237
+ if (syncStatus?.enabled && syncStatus.teamId) {
238
+ console.log(`\x1b[32m●\x1b[0m Team Sync Enabled`);
239
+ }
240
+ else if (loggedIn) {
241
+ console.log('\x1b[33m○\x1b[0m Team Sync Disabled');
242
+ }
243
+ else {
244
+ console.log('\x1b[90m○\x1b[0m Team Sync Not logged in');
245
+ }
246
+ if (agent?.type === 'cli') {
247
+ console.log('\nTO USE:');
248
+ console.log(' Terminal 1: grov proxy');
249
+ console.log(` Terminal 2: ${agent.command}`);
250
+ }
251
+ else if (agent?.type === 'ide') {
252
+ console.log('\nTO USE:');
253
+ console.log(` Restart ${agent.name} and use normally`);
254
+ }
255
+ console.log('\nCOMMANDS');
256
+ console.log(' grov proxy Start the proxy (for CLI agents)');
257
+ console.log(' grov status View captured memories');
258
+ console.log(' grov doctor Check setup health');
259
+ console.log('\nAll commands: grov --help\n');
260
+ }
261
+ // Check if no args - show smart default
262
+ if (process.argv.length === 2) {
263
+ showSmartDefault().catch(err => {
264
+ console.error('Error:', err instanceof Error ? err.message : 'Unknown error');
265
+ process.exit(1);
266
+ });
267
+ }
268
+ else {
269
+ program.parse();
270
+ }
@@ -1,6 +1,6 @@
1
1
  import type { CreateMemoryInput, Memory } from '@grov/shared';
2
- import type { Task } from './store.js';
3
- import type { ExtractedReasoningAndDecisions, ShouldUpdateResult } from './llm-extractor.js';
2
+ import type { Task } from '../store/store.js';
3
+ import type { ExtractedReasoningAndDecisions, ShouldUpdateResult, RequestHeaders } from '../extraction/llm-extractor.js';
4
4
  /**
5
5
  * Evolution step in memory history
6
6
  */
@@ -70,7 +70,7 @@ export declare function getSyncTeamId(): string | null;
70
70
  * @param extractedData - Optional pre-extracted reasoning and decisions
71
71
  * @param taskType - Optional task type for shouldUpdateMemory context
72
72
  */
73
- export declare function syncTask(task: Task, extractedData?: ExtractedReasoningAndDecisions, taskType?: 'information' | 'planning' | 'implementation'): Promise<boolean>;
73
+ export declare function syncTask(task: Task, extractedData: ExtractedReasoningAndDecisions | undefined, taskType: 'information' | 'planning' | 'implementation' | undefined, headers: RequestHeaders): Promise<boolean>;
74
74
  /**
75
75
  * Sync multiple tasks with batching and retry
76
76
  */
@@ -2,7 +2,7 @@
2
2
  // Handles batching, retries, and conversion from Task to Memory format
3
3
  import { getSyncStatus, getAccessToken } from './credentials.js';
4
4
  import { syncMemories, sleep, getApiUrl, fetchMatch } from './api-client.js';
5
- import { shouldUpdateMemory, isShouldUpdateAvailable } from './llm-extractor.js';
5
+ import { shouldUpdateMemory } from '../extraction/llm-extractor.js';
6
6
  // Sync configuration
7
7
  const SYNC_CONFIG = {
8
8
  batchSize: 10, // Number of memories per batch
@@ -154,7 +154,7 @@ export function getSyncTeamId() {
154
154
  * @param extractedData - Optional pre-extracted reasoning and decisions
155
155
  * @param taskType - Optional task type for shouldUpdateMemory context
156
156
  */
157
- export async function syncTask(task, extractedData, taskType) {
157
+ export async function syncTask(task, extractedData, taskType, headers) {
158
158
  if (!isSyncEnabled()) {
159
159
  return false;
160
160
  }
@@ -190,16 +190,16 @@ export async function syncTask(task, extractedData, taskType) {
190
190
  if (!matchResult.match) {
191
191
  const memory = taskToMemory(task);
192
192
  const result = await syncMemories(teamId, { memories: [memory] });
193
- console.log(`[SYNC] ${taskId} -> INSERT ${result.synced === 1 ? 'OK' : 'FAILED'}`);
193
+ console.log(`[SYNC TO CLOUD] ${taskId} -> INSERT (${taskType || 'unknown'})`);
194
194
  return result.synced === 1;
195
195
  }
196
196
  const matchedId = matchResult.match.id.substring(0, 8);
197
197
  const score = matchResult.combined_score?.toFixed(3) || '-';
198
- // If shouldUpdateMemory is not available or no extracted data, INSERT anyway
199
- if (!isShouldUpdateAvailable() || !effectiveExtractedData) {
198
+ // If no extracted data, INSERT anyway
199
+ if (!effectiveExtractedData) {
200
200
  const memory = taskToMemory(task);
201
201
  const result = await syncMemories(teamId, { memories: [memory] });
202
- console.log(`[SYNC] ${taskId} -> INSERT (no haiku) ${result.synced === 1 ? 'OK' : 'FAILED'}`);
202
+ console.log(`[SYNC TO CLOUD] ${taskId} -> INSERT (${taskType || 'unknown'})`);
203
203
  return result.synced === 1;
204
204
  }
205
205
  // Build session context for shouldUpdateMemory
@@ -216,22 +216,22 @@ export async function syncTask(task, extractedData, taskType) {
216
216
  reasoning_trace: matchResult.match.reasoning_trace || [],
217
217
  evolution_steps: (matchResult.match.evolution_steps || []),
218
218
  files_touched: matchResult.match.files_touched || [],
219
- }, effectiveExtractedData, sessionContext);
219
+ }, effectiveExtractedData, sessionContext, headers);
220
220
  // If should NOT update, skip sync entirely
221
221
  if (!updateResult.should_update) {
222
- console.log(`[SYNC] ${taskId} -> SKIP (matched ${matchedId}, score=${score})`);
222
+ console.log(`[SYNC TO CLOUD] ${taskId} -> SKIP (unchanged) [matched: ${matchedId}]`);
223
223
  return true;
224
224
  }
225
225
  // Prepare payload for UPDATE
226
226
  const payload = prepareSyncPayload(matchResult.match, effectiveExtractedData, updateResult, task);
227
227
  // Sync with memory_id for UPDATE path
228
228
  const result = await syncMemories(teamId, { memories: [payload] });
229
- console.log(`[SYNC] ${taskId} -> UPDATE ${matchedId} (score=${score}) ${result.synced === 1 ? 'OK' : 'FAILED'}`);
229
+ console.log(`[SYNC TO CLOUD] ${taskId} -> UPDATE (${taskType || 'unknown'}) [matched: ${matchedId}]`);
230
230
  return result.synced === 1;
231
231
  }
232
232
  catch (err) {
233
233
  const msg = err instanceof Error ? err.message : 'Unknown error';
234
- console.error(`[SYNC] Error: ${msg}`);
234
+ console.error(`[SYNC TO CLOUD] ERROR: ${msg}`);
235
235
  return false;
236
236
  }
237
237
  }
@@ -1,4 +1,4 @@
1
- import type { SessionState, CorrectionLevel } from './store.js';
1
+ import type { SessionState, CorrectionLevel } from '../store/store.js';
2
2
  import type { DriftCheckResult } from './drift-checker-proxy.js';
3
3
  export interface CorrectionMessage {
4
4
  level: CorrectionLevel;
@@ -34,14 +34,10 @@ ${result.diagnostic}
34
34
  */
35
35
  function buildCorrect(result, sessionState) {
36
36
  const goal = sessionState.original_goal || 'the original task';
37
- const scope = sessionState.expected_scope.length > 0
38
- ? sessionState.expected_scope.join(', ')
39
- : 'the relevant files';
40
37
  let message = `<grov_correction>
41
38
  DRIFT DETECTED - Please refocus on the original goal.
42
39
 
43
40
  Original goal: ${goal}
44
- Expected scope: ${scope}
45
41
 
46
42
  Issue: ${result.diagnostic}
47
43
  `;
@@ -1,4 +1,5 @@
1
- import type { SessionState, StepRecord, DriftType, CorrectionLevel } from './store.js';
1
+ import type { SessionState, StepRecord, DriftType, CorrectionLevel } from '../store/store.js';
2
+ import type { RequestHeaders } from './llm-extractor.js';
2
3
  export interface DriftCheckInput {
3
4
  sessionState: SessionState;
4
5
  recentSteps: StepRecord[];
@@ -12,20 +13,23 @@ export interface DriftCheckResult {
12
13
  recoverySteps?: string[];
13
14
  }
14
15
  /**
15
- * Check if drift checking is available
16
+ * Main drift check - uses LLM with auth
16
17
  */
17
- export declare function isDriftCheckAvailable(): boolean;
18
- /**
19
- * Main drift check - uses LLM if available, fallback to basic
20
- */
21
- export declare function checkDrift(input: DriftCheckInput): Promise<DriftCheckResult>;
18
+ export declare function checkDrift(input: DriftCheckInput, headers: RequestHeaders): Promise<DriftCheckResult>;
22
19
  /**
23
20
  * Basic drift check without LLM (fallback)
21
+ * Returns safe default - no penalties without LLM analysis
24
22
  */
25
- export declare function checkDriftBasic(input: DriftCheckInput): DriftCheckResult;
23
+ export declare function checkDriftBasic(_input: DriftCheckInput): DriftCheckResult;
26
24
  /**
27
25
  * Convert score to correction level
28
26
  * Reference: plan_proxy_local.md Section 4.3
27
+ *
28
+ * Thresholds (lenient):
29
+ * - 5-10: OK, no correction needed
30
+ * - 4: nudge (mild reminder)
31
+ * - 3: correct (full correction)
32
+ * - 1-2: intervene (strong intervention)
29
33
  */
30
34
  export declare function scoreToCorrectionLevel(score: number): CorrectionLevel | null;
31
35
  /**
@@ -60,4 +64,4 @@ export interface ForcedRecoveryResult {
60
64
  export declare function generateForcedRecovery(sessionState: SessionState, recentActions: Array<{
61
65
  actionType: string;
62
66
  files: string[];
63
- }>, lastDriftResult: DriftCheckResult): Promise<ForcedRecoveryResult>;
67
+ }>, lastDriftResult: DriftCheckResult, headers: RequestHeaders): Promise<ForcedRecoveryResult>;