@content-reviewer/cli 0.0.2 → 0.0.4
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 +6 -6
- package/dist/index.js +79 -67
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# @content-reviewer/cli
|
|
2
2
|
|
|
3
|
-
CLI
|
|
3
|
+
An LLM-powered CLI for reviewing written content.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
### Global Installation
|
|
7
|
+
### Global Installation
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install -g @content-reviewer/cli
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
### Using npx
|
|
13
|
+
### Using npx
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
npx @content-reviewer/cli article.md
|
|
@@ -18,7 +18,7 @@ npx @content-reviewer/cli article.md
|
|
|
18
18
|
|
|
19
19
|
## Quick Start
|
|
20
20
|
|
|
21
|
-
### 1. Set up
|
|
21
|
+
### 1. Set up an API key
|
|
22
22
|
|
|
23
23
|
Set environment variables in your shell:
|
|
24
24
|
|
|
@@ -83,7 +83,7 @@ Create a `.reviewrc.json` file in your project root:
|
|
|
83
83
|
|
|
84
84
|
### Custom Instruction (Persona & Guidelines)
|
|
85
85
|
|
|
86
|
-
You can
|
|
86
|
+
You can provide an instruction file (e.g., Markdown) to define the reviewer's persona and guidelines:
|
|
87
87
|
|
|
88
88
|
```bash
|
|
89
89
|
content-review article.md --instruction ./my-instruction.md
|
|
@@ -102,7 +102,7 @@ Example instruction file:
|
|
|
102
102
|
|
|
103
103
|
```markdown
|
|
104
104
|
You are a strict technical editor.
|
|
105
|
-
Please review the
|
|
105
|
+
Please review the provided text for technical accuracy and clarity.
|
|
106
106
|
|
|
107
107
|
# Review Guidelines
|
|
108
108
|
|
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_core3 = 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_core2 = 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.4",
|
|
46
46
|
description: "CLI tool for reviewing written content using LLMs",
|
|
47
47
|
bin: {
|
|
48
48
|
"content-review": "./dist/index.js"
|
|
@@ -109,6 +109,68 @@ 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
|
+
|
|
112
174
|
// src/config-loader.ts
|
|
113
175
|
async function loadConfiguration(options) {
|
|
114
176
|
let fileConfig = {};
|
|
@@ -161,7 +223,8 @@ async function loadConfiguration(options) {
|
|
|
161
223
|
);
|
|
162
224
|
}
|
|
163
225
|
}
|
|
164
|
-
const
|
|
226
|
+
const severityLevel = options.severityLevel ?? fileConfig.severityLevel;
|
|
227
|
+
const config = (0, import_core2.createReviewConfig)({
|
|
165
228
|
...fileConfig,
|
|
166
229
|
instruction: instructionContent,
|
|
167
230
|
language: options.language ?? fileConfig.language,
|
|
@@ -170,9 +233,10 @@ async function loadConfiguration(options) {
|
|
|
170
233
|
provider: options.provider ?? fileConfig.llm?.provider,
|
|
171
234
|
apiKey: options.apiKey ?? fileConfig.llm?.apiKey,
|
|
172
235
|
model: options.model ?? fileConfig.llm?.model
|
|
173
|
-
}
|
|
236
|
+
},
|
|
237
|
+
severityLevel: severityLevel === CLI_OPTIONS.SEVERITY_LEVEL.defaultValue ? void 0 : severityLevel
|
|
174
238
|
});
|
|
175
|
-
(0,
|
|
239
|
+
(0, import_core2.validateConfig)(config);
|
|
176
240
|
return config;
|
|
177
241
|
}
|
|
178
242
|
|
|
@@ -284,19 +348,19 @@ async function handleReviewAction(file, options) {
|
|
|
284
348
|
if (config.instruction) {
|
|
285
349
|
import_consola2.consola.log(config.instruction);
|
|
286
350
|
} else {
|
|
287
|
-
const defaultInstruction = config.language === "ja" ?
|
|
351
|
+
const defaultInstruction = config.language === "ja" ? import_core3.DEFAULT_INSTRUCTION_JA : import_core3.DEFAULT_INSTRUCTION_EN;
|
|
288
352
|
import_consola2.consola.log(defaultInstruction);
|
|
289
353
|
import_consola2.consola.log("\n(Note: These are the default instructions for the selected language)");
|
|
290
354
|
}
|
|
291
355
|
import_consola2.consola.info("End of Preview");
|
|
292
356
|
process.exit(EXIT_CODES.SUCCESS);
|
|
293
357
|
}
|
|
294
|
-
(0,
|
|
358
|
+
(0, import_core3.resolveApiKey)(config);
|
|
295
359
|
import_consola2.consola.start(`Reading document: ${filePath}`);
|
|
296
360
|
const document = await readDocument(filePath);
|
|
297
361
|
import_consola2.consola.success(`Document read successfully`);
|
|
298
362
|
import_consola2.consola.start("Initializing AI reviewer...");
|
|
299
|
-
const reviewer = new
|
|
363
|
+
const reviewer = new import_core3.ContentReviewer(config);
|
|
300
364
|
import_consola2.consola.start("Reviewing content (this may take a moment)...");
|
|
301
365
|
const result = await reviewer.review(document);
|
|
302
366
|
if (options.json) {
|
|
@@ -317,65 +381,13 @@ async function handleReviewAction(file, options) {
|
|
|
317
381
|
}
|
|
318
382
|
}
|
|
319
383
|
|
|
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
|
-
API_KEY: {
|
|
341
|
-
flag: "--api-key <key>",
|
|
342
|
-
description: "LLM provider API key",
|
|
343
|
-
envVar: `${import_core3.ENV_VARS.OPENAI_API_KEY}, ${import_core3.ENV_VARS.ANTHROPIC_API_KEY}, or ${import_core3.ENV_VARS.GOOGLE_API_KEY}`
|
|
344
|
-
},
|
|
345
|
-
MODEL: {
|
|
346
|
-
flag: "--model <model>",
|
|
347
|
-
description: "LLM model to use",
|
|
348
|
-
defaultValue: Object.entries(import_core3.PROVIDER_DEFAULT_MODELS).map(([p, m]) => `${m} (${p})`).join(", ")
|
|
349
|
-
},
|
|
350
|
-
PROVIDER: {
|
|
351
|
-
flag: "--provider <provider>",
|
|
352
|
-
description: "LLM provider (openai, anthropic, google)",
|
|
353
|
-
defaultValue: import_core3.DEFAULT_LLM_CONFIG.provider
|
|
354
|
-
},
|
|
355
|
-
JSON: {
|
|
356
|
-
flag: "--json",
|
|
357
|
-
description: "output review result in JSON format (to stdout)",
|
|
358
|
-
defaultValue: false
|
|
359
|
-
},
|
|
360
|
-
DRY_RUN: {
|
|
361
|
-
flag: "--dry-run",
|
|
362
|
-
description: "display configuration and instructions without running review",
|
|
363
|
-
defaultValue: false
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
function getOptionDescription(option) {
|
|
367
|
-
let desc = option.description;
|
|
368
|
-
if (option.envVar) {
|
|
369
|
-
desc += ` (alternatively use ${option.envVar} env var)`;
|
|
370
|
-
}
|
|
371
|
-
if (option.defaultValue !== void 0) {
|
|
372
|
-
desc += ` (default: ${option.defaultValue})`;
|
|
373
|
-
}
|
|
374
|
-
return desc;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
384
|
// src/index.ts
|
|
385
|
+
var import_core4 = require("@content-reviewer/core");
|
|
378
386
|
var program = new import_commander.Command();
|
|
379
387
|
program.name(PROGRAM_NAME).description(PROGRAM_DESCRIPTION).version(PROGRAM_VERSION);
|
|
380
|
-
|
|
388
|
+
var severityLevelOption = new import_commander.Option(
|
|
389
|
+
CLI_OPTIONS.SEVERITY_LEVEL.flag,
|
|
390
|
+
getOptionDescription(CLI_OPTIONS.SEVERITY_LEVEL)
|
|
391
|
+
).choices(Object.keys(import_core4.SEVERITY_LEVELS)).default(CLI_OPTIONS.SEVERITY_LEVEL.defaultValue);
|
|
392
|
+
program.argument("<file>", "File to review").option(CLI_OPTIONS.CONFIG.flag, getOptionDescription(CLI_OPTIONS.CONFIG)).option(CLI_OPTIONS.INSTRUCTION.flag, getOptionDescription(CLI_OPTIONS.INSTRUCTION)).option(CLI_OPTIONS.OUTPUT.flag, getOptionDescription(CLI_OPTIONS.OUTPUT)).option(CLI_OPTIONS.LANGUAGE.flag, getOptionDescription(CLI_OPTIONS.LANGUAGE)).addOption(severityLevelOption).option(CLI_OPTIONS.PROVIDER.flag, getOptionDescription(CLI_OPTIONS.PROVIDER)).option(CLI_OPTIONS.MODEL.flag, getOptionDescription(CLI_OPTIONS.MODEL)).option(CLI_OPTIONS.API_KEY.flag, getOptionDescription(CLI_OPTIONS.API_KEY)).option(CLI_OPTIONS.JSON.flag, getOptionDescription(CLI_OPTIONS.JSON)).option(CLI_OPTIONS.DRY_RUN.flag, getOptionDescription(CLI_OPTIONS.DRY_RUN)).action(handleReviewAction);
|
|
381
393
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@content-reviewer/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
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.4"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^24.10.1",
|