@content-reviewer/cli 0.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.
- package/README.md +111 -0
- package/dist/LICENSE +21 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +381 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# @content-reviewer/cli
|
|
2
|
+
|
|
3
|
+
CLI tool for reviewing written content using LLMs.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Global Installation (Recommended)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @content-reviewer/cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Using npx (No Installation Required)
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx @content-reviewer/cli article.md
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
### 1. Set up your API key
|
|
22
|
+
|
|
23
|
+
Set environment variables in your shell:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# For OpenAI (default)
|
|
27
|
+
export OPENAI_API_KEY="sk-..."
|
|
28
|
+
|
|
29
|
+
# For Anthropic Claude
|
|
30
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
31
|
+
|
|
32
|
+
# For Google
|
|
33
|
+
export GOOGLE_API_KEY="..."
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Alternatively, pass the API key directly using the `--api-key` option:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
content-review article.md --api-key "sk-..."
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 2. Review your content
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
content-review article.md
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
content-review -h
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Examples
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Review in Japanese
|
|
58
|
+
content-review article.md --language ja
|
|
59
|
+
|
|
60
|
+
# Use Anthropic Claude
|
|
61
|
+
content-review article.md --provider anthropic --model claude-sonnet-4-5
|
|
62
|
+
|
|
63
|
+
# Use custom configuration
|
|
64
|
+
content-review article.md -c .reviewrc.json
|
|
65
|
+
|
|
66
|
+
# Save results to JSON file
|
|
67
|
+
content-review article.md -o review-results.json
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Configuration
|
|
71
|
+
|
|
72
|
+
Create a `.reviewrc.json` file in your project root:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"language": "en",
|
|
77
|
+
"llm": {
|
|
78
|
+
"provider": "openai",
|
|
79
|
+
"model": "gpt-4.1-mini"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Custom Instruction (Persona & Guidelines)
|
|
85
|
+
|
|
86
|
+
You can use a text file (such as a Markdown file) for review instructions, defining the reviewer's persona and specific guidelines:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
content-review article.md --instruction ./my-instruction.md
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Or via config file:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"instructionFile": "./my-instruction.md",
|
|
97
|
+
"language": "en"
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Example instruction file:
|
|
102
|
+
|
|
103
|
+
```markdown
|
|
104
|
+
You are a strict technical editor.
|
|
105
|
+
Please review the following text for technical accuracy and clarity.
|
|
106
|
+
|
|
107
|
+
# Review Guidelines
|
|
108
|
+
|
|
109
|
+
- Ensure all code examples are correct.
|
|
110
|
+
- Check for passive voice usage.
|
|
111
|
+
```
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 atkei
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/index.ts
|
|
27
|
+
var import_commander = require("commander");
|
|
28
|
+
|
|
29
|
+
// src/commands/review.ts
|
|
30
|
+
var import_path2 = require("path");
|
|
31
|
+
var import_promises3 = require("fs/promises");
|
|
32
|
+
var import_core2 = require("@content-reviewer/core");
|
|
33
|
+
var import_consola2 = require("consola");
|
|
34
|
+
|
|
35
|
+
// src/config-loader.ts
|
|
36
|
+
var import_path = require("path");
|
|
37
|
+
var import_promises = require("fs/promises");
|
|
38
|
+
var import_cosmiconfig = require("cosmiconfig");
|
|
39
|
+
var import_core = require("@content-reviewer/core");
|
|
40
|
+
var import_consola = require("consola");
|
|
41
|
+
|
|
42
|
+
// package.json
|
|
43
|
+
var package_default = {
|
|
44
|
+
name: "@content-reviewer/cli",
|
|
45
|
+
version: "0.0.1",
|
|
46
|
+
description: "CLI tool for reviewing written content using LLMs",
|
|
47
|
+
bin: {
|
|
48
|
+
"content-review": "./dist/index.js"
|
|
49
|
+
},
|
|
50
|
+
main: "./dist/index.js",
|
|
51
|
+
types: "./dist/index.d.ts",
|
|
52
|
+
files: [
|
|
53
|
+
"dist"
|
|
54
|
+
],
|
|
55
|
+
scripts: {
|
|
56
|
+
build: "tsup src/index.ts --format cjs --dts --clean",
|
|
57
|
+
dev: "tsup src/index.ts --format cjs --dts --watch",
|
|
58
|
+
test: "vitest run",
|
|
59
|
+
clean: "rm -rf dist"
|
|
60
|
+
},
|
|
61
|
+
keywords: [
|
|
62
|
+
"ai",
|
|
63
|
+
"llm",
|
|
64
|
+
"markdown",
|
|
65
|
+
"proofreading",
|
|
66
|
+
"content-review",
|
|
67
|
+
"cli"
|
|
68
|
+
],
|
|
69
|
+
author: "atkei",
|
|
70
|
+
license: "MIT",
|
|
71
|
+
repository: {
|
|
72
|
+
type: "git",
|
|
73
|
+
url: "https://github.com/atkei/content-reviewer.git",
|
|
74
|
+
directory: "packages/cli"
|
|
75
|
+
},
|
|
76
|
+
homepage: "https://github.com/atkei/content-reviewer#readme",
|
|
77
|
+
bugs: {
|
|
78
|
+
url: "https://github.com/atkei/content-reviewer/issues"
|
|
79
|
+
},
|
|
80
|
+
engines: {
|
|
81
|
+
node: ">=20.0.0",
|
|
82
|
+
pnpm: ">=9.0.0"
|
|
83
|
+
},
|
|
84
|
+
publishConfig: {
|
|
85
|
+
access: "public"
|
|
86
|
+
},
|
|
87
|
+
dependencies: {
|
|
88
|
+
"@content-reviewer/core": "workspace:*",
|
|
89
|
+
commander: "^14.0.2",
|
|
90
|
+
consola: "^3.4.2",
|
|
91
|
+
cosmiconfig: "^9.0.0",
|
|
92
|
+
picocolors: "^1.1.1"
|
|
93
|
+
},
|
|
94
|
+
devDependencies: {
|
|
95
|
+
"@types/node": "^24.10.1",
|
|
96
|
+
tsup: "^8.5.1",
|
|
97
|
+
typescript: "^5.9.3",
|
|
98
|
+
vitest: "^4.0.9"
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/constants.ts
|
|
103
|
+
var PROGRAM_NAME = "content-review";
|
|
104
|
+
var PROGRAM_DESCRIPTION = package_default.description;
|
|
105
|
+
var PROGRAM_VERSION = package_default.version;
|
|
106
|
+
var CONFIG_MODULE_NAME = "reviewrc";
|
|
107
|
+
var EXIT_CODES = {
|
|
108
|
+
SUCCESS: 0,
|
|
109
|
+
ERROR: 1
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// src/config-loader.ts
|
|
113
|
+
async function loadConfiguration(options) {
|
|
114
|
+
let fileConfig = {};
|
|
115
|
+
let configDir = process.cwd();
|
|
116
|
+
if (options.config && typeof options.config === "string") {
|
|
117
|
+
const configPath = (0, import_path.resolve)(process.cwd(), options.config);
|
|
118
|
+
try {
|
|
119
|
+
const explorer = (0, import_cosmiconfig.cosmiconfig)(CONFIG_MODULE_NAME);
|
|
120
|
+
const result = await explorer.load(configPath);
|
|
121
|
+
if (result) {
|
|
122
|
+
fileConfig = result.config;
|
|
123
|
+
configDir = (0, import_path.dirname)(result.filepath);
|
|
124
|
+
}
|
|
125
|
+
} catch (error) {
|
|
126
|
+
import_consola.consola.warn(
|
|
127
|
+
`Failed to load config file: ${error instanceof Error ? error.message : String(error)}`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
try {
|
|
132
|
+
const explorer = (0, import_cosmiconfig.cosmiconfig)(CONFIG_MODULE_NAME);
|
|
133
|
+
const result = await explorer.search();
|
|
134
|
+
if (result) {
|
|
135
|
+
fileConfig = result.config;
|
|
136
|
+
configDir = (0, import_path.dirname)(result.filepath);
|
|
137
|
+
import_consola.consola.success(`Loaded config from: ${result.filepath}`);
|
|
138
|
+
}
|
|
139
|
+
} catch {
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
let instructionContent;
|
|
143
|
+
if (options.instruction && typeof options.instruction === "string") {
|
|
144
|
+
try {
|
|
145
|
+
const instructionPath = (0, import_path.resolve)(process.cwd(), options.instruction);
|
|
146
|
+
instructionContent = await (0, import_promises.readFile)(instructionPath, "utf-8");
|
|
147
|
+
import_consola.consola.success(`Loaded instruction from: ${instructionPath}`);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
import_consola.consola.warn(
|
|
150
|
+
`Failed to load instruction file: ${error instanceof Error ? error.message : String(error)}`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
} else if (fileConfig.instructionFile) {
|
|
154
|
+
try {
|
|
155
|
+
const instructionPath = (0, import_path.resolve)(configDir, fileConfig.instructionFile);
|
|
156
|
+
instructionContent = await (0, import_promises.readFile)(instructionPath, "utf-8");
|
|
157
|
+
import_consola.consola.success(`Loaded instruction from: ${instructionPath}`);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
import_consola.consola.warn(
|
|
160
|
+
`Failed to load instruction file from config: ${error instanceof Error ? error.message : String(error)}`
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const config = (0, import_core.createReviewConfig)({
|
|
165
|
+
...fileConfig,
|
|
166
|
+
instruction: instructionContent,
|
|
167
|
+
language: options.language ?? fileConfig.language,
|
|
168
|
+
llm: {
|
|
169
|
+
...fileConfig.llm,
|
|
170
|
+
provider: options.provider ?? fileConfig.llm?.provider,
|
|
171
|
+
apiKey: options.apiKey ?? fileConfig.llm?.apiKey,
|
|
172
|
+
model: options.model ?? fileConfig.llm?.model
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
(0, import_core.validateConfig)(config);
|
|
176
|
+
return config;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// src/document.ts
|
|
180
|
+
var import_promises2 = require("fs/promises");
|
|
181
|
+
async function readDocument(filePath) {
|
|
182
|
+
try {
|
|
183
|
+
const rawContent = await (0, import_promises2.readFile)(filePath, "utf-8");
|
|
184
|
+
return {
|
|
185
|
+
rawContent,
|
|
186
|
+
source: filePath
|
|
187
|
+
};
|
|
188
|
+
} catch (error) {
|
|
189
|
+
if (error instanceof Error) {
|
|
190
|
+
throw new Error(`Failed to read file ${filePath}: ${error.message}`);
|
|
191
|
+
}
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// src/utils.ts
|
|
197
|
+
var import_picocolors = __toESM(require("picocolors"));
|
|
198
|
+
function formatReviewResult(result) {
|
|
199
|
+
let output = "";
|
|
200
|
+
output += `${import_picocolors.default.bold(`Review Result: ${result.source}`)}
|
|
201
|
+
|
|
202
|
+
`;
|
|
203
|
+
output += `${import_picocolors.default.bold("Summary:")}
|
|
204
|
+
`;
|
|
205
|
+
output += `${result.summary}
|
|
206
|
+
|
|
207
|
+
`;
|
|
208
|
+
if (result.issues.length === 0) {
|
|
209
|
+
output += `${import_picocolors.default.green("\u2713 No issues found!")}
|
|
210
|
+
`;
|
|
211
|
+
} else {
|
|
212
|
+
output += `${import_picocolors.default.bold(`Issues (${result.issues.length}):`)}
|
|
213
|
+
|
|
214
|
+
`;
|
|
215
|
+
result.issues.forEach((issue, index) => {
|
|
216
|
+
output += formatIssue(issue, index + 1);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return output;
|
|
220
|
+
}
|
|
221
|
+
function formatIssue(issue, index) {
|
|
222
|
+
const severityIcon = getSeverityIcon(issue.severity);
|
|
223
|
+
const severityColorFn = getSeverityColorFn(issue.severity);
|
|
224
|
+
let output = `${import_picocolors.default.bold(`${index}.`)} `;
|
|
225
|
+
output += `${severityColorFn(`${severityIcon} ${issue.severity.toUpperCase()}`)}
|
|
226
|
+
`;
|
|
227
|
+
if (issue.lineNumber) {
|
|
228
|
+
output += ` ${import_picocolors.default.gray(`Line ${issue.lineNumber}:`)} `;
|
|
229
|
+
} else {
|
|
230
|
+
output += ` `;
|
|
231
|
+
}
|
|
232
|
+
output += `${issue.message}
|
|
233
|
+
`;
|
|
234
|
+
if (issue.matchText) {
|
|
235
|
+
output += ` ${import_picocolors.default.gray(`Snippet: "${issue.matchText}"`)}
|
|
236
|
+
`;
|
|
237
|
+
}
|
|
238
|
+
if (issue.suggestion) {
|
|
239
|
+
output += ` ${import_picocolors.default.cyan("\u{1F4A1} Suggestion:")} ${issue.suggestion}
|
|
240
|
+
`;
|
|
241
|
+
}
|
|
242
|
+
output += "\n";
|
|
243
|
+
return output;
|
|
244
|
+
}
|
|
245
|
+
function getSeverityIcon(severity) {
|
|
246
|
+
switch (severity) {
|
|
247
|
+
case "error":
|
|
248
|
+
return "\u2717";
|
|
249
|
+
case "warning":
|
|
250
|
+
return "\u26A0";
|
|
251
|
+
case "suggestion":
|
|
252
|
+
return "\u{1F4A1}";
|
|
253
|
+
default:
|
|
254
|
+
return "\u2022";
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function getSeverityColorFn(severity) {
|
|
258
|
+
switch (severity) {
|
|
259
|
+
case "error":
|
|
260
|
+
return import_picocolors.default.red;
|
|
261
|
+
case "warning":
|
|
262
|
+
return import_picocolors.default.yellow;
|
|
263
|
+
case "suggestion":
|
|
264
|
+
return import_picocolors.default.cyan;
|
|
265
|
+
default:
|
|
266
|
+
return (text) => text;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function formatReviewResultJSON(result) {
|
|
270
|
+
return JSON.stringify(result, null, 2);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// src/commands/review.ts
|
|
274
|
+
async function handleReviewAction(file, options) {
|
|
275
|
+
try {
|
|
276
|
+
const filePath = (0, import_path2.resolve)(process.cwd(), file);
|
|
277
|
+
const config = await loadConfiguration(options);
|
|
278
|
+
if (options.dryRun) {
|
|
279
|
+
import_consola2.consola.info("Dry Run: Configuration Preview");
|
|
280
|
+
import_consola2.consola.log(`Target File: ${filePath}`);
|
|
281
|
+
import_consola2.consola.log(`Model: ${config.llm.model} (${config.llm.provider})`);
|
|
282
|
+
import_consola2.consola.log(`Language: ${config.language}`);
|
|
283
|
+
import_consola2.consola.log("\n[Applied Instructions]");
|
|
284
|
+
if (config.instruction) {
|
|
285
|
+
import_consola2.consola.log(config.instruction);
|
|
286
|
+
} else {
|
|
287
|
+
const defaultInstruction = config.language === "ja" ? import_core2.DEFAULT_INSTRUCTION_JA : import_core2.DEFAULT_INSTRUCTION_EN;
|
|
288
|
+
import_consola2.consola.log(defaultInstruction);
|
|
289
|
+
import_consola2.consola.log("\n(Note: These are the default instructions for the selected language)");
|
|
290
|
+
}
|
|
291
|
+
import_consola2.consola.info("End of Preview");
|
|
292
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
293
|
+
}
|
|
294
|
+
(0, import_core2.resolveApiKey)(config);
|
|
295
|
+
import_consola2.consola.start(`Reading document: ${filePath}`);
|
|
296
|
+
const document = await readDocument(filePath);
|
|
297
|
+
import_consola2.consola.success(`Document read successfully`);
|
|
298
|
+
import_consola2.consola.start("Initializing AI reviewer...");
|
|
299
|
+
const reviewer = new import_core2.ContentReviewer(config);
|
|
300
|
+
import_consola2.consola.start("Reviewing content (this may take a moment)...");
|
|
301
|
+
const result = await reviewer.review(document);
|
|
302
|
+
if (options.json) {
|
|
303
|
+
import_consola2.consola.log(formatReviewResultJSON(result));
|
|
304
|
+
} else {
|
|
305
|
+
import_consola2.consola.log(formatReviewResult(result));
|
|
306
|
+
}
|
|
307
|
+
if (options.output && typeof options.output === "string") {
|
|
308
|
+
const outputPath = (0, import_path2.resolve)(process.cwd(), options.output);
|
|
309
|
+
await (0, import_promises3.writeFile)(outputPath, formatReviewResultJSON(result), "utf-8");
|
|
310
|
+
import_consola2.consola.success(`Results saved to: ${outputPath}`);
|
|
311
|
+
}
|
|
312
|
+
const hasErrors = result.issues.some((issue) => issue.severity === "error");
|
|
313
|
+
process.exit(hasErrors ? EXIT_CODES.ERROR : EXIT_CODES.SUCCESS);
|
|
314
|
+
} catch (error) {
|
|
315
|
+
import_consola2.consola.error("Error:", error instanceof Error ? error.message : String(error));
|
|
316
|
+
process.exit(EXIT_CODES.ERROR);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
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
|
+
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
|
+
// src/index.ts
|
|
378
|
+
var program = new import_commander.Command();
|
|
379
|
+
program.name(PROGRAM_NAME).description(PROGRAM_DESCRIPTION).version(PROGRAM_VERSION);
|
|
380
|
+
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)).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
|
+
program.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@content-reviewer/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "CLI tool for reviewing written content using LLMs",
|
|
5
|
+
"bin": {
|
|
6
|
+
"content-review": "./dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsup src/index.ts --format cjs --dts --clean",
|
|
15
|
+
"dev": "tsup src/index.ts --format cjs --dts --watch",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"clean": "rm -rf dist"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"ai",
|
|
21
|
+
"llm",
|
|
22
|
+
"markdown",
|
|
23
|
+
"proofreading",
|
|
24
|
+
"content-review",
|
|
25
|
+
"cli"
|
|
26
|
+
],
|
|
27
|
+
"author": "atkei",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/atkei/content-reviewer.git",
|
|
32
|
+
"directory": "packages/cli"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/atkei/content-reviewer#readme",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/atkei/content-reviewer/issues"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=20.0.0",
|
|
40
|
+
"pnpm": ">=9.0.0"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@content-reviewer/core": "workspace:*",
|
|
47
|
+
"commander": "^14.0.2",
|
|
48
|
+
"consola": "^3.4.2",
|
|
49
|
+
"cosmiconfig": "^9.0.0",
|
|
50
|
+
"picocolors": "^1.1.1"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/node": "^24.10.1",
|
|
54
|
+
"tsup": "^8.5.1",
|
|
55
|
+
"typescript": "^5.9.3",
|
|
56
|
+
"vitest": "^4.0.9"
|
|
57
|
+
}
|
|
58
|
+
}
|