@alejandrochaves/devflow-cli 1.7.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.
Files changed (150) hide show
  1. package/README.md +9 -3
  2. package/dist/cli-runner.d.ts +1 -0
  3. package/dist/cli-runner.js +17 -0
  4. package/dist/colors.d.ts +0 -1
  5. package/dist/colors.js +0 -1
  6. package/dist/commands/amend.d.ts +0 -1
  7. package/dist/commands/amend.js +7 -7
  8. package/dist/commands/branch.d.ts +0 -1
  9. package/dist/commands/branch.js +9 -6
  10. package/dist/commands/changelog.d.ts +0 -1
  11. package/dist/commands/changelog.js +9 -5
  12. package/dist/commands/cleanup.d.ts +0 -1
  13. package/dist/commands/cleanup.js +9 -8
  14. package/dist/commands/comments.d.ts +0 -1
  15. package/dist/commands/comments.js +10 -6
  16. package/dist/commands/commit.d.ts +0 -1
  17. package/dist/commands/commit.js +14 -14
  18. package/dist/commands/doctor.d.ts +0 -1
  19. package/dist/commands/doctor.js +8 -9
  20. package/dist/commands/fixup.d.ts +0 -1
  21. package/dist/commands/fixup.js +20 -17
  22. package/dist/commands/init.d.ts +0 -1
  23. package/dist/commands/init.js +69 -22
  24. package/dist/commands/issue.d.ts +0 -1
  25. package/dist/commands/issue.js +9 -27
  26. package/dist/commands/issues.d.ts +0 -1
  27. package/dist/commands/issues.js +2 -3
  28. package/dist/commands/lint-config.d.ts +0 -1
  29. package/dist/commands/lint-config.js +0 -1
  30. package/dist/commands/log.d.ts +0 -1
  31. package/dist/commands/log.js +12 -10
  32. package/dist/commands/merge.d.ts +0 -1
  33. package/dist/commands/merge.js +10 -11
  34. package/dist/commands/pr.d.ts +0 -1
  35. package/dist/commands/pr.js +85 -31
  36. package/dist/commands/release.d.ts +0 -1
  37. package/dist/commands/release.js +14 -11
  38. package/dist/commands/review.d.ts +0 -1
  39. package/dist/commands/review.js +9 -12
  40. package/dist/commands/stash.d.ts +1 -1
  41. package/dist/commands/stash.js +31 -17
  42. package/dist/commands/stats.d.ts +0 -1
  43. package/dist/commands/stats.js +6 -8
  44. package/dist/commands/status.d.ts +0 -1
  45. package/dist/commands/status.js +9 -7
  46. package/dist/commands/test-plan.d.ts +0 -1
  47. package/dist/commands/test-plan.js +0 -1
  48. package/dist/commands/undo.d.ts +0 -1
  49. package/dist/commands/undo.js +9 -10
  50. package/dist/commands/update.d.ts +0 -1
  51. package/dist/commands/update.js +71 -1
  52. package/dist/commands/worktree.d.ts +1 -1
  53. package/dist/commands/worktree.js +35 -26
  54. package/dist/config.d.ts +1 -2
  55. package/dist/config.js +34 -2
  56. package/dist/devflow-version.d.ts +1 -1
  57. package/dist/devflow-version.js +1 -1
  58. package/dist/git.d.ts +11 -1
  59. package/dist/git.js +82 -10
  60. package/dist/index.d.ts +0 -1
  61. package/dist/index.js +32 -27
  62. package/dist/monorepo.d.ts +0 -1
  63. package/dist/monorepo.js +0 -1
  64. package/dist/output.d.ts +3 -0
  65. package/dist/output.js +13 -0
  66. package/dist/plugins.d.ts +8 -1
  67. package/dist/plugins.js +222 -18
  68. package/dist/prompts.d.ts +0 -1
  69. package/dist/prompts.js +0 -1
  70. package/dist/providers/projects.d.ts +0 -1
  71. package/dist/providers/projects.js +5 -12
  72. package/dist/providers/tickets.d.ts +0 -1
  73. package/dist/providers/tickets.js +6 -7
  74. package/dist/test-plan.d.ts +0 -1
  75. package/dist/test-plan.js +0 -1
  76. package/dist/update-notifier.d.ts +0 -1
  77. package/dist/update-notifier.js +43 -28
  78. package/package.json +1 -1
  79. package/dist/colors.d.ts.map +0 -1
  80. package/dist/colors.js.map +0 -1
  81. package/dist/commands/amend.d.ts.map +0 -1
  82. package/dist/commands/amend.js.map +0 -1
  83. package/dist/commands/branch.d.ts.map +0 -1
  84. package/dist/commands/branch.js.map +0 -1
  85. package/dist/commands/changelog.d.ts.map +0 -1
  86. package/dist/commands/changelog.js.map +0 -1
  87. package/dist/commands/cleanup.d.ts.map +0 -1
  88. package/dist/commands/cleanup.js.map +0 -1
  89. package/dist/commands/comments.d.ts.map +0 -1
  90. package/dist/commands/comments.js.map +0 -1
  91. package/dist/commands/commit.d.ts.map +0 -1
  92. package/dist/commands/commit.js.map +0 -1
  93. package/dist/commands/doctor.d.ts.map +0 -1
  94. package/dist/commands/doctor.js.map +0 -1
  95. package/dist/commands/fixup.d.ts.map +0 -1
  96. package/dist/commands/fixup.js.map +0 -1
  97. package/dist/commands/init.d.ts.map +0 -1
  98. package/dist/commands/init.js.map +0 -1
  99. package/dist/commands/issue.d.ts.map +0 -1
  100. package/dist/commands/issue.js.map +0 -1
  101. package/dist/commands/issues.d.ts.map +0 -1
  102. package/dist/commands/issues.js.map +0 -1
  103. package/dist/commands/lint-config.d.ts.map +0 -1
  104. package/dist/commands/lint-config.js.map +0 -1
  105. package/dist/commands/log.d.ts.map +0 -1
  106. package/dist/commands/log.js.map +0 -1
  107. package/dist/commands/merge.d.ts.map +0 -1
  108. package/dist/commands/merge.js.map +0 -1
  109. package/dist/commands/pr.d.ts.map +0 -1
  110. package/dist/commands/pr.js.map +0 -1
  111. package/dist/commands/release.d.ts.map +0 -1
  112. package/dist/commands/release.js.map +0 -1
  113. package/dist/commands/review.d.ts.map +0 -1
  114. package/dist/commands/review.js.map +0 -1
  115. package/dist/commands/stash.d.ts.map +0 -1
  116. package/dist/commands/stash.js.map +0 -1
  117. package/dist/commands/stats.d.ts.map +0 -1
  118. package/dist/commands/stats.js.map +0 -1
  119. package/dist/commands/status.d.ts.map +0 -1
  120. package/dist/commands/status.js.map +0 -1
  121. package/dist/commands/test-plan.d.ts.map +0 -1
  122. package/dist/commands/test-plan.js.map +0 -1
  123. package/dist/commands/undo.d.ts.map +0 -1
  124. package/dist/commands/undo.js.map +0 -1
  125. package/dist/commands/update.d.ts.map +0 -1
  126. package/dist/commands/update.js.map +0 -1
  127. package/dist/commands/worktree.d.ts.map +0 -1
  128. package/dist/commands/worktree.js.map +0 -1
  129. package/dist/config.d.ts.map +0 -1
  130. package/dist/config.js.map +0 -1
  131. package/dist/devflow-version.d.ts.map +0 -1
  132. package/dist/devflow-version.js.map +0 -1
  133. package/dist/git.d.ts.map +0 -1
  134. package/dist/git.js.map +0 -1
  135. package/dist/index.d.ts.map +0 -1
  136. package/dist/index.js.map +0 -1
  137. package/dist/monorepo.d.ts.map +0 -1
  138. package/dist/monorepo.js.map +0 -1
  139. package/dist/plugins.d.ts.map +0 -1
  140. package/dist/plugins.js.map +0 -1
  141. package/dist/prompts.d.ts.map +0 -1
  142. package/dist/prompts.js.map +0 -1
  143. package/dist/providers/projects.d.ts.map +0 -1
  144. package/dist/providers/projects.js.map +0 -1
  145. package/dist/providers/tickets.d.ts.map +0 -1
  146. package/dist/providers/tickets.js.map +0 -1
  147. package/dist/test-plan.d.ts.map +0 -1
  148. package/dist/test-plan.js.map +0 -1
  149. package/dist/update-notifier.d.ts.map +0 -1
  150. package/dist/update-notifier.js.map +0 -1
package/README.md CHANGED
@@ -44,6 +44,8 @@ Or add scripts to your `package.json`:
44
44
 
45
45
  ## Commands
46
46
 
47
+ > **Tip:** In any multi-step command, press **Escape** to go back to the previous step.
48
+
47
49
  ### `devflow init`
48
50
 
49
51
  Interactive setup wizard that configures your entire project. Walks you through:
@@ -116,15 +118,18 @@ The `!` after the ticket indicates a breaking change.
116
118
  Create or update a pull request with an auto-filled template.
117
119
 
118
120
  **Flow:**
119
- 1. Checks if a PR already exists for the current branch (offers to update)
121
+ 1. Checks if a PR already exists for the current branch:
122
+ - **Open** — offers to update it
123
+ - **Merged** — asks whether to create a new PR
124
+ - **Closed** — asks to reopen and update, or create a new PR
120
125
  2. Infers the base branch (closest remote branch by merge-base)
121
126
  3. Enter PR title (pre-filled from branch description)
122
127
  4. Enter optional summary
123
128
  5. Preview PR body with template
124
- 6. Confirm and create/update
129
+ 6. Confirm and create/update/reopen
125
130
 
126
131
  **Features:**
127
- - Auto-detects existing PRs and offers update flow
132
+ - Auto-detects existing PRs; handles open, merged, and closed states
128
133
  - Infers base branch using `git merge-base` comparison
129
134
  - Pre-fills commit list in the summary
130
135
  - Auto-labels from branch type (feat → `feature`, fix → `bug`, etc.)
@@ -449,6 +454,7 @@ eval "$(devflow completions --shell bash)"
449
454
  | `devflow status` | `devflow s` |
450
455
  | `devflow test-plan` | `devflow tp` |
451
456
  | `devflow lint-config` | `devflow lint` |
457
+ | `devflow update` | `devflow up` |
452
458
 
453
459
  ## Global Options
454
460
 
@@ -0,0 +1 @@
1
+ export declare function runCommand(fn: () => Promise<void> | void): Promise<void>;
@@ -0,0 +1,17 @@
1
+ import { red } from "./colors.js";
2
+ export async function runCommand(fn) {
3
+ try {
4
+ await fn();
5
+ }
6
+ catch (error) {
7
+ if (error?.name === "ExitPromptError") {
8
+ console.log("\nCancelled.");
9
+ process.exit(0);
10
+ }
11
+ const message = error?.message;
12
+ if (message) {
13
+ console.error(`${red("✗")} ${message}`);
14
+ }
15
+ process.exit(1);
16
+ }
17
+ }
package/dist/colors.d.ts CHANGED
@@ -6,4 +6,3 @@ export declare const red: (text: string) => string;
6
6
  export declare const cyan: (text: string) => string;
7
7
  export declare const gray: (text: string) => string;
8
8
  export declare const magenta: (text: string) => string;
9
- //# sourceMappingURL=colors.d.ts.map
package/dist/colors.js CHANGED
@@ -10,4 +10,3 @@ export const red = wrap(31, 39);
10
10
  export const cyan = wrap(36, 39);
11
11
  export const gray = wrap(90, 39);
12
12
  export const magenta = wrap(35, 39);
13
- //# sourceMappingURL=colors.js.map
@@ -7,4 +7,3 @@ export interface AmendOptions {
7
7
  yes?: boolean;
8
8
  }
9
9
  export declare function amendCommand(options?: AmendOptions): Promise<void>;
10
- //# sourceMappingURL=amend.d.ts.map
@@ -1,11 +1,10 @@
1
- import { confirm } from "@inquirer/prompts";
2
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
3
2
  import { loadConfig } from "../config.js";
4
3
  import { inferTicket } from "../git.js";
5
4
  import { bold, dim, green, yellow, cyan } from "../colors.js";
6
5
  import { selectWithBack, inputWithBack, confirmWithBack, searchWithBack, BACK_VALUE } from "../prompts.js";
7
6
  function getLastCommitMessage() {
8
- return execSync("git log -1 --format=%s", { encoding: "utf-8" }).trim();
7
+ return execFileSync("git", ["log", "-1", "--format=%s"], { encoding: "utf-8" }).trim();
9
8
  }
10
9
  function parseCommitMessage(msg, format) {
11
10
  // Try to parse the default format: type[ticket]!(scope): message
@@ -45,10 +44,12 @@ export async function amendCommand(options = {}) {
45
44
  editMessage = hasEditFlags;
46
45
  }
47
46
  else {
48
- editMessage = await confirm({
47
+ const editResult = await confirmWithBack({
49
48
  message: "Edit commit message?",
50
49
  default: true,
50
+ showBack: false,
51
51
  });
52
+ editMessage = editResult === true;
52
53
  }
53
54
  let newMessage = lastMessage;
54
55
  if (editMessage) {
@@ -191,7 +192,7 @@ export async function amendCommand(options = {}) {
191
192
  newMessage = result;
192
193
  }
193
194
  // Check for additional staged changes
194
- const staged = execSync("git diff --cached --name-only", { encoding: "utf-8" }).trim();
195
+ const staged = execFileSync("git", ["diff", "--cached", "--name-only"], { encoding: "utf-8" }).trim();
195
196
  if (staged) {
196
197
  console.log(dim("\nStaged changes will be included:"));
197
198
  staged.split("\n").forEach((f) => console.log(dim(` ${f}`)));
@@ -226,7 +227,7 @@ export async function amendCommand(options = {}) {
226
227
  process.exit(0);
227
228
  }
228
229
  }
229
- execSync(`git commit --amend -m ${JSON.stringify(newMessage)}`, {
230
+ execFileSync("git", ["commit", "--amend", "-m", newMessage], {
230
231
  stdio: "inherit",
231
232
  });
232
233
  console.log(green("✓ Commit amended successfully."));
@@ -239,4 +240,3 @@ export async function amendCommand(options = {}) {
239
240
  process.exit(1);
240
241
  }
241
242
  }
242
- //# sourceMappingURL=amend.js.map
@@ -13,4 +13,3 @@ export interface BranchOptions {
13
13
  yes?: boolean;
14
14
  }
15
15
  export declare function branchCommand(options?: BranchOptions): Promise<void>;
16
- //# sourceMappingURL=branch.d.ts.map
@@ -1,7 +1,8 @@
1
1
  import { select, input } from "@inquirer/prompts";
2
- import { execSync } from "child_process";
2
+ import { execFileSync } from "child_process";
3
3
  import { loadConfig } from "../config.js";
4
- import { bold, dim, green, cyan, gray } from "../colors.js";
4
+ import { bold, dim, green, cyan, gray, red } from "../colors.js";
5
+ import { assertBranchName } from "../git.js";
5
6
  import { setTestPlan } from "../test-plan.js";
6
7
  import { createTicketProvider, inferBranchTypeFromLabels, parseAcceptanceCriteria, } from "../providers/tickets.js";
7
8
  import { selectWithBack, inputWithBack, BACK_VALUE } from "../prompts.js";
@@ -17,6 +18,8 @@ export function formatBranchName(format, vars) {
17
18
  result = result.replace(/__+/g, "_").replace(/^_|_$/g, "");
18
19
  // Clean up underscore next to slash
19
20
  result = result.replace(/\/_/g, "/").replace(/_\//g, "/");
21
+ // The ticket and branchFormat come from the user or the repo's config: never hand git an option
22
+ assertBranchName(result);
20
23
  return result;
21
24
  }
22
25
  function toKebabCase(str) {
@@ -254,7 +257,7 @@ export async function branchCommand(options = {}) {
254
257
  // Check if branch already exists
255
258
  let branchExists = false;
256
259
  try {
257
- execSync(`git rev-parse --verify ${branchName}`, { stdio: "pipe" });
260
+ execFileSync("git", ["rev-parse", "--verify", branchName], { stdio: "pipe" });
258
261
  branchExists = true;
259
262
  }
260
263
  catch {
@@ -270,7 +273,7 @@ export async function branchCommand(options = {}) {
270
273
  ],
271
274
  });
272
275
  if (action === "checkout") {
273
- execSync(`git checkout ${branchName}`, { stdio: "inherit" });
276
+ execFileSync("git", ["checkout", branchName], { stdio: "inherit" });
274
277
  console.log(green(`✓ Checked out existing branch: ${branchName}`));
275
278
  }
276
279
  else if (action === "new") {
@@ -283,7 +286,7 @@ export async function branchCommand(options = {}) {
283
286
  }
284
287
  }
285
288
  else {
286
- execSync(`git checkout -b ${branchName}`, { stdio: "inherit" });
289
+ execFileSync("git", ["checkout", "-b", branchName], { stdio: "inherit" });
287
290
  console.log(green(`✓ Branch created: ${branchName}`));
288
291
  }
289
292
  // Handle test plan from flag or prompt
@@ -353,7 +356,7 @@ export async function branchCommand(options = {}) {
353
356
  console.log("\nCancelled.");
354
357
  process.exit(0);
355
358
  }
359
+ console.error(red(`✗ ${error.message}`));
356
360
  process.exit(1);
357
361
  }
358
362
  }
359
- //# sourceMappingURL=branch.js.map
@@ -4,4 +4,3 @@ export interface ChangelogOptions {
4
4
  yes?: boolean;
5
5
  }
6
6
  export declare function changelogCommand(options?: ChangelogOptions): Promise<void>;
7
- //# sourceMappingURL=changelog.d.ts.map
@@ -1,10 +1,12 @@
1
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
2
2
  import { writeFileSync, existsSync, readFileSync } from "fs";
3
3
  import { bold, dim, green, cyan, gray } from "../colors.js";
4
+ import { isOptionLike, resolveCommit } from "../git.js";
4
5
  import { inputWithBack, confirmWithBack, BACK_VALUE, } from "../prompts.js";
5
6
  function getLatestTag() {
6
7
  try {
7
- return execSync("git describe --tags --abbrev=0", { encoding: "utf-8" }).trim();
8
+ const tag = execFileSync("git", ["describe", "--tags", "--abbrev=0"], { encoding: "utf-8" }).trim();
9
+ return isOptionLike(tag) ? undefined : tag;
8
10
  }
9
11
  catch {
10
12
  return undefined;
@@ -12,8 +14,11 @@ function getLatestTag() {
12
14
  }
13
15
  function getCommitsSinceTag(tag) {
14
16
  try {
15
- const range = tag ? `${tag}..HEAD` : "HEAD";
16
- const log = execSync(`git log ${range} --format=%s`, { encoding: "utf-8" }).trim();
17
+ const tagId = tag ? resolveCommit(tag) : undefined;
18
+ if (tag && !tagId)
19
+ return [];
20
+ const range = tagId ? `${tagId}..HEAD` : "HEAD";
21
+ const log = execFileSync("git", ["log", range, "--format=%s"], { encoding: "utf-8" }).trim();
17
22
  return log ? log.split("\n") : [];
18
23
  }
19
24
  catch {
@@ -251,4 +256,3 @@ function bumpVersion(tag, entries) {
251
256
  }
252
257
  return parts.join(".");
253
258
  }
254
- //# sourceMappingURL=changelog.js.map
@@ -6,4 +6,3 @@ export interface CleanupOptions {
6
6
  yes?: boolean;
7
7
  }
8
8
  export declare function cleanupCommand(options?: CleanupOptions): Promise<void>;
9
- //# sourceMappingURL=cleanup.d.ts.map
@@ -1,14 +1,16 @@
1
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
2
2
  import { bold, dim, green, red, yellow, gray } from "../colors.js";
3
3
  import { deleteTestPlan } from "../test-plan.js";
4
+ import { getRepoDefaultBranch } from "../git.js";
4
5
  import { checkboxWithBack, confirmWithBack, BACK_VALUE } from "../prompts.js";
5
6
  function getMergedBranches() {
6
7
  try {
7
- const result = execSync("git branch --merged main", { encoding: "utf-8" }).trim();
8
+ const defaultBranch = getRepoDefaultBranch();
9
+ const result = execFileSync("git", ["branch", "--merged", defaultBranch], { encoding: "utf-8" }).trim();
8
10
  return result
9
11
  .split("\n")
10
12
  .map((b) => b.trim())
11
- .filter((b) => b && !b.startsWith("*") && b !== "main" && b !== "master");
13
+ .filter((b) => b && !b.startsWith("*") && b !== defaultBranch);
12
14
  }
13
15
  catch {
14
16
  return [];
@@ -17,7 +19,7 @@ function getMergedBranches() {
17
19
  function getGoneBranches() {
18
20
  try {
19
21
  // Branches whose remote tracking branch is gone
20
- const result = execSync("git branch -vv", { encoding: "utf-8" }).trim();
22
+ const result = execFileSync("git", ["branch", "-vv"], { encoding: "utf-8" }).trim();
21
23
  return result
22
24
  .split("\n")
23
25
  .filter((line) => line.includes(": gone]"))
@@ -34,7 +36,7 @@ export async function cleanupCommand(options = {}) {
34
36
  // Fetch latest remote state
35
37
  console.log(dim("Fetching remote state..."));
36
38
  try {
37
- execSync("git fetch --prune", { stdio: "ignore" });
39
+ execFileSync("git", ["fetch", "--prune"], { stdio: "ignore" });
38
40
  }
39
41
  catch {
40
42
  console.log(yellow("⚠ Could not fetch from remote."));
@@ -95,7 +97,7 @@ export async function cleanupCommand(options = {}) {
95
97
  }
96
98
  else {
97
99
  try {
98
- execSync(`git branch -d ${branch}`, { stdio: "ignore" });
100
+ execFileSync("git", ["branch", "-d", branch], { stdio: "ignore" });
99
101
  deleteTestPlan(branch);
100
102
  console.log(`${green("✓")} Deleted ${branch}`);
101
103
  }
@@ -118,7 +120,7 @@ export async function cleanupCommand(options = {}) {
118
120
  force = forceResult === true;
119
121
  }
120
122
  if (force) {
121
- execSync(`git branch -D ${branch}`, { stdio: "ignore" });
123
+ execFileSync("git", ["branch", "-D", branch], { stdio: "ignore" });
122
124
  deleteTestPlan(branch);
123
125
  console.log(`${yellow("✓")} Force deleted ${branch}`);
124
126
  }
@@ -147,4 +149,3 @@ export async function cleanupCommand(options = {}) {
147
149
  process.exit(1);
148
150
  }
149
151
  }
150
- //# sourceMappingURL=cleanup.js.map
@@ -3,4 +3,3 @@ export declare function commentsCommand(opts: {
3
3
  resolved?: boolean;
4
4
  unresolved?: boolean;
5
5
  }): Promise<void>;
6
- //# sourceMappingURL=comments.d.ts.map
@@ -1,9 +1,9 @@
1
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
2
2
  import { bold, dim, cyan, yellow, green, magenta, gray } from "../colors.js";
3
3
  import { checkGhInstalled } from "../git.js";
4
4
  function getCurrentPr() {
5
5
  try {
6
- const result = execSync("gh pr view --json number,title", {
6
+ const result = execFileSync("gh", ["pr", "view", "--json", "number,title"], {
7
7
  encoding: "utf-8",
8
8
  stdio: ["pipe", "pipe", "ignore"],
9
9
  }).trim();
@@ -15,7 +15,7 @@ function getCurrentPr() {
15
15
  }
16
16
  function getRepoInfo() {
17
17
  try {
18
- const result = execSync("gh repo view --json owner,name", {
18
+ const result = execFileSync("gh", ["repo", "view", "--json", "owner,name"], {
19
19
  encoding: "utf-8",
20
20
  stdio: ["pipe", "pipe", "ignore"],
21
21
  }).trim();
@@ -51,7 +51,7 @@ function getReviewThreads(owner, repo, prNumber) {
51
51
  }
52
52
  `;
53
53
  try {
54
- const result = execSync(`gh api graphql -f query='${query.replace(/'/g, "'\\''")}'`, {
54
+ const result = execFileSync("gh", ["api", "graphql", "-f", `query=${query}`], {
55
55
  encoding: "utf-8",
56
56
  stdio: ["pipe", "pipe", "ignore"],
57
57
  }).trim();
@@ -75,7 +75,12 @@ function getReviewThreads(owner, repo, prNumber) {
75
75
  }
76
76
  function getReviews(owner, repo, prNumber) {
77
77
  try {
78
- const result = execSync(`gh api repos/${owner}/${repo}/pulls/${prNumber}/reviews --jq '[.[] | {author: .user.login, state: .state, body: .body, submittedAt: .submitted_at}]'`, { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] }).trim();
78
+ const result = execFileSync("gh", [
79
+ "api",
80
+ `repos/${owner}/${repo}/pulls/${prNumber}/reviews`,
81
+ "--jq",
82
+ "[.[] | {author: .user.login, state: .state, body: .body, submittedAt: .submitted_at}]",
83
+ ], { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] }).trim();
79
84
  return result ? JSON.parse(result) : [];
80
85
  }
81
86
  catch {
@@ -263,4 +268,3 @@ export async function commentsCommand(opts) {
263
268
  console.log(`${dim("───")} ${parts.join(dim(" · "))} ${dim("───")}\n`);
264
269
  }
265
270
  }
266
- //# sourceMappingURL=comments.js.map
@@ -21,4 +21,3 @@ export interface CommitOptions {
21
21
  yes?: boolean;
22
22
  }
23
23
  export declare function commitCommand(options?: CommitOptions): Promise<void>;
24
- //# sourceMappingURL=commit.d.ts.map
@@ -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 { inferTicket, inferScope, getBranch, isProtectedBranch } from "../git.js";
4
4
  import { bold, cyan, dim, green, yellow } from "../colors.js";
@@ -66,14 +66,14 @@ export async function commitCommand(options = {}) {
66
66
  // Stage files if --all or --files provided (non-interactive)
67
67
  if (options.all) {
68
68
  if (!options.dryRun) {
69
- execSync("git add -A");
69
+ execFileSync("git", ["add", "-A"]);
70
70
  }
71
71
  }
72
72
  else if (options.files) {
73
73
  const filesToStage = options.files.split(",").map((f) => f.trim());
74
74
  if (!options.dryRun) {
75
75
  for (const file of filesToStage) {
76
- execSync(`git add ${JSON.stringify(file)}`);
76
+ execFileSync("git", ["add", "--", file]);
77
77
  }
78
78
  }
79
79
  }
@@ -92,7 +92,7 @@ export async function commitCommand(options = {}) {
92
92
  // Determine starting step based on flags
93
93
  if (options.all || options.files) {
94
94
  // Files already staged via flags, skip to type
95
- const staged = execSync("git diff --cached --name-only", { encoding: "utf-8" }).trim();
95
+ const staged = execFileSync("git", ["diff", "--cached", "--name-only"], { encoding: "utf-8" }).trim();
96
96
  state.stagedFiles = staged ? staged.split("\n") : [];
97
97
  currentStep = "type";
98
98
  }
@@ -129,9 +129,9 @@ export async function commitCommand(options = {}) {
129
129
  switch (currentStep) {
130
130
  case "stageFiles": {
131
131
  // Check for staged files
132
- const staged = execSync("git diff --cached --name-only", { encoding: "utf-8" }).trim();
133
- const unstaged = execSync("git diff --name-only", { encoding: "utf-8" }).trim();
134
- const untracked = execSync("git ls-files --others --exclude-standard", { encoding: "utf-8" }).trim();
132
+ const staged = execFileSync("git", ["diff", "--cached", "--name-only"], { encoding: "utf-8" }).trim();
133
+ const unstaged = execFileSync("git", ["diff", "--name-only"], { encoding: "utf-8" }).trim();
134
+ const untracked = execFileSync("git", ["ls-files", "--others", "--exclude-standard"], { encoding: "utf-8" }).trim();
135
135
  const allChanges = [
136
136
  ...unstaged.split("\n").filter(Boolean).map((f) => ({ file: f, label: `M ${f}` })),
137
137
  ...untracked.split("\n").filter(Boolean).map((f) => ({ file: f, label: `? ${f}` })),
@@ -152,7 +152,7 @@ export async function commitCommand(options = {}) {
152
152
  if (options.yes) {
153
153
  // Auto-stage all files when --yes
154
154
  if (!options.dryRun) {
155
- execSync("git add -A");
155
+ execFileSync("git", ["add", "-A"]);
156
156
  }
157
157
  state.stagedFiles = allChanges.map((c) => c.file);
158
158
  goNext();
@@ -169,7 +169,7 @@ export async function commitCommand(options = {}) {
169
169
  process.exit(0);
170
170
  }
171
171
  if (!options.dryRun) {
172
- execSync(`git add ${JSON.stringify(allChanges[0].file)}`);
172
+ execFileSync("git", ["--literal-pathspecs", "add", "--", allChanges[0].file]);
173
173
  }
174
174
  state.stagedFiles = [allChanges[0].file];
175
175
  goNext();
@@ -191,7 +191,7 @@ export async function commitCommand(options = {}) {
191
191
  }
192
192
  if (stageChoice === "all") {
193
193
  if (!options.dryRun) {
194
- execSync("git add -A");
194
+ execFileSync("git", ["add", "-A"]);
195
195
  }
196
196
  state.stagedFiles = allChanges.map((c) => c.file);
197
197
  goNext();
@@ -212,8 +212,9 @@ export async function commitCommand(options = {}) {
212
212
  break;
213
213
  }
214
214
  if (!options.dryRun) {
215
+ // Picked names are file names, not patterns: "x*" stages only the file called x*.
215
216
  for (const file of filesToStage) {
216
- execSync(`git add ${JSON.stringify(file)}`);
217
+ execFileSync("git", ["--literal-pathspecs", "add", "--", file]);
217
218
  }
218
219
  }
219
220
  state.stagedFiles = filesToStage;
@@ -234,7 +235,7 @@ export async function commitCommand(options = {}) {
234
235
  });
235
236
  if (result === BACK_VALUE) {
236
237
  // Unstage files before going back
237
- execSync("git reset HEAD", { stdio: "ignore" });
238
+ execFileSync("git", ["reset", "HEAD"], { stdio: "ignore" });
238
239
  goBack();
239
240
  }
240
241
  else {
@@ -463,7 +464,7 @@ export async function commitCommand(options = {}) {
463
464
  console.log("Commit aborted.");
464
465
  process.exit(0);
465
466
  }
466
- execSync(`git commit -m ${JSON.stringify(fullMessage)}`, {
467
+ execFileSync("git", ["commit", "-m", fullMessage], {
467
468
  stdio: "inherit",
468
469
  });
469
470
  console.log(green("✓ Commit created successfully."));
@@ -476,4 +477,3 @@ export async function commitCommand(options = {}) {
476
477
  process.exit(1);
477
478
  }
478
479
  }
479
- //# sourceMappingURL=commit.js.map
@@ -1,2 +1 @@
1
1
  export declare function doctorCommand(): Promise<void>;
2
- //# sourceMappingURL=doctor.d.ts.map
@@ -1,10 +1,10 @@
1
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
2
2
  import { existsSync, readFileSync } from "fs";
3
3
  import { resolve } from "path";
4
4
  import { bold, dim, green, red, yellow, gray } from "../colors.js";
5
- function checkCommand(cmd) {
5
+ function checkCommand(file, ...args) {
6
6
  try {
7
- return execSync(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] }).trim();
7
+ return execFileSync(file, args, { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] }).trim();
8
8
  }
9
9
  catch {
10
10
  return undefined;
@@ -15,12 +15,12 @@ export async function doctorCommand() {
15
15
  const checks = [];
16
16
  console.log(`\n${dim("───")} ${bold("devflow doctor")} ${dim("───")}\n`);
17
17
  // 1. Git
18
- const gitVersion = checkCommand("git --version");
18
+ const gitVersion = checkCommand("git", "--version");
19
19
  checks.push(gitVersion
20
20
  ? { name: "git", status: "ok", detail: gitVersion.replace("git version ", "") }
21
21
  : { name: "git", status: "error", detail: "Not installed" });
22
22
  // 2. Node
23
- const nodeVersion = checkCommand("node --version");
23
+ const nodeVersion = checkCommand("node", "--version");
24
24
  if (nodeVersion) {
25
25
  const major = parseInt(nodeVersion.replace("v", "").split(".")[0], 10);
26
26
  checks.push(major >= 20
@@ -31,7 +31,7 @@ export async function doctorCommand() {
31
31
  checks.push({ name: "node", status: "error", detail: "Not installed" });
32
32
  }
33
33
  // 3. GitHub CLI
34
- const ghVersion = checkCommand("gh --version");
34
+ const ghVersion = checkCommand("gh", "--version");
35
35
  if (ghVersion) {
36
36
  const version = ghVersion.split("\n")[0];
37
37
  checks.push({ name: "gh (GitHub CLI)", status: "ok", detail: version.replace("gh version ", "").split(" ")[0] });
@@ -41,13 +41,13 @@ export async function doctorCommand() {
41
41
  }
42
42
  // 4. gh auth
43
43
  if (ghVersion) {
44
- const ghAuth = checkCommand("gh auth status");
44
+ const ghAuth = checkCommand("gh", "auth", "status");
45
45
  checks.push(ghAuth
46
46
  ? { name: "gh auth", status: "ok", detail: "Authenticated" }
47
47
  : { name: "gh auth", status: "warning", detail: "Not authenticated (run: gh auth login)" });
48
48
  }
49
49
  // 5. Git repo
50
- const isRepo = checkCommand("git rev-parse --is-inside-work-tree");
50
+ const isRepo = checkCommand("git", "rev-parse", "--is-inside-work-tree");
51
51
  checks.push(isRepo === "true"
52
52
  ? { name: "git repository", status: "ok" }
53
53
  : { name: "git repository", status: "error", detail: "Not inside a git repository" });
@@ -119,4 +119,3 @@ export async function doctorCommand() {
119
119
  process.exit(1);
120
120
  }
121
121
  }
122
- //# sourceMappingURL=doctor.js.map
@@ -7,4 +7,3 @@ export interface FixupOptions {
7
7
  yes?: boolean;
8
8
  }
9
9
  export declare function fixupCommand(options?: FixupOptions): Promise<void>;
10
- //# sourceMappingURL=fixup.d.ts.map
@@ -1,10 +1,12 @@
1
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
2
2
  import { bold, dim, green, cyan } from "../colors.js";
3
- import { getDefaultBase, getBranch } from "../git.js";
3
+ import { getDefaultBase, getBranch, resolveCommit } from "../git.js";
4
4
  import { selectWithBack, confirmWithBack, checkboxWithBack, BACK_VALUE, } from "../prompts.js";
5
- function getCommitsOnBranch(base) {
5
+ function getCommitsOnBranch(baseId) {
6
+ if (!baseId)
7
+ return [];
6
8
  try {
7
- const log = execSync(`git log ${base}..HEAD --format=%H|%s`, { encoding: "utf-8" }).trim();
9
+ const log = execFileSync("git", ["log", `${baseId}..HEAD`, "--format=%H|%s"], { encoding: "utf-8" }).trim();
8
10
  if (!log)
9
11
  return [];
10
12
  return log.split("\n").map((line) => {
@@ -20,7 +22,8 @@ export async function fixupCommand(options = {}) {
20
22
  try {
21
23
  const branch = getBranch();
22
24
  const base = getDefaultBase(branch);
23
- const commits = getCommitsOnBranch(base);
25
+ const baseId = resolveCommit(base);
26
+ const commits = getCommitsOnBranch(baseId);
24
27
  if (commits.length < 2) {
25
28
  console.log("Need at least 2 commits on the branch to fixup.");
26
29
  return;
@@ -28,14 +31,14 @@ export async function fixupCommand(options = {}) {
28
31
  // Stage files if --all or --files provided (non-interactive)
29
32
  if (options.all) {
30
33
  if (!options.dryRun) {
31
- execSync("git add -A");
34
+ execFileSync("git", ["add", "-A"]);
32
35
  }
33
36
  }
34
37
  else if (options.files) {
35
38
  const filesToStage = options.files.split(",").map((f) => f.trim());
36
39
  if (!options.dryRun) {
37
40
  for (const file of filesToStage) {
38
- execSync(`git add ${JSON.stringify(file)}`);
41
+ execFileSync("git", ["add", "--", file]);
39
42
  }
40
43
  }
41
44
  }
@@ -60,9 +63,9 @@ export async function fixupCommand(options = {}) {
60
63
  switch (currentStep) {
61
64
  case "stageFiles": {
62
65
  // Check for unstaged/staged changes
63
- const staged = execSync("git diff --cached --name-only", { encoding: "utf-8" }).trim();
64
- const unstaged = execSync("git diff --name-only", { encoding: "utf-8" }).trim();
65
- const untracked = execSync("git ls-files --others --exclude-standard", { encoding: "utf-8" }).trim();
66
+ const staged = execFileSync("git", ["diff", "--cached", "--name-only"], { encoding: "utf-8" }).trim();
67
+ const unstaged = execFileSync("git", ["diff", "--name-only"], { encoding: "utf-8" }).trim();
68
+ const untracked = execFileSync("git", ["ls-files", "--others", "--exclude-standard"], { encoding: "utf-8" }).trim();
66
69
  // If already have staged changes, skip to target selection
67
70
  if (staged) {
68
71
  currentStep = "selectTarget";
@@ -80,7 +83,7 @@ export async function fixupCommand(options = {}) {
80
83
  if (options.yes) {
81
84
  // Auto-stage all when --yes
82
85
  if (!options.dryRun) {
83
- execSync("git add -A");
86
+ execFileSync("git", ["add", "-A"]);
84
87
  }
85
88
  currentStep = "selectTarget";
86
89
  break;
@@ -104,11 +107,12 @@ export async function fixupCommand(options = {}) {
104
107
  }
105
108
  if (!options.dryRun) {
106
109
  if (result.includes("__ALL__")) {
107
- execSync("git add -A");
110
+ execFileSync("git", ["add", "-A"]);
108
111
  }
109
112
  else {
113
+ // Picked names are file names, not patterns: "x*" stages only the file called x*.
110
114
  for (const file of result) {
111
- execSync(`git add ${JSON.stringify(file)}`);
115
+ execFileSync("git", ["--literal-pathspecs", "add", "--", file]);
112
116
  }
113
117
  }
114
118
  }
@@ -130,7 +134,7 @@ export async function fixupCommand(options = {}) {
130
134
  });
131
135
  if (result === BACK_VALUE) {
132
136
  // Unstage files before going back
133
- execSync("git reset HEAD", { stdio: "ignore" });
137
+ execFileSync("git", ["reset", "HEAD"], { stdio: "ignore" });
134
138
  currentStep = "stageFiles";
135
139
  }
136
140
  else {
@@ -146,7 +150,7 @@ export async function fixupCommand(options = {}) {
146
150
  return;
147
151
  }
148
152
  // Create fixup commit
149
- execSync(`git commit --fixup=${target}`, { stdio: "inherit" });
153
+ execFileSync("git", ["commit", `--fixup=${target}`], { stdio: "inherit" });
150
154
  console.log(green("✓ Fixup commit created."));
151
155
  // Handle auto-squash from flag or prompt
152
156
  let autoSquash;
@@ -165,7 +169,7 @@ export async function fixupCommand(options = {}) {
165
169
  autoSquash = squashResult === true;
166
170
  }
167
171
  if (autoSquash) {
168
- execSync(`GIT_SEQUENCE_EDITOR=true git rebase -i --autosquash ${base}`, {
172
+ execFileSync("git", ["rebase", "-i", "--autosquash", baseId], {
169
173
  stdio: "inherit",
170
174
  env: { ...process.env, GIT_SEQUENCE_EDITOR: "true" },
171
175
  });
@@ -190,4 +194,3 @@ export async function fixupCommand(options = {}) {
190
194
  process.exit(1);
191
195
  }
192
196
  }
193
- //# sourceMappingURL=fixup.js.map