Skip to content

Latest commit

 

History

History
149 lines (105 loc) · 3.88 KB

File metadata and controls

149 lines (105 loc) · 3.88 KB

Context Examples

Examples demonstrating the Auggie SDK's context modes and AI-powered code analysis.

Prerequisites

  1. Node.js 18+ - Required to run the examples

  2. Auggie CLI - Required for FileSystem Context examples

    npm install -g @augmentcode/auggie
  3. Authentication - Required for all examples

    auggie login

    This creates a session file at ~/.augment/session.json with your API token.

    Alternatively, you can set environment variables:

    export AUGMENT_API_TOKEN=your_token_here
    export AUGMENT_API_URL=https://staging-shard-0.api.augmentcode.com/

Setup

Install dependencies:

cd examples/typescript-sdk/context
npm install

Examples

API-based indexing with semantic search and AI Q&A.

Run it:

npm run direct-context

Local directory search via MCP protocol.

Prerequisites:

  • Auggie CLI must be installed and in your PATH
  • Authentication via auggie login or AUGMENT_API_TOKEN environment variable
  • A .gitignore or .augmentignore file in the workspace directory to exclude node_modules/ and other large directories

Important: The FileSystem Context indexes all files in the workspace directory. To avoid timeouts when indexing large directories (like node_modules/), make sure you have a .gitignore or .augmentignore file that excludes them. The auggie CLI respects both .gitignore and .augmentignore patterns during indexing.

Run it:

npm run filesystem-context

REST API for semantic file search with AI summarization.

Prerequisites: Auggie CLI must be installed and in your PATH.

Run it:

npm run file-search-server [workspace-directory]

Then query the API:

curl "http://localhost:3000/search?q=typescript"

HTTP server that enhances prompts with codebase context.

Prerequisites: Auggie CLI must be installed and in your PATH.

Run it:

npm run prompt-enhancer-server [workspace-directory]

Then enhance prompts:

curl -X POST http://localhost:3001/enhance \
  -H "Content-Type: application/json" \
  -d '{"prompt": "fix the login bug"}'

Index GitHub repositories for semantic search.

This example has its own package.json and dependencies.

Setup:

npm run github-indexer:install

Run it:

npm run github-indexer:index
npm run github-indexer:search

See github-action-indexer/README.md for more details.

Running Examples Directly with tsx

You can also run examples directly without installing dependencies:

npx tsx direct-context/index.ts
npx tsx filesystem-context/index.ts
npx tsx file-search-server/index.ts .
npx tsx prompt-enhancer-server/index.ts .

Note: This will download dependencies on each run. For better performance, use npm install first.

Troubleshooting

MCP Timeout in FileSystem Context

Problem: The FileSystem Context example times out during indexing.

Cause: The workspace directory contains too many files (e.g., node_modules/ with 45,000+ files).

Solution: Create a .gitignore or .augmentignore file in the workspace directory to exclude large directories:

# .gitignore or .augmentignore
node_modules/
dist/
*.log
.DS_Store

The auggie CLI respects both .gitignore and .augmentignore patterns and will skip excluded files during indexing.

Authentication Errors

Problem: Error: API key is required for searchAndAsk()

Cause: The SDK cannot find your authentication credentials.

Solution: Run auggie login to authenticate, or set the AUGMENT_API_TOKEN and AUGMENT_API_URL environment variables.