* The reaction one action represents, given what the explore had returned. * `earlier` is what PREVIOUS explores in the same thread returned: a re-read of * a file we already shipped is an allocation miss wherever it was shipped, and * filing it as recall would point the fix at the wrong end of t
(action, returned, mentioned, earlier = [])
| 819 | * filing it as recall would point the fix at the wrong end of the pipeline. |
| 820 | */ |
| 821 | function reactionOf(action, returned, mentioned, earlier = []) { |
| 822 | const { name, input } = action; |
| 823 | const readOf = (path, prefix) => { |
| 824 | const base = normPath(path).split('/').pop() || String(path ?? ''); |
| 825 | if (returned.some((r) => samePath(path, r))) return { bucket: 'read_returned', next: `${prefix}Read ${base}` }; |
| 826 | if (earlier.some((r) => samePath(path, r))) return { bucket: 'read_returned', next: `${prefix}Read ${base} (returned by an earlier explore)` }; |
| 827 | const named = mentioned.some((m) => samePath(path, m)); |
| 828 | return { bucket: 'read_missed', next: `${prefix}Read ${base}${named ? ' (named, not returned)' : ''}`, named }; |
| 829 | }; |
| 830 | if (/codegraph/.test(name)) return { bucket: 'explore_again', next: name.replace(/^mcp__[^_]*__/, '') }; |
| 831 | if (name === 'Read' || name === 'NotebookRead') return readOf(input.file_path ?? input.notebook_path, ''); |
| 832 | if (name === 'Grep' || name === 'Glob') return { bucket: 'search', next: name }; |
| 833 | if (name === 'Bash') { |
| 834 | const intent = bashIntent(input.command); |
| 835 | if (intent?.kind === 'read') return readOf(intent.path, 'Bash '); |
| 836 | if (intent?.kind === 'search') return { bucket: 'search', next: 'Bash search' }; |
| 837 | } |
| 838 | return { bucket: 'sufficient', next: name }; |
| 839 | } |
| 840 | |
| 841 | /** Is this action one of the ways an agent gets file bytes into its head? */ |
| 842 | const isFileAccess = (a) => |
no test coverage detected