@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
@@ -1,2 +1 @@
1
1
  export declare function initCommand(): Promise<void>;
2
- //# sourceMappingURL=init.d.ts.map
@@ -1,10 +1,13 @@
1
1
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
2
2
  import { resolve } from "path";
3
3
  import { confirm, input, select } from "@inquirer/prompts";
4
- import { execSync } from "child_process";
4
+ import { execFileSync } from "child_process";
5
5
  import { PRESETS } from "../config.js";
6
6
  import { writeVersionInfo, getCliVersion } from "../devflow-version.js";
7
+ import { isGhInstalled } from "../git.js";
7
8
  import { selectWithBack, inputWithBack, confirmWithBack, BACK_VALUE, } from "../prompts.js";
9
+ // npm and npx are .cmd shims on Windows, which Node only runs through a shell. Their arguments here are constants.
10
+ const WINDOWS_SHELL = process.platform === "win32";
8
11
  const DEFAULT_CHECKLIST = [
9
12
  "Code follows project conventions",
10
13
  "Self-reviewed the changes",
@@ -23,7 +26,7 @@ function readPackageJson(cwd) {
23
26
  }
24
27
  function getGitHubIssuesUrl() {
25
28
  try {
26
- const remoteUrl = execSync("git remote get-url origin", {
29
+ const remoteUrl = execFileSync("git", ["remote", "get-url", "origin"], {
27
30
  encoding: "utf-8",
28
31
  stdio: ["pipe", "pipe", "pipe"],
29
32
  }).trim();
@@ -45,7 +48,7 @@ function getGitHubIssuesUrl() {
45
48
  }
46
49
  function getGitHubRepo() {
47
50
  try {
48
- const remoteUrl = execSync("git remote get-url origin", {
51
+ const remoteUrl = execFileSync("git", ["remote", "get-url", "origin"], {
49
52
  encoding: "utf-8",
50
53
  stdio: ["pipe", "pipe", "pipe"],
51
54
  }).trim();
@@ -64,7 +67,7 @@ function getGitHubRepo() {
64
67
  function hasProjectScopes() {
65
68
  try {
66
69
  // Try to list projects - if it fails with scope error, we don't have permissions
67
- execSync("gh project list --owner @me --limit 1", {
70
+ execFileSync("gh", ["project", "list", "--owner", "@me", "--limit", "1"], {
68
71
  encoding: "utf-8",
69
72
  stdio: ["pipe", "pipe", "pipe"],
70
73
  });
@@ -84,7 +87,7 @@ function getRepoLinkedProjects(repo) {
84
87
  }
85
88
  }
86
89
  }`;
87
- const result = execSync(`gh api graphql -f query='${query}'`, {
90
+ const result = execFileSync("gh", ["api", "graphql", "-f", `query=${query}`], {
88
91
  encoding: "utf-8",
89
92
  stdio: ["pipe", "pipe", "pipe"],
90
93
  }).trim();
@@ -103,7 +106,7 @@ function getRepoLinkedProjects(repo) {
103
106
  }
104
107
  function refreshProjectScopes() {
105
108
  try {
106
- execSync("gh auth refresh -s project", {
109
+ execFileSync("gh", ["auth", "refresh", "-s", "project"], {
107
110
  stdio: "inherit",
108
111
  });
109
112
  return true;
@@ -114,18 +117,10 @@ function refreshProjectScopes() {
114
117
  }
115
118
  function createAndLinkProject(repo, title) {
116
119
  try {
117
- // Create the project
118
- const createResult = execSync(`gh project create --owner ${repo.owner} --title "${title}" --format json`, {
119
- encoding: "utf-8",
120
- stdio: ["pipe", "pipe", "pipe"],
121
- }).trim();
120
+ const createResult = execFileSync("gh", ["project", "create", "--owner", repo.owner, "--title", title, "--format", "json"], { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
122
121
  const project = JSON.parse(createResult);
123
122
  const projectNumber = project.number;
124
- // Link it to the repo
125
- execSync(`gh project link ${projectNumber} --owner ${repo.owner} --repo ${repo.name}`, {
126
- encoding: "utf-8",
127
- stdio: ["pipe", "pipe", "pipe"],
128
- });
123
+ execFileSync("gh", ["project", "link", String(projectNumber), "--owner", repo.owner, "--repo", repo.name], { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
129
124
  return { number: projectNumber, title };
130
125
  }
131
126
  catch {
@@ -227,6 +222,12 @@ export async function initCommand() {
227
222
  break;
228
223
  }
229
224
  case "projectSetup": {
225
+ if (!isGhInstalled()) {
226
+ console.log("⚠ GitHub CLI (gh) is not installed — skipping project integration.");
227
+ console.log(" Install it with: brew install gh\n");
228
+ currentStep = "scopes";
229
+ break;
230
+ }
230
231
  // Check if we have project scopes
231
232
  const hasScopes = hasProjectScopes();
232
233
  if (!hasScopes) {
@@ -540,8 +541,9 @@ export async function initCommand() {
540
541
  // Install commitlint deps
541
542
  console.log("Installing commitlint...");
542
543
  try {
543
- execSync("npm install -D @commitlint/cli @commitlint/config-conventional", {
544
+ execFileSync("npm", ["install", "-D", "@commitlint/cli", "@commitlint/config-conventional"], {
544
545
  cwd,
546
+ shell: WINDOWS_SHELL,
545
547
  stdio: "inherit",
546
548
  });
547
549
  console.log("✓ Installed commitlint");
@@ -560,8 +562,8 @@ export async function initCommand() {
560
562
  // Install husky
561
563
  console.log("Installing husky...");
562
564
  try {
563
- execSync("npm install -D husky", { cwd, stdio: "inherit" });
564
- execSync("npx husky init", { cwd, stdio: "inherit" });
565
+ execFileSync("npm", ["install", "-D", "husky"], { cwd, stdio: "inherit", shell: WINDOWS_SHELL });
566
+ execFileSync("npx", ["husky", "init"], { cwd, stdio: "inherit", shell: WINDOWS_SHELL });
565
567
  console.log("✓ Installed and initialized husky");
566
568
  }
567
569
  catch {
@@ -627,9 +629,9 @@ jobs:
627
629
  ci:
628
630
  runs-on: ubuntu-latest
629
631
  steps:
630
- - uses: actions/checkout@v4
632
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
631
633
 
632
- - uses: actions/setup-node@v4
634
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
633
635
  with:
634
636
  node-version: 20
635
637
  cache: npm
@@ -734,6 +736,52 @@ devflow amend # If you need to add more changes
734
736
  }
735
737
  }
736
738
  }
739
+ // Generate Claude Code skill wrapper that points to AI_INSTRUCTIONS.md
740
+ const skillDir = resolve(cwd, ".claude/skills/devflow-usage");
741
+ mkdirSync(skillDir, { recursive: true });
742
+ const claudeSkill = `---
743
+ name: devflow-usage
744
+ description: MANDATORY when working in any devflow-managed repo (one with a .devflow/config.json). Always use devflow commands instead of raw git/gh — \`devflow branch\` over \`git checkout -b\`, \`devflow commit\` over \`git commit\`, \`devflow pr\` over \`gh pr create\`. Never push directly to main; all changes go through PRs. Full command reference and non-interactive flag examples live in .devflow/AI_INSTRUCTIONS.md.
745
+ ---
746
+
747
+ # DevFlow Usage
748
+
749
+ This repo uses [devflow](https://github.com/alejandrochvs/devflow-cli) for Git workflow automation. Apply these rules whenever making changes.
750
+
751
+ ## Core rules
752
+
753
+ 1. **Never push directly to main.** All changes go through pull requests, even small fixes.
754
+ 2. **Use devflow commands, not raw git/gh:**
755
+ - Branches: \`devflow branch\` (not \`git checkout -b\`)
756
+ - Commits: \`devflow commit\` (not \`git commit\`)
757
+ - PRs: \`devflow pr\` (not \`gh pr create\`)
758
+ - Issues: \`devflow issue\` / \`devflow issues\` (not \`gh issue ...\`)
759
+ 3. **Issue-first workflow** (when a project board is configured):
760
+ - \`devflow issues\` to see Todo / In Progress
761
+ - \`devflow issues --work --issue <N> --yes\` to start work
762
+ 4. **Commit format:** \`${commitFormat}\` — e.g. \`feat[123](auth): add OAuth2 login\`.
763
+ 5. **Branch format:** \`${branchFormat}\` — e.g. \`feat/123_add-login\`.
764
+ 6. **Press \`Escape\`** to go back a step in any multi-step prompt.
765
+ 7. **Use \`--dry-run\`** to preview any command without executing.
766
+
767
+ ## Non-interactive mode for AI agents
768
+
769
+ Append \`--yes\` to skip all confirmation prompts. Each command also accepts content flags so prompts can be skipped entirely:
770
+
771
+ \`\`\`bash
772
+ devflow branch --type feat --ticket 123 --description "add-login" --yes
773
+ devflow commit --type feat --scope auth --message "add login" --all --yes
774
+ devflow pr --title "Add login" --summary "Implements login UI" --yes
775
+ \`\`\`
776
+
777
+ Full per-command non-interactive examples live in \`.devflow/AI_INSTRUCTIONS.md\`.
778
+
779
+ ## Full reference
780
+
781
+ For everything beyond the basics above — Quick Reference table, all command flags, common workflows, edge cases like merged/closed PRs — read \`.devflow/AI_INSTRUCTIONS.md\`. Treat that file as canonical.
782
+ `;
783
+ writeFileSync(resolve(skillDir, "SKILL.md"), claudeSkill);
784
+ console.log("✓ Created .claude/skills/devflow-usage/SKILL.md");
737
785
  }
738
786
  // 10. Write .devflow/config.json
739
787
  const config = {
@@ -790,4 +838,3 @@ devflow amend # If you need to add more changes
790
838
  process.exit(1);
791
839
  }
792
840
  }
793
- //# sourceMappingURL=init.js.map
@@ -9,4 +9,3 @@ export interface IssueOptions {
9
9
  yes?: boolean;
10
10
  }
11
11
  export declare function issueCommand(options?: IssueOptions): Promise<void>;
12
- //# sourceMappingURL=issue.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { select, input, confirm, editor } from "@inquirer/prompts";
2
- import { execSync } from "child_process";
2
+ import { execFileSync } from "child_process";
3
3
  import { loadConfig } from "../config.js";
4
4
  import { bold, dim, green, cyan, gray } from "../colors.js";
5
5
  import { checkGhInstalled } from "../git.js";
@@ -198,35 +198,20 @@ async function collectIssueData(issueType) {
198
198
  function ensureLabelsExist(labels) {
199
199
  for (const label of labels) {
200
200
  try {
201
- // Check if label exists
202
- execSync(`gh label list --search "${label}" --json name`, {
203
- encoding: "utf-8",
204
- stdio: ["pipe", "pipe", "pipe"],
205
- });
206
- // Parse results to see if exact match exists
207
- const result = execSync(`gh label list --search "${label}" --json name`, {
208
- encoding: "utf-8",
209
- });
201
+ const result = execFileSync("gh", ["label", "list", "--search", label, "--json", "name"], { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
210
202
  const existingLabels = JSON.parse(result);
211
203
  const exactMatch = existingLabels.some((l) => l.name.toLowerCase() === label.toLowerCase());
212
204
  if (!exactMatch) {
213
- // Create the label with a default color
214
205
  console.log(dim(`Creating label "${label}"...`));
215
- execSync(`gh label create "${label}" --color "0e8a16" --force`, {
216
- stdio: ["pipe", "pipe", "pipe"],
217
- });
206
+ execFileSync("gh", ["label", "create", "--color", "0e8a16", "--force", "--", label], { stdio: ["pipe", "pipe", "pipe"] });
218
207
  }
219
208
  }
220
209
  catch {
221
- // Label doesn't exist or error checking, try to create it
222
210
  try {
223
211
  console.log(dim(`Creating label "${label}"...`));
224
- execSync(`gh label create "${label}" --color "0e8a16" --force`, {
225
- stdio: ["pipe", "pipe", "pipe"],
226
- });
212
+ execFileSync("gh", ["label", "create", "--color", "0e8a16", "--force", "--", label], { stdio: ["pipe", "pipe", "pipe"] });
227
213
  }
228
214
  catch {
229
- // If we can't create the label, we'll let the issue creation fail with the original error
230
215
  console.warn(dim(`Warning: Could not create label "${label}"`));
231
216
  }
232
217
  }
@@ -238,7 +223,7 @@ function formatIssuePreview(data) {
238
223
  "",
239
224
  `${bold("Type:")} ${data.type.label}`,
240
225
  `${bold("Title:")} ${cyan(data.title)}`,
241
- `${bold("Labels:")} ${data.labels.join(", ")}`,
226
+ `${bold("Labels:")} ${data.labels.join(", ") || dim("none")}`,
242
227
  "",
243
228
  gray("─── Body ───"),
244
229
  "",
@@ -347,8 +332,8 @@ export async function issueCommand(options = {}) {
347
332
  console.log("Aborted.");
348
333
  process.exit(0);
349
334
  }
350
- // Determine labels
351
- const labels = [issueType.labelColor];
335
+ // Determine labels (an issue type may have none)
336
+ const labels = issueType.labelColor ? [issueType.labelColor] : [];
352
337
  // Build issue data
353
338
  const issueData = {
354
339
  type: issueType,
@@ -387,9 +372,7 @@ export async function issueCommand(options = {}) {
387
372
  ensureLabelsExist(labels);
388
373
  }
389
374
  // Create the issue using gh CLI
390
- const labelArg = labels.length > 0 ? `--label "${labels.join(",")}"` : "";
391
- const cmd = `gh issue create --title ${JSON.stringify(title)} --body-file - ${labelArg}`;
392
- const result = execSync(cmd, { input: body, encoding: "utf-8" }).trim();
375
+ const result = execFileSync("gh", ["issue", "create", `--title=${title}`, "--body-file", "-", ...labels.map((l) => `--label=${l}`)], { input: body, encoding: "utf-8" }).trim();
393
376
  // Extract issue number from URL (format: https://github.com/owner/repo/issues/123)
394
377
  const issueUrlMatch = result.match(/\/issues\/(\d+)/);
395
378
  const issueNumber = issueUrlMatch ? issueUrlMatch[1] : null;
@@ -504,7 +487,7 @@ export async function issueCommand(options = {}) {
504
487
  }
505
488
  }
506
489
  // Create the branch
507
- execSync(`git checkout -b ${branchName}`, { stdio: "inherit" });
490
+ execFileSync("git", ["checkout", "-b", branchName], { stdio: "inherit" });
508
491
  console.log(green(`✓ Branch created: ${branchName}`));
509
492
  // Skip test plan prompts if --yes is provided
510
493
  if (!options.yes) {
@@ -593,4 +576,3 @@ export async function issueCommand(options = {}) {
593
576
  throw error;
594
577
  }
595
578
  }
596
- //# sourceMappingURL=issue.js.map
@@ -8,4 +8,3 @@ export interface IssuesOptions {
8
8
  yes?: boolean;
9
9
  }
10
10
  export declare function issuesCommand(options?: IssuesOptions): Promise<void>;
11
- //# sourceMappingURL=issues.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 { bold, dim, green, cyan, yellow, gray } from "../colors.js";
4
4
  import { checkGhInstalled } from "../git.js";
@@ -331,7 +331,7 @@ async function startWork(options, config, ctx) {
331
331
  }
332
332
  // 3. Create branch
333
333
  try {
334
- execSync(`git checkout -b ${branchName}`, { stdio: "inherit" });
334
+ execFileSync("git", ["checkout", "-b", branchName], { stdio: "inherit" });
335
335
  console.log(green(`✓ Branch created: ${branchName}`));
336
336
  }
337
337
  catch {
@@ -376,4 +376,3 @@ export async function issuesCommand(options = {}) {
376
376
  throw error;
377
377
  }
378
378
  }
379
- //# sourceMappingURL=issues.js.map
@@ -1,2 +1 @@
1
1
  export declare function lintConfigCommand(): void;
2
- //# sourceMappingURL=lint-config.d.ts.map
@@ -88,4 +88,3 @@ export function lintConfigCommand() {
88
88
  }
89
89
  console.log("");
90
90
  }
91
- //# sourceMappingURL=lint-config.js.map
@@ -1,2 +1 @@
1
1
  export declare function logCommand(): Promise<void>;
2
- //# sourceMappingURL=log.d.ts.map
@@ -1,12 +1,15 @@
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, BACK_VALUE } from "../prompts.js";
5
5
  function getLog(base, limit = 20) {
6
6
  try {
7
7
  const format = "%H|%h|%s|%an|%ar";
8
- const range = base ? `${base}..HEAD` : `HEAD~${limit}..HEAD`;
9
- const result = execSync(`git log ${range} --pretty=format:"${format}" -${limit}`, {
8
+ const baseId = base ? resolveCommit(base) : undefined;
9
+ if (base && !baseId)
10
+ return [];
11
+ const range = baseId ? `${baseId}..HEAD` : `HEAD~${limit}..HEAD`;
12
+ const result = execFileSync("git", ["log", range, `--pretty=format:${format}`, `-${limit}`], {
10
13
  encoding: "utf-8",
11
14
  }).trim();
12
15
  if (!result)
@@ -61,7 +64,7 @@ export async function logCommand() {
61
64
  case "action": {
62
65
  const entry = entries.find((e) => e.hash === selectedHash);
63
66
  // Show commit detail
64
- const detail = execSync(`git show --stat ${selectedHash} --format="%B"`, {
67
+ const detail = execFileSync("git", ["show", "--stat", selectedHash, "--format=%B"], {
65
68
  encoding: "utf-8",
66
69
  }).trim();
67
70
  console.log(`\n${dim(detail)}\n`);
@@ -82,22 +85,22 @@ export async function logCommand() {
82
85
  }
83
86
  switch (action) {
84
87
  case "cherry-pick":
85
- execSync(`git cherry-pick ${selectedHash}`, { stdio: "inherit" });
88
+ execFileSync("git", ["cherry-pick", selectedHash], { stdio: "inherit" });
86
89
  console.log(green(`✓ Cherry-picked ${entry.shortHash}`));
87
90
  currentStep = "done";
88
91
  break;
89
92
  case "revert":
90
- execSync(`git revert ${selectedHash}`, { stdio: "inherit" });
93
+ execFileSync("git", ["revert", selectedHash], { stdio: "inherit" });
91
94
  console.log(green(`✓ Reverted ${entry.shortHash}`));
92
95
  currentStep = "done";
93
96
  break;
94
97
  case "fixup":
95
- execSync(`git commit --fixup=${selectedHash}`, { stdio: "inherit" });
98
+ execFileSync("git", ["commit", `--fixup=${selectedHash}`], { stdio: "inherit" });
96
99
  console.log(green(`✓ Created fixup for ${entry.shortHash}`));
97
100
  currentStep = "done";
98
101
  break;
99
102
  case "diff": {
100
- const diff = execSync(`git show ${selectedHash}`, { encoding: "utf-8" });
103
+ const diff = execFileSync("git", ["show", selectedHash], { encoding: "utf-8" });
101
104
  console.log(diff);
102
105
  // Stay on action step to allow choosing another action
103
106
  break;
@@ -121,4 +124,3 @@ export async function logCommand() {
121
124
  process.exit(1);
122
125
  }
123
126
  }
124
- //# sourceMappingURL=log.js.map
@@ -4,4 +4,3 @@ export interface MergeOptions {
4
4
  yes?: boolean;
5
5
  }
6
6
  export declare function mergeCommand(options?: MergeOptions): Promise<void>;
7
- //# sourceMappingURL=merge.d.ts.map
@@ -1,11 +1,11 @@
1
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
2
2
  import { bold, dim, green, cyan } from "../colors.js";
3
- import { getBranch, checkGhInstalled } from "../git.js";
3
+ import { getBranch, checkGhInstalled, getRepoDefaultBranch } from "../git.js";
4
4
  import { deleteTestPlan } from "../test-plan.js";
5
5
  import { selectWithBack, confirmWithBack, BACK_VALUE, } from "../prompts.js";
6
6
  function getPrForBranch() {
7
7
  try {
8
- const result = execSync("gh pr view --json number,url,title,state", {
8
+ const result = execFileSync("gh", ["pr", "view", "--json", "number,url,title,state"], {
9
9
  encoding: "utf-8",
10
10
  stdio: ["pipe", "pipe", "ignore"],
11
11
  }).trim();
@@ -118,19 +118,19 @@ export async function mergeCommand(options = {}) {
118
118
  currentStep = "execute";
119
119
  }
120
120
  }
121
- const deleteFlag = deleteBranch ? " --delete-branch" : "";
122
- execSync(`gh pr merge ${pr.number} --${method}${deleteFlag}`, { stdio: "inherit" });
121
+ const deleteArgs = deleteBranch ? ["--delete-branch"] : [];
122
+ execFileSync("gh", ["pr", "merge", String(pr.number), `--${method}`, ...deleteArgs], { stdio: "inherit" });
123
123
  console.log(green(`\n✓ PR #${pr.number} merged via ${method}.`));
124
124
  if (deleteBranch) {
125
125
  deleteTestPlan(branch);
126
- // Switch to main after merge
126
+ const defaultBranch = getRepoDefaultBranch();
127
127
  try {
128
- execSync("git checkout main", { stdio: "inherit" });
129
- execSync("git pull", { stdio: "inherit" });
130
- console.log(green("✓ Switched to main and pulled latest."));
128
+ execFileSync("git", ["checkout", defaultBranch], { stdio: "inherit" });
129
+ execFileSync("git", ["pull"], { stdio: "inherit" });
130
+ console.log(green(`✓ Switched to ${defaultBranch} and pulled latest.`));
131
131
  }
132
132
  catch {
133
- // May not have main locally
133
+ // May not have default branch locally
134
134
  }
135
135
  }
136
136
  }
@@ -142,4 +142,3 @@ export async function mergeCommand(options = {}) {
142
142
  process.exit(1);
143
143
  }
144
144
  }
145
- //# sourceMappingURL=merge.js.map
@@ -7,4 +7,3 @@ export interface PrOptions {
7
7
  ready?: boolean;
8
8
  }
9
9
  export declare function prCommand(options?: PrOptions): Promise<void>;
10
- //# sourceMappingURL=pr.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 { 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", {
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();
@@ -113,15 +113,52 @@ export async function prCommand(options = {}) {
113
113
  const branch = getBranch();
114
114
  const { type, ticket, description } = parseBranch(branch);
115
115
  const existingPr = getExistingPr();
116
- if (existingPr && !options.yes) {
117
- console.log(`\n${cyan(`PR #${existingPr.number}`)} already exists: ${existingPr.url}`);
118
- const shouldUpdate = await confirmWithBack({
119
- message: "Update this PR?",
120
- default: true,
121
- showBack: false,
122
- });
123
- if (shouldUpdate !== true) {
124
- process.exit(0);
116
+ let prAction = existingPr?.state === "OPEN" ? "update" : "create";
117
+ if (existingPr) {
118
+ if (existingPr.state === "OPEN" && !options.yes) {
119
+ console.log(`\n${cyan(`PR #${existingPr.number}`)} already exists: ${existingPr.url}`);
120
+ const shouldUpdate = await confirmWithBack({
121
+ message: "Update this PR?",
122
+ default: true,
123
+ showBack: false,
124
+ });
125
+ if (shouldUpdate !== true) {
126
+ process.exit(0);
127
+ }
128
+ }
129
+ else if (existingPr.state === "MERGED") {
130
+ if (!options.yes) {
131
+ console.log(`\n${cyan(`PR #${existingPr.number}`)} is already ${dim("merged")}: ${existingPr.url}`);
132
+ const proceed = await confirmWithBack({
133
+ message: "Create a new PR for this branch?",
134
+ default: true,
135
+ showBack: false,
136
+ });
137
+ if (proceed !== true) {
138
+ process.exit(0);
139
+ }
140
+ }
141
+ // prAction stays "create"
142
+ }
143
+ else if (existingPr.state === "CLOSED") {
144
+ if (!options.yes) {
145
+ console.log(`\n${cyan(`PR #${existingPr.number}`)} is ${dim("closed")}: ${existingPr.url}`);
146
+ const choice = await selectWithBack({
147
+ message: "What would you like to do?",
148
+ choices: [
149
+ { value: "reopen", name: "Reopen and update existing PR" },
150
+ { value: "new", name: "Create a new PR" },
151
+ { value: "cancel", name: "Cancel" },
152
+ ],
153
+ default: "new",
154
+ showBack: false,
155
+ });
156
+ if (choice === BACK_VALUE || choice === "cancel") {
157
+ process.exit(0);
158
+ }
159
+ prAction = choice === "reopen" ? "reopen" : "create";
160
+ }
161
+ // under --yes: prAction stays "create"
125
162
  }
126
163
  }
127
164
  const defaultBase = getDefaultBase(branch);
@@ -237,9 +274,15 @@ export async function prCommand(options = {}) {
237
274
  previewLabels.push(...previewScopes);
238
275
  const uniquePreviewLabels = [...new Set(previewLabels)];
239
276
  console.log(`\n${dim("───")} ${bold("PR Preview")} ${dim("───")}`);
240
- if (existingPr) {
277
+ if (prAction === "update") {
241
278
  console.log(gray(`(Updating existing PR #${existingPr.number})`));
242
279
  }
280
+ else if (prAction === "reopen") {
281
+ console.log(gray(`(Reopening and updating PR #${existingPr.number})`));
282
+ }
283
+ else if (existingPr) {
284
+ console.log(gray(`(Creating new PR; previous PR #${existingPr.number} was ${existingPr.state.toLowerCase()})`));
285
+ }
243
286
  console.log(`${dim("Title:")} ${bold(title)}`);
244
287
  console.log(`${dim("Branch:")} ${cyan(branch)} → ${cyan(base.trim())}`);
245
288
  console.log(`${dim("Labels:")} ${uniquePreviewLabels.length > 0 ? uniquePreviewLabels.join(", ") : "none"}`);
@@ -256,12 +299,16 @@ export async function prCommand(options = {}) {
256
299
  }
257
300
  // Confirm (skip if --yes)
258
301
  if (!options.yes) {
302
+ const confirmMessage = prAction === "update" ? `Update PR #${existingPr.number}?` :
303
+ prAction === "reopen" ? `Reopen and update PR #${existingPr.number}?` :
304
+ "Create this PR?";
305
+ const confirmYesLabel = prAction === "update" ? "Yes, update PR" :
306
+ prAction === "reopen" ? "Yes, reopen and update" :
307
+ "Yes, create PR";
259
308
  const confirmResult = await selectWithBack({
260
- message: existingPr
261
- ? `Update PR #${existingPr.number}?`
262
- : "Create this PR?",
309
+ message: confirmMessage,
263
310
  choices: [
264
- { value: "yes", name: existingPr ? "Yes, update PR" : "Yes, create PR" },
311
+ { value: "yes", name: confirmYesLabel },
265
312
  { value: "no", name: "No, abort" },
266
313
  ],
267
314
  default: "yes",
@@ -278,7 +325,7 @@ export async function prCommand(options = {}) {
278
325
  }
279
326
  // Push branch if needed
280
327
  try {
281
- execSync(`git push -u origin ${branch}`, { stdio: "inherit" });
328
+ execFileSync("git", ["push", "-u", "origin", branch], { stdio: "inherit" });
282
329
  }
283
330
  catch {
284
331
  // Already pushed or push failed
@@ -296,21 +343,29 @@ export async function prCommand(options = {}) {
296
343
  labels.push(scope);
297
344
  }
298
345
  const uniqueLabels = [...new Set(labels)];
299
- const labelFlag = uniqueLabels.length > 0
300
- ? uniqueLabels.map((l) => JSON.stringify(l)).join(",")
301
- : "";
302
- // Reviewers flag
303
- const reviewerFlag = config.prReviewers && config.prReviewers.length > 0
304
- ? ` --reviewer ${config.prReviewers.join(",")}`
305
- : "";
306
- // Draft flag (unless --ready is specified)
307
- const draftFlag = options.ready ? "" : " --draft";
308
- if (existingPr) {
309
- execSync(`gh pr edit ${existingPr.number} --title ${JSON.stringify(title)} --body-file -${labelFlag ? ` --add-label ${labelFlag}` : ""}`, { input: body, stdio: ["pipe", "inherit", "inherit"] });
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
+ if (prAction === "reopen") {
356
+ execFileSync("gh", ["pr", "reopen", String(existingPr.number)], { stdio: "inherit" });
357
+ execFileSync("gh", editArgs(existingPr.number), { input: body, stdio: ["pipe", "inherit", "inherit"] });
358
+ console.log(green(`✓ PR #${existingPr.number} reopened and updated: ${existingPr.url}`));
359
+ }
360
+ else if (prAction === "update") {
361
+ execFileSync("gh", editArgs(existingPr.number), { input: body, stdio: ["pipe", "inherit", "inherit"] });
310
362
  console.log(green(`✓ PR #${existingPr.number} updated: ${existingPr.url}`));
311
363
  }
312
364
  else {
313
- 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"] });
314
369
  console.log(green("✓ PR created successfully."));
315
370
  }
316
371
  // Move linked issue to "In Review" if project integration is enabled
@@ -338,4 +393,3 @@ export async function prCommand(options = {}) {
338
393
  process.exit(1);
339
394
  }
340
395
  }
341
- //# sourceMappingURL=pr.js.map
@@ -5,4 +5,3 @@ export interface ReleaseOptions {
5
5
  yes?: boolean;
6
6
  }
7
7
  export declare function releaseCommand(options?: ReleaseOptions): Promise<void>;
8
- //# sourceMappingURL=release.d.ts.map