|
| 1 | +import { publisher } from '../constants' |
| 2 | + |
| 3 | +import { |
| 4 | + PLACEHOLDER, |
| 5 | + type SecretAgentDefinition, |
| 6 | +} from '../types/secret-agent-definition' |
| 7 | +import { AssistantMessage } from 'types/util-types' |
| 8 | + |
| 9 | +const definition: SecretAgentDefinition = { |
| 10 | + id: 'file-lister-max', |
| 11 | + displayName: 'Liszt the File Lister', |
| 12 | + publisher, |
| 13 | + model: 'anthropic/claude-haiku-4.5', |
| 14 | + spawnerPrompt: 'Lists files that are relevant to the prompt', |
| 15 | + inputSchema: { |
| 16 | + prompt: { |
| 17 | + type: 'string', |
| 18 | + description: 'A coding task to complete', |
| 19 | + }, |
| 20 | + }, |
| 21 | + outputMode: 'last_message', |
| 22 | + includeMessageHistory: false, |
| 23 | + toolNames: [], |
| 24 | + spawnableAgents: [], |
| 25 | + |
| 26 | + systemPrompt: `You are an expert at finding relevant files in a codebase and listing them out. ${PLACEHOLDER.FILE_TREE_PROMPT}`, |
| 27 | + instructionsPrompt: `PHASE 1 Instructions: |
| 28 | +- Do not use any tools. |
| 29 | +- Do not write any analysis. |
| 30 | +- List out the full paths of up to 12 files that are relevant to the prompt, separated by newlines. |
| 31 | +- Write out the following string to signal the end of this phase: |
| 32 | +"cb_easp": true |
| 33 | +
|
| 34 | +Do not write an introduction. Do not use any tools. Do not write anything else other than the file paths. |
| 35 | +
|
| 36 | +PHASE 2 Instructions: |
| 37 | +- Do not use any tools. |
| 38 | +- Do not write any analysis. |
| 39 | +- After reading those files, give your new best guess at the most relevant files, separated by newlines. |
| 40 | + `.trim(), |
| 41 | + |
| 42 | + handleSteps: function* ({ logger }) { |
| 43 | + const { agentState } = yield 'STEP_ALL' |
| 44 | + const { messageHistory } = agentState |
| 45 | + const lastAssistantMessage = messageHistory.findLast( |
| 46 | + (message) => message.role === 'assistant', |
| 47 | + ) as AssistantMessage |
| 48 | + const lastMessageContent = lastAssistantMessage.content |
| 49 | + const lastMessageStr = Array.isArray(lastMessageContent) |
| 50 | + ? lastMessageContent[0].type === 'text' |
| 51 | + ? lastMessageContent[0].text |
| 52 | + : '' |
| 53 | + : lastMessageContent |
| 54 | + |
| 55 | + const files = lastMessageStr.split('\n').filter(Boolean) |
| 56 | + |
| 57 | + yield { |
| 58 | + toolName: 'read_files', |
| 59 | + input: { |
| 60 | + paths: files, |
| 61 | + }, |
| 62 | + } |
| 63 | + |
| 64 | + yield 'STEP_ALL' |
| 65 | + }, |
| 66 | +} |
| 67 | + |
| 68 | +export default definition |
0 commit comments