精品欧美一区二区三区在线观看 _久久久久国色av免费观看性色_国产精品久久在线观看_亚洲第一综合网站_91精品又粗又猛又爽_小泽玛利亚一区二区免费_91亚洲精品国偷拍自产在线观看 _久久精品视频在线播放_美女精品久久久_欧美日韩国产成人在线

使用Semantic Kernel實現(xiàn)Claude Code的Agents TODO能力

開發(fā) 前端
本文將深入探討如何使用Microsoft Semantic Kernel框架來實現(xiàn)類似Claude Code的TODO任務(wù)管理能力,讓開發(fā)者能夠在.NET生態(tài)系統(tǒng)中構(gòu)建屬于自己的智能編程助手。

引言

在現(xiàn)代軟件開發(fā)中,AI輔助編程工具正在成為開發(fā)者不可或缺的伙伴。Claude Code作為Anthropic推出的先進編程助手,其強大的TODO任務(wù)管理和智能代理(Agents)功能為開發(fā)者提供了卓越的項目管理和代碼開發(fā)體驗。本文將深入探討如何使用Microsoft Semantic Kernel框架來實現(xiàn)類似Claude Code的TODO任務(wù)管理能力,讓開發(fā)者能夠在.NET生態(tài)系統(tǒng)中構(gòu)建屬于自己的智能編程助手。

Claude Code的TODO功能深度解析

1. 核心架構(gòu)與設(shè)計理念

Claude Code采用了基于任務(wù)代理(Task Agents)的架構(gòu)設(shè)計,其TODO功能不僅僅是簡單的任務(wù)列表管理,更是一個智能的任務(wù)編排和執(zhí)行系統(tǒng):

任務(wù)代理工具(Task Agent Tools)

  • 并行處理能力:Claude Code通過Task工具能夠?qū)⑷蝿?wù)委派給子代理進行高效的并行處理
  • 智能任務(wù)分解:支持將復(fù)雜任務(wù)自動分解為多個可執(zhí)行的子任務(wù)
  • 狀態(tài)管理:提供pending、in_progress、completed三種狀態(tài)的精確跟蹤

7并行任務(wù)方法Claude Code實現(xiàn)了一套標準化的并行任務(wù)處理流程:

  • 組件創(chuàng)建 - 處理UI組件和業(yè)務(wù)邏輯組件的創(chuàng)建
  • 樣式處理 - 管理CSS/樣式相關(guān)的任務(wù)
  • 測試編寫 - 自動生成和執(zhí)行測試用例
  • 類型定義 - 處理TypeScript類型定義和接口
  • 工具函數(shù) - 創(chuàng)建輔助函數(shù)和鉤子
  • 系統(tǒng)集成 - 處理路由、導(dǎo)入導(dǎo)出等系統(tǒng)級集成
  • 配置管理 - 處理package.json、文檔等配置文件

2. 智能任務(wù)編排特性

自動任務(wù)識別

  • 復(fù)雜多步驟任務(wù)(3個或更多步驟)自動創(chuàng)建TODO
  • 非平凡任務(wù)需要仔細規(guī)劃時主動建議TODO管理
  • 用戶提供多個任務(wù)時智能拆分和組織

任務(wù)狀態(tài)流轉(zhuǎn)

  • 實時狀態(tài)更新和進度跟蹤
  • 智能錯誤處理和任務(wù)阻塞檢測
  • 任務(wù)完成后自動標記和后續(xù)任務(wù)發(fā)現(xiàn)

上下文感知

  • 基于項目結(jié)構(gòu)和技術(shù)棧的智能任務(wù)建議
  • 與開發(fā)工作流的深度集成(git、構(gòu)建、測試)
  • 支持團隊協(xié)作的任務(wù)共享機制

MarkAgents項目:Semantic Kernel實現(xiàn)方案

1. 項目架構(gòu)分析

MarkAgents項目采用了現(xiàn)代化的.NET 9.0架構(gòu),通過Semantic Kernel框架實現(xiàn)了對Claude Code TODO功能的本土化實現(xiàn):

技術(shù)棧選型

<TargetFramework>net9.0</TargetFramework>
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.60.0" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.OpenAI" Version="1.60.0" />
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="1.60.0" />

核心組件設(shè)計

  • AgentFunction.cs:13-569: 主要的智能代理函數(shù)實現(xiàn)
  • TodoInput.cs:1-39: TODO數(shù)據(jù)模型和狀態(tài)管理
  • Program.cs:1-60: 應(yīng)用程序入口和配置

2. TODO功能核心實現(xiàn)

數(shù)據(jù)模型設(shè)計(TodoInput.cs:1-39)

項目定義了完整的TODO數(shù)據(jù)結(jié)構(gòu):

public sealedclassTodoInputItem
{
    [JsonPropertyName("content")] public required string Content { get; set; }
    [JsonPropertyName("status")] public required TodoInputItemStatus Status { get; set; }
    [JsonPropertyName("priority")] public required Priority Priority { get; set; }
    [JsonPropertyName("id")] public required string Id { get; set; }
}

publicenum TodoInputItemStatus
{
    Pending, InProgress, Completed
}

publicenum Priority  
{
    Low, Medium, High
}

這種設(shè)計完全對標了Claude Code的TODO狀態(tài)模型,支持優(yōu)先級管理和狀態(tài)流轉(zhuǎn)。

智能TODO管理實現(xiàn)(AgentFunction.cs:239-569)

核心功能特性:

  • 智能任務(wù)檢測:通過詳細的描述文檔(AgentFunction.cs:242-417),系統(tǒng)能夠自動識別何時需要創(chuàng)建TODO列表
  • 可視化反饋:控制臺彩色顯示不同優(yōu)先級的任務(wù)(AgentFunction.cs:432-451)
  • 狀態(tài)同步:實時更新任務(wù)狀態(tài)并提供系統(tǒng)級反饋(AgentFunction.cs:519-546)

關(guān)鍵實現(xiàn)亮點:

[KernelFunction,
     Description(
         """
         Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
         It also helps the user understand the progress of the task and overall progress of their requests.

         ## When to Use This Tool
         Use this tool proactively in these scenarios:

         1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
         2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
         3. User explicitly requests todo list - When the user directly asks you to use the todo list
         4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
         5. After receiving new instructions - Immediately capture user requirements as todos
         6. When you start working on a task - Mark it as in_progress BEFORE beginning work. Ideally you should only have one todo as in_progress at a time
         7. After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation

         ## When NOT to Use This Tool

         Skip using this tool when:
         1. There is only a single, straightforward task
         2. The task is trivial and tracking it provides no organizational benefit
         3. The task can be completed in less than 3 trivial steps
         4. The task is purely conversational or informational

         NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.

         ## Examples of When to Use the Todo List

         <example>
         User: I want to add a dark mode toggle to the application settings. Make sure you run the tests and build when you're done!
         Assistant: I'll help add a dark mode toggle to your application settings. Let me create a todo list to track this implementation.
         *Creates todo list with the following items:*
         1. Create dark mode toggle component in Settings page
         2. Add dark mode state management (context/store)
         3. Implement CSS-in-JS styles for dark theme
         4. Update existing components to support theme switching
         5. Run tests and build process, addressing any failures or errors that occur
         *Begins working on the first task*

         <reasoning>
         The assistant used the todo list because:
         1. Adding dark mode is a multi-step feature requiring UI, state management, and styling changes
         2. The user explicitly requested tests and build be run afterward
         3. The assistant inferred that tests and build need to pass by adding \\\"Ensure tests and build succeed\\\" as the final task
         </reasoning>
         </example>

         <example>
         User: Help me rename the function getCwd to getCurrentWorkingDirectory across my project
         Assistant: Let me first search through your codebase to find all occurrences of 'getCwd'.
         *Uses grep or search tools to locate all instances of getCwd in the codebase*
         Assistant: I've found 15 instances of 'getCwd' across 8 different files. Let me create a todo list to track these changes.
         *Creates todo list with specific items for each file that needs updating*

         <reasoning>
         The assistant used the todo list because:
         1. First, the assistant searched to understand the scope of the task
         2. Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps
         3. The todo list helps ensure every instance is tracked and updated systematically
         4. This approach prevents missing any occurrences and maintains code consistency
         </reasoning>
         </example>


         <example>
         User: I need to implement these features for my e-commerce site: user registration, product catalog, shopping cart, and checkout flow.
         Assistant: I'll help implement these features. First, let's add all the features to the todo list.
         *Creates a todo list breaking down each feature into specific tasks based on the project architecture*
         Assistant: Let's start with user registration. This will involve creating database models, API endpoints, and frontend forms that integrate with your existing authentication system.

         <reasoning>
         The assistant used the todo list because:
         1. The user provided multiple complex features to implement in a comma separated list
         2. The todo list helps organize these large features into manageable tasks
         3. This approach allows for tracking progress across the entire implementation
         </reasoning>
         </example>

         <example>
         User: Can you help optimize my React application? It's rendering slowly and has performance issues.</user>
         Assistant: I'll help optimize your React application. First, let me examine your codebase to identify potential performance bottlenecks.
         *Reviews component structure, render patterns, state management, and data fetching*
         Assistant: After analyzing your codebase, I've identified several performance issues. Let me create a todo list to track our optimization efforts.
         *Creates todo list with items like: 1) Implement memoization for expensive calculations in ProductList, 2) Add virtualization for long lists in Dashboard, 3) Optimize image loading in Gallery component, 4) Fix state update loops in ShoppingCart, 5) Review bundle size and implement code splitting*
         Let's start by implementing memoization for the expensive calculations in your ProductList component.</assistant>

         <reasoning>
         The assistant used the todo list because:
         1. First, the assistant examined the codebase to identify specific performance issues
         2. Based on this analysis, it identified multiple optimization opportunities
         3. Performance optimization is a non-trivial task requiring multiple steps
         4. The todo list helps methodically track improvements across different components
         5. This systematic approach ensures all performance bottlenecks are addressed
         </reasoning>
         </example>

         ## Examples of When NOT to Use the Todo List

         <example>
         User: How do I print 'Hello World' in Python?
         Assistant: In Python, you can print \\\"Hello World\\\" with this simple code:

         python
         print(\\\"Hello World\\\")

         This will output the text \\\"Hello World\\\" to the console when executed.</assistant>

         <reasoning>
         The assistant did not use the todo list because this is a single, trivial task that can be completed in one step. There's no need to track multiple tasks or steps for such a straightforward request.
         </reasoning>
         </example>

         <example>
         User: What does the git status command do?
         Assistant: The git status command shows the current state of your working directory and staging area. It displays which changes have been staged, which haven't, and which files aren't being tracked by Git. This is a fundamental command for understanding the current state of your repository before making commits.

         <reasoning>
         The assistant did not use the todo list because this is an informational request with no actual coding task to complete. The user is simply asking for an explanation, not for the assistant to perform multiple steps or tasks.
         </reasoning>
         </example>

         <example>
         User: Can you add a comment to the calculateTotal function to explain what it does?
         Assistant: Sure, let me add a comment to the calculateTotal function to explain what it does.
         * Uses the Edit tool to add a comment to the calculateTotal function *

         <reasoning>
         The assistant did not use the todo list because this is a single, straightforward task confined to one location in the code. Adding a comment doesn't require tracking multiple steps or systematic organization.
         </reasoning>
         </example>

         <example>
         User: Run npm install for me and tell me what happens.
         Assistant: I'll run the npm install command for you.

         *Executes: npm install*

         The command completed successfully. Here's the output:
         [Output of npm install command]

         All dependencies have been installed according to your package.json file.

         <reasoning>
         The assistant did not use the todo list because this is a single command execution with immediate results. There are no multiple steps to track or organize, making the todo list unnecessary for this straightforward task.
         </reasoning>
         </example>

         ## Task States and Management

         1. **Task States**: Use these states to track progress:
            - pending: Task not yet started
            - in_progress: Currently working on (limit to ONE task at a time)
            - completed: Task finished successfully

         2. **Task Management**:
            - Update task status in real-time as you work
            - Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
            - Only have ONE task in_progress at any time
            - Complete current tasks before starting new ones
            - Remove tasks that are no longer relevant from the list entirely

         3. **Task Completion Requirements**:
            - ONLY mark a task as completed when you have FULLY accomplished it
            - If you encounter errors, blockers, or cannot finish, keep the task as in_progress
            - When blocked, create a new task describing what needs to be resolved
            - Never mark a task as completed if:
              - Tests are failing
              - Implementation is partial
              - You encountered unresolved errors
              - You couldn't find necessary files or dependencies

         4. **Task Breakdown**:
            - Create specific, actionable items
            - Break complex tasks into smaller, manageable steps
            - Use clear, descriptive task names

         When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.
         """)]
    public string TodoWrite(
        [Description("The updated todo list")] TodoInputItem[] todos)
    {
        if (_input == null)
        {
            // 初始化TODO列表
            _input = new List<TodoInputItem>(todos);
            // 設(shè)置控制臺編碼支持UTF-8
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            Console.WriteLine();
            Console.WriteLine("□ Initializing TODO list...");
            // 通過控制臺打印一下TODO
            foreach (var item in todos)
            {
                // 根據(jù)item等級渲染不同顏色
                if (item.Priority == Priority.High)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                elseif (item.Priority == Priority.Medium)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }

                Console.Write("□ ");
                Console.Write(item.Content);
                Console.WriteLine();

                Console.ResetColor();
            }

            return GenerateInitialTodoMessage(todos);
        }
        else
        {
            // 添加新的TODO項
            var newItems = todos.Where(x => _input.All(existing => existing.Id != x.Id)).ToList();
            _input.AddRange(newItems);

            // 更新現(xiàn)有TODO項的狀態(tài)
            foreach (var item in _input)
            {
                var updatedItem = todos.FirstOrDefault(x => x.Id == item.Id);
                if (updatedItem == null) continue;
                item.Status = updatedItem.Status;
                item.Content = updatedItem.Content;
                item.Priority = updatedItem.Priority;
            }

            Console.WriteLine("□ Updating TODO list...");
            foreach (var item in _input)
            {
                // 根據(jù)item等級渲染不同顏色
                if (item.Priority == Priority.High)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                elseif (item.Priority == Priority.Medium)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }

                if (item.Status == TodoInputItemStatus.Pending)
                {
                    Console.Write("□ ");
                }
                elseif (item.Status == TodoInputItemStatus.InProgress)
                {
                    Console.Write("■ ");
                }
                elseif (item.Status == TodoInputItemStatus.Completed)
                {
                    Console.Write("? ");
                }

                Console.Write(item.Content);
                Console.WriteLine();
                Console.ResetColor();
            }

            return GenerateUpdateTodoMessage(_input.ToArray());
        }
    }

    private string GenerateInitialTodoMessage(TodoInputItem[] input)
    {
        var sb = new StringBuilder();
        sb.AppendLine(
            "Todos have been modified successfully. Ensure that you continue to use the todo list to track your progress. Please proceed with the current tasks if applicable");
        sb.AppendLine();

        // 返回當前TODO列表的JSON字符串
        var currentTodoJson = SerializeTodoList(input);
        sb.AppendLine("<system-reminder>");
        sb.AppendLine(
            "Your todo list has changed. DO NOT mention this explicitly to the user. Here are the latest contents of your todo list:");
        sb.AppendLine();
        sb.AppendLine(currentTodoJson);
        sb.AppendLine(". Continue on with the tasks at hand if applicable.");
        sb.AppendLine("</system-reminder>");

        return sb.ToString();
    }

    private string GenerateUpdateTodoMessage(TodoInputItem[] todoList)
    {
        var sb = new StringBuilder();
        sb.AppendLine(
            "Todos have been modified successfully. Ensure that you continue to use the todo list to track your progress. Please proceed with the current tasks if applicable");
        sb.AppendLine();

        // 返回當前TODO列表的JSON字符串
        var currentTodoJson = SerializeTodoList(todoList);
        sb.AppendLine("<system-reminder>");
        sb.AppendLine(
            "Your todo list has changed. DO NOT mention this explicitly to the user. Here are the latest contents of your todo list:");
        sb.AppendLine();
        sb.AppendLine(currentTodoJson);
        sb.AppendLine(". Continue on with the tasks at hand if applicable.");
        sb.AppendLine("</system-reminder>");

        return sb.ToString();
    }

    private string SerializeTodoList(TodoInputItem[] todoList)
    {
        var todoItems = todoList.Select(item => new
        {
            content = item.Content,
            status = item.Status.ToString().ToLowerInvariant(),
            priority = item.Priority.ToString().ToLowerInvariant(),
            id = item.Id
        }).ToList();

        var options = new JsonSerializerOptions
        {
            WriteIndented = false,
            Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
            PropertyNamingPolicy = JsonNamingPolicy.CamelCase
        };

        return JsonSerializer.Serialize(todoItems, options);
    }

技術(shù)實現(xiàn)深度剖析

1. Semantic Kernel架構(gòu)優(yōu)勢

插件系統(tǒng)設(shè)計

var kernelBuilder = Kernel.CreateBuilder();
kernelBuilder.Plugins.AddFromType<AgentFunction>();
kernelBuilder.AddOpenAIChatCompletion("kimi-k2-0711-preview", 
    new Uri("https://api.token-ai.cn/v1"), "sk-xxx");

Semantic Kernel的插件架構(gòu)允許開發(fā)者:

  • 模塊化功能開發(fā)
  • 熱插拔功能組件
  • 統(tǒng)一的函數(shù)調(diào)用接口
  • 多模型支持(OpenAI、Azure OpenAI、本地模型)

系統(tǒng)提示詞工程(Program.cs:22-39)

history.AddSystemMessage("You are an AI assistant specialized in C# and .NET development. You assist with Semantic Kernel applications, code analysis, debugging, and feature development.");
history.AddSystemMessage(@"You excel at: **Code Analysis** - Understanding C#/.NET project structure, dependencies, NuGet packages; **Bug Fixing** - Identifying and resolving C# compilation errors, runtime issues; **Feature Development** - Implementing functionality using Microsoft.SemanticKernel framework; **Code Review** - Analyzing C# code quality, best practices, security.

EXECUTION WORKFLOW - STRICTLY FOLLOW THIS ORDER:
1. FIRST: Create TODO list using TodoWrite tool for EVERY user query (MANDATORY)
2. SECOND: Mark first TODO as in_progress and begin work
3. THIRD: Execute the specific task described in the TODO with concrete actions
4. FOURTH: Mark TODO as completed ONLY after providing actual results/findings
5. REPEAT: Move to next TODO item until all are completed

CRITICAL RULES:
- NEVER skip TodoWrite - use it immediately for ANY user request
- NEVER mark TODO as completed without performing actual work and providing concrete results
- ALWAYS work on TODOs sequentially, one at a time
- Each TODO must result in specific findings, analysis, code, or answers - not just status updates
- Break complex requests into detailed, actionable TODO items

Example for 'Search C# info': 1. Search web for C# SemanticKernel documentation and tutorials, 2. Analyze and categorize found resources by topic areas, 3. Extract key concepts and code examples, 4. Compile comprehensive tutorial with practical examples, 5. Provide structured learning path and resource links.");

這種強制性工作流程確保了任務(wù)管理的一致性和完整性。

2. 智能網(wǎng)絡(luò)搜索集成(AgentFunction.cs:27-237)

項目還實現(xiàn)了類似Claude Code的網(wǎng)絡(luò)搜索能力:

多搜索引擎支持

[KernelFunction,
     Description(
         """
         - Allows Claude to search the web and use the results to inform responses
         - Provides up-to-date information for current events and recent data
         - Returns search result information formatted as search result blocks
         - Use this tool for accessing information beyond Claude's knowledge cutoff
         - Searches are performed automatically within a single API call

         Usage notes:
           - Domain filtering is supported to include or block specific websites
           - Web search is only available in the US
           - Account for \\\"Today's date\\\" in <env>. For example, if <env> says \\\"Today's date: 2025-07-01\\\", and the user wants the latest docs, do not use 2024 in the search query. Use 2025.
         """)]
    public async Task<string> WebSearch(
        [Description("The search query to use")]
        string query,
        [Description("Only include search results from these domains")]
        string[]? allowed_domains,
        [Description("Never include search results from these domains")]
        string[]? blocked_domains)
    {
        usingvar client = new HttpClient();
        client.DefaultRequestHeaders.Add("User-Agent", "MarkAgents/1.0 (Compatible Search Engine)");
        client.Timeout = TimeSpan.FromSeconds(30);
        
        var searchEngines = new[]
        {
            "https://search.brave.com/api/search?q={0}&format=json&safesearch=moderate&count=10",
            "https://searx.be/search?q={0}&format=json&categories=general&safesearch=1",
            "https://paulgo.io/search?q={0}&format=json",
            "https://api.duckduckgo.com/?q={0}&format=json&no_html=1&skip_disambig=1"
        };
        
        var results = new StringBuilder();
        results.AppendLine($"# Search Results for: {query}");
        results.AppendLine();
        
        foreach (var engineUrl in searchEngines)
        {
            try
            {
                var searchUrl = string.Format(engineUrl, Uri.EscapeDataString(query));
                var response = await client.GetStringAsync(searchUrl);
                var searchData = JsonSerializer.Deserialize<JsonElement>(response);
                
                var engineResults = await ExtractSearchResults(searchData, allowed_domains, blocked_domains, client);
                if (!string.IsNullOrEmpty(engineResults))
                {
                    results.AppendLine(engineResults);
                    break;
                }
            }
            catch
            {
                continue;
            }
        }
        
        if (results.Length <= 50)
        {
            results.AppendLine("## Alternative Search Results");
            results.AppendLine();
            var fallbackResult = await FallbackWebSearch(query, allowed_domains, blocked_domains, client);
            results.AppendLine(fallbackResult);
        }
        
        return results.ToString();
    }
    
    private async Task<string> ExtractSearchResults(JsonElement searchData, string[]? allowedDomains, string[]? blockedDomains, HttpClient client)
    {
        var results = new StringBuilder();
        var count = 0;
        
        if (searchData.TryGetProperty("results", outvar resultsArray))
        {
            foreach (var result in resultsArray.EnumerateArray())
            {
                if (count >= 8) break;
                
                if (result.TryGetProperty("url", outvar urlProp) && 
                    result.TryGetProperty("title", outvar titleProp))
                {
                    var url = urlProp.GetString() ?? "";
                    var title = titleProp.GetString() ?? "";
                    var snippet = "";
                    
                    if (result.TryGetProperty("content", outvar contentProp))
                        snippet = contentProp.GetString() ?? "";
                    elseif (result.TryGetProperty("description", outvar descProp))
                        snippet = descProp.GetString() ?? "";
                    
                    if (!IsValidUrl(url, allowedDomains, blockedDomains)) continue;
                    
                    var detailedContent = await FetchPageContent(url, client);
                    
                    results.AppendLine($"## Result {count + 1}: {title}");
                    results.AppendLine($"**URL:** {url}");
                    results.AppendLine($"**Summary:** {snippet}");
                    if (!string.IsNullOrEmpty(detailedContent))
                    {
                        results.AppendLine($"**Content Preview:**");
                        results.AppendLine(detailedContent.Substring(0, Math.Min(500, detailedContent.Length)) + "...");
                    }
                    results.AppendLine();
                    count++;
                }
            }
        }
        elseif (searchData.TryGetProperty("RelatedTopics", outvar topics))
        {
            foreach (var topic in topics.EnumerateArray())
            {
                if (count >= 8) break;
                
                if (topic.TryGetProperty("Text", outvar text) && 
                    topic.TryGetProperty("FirstURL", outvar url))
                {
                    var urlStr = url.GetString() ?? "";
                    var textStr = text.GetString() ?? "";
                    
                    if (!IsValidUrl(urlStr, allowedDomains, blockedDomains)) continue;
                    
                    var detailedContent = await FetchPageContent(urlStr, client);
                    
                    results.AppendLine($"## Result {count + 1}");
                    results.AppendLine($"**URL:** {urlStr}");
                    results.AppendLine($"**Summary:** {textStr}");
                    if (!string.IsNullOrEmpty(detailedContent))
                    {
                        results.AppendLine($"**Content Preview:**");
                        results.AppendLine(detailedContent.Substring(0, Math.Min(500, detailedContent.Length)) + "...");
                    }
                    results.AppendLine();
                    count++;
                }
            }
        }
        
        return results.ToString();
    }
    
    private async Task<string> FetchPageContent(string url, HttpClient client)
    {
        try
        {
            var response = await client.GetStringAsync(url);
            var cleanContent = System.Text.RegularExpressions.Regex.Replace(response, @"<[^>]+>", " ");
            cleanContent = System.Text.RegularExpressions.Regex.Replace(cleanContent, @"\s+", " ");
            return cleanContent.Trim();
        }
        catch
        {
            returnstring.Empty;
        }
    }
    
    private bool IsValidUrl(string url, string[]? allowedDomains, string[]? blockedDomains)
    {
        try
        {
            var uri = new Uri(url);
            
            if (allowedDomains != null && allowedDomains.Length > 0)
            {
                if (!allowedDomains.Any(domain => uri.Host.Contains(domain, StringComparison.OrdinalIgnoreCase)))
                    returnfalse;
            }
            
            if (blockedDomains != null && blockedDomains.Length > 0)
            {
                if (blockedDomains.Any(domain => uri.Host.Contains(domain, StringComparison.OrdinalIgnoreCase)))
                    returnfalse;
            }
            
            returntrue;
        }
        catch
        {
            returnfalse;
        }
    }
    
    private async Task<string> FallbackWebSearch(string query, string[]? allowedDomains, string[]? blockedDomains, HttpClient client)
    {
        var results = new StringBuilder();
        var searchTerms = query.Split(' ', StringSplitOptions.RemoveEmptyEntries);
        
        var commonSources = new[]
        {
            $"https://github.com/search?q={Uri.EscapeDataString(query)}&type=repositories",
            $"https://stackoverflow.com/search?q={Uri.EscapeDataString(query)}",
            $"https://docs.microsoft.com/en-us/search/?terms={Uri.EscapeDataString(query)}",
        };
        
        foreach (var source in commonSources)
        {
            try
            {
                if (!IsValidUrl(source, allowedDomains, blockedDomains)) continue;
                
                var content = await FetchPageContent(source, client);
                if (!string.IsNullOrEmpty(content))
                {
                    results.AppendLine($"**Source:** {source}");
                    results.AppendLine($"**Content:** {content.Substring(0, Math.Min(300, content.Length))}...");
                    results.AppendLine();
                }
            }
            catch
            {
                continue;
            }
        }
        
        if (results.Length == 0)
        {
            results.AppendLine($"Search completed for query: {query}");
            results.AppendLine("No detailed results found from available search engines.");
            results.AppendLine($"Suggested search terms: {string.Join(", ", searchTerms)}");
        }
        
        return results.ToString();
    }

智能內(nèi)容提取

  • HTML標簽清理和內(nèi)容標準化
  • 域名過濾(白名單/黑名單)
  • 結(jié)果去重和質(zhì)量評估
  • 分塊內(nèi)容預(yù)覽

3. 控制臺用戶體驗優(yōu)化

彩色輸出系統(tǒng)

if (item.Priority == Priority.High)
    Console.ForegroundColor = ConsoleColor.Red;
elseif (item.Priority == Priority.Medium) 
    Console.ForegroundColor = ConsoleColor.Yellow;
else
    Console.ForegroundColor = ConsoleColor.Green;

if (item.Status == TodoInputItemStatus.Pending)
    Console.Write("□ ");
elseif (item.Status == TodoInputItemStatus.InProgress)
    Console.Write("■ ");  
elseif (item.Status == TodoInputItemStatus.Completed)
    Console.Write("? ");

這種設(shè)計提供了直觀的視覺反饋,讓開發(fā)者能夠快速了解任務(wù)狀態(tài)。

實際應(yīng)用場景與最佳實踐

1. 復(fù)雜項目開發(fā)場景

微服務(wù)架構(gòu)開發(fā)

高優(yōu)先級任務(wù):
■ 設(shè)計API網(wǎng)關(guān)路由配置
□ 實現(xiàn)用戶認證服務(wù)
□ 創(chuàng)建訂單處理微服務(wù)

中優(yōu)先級任務(wù):  
□ 編寫單元測試用例
□ 配置Docker容器化
□ 設(shè)置CI/CD流水線

低優(yōu)先級任務(wù):
□ 編寫API文檔
□ 性能測試和優(yōu)化

結(jié)論

通過深入分析Claude Code的TODO功能并使用Semantic Kernel進行本土化實現(xiàn),MarkAgents項目成功地展示了如何在.NET生態(tài)系統(tǒng)中構(gòu)建智能的任務(wù)管理和代理系統(tǒng)。項目不僅實現(xiàn)了Claude Code的核心功能特性,還結(jié)合.NET平臺的優(yōu)勢提供了額外的擴展性和定制化能力。

這種實現(xiàn)方案為開發(fā)者提供了:

  • 完整的功能對等:涵蓋Claude Code的主要TODO管理特性
  • 技術(shù)棧一致性:與現(xiàn)有.NET項目無縫集成
  • 可擴展架構(gòu):支持未來功能的持續(xù)演進
  • 開源友好:便于社區(qū)貢獻和定制開發(fā)
責任編輯:武曉燕 來源: tokengo的技術(shù)分享
相關(guān)推薦

2025-08-07 08:35:06

2025-09-05 09:06:10

2023-05-08 14:56:33

大型語言模型代碼

2025-11-20 02:25:00

Vs CodeClaudeCursor

2025-11-18 10:20:12

2025-09-18 16:18:23

2025-10-21 09:05:00

2025-06-18 13:07:01

2025-10-30 16:23:47

Cursor 2.0人工智能智能體

2025-02-06 10:45:43

2016-10-18 21:26:29

Semantic-UIReact架構(gòu)

2025-10-10 01:00:00

2010-09-25 12:51:45

DHCP Relay

2016-10-18 21:39:59

Semantic-UIReact基本元素組件

2025-10-16 02:33:00

Claudecommit腳本

2025-02-25 09:43:19

2025-09-23 09:09:49

2025-07-10 09:09:36

2025-08-15 09:23:41

點贊
收藏

51CTO技術(shù)棧公眾號

亚洲伊人伊色伊影伊综合网| 亚洲一区二区三区免费在线观看 | 久久综合九色综合97婷婷| 91高清视频免费观看| 久久久久99精品成人| 日韩欧美高清一区二区三区| 婷婷开心久久网| 一区二区三区|亚洲午夜| 国产 欧美 自拍| 久久亚洲图片| 久久久天堂国产精品女人| 国产jjizz一区二区三区视频| 国产高清亚洲| 色综合久久综合| 91网站在线观看免费| 国产视频精品久久| 粉嫩13p一区二区三区| 国产精品国产三级国产aⅴ浪潮 | 欧美日韩欧美一区二区| 亚洲一区二区三区av无码| 91精品大全| 久久综合色婷婷| 国产99视频精品免费视频36| 又骚又黄的视频| 中文在线一区| 欧美疯狂xxxx大交乱88av| 在线观看免费小视频| 国产伦乱精品| 欧美一区二区三区视频在线 | 国产麻豆精品在线观看| 日韩免费av一区二区| 精品国产乱码久久久久久鸭王1| 伊人久久大香线蕉无限次| 精品少妇一区二区三区免费观看| 伊人国产在线视频| 97久久香蕉国产线看观看| 一二三四区精品视频| 日韩 欧美 自拍| 日本电影全部在线观看网站视频 | 精品不卡在线视频| 午夜影院免费观看视频| 免费视频成人| 欧美三级电影一区| 久草综合在线观看| 肉色欧美久久久久久久免费看| 亚洲电影一级黄| 欧美高清中文字幕| 日韩三级电影视频| 一区二区三区产品免费精品久久75 | 亚洲熟女乱色一区二区三区久久久| 亚欧成人精品| 欧美一级视频在线观看| 国产精品500部| 亚洲激情亚洲| 韩国三级日本三级少妇99| 国产在线视频卡一卡二| 欧美日本一区二区高清播放视频| 欧美床上激情在线观看| 欧美成人精品欧美一级私黄| 欧美91大片| 久久久久久亚洲精品不卡| 国产无遮挡又黄又爽| 在线成人欧美| 欧美尤物巨大精品爽| 亚洲精品男人的天堂| 亚洲欧美高清| 国产精品美女www| 国产一区二区三区三州| 国产一区二区视频在线播放| 亚洲最大成人免费视频| 亚洲va天堂va欧美ⅴa在线| 丁香另类激情小说| 精品亚洲一区二区三区四区五区高| 午夜视频免费看| 国产欧美一区二区精品忘忧草| 日本一区二区三区视频免费看| 国产美女性感在线观看懂色av| 日本一区二区免费在线| 中文精品一区二区三区| 手机在线免费av| 欧美性生活大片免费观看网址| 天天操天天爽天天射| 国产精品亚洲欧美一级在线| 精品99一区二区| 成人国产精品久久久网站| 色婷婷亚洲mv天堂mv在影片| 久久69精品久久久久久久电影好 | 日韩成人伦理| 日韩欧美高清在线视频| 三上悠亚在线一区| 日本一区二区三区电影免费观看| 亚洲国产成人精品一区二区 | 国产精品久久久久不卡| 国产欧美日韩成人| 91碰在线视频| 色中文字幕在线观看| bl在线肉h视频大尺度| 91久久香蕉国产日韩欧美9色| 国产又黄又猛的视频| 免费精品一区二区| 91精品亚洲一区在线观看| 日韩欧美国产系列| 丰满圆润老女人hd| 欧美 日韩 国产 一区| 欧美性受xxxx白人性爽| 精品国产av一区二区三区| 久久综合九色综合欧美就去吻| 蜜桃视频成人在线观看| sis001欧美| 欧美成人免费网站| 摸摸摸bbb毛毛毛片| 亚洲网站视频| 成人激情综合网| 日中文字幕在线| 亚洲精品视频一区二区| 亚欧在线免费观看| 狠狠一区二区三区| 久久不射电影网| 羞羞色院91蜜桃| 91在线小视频| 福利在线一区二区| 欧美久久久网站| 亚洲欧美国产va在线影院| 久久精品国产亚洲av无码娇色| 久久精品72免费观看| 欧美精品欧美精品| 2001个疯子在线观看| 欧美一区二区三区成人| 国产99在线 | 亚洲| 欧美aaaaaaaa| 麻豆中文一区二区| 久久亚洲国产精品日日av夜夜| 亚洲妇熟xxxx妇色黄| 欧美日韩精品系列| 日韩人妻无码精品综合区| 99国产精品视频免费观看一公开 | 国产精品美女久久久久久久 | 欧美精品久久久久性色| 久久成人综合网| 亚洲精品永久www嫩草| 婷婷六月国产精品久久不卡| 亚洲国产古装精品网站| 久久国产在线视频| 国产成人综合视频| 日本aa在线观看| 99久久香蕉| 九九热这里只有在线精品视| www.com在线观看| 亚洲黄网站在线观看| 美女被艹视频网站| 欧美日韩精品一本二本三本| 91超碰rencao97精品| 中国av在线播放| 欧美v亚洲v综合ⅴ国产v| 国产亚洲欧美久久久久| 国产91丝袜在线18| 久青草视频在线播放| 精品少妇3p| 欧美野外猛男的大粗鳮| 国产三区四区在线观看| 欧美综合在线视频| 国产无遮挡在线观看| 美腿丝袜在线亚洲一区| 天堂av免费看| 一本色道69色精品综合久久| 午夜精品一区二区三区在线视| 少妇人妻一区二区| 欧美性生交xxxxx久久久| 欧洲av一区二区三区| 美女任你摸久久| 欧美精品一区二区性色a+v| 日韩一二三区在线观看| 97视频在线观看免费| 欧美精品少妇| 欧美浪妇xxxx高跟鞋交| 国产性生活网站| 久久在线免费观看| 亚洲美女性囗交| 国产精品激情电影| 农村寡妇一区二区三区| 少妇高潮一区二区三区99| 欧美精品日韩www.p站| 三级视频在线看| 欧洲色大大久久| 一区二区在线观看免费视频| 91免费观看国产| 99re6在线观看| 精品999日本| 午夜精品区一区二区三| 136福利精品导航| 国产999在线观看| 99自拍视频在线观看| 亚洲男女自偷自拍图片另类| 国产美女免费看| 黑人精品xxx一区一二区| 影音先锋男人看片资源| 成人免费看视频| 欧美美女性视频| 国产精品三上| 青青草综合视频| 精品国产网站| 国产亚洲欧美一区二区| 色999韩欧美国产综合俺来也| 68精品久久久久久欧美| 久久久久久国产精品免费无遮挡| 亚洲国产第一页| 国产www视频| 欧美三日本三级三级在线播放| 免费在线观看av网址| 欧美韩国一区二区| 朝桐光av一区二区三区| 狠狠色综合播放一区二区| 97av视频在线观看| 国产精品v亚洲精品v日韩精品| 亚洲国产一区二区在线| 日韩精品免费一区二区夜夜嗨| 91免费在线视频| 香蕉成人影院| 欧美尤物巨大精品爽| 国精产品一区一区三区mba下载| 在线播放日韩av| 精品亚洲综合| 日韩国产高清污视频在线观看| 国产ts人妖调教重口男| 制服丝袜中文字幕亚洲| 中文字幕在线视频免费| 色国产综合视频| 偷偷操不一样的久久| 亚洲一区自拍偷拍| 日韩在线观看视频一区二区| 国产精品蜜臀av| a级黄色免费视频| 久久精品视频网| 成年人免费观看视频网站| 91丨porny丨国产| 天天插天天射天天干| 成人免费视频免费观看| 久久久久久久穴| 成人在线视频一区| 欧美做受高潮中文字幕| 丁香激情综合五月| xfplay5566色资源网站| 成人丝袜高跟foot| 亚洲高清无码久久| 成人sese在线| 国产精品手机在线观看| 不卡的看片网站| 国产一级二级在线观看| 91啪亚洲精品| 妺妺窝人体色WWW精品| 国产欧美日韩在线看| 丁香激情五月少妇| 中文字幕 久热精品 视频在线 | 国产精品99蜜臀久久不卡二区 | 在线精品国精品国产尤物884a| 中文字幕在线播| 91福利国产成人精品照片| 亚洲图片欧美日韩| 欧美日韩另类一区| 99国产成人精品| 欧美tickling网站挠脚心| 免费a级片在线观看| 日韩成人高清在线| 国产免费永久在线观看| 久久精品国产一区| 中文字幕有码在线视频| 97精品在线观看| 日韩美女在线看免费观看| 国产精品久久久久免费a∨大胸| 色8久久久久| 国产精品视频福利| 国产成人精品999在线观看| 一区二区三区四区欧美| 欧美精品首页| 成人观看免费完整观看| 热久久国产精品| 手机在线观看日韩av| 波波电影院一区二区三区| 3d动漫精品啪啪一区二区下载| 欧美国产视频在线| 欧美黑吊大战白妞| 日韩人在线观看| 国产乱人乱偷精品视频| 亚洲国产精品人久久电影| 国产香蕉视频在线看| 久久九九国产精品怡红院 | 亚洲在线免费视频| 日韩精品福利一区二区三区| 亚洲午夜精品国产| 99精品免费视频| 老司机久久精品| 91麻豆国产在线观看| 熟女少妇a性色生活片毛片| 亚洲 欧美综合在线网络| 国产情侣免费视频| 亚洲成人精品久久| 尤物视频在线免费观看| 久久免费精品日本久久中文字幕| 99久久亚洲国产日韩美女| 成人三级视频在线观看一区二区| 经典一区二区| av在线com| 久久99国产乱子伦精品免费| 国产中文字幕一区二区| 亚洲欧美国产三级| 午夜精品久久久久久久蜜桃| 欧美成人video| av在线资源站| 8x拔播拔播x8国产精品| 欧美久久一区二区三区| 四虎永久在线精品免费一区二区| 好看不卡的中文字幕| 天堂中文av在线| 国产性天天综合网| 91精品国产乱码久久久张津瑜| 欧美二区三区91| 精品成人一区二区三区免费视频| 欧美精品第一页在线播放| 最新亚洲国产| 五月婷婷一区| 日韩高清在线电影| 亚洲一区二区三区无码久久| 亚洲综合在线第一页| 国产精品热久久| 中文字幕在线看视频国产欧美| 2022成人影院| 久久精品国产99精品国产亚洲性色| 欧美精品偷拍| 国产无套精品一区二区三区| 一区视频在线播放| 亚洲一卡二卡在线观看| 一区二区成人精品| 日本韩国欧美| 欧美精品中文字幕一区二区| 国产乱码精品| 特大黑人巨人吊xxxx| 黑人欧美xxxx| 三级国产在线观看| 日本午夜精品理论片a级appf发布| 加勒比久久高清| 六月婷婷在线视频| av电影在线观看完整版一区二区| 精品一级少妇久久久久久久| 日韩欧美国产综合在线一区二区三区| 精品麻豆一区二区三区| 国产一区视频在线播放| 日韩久久电影| 五月六月丁香婷婷| 亚洲人成人一区二区在线观看| 6—12呦国产精品| 久久香蕉频线观| 日本免费精品| 国产精品久久中文字幕| 91麻豆蜜桃一区二区三区| 香蕉影院在线观看| 揄拍成人国产精品视频| 亚洲日本免费电影| www.国产亚洲| av电影一区二区| 精品久久久久久久久久久久久久久久久久 | 精品产国自在拍| 亚洲欧美国产中文| 亚洲精品五月天| 色噜噜一区二区三区| 热久久这里只有精品| 俺要去色综合狠狠| 日日干日日操日日射| 亚洲精品自拍动漫在线| 成人爽a毛片一区二区| 2019中文字幕全在线观看| 久久不见久久见免费视频7| 日韩av片网站| 依依成人综合视频| 日韩av免费观影| 国产美女精彩久久| 女人色偷偷aa久久天堂| 成人免费无码大片a毛片| 欧日韩精品视频| 日本高清成人vr专区| 精品国产一区二区三区久久久久久| 久久婷婷亚洲| 曰本女人与公拘交酡| 日韩大陆毛片av| 国产原创一区| 欧美在线一区视频| 国产精品丝袜久久久久久app| a级片在线视频| 国产成人jvid在线播放| 一区二区三区四区电影| 久久久久久久久免费看无码 | 日韩av成人在线观看| 天天影视欧美综合在线观看| 白嫩情侣偷拍呻吟刺激| 欧美中文字幕一区| 国产蜜臀在线| 亚洲视频小说| 2023国产精品自拍| www.国产视频| 国产精品视频内| 国产精品成人一区二区网站软件|