({ directory })
| 232 | } |
| 233 | |
| 234 | export const DebugPlugin: Plugin = async ({ directory }) => { |
| 235 | const LOG_PATH = getLogPath(directory); |
| 236 | |
| 237 | return { |
| 238 | auth: { |
| 239 | provider: config.authProvider, |
| 240 | loader: async (getAuth) => { |
| 241 | const auth = await getAuth(); |
| 242 | if (auth?.type === "api") storedNgrokToken = auth.key; |
| 243 | return {}; |
| 244 | }, |
| 245 | methods: [ |
| 246 | { |
| 247 | type: "api" as const, |
| 248 | label: config.authLabel, |
| 249 | prompts: [ |
| 250 | { |
| 251 | type: "text" as const, |
| 252 | key: "token", |
| 253 | message: config.authPromptMessage, |
| 254 | }, |
| 255 | ], |
| 256 | async authorize(inputs) { |
| 257 | if (!inputs?.token) return { type: "failed" as const }; |
| 258 | return { type: "success" as const, key: inputs.token }; |
| 259 | }, |
| 260 | }, |
| 261 | ], |
| 262 | }, |
| 263 | "experimental.chat.system.transform": async (_input, output) => { |
| 264 | if (debugModeActive && activeDebugUrl) { |
| 265 | output.system.push(getDebugInstructions(activeDebugUrl)); |
| 266 | } |
| 267 | }, |
| 268 | tool: { |
| 269 | debug_start: tool({ |
| 270 | description: `Start debug mode to capture runtime data from the codebase. |
| 271 | |
| 272 | WORKFLOW: |
| 273 | 1. Call this tool to start the debug server |
| 274 | 2. Insert fetch() calls at strategic locations in the code to capture runtime data |
| 275 | 3. Ask the user to reproduce the issue |
| 276 | 4. Use debug_read to analyze the captured logs and identify the problem |
| 277 | |
| 278 | This enables runtime debugging by capturing labeled data points as the code executes.`, |
| 279 | args: { |
| 280 | port: tool.schema |
| 281 | .number() |
| 282 | .optional() |
| 283 | .describe("Port for local server (default: auto-select)"), |
| 284 | }, |
| 285 | async execute(args) { |
| 286 | if (server) { |
| 287 | const localUrl = buildDebugUrl(`http://localhost:${server.port}`); |
| 288 | const publicUrl = tunnel?.url ? buildDebugUrl(tunnel.url) : null; |
| 289 | const url = publicUrl ?? localUrl; |
| 290 | return `Debug server already running!\n\nDebug URL: ${url}\n\n**Next Step:** Insert fetch() calls in the code where you need to capture data, then ask the user to reproduce the issue.`; |
| 291 | } |
nothing calls this directly
no test coverage detected