|
| 1 | +# Context Examples |
| 2 | + |
| 3 | +Examples demonstrating the Auggie SDK's context modes and AI-powered code analysis. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. **Python 3.9+** - Required to run the examples |
| 8 | +2. **Auggie CLI** - Required for FileSystem Context examples |
| 9 | + ```bash |
| 10 | + pip install auggie |
| 11 | + # or |
| 12 | + npm install -g @augmentcode/auggie |
| 13 | + ``` |
| 14 | +3. **Authentication** - Required for all examples |
| 15 | + ```bash |
| 16 | + auggie login |
| 17 | + ``` |
| 18 | + This creates a session file at `~/.augment/session.json` with your API token. |
| 19 | + |
| 20 | + Alternatively, you can set environment variables: |
| 21 | + ```bash |
| 22 | + export AUGMENT_API_TOKEN=your_token_here |
| 23 | + export AUGMENT_API_URL=https://staging-shard-0.api.augmentcode.com/ |
| 24 | + ``` |
| 25 | + |
| 26 | +## Examples |
| 27 | + |
| 28 | +### [Direct Context](./direct_context/) |
| 29 | +API-based indexing with semantic search and AI Q&A. |
| 30 | + |
| 31 | +**Run it:** |
| 32 | +```bash |
| 33 | +python direct_context/main.py |
| 34 | +``` |
| 35 | + |
| 36 | +### [FileSystem Context](./filesystem_context/) |
| 37 | +Local directory search via MCP protocol. |
| 38 | + |
| 39 | +**Important:** The FileSystem Context indexes all files in the workspace directory. To avoid timeouts when indexing large directories (like `node_modules/`), consider adding a `.gitignore` or `.augmentignore` file that excludes them. The auggie CLI respects both `.gitignore` and `.augmentignore` patterns during indexing. |
| 40 | + |
| 41 | +**Run it:** |
| 42 | +```bash |
| 43 | +python filesystem_context/main.py |
| 44 | +``` |
| 45 | + |
| 46 | +### [File Search Server](./file_search_server/) |
| 47 | +REST API for semantic file search with AI summarization. |
| 48 | + |
| 49 | +**Run it:** |
| 50 | +```bash |
| 51 | +python file_search_server/main.py [workspace-directory] |
| 52 | +``` |
| 53 | + |
| 54 | +Then query the API: |
| 55 | +```bash |
| 56 | +curl "http://localhost:3000/search?q=python" |
| 57 | +``` |
| 58 | + |
| 59 | +### [Prompt Enhancer Server](./prompt_enhancer_server/) |
| 60 | +HTTP server that enhances prompts with codebase context. |
| 61 | + |
| 62 | +**Run it:** |
| 63 | +```bash |
| 64 | +python prompt_enhancer_server/main.py [workspace-directory] |
| 65 | +``` |
| 66 | + |
| 67 | +Then enhance prompts: |
| 68 | +```bash |
| 69 | +curl -X POST http://localhost:3001/enhance \ |
| 70 | + -H "Content-Type: application/json" \ |
| 71 | + -d '{"prompt": "fix the login bug"}' |
| 72 | +``` |
| 73 | + |
| 74 | +### [GitHub Action Indexer](./github_action_indexer/) |
| 75 | +Index GitHub repositories for semantic search. |
| 76 | + |
| 77 | +This example has its own requirements.txt and dependencies. |
| 78 | + |
| 79 | +**Setup:** |
| 80 | +```bash |
| 81 | +cd github_action_indexer |
| 82 | +pip install -r requirements.txt |
| 83 | +``` |
| 84 | + |
| 85 | +**Run it:** |
| 86 | +```bash |
| 87 | +python src/main.py |
| 88 | +python src/search.py "your query" |
| 89 | +``` |
| 90 | + |
| 91 | +See [github_action_indexer/README.md](./github_action_indexer/README.md) for more details. |
| 92 | + |
| 93 | +## Troubleshooting |
| 94 | + |
| 95 | +### MCP Timeout in FileSystem Context |
| 96 | + |
| 97 | +**Problem:** The FileSystem Context example times out during indexing. |
| 98 | + |
| 99 | +**Cause:** The workspace directory contains too many files (e.g., `node_modules/` with 45,000+ files). |
| 100 | + |
| 101 | +**Solution:** Create a `.gitignore` or `.augmentignore` file in the workspace directory to exclude large directories: |
| 102 | + |
| 103 | +```bash |
| 104 | +# .gitignore or .augmentignore |
| 105 | +node_modules/ |
| 106 | +dist/ |
| 107 | +*.log |
| 108 | +.DS_Store |
| 109 | +__pycache__/ |
| 110 | +*.pyc |
| 111 | +``` |
| 112 | + |
| 113 | +The auggie CLI respects both `.gitignore` and `.augmentignore` patterns and will skip excluded files during indexing. |
| 114 | + |
| 115 | +### Authentication Errors |
| 116 | + |
| 117 | +**Problem:** `Error: API key is required for search_and_ask()` |
| 118 | + |
| 119 | +**Cause:** The SDK cannot find your authentication credentials. |
| 120 | + |
| 121 | +**Solution:** Run `auggie login` to authenticate, or set the `AUGMENT_API_TOKEN` and `AUGMENT_API_URL` environment variables. |
| 122 | + |
0 commit comments