Kode-cli/agents_create_flow.md
CrazyBoyM 926df2cfaf feat: Ultra-redesign completion system with @mention integration
- Complete architectural overhaul of useUnifiedCompletion hook
- Unified state management: 8 separate states → single CompletionState interface
- Simplified core logic: getWordAtCursor 194 lines → 42 lines (78% reduction)
- Fixed infinite React update loops with ref-based input tracking
- Smart triggering mechanism replacing aggressive auto-completion
- Integrated @agent and @file mention system with system reminders
- Added comprehensive agent loading and mention processing
- Enhanced Tab/Arrow/Enter key handling with clean event management
- Maintained 100% functional compatibility across all completion types

Key improvements:
• File path completion (relative, absolute, ~expansion, @references)
• Slash command completion (/help, /model, etc.)
• Agent completion (@agent-xxx with intelligent descriptions)
• System command completion (PATH scanning with fallback)
• Terminal-style Tab cycling, Enter confirmation, Escape cancellation
• Preview mode with boundary calculation
• History navigation compatibility
• Empty directory handling with user feedback

Architecture: Event-driven @mention detection → system reminder injection → LLM tool usage
Performance: Eliminated 7-layer nested conditionals, reduced state synchronization issues
Reliability: Fixed maximum update depth exceeded warnings, stable state management
2025-08-21 01:21:12 +08:00

23 KiB
Raw Blame History

╭───────────────────────────────────────────────────────────╮ │ Agents │ │ 4 agents │ │ │ │ Create new agent │ │ │ │ Personal agents (/Users/baicai/.claude/agents) │ │ general-purpose · sonnet │ │ claude-tester · sonnet │ │ │ │ Built-in agents (always available) │ │ general-purpose · sonnet ⚠ overridden by user │ │ statusline-setup · sonnet │ │ output-mode-setup · sonnet │ │ │ ╰───────────────────────────────────────────────────────────╯ Press ↑↓ to navigate · Enter to select · Esc to go back ╭───────────────────────────────────────────────────────────╮ │ Create new agent │ │ Step 1: Choose location │ │ │ │ 1. Project (.claude/agents/) │ │ 2. Personal (~/.claude/agents/) │ ╰───────────────────────────────────────────────────────────╯ Press ↑↓ to navigate · Enter to select · Esc to go back

╭───────────────────────────────────────────────────────────╮ │ Create new agent │ │ Step 2: Creation method │ │ │ │ 1. Generate with Claude (recommended) │ │ 2. Manual configuration │ ╰───────────────────────────────────────────────────────────╯ Press ↑↓ to navigate · Enter to select · Esc to go back

╭───────────────────────────────────────────────────────────╮ │ Create new agent │ │ Step 3: Describe what this agent should do and when it │ │ should be used (be comprehensive for best results) │ │ │ │ 帮我创建一个专门review代码的专家agent │ ╰───────────────────────────────────────────────────────────╯ Press Enter to submit, Esc to go back

╭───────────────────────────────────────────────────────────╮ │ Create new agent │ │ Step 3: Describe what this agent should do and when it │ │ should be used (be comprehensive for best results) │ │ │ │ 帮我创建一个专门review代码的专家agent │ │ │ │ · Generating agent configuration… │ ╰───────────────────────────────────────────────────────────╯ Press Enter to submit, Esc to go back

╭───────────────────────────────────────────────────────────╮ │ Create new agent │ │ Step 4: Select tools │ │ │ │ [ Continue ] │ │ ──────────────────────────────────────── │ │ ☒ All tools │ │ ☒ Read-only tools │ │ ☒ Edit tools │ │ ☒ Execution tools │ │ ──────────────────────────────────────── │ │ [ Show advanced options ] │ │ │ │ All tools selected │ ╰───────────────────────────────────────────────────────────╯ Press Enter to toggle selection, ↑↓ to navigate, Esc to go back ╭────────────────────────────────────────────────────────────────────────╮ │ Create new agent │ │ Step 4: Select tools │ │ │ │ [ Continue ] │ │ ──────────────────────────────────────── │ │ ☒ All tools │ │ ☒ Read-only tools │ │ ☒ Edit tools │ │ ☒ Execution tools │ │ ──────────────────────────────────────── │ │ [ Show advanced options ] │ │ │ │ All tools selected │ ╰────────────────────────────────────────────────────────────────────────╯ Press Enter to toggle selection, ↑↓ to navigate, Esc to go back

╭────────────────────────────────────────────────────────────────────────╮ │ Create new agent │ │ Step 4: Select tools │ │ │ │ [ Continue ] │ │ ──────────────────────────────────────── │ │ ☒ All tools │ │ ☒ Read-only tools │ │ ☒ Edit tools │ │ ☒ Execution tools │ │ ──────────────────────────────────────── │ │ [ Hide advanced options ] │ │ ☒ Bash │ │ ☒ Glob │ │ ☒ Grep │ │ ☒ LS │ │ ☒ Read │ │ ☒ Edit │ │ ☒ MultiEdit │ │ ☒ Write │ │ ☒ NotebookEdit │ │ ☒ WebFetch │ │ ☒ TodoWrite │ │ ☒ WebSearch │ │ ☒ BashOutput │ │ ☒ KillBash │ │ │ │ All tools selected │ ╰────────────────────────────────────────────────────────────────────────╯ Press Enter to toggle selection, ↑↓ to navigate, Esc to go back

╭────────────────────────────────────────────────────────────────────────╮ │ Create new agent │ │ Step 4: Select tools │ │ │ │ [ Continue ] │ │ ──────────────────────────────────────── │ │ ☐ All tools │ │ ☐ Read-only tools │ │ ☒ Edit tools │ │ ☒ Execution tools │ │ ──────────────────────────────────────── │ │ [ Show advanced options ] │ │ │ │ 5 of 14 tools selected │ ╰────────────────────────────────────────────────────────────────────────╯ Press Enter to toggle selection, ↑↓ to navigate, Esc to go back

╭────────────────────────────────────────────────────────────────────────╮ │ Create new agent │ │ Step 4: Select tools │ │ │ │ [ Continue ] │ │ ──────────────────────────────────────── │ │ ☐ All tools │ │ ☒ Read-only tools │ │ ☐ Edit tools │ │ ☒ Execution tools │ │ ──────────────────────────────────────── │ │ [ Show advanced options ] │ │ │ │ 10 of 14 tools selected │ ╰────────────────────────────────────────────────────────────────────────╯ Press Enter to toggle selection, ↑↓ to navigate, Esc to go back

╭────────────────────────────────────────────────────────────────────────╮ │ Create new agent │ │ Step 5: Select model │ │ Model determines the agent's reasoning capabilities and speed. │ │ │ │ 1. Sonnet Balanced performance - best for most agents✔ │ │ │ │ 2. Opus Most capable for complex reasoning tasks │ │ 3. Haiku Fast and efficient for simple tasks │ │ 4. Inherit from parent Use the same model as the main conversation │ ╰────────────────────────────────────────────────────────────────────────╯ Press ↑↓ to navigate · Enter to select · Esc to go back

╭────────────────────────────────────────────────────────────────────────╮ │ Create new agent │ │ Step 6: Choose background color │ │ │ │ Choose background color │ │ │ │ Automatic color │ │ Red │ │ Blue │ │ Green │ │ Yellow │ │ Purple │ │ Orange │ │ Pink │ │ Cyan │ │ │ │ │ │ Preview: code-reviewer │ ╰────────────────────────────────────────────────────────────────────────╯ Press ↑↓ to navigate · Enter to select · Esc to go back

╭────────────────────────────────────────────────────────────────────────╮ │ Create new agent │ │ Step 6: Choose background color │ │ │ │ Choose background color │ │ │ │ Automatic color │ │ Red │ │ Blue │ │ Green │ │ Yellow │ │ Purple │ │ Orange │ │ Pink │ │ Cyan │ │ │ │ │ │ Preview: code-reviewer │ ╰────────────────────────────────────────────────────────────────────────╯ Press ↑↓ to navigate · Enter to select · Esc to go back

╭────────────────────────────────────────────────────────────────────────╮ │ Create new agent │ │ Final step: Confirm and save │ │ │ │ Name: code-reviewer │ │ Location: .claude/agents/code-reviewer.md │ │ Tools: Bash, Glob, Grep, LS, Read, WebFetch, TodoWrite, WebSearch, │ │ BashOutput, KillBash │ │ Model: Opus │ │ │ │ Description (tells Claude when to use this agent): │ │ │ │ Use this agent when you need comprehensive code review and analysis. │ │ Examples: Context: The user has just written a new │ │ function and wants it reviewed before committing. user: 'I just │ │ wrote this authentication function, can you rev… │ │ │ │ System prompt: │ │ │ │ You are a Senior Code Review Expert with over 15 years of experience │ │ in software engineering across multiple programming languages and │ │ paradigms. You specialize in identifying code quality issues, │ │ security vulnerabilities, performance bottl… │ ╰────────────────────────────────────────────────────────────────────────╯ Press s/Enter to save, e to edit in your editor, Esc to cancel

完成后enter进入主菜单查看到刚刚创建好的agent ╭────────────────────────────────────────────────────────────────────────╮ │ Agents │ │ 5 agents │ │ │ │ Created agent: code-reviewer │ │ │ │ Create new agent │ │ │ │ Personal agents (/Users/baicai/.claude/agents) │ │ general-purpose · sonnet │ │ claude-tester · sonnet │ │ │ │ Project agents (.claude/agents) │ │ code-reviewer · opus │ │ │ │ Built-in agents (always available) │ │ general-purpose · sonnet ⚠ overridden by user │ │ statusline-setup · sonnet │ │ output-mode-setup · sonnet │ │ │ ╰────────────────────────────────────────────────────────────────────────╯ Press ↑↓ to navigate · Enter to select · Esc to go back