co-mono/todos/project-description.md
Mario Zechner f064ea0e14 feat(ai): Create unified AI package with OpenAI, Anthropic, and Gemini support
- Set up @mariozechner/ai package structure following monorepo patterns
- Install OpenAI, Anthropic, and Google Gemini SDK dependencies
- Document comprehensive API investigation for all three providers
- Design minimal unified API with streaming-first architecture
- Add models.dev integration for pricing and capabilities
- Implement automatic caching strategy for all providers
- Update project documentation with package creation guide
2025-08-17 20:18:45 +02:00

4.2 KiB

Project: Pi Monorepo

A comprehensive toolkit for managing Large Language Model (LLM) deployments and building AI agents, specifically designed for deploying and managing LLMs on remote GPU pods with automatic vLLM configuration for agentic workloads.

Features

  • Terminal UI framework with differential rendering and interactive components
  • AI agent framework with tool calling, session persistence, and multiple renderers
  • GPU pod management CLI for automated vLLM deployment on various providers
  • Support for OpenAI, Anthropic, Groq, OpenRouter, Gemini, and compatible APIs
  • Built-in file system tools for agentic AI capabilities

Tech Stack

  • TypeScript/JavaScript with ES Modules
  • Node.js ≥20.0.0
  • OpenAI SDK for LLM integration
  • Custom TUI library with differential rendering
  • Biome for linting and formatting
  • npm workspaces for monorepo structure

Structure

  • packages/tui/ - Terminal UI library
  • packages/agent/ - AI agent with tool calling
  • packages/pods/ - CLI for GPU pod management
  • scripts/ - Utility scripts for version sync
  • todos/ - Task tracking

Architecture

  • Event-driven agent system with publish-subscribe pattern
  • Component-based TUI with differential rendering
  • SSH-based remote pod management
  • Tool calling system for file operations (read, bash, glob, ripgrep)
  • Session persistence in JSONL format
  • Multiple renderer strategies (Console, TUI, JSON)

Commands

  • Lint: npm run check
  • Dev/Run: npx tsx packages/agent/src/cli.ts (pi-agent), npx tsx packages/pods/src/cli.ts (pi)
  • Version: npm run version:patch/minor/major
  • Publish: npm run publish

Testing

The TUI package includes comprehensive tests using Node.js built-in test framework:

  • Unit tests in packages/tui/test/*.test.ts
  • Test runner: node --test --import tsx test/*.test.ts
  • Virtual terminal for TUI testing via @xterm/headless
  • Example applications for manual testing

How to Create a New Package

Follow these steps to add a new package to the monorepo:

  1. Create package directory structure:

    mkdir -p packages/your-package/src
    
  2. Create package.json:

    {
      "name": "@mariozechner/your-package",
      "version": "0.5.8",
      "description": "Package description",
      "type": "module",
      "main": "./dist/index.js",
      "types": "./dist/index.d.ts",
      "files": ["dist", "README.md"],
      "scripts": {
        "clean": "rm -rf dist",
        "build": "tsc -p tsconfig.build.json",
        "check": "biome check --write .",
        "prepublishOnly": "npm run clean && npm run build"
      },
      "dependencies": {},
      "devDependencies": {},
      "keywords": ["relevant", "keywords"],
      "author": "Mario Zechner",
      "license": "MIT",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/badlogic/pi-mono.git",
        "directory": "packages/your-package"
      },
      "engines": {
        "node": ">=20.0.0"
      }
    }
    
  3. Create tsconfig.build.json:

    {
      "extends": "../../tsconfig.base.json",
      "compilerOptions": {
        "outDir": "./dist",
        "rootDir": "./src"
      },
      "include": ["src/**/*"],
      "exclude": ["node_modules", "dist"]
    }
    
  4. Create src/index.ts:

    // Main exports for your package
    export const version = "0.5.8";
    
  5. Update root tsconfig.json paths: Add your package to the paths mapping in the correct dependency order:

    "paths": {
      "@mariozechner/pi-tui": ["./packages/tui/src/index.ts"],
      "@mariozechner/your-package": ["./packages/your-package/src/index.ts"],
      // ... other packages
    }
    
  6. Update root package.json build script: Insert your package in the correct dependency order:

    "build": "npm run build -w @mariozechner/pi-tui && npm run build -w @mariozechner/your-package && ..."
    
  7. Install and verify:

    npm install
    npm run build
    npm run check
    

Important Notes:

  • All packages use lockstep versioning (same version number)
  • Follow dependency order: foundational packages build first
  • Use ESM modules ("type": "module")
  • No any types unless absolutely necessary
  • Include README.md with package documentation