(ctx context.Context)
| 1413 | } |
| 1414 | |
| 1415 | func (cli *ChatCLI) runCoderLogic(ctx context.Context) { |
| 1416 | cli.setExecutionProfile(ProfileCoder) |
| 1417 | defer cli.setExecutionProfile(ProfileNormal) |
| 1418 | |
| 1419 | if len(cli.commandHistory) == 0 { |
| 1420 | return |
| 1421 | } |
| 1422 | lastCommand := cli.commandHistory[len(cli.commandHistory)-1] |
| 1423 | |
| 1424 | var query string |
| 1425 | if strings.HasPrefix(lastCommand, "/plan coder") { |
| 1426 | query = strings.TrimSpace(strings.TrimPrefix(lastCommand, "/plan coder")) |
| 1427 | } else { |
| 1428 | query = strings.TrimSpace(strings.TrimPrefix(lastCommand, "/coder")) |
| 1429 | } |
| 1430 | if query == "" { |
| 1431 | fmt.Println(i18n.T("error.agent_query_extraction")) |
| 1432 | return |
| 1433 | } |
| 1434 | |
| 1435 | wd, _ := os.Getwd() |
| 1436 | renderer := agent.NewUIRenderer(cli.logger) |
| 1437 | // "🛠️" carries the VS-16 emoji-presentation selector so runewidth and the |
| 1438 | // terminal agree it is 2 cells wide. The bare "🛠" (U+1F6E0) defaults to |
| 1439 | // text presentation and is measured as 1 while most terminals render it as |
| 1440 | // 2, which drifted the banner's top border. (No trailing-space hack now.) |
| 1441 | renderer.RenderModeBanner("🛠️", i18n.T("coder.banner.title"), agent.ColorCyan, [][2]string{ |
| 1442 | {i18n.T("coder.banner.objective"), query}, |
| 1443 | {i18n.T("coder.banner.workspace"), wd}, |
| 1444 | {i18n.T("coder.banner.policy"), i18n.T("coder.banner.policy_value")}, |
| 1445 | }) |
| 1446 | |
| 1447 | query, additionalContext, images := cli.processSpecialCommands(ctx, query) |
| 1448 | images, visionDesc := cli.gateImagesForModel(ctx, images) |
| 1449 | additionalContext += visionDesc |
| 1450 | |
| 1451 | if cli.agentMode == nil { |
| 1452 | cli.agentMode = NewAgentMode(cli, cli.logger) |
| 1453 | } |
| 1454 | |
| 1455 | cli.agentMode.pendingUserImages = images |
| 1456 | cli.agentMode.isOneShot = false // interactive /coder: wait for input between turns |
| 1457 | cli.runWithCancellation(ctx, "Coder Mode", func(ctx context.Context) error { |
| 1458 | return cli.agentMode.Run(ctx, query, additionalContext, CoderSystemPrompt) |
| 1459 | }) |
| 1460 | |
| 1461 | // Nudge memory worker after coder run |
| 1462 | if cli.memWorker != nil { |
| 1463 | cli.memWorker.nudge(ctx) |
| 1464 | } |
| 1465 | |
| 1466 | fmt.Println(colorize("\n "+i18n.T("coder.session_finished"), ColorGreen)) |
| 1467 | } |
| 1468 | |
| 1469 | func (cli *ChatCLI) handleCtrlC(buf *prompt.Buffer) { |
| 1470 | // Cancel multiline mode on Ctrl+C |
no test coverage detected