@brainstack/pipe-chat-cli
v1.0.3
Published
CLI tool to discuss with AI to about data source and apply changes.
Downloads
4
Readme
Here is a README and a deployment script for your npm package @brainstack/pipe-chat-cli
:
README
# @brainstack/pipe-chat-cli
`@brainstack/pipe-chat-cli` is a CLI tool designed to interact with your Supabase database and leverage AI to discuss, refactor, and improve your database schema.
## Features
- Initialize a data source.
- Retrieve the current context (schema) from the data source.
- Chat with an AI to get insights and suggestions for schema modifications.
- Dynamically process messages through a customizable parser pipeline.
## Installation
You can install the CLI globally using npm:
```sh
npm install -g @brainstack/pipe-chat-cli
Usage
After installation, you can use the CLI commands as follows:
pipe-chat-cli init
pipe-chat-cli context
pipe-chat-cli chat
Commands
init
: Initialize the data source.context
: Get the current context from the data source.chat
: Chat with the AI to discuss and improve the schema.
Environment Variables
Create a .env
file in the root directory of your project and add the following environment variables:
SUPABASE_URL=your-supabase-url
SUPABASE_KEY=your-supabase-key
AI_PROVIDER_BASE_URL=your-openai-base-url
AI_PROVIDER_API_KEY=your-openai-api-key
AI_MODEL=your-openai-model
Example .env file
SUPABASE_URL=https://xyzcompany.supabase.co
SUPABASE_KEY=your-supabase-key
AI_PROVIDER_BASE_URL=https://api.openai.com
AI_PROVIDER_API_KEY=your-openai-api-key
AI_MODEL=gpt-4
Development
To develop and test the package locally, clone the repository and run:
npm install
npm run build
npm link
This will link the local package as a global npm package. You can then use the CLI commands as described above.
License
MIT
### Deployment Script
Here's a script to prepare and publish your package to npm:
```sh
#!/bin/bash
# Ensure the package.json version is updated before publishing
echo "Updating package version..."
npm version patch
# Build the project
echo "Building the project..."
npm run build
# Publish the package to npm
echo "Publishing the package to npm..."
npm publish
# Output completion message
echo "Package @brainstack/pipe-chat-cli published successfully!"
# Instructions for testing the package
echo "You can now test the package using: npx @brainstack/pipe-chat-cli"
Adding bin
field in package.json
To make sure the CLI can be run using npx @brainstack/pipe-chat-cli
, add the bin
field to your package.json
:
{
"name": "@brainstack/pipe-chat-cli",
"version": "1.0.0",
"description": "CLI tool to interact with Supabase and AI to improve your database schema",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"start": "node dist/index.js"
},
"bin": {
"pipe-chat-cli": "./dist/index.js"
},
"dependencies": {
"commander": "^10.0.0",
"dotenv": "^16.0.0",
"openai": "^3.0.0",
"supabase": "^1.0.0"
},
"devDependencies": {
"@types/node": "^18.0.0",
"typescript": "^5.0.0"
},
"keywords": [
"supabase",
"openai",
"cli",
"database",
"ai"
},
"author": "Your Name",
"license": "MIT"
}
Final Steps
- Save the deployment script as
deploy.sh
, give it executable permissions usingchmod +x deploy.sh
, and then run it with./deploy.sh
. - Make sure to update the version in
package.json
appropriately before publishing.
With these steps, your CLI tool should be ready to use and can be installed globally or run using npx @brainstack/pipe-chat-cli
.