optikit 1.2.4 → 1.3.0

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.
Files changed (104) hide show
  1. package/.claude/commands/build.md +57 -0
  2. package/.claude/commands/clean.md +45 -0
  3. package/.claude/commands/generate.md +64 -0
  4. package/.claude/commands/rollback.md +67 -0
  5. package/.claude/commands/run.md +63 -0
  6. package/.claude/commands/setup.md +69 -0
  7. package/.claude/commands/sync-docs.md +148 -0
  8. package/.claude/commands/version.md +63 -0
  9. package/.claude/settings.local.json +28 -0
  10. package/.claude-plugin/marketplace.json +36 -0
  11. package/.claude-plugin/plugin.json +25 -0
  12. package/.history/README_20260325211923.md +268 -0
  13. package/.history/README_20260325212116.md +268 -0
  14. package/.history/README_20260325212234.md +266 -0
  15. package/.history/README_20260325221838.md +321 -0
  16. package/.history/README_20260325221920.md +327 -0
  17. package/.history/README_20260325222245.md +328 -0
  18. package/.history/README_20260325222247.md +328 -0
  19. package/.mcp.json +8 -0
  20. package/CHANGELOG.md +79 -46
  21. package/CLAUDE.md +57 -206
  22. package/OPTIKIT_AGENT.md +398 -0
  23. package/README.md +293 -60
  24. package/dist/cli.js +75 -241
  25. package/dist/commands/build/commands.js +146 -0
  26. package/dist/commands/build/testflight.js +14 -0
  27. package/dist/commands/clean/commands.js +41 -0
  28. package/dist/commands/clean/flutter.js +8 -14
  29. package/dist/commands/clean/ios.js +12 -15
  30. package/dist/commands/config/aliases.js +122 -0
  31. package/dist/commands/config/commands.js +49 -0
  32. package/dist/commands/config/initApp.js +191 -0
  33. package/dist/commands/config/rollback.js +15 -4
  34. package/dist/commands/config/upgrade.js +36 -0
  35. package/dist/commands/mcp/commands.js +21 -0
  36. package/dist/commands/mcp/server.js +27 -0
  37. package/dist/commands/mcp/setup.js +62 -0
  38. package/dist/commands/mcp/tools.js +359 -0
  39. package/dist/commands/project/commands.js +132 -0
  40. package/dist/commands/project/devices.js +10 -26
  41. package/dist/commands/project/doctor.js +58 -0
  42. package/dist/commands/project/generate.js +183 -30
  43. package/dist/commands/project/setup.js +10 -28
  44. package/dist/commands/project/status.js +65 -0
  45. package/dist/commands/version/bump.js +96 -82
  46. package/dist/commands/version/commands.js +63 -0
  47. package/dist/commands/version/update.js +36 -24
  48. package/dist/constants.js +6 -1
  49. package/dist/styles.js +42 -5
  50. package/dist/utils/helpers/error.js +14 -0
  51. package/dist/utils/helpers/file.js +1 -1
  52. package/dist/utils/helpers/version.js +2 -1
  53. package/dist/utils/services/backup.js +12 -1
  54. package/dist/utils/services/command.js +1 -34
  55. package/dist/utils/services/exec.js +76 -101
  56. package/dist/utils/services/logger.js +10 -4
  57. package/dist/utils/validators/validation.js +24 -12
  58. package/docs/INSTALLATION.md +72 -0
  59. package/docs/TROUBLESHOOT.md +140 -0
  60. package/docs/USAGE.md +185 -0
  61. package/docs/VERSION_MANAGEMENT.md +177 -0
  62. package/package.json +7 -11
  63. package/src/cli.ts +82 -362
  64. package/src/commands/build/commands.ts +169 -0
  65. package/src/commands/build/testflight.ts +18 -0
  66. package/src/commands/clean/commands.ts +43 -0
  67. package/src/commands/clean/flutter.ts +9 -13
  68. package/src/commands/clean/ios.ts +13 -13
  69. package/src/commands/config/aliases.ts +150 -0
  70. package/src/commands/config/commands.ts +50 -0
  71. package/src/commands/config/initApp.ts +213 -0
  72. package/src/commands/config/rollback.ts +16 -4
  73. package/src/commands/config/upgrade.ts +40 -0
  74. package/src/commands/mcp/commands.ts +23 -0
  75. package/src/commands/mcp/server.ts +35 -0
  76. package/src/commands/mcp/setup.ts +69 -0
  77. package/src/commands/mcp/tools.ts +365 -0
  78. package/src/commands/project/commands.ts +132 -0
  79. package/src/commands/project/devices.ts +11 -24
  80. package/src/commands/project/doctor.ts +81 -0
  81. package/src/commands/project/generate.ts +211 -32
  82. package/src/commands/project/setup.ts +13 -30
  83. package/src/commands/project/status.ts +72 -0
  84. package/src/commands/version/bump.ts +124 -85
  85. package/src/commands/version/commands.ts +76 -0
  86. package/src/commands/version/update.ts +86 -75
  87. package/src/constants.ts +7 -1
  88. package/src/styles.ts +49 -7
  89. package/src/utils/helpers/error.ts +16 -0
  90. package/src/utils/helpers/file.ts +1 -1
  91. package/src/utils/helpers/version.ts +2 -1
  92. package/src/utils/services/backup.ts +17 -1
  93. package/src/utils/services/command.ts +1 -58
  94. package/src/utils/services/exec.ts +92 -117
  95. package/src/utils/services/logger.ts +12 -4
  96. package/src/utils/validators/validation.ts +24 -12
  97. package/CODE_QUALITY.md +0 -398
  98. package/ENHANCEMENTS.md +0 -310
  99. package/FEATURE_ENHANCEMENTS.md +0 -435
  100. package/INSTALLATION.md +0 -118
  101. package/SAFETY_FEATURES.md +0 -396
  102. package/TROUBLESHOOT.md +0 -60
  103. package/USAGE.md +0 -388
  104. package/VERSION_MANAGEMENT.md +0 -438
package/CLAUDE.md CHANGED
@@ -2,238 +2,89 @@
2
2
 
3
3
  This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
4
 
5
- ## Project Overview
5
+ ## Related Documentation
6
6
 
7
- OptiKit is a TypeScript-based CLI tool for Flutter developers, especially those using the Opticore micro framework. It automates module scaffolding, build processes, and project maintenance tasks.
7
+ | File | Purpose |
8
+ |---|---|
9
+ | [OPTIKIT_AGENT.md](OPTIKIT_AGENT.md) | Full AI agent reference — deep command details, behaviors, constraints |
10
+ | [docs/USAGE.md](docs/USAGE.md) | End-user command reference |
11
+ | [docs/VERSION_MANAGEMENT.md](docs/VERSION_MANAGEMENT.md) | Version bump strategy and dual build number system |
12
+ | [docs/INSTALLATION.md](docs/INSTALLATION.md) | Installation methods (NPM, Homebrew, source) |
8
13
 
9
- ## Essential Commands
14
+ ## Claude Slash Commands (`.claude/commands/`)
10
15
 
11
- ### Development
12
- ```bash
13
- npm install # Install dependencies
14
- npm run build # Compile TypeScript to dist/
15
- npm start # Run the CLI (after build)
16
- node dist/cli.js # Direct execution
17
- ```
16
+ These commands can be copied into any Flutter project that uses OptiKit:
18
17
 
19
- ### Testing the CLI Locally
20
- ```bash
21
- npm link # Create global symlink for testing
22
- optikit <command> # Test commands globally
23
- npm unlink # Remove symlink when done
24
- ```
25
-
26
- ### Build Configuration
27
- - TypeScript compiles from `src/` to `dist/`
28
- - Target: ESNext, Module: NodeNext
29
- - Entry point: `src/cli.ts` (shebang for CLI execution)
30
- - Binary: `dist/cli.js` (executable as `optikit` command)
18
+ | Command | Triggers |
19
+ |---|---|
20
+ | `/version` | Show, bump, or manually set version/build numbers |
21
+ | `/build` | Build APK, AAB, iOS, or IPA |
22
+ | `/clean` | Clean Flutter project or iOS CocoaPods |
23
+ | `/generate` | Scaffold a BLoC module for Opticore |
24
+ | `/run` | List devices and run the app |
25
+ | `/rollback` | Inspect and restore backups |
26
+ | `/setup` | Init config and VSCode settings |
27
+ | `/sync-docs` | Keep all docs in sync after any source change |
31
28
 
32
- ## Architecture
29
+ > After any change to `src/`, run `/sync-docs` to update all documentation automatically.
33
30
 
34
- ### Folder Structure (Domain-Based Organization)
35
-
36
- ```
37
- src/
38
- ├── cli.ts # Main CLI entry point (yargs configuration)
39
- ├── constants.ts # Centralized constants and configurations
40
- ├── styles.ts # CLI styling (boxen, chalk)
41
-
42
- ├── commands/ # Domain-organized command modules
43
- │ ├── build/ # Build-related commands
44
- │ │ └── releases.ts # APK, Bundle, IPA, iOS builds
45
- │ ├── clean/ # Clean-related commands
46
- │ │ ├── flutter.ts # Flutter project cleaning
47
- │ │ └── ios.ts # iOS-specific cleaning
48
- │ ├── version/ # Version management commands
49
- │ │ ├── bump.ts # Smart version bumping (major/minor/patch, iOS/Android)
50
- │ │ └── update.ts # Manual version updates
51
- │ ├── project/ # Project-related commands
52
- │ │ ├── generate.ts # Module generation (BLoC pattern)
53
- │ │ ├── open.ts # Open in Xcode/Android Studio
54
- │ │ └── setup.ts # VSCode settings setup
55
- │ └── config/ # Configuration commands
56
- │ ├── init.ts # Initialize OptiKit config
57
- │ └── rollback.ts # Backup management
58
-
59
- └── utils/ # Categorized utility modules
60
- ├── validators/ # Validation utilities
61
- │ └── validation.ts # Flutter project, SDK, iOS/Android validation
62
- ├── helpers/ # Helper functions
63
- │ ├── build.ts # Build execution helpers
64
- │ ├── dryRun.ts # Dry-run mode utilities
65
- │ ├── file.ts # File operations (create, write, getClassName)
66
- │ ├── string.ts # String manipulation (capitalize, etc.)
67
- │ └── version.ts # Version parsing and manipulation
68
- └── services/ # Service modules
69
- ├── backup.ts # Automatic backup/restore system
70
- ├── command.ts # Command validation helpers
71
- ├── config.ts # .optikitrc configuration management
72
- ├── exec.ts # Process execution (execCommand, execInIos)
73
- └── logger.ts # Colored console output (chalk)
74
- ```
75
-
76
- ### Command Structure
77
- All commands are defined in [src/cli.ts](src/cli.ts) using yargs and implemented in domain-specific modules under `src/commands/`:
78
-
79
- **Command Registry Pattern:**
80
- ```
81
- cli.ts (yargs configuration)
82
- ├── Import command modules from domain folders
83
- └── Define command specs with:
84
- ├── Command name and arguments
85
- ├── Options (flags like --disable-fvm)
86
- └── Handler function (calls command module)
87
- ```
88
-
89
- ### Module Generation System
90
- The `generate module` command creates a complete BLoC pattern structure for Opticore framework:
31
+ ## Essential Commands
91
32
 
92
- **Generated Structure:**
93
- ```
94
- lib/module/<moduleName>/
95
- ├── bloc/ # BLoC implementation
96
- ├── event/ # Event definitions
97
- ├── state/ # State definitions
98
- ├── screen/ # UI screen widgets
99
- ├── factory/ # State factory
100
- └── import/ # Centralized imports file
33
+ ```bash
34
+ npm install # Install dependencies
35
+ npm run build # Compile TypeScript (src/ -> dist/)
36
+ npm start # Run CLI (equivalent to node dist/cli.js)
37
+ npm link # Create global symlink for local testing
38
+ optikit <command> # Test commands after npm link
101
39
  ```
102
40
 
103
- **Template System:**
41
+ **No test suite exists** — `npm test` is a stub. There is no linter configured.
104
42
 
105
- - Each component type has a template in [src/commands/project/generate.ts](src/commands/project/generate.ts)
106
- - Uses `part of` syntax linking to central import file
107
- - Class names auto-generated via `getClassName()` utility
108
- - All files use `.dart` extension and follow Opticore patterns
109
-
110
- ### Utility Modules
111
-
112
- #### Validators (src/utils/validators/)
113
-
114
- **validation.ts** - Pre-flight validation system:
115
-
116
- - `validateFlutterProject()` - Checks for pubspec.yaml
117
- - `validateFlutterSdk(useFvm)` - Validates Flutter/FVM installation
118
- - `validateIosProject()` - Checks iOS project structure
119
- - `validateAndroidProject()` - Checks Android project structure
120
-
121
- #### Helpers (src/utils/helpers/)
122
-
123
- **exec.ts** (in services/) - Process execution with three patterns:
124
-
125
- 1. `execCommand(command)` - Spawns shell command with streaming output
126
- 2. `execInIos(command)` - Runs command in `ios/` directory with 10min timeout
127
- 3. `execInIosWithRetry(command, retries, delay)` - Retry wrapper for flaky network operations
128
-
129
- **file.ts** - File operations:
130
-
131
- - `createDirectories(basePath, dirs)` - Recursive directory creation
132
- - `writeFile(path, content)` - Write with error handling
133
- - `getClassName(moduleName, suffix)` - Converts snake_case to PascalCase (e.g., "user_profile" → "UserProfileBloc")
134
-
135
- **version.ts** - Version management:
136
-
137
- - `parseVersion(versionString)` - Parses version in X.Y.Z+B format
138
- - `incrementVersion(current, type)` - Handles major/minor/patch increments
139
- - `getCurrentVersion()` - Reads version from pubspec.yaml
140
- - `formatVersion(version)` - Formats version to string
141
-
142
- **build.ts** - Build execution:
143
-
144
- - `executeBuild(config, noFvm)` - Unified build execution with validation
145
-
146
- **string.ts** - String utilities (capitalize, etc.)
147
-
148
- #### Services (src/utils/services/)
149
-
150
- **logger.ts** - Colored console output using chalk:
151
-
152
- - `.success()` - Green
153
- - `.error()` - Red
154
- - `.warning()` - Yellow
155
- - `.info()` - Light blue
43
+ ## Project Overview
156
44
 
157
- **backup.ts** - Automatic backup system:
45
+ OptiKit is a TypeScript CLI for Flutter/Opticore developers. It automates module scaffolding, builds, version management, and project maintenance. Built with yargs, chalk, and boxen.
158
46
 
159
- - `createBackup(filePath)` - Creates timestamped backups in .optikit-backup/
160
- - `restoreBackup(originalPath, backupPath)` - Restores from backup
161
- - `cleanupBackups(directory, retentionCount)` - Maintains backup retention limit
47
+ ## Architecture
162
48
 
163
- **config.ts** - Configuration management:
49
+ ### How Commands Work
164
50
 
165
- - `loadConfig()` - Loads .optikitrc.json from project or home directory
166
- - `saveConfig(config)` - Saves configuration to file
167
- - Priority: project .optikitrc → project .optikitrc.json → home directory versions
51
+ All commands are registered in `src/cli.ts` using yargs `.command()` blocks. Each block imports a handler from a domain module under `src/commands/`. The pattern:
168
52
 
169
- **command.ts** - Command utilities:
53
+ 1. `cli.ts` defines the command name, positional args, options (flags), and description
54
+ 2. The handler function delegates to the imported command module
55
+ 3. Command modules use utilities from `src/utils/` (validators, helpers, services)
170
56
 
171
- - Validation and command helpers
57
+ ### Domain Organization
172
58
 
173
- ### FVM Support Pattern
174
- Most Flutter commands support `--disable-fvm` flag:
175
- - Default: Prepends `fvm` to Flutter/Dart commands
176
- - With flag: Uses global Flutter SDK
177
- - Used in: build commands, clean commands
59
+ Commands are grouped by domain: `build/`, `clean/`, `version/`, `project/`, `config/`. Utilities are grouped by role: `validators/`, `helpers/`, `services/`.
178
60
 
179
- ### Version Management Flow
180
- The `flutter-update-version` command handles cross-platform versioning:
181
- 1. Updates `pubspec.yaml` (version + build number)
182
- 2. Updates `ios/Runner.xcodeproj/project.pbxproj` (MARKETING_VERSION, CURRENT_PROJECT_VERSION)
183
- 3. Updates `ios/Runner/Info.plist` (CFBundleShortVersionString, CFBundleVersion)
184
- 4. Runs `agvtool` commands in iOS directory for Xcode build settings
61
+ ### Key Architectural Patterns
185
62
 
186
- ### iOS Build Pattern
187
- iOS commands use retry logic due to CocoaPods network instability:
188
- - Default: 3 retries with 5s delay
189
- - All iOS operations run in `ios/` directory via `execInIos()`
190
- - 10-minute timeout for pod operations
63
+ **FVM Support** Most Flutter commands support a `--disable-fvm` flag. By default, commands prepend `fvm` to Flutter/Dart commands. The flag switches to the global Flutter SDK. Constants for both variants live in `src/constants.ts` (`FLUTTER_COMMANDS` vs `FVM_COMMANDS`).
191
64
 
192
- ## File Naming Conventions
65
+ **Version Management (Dual Build Numbers)** — Android and iOS have independent build numbers. `bump <type>` increments the semver and resets both. `bump-ios` / `bump-android` / `bump-build` increment build numbers independently. Version updates touch three files simultaneously: `pubspec.yaml`, `ios/Runner.xcodeproj/project.pbxproj`, and `ios/Runner/Info.plist`.
193
66
 
194
- ### TypeScript Files (Domain-Based)
67
+ **Backup System** Before modifying version files, OptiKit creates timestamped backups in `.optikit-backup/`. Retention is capped at 5 backups (configurable in `constants.ts` `BACKUP_CONFIG`). The `rollback` command lists and restores these.
195
68
 
196
- **Commands** - Organized by domain in `src/commands/`:
69
+ **Process Execution** Three execution patterns in `src/utils/services/exec.ts`: `execCommand()` for general shell commands with streaming output, `execInIos()` for commands in `ios/` with 10-min timeout, and `execInIosWithRetry()` for flaky CocoaPods operations (3 retries, 10s delay).
197
70
 
198
- - `build/releases.ts` - Build commands
199
- - `clean/flutter.ts`, `clean/ios.ts` - Clean commands
200
- - `version/bump.ts`, `version/update.ts` - Version commands
201
- - `project/generate.ts`, `project/open.ts`, `project/setup.ts` - Project commands
202
- - `config/init.ts`, `config/rollback.ts` - Configuration commands
71
+ **Module Generation** — The `generate module` command scaffolds a complete BLoC pattern: bloc, event, state, screen, factory, and import file. Templates are inline in `src/commands/project/generate.ts`. Class names are derived from snake_case module names via `getClassName()` (e.g., `user_profile` -> `UserProfileBloc`).
203
72
 
204
- **Utilities** - Categorized in `src/utils/`:
73
+ **Configuration** `.optikitrc.json` loaded with priority: project root > home directory. Managed by `src/utils/services/config.ts`.
205
74
 
206
- - `validators/validation.ts` - Validation utilities
207
- - `helpers/*.ts` - Helper functions (build, file, string, version, dryRun)
208
- - `services/*.ts` - Service modules (backup, command, config, exec, logger)
209
- - All modules use ES6 imports with `.js` extension (TypeScript quirk for NodeNext)
75
+ **Constants** — All magic strings, paths, commands, error messages, and build configs are centralized in `src/constants.ts`. Always use these rather than inline strings.
210
76
 
211
- ### Generated Dart Files
77
+ ## Adding New Commands
212
78
 
213
- - Pattern: `<moduleName>_<type>.dart`
214
- - Types: `bloc`, `event`, `state`, `screen`, `factory`, `import`
215
- - Example: For module "user_profile" `user_profile_bloc.dart`
79
+ 1. Create a command module in the appropriate domain folder under `src/commands/`
80
+ 2. Import it in `src/cli.ts` (use `.js` extension in imports — ES modules requirement)
81
+ 3. Add a `.command()` block following the existing pattern in cli.ts
82
+ 4. Use `LoggerHelpers` for output, `execCommand()` for shell ops, validators for pre-flight checks
216
83
 
217
- ## Adding New Commands
84
+ ## Important Conventions
218
85
 
219
- 1. **Choose the appropriate domain folder** in `src/commands/` (build, clean, version, project, config)
220
- 2. **Create command module** in that folder (e.g., `src/commands/build/newBuild.ts`)
221
- 3. **Import in [src/cli.ts](src/cli.ts)** using the new path (e.g., `./commands/build/newBuild.js`)
222
- 4. **Add `.command()` block** with:
223
- - Command signature
224
- - Description
225
- - Options configuration
226
- - Handler calling your module function
227
- 5. **Use categorized utilities**:
228
- - `LoggerHelpers` from `../utils/services/logger.js` for console output
229
- - `execCommand()` from `../utils/services/exec.js` for shell operations
230
- - `validateFlutterProject()` from `../utils/validators/validation.js` for validation
231
- - `createBackup()` from `../utils/services/backup.js` for backups
232
-
233
- ## Important Notes
234
-
235
- - **ES Modules**: Project uses `"type": "module"` - all imports need `.js` extension
236
- - **Path Construction**: Use `path.join()` for cross-platform compatibility
237
- - **Error Handling**: Wrap async operations in try-catch, log with `LoggerHelpers.error()`
238
- - **Process Execution**: Never use `exec()` directly - use helper functions for consistent output streaming
239
- - **Opticore Framework**: Generated modules assume Opticore package is installed in target Flutter project
86
+ - **ES Modules**: `"type": "module"` all imports must use `.js` extension even for `.ts` files
87
+ - **Strict TypeScript**: `strict: true` in tsconfig, target ESNext with NodeNext module resolution
88
+ - **Path construction**: Always use `path.join()` for cross-platform paths
89
+ - **Process execution**: Never use `child_process` directly — use `execCommand()` / `execInIos()` wrappers
90
+ - **Constants over strings**: Use `src/constants.ts` for paths, commands, error messages, and config values