litedbmodel-gen 0.3.3 → 0.5.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.
package/cli-contract.yaml CHANGED
@@ -90,16 +90,430 @@ command_sets:
90
90
 
91
91
  '1':
92
92
  description: >-
93
- Setup failed. The embedoc config file was not found
94
- or a file operation failed.
93
+ Setup failed due to an unexpected file operation error.
95
94
  stderr:
96
95
  format: text
97
96
 
97
+ '3':
98
+ description: >-
99
+ Input validation failed. The specified embedoc.config.yaml
100
+ path was not found. Run "npx embedoc init" first.
101
+ stderr:
102
+ format: json
103
+
98
104
  x-agent:
99
- risk_level: low
100
- requires_confirmation: false
105
+ riskLevel: low
106
+ requiresConfirmation: false
101
107
  idempotent: true
102
- side_effects:
108
+ sideEffects:
103
109
  - file_write
104
- recommended_before_use:
110
+ recommendedBeforeUse:
105
111
  - Run "npx embedoc init" first to create embedoc.config.yaml.
112
+
113
+ # ── audit ────────────────────────────────────────────
114
+ audit:
115
+ summary: Audit litedbmodel usage code for common anti-patterns.
116
+ description: >-
117
+ Scans TypeScript source files that import or use litedbmodel models,
118
+ detecting anti-patterns such as loop-insert (use createMany),
119
+ delete-then-reinsert (use upsert), N+1 queries, missing idempotency
120
+ guards, missing UNIQUE constraints for onConflict, over-broad deletes,
121
+ and missing forUpdate in concurrent-write paths.
122
+ Returns structured findings with severity ratings and remediation
123
+ guidance referencing the correct litedbmodel API.
124
+ usage:
125
+ - litedbmodel-gen audit
126
+ - litedbmodel-gen audit src/
127
+ - litedbmodel-gen audit src/services/user-service.ts --fail-on warning --report-format text
128
+
129
+ arguments:
130
+ - name: target
131
+ index: 0
132
+ required: false
133
+ description: >-
134
+ File or directory path to audit.
135
+ Defaults to the current working directory.
136
+ schema:
137
+ type: string
138
+ default: "."
139
+
140
+ options:
141
+ - name: adapter
142
+ description: LLM adapter to use for the audit.
143
+ schema:
144
+ type: string
145
+ enum: [mock, cursor, claude, openai, gemini]
146
+ default: mock
147
+
148
+ - name: model
149
+ description: Model name override for the selected adapter.
150
+ schema:
151
+ type: string
152
+
153
+ - name: dry-run
154
+ description: Output the constructed prompt without calling the LLM.
155
+ schema:
156
+ type: boolean
157
+ default: false
158
+
159
+ - name: fail-on
160
+ description: >-
161
+ Minimum finding severity that causes exit code 10.
162
+ Findings below this threshold are still reported.
163
+ schema:
164
+ type: string
165
+ enum: [warning, error, critical]
166
+ default: error
167
+
168
+ - name: output
169
+ aliases: [o]
170
+ description: Write the report to a file instead of stdout.
171
+ schema:
172
+ type: string
173
+ file:
174
+ mode: write
175
+
176
+ - name: report-format
177
+ description: Output format for the audit report.
178
+ schema:
179
+ type: string
180
+ enum: [json, text, yaml]
181
+ default: json
182
+
183
+ x-agent:
184
+ riskLevel: low
185
+ requiresConfirmation: false
186
+ idempotent: true
187
+ sideEffects: [network]
188
+ sideEffectNote: >-
189
+ Makes network calls to the configured LLM provider when adapter is
190
+ not "mock". Writes to the filesystem only when --output is specified.
191
+ safeDryRunOption: dry-run
192
+ expectedDurationMs: 120000
193
+ retryableExitCodes: [1, 12]
194
+
195
+ exits:
196
+ '0':
197
+ description: >-
198
+ Audit completed. No findings at or above the --fail-on threshold.
199
+ stdout:
200
+ format: json
201
+ schema:
202
+ $ref: '#/components/schemas/AgentAuditResult'
203
+ '1':
204
+ description: General error (unexpected exception or I/O failure).
205
+ stderr:
206
+ format: text
207
+ '3':
208
+ description: >-
209
+ Input validation failed (target path not found, no TypeScript
210
+ files found at path).
211
+ stderr:
212
+ format: json
213
+ '10':
214
+ description: >-
215
+ Blocking findings detected at or above the --fail-on threshold.
216
+ stdout:
217
+ format: json
218
+ schema:
219
+ $ref: '#/components/schemas/AgentAuditResult'
220
+ '11':
221
+ description: agent-contracts-runtime package is not installed.
222
+ stderr:
223
+ format: json
224
+ '12':
225
+ description: >-
226
+ Adapter initialization failed (missing API key or invalid
227
+ configuration).
228
+ stderr:
229
+ format: json
230
+
231
+ # ── implement ─────────────────────────────────────────
232
+ implement:
233
+ summary: Implement a feature using litedbmodel best practices.
234
+ description: >-
235
+ Reads the project's model definitions, then implements the described
236
+ feature directly in the target source file(s), applying litedbmodel
237
+ best-practice patterns: createMany for batch inserts, upsert with
238
+ onConflict/onConflictUpdate for idempotent writes, forUpdate for
239
+ concurrent-safe reads, and DBModel.transaction for multi-step
240
+ operations. Avoids all eight common litedbmodel anti-patterns.
241
+ Requires an agentic adapter (claude/cursor) that can read and
242
+ write project files.
243
+ usage:
244
+ - >-
245
+ litedbmodel-gen implement
246
+ "Add syncNutrientSummary in src/services/meal.service.ts"
247
+ --target src/services/meal.service.ts
248
+ --models "src/models/**/*.ts"
249
+ --adapter claude
250
+ - >-
251
+ litedbmodel-gen implement
252
+ "Add bulk upsert for order items"
253
+ --target src/services/order.service.ts
254
+ --adapter claude
255
+
256
+ arguments:
257
+ - name: description
258
+ index: 0
259
+ required: true
260
+ description: >-
261
+ Natural-language description of the feature to implement.
262
+ Should specify the function name, target file, and business logic.
263
+ schema:
264
+ type: string
265
+
266
+ options:
267
+ - name: target
268
+ aliases: [t]
269
+ description: >-
270
+ Target source file(s) to create or edit. The agent reads these
271
+ files to understand existing code and writes the implementation
272
+ to them.
273
+ schema:
274
+ type: string
275
+
276
+ - name: models
277
+ description: >-
278
+ Glob pattern for model definition files. The agent reads these
279
+ to understand available models, columns, and relations.
280
+ schema:
281
+ type: string
282
+ default: "models/**/*.ts"
283
+
284
+ - name: adapter
285
+ description: LLM adapter to use for code generation.
286
+ schema:
287
+ type: string
288
+ enum: [mock, cursor, claude, openai, gemini]
289
+ default: mock
290
+
291
+ - name: model
292
+ description: Model name override for the selected adapter.
293
+ schema:
294
+ type: string
295
+
296
+ - name: dry-run
297
+ description: Output the constructed prompt without calling the LLM.
298
+ schema:
299
+ type: boolean
300
+ default: false
301
+
302
+ - name: fail-on
303
+ description: >-
304
+ Minimum finding severity that causes exit code 10.
305
+ Design concerns (info/warning) are still reported at exit 0.
306
+ schema:
307
+ type: string
308
+ enum: [warning, error, critical]
309
+ default: error
310
+
311
+ - name: output
312
+ aliases: [o]
313
+ description: Write the report to a file instead of stdout.
314
+ schema:
315
+ type: string
316
+ file:
317
+ mode: write
318
+
319
+ - name: report-format
320
+ description: Output format for the implementation report.
321
+ schema:
322
+ type: string
323
+ enum: [json, text, yaml]
324
+ default: json
325
+
326
+ x-agent:
327
+ riskLevel: high
328
+ requiresConfirmation: true
329
+ idempotent: false
330
+ sideEffects: [network, filesystem_write]
331
+ sideEffectNote: >-
332
+ The agent reads project files and writes implementation code
333
+ directly to the target source file(s). Uses an agentic adapter
334
+ (claude/cursor) with file read/write tools.
335
+ safeDryRunOption: dry-run
336
+ expectedDurationMs: 120000
337
+ retryableExitCodes: [1, 12]
338
+
339
+ exits:
340
+ '0':
341
+ description: >-
342
+ Implementation written to target files successfully with no
343
+ design concerns at or above the --fail-on threshold.
344
+ stdout:
345
+ format: json
346
+ schema:
347
+ $ref: '#/components/schemas/LitedbmodelImplementResult'
348
+ '1':
349
+ description: General error (unexpected exception or I/O failure).
350
+ stderr:
351
+ format: text
352
+ '3':
353
+ description: >-
354
+ Input validation failed (missing description or unreadable
355
+ model files).
356
+ stderr:
357
+ format: json
358
+ '10':
359
+ description: >-
360
+ Implementation written but design concerns at or above the
361
+ --fail-on threshold were detected.
362
+ stdout:
363
+ format: json
364
+ schema:
365
+ $ref: '#/components/schemas/LitedbmodelImplementResult'
366
+ '11':
367
+ description: agent-contracts-runtime package is not installed.
368
+ stderr:
369
+ format: json
370
+ '12':
371
+ description: >-
372
+ Adapter initialization failed (missing API key or invalid
373
+ configuration).
374
+ stderr:
375
+ format: json
376
+
377
+ components:
378
+ schemas:
379
+ AgentEvidence:
380
+ type: object
381
+ required: [type, content]
382
+ properties:
383
+ type:
384
+ type: string
385
+ description: Evidence category (e.g. code_snippet, log_line, metric).
386
+ content:
387
+ type: string
388
+ description: The evidence body.
389
+ source:
390
+ type: string
391
+ description: File path, URL, or identifier of the evidence source.
392
+
393
+ AgentFinding:
394
+ type: object
395
+ required: [severity, category, message]
396
+ properties:
397
+ id:
398
+ type: string
399
+ description: Optional stable identifier for the finding.
400
+ severity:
401
+ type: string
402
+ enum: [info, warning, error, critical]
403
+ category:
404
+ type: string
405
+ description: Domain-specific vocabulary label (e.g. LOOP_CREATE, N_PLUS_ONE).
406
+ target:
407
+ type: string
408
+ description: Symbol, class, or function where the finding applies.
409
+ location:
410
+ type: string
411
+ description: File path and optional line reference.
412
+ message:
413
+ type: string
414
+ description: Human-readable description of the finding.
415
+ recommendation:
416
+ type: string
417
+ description: Actionable fix referencing the correct litedbmodel API.
418
+ confidence:
419
+ type: number
420
+ minimum: 0
421
+ maximum: 1
422
+ description: Model confidence in the finding (0–1).
423
+ evidence:
424
+ type: array
425
+ items:
426
+ $ref: '#/components/schemas/AgentEvidence'
427
+ details:
428
+ type: object
429
+ description: Arbitrary additional structured detail.
430
+
431
+ AgentRecommendedAction:
432
+ type: object
433
+ required: [kind, title]
434
+ properties:
435
+ kind:
436
+ type: string
437
+ enum: [run_command, edit_file, review, confirm, block, ignore]
438
+ title:
439
+ type: string
440
+ description: Short imperative label for the action.
441
+ command:
442
+ type: string
443
+ description: Shell command to run (for kind=run_command).
444
+ target:
445
+ type: string
446
+ description: File or symbol to edit/review.
447
+ rationale:
448
+ type: string
449
+ description: Why this action is recommended.
450
+
451
+ AgentAuditResult:
452
+ type: object
453
+ required: [summary, riskLevel, findings]
454
+ properties:
455
+ summary:
456
+ type: string
457
+ description: One-paragraph summary of the audit result.
458
+ riskLevel:
459
+ type: string
460
+ enum: [low, medium, high, critical]
461
+ description: Overall risk level reflecting the highest-severity finding.
462
+ findings:
463
+ type: array
464
+ items:
465
+ $ref: '#/components/schemas/AgentFinding'
466
+ recommendedActions:
467
+ type: array
468
+ items:
469
+ $ref: '#/components/schemas/AgentRecommendedAction'
470
+ metadata:
471
+ type: object
472
+ properties:
473
+ tool:
474
+ type: string
475
+ command:
476
+ type: string
477
+ version:
478
+ type: string
479
+ generatedAt:
480
+ type: string
481
+ adapter:
482
+ type: string
483
+ model:
484
+ type: string
485
+
486
+ FileChange:
487
+ type: object
488
+ required: [path, action]
489
+ properties:
490
+ path:
491
+ type: string
492
+ description: Relative file path that was created or modified.
493
+ action:
494
+ type: string
495
+ enum: [created, updated]
496
+ description: Whether the file was newly created or updated.
497
+ rationale:
498
+ type: string
499
+ description: Why this file was changed.
500
+
501
+ LitedbmodelImplementResult:
502
+ allOf:
503
+ - $ref: '#/components/schemas/AgentAuditResult'
504
+ - type: object
505
+ required: [changedFiles]
506
+ properties:
507
+ changedFiles:
508
+ type: array
509
+ description: Files that the agent created or modified.
510
+ items:
511
+ $ref: '#/components/schemas/FileChange'
512
+ dependencies:
513
+ type: array
514
+ description: npm packages required but not yet in the project.
515
+ items:
516
+ type: string
517
+ notes:
518
+ type: string
519
+ description: Additional integration instructions.
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, { get: all[name], enumerable: true });
6
+ };
7
+
8
+ export {
9
+ __export
10
+ };
11
+ //# sourceMappingURL=chunk-2H7UOFLK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}