@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/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) {
@@ -452,4 +485,3 @@ export function loadConfig(cwd = process.cwd()) {
452
485
  return DEFAULT_CONFIG;
453
486
  }
454
487
  }
455
- //# sourceMappingURL=config.js.map
@@ -3,6 +3,7 @@ interface DevflowVersionInfo {
3
3
  generatedAt: string;
4
4
  files: {
5
5
  aiInstructions?: string;
6
+ claudeSkill?: string;
6
7
  };
7
8
  }
8
9
  export declare function getVersionFilePath(cwd?: string): string;
@@ -15,4 +16,3 @@ export declare function getCliVersion(): string;
15
16
  */
16
17
  export declare function checkForDevflowUpdates(cwd?: string): boolean;
17
18
  export {};
18
- //# sourceMappingURL=devflow-version.d.ts.map
@@ -24,6 +24,7 @@ export function writeVersionInfo(cliVersion, cwd = process.cwd()) {
24
24
  generatedAt: new Date().toISOString(),
25
25
  files: {
26
26
  aiInstructions: cliVersion,
27
+ claudeSkill: cliVersion,
27
28
  },
28
29
  };
29
30
  writeFileSync(versionPath, JSON.stringify(info, null, 2) + "\n");
@@ -84,4 +85,3 @@ function compareVersions(a, b) {
84
85
  }
85
86
  return 0;
86
87
  }
87
- //# sourceMappingURL=devflow-version.js.map
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;
@@ -10,7 +19,8 @@ export declare function inferScope(): string | undefined;
10
19
  export declare function getCommits(base: string): string[];
11
20
  export declare function getScopesFromCommits(commits: string[]): string[];
12
21
  export declare function getDefaultBase(currentBranch: string): string;
22
+ export declare function getRepoDefaultBranch(): string;
23
+ export declare function isGhInstalled(): boolean;
13
24
  export declare function checkGhInstalled(): void;
14
25
  export declare function isProtectedBranch(branch?: string): boolean;
15
26
  export {};
16
- //# sourceMappingURL=git.d.ts.map
package/dist/git.js CHANGED
@@ -1,7 +1,44 @@
1
- import { execSync } from "child_process";
1
+ import { execFileSync } from "child_process";
2
2
  const PROTECTED_BRANCHES = ["main", "master", "develop", "production"];
3
+ /** Refs read from git can still be named like options (a tag "--output=x"); never pass those as arguments. */
4
+ export function isOptionLike(ref) {
5
+ return ref.startsWith("-");
6
+ }
7
+ /**
8
+ * The commit a user- or config-provided revision (a PR base, a tag) names, as an object id, so it can
9
+ * be put in a range without git reading it as an option. undefined when it names no commit.
10
+ */
11
+ export function resolveCommit(rev) {
12
+ if (!rev || isOptionLike(rev))
13
+ return undefined;
14
+ try {
15
+ // No --end-of-options (older gits lack it for rev-parse): a leading "-" is refused above, and the
16
+ // ^{commit} suffix keeps the argument a revision.
17
+ return execFileSync("git", ["rev-parse", "--verify", "--quiet", `${rev}^{commit}`], {
18
+ encoding: "utf-8",
19
+ stdio: ["ignore", "pipe", "ignore"],
20
+ }).trim() || undefined;
21
+ }
22
+ catch {
23
+ return undefined;
24
+ }
25
+ }
26
+ /** Throws unless `name` is a valid branch name that git cannot read as an option. */
27
+ export function assertBranchName(name) {
28
+ let valid = !isOptionLike(name);
29
+ if (valid) {
30
+ try {
31
+ execFileSync("git", ["check-ref-format", "--branch", name], { stdio: "ignore" });
32
+ }
33
+ catch {
34
+ valid = false;
35
+ }
36
+ }
37
+ if (!valid)
38
+ throw new Error(`Invalid branch name: ${JSON.stringify(name)}. Check the ticket, type and branchFormat.`);
39
+ }
3
40
  export function getBranch() {
4
- return execSync("git branch --show-current", { encoding: "utf-8" }).trim();
41
+ return execFileSync("git", ["branch", "--show-current"], { encoding: "utf-8" }).trim();
5
42
  }
6
43
  export function parseBranch(branch, format) {
7
44
  // Default format for backwards compatibility
@@ -51,7 +88,7 @@ export function inferTicket(format) {
51
88
  }
52
89
  export function inferScope() {
53
90
  try {
54
- const log = execSync("git log main..HEAD --format=%s", {
91
+ const log = execFileSync("git", ["log", "main..HEAD", "--format=%s"], {
55
92
  encoding: "utf-8",
56
93
  }).trim();
57
94
  if (!log)
@@ -69,8 +106,11 @@ export function inferScope() {
69
106
  return undefined;
70
107
  }
71
108
  export function getCommits(base) {
109
+ const baseId = resolveCommit(base);
110
+ if (!baseId)
111
+ return [];
72
112
  try {
73
- const log = execSync(`git log ${base}..HEAD --format=%s`, { encoding: "utf-8" }).trim();
113
+ const log = execFileSync("git", ["log", `${baseId}..HEAD`, "--format=%s"], { encoding: "utf-8" }).trim();
74
114
  return log ? log.split("\n") : [];
75
115
  }
76
116
  catch {
@@ -88,19 +128,19 @@ export function getScopesFromCommits(commits) {
88
128
  }
89
129
  export function getDefaultBase(currentBranch) {
90
130
  try {
91
- const remoteBranches = execSync("git branch -r", { encoding: "utf-8" })
131
+ const remoteBranches = execFileSync("git", ["branch", "-r"], { encoding: "utf-8" })
92
132
  .trim()
93
133
  .split("\n")
94
134
  .map((b) => b.trim())
95
- .filter((b) => b && !b.includes("HEAD") && !b.endsWith(`/${currentBranch}`));
135
+ .filter((b) => b && !b.includes("HEAD") && !b.endsWith(`/${currentBranch}`) && !isOptionLike(b.replace(/^origin\//, "")));
96
136
  let closest = "main";
97
137
  let minAhead = Infinity;
98
138
  for (const remote of remoteBranches) {
99
139
  try {
100
- const mergeBase = execSync(`git merge-base HEAD ${remote}`, {
140
+ const mergeBase = execFileSync("git", ["merge-base", "HEAD", remote], {
101
141
  encoding: "utf-8",
102
142
  }).trim();
103
- const ahead = execSync(`git rev-list --count ${mergeBase}..HEAD`, {
143
+ const ahead = execFileSync("git", ["rev-list", "--count", `${mergeBase}..HEAD`], {
104
144
  encoding: "utf-8",
105
145
  }).trim();
106
146
  const count = parseInt(ahead, 10);
@@ -119,9 +159,42 @@ export function getDefaultBase(currentBranch) {
119
159
  return "main";
120
160
  }
121
161
  }
162
+ export function getRepoDefaultBranch() {
163
+ try {
164
+ const ref = execFileSync("git", ["symbolic-ref", "refs/remotes/origin/HEAD"], {
165
+ encoding: "utf-8",
166
+ stdio: ["pipe", "pipe", "ignore"],
167
+ }).trim();
168
+ const name = ref.replace(/^refs\/remotes\/origin\//, "");
169
+ if (isOptionLike(name))
170
+ throw new Error("option-like default branch");
171
+ return name;
172
+ }
173
+ catch {
174
+ for (const candidate of ["main", "master", "trunk", "develop"]) {
175
+ try {
176
+ execFileSync("git", ["rev-parse", "--verify", candidate], { stdio: "ignore" });
177
+ return candidate;
178
+ }
179
+ catch {
180
+ // try next
181
+ }
182
+ }
183
+ return "main";
184
+ }
185
+ }
186
+ export function isGhInstalled() {
187
+ try {
188
+ execFileSync("gh", ["--version"], { stdio: "ignore" });
189
+ return true;
190
+ }
191
+ catch {
192
+ return false;
193
+ }
194
+ }
122
195
  export function checkGhInstalled() {
123
196
  try {
124
- execSync("gh --version", { stdio: "ignore" });
197
+ execFileSync("gh", ["--version"], { stdio: "ignore" });
125
198
  }
126
199
  catch {
127
200
  console.error("Error: GitHub CLI (gh) is not installed.");
@@ -134,4 +207,3 @@ export function isProtectedBranch(branch) {
134
207
  const current = branch || getBranch();
135
208
  return PROTECTED_BRANCHES.includes(current);
136
209
  }
137
- //# sourceMappingURL=git.js.map
package/dist/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env node
2
2
  export {};
3
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -28,6 +28,7 @@ import { updateCommand } from "./commands/update.js";
28
28
  import { loadPlugins } from "./plugins.js";
29
29
  import { checkForUpdates } from "./update-notifier.js";
30
30
  import { checkForDevflowUpdates } from "./devflow-version.js";
31
+ import { runCommand } from "./cli-runner.js";
31
32
  const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
32
33
  // Check for updates (non-blocking, cached)
33
34
  checkForUpdates();
@@ -53,7 +54,7 @@ program
53
54
  .option("-d, --description <desc>", "Branch description")
54
55
  .option("--test-plan <steps>", "Pipe-separated test plan steps")
55
56
  .option("--yes", "Skip confirmation prompts")
56
- .action((opts) => branchCommand(opts));
57
+ .action((opts) => runCommand(() => branchCommand(opts)));
57
58
  program
58
59
  .command("commit")
59
60
  .alias("c")
@@ -68,7 +69,7 @@ program
68
69
  .option("--all", "Stage all changes")
69
70
  .option("--files <files>", "Comma-separated files to stage")
70
71
  .option("--yes", "Skip confirmation prompts")
71
- .action((opts) => commitCommand(opts));
72
+ .action((opts) => runCommand(() => commitCommand(opts)));
72
73
  program
73
74
  .command("pr")
74
75
  .alias("p")
@@ -79,7 +80,7 @@ program
79
80
  .option("--base <branch>", "Base branch")
80
81
  .option("--yes", "Skip confirmation prompts")
81
82
  .option("--ready", "Create as ready (not draft)")
82
- .action((opts) => prCommand(opts));
83
+ .action((opts) => runCommand(() => prCommand(opts)));
83
84
  program
84
85
  .command("amend")
85
86
  .alias("a")
@@ -90,14 +91,14 @@ program
90
91
  .option("-m, --message <message>", "New commit message")
91
92
  .option("--breaking", "Mark as breaking change")
92
93
  .option("--yes", "Skip confirmation prompts")
93
- .action((opts) => amendCommand(opts));
94
+ .action((opts) => runCommand(() => amendCommand(opts)));
94
95
  program
95
96
  .command("undo")
96
97
  .alias("u")
97
98
  .description("Undo the last commit (keeps changes staged)")
98
99
  .option("--dry-run", "Preview without executing git commands")
99
100
  .option("--yes", "Skip confirmation prompt")
100
- .action((opts) => undoCommand(opts));
101
+ .action((opts) => runCommand(() => undoCommand(opts)));
101
102
  program
102
103
  .command("fixup")
103
104
  .alias("f")
@@ -108,7 +109,7 @@ program
108
109
  .option("--files <files>", "Comma-separated files to stage")
109
110
  .option("--auto-squash", "Auto-rebase with --autosquash")
110
111
  .option("--yes", "Skip confirmation prompts")
111
- .action((opts) => fixupCommand(opts));
112
+ .action((opts) => runCommand(() => fixupCommand(opts)));
112
113
  program
113
114
  .command("merge")
114
115
  .alias("m")
@@ -116,15 +117,16 @@ program
116
117
  .option("--dry-run", "Preview without executing git commands")
117
118
  .option("--method <method>", "Merge method: squash, merge, or rebase")
118
119
  .option("--yes", "Skip confirmation prompts")
119
- .action((opts) => mergeCommand(opts));
120
+ .action((opts) => runCommand(() => mergeCommand(opts)));
120
121
  program
121
122
  .command("release")
122
123
  .alias("rel")
123
124
  .description("Create a release with version bump, changelog, tag, and GitHub release")
125
+ .option("--dry-run", "Preview without releasing")
124
126
  .option("--bump <type>", "Version bump type: patch, minor, or major")
125
127
  .option("--version <version>", "Explicit version number")
126
128
  .option("--yes", "Skip confirmation prompts")
127
- .action((opts) => releaseCommand(opts));
129
+ .action((opts) => runCommand(() => releaseCommand(opts)));
128
130
  program
129
131
  .command("review")
130
132
  .alias("rv")
@@ -132,7 +134,7 @@ program
132
134
  .option("--pr <number>", "PR number to review")
133
135
  .option("--action <action>", "Action: checkout, approve, comment, request-changes, view")
134
136
  .option("--comment <text>", "Comment text (for comment/request-changes)")
135
- .action((opts) => reviewCommand(opts));
137
+ .action((opts) => runCommand(() => reviewCommand(opts)));
136
138
  program
137
139
  .command("comments")
138
140
  .alias("cm")
@@ -140,7 +142,7 @@ program
140
142
  .option("--number <number>", "PR number (defaults to current branch PR)")
141
143
  .option("--resolved", "Show only resolved comments")
142
144
  .option("--unresolved", "Show only unresolved comments")
143
- .action((opts) => commentsCommand(opts));
145
+ .action((opts) => runCommand(() => commentsCommand(opts)));
144
146
  program
145
147
  .command("issue")
146
148
  .alias("i")
@@ -153,7 +155,7 @@ program
153
155
  .option("--create-branch", "Auto-create branch after issue creation")
154
156
  .option("--branch-desc <desc>", "Branch description (for --create-branch)")
155
157
  .option("--yes", "Skip confirmation prompts")
156
- .action((opts) => issueCommand(opts));
158
+ .action((opts) => runCommand(() => issueCommand(opts)));
157
159
  program
158
160
  .command("issues")
159
161
  .alias("is")
@@ -165,37 +167,39 @@ program
165
167
  .option("--branch-desc <desc>", "Branch description (with --work)")
166
168
  .option("--dry-run", "Preview without making changes")
167
169
  .option("--yes", "Skip confirmation prompts")
168
- .action((opts) => issuesCommand(opts));
170
+ .action((opts) => runCommand(() => issuesCommand(opts)));
169
171
  program
170
172
  .command("stash")
171
173
  .alias("st")
172
174
  .description("Save, pop, apply, or drop named stashes")
175
+ .option("--dry-run", "Preview without modifying stashes")
173
176
  .option("--action <action>", "Action: save, pop, apply, drop, show")
174
177
  .option("--message <msg>", "Stash message (for save)")
175
178
  .option("--index <n>", "Stash index (for pop/apply/drop/show)")
176
179
  .option("--include-untracked", "Include untracked files (for save)")
177
180
  .option("--yes", "Skip confirmation prompts")
178
- .action((opts) => stashCommand(opts));
181
+ .action((opts) => runCommand(() => stashCommand(opts)));
179
182
  program
180
183
  .command("worktree")
181
184
  .alias("wt")
182
185
  .description("Manage git worktrees for parallel branch work")
186
+ .option("--dry-run", "Preview without modifying worktrees")
183
187
  .option("--action <action>", "Action: add, remove, list")
184
188
  .option("--branch <branch>", "Branch name (for add)")
185
189
  .option("--path <path>", "Directory path (for add)")
186
190
  .option("--yes", "Skip confirmation prompts")
187
- .action((opts) => worktreeCommand(opts));
191
+ .action((opts) => runCommand(() => worktreeCommand(opts)));
188
192
  program
189
193
  .command("log")
190
194
  .alias("l")
191
195
  .description("Interactive commit log with cherry-pick, revert, and fixup actions")
192
- .action(logCommand);
196
+ .action(() => runCommand(() => logCommand()));
193
197
  // --- Info commands ---
194
198
  program
195
199
  .command("status")
196
200
  .alias("s")
197
201
  .description("Show current branch, ticket, commits, and PR info")
198
- .action(statusCommand);
202
+ .action(() => runCommand(() => statusCommand()));
199
203
  program
200
204
  .command("test-plan")
201
205
  .alias("tp")
@@ -204,14 +208,14 @@ program
204
208
  .option("--replace <steps>", "Replace all steps with these (pipe-separated)")
205
209
  .option("--clear", "Clear all steps")
206
210
  .option("--show", "Show current steps (default if no other flags)")
207
- .action((opts) => testPlanCommand(opts));
211
+ .action((opts) => runCommand(() => testPlanCommand(opts)));
208
212
  program
209
213
  .command("changelog")
210
214
  .description("Generate a changelog from conventional commits since last tag")
211
215
  .option("--dry-run", "Preview without writing to file")
212
216
  .option("--version <version>", "Version number for the changelog")
213
217
  .option("--yes", "Skip confirmation prompt")
214
- .action((opts) => changelogCommand(opts));
218
+ .action((opts) => runCommand(() => changelogCommand(opts)));
215
219
  program
216
220
  .command("cleanup")
217
221
  .description("Delete local branches that have been merged or whose remote is gone")
@@ -220,32 +224,32 @@ program
220
224
  .option("--branches <list>", "Comma-separated branch names to delete")
221
225
  .option("--force", "Force delete unmerged branches")
222
226
  .option("--yes", "Skip confirmation prompts")
223
- .action((opts) => cleanupCommand(opts));
227
+ .action((opts) => runCommand(() => cleanupCommand(opts)));
224
228
  program
225
229
  .command("stats")
226
230
  .description("Show commit type distribution, top scopes, and contributor stats")
227
- .action(statsCommand);
231
+ .action(() => runCommand(() => statsCommand()));
228
232
  program
229
233
  .command("lint-config")
230
234
  .alias("lint")
231
235
  .description("Validate devflow config for errors and warnings (CI-friendly)")
232
- .action(lintConfigCommand);
236
+ .action(() => runCommand(() => lintConfigCommand()));
233
237
  // --- Setup commands ---
234
238
  program
235
239
  .command("init")
236
240
  .description("Initialize devflow config and project setup")
237
- .action(initCommand);
241
+ .action(() => runCommand(() => initCommand()));
238
242
  program
239
243
  .command("doctor")
240
244
  .description("Check that all devflow dependencies are properly configured")
241
- .action(doctorCommand);
245
+ .action(() => runCommand(() => doctorCommand()));
242
246
  program
243
247
  .command("update")
244
248
  .alias("up")
245
249
  .description("Update AI instructions and other devflow files to latest version")
246
250
  .option("--dry-run", "Preview without writing files")
247
251
  .option("--yes", "Skip confirmation prompts")
248
- .action((opts) => updateCommand(opts));
252
+ .action((opts) => runCommand(() => updateCommand(opts)));
249
253
  program
250
254
  .command("completions")
251
255
  .description("Output shell completion script")
@@ -258,8 +262,10 @@ program
258
262
  console.log(generateZshCompletions());
259
263
  }
260
264
  });
261
- // Load plugins before parsing
262
- await loadPlugins(program);
265
+ // Load plugins before parsing. Completions output is eval'd by shells: never prompt or load there.
266
+ if (args[0] !== "completions") {
267
+ await loadPlugins(program);
268
+ }
263
269
  program.parse();
264
270
  function generateBashCompletions() {
265
271
  return `# devflow bash completions
@@ -331,4 +337,3 @@ _devflow() {
331
337
  }
332
338
  compdef _devflow devflow`;
333
339
  }
334
- //# sourceMappingURL=index.js.map
@@ -10,4 +10,3 @@ interface WorkspacePackage {
10
10
  export declare function detectMonorepo(cwd?: string): WorkspaceInfo | undefined;
11
11
  export declare function workspacesToScopes(info: WorkspaceInfo): Scope[];
12
12
  export {};
13
- //# sourceMappingURL=monorepo.d.ts.map
package/dist/monorepo.js CHANGED
@@ -188,4 +188,3 @@ export function workspacesToScopes(info) {
188
188
  };
189
189
  });
190
190
  }
191
- //# sourceMappingURL=monorepo.js.map
@@ -0,0 +1,3 @@
1
+ export declare function failWith(message: string, hint?: string): never;
2
+ export declare function printHeader(title: string): void;
3
+ export declare function printFooter(): void;
package/dist/output.js ADDED
@@ -0,0 +1,13 @@
1
+ import { red, bold, dim } from "./colors.js";
2
+ export function failWith(message, hint) {
3
+ console.error(`${red("✗")} ${bold(message)}`);
4
+ if (hint)
5
+ console.error(dim(` ${hint}`));
6
+ process.exit(1);
7
+ }
8
+ export function printHeader(title) {
9
+ console.log(`\n${dim("───")} ${bold(title)} ${dim("───")}\n`);
10
+ }
11
+ export function printFooter() {
12
+ console.log(dim("─────────────────────"));
13
+ }
package/dist/plugins.d.ts CHANGED
@@ -1,3 +1,10 @@
1
1
  import { Command } from "commander";
2
+ /** Records the user's decision for this checkout and what these plugins resolve to now, outside the repo. */
3
+ export declare function setPluginTrust(cwd: string, plugins: string[], trusted: boolean): void;
4
+ /**
5
+ * Loads plugins named by the repo's package.json and .devflow/config.json. Both files come from the
6
+ * checked-out repo, so nothing is imported until the user has trusted this checkout and exactly what
7
+ * the plugins resolve to. The decision is asked once, interactively; non-interactive runs never trust
8
+ * on their own. A plugin whose package or entry file leaves the repo's node_modules is never loaded.
9
+ */
2
10
  export declare function loadPlugins(program: Command, cwd?: string): Promise<void>;
3
- //# sourceMappingURL=plugins.d.ts.map