Skip to content

Conversation

@igor0
Copy link
Contributor

@igor0 igor0 commented Dec 5, 2025

Add comprehensive TypeScript SDK context examples demonstrating core functionality

This PR introduces four practical examples showcasing different use cases of the Auggie TypeScript SDK's context capabilities:

  • Direct Context (direct-context/index.ts) - Demonstrates basic usage patterns including simple file indexing, persistent index management across sessions, batch upload optimization, and external LLM integration
  • File Search Server (file-search-server/index.ts) - Implements a REST API server providing semantic file search with AI-powered summarization, including /search and /ask endpoints
  • FileSystem Context (filesystem-context/index.ts) - Shows automatic file discovery and indexing from local directories using the MCP protocol
  • Prompt Enhancer Server (prompt-enhancer-server/index.ts) - Provides an HTTP server that automatically enriches user prompts with relevant codebase context via /enhance and /enhance-and-ask endpoints

These examples provide developers with ready-to-use patterns for integrating semantic code search, context-aware AI interactions, and codebase indexing into their applications.


🤖 This description was generated automatically. Please react with 👍 if it's helpful or 👎 if it needs improvement.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed the TypeScript SDK examples. The code demonstrates the SDK functionality well with clear examples. I found one potential security concern regarding path validation in the server examples.


🤖 Automated review complete. Please react with 👍 or 👎 on the individual review comments to provide feedback on their usefulness.


// Start server
async function main() {
const directory = process.argv[2] || process.cwd();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The directory parameter from command-line arguments is passed directly to initializeContext without validation. This could allow an attacker to read arbitrary directories on the system if they can control the command-line arguments.

Consider adding path validation to ensure the directory is within expected bounds:

import { resolve } from 'path';

async function main() {
  const directory = process.argv[2] || process.cwd();
  const resolvedDir = resolve(directory);
  
  // Validate the directory exists and is accessible
  try {
    const stat = statSync(resolvedDir);
    if (!stat.isDirectory()) {
      throw new Error('Path is not a directory');
    }
  } catch (error) {
    console.error('Invalid directory:', error);
    process.exit(1);
  }
  
  console.log('Starting File Search Server...');
  await initializeContext(resolvedDir);
  // ...
}


// Start server
async function main() {
const directory = process.argv[2] || process.cwd();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The directory parameter from command-line arguments is passed directly to initializeContext without validation. This could allow an attacker to read arbitrary directories on the system if they can control the command-line arguments.

Consider adding path validation to ensure the directory is within expected bounds:

import { resolve } from 'path';

async function main() {
  const directory = process.argv[2] || process.cwd();
  const resolvedDir = resolve(directory);
  
  // Validate the directory exists and is accessible
  try {
    const stat = statSync(resolvedDir);
    if (!stat.isDirectory()) {
      throw new Error('Path is not a directory');
    }
  } catch (error) {
    console.error('Invalid directory:', error);
    process.exit(1);
  }
  
  console.log('Starting Prompt Enhancer Server...');
  await initializeContext(resolvedDir);
  // ...
}

@igor0 igor0 force-pushed the context-sdk-examples branch from c4990f2 to e457946 Compare December 5, 2025 19:43
@igor0 igor0 requested a review from richhankins December 6, 2025 00:16
@igor0
Copy link
Contributor Author

igor0 commented Dec 7, 2025

augment review

@igor0 igor0 force-pushed the context-sdk-examples branch from 15a82ce to fb57058 Compare December 9, 2025 06:29
Copy link
Contributor

@richhankins richhankins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@igor0 igor0 merged commit fa59113 into main Dec 9, 2025
@igor0 igor0 deleted the context-sdk-examples branch December 9, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants