@lenne.tech/cli 0.0.125 → 1.0.1

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 (46) hide show
  1. package/bin/lt +145 -14
  2. package/build/commands/claude/install-commands.js +332 -0
  3. package/build/commands/claude/install-skills.js +626 -0
  4. package/build/commands/config/config.js +25 -0
  5. package/build/commands/config/help.js +167 -0
  6. package/build/commands/config/init.js +143 -0
  7. package/build/commands/config/show.js +68 -0
  8. package/build/commands/server/add-property.js +163 -46
  9. package/build/commands/server/create.js +66 -4
  10. package/build/commands/server/module.js +133 -20
  11. package/build/commands/server/object.js +23 -15
  12. package/build/extensions/config.js +157 -0
  13. package/build/extensions/server.js +194 -63
  14. package/build/interfaces/lt-config.interface.js +3 -0
  15. package/build/templates/claude-commands/code-cleanup.md +82 -0
  16. package/build/templates/claude-commands/mr-description-clipboard.md +48 -0
  17. package/build/templates/claude-commands/mr-description.md +33 -0
  18. package/build/templates/claude-commands/sec-review.md +62 -0
  19. package/build/templates/claude-commands/skill-optimize.md +140 -0
  20. package/build/templates/claude-commands/test-generate.md +45 -0
  21. package/build/templates/claude-skills/lt-cli/SKILL.md +190 -259
  22. package/build/templates/claude-skills/lt-cli/examples.md +433 -203
  23. package/build/templates/claude-skills/lt-cli/reference.md +400 -226
  24. package/build/templates/claude-skills/nest-server-generator/SKILL.md +1891 -0
  25. package/build/templates/claude-skills/nest-server-generator/configuration.md +279 -0
  26. package/build/templates/claude-skills/nest-server-generator/declare-keyword-warning.md +124 -0
  27. package/build/templates/claude-skills/nest-server-generator/description-management.md +217 -0
  28. package/build/templates/claude-skills/nest-server-generator/examples.md +886 -0
  29. package/build/templates/claude-skills/nest-server-generator/quality-review.md +855 -0
  30. package/build/templates/claude-skills/nest-server-generator/reference.md +471 -0
  31. package/build/templates/claude-skills/nest-server-generator/security-rules.md +358 -0
  32. package/build/templates/claude-skills/story-tdd/SKILL.md +1173 -0
  33. package/build/templates/claude-skills/story-tdd/code-quality.md +266 -0
  34. package/build/templates/claude-skills/story-tdd/database-indexes.md +173 -0
  35. package/build/templates/claude-skills/story-tdd/examples.md +1332 -0
  36. package/build/templates/claude-skills/story-tdd/reference.md +1180 -0
  37. package/build/templates/claude-skills/story-tdd/security-review.md +299 -0
  38. package/build/templates/nest-server-module/inputs/template-create.input.ts.ejs +1 -3
  39. package/build/templates/nest-server-module/inputs/template.input.ts.ejs +1 -1
  40. package/build/templates/nest-server-module/template.controller.ts.ejs +24 -13
  41. package/build/templates/nest-server-module/template.model.ts.ejs +2 -2
  42. package/build/templates/nest-server-module/template.module.ts.ejs +4 -0
  43. package/build/templates/nest-server-module/template.service.ts.ejs +6 -6
  44. package/build/templates/nest-server-object/template.object.ts.ejs +2 -2
  45. package/package.json +13 -11
  46. package/build/commands/claude/install-skill.js +0 -93
@@ -0,0 +1,471 @@
1
+ ---
2
+ name: nest-server-generator-reference
3
+ version: 1.0.1
4
+ description: Quick reference for ALL NestJS server development - from simple single commands to complex structure generation
5
+ ---
6
+
7
+ # NestJS Server Development Quick Reference
8
+
9
+ ## Scope
10
+
11
+ **This skill handles ALL NestJS server development tasks:**
12
+ - ✅ Simple: Create single module, object, or add property
13
+ - ✅ Complex: Generate complete server structures from specifications
14
+ - ✅ Any `lt server` command
15
+
16
+ Use this skill for **ANY** NestJS/nest-server work, no matter how simple or complex.
17
+
18
+ ## Specification Syntax
19
+
20
+ ### Component Types
21
+
22
+ | Type | Syntax | Purpose |
23
+ |------|--------|---------|
24
+ | **SubObject** | `SubObject: Name // Desc` | Embedded data structure (no _id, no timestamps) |
25
+ | **Object** | `Object: Name\nProperties:\n- prop: type` | Base model for inheritance |
26
+ | **Module** | `Module: Name\nModel: Name\n- prop: type` | Full CRUD module with API |
27
+
28
+ ### Property Syntax
29
+
30
+ | Pattern | Meaning | LT CLI Flag |
31
+ |---------|---------|-------------|
32
+ | `name: string` | Required string | `--prop-name-X name --prop-type-X string` |
33
+ | `age?: number` | Optional number | `--prop-name-X age --prop-type-X number --prop-nullable-X true` |
34
+ | `tags: string[]` | Array of strings | `--prop-name-X tags --prop-type-X string --prop-array-X true` |
35
+ | `status: ENUM (A, B)` | Enum property | `--prop-name-X status --prop-enum-X StatusEnum` |
36
+ | `owner: User` | Reference to module | `--prop-name-X owner --prop-type-X ObjectId --prop-reference-X User` |
37
+ | `address: Address` | Embedded object | `--prop-name-X address --prop-schema-X Address` |
38
+ | `items: Item[]` | Array of objects | `--prop-name-X items --prop-schema-X Item --prop-array-X true` |
39
+ | `doc: File` | File reference | `--prop-name-X doc --prop-type-X string` |
40
+
41
+ ### Type Mapping
42
+
43
+ | Spec Type | TypeScript | MongoDB | CLI Type |
44
+ |-----------|-----------|---------|----------|
45
+ | `string` | string | String | string |
46
+ | `number` | number | Number | number |
47
+ | `boolean` | boolean | Boolean | boolean |
48
+ | `Date` | Date | Date | Date |
49
+ | `bigint` | bigint | Long | bigint |
50
+ | `File` | string | String | string |
51
+ | `ENUM(...)` | XxxEnum | String/Number | (use --prop-enum-X) |
52
+ | `OtherModule` | ObjectId ref | ObjectId | ObjectId + reference |
53
+ | `SubObject` | Embedded | Object | (use --prop-schema-X) |
54
+
55
+ ## Execution Workflow
56
+
57
+ ### Phase Checklist
58
+
59
+ ```
60
+ ☐ 1. Parse specification completely
61
+ ☐ 2. Create comprehensive todo list
62
+ ☐ 3. Create all SubObjects (dependency order)
63
+ ☐ 4. Create all Objects
64
+ ☐ 5. Create all Modules (dependency order)
65
+ ☐ 6. Handle inheritance (manual edits)
66
+ ☐ 7. Update ALL descriptions EVERYWHERE (CRITICAL!)
67
+ ☐ 7.1. Extract ALL user comments (after //) from specification
68
+ ☐ 7.2. Format descriptions: ENGLISH (DEUTSCH)
69
+ ☐ 7.3. Apply to ALL Module files (Model, CreateInput, UpdateInput)
70
+ ☐ 7.4. Apply to ALL SubObject files (Object, CreateInput, UpdateInput)
71
+ ☐ 7.5. Add to ALL class decorators (@ObjectType, @InputType)
72
+ ☐ 7.6. Verify consistency (same property = same description)
73
+ ☐ 8. Alphabetize all properties
74
+ ☐ 9. Create enum files
75
+ ☐ 10. Create API tests
76
+ ☐ 11. Run tests
77
+ ☐ 12. Verify & provide summary
78
+ ```
79
+
80
+ ### Dependency Order
81
+
82
+ ```
83
+ 1. SubObjects (if A uses B, create B first)
84
+ 2. Objects (base models)
85
+ 3. Modules (if A references B, create B first)
86
+ 4. Circular refs (use addProp for second reference)
87
+ 5. Inheritance updates
88
+ 6. Enums
89
+ 7. Tests
90
+ ```
91
+
92
+ ## Command Quick Reference
93
+
94
+ ### Create New Server
95
+ ```bash
96
+ lt server create <server-name>
97
+ # Alias: lt server c <server-name>
98
+
99
+ # Example
100
+ lt server create my-api
101
+ ```
102
+
103
+ **What it does**:
104
+ - Clones nest-server-starter template
105
+ - Configures package.json
106
+ - Sets up Swagger docs
107
+ - **Replaces ALL secrets** (`'SECRET_OR_PRIVATE_KEY...'` → unique random values)
108
+ - **Updates database names** (`nest-server-*` → `<project-name>-*`)
109
+ - Installs dependencies
110
+ - Optionally initializes git
111
+
112
+ **Post-creation verification**:
113
+ - Verify `src/config.env.ts` has no `SECRET_OR_PRIVATE_KEY` placeholders
114
+ - Verify mongoose.uri uses project name (e.g., `my-api-local` not `nest-server-local`)
115
+ - If using older CLI (<v0.0.126), run `lt server setConfigSecrets` manually
116
+
117
+ ### Create SubObject
118
+ ```bash
119
+ lt server object --name <Name> \
120
+ --prop-name-0 <name> --prop-type-0 <type> [modifiers] \
121
+ --prop-name-1 <name> --prop-type-1 <type> [modifiers]
122
+ ```
123
+
124
+ ### Create Module
125
+ ```bash
126
+ lt server module --name <Name> --controller <Rest|GraphQL|Both> \
127
+ --prop-name-0 <name> --prop-type-0 <type> [modifiers] \
128
+ --prop-name-1 <name> --prop-type-1 <type> [modifiers]
129
+ ```
130
+
131
+ ### Add Properties
132
+ ```bash
133
+ lt server addProp --type Module --element <Name> \
134
+ --prop-name-0 <name> --prop-type-0 <type> [modifiers]
135
+ ```
136
+
137
+ ### Modifiers
138
+
139
+ | Modifier | Flag | Example |
140
+ |----------|------|---------|
141
+ | Optional | `--prop-nullable-X true` | `--prop-nullable-2 true` |
142
+ | Array | `--prop-array-X true` | `--prop-array-1 true` |
143
+ | Enum | `--prop-enum-X <EnumName>` | `--prop-enum-3 StatusEnum` |
144
+ | Schema | `--prop-schema-X <SchemaName>` | `--prop-schema-0 Address` |
145
+ | Reference | `--prop-reference-X <ModelName>` | `--prop-reference-1 User` |
146
+
147
+ ## Description Format
148
+
149
+ **⚠️ CRITICAL:** Always extract descriptions from user comments (after `//`) and apply EVERYWHERE!
150
+
151
+ **Rule**: `"ENGLISH_DESCRIPTION (DEUTSCHE_BESCHREIBUNG)"`
152
+
153
+ ### Processing
154
+
155
+ | Input Comment | Language | Output Description |
156
+ |---------------|----------|-------------------|
157
+ | `// Product name` | English | `'Product name'` |
158
+ | `// Produktname` | German | `'Product name (Produktname)'` |
159
+ | `// Street name` | English | `'Street name'` |
160
+ | `// Straße` | German | `'Street (Straße)'` |
161
+ | `// Postleizahl` (typo) | German | `'Postal code (Postleitzahl)'` (corrected) |
162
+ | (no comment) | - | Create meaningful English description |
163
+
164
+ **⚠️ Preserve Original Wording:**
165
+ - ✅ Fix typos: `Postleizahl` → `Postleitzahl`, `Starße` → `Straße`
166
+ - ❌ DON'T rephrase: `Straße` → `Straßenname` (NO!)
167
+ - ❌ DON'T expand: `Produkt` → `Produktbezeichnung` (NO!)
168
+ - **Reason:** User comments may be predefined terms referenced by external systems
169
+
170
+ ### Apply To ALL Files
171
+
172
+ **For EVERY Module property** (3 files):
173
+ 1. `<module>.model.ts` → Property `@UnifiedField({ description: '...' })`
174
+ 2. `inputs/<module>-create.input.ts` → Property `@UnifiedField({ description: '...' })`
175
+ 3. `inputs/<module>.input.ts` → Property `@UnifiedField({ description: '...' })`
176
+
177
+ **For EVERY SubObject property** (3 files):
178
+ 1. `objects/<object>/<object>.object.ts` → Property `@UnifiedField({ description: '...' })`
179
+ 2. `objects/<object>/<object>-create.input.ts` → Property `@UnifiedField({ description: '...' })`
180
+ 3. `objects/<object>/<object>.input.ts` → Property `@UnifiedField({ description: '...' })`
181
+
182
+ **For class decorators**:
183
+ - `@ObjectType({ description: '...' })` on Models and Objects
184
+ - `@InputType({ description: '...' })` on all Input classes
185
+
186
+ ### Common Mistakes
187
+
188
+ ❌ **WRONG:** Descriptions only in Model, missing in Inputs
189
+ ❌ **WRONG:** German-only descriptions without English translation
190
+ ❌ **WRONG:** Inconsistent descriptions (different in Model vs Input)
191
+ ❌ **WRONG:** Ignoring user-provided comments from specification
192
+ ❌ **WRONG:** Changing wording: `Straße` → `Straßenname` (rephrased!)
193
+ ❌ **WRONG:** Expanding terms: `Produkt` → `Produktbezeichnung` (added word!)
194
+
195
+ ✅ **CORRECT:** Same description in ALL 3 files (Model, CreateInput, UpdateInput)
196
+ ✅ **CORRECT:** Format `ENGLISH (DEUTSCH)` for German comments
197
+ ✅ **CORRECT:** All user comments extracted and applied
198
+ ✅ **CORRECT:** Fix typos only, preserve original wording: `Postleizahl` → `Postleitzahl`
199
+ ✅ **CORRECT:** Keep exact terms: `Straße` → `Street (Straße)` (not "Street name"!)
200
+
201
+ ## Inheritance Handling
202
+
203
+ ### Model Extension
204
+
205
+ ```typescript
206
+ // FROM (generated):
207
+ import { CoreModel } from '@lenne.tech/nest-server';
208
+ export class ChildModel extends CoreModel { ... }
209
+
210
+ // TO (manual edit):
211
+ import { ParentModel } from '../../common/objects/parent/parent.model';
212
+ export class ChildModel extends ParentModel { ... }
213
+ ```
214
+
215
+ ### Input Extension
216
+
217
+ ```typescript
218
+ // child-create.input.ts
219
+ // MUST include:
220
+ // 1. ALL required fields from parent's CreateInput
221
+ // 2. ALL required fields from child model
222
+ // 3. Optional fields from both (optional in UpdateInput)
223
+ ```
224
+
225
+ ### Core Models (no changes needed)
226
+ - `CoreModel`
227
+ - `CorePersisted`
228
+ - Any @lenne.tech/nest-server base class
229
+
230
+ ## Enum File Template
231
+
232
+ ```typescript
233
+ // src/server/common/enums/<name>.enum.ts
234
+ export enum <Name>Enum {
235
+ VALUE_ONE = 'VALUE_ONE',
236
+ VALUE_TWO = 'VALUE_TWO',
237
+ VALUE_THREE = 'VALUE_THREE',
238
+ }
239
+ ```
240
+
241
+ ### Naming
242
+ - **File**: `kebab-case.enum.ts` → `user-status.enum.ts`
243
+ - **Enum**: `PascalCaseEnum` → `UserStatusEnum`
244
+ - **Values**: `UPPER_SNAKE_CASE` → `ACTIVE`, `PENDING`
245
+
246
+ ## API Test Template
247
+
248
+ ```typescript
249
+ // test/<module>/<module>.controller.test.ts
250
+ import { testHelper } from '@lenne.tech/nest-server';
251
+
252
+ describe('<Module> Controller', () => {
253
+ let testUser;
254
+ let created<Model>;
255
+
256
+ beforeAll(async () => {
257
+ testUser = await testHelper.createTestUser({ roles: ['admin'] });
258
+ });
259
+
260
+ afterAll(async () => {
261
+ if (created<Model>) await testHelper.delete('<modules>', created<Model>.id);
262
+ await testHelper.deleteTestUser(testUser.id);
263
+ });
264
+
265
+ it('should create with required fields', async () => { /* ... */ });
266
+ it('should fail without required fields', async () => { /* ... */ });
267
+ it('should get all', async () => { /* ... */ });
268
+ it('should get by id', async () => { /* ... */ });
269
+ it('should update', async () => { /* ... */ });
270
+ it('should delete', async () => { /* ... */ });
271
+ it('should fail without auth', async () => { /* ... */ });
272
+ });
273
+ ```
274
+
275
+ ### Test Coverage
276
+ - ✅ Create (valid data)
277
+ - ✅ Create (missing required - fail)
278
+ - ✅ Find all
279
+ - ✅ Find by ID
280
+ - ✅ Update
281
+ - ✅ Delete
282
+ - ✅ Authorization (fail without auth)
283
+ - ✅ Required fields validation
284
+
285
+ ## Common Patterns
286
+
287
+ ### Pattern 1: Simple Module
288
+ ```
289
+ Module: Product
290
+ Model: Product
291
+ - name: string
292
+ - price: number
293
+ ```
294
+ → `lt server module --name Product --controller Both --prop-name-0 name --prop-type-0 string --prop-name-1 price --prop-type-1 number`
295
+
296
+ ### Pattern 2: Module with Reference
297
+ ```
298
+ Module: Order
299
+ Model: Order
300
+ - customer: User
301
+ - total: number
302
+ ```
303
+ → `lt server module --name Order --controller Both --prop-name-0 customer --prop-type-0 ObjectId --prop-reference-0 User --prop-name-1 total --prop-type-1 number`
304
+
305
+ ### Pattern 3: Module with Embedded Object
306
+ ```
307
+ SubObject: Address
308
+ - street: string
309
+ - city: string
310
+
311
+ Module: Company
312
+ Model: Company
313
+ - name: string
314
+ - address: Address
315
+ ```
316
+ → Create Address first, then Company with `--prop-schema-X Address`
317
+
318
+ ### Pattern 4: Module with Enum Array
319
+ ```
320
+ Module: User
321
+ Model: User
322
+ - name: string
323
+ - roles: ENUM (ADMIN, USER, GUEST)[]
324
+ ```
325
+ → `--prop-name-1 roles --prop-enum-1 RoleEnum --prop-array-1 true`
326
+
327
+ ### Pattern 5: Inheritance
328
+ ```
329
+ Object: BaseProfile
330
+ Properties:
331
+ - name: string
332
+ - email: string
333
+
334
+ Module: UserProfile
335
+ Model: UserProfile
336
+ Extends: BaseProfile
337
+ - username: string
338
+ ```
339
+ → Create BaseProfile object, create UserProfile module, manually update to extend BaseProfile
340
+
341
+ ### Pattern 6: Circular References
342
+ ```
343
+ Module: Author
344
+ - books: Book[]
345
+
346
+ Module: Book
347
+ - author: Author
348
+ ```
349
+ → Create Author, create Book with author ref, use addProp to add books to Author
350
+
351
+ ## Troubleshooting
352
+
353
+ | Issue | Solution |
354
+ |-------|----------|
355
+ | Missing imports | Add manually: `import { Ref } from '@lenne.tech/nest-server'` |
356
+ | CreateInput validation fails | Add parent's required fields to child's CreateInput |
357
+ | Enum errors | Create enum file in `src/server/common/enums/` |
358
+ | Test fails (required fields) | Check CreateInput for all required fields |
359
+ | Circular dependency | Use `addProp` for second reference |
360
+ | Properties not alphabetical | Reorder manually in all files |
361
+ | TypeScript errors after inheritance | Check imports and extend statement |
362
+
363
+ ## Verification Checklist
364
+
365
+ Final checks before completing:
366
+
367
+ ```
368
+ ☐ All SubObjects created
369
+ ☐ All Objects created
370
+ ☐ All Modules created
371
+ ☐ Properties in alphabetical order
372
+ ☐ DESCRIPTIONS - CRITICAL (check ALL):
373
+ ☐ User comments extracted from specification
374
+ ☐ German descriptions → ENGLISH (DEUTSCH) format
375
+ ☐ English descriptions → kept as-is
376
+ ☐ Module Models have descriptions
377
+ ☐ Module CreateInputs have SAME descriptions
378
+ ☐ Module UpdateInputs have SAME descriptions
379
+ ☐ SubObjects have descriptions
380
+ ☐ SubObject CreateInputs have SAME descriptions
381
+ ☐ SubObject UpdateInputs have SAME descriptions
382
+ ☐ @ObjectType/@InputType decorators have descriptions
383
+ ☐ NO inconsistencies between files
384
+ ☐ Inheritance correctly implemented
385
+ ☐ CreateInputs have all required fields (parent + model)
386
+ ☐ Enum files created in src/server/common/enums/
387
+ ☐ API tests created for all modules
388
+ ☐ Tests cover CRUD operations
389
+ ☐ Tests verify authorization
390
+ ☐ Tests verify required fields
391
+ ☐ All tests pass
392
+ ☐ No TypeScript errors
393
+ ☐ Lint passes
394
+ ```
395
+
396
+ ## File Structure
397
+
398
+ ```
399
+ src/server/
400
+ ├── modules/
401
+ │ ├── <module-name>/
402
+ │ │ ├── <module-name>.model.ts
403
+ │ │ ├── <module-name>.service.ts
404
+ │ │ ├── <module-name>.controller.ts (if Rest/Both)
405
+ │ │ ├── <module-name>.resolver.ts (if GraphQL/Both)
406
+ │ │ ├── <module-name>.module.ts
407
+ │ │ ├── inputs/
408
+ │ │ │ ├── <module-name>.input.ts
409
+ │ │ │ └── <module-name>-create.input.ts
410
+ │ │ └── outputs/
411
+ │ │ └── find-and-count-<module-name>s-result.output.ts
412
+ │ └── ...
413
+ └── common/
414
+ ├── objects/
415
+ │ ├── <object-name>/
416
+ │ │ ├── <object-name>.object.ts
417
+ │ │ ├── <object-name>.input.ts
418
+ │ │ └── <object-name>-create.input.ts
419
+ │ └── ...
420
+ └── enums/
421
+ ├── <enum-name>.enum.ts
422
+ └── ...
423
+
424
+ test/
425
+ ├── <module-name>/
426
+ │ ├── <module-name>.controller.test.ts
427
+ │ └── <module-name>.resolver.test.ts
428
+ └── ...
429
+ ```
430
+
431
+ ## Best Practices Summary
432
+
433
+ 1. ✅ **Plan before executing** - Analyze full specification first
434
+ 2. ✅ **Create dependencies first** - SubObjects → Objects → Modules
435
+ 3. ✅ **Follow naming conventions** - PascalCase for types, camelCase for properties
436
+ 4. ✅ **Order matters** - Alphabetical properties, dependency-ordered creation
437
+ 5. ✅ **Describe thoroughly** - "ENGLISH (DEUTSCH)" everywhere
438
+ 6. ✅ **Test comprehensively** - All CRUD + auth + validation
439
+ 7. ✅ **Clean up tests** - Delete test data in afterAll
440
+ 8. ✅ **Commit incrementally** - After SubObjects, Modules, Tests
441
+ 9. ✅ **Verify before finishing** - Run checklist, ensure tests pass
442
+ 10. ✅ **Report observations** - Note data structure issues/improvements
443
+
444
+ ## Quick Start
445
+
446
+ ```bash
447
+ # 1. Receive specification
448
+ # 2. Parse and create todo list
449
+ # 3. Execute commands in order:
450
+
451
+ # SubObjects
452
+ lt server object --name Address --prop-name-0 street --prop-type-0 string ...
453
+
454
+ # Modules
455
+ lt server module --name User --controller Both --prop-name-0 email --prop-type-0 string ...
456
+
457
+ # Enums
458
+ # Create files in src/server/common/enums/
459
+
460
+ # Tests
461
+ # Create test files for each module
462
+
463
+ # 4. Verify and report
464
+ npm test
465
+ npm run lint
466
+ # Provide summary
467
+ ```
468
+
469
+ ---
470
+
471
+ **Remember**: This skill handles COMPLETE structure generation, not individual commands. Always process the full specification systematically and provide comprehensive summaries.