@sashimo/cli
v3.7.0
Published
CLI tool for installing and setting up Sashi in Next.js and Node.js projects
Maintainers
Readme
Sashi CLI
The official command-line interface for installing and managing Sashi AI admin companion in your Next.js and Node.js projects.
Installation
No installation required! Use npx to run commands directly:
npx @sashimo/cli setup
npx @sashimo/cli init my-app
npx @sashimo/cli checkQuick Start
For Existing Projects
# Setup Sashi in your existing project
npx @sashimo/cli setup
# Or with options
npx @sashimo/cli setup --framework nextjs --typescript --api-key sk-your-openai-keyFor New Projects
# Create a new project with Sashi pre-configured
npx @sashimo/cli init my-admin-app
# Or with options
npx @sashimo/cli init my-admin-app --framework nodejs --typescriptCheck Your Setup
# Verify your Sashi configuration
npx @sashimo/cli checkCommands
npx @sashimo/cli setup
Setup Sashi in an existing Next.js or Node.js project.
npx @sashimo/cli setup [options]Options:
-f, --framework <framework>- Target framework (nextjs, nodejs, express, auto)-t, --typescript- Use TypeScript setup-y, --yes- Skip prompts and use defaults--api-key <key>- OpenAI API key--hub-url <url>- Sashi Hub URL (optional)
Example:
npx @sashimo/cli setup --framework nextjs --typescript --api-key sk-...npx @sashimo/cli init [project-name]
Create a new project with Sashi pre-configured.
npx @sashimo/cli init [project-name] [options]Options:
-f, --framework <framework>- Target framework (nextjs, nodejs, express)-t, --typescript- Use TypeScript (default: true)-y, --yes- Skip prompts and use defaults--api-key <key>- OpenAI API key--hub-url <url>- Sashi Hub URL (optional)
Example:
npx @sashimo/cli init my-app --framework nextjs --api-key sk-...npx @sashimo/cli check
Check your Sashi setup and configuration.
npx @sashimo/cli checkThis command will:
- Check if Sashi packages are installed
- Verify configuration files exist
- Provide recommendations for setup issues
npx @sashimo/cli add
Add Sashi middleware to your project.
npx @sashimo/cli add [options]Options:
-y, --yes- Skip prompts and use defaults
Example:
npx @sashimo/cli add --yesnpx @sashimo/cli update
Update Sashi packages to latest version.
npx @sashimo/cli update [options]Options:
-y, --yes- Skip prompts and update all
Example:
npx @sashimo/cli update --yesFramework Support
Next.js
Sashi CLI provides full support for Next.js projects:
- Automatic detection of Pages Router vs App Router
- Creates API routes for Sashi middleware
- Sets up UI pages for admin interface
- Configures Tailwind CSS integration
Generated Files:
pages/api/sashi/[[...slug]].ts- API routepages/sashi/index.tsx- Admin UI pagesashi.config.ts- Configuration file.env.local- Environment variables
Express.js
For Express.js applications:
- Creates middleware integration example
- Provides server setup templates
- Configures CORS and routing
Generated Files:
sashi-example.ts- Integration examplesashi.config.ts- Configuration file.env- Environment variables
Node.js (Generic)
For generic Node.js applications:
- Creates HTTP server integration
- Provides basic routing setup
- Configures middleware handling
Configuration
Sashi CLI generates a sashi.config.ts file with all configuration options:
import type { SashiConfig } from "@sashimo/lib"
const config: SashiConfig = {
openai: {
apiKey: process.env.OPENAI_API_KEY!,
model: "gpt-4",
},
middleware: {
path: "/sashi",
cors: {
origin: process.env.NODE_ENV === "development" ? "*" : false,
},
},
ui: {
theme: "light",
branding: {
title: "Admin Panel",
},
},
functions: {
loadDefaults: false,
hiddenFromUI: [],
},
}
export default configEnvironment Variables
The CLI sets up these environment variables:
# Required
OPENAI_API_KEY=your-openai-api-key
# Optional - defaults to https://hub.usesashi.com
SASHI_API_SECRET_KEY=your-sashi-api-secret-key
SASHI_HUB_URL=https://hub.usesashi.comPackage Manager Support
Sashi CLI automatically detects and uses your preferred package manager:
- npm - Default
- yarn - Detected by
yarn.lock - pnpm - Detected by
pnpm-lock.yaml - bun - Detected by
bun.lockb
TypeScript Support
Sashi CLI provides excellent TypeScript support:
- Automatic TypeScript detection
- Type-safe configuration files
- Proper import/export syntax
- Type definitions for all APIs
Troubleshooting
Common Issues
"No package.json found"
- Run the command in a Node.js project directory
- Initialize with
npm initif needed
"OpenAI API key is required"
- Get an API key from OpenAI Platform
- Pass it via
--api-keyflag or set in environment
"Tailwind CSS not detected"
- Install Tailwind CSS:
npx tailwindcss init -p - Required for Sashi UI components
- Install Tailwind CSS:
Getting Help
# Show help for any command
sashi --help
sashi setup --help
sashi init --help
# Check your setup
sashi check --verboseExamples
Quick Setup for Next.js
# In your Next.js project
sashi setup --framework nextjs --typescript --api-key sk-your-key
# Start development server
npm run dev
# Visit http://localhost:3000/sashiCreate New Express App
# Create new Express app with Sashi
sashi init my-api --framework express --typescript
cd my-api
npm run dev
# Visit http://localhost:3000/sashiAdd Middleware to Existing Project
# Add Sashi middleware
sashi add
# Update Sashi packages
sashi updateCommunity
- GitHub: https://github.com/UseSashiMoto/usesashi
- Discord: Join our community at https://discord.gg/3a9S6XPc6Q
Contributing
See the main Sashi repository for contribution guidelines.
License
MIT License - see the LICENSE file for details.
