npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

bsa-ai

v1.1.0

Published

A multi-AI model CLI SDK for interacting with ChatGPT, Gemini, Claude, Deepseek, and GitHub Copilot

Readme

BSA-AI - Multi-AI Model CLI SDK

A powerful Node.js CLI-based SDK that allows seamless interaction with multiple AI models including ChatGPT, Google Gemini, Claude, Deepseek, and GitHub Copilot. Built with TypeScript for robust type safety and developer experience.

Features

  • Multi-Provider Support: Interact with 5 major AI providers from a single interface

    • OpenAI ChatGPT (GPT-4, GPT-4-turbo, GPT-3.5-turbo)
    • Google Gemini (Gemini 1.5 Pro, Flash)
    • Anthropic Claude (Claude 3.5 Sonnet, Haiku, Opus)
    • Deepseek (Deepseek Chat, Coder)
    • GitHub Copilot
  • Persistent Interactive Sessions: Start a session that runs until explicitly closed

  • File System Operations: Read, write, edit, and delete files in your project

  • Command Execution: Execute shell commands with safety checks

  • Consent Prompts: User approval required for file modifications and command execution

  • Streaming Responses: Real-time streaming for supported providers

  • Session Management: Save and load conversation sessions

  • Configuration Management: Easy provider configuration with secure API key storage

Installation

From NPM (after publishing)

npm install -g bsa-ai

From Source

# Clone the repository
git clone <your-repo-url>
cd bsa-ai

# Install dependencies
npm install

# Build the project
npm run build

# Link globally
npm link

Quick Start

1. Configure a Provider

Before using BSA-AI, you need to configure at least one AI provider:

# Configure interactively
bsa-ai config

# Or configure a specific provider
bsa-ai config -p chatgpt

You'll be prompted to enter:

  • API key (required)
  • Base URL (optional, for custom endpoints)
  • Default model (optional)
  • Temperature (optional, default: 0.7)
  • Max tokens (optional)

2. Start an Interactive Session

# Start with default provider
bsa-ai start

# Start with specific provider
bsa-ai start -p gemini

# Start with custom working directory
bsa-ai start -d /path/to/your/project

3. Interact with the AI

Once in a session, you can:

You: Help me create a Node.js express server
Assistant: I'll help you create a Node.js Express server...

CLI Commands

Session Commands

  • bsa-ai start - Start an interactive AI session
    • -p, --provider <provider> - Specify AI provider (chatgpt, gemini, claude, deepseek, copilot)
    • -d, --directory <directory> - Set working directory (default: current directory)

Configuration Commands

  • bsa-ai config - Configure a provider interactively

    • -p, --provider <provider> - Configure specific provider
  • bsa-ai list - List all configured providers

  • bsa-ai default <provider> - Set default AI provider

  • bsa-ai info - Show configuration information

  • bsa-ai clear - Clear configuration

    • -p, --provider <provider> - Clear specific provider config

In-Session Commands

While in an interactive session, use these commands:

  • /exit or /quit - Exit the session
  • /clear - Clear conversation history
  • /save - Save current session to file
  • /history - Display conversation history
  • /help - Show help message

Obtaining API Keys

OpenAI (ChatGPT)

  1. Visit https://platform.openai.com/api-keys
  2. Sign in or create an account
  3. Click "Create new secret key"
  4. Copy and save your API key

Google Gemini

  1. Visit https://makersuite.google.com/app/apikey
  2. Sign in with your Google account
  3. Click "Create API Key"
  4. Copy and save your API key

Anthropic (Claude)

  1. Visit https://console.anthropic.com/
  2. Sign in or create an account
  3. Navigate to API Keys
  4. Create a new API key
  5. Copy and save your API key

Deepseek

  1. Visit https://platform.deepseek.com/
  2. Sign in or create an account
  3. Navigate to API Keys section
  4. Create a new API key
  5. Copy and save your API key

GitHub Copilot

  1. Requires GitHub Copilot subscription
  2. Visit https://github.com/settings/tokens
  3. Generate a personal access token with appropriate scopes
  4. Use the token as your API key

Project Structure

bsa-ai/
├── src/
│   ├── cli.ts              # CLI entry point
│   ├── index.ts            # Main exports
│   ├── types/
│   │   ├── index.ts        # Type definitions
│   │   └── provider.ts     # Provider interfaces
│   ├── providers/
│   │   ├── chatgpt.ts      # OpenAI provider
│   │   ├── gemini.ts       # Google Gemini provider
│   │   ├── claude.ts       # Anthropic Claude provider
│   │   ├── deepseek.ts     # Deepseek provider
│   │   ├── copilot.ts      # GitHub Copilot provider
│   │   └── index.ts        # Provider factory
│   ├── managers/
│   │   ├── configManager.ts    # Configuration management
│   │   ├── sessionManager.ts   # Session management
│   │   ├── fileManager.ts      # File operations
│   │   ├── consentManager.ts   # User consent handling
│   │   └── commandManager.ts   # Command execution
│   ├── core/
│   │   └── interactiveSession.ts  # Interactive session logic
│   └── utils/
│       └── logger.ts           # Logging utilities
├── dist/                    # Compiled JavaScript
├── package.json
├── tsconfig.json
└── README.md

Programmatic Usage

You can also use BSA-AI as a library in your own Node.js projects:

import {
  createProvider,
  AIProvider,
  SessionManager,
  ConfigManager
} from 'bsa-ai';

// Create a provider
const provider = createProvider(AIProvider.CHATGPT);
provider.configure({
  apiKey: 'your-api-key',
  model: 'gpt-4',
  temperature: 0.7
});

// Use session manager
const configManager = new ConfigManager();
const sessionManager = new SessionManager(configManager);

await sessionManager.initializeSession(AIProvider.CHATGPT);
const response = await sessionManager.sendMessage('Hello!');
console.log(response);

File Operations

The SDK includes a file manager that can:

  • Read files: Access file contents in your project
  • Write files: Create new files with content
  • Edit files: Modify existing file contents
  • Delete files: Remove files (with consent)
  • List files: Browse directory contents

All file operations require user consent through interactive prompts.

Command Execution

Execute shell commands safely:

  • Commands are executed in the specified working directory
  • Dangerous commands (rm -rf, format, etc.) require explicit consent
  • Output (stdout/stderr) is captured and displayed
  • Error handling for failed commands

Consent System

BSA-AI uses a three-option consent system similar to Claude CLI for enhanced control:

When the AI requests to edit, create, or execute files/commands, you'll be prompted with:

  • Yes - Approve this single operation only
  • Yes for current session - Auto-approve all similar operations for the remainder of the session
  • No - Reject this operation

Session-Based Auto-Approval

  • File operations and command executions have separate session approval settings
  • Choosing "Yes for current session" remembers your preference until:
    • You exit the session
    • You use the /clear command (resets both history and consent preferences)
  • Auto-approved operations show: ✓ Auto-approved (session setting)

Example

⚠️  File Operation Requested:
Type: WRITE
Path: server.js
Content preview: const express = require('express')...

? Do you want to proceed?
  Yes
> Yes for current session
  No

After selecting "Yes for current session", all subsequent file operations in that session will be automatically approved.

Security Considerations

  • API keys are stored securely using the conf package
  • Configuration files are stored in OS-specific config directories
  • All file modifications require user consent
  • Dangerous commands are flagged and require approval
  • No API keys are logged or displayed

Configuration File Location

BSA-AI stores configuration in platform-specific locations:

  • macOS: ~/Library/Preferences/bsa-ai-nodejs/
  • Windows: %APPDATA%\bsa-ai-nodejs\Config\
  • Linux: ~/.config/bsa-ai-nodejs/

To view config location: bsa-ai info

Development

Building

npm run build

Development Mode (watch)

npm run dev

Testing

npm test

Troubleshooting

Provider not configured error

Run bsa-ai config -p <provider> to configure the provider with your API key.

API key errors

Verify your API key is correct and has not expired. Reconfigure using bsa-ai config.

Connection errors

Check your internet connection and verify the provider's API is accessible.

Permission errors

Ensure the CLI has permission to read/write files in your working directory.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

License

MIT License - see LICENSE file for details

Acknowledgments

  • Built with TypeScript
  • Uses official SDKs from OpenAI, Google, and Anthropic
  • Powered by Commander.js, Inquirer.js, and Chalk

Support

For issues and feature requests, please open an issue on GitHub.


Note: This SDK requires Node.js 16.0.0 or higher.