You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(core): change folder structure to be by command/resource (#8)
* refactor core/ to structured by resource
* remove usage of @core from inside core/
* some more changes
* lint issues
* small eslint rule
* no name for resource
3.**Path aliases** - Use `@api/*`, `@config/*`, `@schemas/*`, `@core/*` for imports from core module
183
-
4.**CLI utilities** - Use relative imports for CLI-specific utilities (`../../utils/index.js`)
184
-
5.**Zod validation is required** for all external data
185
-
6.**@clack/prompts for all user interaction** - no raw `readline` or `inquirer`
186
-
7.**TypeScript strict mode** - maintain type safety
187
-
8.**Commander.js for commands** - follow the established pattern
188
-
9.**TypeScript compiler for builds** - use `tsc && tsc-alias` for production builds, `tsx` for development
189
-
10.**Test commands** after implementation to ensure they're registered
190
-
11.**Cross-platform support** - The CLI must work on both Windows and Unix-like systems. Always use `path.join()`, `path.dirname()`, and other `path` module utilities for path operations. Never use string concatenation or hardcoded path separators.
191
-
12.**Command wrapper** - All commands must use `runCommand()` utility for consistent Base44 branding
192
-
13.**Task wrapper** - Use `runTask()` for async operations that need spinner feedback
193
-
14.**ES Modules** - Package uses `"type": "module"` - always use `.js` extensions in import statements
194
-
15.**Shared utilities** - Use cross-platform file utilities and config management from `src/core/`
195
-
196
-
## Common Patterns
197
-
198
-
### Adding a New Command
199
-
1. Create command file in `src/cli/commands/<feature>/` directory
200
-
2. Import and register in main CLI entry point (`src/cli/index.ts`)
201
-
3. Use Commander.js Command class
202
-
4. Add Zod validation for inputs (schemas in `src/core/schemas/`)
203
-
5. Use @clack/prompts for user interaction
204
-
6. Use path aliases for imports from core module (`@api/*`, `@config/*`, etc.)
205
-
7. Use relative imports for CLI utilities (`../../utils/index.js`)
206
-
8. Wrap command function with `runCommand()` utility
207
-
9. Use `runTask()` for async operations with spinners
208
-
209
-
### API Integration
210
-
1. Define Zod schema in `src/core/schemas/` directory
211
-
2. Create API client function in `src/core/api/` directory
212
-
3. Export from `src/core/api/index.ts`
213
-
4. Import in CLI commands using path alias (`@api/*`)
214
-
5. Validate response with Zod schema
215
-
6. Handle errors gracefully
216
-
7. Use `runTask()` for loading states
217
-
218
-
### Configuration Management
219
-
1. Define Zod schema in `src/core/schemas/` directory
220
-
2. Create config management functions in `src/core/config/` directory
221
-
3. Export from `src/core/config/index.ts`
222
-
4. Import in CLI commands using path alias (`@config/*`)
223
-
5. Read config file
224
-
6. Validate with Zod schema
225
-
7. Provide type-safe access via inferred types
226
-
227
-
## Dependencies Reference
228
-
229
-
### Core (Required)
230
-
-`commander` - CLI framework
231
-
-`@clack/prompts` - User prompts and UI components
232
-
-`chalk` - Terminal colors
233
-
-`zod` - Schema validation
234
-
-`p-wait-for` - Polling utility for async operations
235
-
236
-
### Development
237
-
-`typescript` - Language
238
-
-`tsx` - TypeScript execution for development mode
239
-
-`tsc-alias` - Path alias resolution for compiled output
102
+
1.**npm only** - Never use yarn
103
+
2.**Zod validation** - Required for all external data
104
+
3.**@clack/prompts** - For all user interaction
105
+
4.**ES Modules** - Use `.js` extensions in imports
106
+
5.**Cross-platform** - Use `path` module utilities, never hardcode separators
107
+
6.**Command wrapper** - All commands use `runCommand()` utility
108
+
7.**Task wrapper** - Use `runTask()` for async operations with spinners
109
+
8.**Keep AGENTS.md updated** - Update this file when architecture changes
110
+
111
+
## Development
112
+
113
+
```bash
114
+
npm run build # tsc && tsc-alias
115
+
npm run dev # tsx for development
116
+
npm test# vitest
117
+
```
240
118
241
119
## File Locations
242
120
243
-
-**Main plan**: `cli/plan.md` - Full implementation plan
244
-
-**This file**: `cli/AGENTS.md` - AI agent guidelines
0 commit comments