bsa-ai
v1.1.0
Published
A multi-AI model CLI SDK for interacting with ChatGPT, Gemini, Claude, Deepseek, and GitHub Copilot
Maintainers
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-aiFrom 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 linkQuick 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 chatgptYou'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/project3. 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 providersbsa-ai default <provider>- Set default AI providerbsa-ai info- Show configuration informationbsa-ai clear- Clear configuration-p, --provider <provider>- Clear specific provider config
In-Session Commands
While in an interactive session, use these commands:
/exitor/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)
- Visit https://platform.openai.com/api-keys
- Sign in or create an account
- Click "Create new secret key"
- Copy and save your API key
Google Gemini
- Visit https://makersuite.google.com/app/apikey
- Sign in with your Google account
- Click "Create API Key"
- Copy and save your API key
Anthropic (Claude)
- Visit https://console.anthropic.com/
- Sign in or create an account
- Navigate to API Keys
- Create a new API key
- Copy and save your API key
Deepseek
- Visit https://platform.deepseek.com/
- Sign in or create an account
- Navigate to API Keys section
- Create a new API key
- Copy and save your API key
GitHub Copilot
- Requires GitHub Copilot subscription
- Visit https://github.com/settings/tokens
- Generate a personal access token with appropriate scopes
- 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.mdProgrammatic 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
/clearcommand (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
NoAfter 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
confpackage - 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 buildDevelopment Mode (watch)
npm run devTesting
npm testTroubleshooting
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:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- 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.
