prompt-version-manager
Version:
Centralized prompt management system for Human Behavior AI agents
86 lines (71 loc) ⢠2.74 kB
JavaScript
/**
* Setup script for TypeScript projects using PVM
* Run this after installing PVM to set up all dependencies
*/
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
console.log('\nš Setting up PVM for TypeScript...\n');
const dependencies = [
'openai@^5.0.0',
'@anthropic-ai/sdk@^0.57.0',
'@google/generative-ai@^0.24.0',
'dotenv',
'crypto-js'
];
const devDependencies = [
'tsx',
'typescript@^5.0.0',
'@types/node@^20.0.0',
'@types/crypto-js'
];
try {
// Install dependencies
console.log('š¦ Installing AI provider dependencies...');
execSync(`npm install ${dependencies.join(' ')}`, { stdio: 'inherit' });
console.log('\nš¦ Installing TypeScript development dependencies...');
execSync(`npm install -D ${devDependencies.join(' ')}`, { stdio: 'inherit' });
// Create .env template if it doesn't exist
const envPath = path.join(process.cwd(), '.env');
if (!fs.existsSync(envPath)) {
console.log('\nš Creating .env template...');
const envTemplate = `# AI Provider API Keys
# Get your keys from:
# - OpenAI: https://platform.openai.com/api-keys
# - Anthropic: https://console.anthropic.com/
# - Google: https://makersuite.google.com/app/apikey
OPENAI_API_KEY=your-openai-key-here
ANTHROPIC_API_KEY=your-anthropic-key-here
GOOGLE_API_KEY=your-google-key-here
`;
fs.writeFileSync(envPath, envTemplate);
console.log('ā
Created .env file - add your API keys!');
} else {
console.log('\nā
Found existing .env file - keeping your configuration');
}
// Update package.json scripts
const packageJsonPath = path.join(process.cwd(), 'package.json');
if (fs.existsSync(packageJsonPath)) {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
if (!packageJson.scripts) {
packageJson.scripts = {};
}
// Add helpful scripts
packageJson.scripts['example'] = 'tsx example.ts';
packageJson.scripts['dev'] = 'tsx --watch';
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
console.log('\nā
Added npm scripts: "npm run example" and "npm run dev"');
}
console.log('\n⨠TypeScript setup complete!\n');
console.log('Next steps:');
console.log('1. Add your API keys to .env');
console.log('2. Run "pvm init" if you haven\'t already');
console.log('3. Run "npm run example" to test your setup\n');
} catch (error) {
console.error('\nā Setup failed:', error.message);
console.error('\nYou can manually install dependencies:');
console.error(`npm install ${dependencies.join(' ')}`);
console.error(`npm install -D ${devDependencies.join(' ')}`);
process.exit(1);
}