myaidev-method
Version:
Comprehensive development framework with SPARC methodology for AI-assisted software development, multi-platform publishing (WordPress, PayloadCMS, Astro, Docusaurus, Mintlify), and Coolify deployment
474 lines (388 loc) ⢠17.8 kB
JavaScript
#!/usr/bin/env node
import { program } from 'commander';
import chalk from 'chalk';
import ora from 'ora';
import fs from 'fs-extra';
import path from 'path';
import { fileURLToPath } from 'url';
import inquirer from 'inquirer';
import { getASCIIBanner, getSPARCBreakdown, getInitSuccessMessage } from '../src/lib/ascii-banner.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
program
.version('0.2.5')
.description('MyAIDev Method - Comprehensive development framework with SPARC methodology');
program
.command('init')
.description('Initialize AI CLI configuration in current project')
.option('--claude', 'Initialize for Claude Code')
.option('--gemini', 'Initialize for Gemini CLI')
.option('--codex', 'Initialize for Codex CLI')
.action(async (options) => {
const spinner = ora('Initializing AI CLI configuration...').start();
try {
const cwd = process.cwd();
let cliType = null;
// Determine CLI type
if (options.claude) {
cliType = 'claude';
} else if (options.gemini) {
cliType = 'gemini';
} else if (options.codex) {
cliType = 'codex';
} else {
spinner.stop();
// Interactive selection if no flag provided
const answer = await inquirer.prompt([
{
type: 'list',
name: 'cliType',
message: 'Which AI CLI are you configuring for?',
choices: [
{ name: 'Claude Code', value: 'claude' },
{ name: 'Gemini CLI', value: 'gemini' },
{ name: 'Codex CLI', value: 'codex' }
]
}
]);
cliType = answer.cliType;
spinner.start();
}
if (cliType === 'claude') {
// Create Claude Code standard structure
await setupClaude(cwd);
} else if (cliType === 'gemini') {
await setupGemini(cwd);
} else if (cliType === 'codex') {
await setupCodex(cwd);
}
spinner.succeed(chalk.green(`Successfully initialized ${cliType} configuration!`));
// Display ASCII banner and SPARC methodology
console.log(getASCIIBanner());
console.log(getSPARCBreakdown());
console.log(getInitSuccessMessage(cliType));
if (cliType === 'claude') {
console.log(chalk.green('\nšļø SPARC Development Workflow (Systematic Software Development):'));
console.log(chalk.gray(' ⢠Complete: /myai-sparc-workflow "Build authentication system"'));
console.log(chalk.gray(' ⢠Architecture: /myai-dev-architect "Design microservices"'));
console.log(chalk.gray(' ⢠Code: /myai-dev-code "Implement user service"'));
console.log(chalk.gray(' ⢠Test: /myai-dev-test "Test authentication"'));
console.log(chalk.gray(' ⢠Review: /myai-dev-review "Security audit"'));
console.log(chalk.gray(' ⢠Document: /myai-dev-docs "API documentation"'));
console.log(chalk.green('\n⨠Content creation:'));
console.log(chalk.gray(' /myai-content-writer "Your Article Topic"'));
console.log(chalk.yellow('\nš¤ Publish to multiple platforms:'));
console.log(chalk.gray(' ⢠WordPress: /myai-wordpress-publish "article.md"'));
console.log(chalk.gray(' ⢠PayloadCMS: /myai-payloadcms-publish "article.md"'));
console.log(chalk.gray(' ⢠Docusaurus: /myai-docusaurus-publish "guide.md"'));
console.log(chalk.gray(' ⢠Mintlify: /myai-mintlify-publish "docs.mdx"'));
console.log(chalk.gray(' ⢠Astro: /myai-astro-publish "post.md"'));
console.log(chalk.blue('\nš Git & CI/CD Workflow:'));
console.log(chalk.gray(' ⢠Pull Requests: /myai-git-pr "Add user feature"'));
console.log(chalk.gray(' ⢠Releases: /myai-git-release'));
console.log(chalk.gray(' ⢠Sync Branches: /myai-git-sync'));
console.log(chalk.gray(' ⢠Hotfixes: /myai-git-hotfix'));
console.log(chalk.gray(' ⢠Deploy Dev: /myai-deploy-dev'));
console.log(chalk.gray(' ⢠Deploy Staging: /myai-deploy-staging'));
console.log(chalk.gray(' ⢠Deploy Prod: /myai-deploy-prod'));
console.log(chalk.cyan('\nāļø Configure platforms:'));
console.log(chalk.gray(' ⢠Run /myai-configure for guided setup'));
console.log(chalk.gray(' ⢠Edit .env for manual configuration'));
console.log(chalk.magenta('\nš Documentation copied to your project:'));
console.log(chalk.gray(' ⢠USER_GUIDE.md - Getting started and customization'));
console.log(chalk.gray(' ⢠DEV_WORKFLOW_GUIDE.md - SPARC methodology guide'));
console.log(chalk.gray(' ⢠MCP_INTEGRATION.md - MCP server setup and usage'));
console.log(chalk.gray(' ⢠PUBLISHING_GUIDE.md - Multi-platform publishing'));
console.log(chalk.gray(' ⢠COOLIFY_DEPLOYMENT.md - Application deployment'));
console.log(chalk.gray(' ⢠WORDPRESS_ADMIN_SCRIPTS.md - WordPress utilities'));
console.log(chalk.magenta('\nš§ MCP Server Integration (Optional Advanced Features):'));
console.log(chalk.gray(' ⢠SPARC Orchestrator: Workflow automation with MCP tools'));
console.log(chalk.gray(' ⢠Chrome DevTools: Browser testing and debugging'));
console.log(chalk.gray(' ⢠WordPress MCP: Enhanced WordPress API operations'));
console.log(chalk.magenta('\nš” Quick tips:'));
console.log(chalk.gray(' ⢠SPARC workflow: Architecture ā Code ā Test ā Review ā Docs'));
console.log(chalk.gray(' ⢠All platforms support draft/published workflows'));
console.log(chalk.gray(' ⢠Git-based platforms (Docusaurus, Mintlify, Astro) auto-commit'));
console.log(chalk.gray(' ⢠MCP servers provide advanced orchestration and testing'));
console.log(chalk.gray(' ⢠Visit: https://github.com/myaione/myaidev-method'));
}
console.log(chalk.cyan(`\nš Restart ${cliType} to load your new AI-powered commands!`));
} catch (error) {
spinner.fail(chalk.red('Failed to initialize configuration'));
console.error(error);
process.exit(1);
}
});
async function setupClaude(projectDir) {
// Create .claude directory structure following Claude Code standards
const claudeDir = path.join(projectDir, '.claude');
const commandsDir = path.join(claudeDir, 'commands');
const agentsDir = path.join(claudeDir, 'agents');
const mcpDir = path.join(claudeDir, 'mcp');
// Ensure directories exist
await fs.ensureDir(commandsDir);
await fs.ensureDir(agentsDir);
await fs.ensureDir(mcpDir);
// Copy command markdown files
const templateCommandsDir = path.join(__dirname, '..', 'src', 'templates', 'claude', 'commands');
if (await fs.pathExists(templateCommandsDir)) {
const commandFiles = await fs.readdir(templateCommandsDir);
for (const file of commandFiles) {
if (file.endsWith('.md')) {
await fs.copy(
path.join(templateCommandsDir, file),
path.join(commandsDir, file)
);
}
}
}
// Copy agent markdown files
const templateAgentsDir = path.join(__dirname, '..', 'src', 'templates', 'claude', 'agents');
if (await fs.pathExists(templateAgentsDir)) {
const agentFiles = await fs.readdir(templateAgentsDir);
for (const file of agentFiles) {
if (file.endsWith('.md')) {
await fs.copy(
path.join(templateAgentsDir, file),
path.join(agentsDir, file)
);
}
}
}
// Copy MCP server files
const templateMcpDir = path.join(__dirname, '..', '.claude', 'mcp');
if (await fs.pathExists(templateMcpDir)) {
const mcpFiles = await fs.readdir(templateMcpDir);
for (const file of mcpFiles) {
if (file.endsWith('.js') || file.endsWith('.json')) {
await fs.copy(
path.join(templateMcpDir, file),
path.join(mcpDir, file)
);
}
}
}
// Create CLAUDE.md configuration file
const claudeMd = `# Claude Code Configuration
This project uses the MyAIDev Method package for enhanced AI-assisted development.
## Available Commands
### SPARC Development Workflow (Systematic Software Development)
- \`/myai-sparc-workflow\` - Complete 5-phase SPARC workflow
- \`/myai-dev-architect\` - Design system architecture (Phase 1)
- \`/myai-dev-code\` - Implement features with SOLID principles (Phase 2)
- \`/myai-dev-test\` - Create comprehensive tests (Phase 3)
- \`/myai-dev-review\` - Code quality and security review (Phase 4)
- \`/myai-dev-docs\` - Generate documentation (Phase 5)
### Content Creation
- \`/myai-content-writer\` - Create SEO-optimized content
### Publishing Platforms
- \`/myai-wordpress-publish\` - Publish to WordPress
- \`/myai-payloadcms-publish\` - Publish to PayloadCMS
- \`/myai-docusaurus-publish\` - Publish to Docusaurus
- \`/myai-mintlify-publish\` - Publish to Mintlify
- \`/myai-astro-publish\` - Publish to Astro
### Deployment
- \`/myai-coolify-deploy\` - Deploy to Coolify
### Administration
- \`/myai-wordpress-admin\` - WordPress administration and security
- \`/myai-configure\` - Configure settings
## Available Agents
### Development Agents (SPARC Methodology)
- \`dev-architect\` - System architecture and design agent
- \`dev-coder\` - Code implementation agent with SOLID principles
- \`dev-tester\` - Testing and quality assurance agent
- \`dev-reviewer\` - Code review and security analysis agent
- \`dev-documenter\` - Technical documentation agent
### Content & Publishing Agents
- \`content-writer\` - Professional content creation agent
- \`wordpress-admin\` - WordPress administration and security agent
- \`payloadcms-publish\` - PayloadCMS publishing agent
- \`docusaurus-publish\` - Docusaurus publishing agent
- \`mintlify-publish\` - Mintlify publishing agent
- \`astro-publish\` - Astro publishing agent
### Deployment Agents
- \`coolify-deploy\` - Coolify deployment agent
## Platform Configuration
To use publishing features, configure your platforms in \`.env\`:
\`\`\`bash
# WordPress (API-based)
WORDPRESS_URL=https://your-site.com
WORDPRESS_USERNAME=your-username
WORDPRESS_APP_PASSWORD=your-app-password
# PayloadCMS (API-based)
PAYLOADCMS_URL=https://cms.your-site.com
PAYLOADCMS_EMAIL=your-email@example.com
PAYLOADCMS_PASSWORD=your-password
# Git Configuration (for static sites)
GIT_USER_NAME=Your Name
GIT_USER_EMAIL=your-email@example.com
# Static Site Project Paths (optional)
DOCUSAURUS_PROJECT_PATH=./docs
MINTLIFY_PROJECT_PATH=./docs
ASTRO_PROJECT_PATH=./blog
# Coolify Deployment
COOLIFY_URL=https://coolify.your-server.com
COOLIFY_API_KEY=your-api-key
\`\`\`
## Documentation
- **USER_GUIDE.md** - Getting started and customization
- **PUBLISHING_GUIDE.md** - Comprehensive multi-platform publishing guide
- **COOLIFY_DEPLOYMENT.md** - Application deployment guide
- **WORDPRESS_ADMIN_SCRIPTS.md** - WordPress admin utilities
- **TECHNICAL_ARCHITECTURE.md** - Developer and architecture guide
## Project Conventions
- All custom commands are in \`.claude/commands/\`
- All agents are in \`.claude/agents/\`
- Commands and agents use Markdown format with YAML frontmatter
## Notes
This configuration follows Claude Code's official standards for custom commands and agents.
`;
await fs.writeFile(path.join(claudeDir, 'CLAUDE.md'), claudeMd);
// Copy the comprehensive .env.example from package
const sourceEnvExample = path.join(__dirname, '..', '.env.example');
if (await fs.pathExists(sourceEnvExample)) {
await fs.copy(sourceEnvExample, path.join(projectDir, '.env.example'));
}
// Note: MCP integration disabled for now - using native tools for WordPress REST API
// Copy documentation files to project root
const docsToMerge = [
'USER_GUIDE.md',
'DEV_WORKFLOW_GUIDE.md',
'MCP_INTEGRATION.md',
'PUBLISHING_GUIDE.md',
'COOLIFY_DEPLOYMENT.md',
'WORDPRESS_ADMIN_SCRIPTS.md',
'TECHNICAL_ARCHITECTURE.md'
];
for (const docFile of docsToMerge) {
const sourcePath = path.join(__dirname, '..', docFile);
if (await fs.pathExists(sourcePath)) {
await fs.copy(sourcePath, path.join(projectDir, docFile));
}
}
}
async function setupGemini(projectDir) {
// Setup Gemini-specific configuration
const geminiDir = path.join(projectDir, '.gemini');
const commandsDir = path.join(geminiDir, 'commands');
await fs.ensureDir(commandsDir);
// Copy all Gemini command files (.toml format)
const templateCommandsDir = path.join(__dirname, '..', 'src', 'templates', 'gemini', 'commands');
if (await fs.pathExists(templateCommandsDir)) {
const commandFiles = await fs.readdir(templateCommandsDir);
for (const file of commandFiles) {
if (file.endsWith('.toml')) {
await fs.copy(
path.join(templateCommandsDir, file),
path.join(commandsDir, file)
);
}
}
}
// Create Gemini README
const geminiReadme = `# Gemini CLI Configuration
This project uses the MyAIDev Method package for AI-assisted development with Gemini.
## Available Commands
All commands are located in \`.gemini/commands/\` and use TOML format.
### SPARC Development Workflow
- \`/myai-sparc-workflow\` - Complete 5-phase SPARC workflow
- \`/myai-dev-architect\` - Design system architecture
- \`/myai-dev-code\` - Implement features with SOLID principles
- \`/myai-dev-test\` - Create comprehensive tests
- \`/myai-dev-review\` - Code quality and security review
- \`/myai-dev-docs\` - Generate documentation
### Git & CI/CD Workflow
- \`/myai-git-pr\` - Create and manage GitHub Pull Requests
- \`/myai-git-release\` - Create releases with semantic versioning
- \`/myai-git-sync\` - Sync and manage branches
- \`/myai-git-hotfix\` - Create and deploy emergency hotfixes
- \`/myai-deploy-dev\` - Deploy to development environment
- \`/myai-deploy-staging\` - Deploy to staging environment
- \`/myai-deploy-prod\` - Deploy to production environment
### Content & Publishing
- \`/myai-content-writer\` - Create SEO-optimized content
- \`/myai-wordpress-publish\` - Publish to WordPress
- \`/myai-payloadcms-publish\` - Publish to PayloadCMS
- \`/myai-docusaurus-publish\` - Publish to Docusaurus
- \`/myai-mintlify-publish\` - Publish to Mintlify
- \`/myai-astro-publish\` - Publish to Astro
### Administration
- \`/myai-coolify-deploy\` - Deploy to Coolify
- \`/myai-wordpress-admin\` - WordPress administration
- \`/myai-configure\` - Configure settings
## Usage
\`\`\`bash
# Execute a command with arguments
/myai-dev-architect "Design authentication system"
/myai-git-pr "Add user profile feature"
/myai-deploy-staging
# Commands support the {{args}} placeholder
\`\`\`
## Documentation
For full documentation, see the USER_GUIDE.md in your project root.
`;
await fs.writeFile(path.join(geminiDir, 'README.md'), geminiReadme);
}
async function setupCodex(projectDir) {
// Setup Codex/OpenCode-specific configuration
const codexDir = path.join(projectDir, '.opencode');
const commandsDir = path.join(codexDir, 'commands');
await fs.ensureDir(commandsDir);
// Copy all Codex/OpenCode command files (.md format)
const templateCommandsDir = path.join(__dirname, '..', 'src', 'templates', 'codex', 'commands');
if (await fs.pathExists(templateCommandsDir)) {
const commandFiles = await fs.readdir(templateCommandsDir);
for (const file of commandFiles) {
if (file.endsWith('.md')) {
await fs.copy(
path.join(templateCommandsDir, file),
path.join(commandsDir, file)
);
}
}
}
// Create OpenCode README
const opencodeReadme = `# OpenCode Configuration
This project uses the MyAIDev Method package for AI-assisted development with OpenCode.
## Available Commands
All commands are located in \`.opencode/commands/\` and use Markdown format.
### SPARC Development Workflow
- \`/myai-sparc-workflow\` - Complete 5-phase SPARC workflow
- \`/myai-dev-architect\` - Design system architecture
- \`/myai-dev-code\` - Implement features with SOLID principles
- \`/myai-dev-test\` - Create comprehensive tests
- \`/myai-dev-review\` - Code quality and security review
- \`/myai-dev-docs\` - Generate documentation
### Git & CI/CD Workflow
- \`/myai-git-pr\` - Create and manage GitHub Pull Requests
- \`/myai-git-release\` - Create releases with semantic versioning
- \`/myai-git-sync\` - Sync and manage branches
- \`/myai-git-hotfix\` - Create and deploy emergency hotfixes
- \`/myai-deploy-dev\` - Deploy to development environment
- \`/myai-deploy-staging\` - Deploy to staging environment
- \`/myai-deploy-prod\` - Deploy to production environment
### Content & Publishing
- \`/myai-content-writer\` - Create SEO-optimized content
- \`/myai-wordpress-publish\` - Publish to WordPress
- \`/myai-payloadcms-publish\` - Publish to PayloadCMS
- \`/myai-docusaurus-publish\` - Publish to Docusaurus
- \`/myai-mintlify-publish\` - Publish to Mintlify
- \`/myai-astro-publish\` - Publish to Astro
### Administration
- \`/myai-coolify-deploy\` - Deploy to Coolify
- \`/myai-wordpress-admin\` - WordPress administration
- \`/myai-configure\` - Configure settings
## Usage
\`\`\`bash
# Execute a command with arguments
/myai-dev-architect "Design authentication system"
/myai-git-pr "Add user profile feature"
/myai-deploy-staging
# Commands support the $ARGUMENTS placeholder
\`\`\`
## Documentation
For full documentation, see the USER_GUIDE.md in your project root.
`;
await fs.writeFile(path.join(codexDir, 'README.md'), opencodeReadme);
}
program.parse(process.argv);