Auggie Agentic Coding CLI

repository·main·Indexed 42 days ago

https://github.com/augmentcode/auggie

An agentic coding CLI for the terminal that assists developers with codebase analysis, safe edits, and routine task automation using natural language processing. It features Augment Commands for common development tasks, a Python SDK for Direct Context API-based indexing, and a GitHub Action Repository Indexer for automated semantic search and AI-powered Q&A.

Tokens
20.9K
Snippets
74
Records
101
Agent score
54%

What's inside Auggie

  1. Explore Context SDK capabilities

    main

    The Context SDK provides several modes for semantic search and codebase analysis:

    • Direct Context: API-based indexing for semantic search and AI Q&A.
    • FileSystem Context: Local directory search via the MCP protocol.
    • File Search Server: A REST API for semantic file search with AI summarization.
    • Prompt Enhancer Server: An HTTP server that enriches prompts with codebase context.
    • GitHub Action Indexer: Indexes GitHub repositories for semantic search.
  2. Core FileSystem Context features

    main

    The FileSystem Context implementation provides several key capabilities for interacting with local workspaces:

    • search(): Performs semantic search over local files.
    • search_and_ask(): A single-step method for AI-powered Q&A about your workspace.
    • MCP Protocol: Uses the Model Context Protocol to provide standardized access to context.
    • Auto-indexing: Files are indexed on-the-fly, allowing for searches without a manual explicit indexing step.
    • AI Code Review: Performs automated code reviews and explains code patterns using AI.
  3. Explore Augment Python SDK features via examples

    main

    The user_examples directory provides executable scripts demonstrating the core capabilities of the Augment Python SDK. Use these examples to learn about:

    • Basic Agent Usage: Getting started with the agent (01_quick_start.py).
    • Event Listeners: Using built-in logging listeners (02_event_listener_builtin.py) or creating custom event listeners (03_event_listener_custom.py).
    • Session Management: Managing conversational context using sessions (04_session_management.py).
    • Type Handling: Automatic type inference (05_type_inference.py) and explicit type specification using dataclasses (06_typed_returns.py).
    • Verification: Using success criteria to verify agent outputs (07_success_criteria.py).
    • Tool Use: Providing the agent with access to custom functions via function tools (08_function_tools.py).
  4. FileSystem Context key features and API capabilities

    main

    The FileSystem Context implementation provides several core capabilities for interacting with local codebases:

    • search(): Performs semantic search over local files.
    • searchAndAsk(): A single-step operation for AI-powered Q&A regarding the workspace.
    • MCP Protocol: Uses the Model Context Protocol to provide standardized access to context.
    • Auto-indexing: Files are indexed on-the-fly, allowing for search without an explicit manual indexing step.
  5. How the Repository Indexer works

    main

    The indexer provides efficient, incremental updates to your repository's semantic index. It follows this lifecycle:

    1. State Loading: It attempts to load the previous index state from storage (e.g., GitHub Actions cache).
    2. Re-index Decision: It determines if a full re-index is required. A full re-index occurs if:
      • There is no previous state (first run).
      • A force push is detected.
      • There are too many commits or file changes.
      • Files that were previously ignored have changed.
    3. Indexing Execution:
      • Full Re-index: Downloads a tarball and indexes all files.
      • Incremental Update: Uses the GitHub Compare API to identify and index only the changed files.
    4. State Persistence: Saves the new state to storage (defaulting to .augment-index-state/{branch}/state.json).
  6. Important considerations for AgentEventListener

    main

    When implementing a custom listener, keep the following constraints in mind:

    • Thread Safety: If your listener updates a UI, ensure the methods are thread-safe.
    • Performance: Listener methods are called synchronously. If a method takes too long to execute, it will block the agent's execution.
    • Tool Call Pairing: Every on_tool_call event will have one or more corresponding on_tool_response events sharing the same tool_call_id.
    • Chunking: on_agent_message_chunk is for real-time streaming (e.g., typewriter effects), while on_agent_message is for the final, complete payload.
  7. Understand the Augment SDK components

    main

    The Augment Python SDK is divided into two primary functional areas:

    1. Auggie SDK: An agent-based interface designed for AI-powered workflows. It supports typed responses, session management (for conversation continuity), and function calling.
    2. Context SDK: Focused on semantic search and AI-powered code analysis. It provides tools like FileSystemContext and DirectContext to interact with codebases.
  8. Core features of Direct Context

    main

    The Direct Context implementation provides several key capabilities for interacting with indexed codebases:

    • search(): Performs semantic searches that return formatted code snippets.
    • searchAndAsk(): A high-level method for one-step AI-powered Q&A based on the indexed code.
    • State persistence: Supports exporting and importing the index state so that the indexed context can be reused without re-indexing.
  9. Manage conversation continuity with Sessions

    main

    By default, agent calls are independent. To maintain conversation continuity where subsequent calls remember previous context, use the agent.session() context manager.

    Sequential Workflow Pattern

    with agent.session() as session:
        session("Step 1")
        session("Step 2 that builds on step 1")
        session("Step 3 that uses both")
    with agent.session() as session:
        session("Step 1")
        session("Step 2 that builds on step 1")
  10. Manage session continuity and context

    main

    The ClaudeCodeACPClient maintains context automatically across multiple messages sent to the same client instance. This allows for multi-turn conversations where the agent remembers previous instructions and information.

    To start a completely new session and wipe the existing conversation history, use the clear_context() method.

    client = ClaudeCodeACPClient()
    client.start()
    
    # Context is preserved between these calls
    client.send_message("My favorite color is blue")
    response = client.send_message("What is my favorite color?")
    
    # Clear context to start fresh
    client.clear_context()
    client.stop()
  11. Requirements for functions used in function calling

    main

    For the agent to correctly understand and invoke your functions, they must adhere to these three requirements:

    1. Type Hints: All parameters must have type hints (e.g., param: str).
    2. Docstrings: You must include a docstring that describes the function and provides descriptions for each parameter in the Args: section.
    3. Return Type: You must specify a return type hint (e.g., -> dict).

    Supported Types include:

    • Basic types: str, int, float, bool
    • Collections: list, dict, List[T], Dict[K, V]
    • Optional types: Optional[T]
    • Union types: Union[T1, T2]
    • Any type: Any
  12. How the Augment SDK handles complex workflows

    main

    The converter translates natural language patterns into specific SDK patterns. When writing or reviewing generated code, understand these five core patterns:

    1. Sequential Stages with Context: Uses agent.session() to maintain continuity between steps.
    2. Conditional Logic: Uses typed results (e.g., bool) to drive if/else control flow.
    3. Loops/Iterations: Uses Python loops over collections returned by the agent.
    4. Data Dependencies: Uses dataclasses and type hints to pass structured data between steps.
    5. Function Calling: Uses agent.run() to allow the agent to execute local Python functions.
    # Example of Sequential Stages with Context
    with agent.session() as session:
        session("Step 1: Create the base structure")
        session("Step 2: Add features")
    
    # Example of Conditional Logic
    result = agent("Check if the file exists", bool)
    if result:
        agent("Process the existing file")
    
    # Example of Data Dependencies
    @dataclass
    class FileInfo:
        path: str
        size: int
    
    files = agent("Analyze all config files", list[FileInfo])
    for file in files:
        if file.size > 1000:
            agent(f"Optimize {file.path}")
    
    # Example of Function Calling
    def run_tests(test_file: str) -> dict:
        return {"passed": 10, "failed": 0}
    
    result = agent.run(
        "Run all tests",
        return_type=dict,
        functions=[run_tests]
    )