feat(npm): Rename CLI package from @sim/cli to @simstudio/cli and update references

This commit is contained in:
Waleed Latif
2025-03-05 11:59:42 -08:00
parent 34dfdf3119
commit cac85c6c24
52 changed files with 2682 additions and 2506 deletions

4
.gitignore vendored
View File

@@ -2,6 +2,7 @@
# dependencies
/node_modules
/packages/**/node_modules
/.pnp
.pnp.*
.yarn/*
@@ -19,6 +20,9 @@
# production
/build
/dist
**/dist/
sim-standalone.tar.gz
# misc
.DS_Store

View File

@@ -398,7 +398,7 @@ Happy coding!
Sim Studio supports a local storage mode that uses the browser's localStorage instead of a database. This is particularly useful for:
- Quick demos and testing
- Using the `npx sim` CLI
- Using the `npx simstudio` CLI
- Development without setting up a database
- Creating shareable examples
@@ -415,18 +415,18 @@ All data will be stored in the browser's localStorage. This means:
### Developing the CLI
Sim Studio includes a CLI package that allows users to quickly start the application with `npx sim`. To develop the CLI:
Sim Studio includes a CLI package that allows users to quickly start the application with `npx simstudio`. To develop the CLI:
1. Build the CLI: `npm run cli:build`
2. Test the CLI: `npm run cli:start`
3. Make changes in the `packages/@sim/cli` directory
3. Make changes in the `packages/@simstudio/cli` directory
4. Publish new versions: `npm run cli:publish` (requires npm permissions)
The CLI automatically enables local storage mode when running.
### Building the Standalone Version
The `npx sim` command downloads and runs a pre-built standalone version of Sim Studio. To build this standalone version:
The `npx simstudio` command downloads and runs a pre-built standalone version of Sim Studio. To build this standalone version:
1. Run `npm run build:standalone` from the project root
2. This creates a tarball (`sim-standalone.tar.gz`) containing:
@@ -437,7 +437,7 @@ The `npx sim` command downloads and runs a pre-built standalone version of Sim S
3. To release a new version:
- Upload the tarball to a GitHub release
- Update the `DOWNLOAD_URL` in `packages/@sim/cli/src/commands/start.ts`
- Update the `DOWNLOAD_URL` in `packages/@simstudio/cli/src/commands/start.ts`
- Update the `STANDALONE_VERSION` constant if needed
- Publish the CLI package: `npm run cli:publish`

View File

@@ -16,7 +16,7 @@
Sim Studio now supports a quick start option with zero installation required:
```bash
npx sim
npx simstudio
```
This downloads and runs Sim Studio with browser localStorage for data persistence. Visit http://localhost:3000 to start building workflows immediately!

View File

@@ -13,8 +13,8 @@ This guide outlines the steps to release Sim Studio CLI to npm and create a GitH
### 1. Prepare the Release
1. Ensure all changes are committed and pushed to the main branch
2. Update the version number in `packages/@sim/cli/package.json`
3. Update the `STANDALONE_VERSION` in `packages/@sim/cli/src/commands/start.ts` to match
2. Update the version number in `packages/@simstudio/cli/package.json`
3. Update the `STANDALONE_VERSION` in `packages/@simstudio/cli/src/commands/start.ts` to match
### 2. Run the Release Script
@@ -37,7 +37,7 @@ This script will:
After the script completes, follow the instructions to publish to npm:
```bash
cd packages/@sim/cli
cd packages/@simstudio/cli
npm publish
```
@@ -83,6 +83,6 @@ npx simstudio start
After a successful release:
1. Increment the version number in `packages/@sim/cli/package.json` for the next release
2. Update the `STANDALONE_VERSION` in `packages/@sim/cli/src/commands/start.ts`
1. Increment the version number in `packages/@simstudio/cli/package.json` for the next release
2. Update the `STANDALONE_VERSION` in `packages/@simstudio/cli/src/commands/start.ts`
3. Commit these changes with a message like "Bump version to X.Y.Z"

View File

@@ -1,7 +1,7 @@
import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
// Check if we're in local storage mode (CLI usage with npx sim)
// Check if we're in local storage mode (CLI usage with npx simstudio)
const isLocalStorage = process.env.USE_LOCAL_STORAGE === 'true'
// Create a type for our database client

View File

@@ -2,13 +2,13 @@
/**
* Storage detection helper that determines if we should use local storage
* This is used when running via the CLI with `npx sim`
* This is used when running via the CLI with `npx simstudio`
*/
// Check if we should use local storage based on environment variable
export const useLocalStorage = () => {
// In client components, check for the environment variable in localStorage
// This is set by the CLI when running with `npx sim`
// This is set by the CLI when running with `npx simstudio`
if (typeof window !== 'undefined') {
return localStorage.getItem('USE_LOCAL_STORAGE') === 'true'
}

1938
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -15,10 +15,10 @@
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"cli:build": "npm run build -w packages/@sim/cli",
"cli:dev": "npm run build -w packages/@sim/cli && cd packages/@sim/cli && node ./dist/index.js",
"cli:publish": "cd packages/@sim/cli && npm publish --access public",
"cli:start": "cd packages/@sim/cli && node ./dist/index.js start",
"cli:build": "npm run build -w packages/@simstudio/cli",
"cli:dev": "npm run build -w packages/@simstudio/cli && cd packages/@simstudio/cli && node ./dist/index.js",
"cli:publish": "cd packages/@simstudio/cli && npm publish --access public",
"cli:start": "cd packages/@simstudio/cli && node ./dist/index.js start",
"build:standalone": "node scripts/build-standalone.js",
"build:cli": "npm run cli:build && npm run build:standalone",
"publish:cli": "npm run build:cli && npm run cli:publish"

View File

@@ -1,4 +0,0 @@
/**
* Help command displays the logo and usage information
*/
export declare function help(): void;

View File

@@ -1,43 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.help = help;
const chalk_1 = __importDefault(require("chalk"));
const logo_1 = require("../utils/logo");
/**
* Help command displays the logo and usage information
*/
function help() {
// Display logo
console.log(logo_1.logo);
// Display help text
console.log(`
${chalk_1.default.bold('USAGE')}
${chalk_1.default.cyan('sim')} Start Sim Studio with default settings
${chalk_1.default.cyan('sim start')} Start Sim Studio with options
${chalk_1.default.cyan('sim version')} Display version information
${chalk_1.default.cyan('sim help')} Show this help information
${chalk_1.default.bold('OPTIONS')}
${chalk_1.default.cyan('-p, --port <port>')} Specify port (default: 3000)
${chalk_1.default.cyan('-d, --debug')} Enable debug mode
${chalk_1.default.cyan('-v, --version')} Show version information
${chalk_1.default.cyan('-h, --help')} Show help information
${chalk_1.default.bold('EXAMPLES')}
${chalk_1.default.gray('# Start with default settings')}
${chalk_1.default.cyan('$ sim')}
${chalk_1.default.gray('# Start on a specific port')}
${chalk_1.default.cyan('$ sim start --port 8080')}
${chalk_1.default.gray('# Start with debug logging')}
${chalk_1.default.cyan('$ sim start --debug')}
${chalk_1.default.bold('DOCUMENTATION')}
${chalk_1.default.gray('For more information:')}
https://github.com/simstudioai/sim
`);
}

View File

@@ -1,9 +0,0 @@
interface StartOptions {
port: string;
debug: boolean;
}
/**
* Start command that launches Sim Studio using local storage
*/
export declare function start(options: StartOptions): Promise<import("child_process").ChildProcess>;
export {};

View File

@@ -1,268 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.start = start;
const chalk_1 = __importDefault(require("chalk"));
const child_process_1 = require("child_process");
const child_process_2 = require("child_process");
const fs_1 = __importDefault(require("fs"));
const fs_2 = require("fs");
const https_1 = __importDefault(require("https"));
const os_1 = __importDefault(require("os"));
const path_1 = __importDefault(require("path"));
const tar_1 = require("tar");
const config_1 = require("../utils/config");
const spinner_1 = require("../utils/spinner");
// Constants for standalone app
const SIM_HOME_DIR = path_1.default.join(os_1.default.homedir(), '.sim-studio');
const SIM_STANDALONE_DIR = path_1.default.join(SIM_HOME_DIR, 'standalone');
const SIM_VERSION_FILE = path_1.default.join(SIM_HOME_DIR, 'version.json');
const DOWNLOAD_URL = 'https://github.com/simstudioai/sim/releases/latest/download/sim-standalone.tar.gz';
const STANDALONE_VERSION = '0.1.0';
/**
* Start command that launches Sim Studio using local storage
*/
async function start(options) {
// Update config with provided options
config_1.config.set('port', options.port);
config_1.config.set('debug', options.debug);
config_1.config.set('lastRun', new Date().toISOString());
const port = options.port || '3000';
const debug = options.debug || false;
// Show starting message
const spinner = (0, spinner_1.createSpinner)(`Starting Sim Studio on port ${port}...`).start();
try {
// Set environment variables for using local storage
const env = {
...process.env,
PORT: port,
USE_LOCAL_STORAGE: 'true', // Key environment variable to switch to local storage
NEXT_PUBLIC_USE_LOCAL_STORAGE: 'true', // For client-side code
DISABLE_DB_SYNC: 'true', // Disable database sync
NODE_ENV: debug ? 'development' : 'production',
DEBUG: debug ? '*' : undefined,
};
// Try to find the main package.json to determine if we're running from within the repo
// or as an installed npm package
const isInProjectDirectory = checkIfInProjectDirectory();
let simProcess;
if (isInProjectDirectory) {
// Running from within the project directory - we'll use the existing
// Next.js setup directly
spinner.text = 'Detected Sim Studio project, starting with local configuration...';
// When running in dev mode, we need to make sure we're not trying to use static export
// as it will fail with API routes
if (debug) {
spinner.text = 'Starting in development mode with local storage...';
simProcess = (0, child_process_1.spawn)('npm', ['run', 'dev'], {
env: env,
stdio: 'inherit',
shell: true,
});
}
else {
// In production mode, we'll use the start command which uses the built app
spinner.text = 'Starting in production mode with local storage...';
// Build first if needed
if (!fs_1.default.existsSync(path_1.default.join(process.cwd(), '.next'))) {
spinner.text = 'Building Next.js app first...';
try {
(0, child_process_2.execSync)('npm run build', {
env: env,
stdio: 'inherit'
});
}
catch (error) {
spinner.fail('Failed to build Next.js app');
console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : error);
process.exit(1);
}
}
simProcess = (0, child_process_1.spawn)('npm', ['run', 'start'], {
env: env,
stdio: 'inherit',
shell: true,
});
}
}
else {
// Running from outside the project via npx - we'll download and start a standalone version
spinner.text = 'Setting up standalone Sim Studio...';
// Create the .sim-studio directory if it doesn't exist
if (!fs_1.default.existsSync(SIM_HOME_DIR)) {
fs_1.default.mkdirSync(SIM_HOME_DIR, { recursive: true });
}
// Check if we already have the standalone version
let needsDownload = true;
if (fs_1.default.existsSync(SIM_VERSION_FILE)) {
try {
const versionInfo = JSON.parse(fs_1.default.readFileSync(SIM_VERSION_FILE, 'utf8'));
if (versionInfo.version === STANDALONE_VERSION) {
needsDownload = false;
}
}
catch (error) {
// If there's an error reading the version file, download again
needsDownload = true;
}
}
// Download and extract if needed
if (needsDownload) {
try {
await downloadStandaloneApp(spinner);
}
catch (error) {
spinner.fail(`Failed to download Sim Studio: ${error instanceof Error ? error.message : String(error)}`);
console.log(`\n${chalk_1.default.yellow('⚠️')} If you're having network issues, you can try:
1. Check your internet connection
2. Try again later
3. Run Sim Studio directly from a cloned repository`);
process.exit(1);
}
}
else {
spinner.text = 'Using cached Sim Studio standalone version...';
}
// Start the standalone app
spinner.text = 'Starting Sim Studio standalone...';
// Make sure the standalone directory exists
if (!fs_1.default.existsSync(SIM_STANDALONE_DIR) ||
!fs_1.default.existsSync(path_1.default.join(SIM_STANDALONE_DIR, 'server.js'))) {
spinner.fail('Standalone app files are missing. Re-run to download again.');
// Force a fresh download next time
if (fs_1.default.existsSync(SIM_VERSION_FILE)) {
fs_1.default.unlinkSync(SIM_VERSION_FILE);
}
process.exit(1);
}
// Start the standalone Node.js server
const standaloneEnv = {
...env,
SIM_STUDIO_PORT: port,
};
simProcess = (0, child_process_1.spawn)('node', ['server.js'], {
cwd: SIM_STANDALONE_DIR,
env: standaloneEnv,
stdio: 'inherit',
shell: true,
});
}
// Successful start
spinner.succeed(`Sim Studio is running on ${chalk_1.default.cyan(`http://localhost:${port}`)}`);
console.log(`
${chalk_1.default.green('✓')} Using local storage mode - your data will be stored in the browser
${chalk_1.default.green('✓')} Any changes will be persisted between sessions through localStorage
${chalk_1.default.yellow('i')} Press ${chalk_1.default.bold('Ctrl+C')} to stop the server
`);
// Handle process termination
process.on('SIGINT', () => {
console.log(`\n${chalk_1.default.yellow('⚠️')} Shutting down Sim Studio...`);
simProcess.kill('SIGINT');
process.exit(0);
});
// Return the process for testing purposes
return simProcess;
}
catch (error) {
spinner.fail('Failed to start Sim Studio');
console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : error);
process.exit(1);
}
}
/**
* Checks if we're running in a Sim Studio project directory
*/
function checkIfInProjectDirectory() {
// Check if we have package.json that looks like a Sim Studio project
try {
const packageJsonPath = path_1.default.join(process.cwd(), 'package.json');
if (fs_1.default.existsSync(packageJsonPath)) {
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
// Check if it looks like our project
if (packageJson.name === 'sim' ||
packageJson.name === 'sim-studio' ||
(packageJson.dependencies &&
(packageJson.dependencies['next'] || packageJson.dependencies['@sim/cli'] || packageJson.dependencies['sim-studio-cli']))) {
return true;
}
}
// Also check for Next.js app files
const nextConfigPath = path_1.default.join(process.cwd(), 'next.config.js');
const nextTsConfigPath = path_1.default.join(process.cwd(), 'next.config.ts');
if (fs_1.default.existsSync(nextConfigPath) || fs_1.default.existsSync(nextTsConfigPath)) {
return true;
}
}
catch (error) {
// If we can't read/parse package.json, assume we're not in a project directory
}
return false;
}
/**
* Downloads and extracts the standalone app
*/
async function downloadStandaloneApp(spinner) {
return new Promise((resolve, reject) => {
// Create temp directory
const tmpDir = path_1.default.join(os_1.default.tmpdir(), `sim-download-${Date.now()}`);
fs_1.default.mkdirSync(tmpDir, { recursive: true });
const tarballPath = path_1.default.join(tmpDir, 'sim-standalone.tar.gz');
const file = (0, fs_2.createWriteStream)(tarballPath);
spinner.text = 'Downloading Sim Studio...';
// Download the tarball
https_1.default
.get(DOWNLOAD_URL, (response) => {
if (response.statusCode !== 200) {
spinner.fail(`Failed to download: ${response.statusCode}`);
return reject(new Error(`Download failed with status code: ${response.statusCode}`));
}
response.pipe(file);
file.on('finish', () => {
file.close();
// Clear the standalone directory if it exists
if (fs_1.default.existsSync(SIM_STANDALONE_DIR)) {
fs_1.default.rmSync(SIM_STANDALONE_DIR, { recursive: true, force: true });
}
// Create the directory
fs_1.default.mkdirSync(SIM_STANDALONE_DIR, { recursive: true });
spinner.text = 'Extracting Sim Studio...';
// Extract the tarball
(0, tar_1.extract)({
file: tarballPath,
cwd: SIM_STANDALONE_DIR,
})
.then(() => {
// Clean up
fs_1.default.rmSync(tmpDir, { recursive: true, force: true });
// Install dependencies if needed
if (fs_1.default.existsSync(path_1.default.join(SIM_STANDALONE_DIR, 'package.json'))) {
spinner.text = 'Installing dependencies...';
try {
(0, child_process_2.execSync)('npm install --production', {
cwd: SIM_STANDALONE_DIR,
stdio: 'ignore',
});
}
catch (error) {
spinner.warn('Error installing dependencies, but trying to continue...');
}
}
// Write version file
fs_1.default.writeFileSync(SIM_VERSION_FILE, JSON.stringify({ version: STANDALONE_VERSION, date: new Date().toISOString() }));
spinner.succeed('Sim Studio downloaded successfully');
resolve();
})
.catch((err) => {
spinner.fail('Failed to extract Sim Studio');
reject(err);
});
});
})
.on('error', (err) => {
spinner.fail('Network error');
reject(err);
});
});
}

View File

@@ -1,4 +0,0 @@
/**
* Version command displays the current version of the CLI
*/
export declare function version(): void;

View File

@@ -1,19 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = version;
const chalk_1 = __importDefault(require("chalk"));
/**
* Version command displays the current version of the CLI
*/
function version() {
const pkg = require('../../package.json');
console.log(`
${chalk_1.default.bold('Sim Studio CLI')} ${chalk_1.default.green(`v${pkg.version}`)}
${chalk_1.default.gray('Platform:')} ${process.platform}
${chalk_1.default.gray('Node Version:')} ${process.version}
${chalk_1.default.gray('CLI Path:')} ${__dirname}
`);
}

View File

@@ -1,2 +0,0 @@
#!/usr/bin/env node
export {};

View File

@@ -1,68 +0,0 @@
#!/usr/bin/env node
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
const commander_1 = require("commander");
const update_notifier_1 = __importDefault(require("update-notifier"));
const help_1 = require("./commands/help");
const start_1 = require("./commands/start");
const version_1 = require("./commands/version");
const config_1 = require("./utils/config");
const logo_1 = require("./utils/logo");
// Package info for version checking
const pkg = require('../package.json');
// Check for updates
(0, update_notifier_1.default)({ pkg }).notify();
// Create program
const program = new commander_1.Command();
// Initialize CLI
async function main() {
// Configure the CLI
program
.name('sim')
.description('Sim Studio CLI')
.version(pkg.version, '-v, --version', 'Output the current version')
.helpOption('-h, --help', 'Display help for command')
.on('--help', () => (0, help_1.help)())
.action(() => {
// Default command (no args) runs start with default options
(0, start_1.start)({ port: config_1.config.get('port'), debug: config_1.config.get('debug') });
});
// Start command
program
.command('start')
.description('Start Sim Studio with local storage')
.option('-p, --port <port>', 'Port to run on', config_1.config.get('port'))
.option('-d, --debug', 'Enable debug mode', config_1.config.get('debug'))
.action((options) => {
(0, start_1.start)(options);
});
// Version command
program
.command('version')
.description('Show detailed version information')
.action(() => {
(0, version_1.version)();
});
// Help command
program
.command('help')
.description('Display help information')
.action(() => {
(0, help_1.help)();
});
// Display logo if not in help mode
if (!process.argv.includes('--help') && !process.argv.includes('-h')) {
console.log(logo_1.logo);
}
// Parse arguments
program.parse(process.argv);
}
// Run the CLI
main().catch((error) => {
console.error(chalk_1.default.red('Error:'), error);
process.exit(1);
});

View File

@@ -1,8 +0,0 @@
import Conf from 'conf';
interface ConfigSchema {
port: string;
debug: boolean;
lastRun: string;
}
export declare const config: Conf<ConfigSchema>;
export {};

View File

@@ -1,16 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.config = void 0;
const conf_1 = __importDefault(require("conf"));
// Create a config instance with default values
exports.config = new conf_1.default({
projectName: 'sim-studio',
defaults: {
port: '3000',
debug: false,
lastRun: new Date().toISOString(),
},
});

View File

@@ -1,4 +0,0 @@
/**
* ASCII art logo for Sim Studio
*/
export declare const logo: string;

View File

@@ -1,22 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.logo = void 0;
const chalk_1 = __importDefault(require("chalk"));
/**
* ASCII art logo for Sim Studio
*/
exports.logo = `
${chalk_1.default.bold(chalk_1.default.magenta(`
███████╗██╗███╗ ███╗ ███████╗████████╗██╗ ██╗██████╗ ██╗ ██████╗
██╔════╝██║████╗ ████║ ██╔════╝╚══██╔══╝██║ ██║██╔══██╗██║██╔═══██╗
███████╗██║██╔████╔██║ ███████╗ ██║ ██║ ██║██║ ██║██║██║ ██║
╚════██║██║██║╚██╔╝██║ ╚════██║ ██║ ██║ ██║██║ ██║██║██║ ██║
███████║██║██║ ╚═╝ ██║ ███████║ ██║ ╚██████╔╝██████╔╝██║╚██████╔╝
╚══════╝╚═╝╚═╝ ╚═╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝
`))}
${chalk_1.default.cyan('Build, optimize, and test agent workflows with a powerful visual interface')}
`;

View File

@@ -1,52 +0,0 @@
/**
* A simple spinner implementation that doesn't rely on external packages
*/
export declare class SimpleSpinner {
private interval;
private frames;
private frameIndex;
private isSpinning;
private lastOutput;
private _text;
constructor(text?: string);
/**
* Start the spinner
*/
start(text?: string): SimpleSpinner;
/**
* Stop the spinner
*/
stop(): SimpleSpinner;
/**
* Update the spinner text
*/
set text(value: string);
/**
* Get the spinner text
*/
get text(): string;
/**
* Show a success message
*/
succeed(text?: string): SimpleSpinner;
/**
* Show a failure message
*/
fail(text?: string): SimpleSpinner;
/**
* Show a warning message
*/
warn(text?: string): SimpleSpinner;
/**
* Show an info message
*/
info(text?: string): SimpleSpinner;
/**
* Stop the spinner and show a symbol with text
*/
private stopWithSymbol;
}
/**
* Create a new spinner
*/
export declare function createSpinner(text?: string): SimpleSpinner;

View File

@@ -1,110 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SimpleSpinner = void 0;
exports.createSpinner = createSpinner;
const chalk_1 = __importDefault(require("chalk"));
/**
* A simple spinner implementation that doesn't rely on external packages
*/
class SimpleSpinner {
constructor(text = '') {
this.interval = null;
this.frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
this.frameIndex = 0;
this.isSpinning = false;
this.lastOutput = '';
this._text = '';
this._text = text;
}
/**
* Start the spinner
*/
start(text) {
if (text) {
this._text = text;
}
if (!this.isSpinning) {
this.isSpinning = true;
this.frameIndex = 0;
// Clear any previous output
if (this.lastOutput) {
process.stdout.write('\r' + ' '.repeat(this.lastOutput.length) + '\r');
}
this.interval = setInterval(() => {
const frame = this.frames[this.frameIndex];
const output = `${chalk_1.default.cyan(frame)} ${this._text}`;
process.stdout.write('\r' + output);
this.lastOutput = output;
this.frameIndex = (this.frameIndex + 1) % this.frames.length;
}, 80);
}
return this;
}
/**
* Stop the spinner
*/
stop() {
if (this.isSpinning && this.interval) {
clearInterval(this.interval);
this.interval = null;
this.isSpinning = false;
// Clear the spinner line
process.stdout.write('\r' + ' '.repeat(this.lastOutput.length) + '\r');
}
return this;
}
/**
* Update the spinner text
*/
set text(value) {
this._text = value;
}
/**
* Get the spinner text
*/
get text() {
return this._text;
}
/**
* Show a success message
*/
succeed(text) {
return this.stopWithSymbol(chalk_1.default.green('✓'), text || this._text);
}
/**
* Show a failure message
*/
fail(text) {
return this.stopWithSymbol(chalk_1.default.red('✗'), text || this._text);
}
/**
* Show a warning message
*/
warn(text) {
return this.stopWithSymbol(chalk_1.default.yellow('⚠'), text || this._text);
}
/**
* Show an info message
*/
info(text) {
return this.stopWithSymbol(chalk_1.default.blue(''), text || this._text);
}
/**
* Stop the spinner and show a symbol with text
*/
stopWithSymbol(symbol, text) {
this.stop();
console.log(`${symbol} ${text}`);
return this;
}
}
exports.SimpleSpinner = SimpleSpinner;
/**
* Create a new spinner
*/
function createSpinner(text) {
return new SimpleSpinner(text);
}

2547
packages/@simstudio/cli/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
{
"name": "simstudio",
"name": "@simstudio/cli",
"version": "0.1.0",
"description": "CLI tool for Sim Studio - easily start, build and test agent workflows",
"license": "MIT",

View File

@@ -11,10 +11,10 @@ export function help() {
// Display help text
console.log(`
${chalk.bold('USAGE')}
${chalk.cyan('sim')} Start Sim Studio with default settings
${chalk.cyan('sim start')} Start Sim Studio with options
${chalk.cyan('sim version')} Display version information
${chalk.cyan('sim help')} Show this help information
${chalk.cyan('simstudio')} Start Sim Studio with default settings
${chalk.cyan('simstudio start')} Start Sim Studio with options
${chalk.cyan('simstudio version')} Display version information
${chalk.cyan('simstudio help')} Show this help information
${chalk.bold('OPTIONS')}
${chalk.cyan('-p, --port <port>')} Specify port (default: 3000)
@@ -24,13 +24,13 @@ ${chalk.bold('OPTIONS')}
${chalk.bold('EXAMPLES')}
${chalk.gray('# Start with default settings')}
${chalk.cyan('$ sim')}
${chalk.cyan('$ simstudio')}
${chalk.gray('# Start on a specific port')}
${chalk.cyan('$ sim start --port 8080')}
${chalk.cyan('$ simstudio start --port 8080')}
${chalk.gray('# Start with debug logging')}
${chalk.cyan('$ sim start --debug')}
${chalk.cyan('$ simstudio start --debug')}
${chalk.bold('DOCUMENTATION')}
${chalk.gray('For more information:')}

View File

@@ -208,7 +208,7 @@ function checkIfInProjectDirectory(): boolean {
packageJson.name === 'sim-studio' ||
(packageJson.dependencies &&
(packageJson.dependencies['next'] ||
packageJson.dependencies['@sim/cli'] ||
packageJson.dependencies['@simstudio/cli'] ||
packageJson.dependencies['sim-studio-cli']))
) {
return true

View File

@@ -21,7 +21,7 @@ const program = new Command()
async function main() {
// Configure the CLI
program
.name('sim')
.name('simstudio')
.description('Sim Studio CLI')
.version(pkg.version, '-v, --version', 'Output the current version')
.helpOption('-h, --help', 'Display help for command')

View File

@@ -18,7 +18,7 @@ const crypto = require('crypto')
// Configuration
const ROOT_DIR = path.resolve(__dirname, '..')
const STANDALONE_DIR = path.join(ROOT_DIR, 'packages/@sim/cli/standalone')
const STANDALONE_DIR = path.join(ROOT_DIR, 'packages/@simstudio/cli/standalone')
const STANDALONE_PACKAGE_JSON = path.join(STANDALONE_DIR, 'package.json')
const STANDALONE_SERVER_JS = path.join(STANDALONE_DIR, 'server.js')
const OUTPUT_TARBALL = path.join(ROOT_DIR, 'sim-standalone.tar.gz')

View File

@@ -13,7 +13,7 @@ const { execSync } = require('child_process')
// Configuration
const ROOT_DIR = path.resolve(__dirname, '..')
const CLI_DIR = path.join(ROOT_DIR, 'packages/@sim/cli')
const CLI_DIR = path.join(ROOT_DIR, 'packages/@simstudio/cli')
const STANDALONE_DIR = path.join(CLI_DIR, 'standalone')
const OUTPUT_TARBALL = path.join(ROOT_DIR, 'sim-standalone.tar.gz')

View File

@@ -5,12 +5,12 @@ set -e
echo "Setting up Sim Studio CLI Package..."
# Create directory structure if it doesn't exist
mkdir -p packages/@sim/cli/bin
mkdir -p packages/@sim/cli/src/commands
mkdir -p packages/@sim/cli/src/utils
mkdir -p packages/@simstudio/cli/bin
mkdir -p packages/@simstudio/cli/src/commands
mkdir -p packages/@simstudio/cli/src/utils
# Navigate to CLI directory
cd packages/@sim/cli
cd packages/@simstudio/cli
# Install dependencies
echo "Installing CLI dependencies..."
@@ -30,4 +30,4 @@ echo " npm run cli:start - to test the CLI"
echo " npm run cli:dev - to develop the CLI with live reload"
echo " npm run cli:publish - to publish to npm"
echo ""
echo "Try it out with: ./packages/@sim/cli/bin/sim.js"
echo "Try it out with: ./packages/@simstudio/cli/bin/sim.js"