@alejandrochaves/devflow-cli 1.8.0 → 1.9.0

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.
@@ -1,4 +1,4 @@
1
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
2
2
  import { loadConfig } from "../config.js";
3
3
  import { bold, dim, green, cyan, gray, yellow } from "../colors.js";
4
4
  import { getBranch, parseBranch, getCommits, getScopesFromCommits, getDefaultBase, checkGhInstalled, } from "../git.js";
@@ -44,7 +44,7 @@ function formatTicket(opts) {
44
44
  }
45
45
  function ensureLabel(label) {
46
46
  try {
47
- execSync(`gh label create ${JSON.stringify(label.name)} --color ${label.color} --force`, { stdio: "ignore" });
47
+ execFileSync("gh", ["label", "create", "--color", label.color, "--force", "--", label.name], { stdio: "ignore" });
48
48
  }
49
49
  catch {
50
50
  // Label might already exist
@@ -52,7 +52,7 @@ function ensureLabel(label) {
52
52
  }
53
53
  function getExistingPr() {
54
54
  try {
55
- const result = execSync("gh pr view --json url,number,state", {
55
+ const result = execFileSync("gh", ["pr", "view", "--json", "url,number,state"], {
56
56
  encoding: "utf-8",
57
57
  stdio: ["pipe", "pipe", "ignore"],
58
58
  }).trim();
@@ -325,7 +325,7 @@ export async function prCommand(options = {}) {
325
325
  }
326
326
  // Push branch if needed
327
327
  try {
328
- execSync(`git push -u origin ${branch}`, { stdio: "inherit" });
328
+ execFileSync("git", ["push", "-u", "origin", branch], { stdio: "inherit" });
329
329
  }
330
330
  catch {
331
331
  // Already pushed or push failed
@@ -343,26 +343,29 @@ export async function prCommand(options = {}) {
343
343
  labels.push(scope);
344
344
  }
345
345
  const uniqueLabels = [...new Set(labels)];
346
- const labelFlag = uniqueLabels.length > 0
347
- ? uniqueLabels.map((l) => JSON.stringify(l)).join(",")
348
- : "";
349
- // Reviewers flag
350
- const reviewerFlag = config.prReviewers && config.prReviewers.length > 0
351
- ? ` --reviewer ${config.prReviewers.join(",")}`
352
- : "";
353
- // Draft flag (unless --ready is specified)
354
- const draftFlag = options.ready ? "" : " --draft";
346
+ const labelArgs = uniqueLabels.map((l) => `--label=${l}`);
347
+ const reviewerArgs = config.prReviewers && config.prReviewers.length > 0
348
+ ? [`--reviewer=${config.prReviewers.join(",")}`]
349
+ : [];
350
+ const draftArgs = options.ready ? [] : ["--draft"];
351
+ const editArgs = (n) => [
352
+ "pr", "edit", String(n), `--title=${title}`, "--body-file", "-",
353
+ ...labelArgs.map((l) => l.replace("--label=", "--add-label=")),
354
+ ];
355
355
  if (prAction === "reopen") {
356
- execSync(`gh pr reopen ${existingPr.number}`, { stdio: "inherit" });
357
- execSync(`gh pr edit ${existingPr.number} --title ${JSON.stringify(title)} --body-file -${labelFlag ? ` --add-label ${labelFlag}` : ""}`, { input: body, stdio: ["pipe", "inherit", "inherit"] });
356
+ execFileSync("gh", ["pr", "reopen", String(existingPr.number)], { stdio: "inherit" });
357
+ execFileSync("gh", editArgs(existingPr.number), { input: body, stdio: ["pipe", "inherit", "inherit"] });
358
358
  console.log(green(`✓ PR #${existingPr.number} reopened and updated: ${existingPr.url}`));
359
359
  }
360
360
  else if (prAction === "update") {
361
- execSync(`gh pr edit ${existingPr.number} --title ${JSON.stringify(title)} --body-file -${labelFlag ? ` --add-label ${labelFlag}` : ""}`, { input: body, stdio: ["pipe", "inherit", "inherit"] });
361
+ execFileSync("gh", editArgs(existingPr.number), { input: body, stdio: ["pipe", "inherit", "inherit"] });
362
362
  console.log(green(`✓ PR #${existingPr.number} updated: ${existingPr.url}`));
363
363
  }
364
364
  else {
365
- execSync(`gh pr create${draftFlag} --title ${JSON.stringify(title)} --body-file - --base ${base.trim()} --head ${branch} --assignee @me${reviewerFlag}${labelFlag ? ` --label ${labelFlag}` : ""}`, { input: body, stdio: ["pipe", "inherit", "inherit"] });
365
+ execFileSync("gh", [
366
+ "pr", "create", ...draftArgs, `--title=${title}`, "--body-file", "-",
367
+ `--base=${base.trim()}`, `--head=${branch}`, "--assignee", "@me", ...reviewerArgs, ...labelArgs,
368
+ ], { input: body, stdio: ["pipe", "inherit", "inherit"] });
366
369
  console.log(green("✓ PR created successfully."));
367
370
  }
368
371
  // Move linked issue to "In Review" if project integration is enabled
@@ -1,8 +1,8 @@
1
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
2
2
  import { readFileSync, writeFileSync, existsSync } from "fs";
3
3
  import { resolve } from "path";
4
4
  import { bold, dim, green, cyan } from "../colors.js";
5
- import { checkGhInstalled } from "../git.js";
5
+ import { checkGhInstalled, isOptionLike, resolveCommit } from "../git.js";
6
6
  import { selectWithBack, confirmWithBack, BACK_VALUE, } from "../prompts.js";
7
7
  function getCurrentVersion(cwd) {
8
8
  const pkgPath = resolve(cwd, "package.json");
@@ -11,19 +11,23 @@ function getCurrentVersion(cwd) {
11
11
  }
12
12
  function getLastTag() {
13
13
  try {
14
- return execSync("git describe --tags --abbrev=0", {
14
+ const tag = execFileSync("git", ["describe", "--tags", "--abbrev=0"], {
15
15
  encoding: "utf-8",
16
16
  stdio: ["pipe", "pipe", "ignore"],
17
17
  }).trim();
18
+ return isOptionLike(tag) ? undefined : tag;
18
19
  }
19
20
  catch {
20
21
  return undefined;
21
22
  }
22
23
  }
23
24
  function getCommitsSinceTag(tag) {
24
- const range = tag ? `${tag}..HEAD` : "HEAD";
25
+ const tagId = tag ? resolveCommit(tag) : undefined;
26
+ if (tag && !tagId)
27
+ return [];
28
+ const range = tagId ? `${tagId}..HEAD` : "HEAD";
25
29
  try {
26
- const log = execSync(`git log ${range} --pretty=format:"%H %s"`, {
30
+ const log = execFileSync("git", ["log", range, "--pretty=format:%H %s"], {
27
31
  encoding: "utf-8",
28
32
  }).trim();
29
33
  if (!log)
@@ -216,14 +220,14 @@ export async function releaseCommand(options = {}) {
216
220
  updateChangelog(cwd, newVersion, notes);
217
221
  console.log(green("✓ Updated CHANGELOG.md"));
218
222
  // 3. Commit
219
- execSync("git add package.json CHANGELOG.md", { stdio: "ignore" });
220
- execSync(`git commit -m ${JSON.stringify(`${newVersion}`)}`, { stdio: "ignore" });
223
+ execFileSync("git", ["add", "package.json", "CHANGELOG.md"], { stdio: "ignore" });
224
+ execFileSync("git", ["commit", "-m", newVersion], { stdio: "ignore" });
221
225
  console.log(green("✓ Created release commit"));
222
226
  // 4. Tag
223
- execSync(`git tag v${newVersion}`, { stdio: "ignore" });
227
+ execFileSync("git", ["tag", `v${newVersion}`], { stdio: "ignore" });
224
228
  console.log(green(`✓ Tagged v${newVersion}`));
225
229
  // 5. Push
226
- execSync("git push origin HEAD --tags", { stdio: "inherit" });
230
+ execFileSync("git", ["push", "origin", "HEAD", "--tags"], { stdio: "inherit" });
227
231
  console.log(green("✓ Pushed to remote"));
228
232
  // 6. Create GitHub release (auto-create with --yes)
229
233
  const createReleaseResult = options.yes || await confirmWithBack({
@@ -233,7 +237,7 @@ export async function releaseCommand(options = {}) {
233
237
  });
234
238
  const createRelease = createReleaseResult === true;
235
239
  if (createRelease) {
236
- execSync(`gh release create v${newVersion} --title "v${newVersion}" --notes-file -`, { input: notes, stdio: ["pipe", "inherit", "inherit"] });
240
+ execFileSync("gh", ["release", "create", `v${newVersion}`, `--title=v${newVersion}`, "--notes-file", "-"], { input: notes, stdio: ["pipe", "inherit", "inherit"] });
237
241
  console.log(green(`\n✓ Released v${newVersion}`));
238
242
  console.log(dim(" npm publish will be triggered by the publish workflow."));
239
243
  }
@@ -1,10 +1,10 @@
1
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
2
2
  import { bold, dim, green, cyan, yellow } from "../colors.js";
3
3
  import { checkGhInstalled } from "../git.js";
4
4
  import { selectWithBack, inputWithBack, BACK_VALUE, } from "../prompts.js";
5
5
  function listOpenPrs() {
6
6
  try {
7
- const result = execSync("gh pr list --state open --json number,title,headRefName,author,additions,deletions,reviewDecision", { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] }).trim();
7
+ const result = execFileSync("gh", ["pr", "list", "--state", "open", "--json", "number,title,headRefName,author,additions,deletions,reviewDecision"], { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] }).trim();
8
8
  return JSON.parse(result);
9
9
  }
10
10
  catch {
@@ -13,7 +13,7 @@ function listOpenPrs() {
13
13
  }
14
14
  function getPrDiffStat(number) {
15
15
  try {
16
- return execSync(`gh pr diff ${number} --stat`, {
16
+ return execFileSync("gh", ["pr", "diff", String(number), "--stat"], {
17
17
  encoding: "utf-8",
18
18
  stdio: ["pipe", "pipe", "ignore"],
19
19
  }).trim();
@@ -112,7 +112,7 @@ export async function reviewCommand(options = {}) {
112
112
  const pr = prs.find((p) => p.number === prNumber);
113
113
  switch (selectedAction) {
114
114
  case "checkout":
115
- execSync(`gh pr checkout ${pr.number}`, { stdio: "inherit" });
115
+ execFileSync("gh", ["pr", "checkout", String(pr.number)], { stdio: "inherit" });
116
116
  console.log(green(`✓ Checked out ${pr.headRefName}`));
117
117
  currentStep = "done";
118
118
  break;
@@ -126,10 +126,8 @@ export async function reviewCommand(options = {}) {
126
126
  break;
127
127
  }
128
128
  const approveBody = approveBodyResult;
129
- const approveFlag = approveBody.trim()
130
- ? `--body ${JSON.stringify(approveBody.trim())}`
131
- : "";
132
- execSync(`gh pr review ${pr.number} --approve ${approveFlag}`, { stdio: "inherit" });
129
+ const approveArgs = approveBody.trim() ? [`--body=${approveBody.trim()}`] : [];
130
+ execFileSync("gh", ["pr", "review", String(pr.number), "--approve", ...approveArgs], { stdio: "inherit" });
133
131
  console.log(green(`✓ Approved #${pr.number}`));
134
132
  currentStep = "done";
135
133
  break;
@@ -149,7 +147,7 @@ export async function reviewCommand(options = {}) {
149
147
  console.error("Comment is required.");
150
148
  process.exit(1);
151
149
  }
152
- execSync(`gh pr comment ${pr.number} --body ${JSON.stringify(comment.trim())}`, {
150
+ execFileSync("gh", ["pr", "comment", String(pr.number), `--body=${comment.trim()}`], {
153
151
  stdio: "inherit",
154
152
  });
155
153
  console.log(green("✓ Comment added"));
@@ -171,13 +169,13 @@ export async function reviewCommand(options = {}) {
171
169
  console.error("Description is required.");
172
170
  process.exit(1);
173
171
  }
174
- execSync(`gh pr review ${pr.number} --request-changes --body ${JSON.stringify(changesBody.trim())}`, { stdio: "inherit" });
172
+ execFileSync("gh", ["pr", "review", String(pr.number), "--request-changes", `--body=${changesBody.trim()}`], { stdio: "inherit" });
175
173
  console.log(yellow(`✓ Requested changes on #${pr.number}`));
176
174
  currentStep = "done";
177
175
  break;
178
176
  }
179
177
  case "view":
180
- execSync(`gh pr view ${pr.number} --web`, { stdio: "inherit" });
178
+ execFileSync("gh", ["pr", "view", String(pr.number), "--web"], { stdio: "inherit" });
181
179
  currentStep = "done";
182
180
  break;
183
181
  default:
@@ -1,11 +1,11 @@
1
1
  import { select } from "@inquirer/prompts";
2
- import { execSync } from "child_process";
2
+ import { execFileSync } from "child_process";
3
3
  import { bold, dim, green, yellow } from "../colors.js";
4
4
  import { getBranch } from "../git.js";
5
5
  import { selectWithBack, inputWithBack, confirmWithBack, BACK_VALUE, } from "../prompts.js";
6
6
  function listStashes() {
7
7
  try {
8
- const result = execSync("git stash list", { encoding: "utf-8" }).trim();
8
+ const result = execFileSync("git", ["stash", "list"], { encoding: "utf-8" }).trim();
9
9
  if (!result)
10
10
  return [];
11
11
  return result.split("\n").map((line, i) => {
@@ -22,7 +22,7 @@ function listStashes() {
22
22
  }
23
23
  function hasChanges() {
24
24
  try {
25
- const status = execSync("git status --porcelain", { encoding: "utf-8" }).trim();
25
+ const status = execFileSync("git", ["status", "--porcelain"], { encoding: "utf-8" }).trim();
26
26
  return status.length > 0;
27
27
  }
28
28
  catch {
@@ -120,12 +120,12 @@ export async function stashCommand(options = {}) {
120
120
  }
121
121
  includeUntracked = untrackedResult === true;
122
122
  }
123
- const untrackedFlag = includeUntracked ? " --include-untracked" : "";
123
+ const untrackedArgs = includeUntracked ? ["--include-untracked"] : [];
124
124
  if (options.dryRun) {
125
125
  console.log(dim(`[dry-run] Would stash with message: ${stashMessage}${includeUntracked ? " (incl. untracked)" : ""}`));
126
126
  }
127
127
  else {
128
- execSync(`git stash push -m ${JSON.stringify(stashMessage)}${untrackedFlag}`, {
128
+ execFileSync("git", ["stash", "push", "-m", stashMessage, ...untrackedArgs], {
129
129
  stdio: "inherit",
130
130
  });
131
131
  console.log(green(`✓ Stashed: ${stashMessage}`));
@@ -151,7 +151,7 @@ export async function stashCommand(options = {}) {
151
151
  }
152
152
  else {
153
153
  try {
154
- execSync(`git stash ${selectedAction} stash@{${stashTarget}}`, { stdio: "inherit" });
154
+ execFileSync("git", ["stash", selectedAction, `stash@{${stashTarget}}`], { stdio: "inherit" });
155
155
  console.log(green(`✓ ${selectedAction === "pop" ? "Popped" : "Applied"} stash@{${stashTarget}}`));
156
156
  }
157
157
  catch {
@@ -187,7 +187,7 @@ export async function stashCommand(options = {}) {
187
187
  console.log(dim(`[dry-run] Would drop stash@{${stashTarget}}`));
188
188
  }
189
189
  else {
190
- execSync(`git stash drop stash@{${stashTarget}}`, { stdio: "ignore" });
190
+ execFileSync("git", ["stash", "drop", `stash@{${stashTarget}}`], { stdio: "ignore" });
191
191
  console.log(green(`✓ Dropped stash@{${stashTarget}}`));
192
192
  }
193
193
  }
@@ -206,7 +206,7 @@ export async function stashCommand(options = {}) {
206
206
  }
207
207
  stashTarget = target;
208
208
  }
209
- const diff = execSync(`git stash show -p stash@{${stashTarget}}`, { encoding: "utf-8" });
209
+ const diff = execFileSync("git", ["stash", "show", "-p", `stash@{${stashTarget}}`], { encoding: "utf-8" });
210
210
  console.log(diff);
211
211
  currentStep = "done";
212
212
  break;
@@ -1,8 +1,8 @@
1
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
2
2
  import { bold, dim, cyan } from "../colors.js";
3
3
  function getCommitStats(limit = 100) {
4
4
  try {
5
- const result = execSync(`git log --pretty=format:"%s|%an" -${limit}`, { encoding: "utf-8" }).trim();
5
+ const result = execFileSync("git", ["log", "--pretty=format:%s|%an", `-${limit}`], { encoding: "utf-8" }).trim();
6
6
  if (!result)
7
7
  return [];
8
8
  return result.split("\n").map((line) => {
@@ -79,12 +79,11 @@ export function statsCommand() {
79
79
  // Activity
80
80
  console.log("");
81
81
  try {
82
- const firstCommit = execSync("git log --reverse --format=%ar | head -1", {
82
+ const firstCommit = execFileSync("git", ["log", "--reverse", "--format=%ar"], {
83
83
  encoding: "utf-8",
84
- shell: "/bin/bash",
85
- }).trim();
86
- const totalCommits = execSync("git rev-list --count HEAD", { encoding: "utf-8" }).trim();
87
- const branches = execSync("git branch | wc -l", { encoding: "utf-8", shell: "/bin/bash" }).trim();
84
+ }).split("\n")[0].trim();
85
+ const totalCommits = execFileSync("git", ["rev-list", "--count", "HEAD"], { encoding: "utf-8" }).trim();
86
+ const branches = String(execFileSync("git", ["branch", "--format=%(refname)"], { encoding: "utf-8" }).split("\n").filter(Boolean).length);
88
87
  console.log(bold(" Summary"));
89
88
  console.log(` ${dim("Total commits:")} ${cyan(totalCommits)}`);
90
89
  console.log(` ${dim("Local branches:")} ${cyan(branches.trim())}`);
@@ -1,10 +1,10 @@
1
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
2
2
  import { loadConfig } from "../config.js";
3
3
  import { bold, dim, cyan, green, yellow, gray } from "../colors.js";
4
4
  import { getBranch, parseBranch, getDefaultBase, getCommits, isGhInstalled } from "../git.js";
5
5
  function getPrInfo() {
6
6
  try {
7
- const result = execSync("gh pr view --json url,number,state", {
7
+ const result = execFileSync("gh", ["pr", "view", "--json", "url,number,state"], {
8
8
  encoding: "utf-8",
9
9
  stdio: ["pipe", "pipe", "ignore"],
10
10
  }).trim();
@@ -15,9 +15,9 @@ function getPrInfo() {
15
15
  }
16
16
  }
17
17
  function getUncommittedCount() {
18
- const staged = execSync("git diff --cached --name-only", { encoding: "utf-8" }).trim();
19
- const unstaged = execSync("git diff --name-only", { encoding: "utf-8" }).trim();
20
- const untracked = execSync("git ls-files --others --exclude-standard", { encoding: "utf-8" }).trim();
18
+ const staged = execFileSync("git", ["diff", "--cached", "--name-only"], { encoding: "utf-8" }).trim();
19
+ const unstaged = execFileSync("git", ["diff", "--name-only"], { encoding: "utf-8" }).trim();
20
+ const untracked = execFileSync("git", ["ls-files", "--others", "--exclude-standard"], { encoding: "utf-8" }).trim();
21
21
  return {
22
22
  staged: staged ? staged.split("\n").length : 0,
23
23
  unstaged: unstaged ? unstaged.split("\n").length : 0,
@@ -1,18 +1,18 @@
1
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
2
2
  import { bold, dim, green, yellow } from "../colors.js";
3
3
  import { confirmWithBack } from "../prompts.js";
4
4
  export async function undoCommand(options = {}) {
5
5
  try {
6
6
  // Check if there are commits to undo
7
7
  try {
8
- execSync("git log -1 --format=%H", { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] });
8
+ execFileSync("git", ["log", "-1", "--format=%H"], { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] });
9
9
  }
10
10
  catch {
11
11
  console.log("No commits to undo.");
12
12
  return;
13
13
  }
14
- const lastMessage = execSync("git log -1 --format=%s", { encoding: "utf-8" }).trim();
15
- const lastFiles = execSync("git diff-tree --no-commit-id --name-only -r HEAD", { encoding: "utf-8" }).trim();
14
+ const lastMessage = execFileSync("git", ["log", "-1", "--format=%s"], { encoding: "utf-8" }).trim();
15
+ const lastFiles = execFileSync("git", ["diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD"], { encoding: "utf-8" }).trim();
16
16
  console.log(`\n${dim("───")} ${bold("Undo Last Commit")} ${dim("───")}\n`);
17
17
  console.log(`${dim("Message:")} ${yellow(lastMessage)}`);
18
18
  if (lastFiles) {
@@ -35,7 +35,7 @@ export async function undoCommand(options = {}) {
35
35
  return;
36
36
  }
37
37
  }
38
- execSync("git reset --soft HEAD~1", { stdio: "inherit" });
38
+ execFileSync("git", ["reset", "--soft", "HEAD~1"], { stdio: "inherit" });
39
39
  console.log(green("✓ Commit undone. Changes are staged."));
40
40
  }
41
41
  catch (error) {
@@ -1,9 +1,9 @@
1
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
2
2
  import { bold, dim, green, cyan, yellow, red } from "../colors.js";
3
3
  import { selectWithBack, inputWithBack, confirmWithBack, BACK_VALUE, } from "../prompts.js";
4
4
  function listWorktrees() {
5
5
  try {
6
- const result = execSync("git worktree list --porcelain", { encoding: "utf-8" }).trim();
6
+ const result = execFileSync("git", ["worktree", "list", "--porcelain"], { encoding: "utf-8" }).trim();
7
7
  if (!result)
8
8
  return [];
9
9
  const trees = [];
@@ -30,7 +30,7 @@ function listWorktrees() {
30
30
  }
31
31
  }
32
32
  function getRepoRoot() {
33
- return execSync("git rev-parse --show-toplevel", { encoding: "utf-8" }).trim();
33
+ return execFileSync("git", ["rev-parse", "--show-toplevel"], { encoding: "utf-8" }).trim();
34
34
  }
35
35
  export async function worktreeCommand(options = {}) {
36
36
  try {
@@ -137,19 +137,19 @@ export async function worktreeCommand(options = {}) {
137
137
  // Check if branch exists
138
138
  let branchExists = false;
139
139
  try {
140
- execSync(`git rev-parse --verify ${branchName.trim()}`, { stdio: "ignore" });
140
+ execFileSync("git", ["rev-parse", "--verify", branchName.trim()], { stdio: "ignore" });
141
141
  branchExists = true;
142
142
  }
143
143
  catch {
144
144
  // Branch doesn't exist
145
145
  }
146
- const createFlag = branchExists ? "" : "-b ";
146
+ const branchArgs = branchExists ? ["--", worktreePath.trim(), branchName.trim()] : ["-b", branchName.trim(), "--", worktreePath.trim()];
147
147
  if (options.dryRun) {
148
148
  console.log(dim(`[dry-run] Would create worktree at ${worktreePath.trim()} for ${branchName.trim()}`));
149
149
  }
150
150
  else {
151
151
  try {
152
- execSync(`git worktree add ${JSON.stringify(worktreePath.trim())} ${createFlag}${branchName.trim()}`, {
152
+ execFileSync("git", ["worktree", "add", ...branchArgs], {
153
153
  stdio: "inherit",
154
154
  });
155
155
  console.log(green(`✓ Created worktree at ${worktreePath.trim()}`));
@@ -209,7 +209,7 @@ export async function worktreeCommand(options = {}) {
209
209
  }
210
210
  else {
211
211
  try {
212
- execSync(`git worktree remove ${JSON.stringify(selected)}`, { stdio: "inherit" });
212
+ execFileSync("git", ["worktree", "remove", "--", selected], { stdio: "inherit" });
213
213
  console.log(green("✓ Worktree removed"));
214
214
  }
215
215
  catch {
@@ -219,7 +219,7 @@ export async function worktreeCommand(options = {}) {
219
219
  showBack: false,
220
220
  });
221
221
  if (force === true) {
222
- execSync(`git worktree remove --force ${JSON.stringify(selected)}`, { stdio: "inherit" });
222
+ execFileSync("git", ["worktree", "remove", "--force", "--", selected], { stdio: "inherit" });
223
223
  console.log(yellow("✓ Force removed worktree"));
224
224
  }
225
225
  }
package/dist/config.d.ts CHANGED
@@ -13,7 +13,7 @@ export interface IssueField {
13
13
  export interface IssueType {
14
14
  value: string;
15
15
  label: string;
16
- labelColor: string;
16
+ labelColor?: string;
17
17
  branchType: string;
18
18
  fields: IssueField[];
19
19
  template: string;
package/dist/config.js CHANGED
@@ -282,7 +282,7 @@ export function validateConfig(raw) {
282
282
  const validFields = [
283
283
  "extends", "ticketBaseUrl", "scopes", "branchTypes", "commitTypes",
284
284
  "checklist", "commitFormat", "prTemplate", "prReviewers",
285
- "preset", "branchFormat", "issueTypes", "ticketProvider", "project",
285
+ "preset", "branchFormat", "issueTypes", "ticketProvider", "project", "plugins",
286
286
  ];
287
287
  for (const key of Object.keys(raw)) {
288
288
  if (!validFields.includes(key)) {
@@ -397,6 +397,38 @@ function mergeConfigs(base, override) {
397
397
  }
398
398
  return result;
399
399
  }
400
+ // Config values become discrete command arguments (no shell parses them), label lists joined with commas,
401
+ // or branch-name parts that git validates later. So refuse only what still matters there: a leading dash
402
+ // (read as an option), a comma (splits a list) and control characters. Emoji, spaces and "&" are fine.
403
+ const isPlain = (v) => typeof v === "string" && v !== "" && !v.startsWith("-") && !/[,\p{Cc}]/u.test(v);
404
+ // GitHub logins (Enterprise managed users carry an _shortcode suffix) or org/team slugs
405
+ const REVIEWER = /^[A-Za-z0-9][A-Za-z0-9_-]*(\/[A-Za-z0-9][A-Za-z0-9._-]*)?$/;
406
+ function keepValid(field, items, isValid) {
407
+ if (items === undefined)
408
+ return undefined;
409
+ if (!Array.isArray(items)) {
410
+ console.error(yellow(`⚠ .devflow/config.json: "${field}" must be an array; ignored.`));
411
+ return undefined;
412
+ }
413
+ return items.filter((item, i) => {
414
+ const ok = item !== null && item !== undefined && isValid(item);
415
+ if (!ok)
416
+ console.error(yellow(`⚠ .devflow/config.json: ignoring invalid ${field}[${i}]`));
417
+ return ok;
418
+ });
419
+ }
420
+ function sanitizeConfig(raw) {
421
+ return {
422
+ ...raw,
423
+ prReviewers: keepValid("prReviewers", raw.prReviewers, (r) => typeof r === "string" && REVIEWER.test(r)),
424
+ scopes: keepValid("scopes", raw.scopes, (s) => isPlain(s.value)),
425
+ branchTypes: keepValid("branchTypes", raw.branchTypes, isPlain),
426
+ commitTypes: keepValid("commitTypes", raw.commitTypes, (t) => isPlain(t.value)),
427
+ issueTypes: keepValid("issueTypes", raw.issueTypes, (t) => isPlain(t.value) &&
428
+ isPlain(t.branchType) &&
429
+ (t.labelColor === undefined || isPlain(t.labelColor))),
430
+ };
431
+ }
400
432
  export function loadConfig(cwd = process.cwd()) {
401
433
  const configPath = resolve(cwd, ".devflow/config.json");
402
434
  if (!existsSync(configPath)) {
@@ -414,6 +446,7 @@ export function loadConfig(cwd = process.cwd()) {
414
446
  const base = resolveExtends(raw.extends, cwd);
415
447
  raw = mergeConfigs(base, raw);
416
448
  }
449
+ raw = sanitizeConfig(raw);
417
450
  const warnings = validateConfig(raw);
418
451
  if (warnings.length > 0) {
419
452
  for (const w of warnings) {
package/dist/git.d.ts CHANGED
@@ -1,3 +1,12 @@
1
+ /** Refs read from git can still be named like options (a tag "--output=x"); never pass those as arguments. */
2
+ export declare function isOptionLike(ref: string): boolean;
3
+ /**
4
+ * The commit a user- or config-provided revision (a PR base, a tag) names, as an object id, so it can
5
+ * be put in a range without git reading it as an option. undefined when it names no commit.
6
+ */
7
+ export declare function resolveCommit(rev: string): string | undefined;
8
+ /** Throws unless `name` is a valid branch name that git cannot read as an option. */
9
+ export declare function assertBranchName(name: string): void;
1
10
  export declare function getBranch(): string;
2
11
  interface ParsedBranch {
3
12
  type: string | undefined;