JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q31675F
  • License MIT

AI-powered technical documentation assistant for analyzing codebases and generating documentation

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ai-documenter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    AI Documenter

    AI Documenter is an AI-powered technical documentation assistant designed to analyze codebases, files, and directories, generating accurate, well-structured documentation, README files, API docs, and technical guides. It supports both OpenAI models (cloud) and LMStudio (local) for deep code and documentation analysis, making it an ideal tool for developers and technical writers who value flexibility and privacy.

    Features

    • Interactive CLI: Engage in natural conversations with the documentation assistant via a terminal-based interface.
    • Multiple AI Providers: Choose between OpenAI (cloud) or LMStudio (local) for AI processing.
    • Automated Documentation: Generate documentation for source files, project directories, configuration files, and more.
    • AI-Powered Analysis: Integrates OpenAI's latest models or local LMStudio models for advanced understanding and generation.
    • Privacy-First Option: Use LMStudio for completely local processing without sending code to external APIs.
    • Customizable Tools: File system read/write, directory and file info, project structure analysis, and more.
    • Project-Specific Configuration: Configurable per-project with .documenter.json config files.
    • Global Installation: Install once, use anywhere in your projects.
    • Built-in Help & Guidance: Easily accessible help and usage examples within the CLI.

    Installation

    Install AI Documenter globally to use it in any project:

    npm install -g ai-documenter

    Local Installation

    Install in a specific project:

    npm install ai-documenter
    npx ai-documenter

    From Source

    1. Clone the Repository:

      git clone <repository-url>
      cd documenter
    2. Install Dependencies:

      npm install
    3. Build and Install:

      npm run build
      npm link  # For global installation

    Quick Start

    1. Initialize AI Documenter in your project:

      cd your-project
      ai-documenter init
    2. Start the documentation assistant:

      ai-documenter
    3. Start documenting! Try commands like:

      • "Document the file src/app.js"
      • "Create a README for this project"
      • "Explain the src/ folder structure"

    Configuration

    AI Documenter supports both OpenAI (cloud) and LMStudio (local) providers for maximum flexibility.

    Environment Variables

    Common Settings

    • LLM_PROVIDER (Optional): Choose provider: openai or lmstudio (default: openai)
    • MAX_CONVERSATION_HISTORY (Optional): Number of conversation turns to remember (default: 10)
    • DEFAULT_OUTPUT_DIR (Optional): Default directory for generated documentation (default: ./docs)
    • LLM_TIMEOUT (Optional): Request timeout in milliseconds (default: 3600000)

    OpenAI Provider

    • OPENAI_API_KEY (Required for OpenAI): Your OpenAI API key
    • OPENAI_MODEL (Optional): Model to use (default: gpt-4o-mini)

    LMStudio Provider

    • LMSTUDIO_ENDPOINT (Optional): LMStudio API endpoint (default: http://localhost:1234/v1)
    • LMSTUDIO_MODEL (Optional): Model name in LMStudio (default: local-model)

    Configuration File

    Create a .documenter.json file in your project root (this file is automatically added to .gitignore):

    OpenAI Configuration

    {
      "provider": "openai",
      "openai_api_key": "your-api-key-here",
      "openai_model": "gpt-4o-mini",
      "max_conversation_history": 10,
      "default_output_dir": "./docs"
    }

    LMStudio Configuration

    {
      "provider": "lmstudio",
      "lmstudio_endpoint": "http://localhost:1234/v1",
      "lmstudio_model": "your-local-model-name",
      "max_conversation_history": 10,
      "default_output_dir": "./docs"
    }

    Configuration Priority

    1. .documenter.json in current directory
    2. documenter.config.json in current directory
    3. Environment variables
    4. .env file in current directory
    5. Global .env file in ~/.documenter/.env

    Note: Configuration files (.documenter.json, documenter.config.json) are automatically excluded from git to prevent committing sensitive API keys. For team projects, document the required configuration in your project's README instead of committing the actual config files.

    LMStudio Setup

    To use LMStudio for local AI models:

    1. Download and Install LMStudio from https://lmstudio.ai

    2. Download a Model (e.g., Code Llama, Mistral, or other coding-focused models)

    3. Start the Local Server in LMStudio (typically runs on port 1234)

    4. Configure AI Documenter:

      ai-documenter init
      # Select option 2 for LMStudio when prompted
    5. Set Environment Variables (optional):

      export LLM_PROVIDER=lmstudio
      export LMSTUDIO_ENDPOINT=http://localhost:1234/v1
      export LMSTUDIO_MODEL=your-model-name

    Benefits of LMStudio:

    • ✅ Complete privacy - your code never leaves your machine
    • ✅ No API costs - run unlimited documentation generation
    • ✅ Works offline - no internet connection required
    • ✅ Custom models - use specialized coding models

    Usage

    Interactive Mode

    Run ai-documenter to start the interactive documentation assistant:

    ai-documenter

    Initialize a Project

    Set up AI Documenter configuration for your project:

    ai-documenter init

    Example Commands

    Once in interactive mode, try these commands:

    • Document the file src/app.js
    • Explain the src/ folder structure
    • Write API docs for this project
    • Create a README for this project
    • Explain how this code works
    • Generate documentation for the entire codebase

    CLI Commands

    • exit or quit - Exit the application
    • clear - Reset conversation and clear the screen
    • help - Display help message
    • init - Initialize documenter in current directory

    Project Structure

    ai-documenter/
    ├── src/
    │   ├── cli.ts        # Main CLI application and entry point
    │   ├── agent.ts      # Custom agent implementation for multiple providers
    │   ├── providers.ts  # Provider abstraction (OpenAI, LMStudio)
    │   ├── prompt.ts     # Agent instructions and prompt template
    │   ├── tools.ts      # File and directory tools used by the agent
    ├── bin/              # Built executable (generated)
    ├── package.json      # Project configuration and dependencies
    └── README.md         # This file

    Configuration Examples

    Basic Setup

    1. Global API Key (works everywhere):

      echo "OPENAI_API_KEY=your-key-here" >> ~/.zshrc  # or ~/.bashrc
      source ~/.zshrc
    2. Project-Specific Setup:

      cd your-project
      ai-documenter init
      # Follow the prompts to configure

    Advanced Configuration

    Create .documenter.json for project-specific settings:

    {
      "openai_model": "gpt-4o",
      "default_output_dir": "./documentation",
      "max_conversation_history": 20
    }

    Development

    Running from Source

    npm run dev

    Building

    npm run build
    ./bin/ai-documenter

    Publishing

    npm run build
    npm publish

    Customization

    • Edit src/prompt.ts to change instructions for the technical writer agent
    • Enhance src/tools.ts to extend or modify file system tools
    • Modify src/cli.ts to add new commands or change behavior

    Use Cases

    • API Documentation: Generate comprehensive API docs from source code
    • README Files: Create project overviews and setup instructions
    • Code Explanations: Understand and document complex codebases
    • Technical Guides: Create step-by-step implementation guides
    • Architecture Documentation: Document system design and structure
    • Configuration Documentation: Explain config files and settings

    Tips

    • Use specific file paths for targeted documentation
    • Ask for explanations of code patterns and architecture
    • Request documentation in specific formats (Markdown, HTML, etc.)
    • Combine multiple requests in conversation for comprehensive docs
    • Use the clear command to start fresh documentation sessions

    Troubleshooting

    API Key Issues

    If you get an API key error:

    1. Run ai-documenter init to set up configuration
    2. Check environment variables: echo $OPENAI_API_KEY
    3. Verify .env file exists in your project or home directory
    4. Check .documenter.json configuration file

    Permission Issues

    If you get permission errors:

    # Fix npm permissions
    npm config set prefix ~/.npm-global
    export PATH=~/.npm-global/bin:$PATH

    Build Issues

    If the build fails:

    # Clean and rebuild
    rm -rf bin/
    npm run build

    Contributing

    Pull requests, bug reports, and feature suggestions are welcome! Please open an issue for discussion before making major changes.

    License

    MIT License