@content-reviewer/cli 0.0.4 → 0.0.5
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/dist/index.js +73 -76
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -29,20 +29,20 @@ var import_commander = require("commander");
|
|
|
29
29
|
// src/commands/review.ts
|
|
30
30
|
var import_path2 = require("path");
|
|
31
31
|
var import_promises3 = require("fs/promises");
|
|
32
|
-
var
|
|
32
|
+
var import_core2 = require("@content-reviewer/core");
|
|
33
33
|
var import_consola2 = require("consola");
|
|
34
34
|
|
|
35
35
|
// src/config-loader.ts
|
|
36
36
|
var import_path = require("path");
|
|
37
37
|
var import_promises = require("fs/promises");
|
|
38
38
|
var import_cosmiconfig = require("cosmiconfig");
|
|
39
|
-
var
|
|
39
|
+
var import_core = require("@content-reviewer/core");
|
|
40
40
|
var import_consola = require("consola");
|
|
41
41
|
|
|
42
42
|
// package.json
|
|
43
43
|
var package_default = {
|
|
44
44
|
name: "@content-reviewer/cli",
|
|
45
|
-
version: "0.0.
|
|
45
|
+
version: "0.0.5",
|
|
46
46
|
description: "CLI tool for reviewing written content using LLMs",
|
|
47
47
|
bin: {
|
|
48
48
|
"content-review": "./dist/index.js"
|
|
@@ -109,68 +109,6 @@ var EXIT_CODES = {
|
|
|
109
109
|
ERROR: 1
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
// src/options.ts
|
|
113
|
-
var import_core = require("@content-reviewer/core");
|
|
114
|
-
var CLI_OPTIONS = {
|
|
115
|
-
CONFIG: {
|
|
116
|
-
flag: "-c, --config <path>",
|
|
117
|
-
description: "path to review configuration file"
|
|
118
|
-
},
|
|
119
|
-
INSTRUCTION: {
|
|
120
|
-
flag: "-i, --instruction <path>",
|
|
121
|
-
description: "path to review instruction file"
|
|
122
|
-
},
|
|
123
|
-
OUTPUT: {
|
|
124
|
-
flag: "-o, --output <path>",
|
|
125
|
-
description: "output review result file path (JSON format)"
|
|
126
|
-
},
|
|
127
|
-
LANGUAGE: {
|
|
128
|
-
flag: "-l, --language <lang>",
|
|
129
|
-
description: "review language (ja, en)",
|
|
130
|
-
defaultValue: import_core.DEFAULT_CONFIG.language
|
|
131
|
-
},
|
|
132
|
-
SEVERITY_LEVEL: {
|
|
133
|
-
flag: "-s, --severity-level <level>",
|
|
134
|
-
description: `minimum severity level to display (${Object.keys(import_core.SEVERITY_LEVELS).join(", ")})`,
|
|
135
|
-
defaultValue: import_core.DEFAULT_SEVERITY_LEVEL
|
|
136
|
-
},
|
|
137
|
-
API_KEY: {
|
|
138
|
-
flag: "--api-key <key>",
|
|
139
|
-
description: "LLM provider API key",
|
|
140
|
-
envVar: `${import_core.ENV_VARS.OPENAI_API_KEY}, ${import_core.ENV_VARS.ANTHROPIC_API_KEY}, or ${import_core.ENV_VARS.GOOGLE_API_KEY}`
|
|
141
|
-
},
|
|
142
|
-
MODEL: {
|
|
143
|
-
flag: "--model <model>",
|
|
144
|
-
description: "LLM model to use",
|
|
145
|
-
defaultValue: Object.entries(import_core.PROVIDER_DEFAULT_MODELS).map(([p, m]) => `${m} (${p})`).join(", ")
|
|
146
|
-
},
|
|
147
|
-
PROVIDER: {
|
|
148
|
-
flag: "--provider <provider>",
|
|
149
|
-
description: "LLM provider (openai, anthropic, google)",
|
|
150
|
-
defaultValue: import_core.DEFAULT_LLM_CONFIG.provider
|
|
151
|
-
},
|
|
152
|
-
JSON: {
|
|
153
|
-
flag: "--json",
|
|
154
|
-
description: "output review result in JSON format (to stdout)",
|
|
155
|
-
defaultValue: false
|
|
156
|
-
},
|
|
157
|
-
DRY_RUN: {
|
|
158
|
-
flag: "--dry-run",
|
|
159
|
-
description: "display configuration and instructions without running review",
|
|
160
|
-
defaultValue: false
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
function getOptionDescription(option) {
|
|
164
|
-
let desc = option.description;
|
|
165
|
-
if (option.envVar) {
|
|
166
|
-
desc += ` (alternatively use ${option.envVar} env var)`;
|
|
167
|
-
}
|
|
168
|
-
if (option.defaultValue !== void 0) {
|
|
169
|
-
desc += ` (default: ${option.defaultValue})`;
|
|
170
|
-
}
|
|
171
|
-
return desc;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
112
|
// src/config-loader.ts
|
|
175
113
|
async function loadConfiguration(options) {
|
|
176
114
|
let fileConfig = {};
|
|
@@ -224,7 +162,7 @@ async function loadConfiguration(options) {
|
|
|
224
162
|
}
|
|
225
163
|
}
|
|
226
164
|
const severityLevel = options.severityLevel ?? fileConfig.severityLevel;
|
|
227
|
-
const config = (0,
|
|
165
|
+
const config = (0, import_core.createReviewConfig)({
|
|
228
166
|
...fileConfig,
|
|
229
167
|
instruction: instructionContent,
|
|
230
168
|
language: options.language ?? fileConfig.language,
|
|
@@ -234,9 +172,9 @@ async function loadConfiguration(options) {
|
|
|
234
172
|
apiKey: options.apiKey ?? fileConfig.llm?.apiKey,
|
|
235
173
|
model: options.model ?? fileConfig.llm?.model
|
|
236
174
|
},
|
|
237
|
-
severityLevel
|
|
175
|
+
severityLevel
|
|
238
176
|
});
|
|
239
|
-
(0,
|
|
177
|
+
(0, import_core.validateConfig)(config);
|
|
240
178
|
return config;
|
|
241
179
|
}
|
|
242
180
|
|
|
@@ -263,11 +201,6 @@ function formatReviewResult(result) {
|
|
|
263
201
|
let output = "";
|
|
264
202
|
output += `${import_picocolors.default.bold(`Review Result: ${result.source}`)}
|
|
265
203
|
|
|
266
|
-
`;
|
|
267
|
-
output += `${import_picocolors.default.bold("Summary:")}
|
|
268
|
-
`;
|
|
269
|
-
output += `${result.summary}
|
|
270
|
-
|
|
271
204
|
`;
|
|
272
205
|
if (result.issues.length === 0) {
|
|
273
206
|
output += `${import_picocolors.default.green("\u2713 No issues found!")}
|
|
@@ -348,19 +281,19 @@ async function handleReviewAction(file, options) {
|
|
|
348
281
|
if (config.instruction) {
|
|
349
282
|
import_consola2.consola.log(config.instruction);
|
|
350
283
|
} else {
|
|
351
|
-
const defaultInstruction = config.language === "ja" ?
|
|
284
|
+
const defaultInstruction = config.language === "ja" ? import_core2.DEFAULT_INSTRUCTION_JA : import_core2.DEFAULT_INSTRUCTION_EN;
|
|
352
285
|
import_consola2.consola.log(defaultInstruction);
|
|
353
286
|
import_consola2.consola.log("\n(Note: These are the default instructions for the selected language)");
|
|
354
287
|
}
|
|
355
288
|
import_consola2.consola.info("End of Preview");
|
|
356
289
|
process.exit(EXIT_CODES.SUCCESS);
|
|
357
290
|
}
|
|
358
|
-
(0,
|
|
291
|
+
(0, import_core2.resolveApiKey)(config);
|
|
359
292
|
import_consola2.consola.start(`Reading document: ${filePath}`);
|
|
360
293
|
const document = await readDocument(filePath);
|
|
361
294
|
import_consola2.consola.success(`Document read successfully`);
|
|
362
295
|
import_consola2.consola.start("Initializing AI reviewer...");
|
|
363
|
-
const reviewer = new
|
|
296
|
+
const reviewer = new import_core2.ContentReviewer(config);
|
|
364
297
|
import_consola2.consola.start("Reviewing content (this may take a moment)...");
|
|
365
298
|
const result = await reviewer.review(document);
|
|
366
299
|
if (options.json) {
|
|
@@ -383,6 +316,70 @@ async function handleReviewAction(file, options) {
|
|
|
383
316
|
|
|
384
317
|
// src/index.ts
|
|
385
318
|
var import_core4 = require("@content-reviewer/core");
|
|
319
|
+
|
|
320
|
+
// src/options.ts
|
|
321
|
+
var import_core3 = require("@content-reviewer/core");
|
|
322
|
+
var CLI_OPTIONS = {
|
|
323
|
+
CONFIG: {
|
|
324
|
+
flag: "-c, --config <path>",
|
|
325
|
+
description: "path to review configuration file"
|
|
326
|
+
},
|
|
327
|
+
INSTRUCTION: {
|
|
328
|
+
flag: "-i, --instruction <path>",
|
|
329
|
+
description: "path to review instruction file"
|
|
330
|
+
},
|
|
331
|
+
OUTPUT: {
|
|
332
|
+
flag: "-o, --output <path>",
|
|
333
|
+
description: "output review result file path (JSON format)"
|
|
334
|
+
},
|
|
335
|
+
LANGUAGE: {
|
|
336
|
+
flag: "-l, --language <lang>",
|
|
337
|
+
description: "review language (ja, en)",
|
|
338
|
+
defaultValue: import_core3.DEFAULT_CONFIG.language
|
|
339
|
+
},
|
|
340
|
+
SEVERITY_LEVEL: {
|
|
341
|
+
flag: "-s, --severity-level <level>",
|
|
342
|
+
description: `minimum severity level to display (${Object.keys(import_core3.SEVERITY_LEVELS).join(", ")})`,
|
|
343
|
+
defaultValue: import_core3.DEFAULT_SEVERITY_LEVEL
|
|
344
|
+
},
|
|
345
|
+
API_KEY: {
|
|
346
|
+
flag: "--api-key <key>",
|
|
347
|
+
description: "LLM provider API key",
|
|
348
|
+
envVar: `${import_core3.ENV_VARS.OPENAI_API_KEY}, ${import_core3.ENV_VARS.ANTHROPIC_API_KEY}, or ${import_core3.ENV_VARS.GOOGLE_API_KEY}`
|
|
349
|
+
},
|
|
350
|
+
MODEL: {
|
|
351
|
+
flag: "--model <model>",
|
|
352
|
+
description: "LLM model to use",
|
|
353
|
+
defaultValue: Object.entries(import_core3.PROVIDER_DEFAULT_MODELS).map(([p, m]) => `${m} (${p})`).join(", ")
|
|
354
|
+
},
|
|
355
|
+
PROVIDER: {
|
|
356
|
+
flag: "--provider <provider>",
|
|
357
|
+
description: "LLM provider (openai, anthropic, google)",
|
|
358
|
+
defaultValue: import_core3.DEFAULT_LLM_CONFIG.provider
|
|
359
|
+
},
|
|
360
|
+
JSON: {
|
|
361
|
+
flag: "--json",
|
|
362
|
+
description: "output review result in JSON format (to stdout)",
|
|
363
|
+
defaultValue: false
|
|
364
|
+
},
|
|
365
|
+
DRY_RUN: {
|
|
366
|
+
flag: "--dry-run",
|
|
367
|
+
description: "display configuration and instructions without running review",
|
|
368
|
+
defaultValue: false
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
function getOptionDescription(option) {
|
|
372
|
+
let desc = option.description;
|
|
373
|
+
if (option.envVar) {
|
|
374
|
+
desc += ` (alternatively use ${option.envVar} env var)`;
|
|
375
|
+
}
|
|
376
|
+
if (option.defaultValue !== void 0) {
|
|
377
|
+
desc += ` (default: ${option.defaultValue})`;
|
|
378
|
+
}
|
|
379
|
+
return desc;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// src/index.ts
|
|
386
383
|
var program = new import_commander.Command();
|
|
387
384
|
program.name(PROGRAM_NAME).description(PROGRAM_DESCRIPTION).version(PROGRAM_VERSION);
|
|
388
385
|
var severityLevelOption = new import_commander.Option(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@content-reviewer/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "CLI tool for reviewing written content using LLMs",
|
|
5
5
|
"bin": {
|
|
6
6
|
"content-review": "./dist/index.js"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"consola": "^3.4.2",
|
|
42
42
|
"cosmiconfig": "^9.0.0",
|
|
43
43
|
"picocolors": "^1.1.1",
|
|
44
|
-
"@content-reviewer/core": "0.0.
|
|
44
|
+
"@content-reviewer/core": "0.0.5"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^24.10.1",
|