myaidev-method 0.2.10 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,164 @@
1
+ # Changelog
2
+
3
+ All notable changes to the MyAIDev Method package will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.2.12] - 2025-11-10
9
+
10
+ ### Added
11
+ - **Update Command**: `npx myaidev-method@latest update` for intelligent component updates
12
+ - Interactive conflict resolution for modified files
13
+ - Automatic backup creation before updates
14
+ - Dry-run mode to preview changes
15
+ - Force mode for clean updates
16
+ - Version tracking with `.claude/.myaidev-version`
17
+ - Updates all components: commands, agents, scripts, libs, docs, MCP configs
18
+ - Comprehensive update documentation in USER_GUIDE.md
19
+ - Update instructions in README.md
20
+ - CHANGELOG.md for version history tracking
21
+
22
+ ### Changed
23
+ - Init command now saves installation version for update tracking
24
+ - Enhanced documentation with update best practices
25
+
26
+ ## [0.2.11] - 2025-11-10
27
+
28
+ ### Fixed
29
+ - Script installation for non-Node.js projects
30
+ - Scripts now installed to `.myaidev-method/` with self-contained dependencies
31
+ - No longer requires Node.js project structure (package.json in root)
32
+ - Works in any project type (WordPress themes, Hugo sites, plain folders)
33
+ - Agent documentation updated to reference `.myaidev-method/` paths
34
+
35
+ ### Changed
36
+ - Scripts copied to `.myaidev-method/scripts/` directory
37
+ - Libraries copied to `.myaidev-method/lib/` directory
38
+ - Dependencies installed locally in `.myaidev-method/node_modules/`
39
+ - Added `.gitignore` guidance in CLAUDE.md template
40
+
41
+ ## [0.2.10] - 2025-11-06
42
+
43
+ ### Changed
44
+ - ⚠️ **Deprecated approach**: Attempted node_modules path (reverted in v0.2.11)
45
+
46
+ ## [0.2.9] - 2025-11-06
47
+
48
+ ### Added
49
+ - User Pathways section in USER_GUIDE.md
50
+ - Content Creator pathway with complete publishing pipeline
51
+ - Developer pathway with SPARC methodology guidance
52
+ - End-to-end workflow examples
53
+
54
+ ### Changed
55
+ - Enhanced documentation structure
56
+ - Improved onboarding experience
57
+
58
+ ## [0.2.8] - 2025-11-06
59
+
60
+ ### Changed
61
+ - Package documentation distribution updates
62
+ - Fixed package.json files array
63
+
64
+ ## [0.2.7] - 2025-11-06
65
+
66
+ ### Added
67
+ - Comprehensive content creation pipeline examples
68
+ - Multi-platform publishing workflows
69
+
70
+ ## [0.2.6] - 2025-11-05
71
+
72
+ ### Changed
73
+ - Documentation updates and improvements
74
+
75
+ ## [0.2.5] - 2025-11-04
76
+
77
+ ### Added
78
+ - PayloadCMS authentication simplification
79
+ - JWT-based authentication for PayloadCMS
80
+ - Improved publishing workflows
81
+
82
+ ## [0.2.4] - 2025-11-03
83
+
84
+ ### Added
85
+ - Slash command fixes and improvements
86
+ - 14 command updates with proper Task tool invocations
87
+
88
+ ## [0.2.3] - 2025-11-02
89
+
90
+ ### Added
91
+ - Enhanced MCP server integration
92
+ - SPARC orchestrator improvements
93
+
94
+ ## [0.2.2] - 2025-11-01
95
+
96
+ ### Added
97
+ - WordPress admin utilities
98
+ - Security scanning scripts
99
+ - Performance checking tools
100
+
101
+ ## [0.2.1] - 2025-10-31
102
+
103
+ ### Added
104
+ - Coolify deployment integration
105
+ - Multi-platform publishing support
106
+
107
+ ## [0.2.0] - 2025-10-30
108
+
109
+ ### Added
110
+ - SPARC methodology implementation
111
+ - Development workflow agents
112
+ - Git & CI/CD workflows
113
+
114
+ ## [0.1.0] - 2025-10-29
115
+
116
+ ### Added
117
+ - Initial release
118
+ - Content writer agent
119
+ - WordPress publishing integration
120
+ - Basic slash commands
121
+ - MCP server foundation
122
+
123
+ ---
124
+
125
+ ## Release Notes
126
+
127
+ ### Version 0.2.12 Highlights
128
+
129
+ **Major Feature: Update Command**
130
+
131
+ The highlight of this release is the new intelligent update system. Users can now easily keep their MyAIDev Method installation current while preserving customizations:
132
+
133
+ ```bash
134
+ npx myaidev-method@latest update --claude
135
+ ```
136
+
137
+ Key features:
138
+ - Interactive conflict resolution - choose what to update
139
+ - Automatic backups - safe rollback if needed
140
+ - Dry-run mode - preview changes first
141
+ - Version tracking - know what version you're running
142
+
143
+ This solves a major pain point where users had to manually track updates or risk losing customizations by re-running init.
144
+
145
+ ### Migration Guide
146
+
147
+ **From v0.2.10 or earlier to v0.2.12**:
148
+
149
+ 1. Your scripts are now in `.myaidev-method/` instead of `node_modules/`
150
+ 2. If you have any custom scripts referencing the old path, update them
151
+ 3. Add `.myaidev-method/node_modules/` to your `.gitignore`
152
+ 4. Use the new update command going forward instead of re-running init
153
+
154
+ **Checking Your Version**:
155
+ ```bash
156
+ cat .claude/.myaidev-version
157
+ ```
158
+
159
+ **First-Time Update Setup**:
160
+ If you installed before v0.2.12, the version file won't exist. The update command will still work, but it won't know your current version. Consider it an upgrade from "unknown" to v0.2.12.
161
+
162
+ ---
163
+
164
+ For more details on any release, see the [commit history](https://github.com/myaione/myaidev-method/commits/master) or [release notes](https://github.com/myaione/myaidev-method/releases).
package/README.md CHANGED
@@ -29,6 +29,7 @@ The **MyAIDev Method** is a complete development framework for AI CLI tools (Cla
29
29
  - [Features](#features)
30
30
  - [Installation](#installation)
31
31
  - [Quick Start](#quick-start)
32
+ - [Updating](#updating)
32
33
  - [SPARC Development Workflow](#sparc-development-workflow)
33
34
  - [Development Agents](#development-agents)
34
35
  - [Content & Publishing Agents](#content--publishing-agents)
@@ -134,6 +135,30 @@ npx myaidev-method@latest init
134
135
  /myai-wordpress-admin health-check
135
136
  ```
136
137
 
138
+ ## 🔄 Updating
139
+
140
+ Keep your MyAIDev Method installation up to date with the latest features and bug fixes:
141
+
142
+ ```bash
143
+ # Interactive update (recommended) - prompts for conflicts
144
+ npx myaidev-method@latest update --claude
145
+
146
+ # Force update - overwrites all files
147
+ npx myaidev-method@latest update --claude --force
148
+
149
+ # Preview changes without updating
150
+ npx myaidev-method@latest update --claude --dry-run
151
+ ```
152
+
153
+ The update command:
154
+ - ✅ Detects your current version
155
+ - ✅ Updates commands, agents, scripts, and documentation
156
+ - ✅ Preserves your customizations (interactive conflict resolution)
157
+ - ✅ Creates automatic backups before updating
158
+ - ✅ Installs updated dependencies
159
+
160
+ See [USER_GUIDE.md - Updating Section](USER_GUIDE.md#-updating-myaidev-method) for detailed update instructions and best practices.
161
+
137
162
  ## 🏗️ SPARC Development Workflow
138
163
 
139
164
  The **MyAIDev Method** implements the **SPARC methodology** - a systematic 5-phase approach to software development inspired by [GitHub Spec-Kit](https://github.com/github/spec-kit) patterns for agentic software development.
package/USER_GUIDE.md CHANGED
@@ -7,6 +7,7 @@ This guide covers everything you need to know about using, customizing, and exte
7
7
  ## 📋 Table of Contents
8
8
 
9
9
  - [Quick Start](#quick-start)
10
+ - [Updating MyAIDev Method](#-updating-myaidev-method)
10
11
  - [Understanding the Structure](#understanding-the-structure)
11
12
  - [👤 User Pathways](#-user-pathways)
12
13
  - [Content Creator Pathway](#content-creator-pathway)
@@ -98,6 +99,161 @@ You'll have a `.claude` folder in your project:
98
99
  /myai-configure agents --list
99
100
  ```
100
101
 
102
+ ## 🔄 Updating MyAIDev Method
103
+
104
+ The MyAIDev Method package receives regular updates with new features, bug fixes, and improved agents. Keep your installation up to date to access the latest capabilities.
105
+
106
+ ### Checking for Updates
107
+
108
+ Your current installation version is stored in `.claude/.myaidev-version`. When new versions are published to npm, you can update using the dedicated update command.
109
+
110
+ ### Running Updates
111
+
112
+ ```bash
113
+ # Interactive update (recommended) - prompts for conflicts
114
+ npx myaidev-method@latest update --claude
115
+
116
+ # Force update - overwrites all files without prompting
117
+ npx myaidev-method@latest update --claude --force
118
+
119
+ # Preview changes - see what would be updated without making changes
120
+ npx myaidev-method@latest update --claude --dry-run
121
+
122
+ # Verbose output - show detailed progress
123
+ npx myaidev-method@latest update --claude --verbose
124
+ ```
125
+
126
+ ### What Gets Updated
127
+
128
+ The update command updates all MyAIDev Method components:
129
+
130
+ - ✅ **Slash commands** (`.claude/commands/`) - New commands and improvements
131
+ - ✅ **Agent definitions** (`.claude/agents/`) - Enhanced prompts and capabilities
132
+ - ✅ **Executable scripts** (`.myaidev-method/scripts/`) - Bug fixes and new features
133
+ - ✅ **Utility libraries** (`.myaidev-method/lib/`) - Helper functions and utilities
134
+ - ✅ **Documentation files** (`USER_GUIDE.md`, `PUBLISHING_GUIDE.md`, etc.) - Updated guides
135
+ - ✅ **MCP configurations** (`.claude/mcp/`) - Server configurations and integrations
136
+ - ✅ **Dependencies** (`.myaidev-method/package.json`) - npm package updates
137
+
138
+ ### Handling Customizations
139
+
140
+ If you've customized agents or commands, the update process intelligently handles conflicts:
141
+
142
+ 1. **Detection**: The update command detects which files you've modified
143
+ 2. **Diff Display**: Shows you the differences between your version and the new version
144
+ 3. **User Choice**: You decide what to do for each modified file:
145
+ - **Keep current** - Skip this update, preserve your customizations
146
+ - **Use new version** - Overwrite with the latest version
147
+ - **View diff** - See detailed line-by-line differences
148
+ - **Keep + backup** - Update to new version and save your current version as `.bak`
149
+
150
+ Example update session:
151
+
152
+ ```
153
+ $ npx myaidev-method@latest update --claude
154
+
155
+ 🔍 Detecting MyAIDev Method installation...
156
+
157
+ ✓ Found claude installation
158
+ Current version: 0.2.11
159
+ Latest version: 0.2.12
160
+
161
+ ⚠️ This will update your MyAIDev Method installation
162
+ Modified files will require your confirmation
163
+
164
+ ? Continue with update? Yes
165
+
166
+ 💾 Creating backup...
167
+ ✓ Backup created at: .myaidev-method-backup-2025-11-10T20-59-00
168
+
169
+ 📦 Updating components...
170
+
171
+ Commands:
172
+ ➕ myai-new-feature.md (new)
173
+ ✓ myai-git-pr.md (unchanged)
174
+
175
+ Agents:
176
+ 📝 content-writer.md has been modified
177
+ ? What would you like to do?
178
+ ❯ Keep current version (skip update)
179
+ Use new version (overwrite)
180
+ View diff
181
+ Keep current + backup (.bak)
182
+
183
+ ✅ payloadcms-publish.md (updated)
184
+
185
+ Scripts:
186
+ ✅ payloadcms-publish.js (updated)
187
+ ✅ coolify-deploy-app.js (updated)
188
+
189
+ ═══════════════════════════════════════
190
+ Update Summary
191
+ ═══════════════════════════════════════
192
+ ✅ Updated: 5 files
193
+ ➕ Added: 2 new files
194
+ ⏭️ Skipped: 1 files (kept current)
195
+ ═══════════════════════════════════════
196
+
197
+ ✅ Successfully updated to v0.2.12
198
+ Backup available at: .myaidev-method-backup-2025-11-10T20-59-00
199
+ ```
200
+
201
+ ### Safety Features
202
+
203
+ **Automatic Backups**: Before making any changes, the update command creates a complete backup:
204
+ ```
205
+ .myaidev-method-backup-{timestamp}/
206
+ ├── .claude/
207
+ ├── .myaidev-method/
208
+ └── *.md (documentation files)
209
+ ```
210
+
211
+ **Dry Run Mode**: Preview all changes without modifying any files:
212
+ ```bash
213
+ npx myaidev-method@latest update --claude --dry-run
214
+ ```
215
+
216
+ **Version Tracking**: The update command checks your current version and only proceeds if an update is available.
217
+
218
+ ### Best Practices
219
+
220
+ 1. **Review Release Notes**: Check the [CHANGELOG.md](CHANGELOG.md) before updating
221
+ 2. **Use Dry Run**: Preview changes with `--dry-run` before actual update
222
+ 3. **Backup Custom Work**: If you have heavily customized agents, create manual backups
223
+ 4. **Update Regularly**: Stay current with latest features and security fixes
224
+ 5. **Test After Update**: Verify your workflows still function as expected
225
+
226
+ ### Troubleshooting Updates
227
+
228
+ **Update command not found**:
229
+ ```bash
230
+ # Ensure you're using the latest package
231
+ npx myaidev-method@latest --version
232
+ ```
233
+
234
+ **No installation detected**:
235
+ ```bash
236
+ # Verify installation exists
237
+ ls -la .claude
238
+
239
+ # Reinstall if needed
240
+ npx myaidev-method@latest init --claude
241
+ ```
242
+
243
+ **Dependency installation fails**:
244
+ ```bash
245
+ # Manually install dependencies
246
+ cd .myaidev-method
247
+ npm install
248
+ ```
249
+
250
+ **Want to rollback an update**:
251
+ ```bash
252
+ # Restore from backup
253
+ rm -rf .claude .myaidev-method *.md
254
+ cp -r .myaidev-method-backup-{timestamp}/* .
255
+ ```
256
+
101
257
  ## 🏗️ Understanding the Structure
102
258
 
103
259
  ### Commands Directory (`.claude/commands/`)
package/bin/cli.js CHANGED
@@ -111,10 +111,10 @@ program
111
111
  console.log(chalk.gray(' • COOLIFY_DEPLOYMENT.md - Application deployment'));
112
112
  console.log(chalk.gray(' • WORDPRESS_ADMIN_SCRIPTS.md - WordPress utilities'));
113
113
 
114
- console.log(chalk.magenta('\n🛠️ Scripts and Utilities Available:'));
115
- console.log(chalk.gray(' • node_modules/myaidev-method/src/scripts/ - Publishing scripts'));
116
- console.log(chalk.gray(' • node_modules/myaidev-method/src/lib/ - Utility libraries'));
117
- console.log(chalk.gray(' • Agents can invoke scripts via Bash tool with full dependencies'));
114
+ console.log(chalk.magenta('\n🛠️ Scripts and Utilities Installed:'));
115
+ console.log(chalk.gray(' • .myaidev-method/scripts/ - Publishing and deployment scripts'));
116
+ console.log(chalk.gray(' • .myaidev-method/lib/ - Utility libraries and helpers'));
117
+ console.log(chalk.gray(' • Installing script dependencies... (this may take a moment)'));
118
118
 
119
119
  console.log(chalk.magenta('\n🔧 MCP Server Integration (Optional Advanced Features):'));
120
120
  console.log(chalk.gray(' • SPARC Orchestrator: Workflow automation with MCP tools'));
@@ -285,21 +285,28 @@ COOLIFY_API_KEY=your-api-key
285
285
  - All custom commands are in \`.claude/commands/\`
286
286
  - All agents are in \`.claude/agents/\`
287
287
  - Commands and agents use Markdown format with YAML frontmatter
288
- - Executable scripts are in the npm package: \`node_modules/myaidev-method/src/scripts/\`
288
+ - Executable scripts and utilities are in \`.myaidev-method/scripts/\` and \`.myaidev-method/lib/\`
289
289
 
290
290
  ## Scripts and Utilities
291
291
 
292
- Publishing and deployment scripts are available via the installed npm package.
293
- Agents can invoke these scripts using the Bash tool:
292
+ The \`.myaidev-method/\` directory contains self-contained scripts and utilities:
294
293
 
295
294
  \`\`\`bash
296
- # Publishing scripts
297
- node node_modules/myaidev-method/src/scripts/payloadcms-publish.js "article.md" --status published
298
- node node_modules/myaidev-method/src/scripts/wordpress-health-check.js
299
- node node_modules/myaidev-method/src/scripts/docusaurus-publish.js "guide.md" --category tutorials
295
+ .myaidev-method/
296
+ ├── scripts/ # Executable publishing and deployment scripts
297
+ ├── lib/ # Utility libraries (PayloadCMSUtils, etc.)
298
+ ├── node_modules/ # Script dependencies (installed automatically)
299
+ └── package.json # Dependency manifest
300
+ \`\`\`
301
+
302
+ **Agents can invoke scripts directly using the Bash tool**:
300
303
 
301
- # Or use the global CLI if installed globally
302
- npx myaidev-method [script-name]
304
+ \`\`\`bash
305
+ # Publishing scripts
306
+ node .myaidev-method/scripts/payloadcms-publish.js "article.md" --status published
307
+ node .myaidev-method/scripts/wordpress-health-check.js
308
+ node .myaidev-method/scripts/docusaurus-publish.js "guide.md" --category tutorials
309
+ node .myaidev-method/scripts/coolify-deploy-app.js --name myapp
303
310
  \`\`\`
304
311
 
305
312
  **Available Scripts**:
@@ -312,6 +319,37 @@ npx myaidev-method [script-name]
312
319
  - \`wordpress-security-scan.js\` - WordPress security scan
313
320
  - \`wordpress-performance-check.js\` - WordPress performance analysis
314
321
 
322
+ **Note**: The \`.myaidev-method/\` directory includes its own \`node_modules/\` with all required dependencies.
323
+ To update dependencies, run \`npm install\` inside the \`.myaidev-method/\` directory.
324
+
325
+ **Git Ignore**: Add to your \`.gitignore\`:
326
+ \`\`\`
327
+ .myaidev-method/node_modules/
328
+ \`\`\`
329
+
330
+ ## Updating MyAIDev Method
331
+
332
+ To get the latest features, bug fixes, and improved agents:
333
+
334
+ \`\`\`bash
335
+ # Interactive update (recommended) - prompts for conflicts
336
+ npx myaidev-method@latest update --claude
337
+
338
+ # Force update - overwrites all files
339
+ npx myaidev-method@latest update --claude --force
340
+
341
+ # Preview changes without updating
342
+ npx myaidev-method@latest update --claude --dry-run
343
+ \`\`\`
344
+
345
+ The update command:
346
+ - ✅ Preserves your customizations (interactive conflict resolution)
347
+ - ✅ Creates automatic backups before updating
348
+ - ✅ Updates all components (commands, agents, scripts, docs)
349
+ - ✅ Installs updated dependencies
350
+
351
+ See \`USER_GUIDE.md\` for detailed update instructions and best practices.
352
+
315
353
  ## Notes
316
354
 
317
355
  This configuration follows Claude Code's official standards for custom commands and agents.
@@ -325,8 +363,70 @@ This configuration follows Claude Code's official standards for custom commands
325
363
  await fs.copy(sourceEnvExample, path.join(projectDir, '.env.example'));
326
364
  }
327
365
 
328
- // Note: Scripts are NOT copied locally because they need access to npm dependencies
329
- // Agents should reference scripts in node_modules: node_modules/myaidev-method/src/scripts/
366
+ // Create .myaidev-method directory for scripts and utilities
367
+ // This allows agents to access publishing/deployment scripts in non-Node.js projects
368
+ const myaidevDir = path.join(projectDir, '.myaidev-method');
369
+ const scriptsDir = path.join(myaidevDir, 'scripts');
370
+ const libDir = path.join(myaidevDir, 'lib');
371
+
372
+ await fs.ensureDir(scriptsDir);
373
+ await fs.ensureDir(libDir);
374
+
375
+ // Copy all executable scripts
376
+ const sourceScriptsDir = path.join(__dirname, '..', 'src', 'scripts');
377
+ if (await fs.pathExists(sourceScriptsDir)) {
378
+ const scriptFiles = await fs.readdir(sourceScriptsDir);
379
+ for (const file of scriptFiles) {
380
+ if (file.endsWith('.js') && file !== 'init-project.js') { // Skip init script
381
+ await fs.copy(
382
+ path.join(sourceScriptsDir, file),
383
+ path.join(scriptsDir, file)
384
+ );
385
+ }
386
+ }
387
+ }
388
+
389
+ // Copy all utility libraries
390
+ const sourceLibDir = path.join(__dirname, '..', 'src', 'lib');
391
+ if (await fs.pathExists(sourceLibDir)) {
392
+ await fs.copy(sourceLibDir, libDir);
393
+ }
394
+
395
+ // Copy package.json and install dependencies in .myaidev-method
396
+ // This ensures scripts have access to required npm packages
397
+ const packageJson = {
398
+ "name": "myaidev-method-scripts",
399
+ "version": "1.0.0",
400
+ "type": "module",
401
+ "private": true,
402
+ "dependencies": {
403
+ "node-fetch": "^3.3.2",
404
+ "marked": "^11.0.0",
405
+ "gray-matter": "^4.0.3",
406
+ "dotenv": "^16.4.1",
407
+ "chalk": "^5.3.0",
408
+ "ora": "^8.0.1"
409
+ }
410
+ };
411
+
412
+ await fs.writeFile(
413
+ path.join(myaidevDir, 'package.json'),
414
+ JSON.stringify(packageJson, null, 2)
415
+ );
416
+
417
+ // Install dependencies in .myaidev-method directory
418
+ console.log(chalk.gray('\n Installing script dependencies...'));
419
+ const { execSync } = await import('child_process');
420
+ try {
421
+ execSync('npm install', {
422
+ cwd: myaidevDir,
423
+ stdio: 'inherit'
424
+ });
425
+ console.log(chalk.green(' ✓ Dependencies installed successfully'));
426
+ } catch (error) {
427
+ console.log(chalk.yellow(' ⚠ Failed to install dependencies automatically'));
428
+ console.log(chalk.gray(' Run: cd .myaidev-method && npm install'));
429
+ }
330
430
 
331
431
  // Note: MCP integration disabled for now - using native tools for WordPress REST API
332
432
 
@@ -347,6 +447,11 @@ This configuration follows Claude Code's official standards for custom commands
347
447
  await fs.copy(sourcePath, path.join(projectDir, docFile));
348
448
  }
349
449
  }
450
+
451
+ // Save installation version for update tracking
452
+ const pkgJson = await fs.readJson(path.join(__dirname, '..', 'package.json'));
453
+ const versionFile = path.join(claudeDir, '.myaidev-version');
454
+ await fs.writeFile(versionFile, pkgJson.version);
350
455
  }
351
456
 
352
457
  async function setupGemini(projectDir) {
@@ -505,6 +610,154 @@ For full documentation, see the USER_GUIDE.md in your project root.
505
610
  await fs.writeFile(path.join(codexDir, 'README.md'), opencodeReadme);
506
611
  }
507
612
 
613
+ program
614
+ .command('update')
615
+ .description('Update MyAIDev Method components to latest version')
616
+ .option('--claude', 'Update Claude Code configuration')
617
+ .option('--gemini', 'Update Gemini CLI configuration')
618
+ .option('--codex', 'Update Codex CLI configuration')
619
+ .option('--force', 'Force update all files without prompting')
620
+ .option('--dry-run', 'Show what would be updated without making changes')
621
+ .option('--verbose', 'Show detailed progress')
622
+ .action(async (options) => {
623
+ const ora = (await import('ora')).default;
624
+ const { fileURLToPath } = await import('url');
625
+ const updateManager = await import('../src/lib/update-manager.js');
626
+
627
+ const __filename = fileURLToPath(import.meta.url);
628
+ const __dirname = path.dirname(__filename);
629
+ const packageRoot = path.join(__dirname, '..');
630
+
631
+ try {
632
+ const cwd = process.cwd();
633
+
634
+ // Detect existing installation
635
+ console.log(chalk.cyan('\n🔍 Detecting MyAIDev Method installation...\n'));
636
+ const installation = await updateManager.detectExistingInstallation(cwd);
637
+
638
+ if (!installation) {
639
+ console.log(chalk.red('❌ No MyAIDev Method installation found'));
640
+ console.log(chalk.gray(' Run: npx myaidev-method@latest init --claude'));
641
+ process.exit(1);
642
+ }
643
+
644
+ console.log(chalk.green(`✓ Found ${installation.type} installation`));
645
+ console.log(chalk.gray(` Current version: ${installation.currentVersion}`));
646
+
647
+ // Get package version
648
+ const packageJson = await fs.readJson(path.join(packageRoot, 'package.json'));
649
+ const newVersion = packageJson.version;
650
+
651
+ console.log(chalk.gray(` Latest version: ${newVersion}`));
652
+
653
+ // Check if already up to date
654
+ if (installation.currentVersion === newVersion && !options.force) {
655
+ console.log(chalk.green('\n✅ Already up to date!'));
656
+ process.exit(0);
657
+ }
658
+
659
+ if (options.dryRun) {
660
+ console.log(chalk.yellow('\n📋 DRY RUN MODE - No changes will be made\n'));
661
+ } else if (!options.force) {
662
+ console.log(chalk.yellow('\n⚠️ This will update your MyAIDev Method installation'));
663
+ console.log(chalk.gray(' Modified files will require your confirmation\n'));
664
+
665
+ const { confirm } = await inquirer.prompt([
666
+ {
667
+ type: 'confirm',
668
+ name: 'confirm',
669
+ message: 'Continue with update?',
670
+ default: true
671
+ }
672
+ ]);
673
+
674
+ if (!confirm) {
675
+ console.log(chalk.gray('Update cancelled'));
676
+ process.exit(0);
677
+ }
678
+ }
679
+
680
+ // Create backup unless dry-run
681
+ let backupDir;
682
+ if (!options.dryRun) {
683
+ console.log(chalk.cyan('\n💾 Creating backup...'));
684
+ backupDir = await updateManager.createBackup(cwd, installation.type);
685
+ console.log(chalk.green(`✓ Backup created at: ${path.basename(backupDir)}`));
686
+ }
687
+
688
+ // Update components
689
+ const allStats = {};
690
+
691
+ console.log(chalk.cyan('\n📦 Updating components...\n'));
692
+
693
+ // Commands
694
+ console.log(chalk.blue('Commands:'));
695
+ allStats.commands = await updateManager.updateComponent(
696
+ 'commands', cwd, installation.type, packageRoot, options
697
+ );
698
+
699
+ // Agents
700
+ console.log(chalk.blue('\nAgents:'));
701
+ allStats.agents = await updateManager.updateComponent(
702
+ 'agents', cwd, installation.type, packageRoot, options
703
+ );
704
+
705
+ // Scripts
706
+ console.log(chalk.blue('\nScripts:'));
707
+ allStats.scripts = await updateManager.updateComponent(
708
+ 'scripts', cwd, installation.type, packageRoot, options
709
+ );
710
+
711
+ // Libraries
712
+ console.log(chalk.blue('\nLibraries:'));
713
+ allStats.lib = await updateManager.updateComponent(
714
+ 'lib', cwd, installation.type, packageRoot, options
715
+ );
716
+
717
+ // MCP configurations
718
+ console.log(chalk.blue('\nMCP Configurations:'));
719
+ allStats.mcp = await updateManager.updateComponent(
720
+ 'mcp', cwd, installation.type, packageRoot, options
721
+ );
722
+
723
+ // Documentation
724
+ console.log(chalk.blue('\nDocumentation:'));
725
+ allStats.docs = await updateManager.updateComponent(
726
+ 'docs', cwd, installation.type, packageRoot, options
727
+ );
728
+
729
+ // Update dependencies
730
+ if (!options.dryRun) {
731
+ await updateManager.updateDependencies(cwd);
732
+ }
733
+
734
+ // Save new version
735
+ if (!options.dryRun) {
736
+ await updateManager.saveVersion(cwd, installation.type, newVersion);
737
+ }
738
+
739
+ // Show report
740
+ updateManager.generateUpdateReport(allStats);
741
+
742
+ if (options.dryRun) {
743
+ console.log(chalk.yellow('This was a dry run. No changes were made.'));
744
+ } else {
745
+ console.log(chalk.green(`✅ Successfully updated to v${newVersion}`));
746
+ if (backupDir) {
747
+ console.log(chalk.gray(` Backup available at: ${path.basename(backupDir)}`));
748
+ }
749
+ }
750
+
751
+ } catch (error) {
752
+ console.error(chalk.red('\n❌ Update failed:'));
753
+ console.error(error.message);
754
+ if (options.verbose) {
755
+ console.error(error);
756
+ }
757
+ process.exit(1);
758
+ }
759
+ });
760
+
508
761
  program
509
762
  .command('claudeweb')
510
763
  .description('Start MyAIDev Method Web UI with Claude Code Viewer')