feat(lmc): add --git-message and --review modes, standardize args casing
This commit is contained in:
parent
fc7d9101e9
commit
f3146ab087
1 changed files with 30 additions and 6 deletions
36
index.ts
36
index.ts
|
|
@ -17,9 +17,14 @@ const { values: args, positionals } = util.parseArgs({
|
||||||
config: { type: "boolean" },
|
config: { type: "boolean" },
|
||||||
c: { type: "boolean" },
|
c: { type: "boolean" },
|
||||||
plain: { type: "boolean" },
|
plain: { type: "boolean" },
|
||||||
plainOut: { type: "boolean" },
|
"plain-out": { type: "boolean" },
|
||||||
plainErr: { type: "boolean" },
|
"plain-err": { type: "boolean" },
|
||||||
|
version: { type: "boolean" },
|
||||||
v: { type: "boolean" },
|
v: { type: "boolean" },
|
||||||
|
"git-message": { type: "boolean" },
|
||||||
|
g: { type: "boolean" },
|
||||||
|
review: { type: "boolean" },
|
||||||
|
r: { type: "boolean" },
|
||||||
},
|
},
|
||||||
strict: true,
|
strict: true,
|
||||||
allowPositionals: true,
|
allowPositionals: true,
|
||||||
|
|
@ -27,12 +32,15 @@ const { values: args, positionals } = util.parseArgs({
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const newConvo = args.new ?? args.n;
|
const newConvo = args.new ?? args.n;
|
||||||
const plainOut = args.plainOut ?? args.plain ?? !process.stdout.isTTY;
|
const plainOut = args["plain-out"] ?? args.plain ?? !process.stdout.isTTY;
|
||||||
const plainErr = args.plainErr ?? args.plain ?? !process.stderr.isTTY;
|
const plainErr = args["plain-err"] ?? args.plain ?? !process.stderr.isTTY;
|
||||||
const modelFlag = args.model ?? args.m;
|
const modelFlag = args.model ?? args.m;
|
||||||
|
const versionFlag = args.version ?? args.v;
|
||||||
const configFlag = args.config ?? args.c;
|
const configFlag = args.config ?? args.c;
|
||||||
|
const messageFlag = args["git-message"] ?? args.g;
|
||||||
|
const reviewFlag = args.review ?? args.r;
|
||||||
|
|
||||||
if (args.v) {
|
if (versionFlag) {
|
||||||
console.log("0.0.0");
|
console.log("0.0.0");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +70,23 @@ async function main() {
|
||||||
if (modelFlag) convo.model = modelFlag;
|
if (modelFlag) convo.model = modelFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
const prompt = positionals.join(" ") || "Introduce yourself.";
|
let prompt = "Introduce yourself.";
|
||||||
|
const input = positionals.join(" ").trim();
|
||||||
|
if (messageFlag) {
|
||||||
|
prompt = `\`\`\`diff
|
||||||
|
${input}
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
Generate a conventional commit message for this diff. If you are unable to generate a reasonable option, ask for more context.`;
|
||||||
|
} else if (reviewFlag) {
|
||||||
|
prompt = `\`\`\`diff
|
||||||
|
${input}
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
Review the above diff for any potential bugs, best practices, performance issues, or security flaws. Let me know if you need any more context to compelete your review.`;
|
||||||
|
} else if (input) {
|
||||||
|
prompt = input;
|
||||||
|
}
|
||||||
convo.messages.push({ role: "user", content: prompt });
|
convo.messages.push({ role: "user", content: prompt });
|
||||||
|
|
||||||
const { fullStream, text, totalUsage } = streamText({
|
const { fullStream, text, totalUsage } = streamText({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue