feat(config): add interactive config editor and GitLab PR support #4

Merged
Mplan merged 8 commits from v0.1.2 into main 2026-06-12 09:00:29 +08:00
Showing only changes of commit 14df49b110 - Show all commits
+28 -15
View File
@@ -611,11 +611,14 @@ async function showMenu(): Promise<void> {
if (selected === null || selected === BACK) return;
if (selected === "commit") await handleCommit(false, false);
else if (selected === "pr") await handlePR(false);
else await handleConfig();
const result =
selected === "commit"
? await handleCommit(false, false)
: selected === "pr"
? await handlePR(false)
: await handleConfig();
return;
if (result !== "back") return;
}
}
@@ -660,9 +663,13 @@ async function handleCommit(
const unstagedFiles = await getUnstagedFiles();
if (stagedFiles.length === 0 && unstagedFiles.length === 0) {
console.log(`\n ${YELLOW}Nothing to commit.${RESET}`);
await ask(` ${DIM}Press Enter to exit...${RESET}`);
process.exit(0);
const choice = await selectOne({
title: "Nothing to commit",
subtitle: "No staged or unstaged changes.",
items: [{ label: "Back", value: "back" as const }],
});
if (choice === null) process.exit(0);
return "done";
}
if (unstagedFiles.length > 0) {
@@ -685,9 +692,13 @@ async function handleCommit(
const diff = await getStagedDiff();
if (!diff) {
console.log(`\n ${YELLOW}No staged changes to commit.${RESET}`);
await ask(` ${DIM}Press Enter to exit...${RESET}`);
process.exit(0);
const choice = await selectOne({
title: "Nothing to commit",
subtitle: "No staged changes to commit.",
items: [{ label: "Back", value: "back" as const }],
});
if (choice === null) process.exit(0);
return "done";
}
const MAX_DIFF_SIZE = 15000;
@@ -815,11 +826,13 @@ async function handlePR(draft: boolean): Promise<"done" | "back"> {
const commits = await getBranchCommits(baseBranch);
if (commits.length === 0) {
console.error(
`\n ${YELLOW}No commits on ${branchName} compared to ${baseBranch}. Commit something first.${RESET}`,
);
await ask(` ${DIM}Press Enter to exit...${RESET}`);
process.exit(0);
const choice = await selectOne({
title: "No commits to compare",
subtitle: `No commits on ${branchName} compared to ${baseBranch}. Commit something first.`,
items: [{ label: "Back", value: "back" as const }],
});
if (choice === null) process.exit(0);
return "done";
}
console.log(