litedbmodel-gen 0.7.0 → 0.7.2
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/README.md +3 -3
- package/cli-contract.yaml +6 -6
- package/dist/cli.js +34 -43
- package/dist/cli.js.map +1 -1
- package/dist/litedbmodel-gen.bundle.mjs +719 -494
- package/dist/litedbmodel-gen.bundle.mjs.map +4 -4
- package/docs/cli-reference.md +4 -4
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ npx litedbmodel-gen implement \
|
|
|
77
77
|
|
|
78
78
|
# Preview the full prompt without calling the LLM
|
|
79
79
|
npx litedbmodel-gen implement "Add bulk user import" \
|
|
80
|
-
--target src/services/user.service.ts --
|
|
80
|
+
--target src/services/user.service.ts --show-prompt
|
|
81
81
|
|
|
82
82
|
# Write result to a file
|
|
83
83
|
npx litedbmodel-gen implement "..." --target src/services/foo.ts --adapter claude -o result.json
|
|
@@ -89,7 +89,7 @@ npx litedbmodel-gen implement "..." --target src/services/foo.ts --adapter claud
|
|
|
89
89
|
| `--models <glob>` | `models/**/*.ts` | Glob pattern for model definition files |
|
|
90
90
|
| `--adapter <name>` | `mock` | LLM adapter: `claude`, `openai`, `gemini`, `cursor`, `mock` |
|
|
91
91
|
| `--model <name>` | — | Model name override for the adapter |
|
|
92
|
-
| `--
|
|
92
|
+
| `--show-prompt` | `false` | Output the prompt without calling the LLM |
|
|
93
93
|
| `--report-format` | `json` | Output format: `json`, `text`, `yaml` |
|
|
94
94
|
| `--output <path>` | — | Write result to file instead of stdout |
|
|
95
95
|
| `--fail-on` | `error` | Minimum severity that causes exit code 10 |
|
|
@@ -115,7 +115,7 @@ npx litedbmodel-gen audit src/ --adapter claude --report-format text
|
|
|
115
115
|
|--------|---------|-------------|
|
|
116
116
|
| `--adapter <name>` | `mock` | LLM adapter: `claude`, `openai`, `gemini`, `cursor`, `mock` |
|
|
117
117
|
| `--model <name>` | — | Model name override for the adapter |
|
|
118
|
-
| `--
|
|
118
|
+
| `--show-prompt` | `false` | Output the prompt without calling the LLM |
|
|
119
119
|
| `--report-format` | `json` | Output format: `json`, `text`, `yaml` |
|
|
120
120
|
| `--output <path>` | — | Write result to file instead of stdout |
|
|
121
121
|
| `--fail-on` | `error` | Minimum severity that causes exit code 10 |
|
package/cli-contract.yaml
CHANGED
|
@@ -150,8 +150,8 @@ command_sets:
|
|
|
150
150
|
schema:
|
|
151
151
|
type: string
|
|
152
152
|
|
|
153
|
-
- name:
|
|
154
|
-
description: Output the constructed prompt without calling the LLM.
|
|
153
|
+
- name: show-prompt
|
|
154
|
+
description: Output the constructed prompt without calling the LLM API.
|
|
155
155
|
schema:
|
|
156
156
|
type: boolean
|
|
157
157
|
default: false
|
|
@@ -197,7 +197,7 @@ command_sets:
|
|
|
197
197
|
sideEffectNote: >-
|
|
198
198
|
Makes network calls to the configured LLM provider when adapter is
|
|
199
199
|
not "mock". Writes to the filesystem only when --output is specified.
|
|
200
|
-
safeDryRunOption:
|
|
200
|
+
safeDryRunOption: show-prompt
|
|
201
201
|
expectedDurationMs: 120000
|
|
202
202
|
retryableExitCodes: [1, 12]
|
|
203
203
|
|
|
@@ -302,8 +302,8 @@ command_sets:
|
|
|
302
302
|
schema:
|
|
303
303
|
type: string
|
|
304
304
|
|
|
305
|
-
- name:
|
|
306
|
-
description: Output the constructed prompt without calling the LLM.
|
|
305
|
+
- name: show-prompt
|
|
306
|
+
description: Output the constructed prompt without calling the LLM API.
|
|
307
307
|
schema:
|
|
308
308
|
type: boolean
|
|
309
309
|
default: false
|
|
@@ -350,7 +350,7 @@ command_sets:
|
|
|
350
350
|
The agent reads project files and writes implementation code
|
|
351
351
|
directly to the target source file(s). Uses an agentic adapter
|
|
352
352
|
(claude/cursor) with file read/write tools.
|
|
353
|
-
safeDryRunOption:
|
|
353
|
+
safeDryRunOption: show-prompt
|
|
354
354
|
expectedDurationMs: 120000
|
|
355
355
|
retryableExitCodes: [1, 12]
|
|
356
356
|
|
package/dist/cli.js
CHANGED
|
@@ -6239,8 +6239,8 @@ command_sets:
|
|
|
6239
6239
|
schema:
|
|
6240
6240
|
type: string
|
|
6241
6241
|
|
|
6242
|
-
- name:
|
|
6243
|
-
description: Output the constructed prompt without calling the LLM.
|
|
6242
|
+
- name: show-prompt
|
|
6243
|
+
description: Output the constructed prompt without calling the LLM API.
|
|
6244
6244
|
schema:
|
|
6245
6245
|
type: boolean
|
|
6246
6246
|
default: false
|
|
@@ -6286,7 +6286,7 @@ command_sets:
|
|
|
6286
6286
|
sideEffectNote: >-
|
|
6287
6287
|
Makes network calls to the configured LLM provider when adapter is
|
|
6288
6288
|
not "mock". Writes to the filesystem only when --output is specified.
|
|
6289
|
-
safeDryRunOption:
|
|
6289
|
+
safeDryRunOption: show-prompt
|
|
6290
6290
|
expectedDurationMs: 120000
|
|
6291
6291
|
retryableExitCodes: [1, 12]
|
|
6292
6292
|
|
|
@@ -6391,8 +6391,8 @@ command_sets:
|
|
|
6391
6391
|
schema:
|
|
6392
6392
|
type: string
|
|
6393
6393
|
|
|
6394
|
-
- name:
|
|
6395
|
-
description: Output the constructed prompt without calling the LLM.
|
|
6394
|
+
- name: show-prompt
|
|
6395
|
+
description: Output the constructed prompt without calling the LLM API.
|
|
6396
6396
|
schema:
|
|
6397
6397
|
type: boolean
|
|
6398
6398
|
default: false
|
|
@@ -6439,7 +6439,7 @@ command_sets:
|
|
|
6439
6439
|
The agent reads project files and writes implementation code
|
|
6440
6440
|
directly to the target source file(s). Uses an agentic adapter
|
|
6441
6441
|
(claude/cursor) with file read/write tools.
|
|
6442
|
-
safeDryRunOption:
|
|
6442
|
+
safeDryRunOption: show-prompt
|
|
6443
6443
|
expectedDurationMs: 120000
|
|
6444
6444
|
retryableExitCodes: [1, 12]
|
|
6445
6445
|
|
|
@@ -6823,8 +6823,8 @@ var CONTRACT_JSON_STR = `{
|
|
|
6823
6823
|
}
|
|
6824
6824
|
},
|
|
6825
6825
|
{
|
|
6826
|
-
"name": "
|
|
6827
|
-
"description": "Output the constructed prompt without calling the LLM.",
|
|
6826
|
+
"name": "show-prompt",
|
|
6827
|
+
"description": "Output the constructed prompt without calling the LLM API.",
|
|
6828
6828
|
"schema": {
|
|
6829
6829
|
"type": "boolean",
|
|
6830
6830
|
"default": false
|
|
@@ -6892,7 +6892,7 @@ var CONTRACT_JSON_STR = `{
|
|
|
6892
6892
|
"network"
|
|
6893
6893
|
],
|
|
6894
6894
|
"sideEffectNote": "Makes network calls to the configured LLM provider when adapter is not \\"mock\\". Writes to the filesystem only when --output is specified.",
|
|
6895
|
-
"safeDryRunOption": "
|
|
6895
|
+
"safeDryRunOption": "show-prompt",
|
|
6896
6896
|
"expectedDurationMs": 120000,
|
|
6897
6897
|
"retryableExitCodes": [
|
|
6898
6898
|
1,
|
|
@@ -7004,8 +7004,8 @@ var CONTRACT_JSON_STR = `{
|
|
|
7004
7004
|
}
|
|
7005
7005
|
},
|
|
7006
7006
|
{
|
|
7007
|
-
"name": "
|
|
7008
|
-
"description": "Output the constructed prompt without calling the LLM.",
|
|
7007
|
+
"name": "show-prompt",
|
|
7008
|
+
"description": "Output the constructed prompt without calling the LLM API.",
|
|
7009
7009
|
"schema": {
|
|
7010
7010
|
"type": "boolean",
|
|
7011
7011
|
"default": false
|
|
@@ -7074,7 +7074,7 @@ var CONTRACT_JSON_STR = `{
|
|
|
7074
7074
|
"filesystem_write"
|
|
7075
7075
|
],
|
|
7076
7076
|
"sideEffectNote": "The agent reads project files and writes implementation code directly to the target source file(s). Uses an agentic adapter (claude/cursor) with file read/write tools.",
|
|
7077
|
-
"safeDryRunOption": "
|
|
7077
|
+
"safeDryRunOption": "show-prompt",
|
|
7078
7078
|
"expectedDurationMs": 120000,
|
|
7079
7079
|
"retryableExitCodes": [
|
|
7080
7080
|
1,
|
|
@@ -7416,7 +7416,7 @@ function createProgram(handlers2, version2) {
|
|
|
7416
7416
|
program2.command("init").description("Set up litedbmodel-gen in an embedoc project.").argument("[config]", "Path to embedoc.config.yaml. Defaults to embedoc.config.yaml in the current directory.").action(async (config2, opts, cmd) => {
|
|
7417
7417
|
await handlers2.init(config2, {}, cmd.optsWithGlobals());
|
|
7418
7418
|
});
|
|
7419
|
-
program2.command("audit").description("Audit litedbmodel usage code for common anti-patterns.").argument("[target]", "File or directory path to audit. Defaults to the current working directory.").option("--adapter <value>", "LLM adapter to use for the audit.", "mock").option("--model <value>", "Model name override for the selected adapter.").option("--
|
|
7419
|
+
program2.command("audit").description("Audit litedbmodel usage code for common anti-patterns.").argument("[target]", "File or directory path to audit. Defaults to the current working directory.").option("--adapter <value>", "LLM adapter to use for the audit.", "mock").option("--model <value>", "Model name override for the selected adapter.").option("--show-prompt", "Output the constructed prompt without calling the LLM API.", false).option("--fail-on <value>", "Minimum finding severity that causes exit code 10. Findings below this threshold are still reported.", "error").option("-o, --output <value>", "Write the report to a file instead of stdout.").option("--report-format <value>", "Output format for the audit report.", "json").option("-l, --log-file <value>", "File path to write structured progress logs.").action(async (target, opts, cmd) => {
|
|
7420
7420
|
if (opts.showPrompt) {
|
|
7421
7421
|
const prompt = await handlers2.audit(target, opts, cmd.optsWithGlobals());
|
|
7422
7422
|
if (typeof prompt === "string") process.stdout.write(prompt + "\n");
|
|
@@ -7424,7 +7424,7 @@ function createProgram(handlers2, version2) {
|
|
|
7424
7424
|
}
|
|
7425
7425
|
await handlers2.audit(target, opts, cmd.optsWithGlobals());
|
|
7426
7426
|
});
|
|
7427
|
-
program2.command("implement").description("Implement a feature using litedbmodel best practices.").argument("<description>", "Natural-language description of the feature to implement. Should specify the function name, target file, and business logic.").option("-t, --target <value>", "Target source file(s) to create or edit. The agent reads these files to understand existing code and writes the implementation to them.").option("--models <value>", "Glob pattern for model definition files. The agent reads these to understand available models, columns, and relations.", "models/**/*.ts").option("--adapter <value>", "LLM adapter to use for code generation.", "mock").option("--model <value>", "Model name override for the selected adapter.").option("--
|
|
7427
|
+
program2.command("implement").description("Implement a feature using litedbmodel best practices.").argument("<description>", "Natural-language description of the feature to implement. Should specify the function name, target file, and business logic.").option("-t, --target <value>", "Target source file(s) to create or edit. The agent reads these files to understand existing code and writes the implementation to them.").option("--models <value>", "Glob pattern for model definition files. The agent reads these to understand available models, columns, and relations.", "models/**/*.ts").option("--adapter <value>", "LLM adapter to use for code generation.", "mock").option("--model <value>", "Model name override for the selected adapter.").option("--show-prompt", "Output the constructed prompt without calling the LLM API.", false).option("--fail-on <value>", "Minimum finding severity that causes exit code 10. Design concerns (info/warning) are still reported at exit 0.", "error").option("-o, --output <value>", "Write the report to a file instead of stdout.").option("--report-format <value>", "Output format for the implementation report.", "json").option("-l, --log-file <value>", "File path to write structured progress logs.").action(async (description, opts, cmd) => {
|
|
7428
7428
|
if (opts.showPrompt) {
|
|
7429
7429
|
const prompt = await handlers2.implement(description, opts, cmd.optsWithGlobals());
|
|
7430
7430
|
if (typeof prompt === "string") process.stdout.write(prompt + "\n");
|
|
@@ -8196,15 +8196,6 @@ async function createAdapter(adapterName, config2) {
|
|
|
8196
8196
|
responses: config2.mockResponses ?? {}
|
|
8197
8197
|
});
|
|
8198
8198
|
}
|
|
8199
|
-
case "cursor": {
|
|
8200
|
-
const m = await import(`${PKG}/adapters/cursor-sdk`);
|
|
8201
|
-
const apiKey = process.env["CURSOR_API_KEY"];
|
|
8202
|
-
return m.CursorSdkAdapter.create({
|
|
8203
|
-
apiKey,
|
|
8204
|
-
...config2.model ? { model: config2.model } : {},
|
|
8205
|
-
...config2.cwd ? { cwd: config2.cwd } : {}
|
|
8206
|
-
});
|
|
8207
|
-
}
|
|
8208
8199
|
case "claude": {
|
|
8209
8200
|
const m = await import(`${PKG}/adapters/claude-agent-sdk`);
|
|
8210
8201
|
return new m.ClaudeAgentSdkAdapter({
|
|
@@ -8219,15 +8210,15 @@ async function createAdapter(adapterName, config2) {
|
|
|
8219
8210
|
});
|
|
8220
8211
|
}
|
|
8221
8212
|
case "gemini": {
|
|
8222
|
-
const m = await import(`${PKG}/adapters/
|
|
8223
|
-
return new m.
|
|
8213
|
+
const m = await import(`${PKG}/adapters/adk-sdk`);
|
|
8214
|
+
return new m.AdkSdkAdapter({
|
|
8224
8215
|
apiKey: process.env["GEMINI_API_KEY"],
|
|
8225
8216
|
...config2.model ? { model: config2.model } : {}
|
|
8226
8217
|
});
|
|
8227
8218
|
}
|
|
8228
8219
|
default:
|
|
8229
8220
|
throw Object.assign(
|
|
8230
|
-
new Error(`Unknown adapter: "${adapterName}". Valid values: mock,
|
|
8221
|
+
new Error(`Unknown adapter: "${adapterName}". Valid values: mock, claude, openai, gemini`),
|
|
8231
8222
|
{ exitCode: EXIT_ADAPTER_ERROR }
|
|
8232
8223
|
);
|
|
8233
8224
|
}
|
|
@@ -8268,7 +8259,7 @@ async function runAgentTask(userRequest, taskId, config2, options) {
|
|
|
8268
8259
|
}
|
|
8269
8260
|
});
|
|
8270
8261
|
const registries = ctx.registries;
|
|
8271
|
-
if (options.
|
|
8262
|
+
if (options.showPrompt) {
|
|
8272
8263
|
const task = registries.taskRegistry[taskId];
|
|
8273
8264
|
const targetAgent = task?.target_agent;
|
|
8274
8265
|
const agent = targetAgent ? registries.agentRegistry[targetAgent] : void 0;
|
|
@@ -8291,7 +8282,7 @@ async function runAgentTask(userRequest, taskId, config2, options) {
|
|
|
8291
8282
|
data: null,
|
|
8292
8283
|
raw: "",
|
|
8293
8284
|
prompt: fullPrompt,
|
|
8294
|
-
|
|
8285
|
+
showPrompt: true,
|
|
8295
8286
|
status: "success",
|
|
8296
8287
|
followUpsUsed: 0,
|
|
8297
8288
|
retriesUsed: 0
|
|
@@ -8322,7 +8313,7 @@ async function runAgentTask(userRequest, taskId, config2, options) {
|
|
|
8322
8313
|
data: outcome.data,
|
|
8323
8314
|
raw: outcome.raw ?? "",
|
|
8324
8315
|
prompt: userRequest,
|
|
8325
|
-
|
|
8316
|
+
showPrompt: false,
|
|
8326
8317
|
status: "success",
|
|
8327
8318
|
followUpsUsed: follow_ups_used,
|
|
8328
8319
|
retriesUsed: retries_used
|
|
@@ -8334,7 +8325,7 @@ async function runAgentTask(userRequest, taskId, config2, options) {
|
|
|
8334
8325
|
data: null,
|
|
8335
8326
|
raw: outcome.raw ?? "",
|
|
8336
8327
|
prompt: userRequest,
|
|
8337
|
-
|
|
8328
|
+
showPrompt: false,
|
|
8338
8329
|
status: "validation_error",
|
|
8339
8330
|
errorMessage: outcome.errors.join("; "),
|
|
8340
8331
|
followUpsUsed: follow_ups_used,
|
|
@@ -8347,7 +8338,7 @@ async function runAgentTask(userRequest, taskId, config2, options) {
|
|
|
8347
8338
|
data: null,
|
|
8348
8339
|
raw: outcome.raw ?? "",
|
|
8349
8340
|
prompt: userRequest,
|
|
8350
|
-
|
|
8341
|
+
showPrompt: false,
|
|
8351
8342
|
status: "escalation",
|
|
8352
8343
|
errorMessage: outcome.reason,
|
|
8353
8344
|
followUpsUsed: follow_ups_used,
|
|
@@ -8359,7 +8350,7 @@ async function runAgentTask(userRequest, taskId, config2, options) {
|
|
|
8359
8350
|
data: null,
|
|
8360
8351
|
raw: "",
|
|
8361
8352
|
prompt: userRequest,
|
|
8362
|
-
|
|
8353
|
+
showPrompt: false,
|
|
8363
8354
|
status: "error",
|
|
8364
8355
|
errorMessage: typeof outcome.message === "string" ? outcome.message : "Unknown agent error",
|
|
8365
8356
|
followUpsUsed: follow_ups_used,
|
|
@@ -8374,7 +8365,7 @@ function severityIndex(s) {
|
|
|
8374
8365
|
return idx === -1 ? 0 : idx;
|
|
8375
8366
|
}
|
|
8376
8367
|
function computeExitCode(result, options) {
|
|
8377
|
-
if (result.
|
|
8368
|
+
if (result.showPrompt) return 0;
|
|
8378
8369
|
if (result.status === "error" || result.status === "escalation" || result.status === "validation_error") {
|
|
8379
8370
|
return 1;
|
|
8380
8371
|
}
|
|
@@ -8400,8 +8391,8 @@ function severityIcon(severity) {
|
|
|
8400
8391
|
}
|
|
8401
8392
|
}
|
|
8402
8393
|
function formatResultText(result) {
|
|
8403
|
-
if (result.
|
|
8404
|
-
return `[
|
|
8394
|
+
if (result.showPrompt) {
|
|
8395
|
+
return `[SHOW PROMPT \u2014 prompt only, LLM was not called]
|
|
8405
8396
|
|
|
8406
8397
|
${result.prompt}`;
|
|
8407
8398
|
}
|
|
@@ -8474,14 +8465,14 @@ Generated at ${m.generatedAt ?? "\u2014"} by ${m.tool ?? "litedbmodel-gen"} (ada
|
|
|
8474
8465
|
return lines.join("\n");
|
|
8475
8466
|
}
|
|
8476
8467
|
function formatResultJson(result) {
|
|
8477
|
-
if (result.
|
|
8478
|
-
return JSON.stringify({
|
|
8468
|
+
if (result.showPrompt) {
|
|
8469
|
+
return JSON.stringify({ showPrompt: true, prompt: result.prompt }, null, 2);
|
|
8479
8470
|
}
|
|
8480
8471
|
return JSON.stringify(result.data, null, 2);
|
|
8481
8472
|
}
|
|
8482
8473
|
function formatResultYaml(result) {
|
|
8483
|
-
if (result.
|
|
8484
|
-
return jsYaml.dump({
|
|
8474
|
+
if (result.showPrompt) {
|
|
8475
|
+
return jsYaml.dump({ showPrompt: true, prompt: result.prompt });
|
|
8485
8476
|
}
|
|
8486
8477
|
return jsYaml.dump(result.data, { lineWidth: 120 });
|
|
8487
8478
|
}
|
|
@@ -8524,7 +8515,7 @@ async function commandAudit(target, opts) {
|
|
|
8524
8515
|
} : {}
|
|
8525
8516
|
};
|
|
8526
8517
|
const agentOpts = {
|
|
8527
|
-
|
|
8518
|
+
showPrompt: opts.showPrompt ?? false,
|
|
8528
8519
|
failOn: opts.failOn ?? "error",
|
|
8529
8520
|
logFile: opts.logFile
|
|
8530
8521
|
};
|
|
@@ -8600,7 +8591,7 @@ async function commandImplement(description, opts) {
|
|
|
8600
8591
|
} : {}
|
|
8601
8592
|
};
|
|
8602
8593
|
const agentOpts = {
|
|
8603
|
-
|
|
8594
|
+
showPrompt: opts.showPrompt ?? false,
|
|
8604
8595
|
failOn: opts.failOn ?? "error",
|
|
8605
8596
|
logFile: opts.logFile
|
|
8606
8597
|
};
|
|
@@ -23272,7 +23263,7 @@ var handlers = {
|
|
|
23272
23263
|
await commandAudit(target, {
|
|
23273
23264
|
adapter: opts.adapter,
|
|
23274
23265
|
model: opts.model,
|
|
23275
|
-
|
|
23266
|
+
showPrompt: opts.showPrompt,
|
|
23276
23267
|
failOn: opts.failOn,
|
|
23277
23268
|
output: opts.output,
|
|
23278
23269
|
reportFormat: opts.reportFormat
|
|
@@ -23285,7 +23276,7 @@ var handlers = {
|
|
|
23285
23276
|
models: opts.models,
|
|
23286
23277
|
adapter: opts.adapter,
|
|
23287
23278
|
model: opts.model,
|
|
23288
|
-
|
|
23279
|
+
showPrompt: opts.showPrompt,
|
|
23289
23280
|
failOn: opts.failOn,
|
|
23290
23281
|
output: opts.output,
|
|
23291
23282
|
reportFormat: opts.reportFormat
|