| 115 | }; |
| 116 | |
| 117 | function buildSystemPrompt(tools: string[]): string { |
| 118 | const toolList = tools.map((t) => `- ${t}: ${TOOL_DESCRIPTIONS[t] || 'Unix command'}`).join('\n'); |
| 119 | |
| 120 | const tips = [ |
| 121 | "Use 'find' to locate files by pattern", |
| 122 | "Use 'grep -r' for recursive text search", |
| 123 | 'All files are in the working directory', |
| 124 | ]; |
| 125 | |
| 126 | if (tools.includes('jq')) { |
| 127 | tips.push("Use 'jq' to extract specific fields from JSON files"); |
| 128 | } |
| 129 | |
| 130 | return `You are a data analyst assistant that explores GitHub event data stored in a filesystem. |
| 131 | |
| 132 | IMPORTANT: You are already in the data directory. Do NOT use "cd" commands - all paths are relative to the current working directory. |
| 133 | |
| 134 | The data is organized as follows: |
| 135 | - repos/{owner}/{repo}/repo.json - Repository metadata |
| 136 | - repos/{owner}/{repo}/issues/{number}.json - Issue data with title, body, state, labels, comments |
| 137 | - repos/{owner}/{repo}/pulls/{number}.json - Pull request data with title, body, state, merged status, comments |
| 138 | - users/{username}.json - User data with activity counts |
| 139 | |
| 140 | You have access to standard Unix tools via bash: |
| 141 | ${toolList} |
| 142 | |
| 143 | Use these tools to explore the data and answer questions. Start by understanding the directory structure, then drill down to find specific information. |
| 144 | |
| 145 | When searching, consider: |
| 146 | ${tips.map((t) => `- ${t}`).join('\n')}`; |
| 147 | } |
| 148 | |
| 149 | export interface AgentResult { |
| 150 | answer: string; |