@bragduck/cli 2.0.23 → 2.2.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.
@@ -1071,11 +1071,8 @@ var init_api_service = __esm({
1071
1071
  this.client = ofetch2.create({
1072
1072
  baseURL: this.baseURL,
1073
1073
  // Request interceptor
1074
- onRequest: async ({ options }) => {
1075
- const extendedOptions = options;
1076
- logger.debug(
1077
- `API Request: ${options.method} ${extendedOptions.baseURL}${extendedOptions.url}`
1078
- );
1074
+ onRequest: async ({ request, options }) => {
1075
+ logger.debug(`API Request: ${options.method || "GET"} ${request}`);
1079
1076
  const cliVersion = getCliVersion();
1080
1077
  const platform = getPlatformInfo();
1081
1078
  const userAgent = `BragDuck-CLI/${cliVersion} (${platform})`;
@@ -1084,10 +1081,13 @@ var init_api_service = __esm({
1084
1081
  "User-Agent": userAgent
1085
1082
  };
1086
1083
  if (options.headers) {
1087
- const existingHeaders = new Headers(options.headers);
1088
- existingHeaders.forEach((value, key) => {
1089
- newHeaders[key] = value;
1090
- });
1084
+ if (typeof options.headers === "object" && !Array.isArray(options.headers)) {
1085
+ Object.entries(options.headers).forEach(([key, value]) => {
1086
+ if (typeof value === "string") {
1087
+ newHeaders[key] = value;
1088
+ }
1089
+ });
1090
+ }
1091
1091
  }
1092
1092
  if (token) {
1093
1093
  newHeaders.Authorization = `Bearer ${token}`;
@@ -1102,11 +1102,9 @@ var init_api_service = __esm({
1102
1102
  logger.debug(`API Response: ${response.status} ${response.statusText}`);
1103
1103
  },
1104
1104
  // Response interceptor for errors
1105
- onResponseError: async ({ response, options }) => {
1105
+ onResponseError: async ({ request, response }) => {
1106
1106
  const status = response.status;
1107
- const extendedOptions = options;
1108
- const url = `${extendedOptions.baseURL}${extendedOptions.url}`;
1109
- logger.debug(`API Error: ${status} ${response.statusText} - ${url}`);
1107
+ logger.debug(`API Error: ${status} ${response.statusText} - ${request}`);
1110
1108
  if (status === HTTP_STATUS.UNAUTHORIZED) {
1111
1109
  logger.debug("Token expired, attempting refresh");
1112
1110
  try {
@@ -1923,6 +1921,7 @@ ${truncatedBody}` : title;
1923
1921
  authorEmail: "",
1924
1922
  // Not available from gh PR API
1925
1923
  date: pr.mergedAt,
1924
+ url: pr.url,
1926
1925
  diffStats: {
1927
1926
  filesChanged: pr.changedFiles,
1928
1927
  insertions: pr.additions,
@@ -1981,7 +1980,9 @@ var colors = {
1981
1980
  dim: chalk5.dim,
1982
1981
  // Special purpose
1983
1982
  white: chalk5.white,
1984
- gray: chalk5.gray
1983
+ gray: chalk5.gray,
1984
+ // Links and URLs
1985
+ link: chalk5.blue.underline
1985
1986
  };
1986
1987
  var theme = {
1987
1988
  /**
@@ -2301,73 +2302,110 @@ async function promptSortOption() {
2301
2302
  default: "date"
2302
2303
  });
2303
2304
  }
2304
- async function promptReviewBrags(refinedCommits) {
2305
+ async function promptReviewBrags(refinedBrags, selectedCommits) {
2305
2306
  const acceptedBrags = [];
2306
2307
  console.log("\n" + theme.info("Review each brag before creation:") + "\n");
2307
- for (let i = 0; i < refinedCommits.length; i++) {
2308
- const commit = refinedCommits[i];
2308
+ for (let i = 0; i < refinedBrags.length; i++) {
2309
+ let currentBrag = refinedBrags[i];
2309
2310
  const current = i + 1;
2310
- const total = refinedCommits.length;
2311
- const displaySha = commit.sha.startsWith("pr-") ? commit.sha.replace("pr-", "#") : commit.sha.substring(0, 7);
2312
- const bragDetails = `${theme.step(current, total)} ${colors.highlight(displaySha)}
2311
+ const total = refinedBrags.length;
2312
+ let reviewingBrag = true;
2313
+ while (reviewingBrag) {
2314
+ const isNewBragType = !("sha" in currentBrag);
2315
+ let displaySha;
2316
+ let prUrl;
2317
+ if (isNewBragType && selectedCommits) {
2318
+ const commit = selectedCommits[i];
2319
+ displaySha = commit.sha.startsWith("pr-") ? commit.sha.replace("pr-", "#") : commit.sha.substring(0, 7);
2320
+ prUrl = commit.url;
2321
+ } else if (!isNewBragType) {
2322
+ const commit = currentBrag;
2323
+ displaySha = commit.sha.startsWith("pr-") ? commit.sha.replace("pr-", "#") : commit.sha.substring(0, 7);
2324
+ prUrl = commit.commit_url;
2325
+ } else {
2326
+ displaySha = `#${i + 1}`;
2327
+ }
2328
+ const impactScore = isNewBragType ? currentBrag.suggested_impactLevel?.toString() || "N/A" : currentBrag.impact_score?.toString() || "N/A";
2329
+ let bragDetails = `${theme.step(current, total)} ${colors.highlight(displaySha)}
2313
2330
 
2314
- ${theme.label("Title")} ${colors.white(commit.refined_title)}
2331
+ ${theme.label("Title")} ${colors.white(currentBrag.refined_title)}
2315
2332
 
2316
2333
  ${theme.label("Description")}
2317
- ${colors.white(commit.refined_description)}
2334
+ ${colors.white(currentBrag.refined_description)}
2318
2335
 
2319
- ${theme.label("Tags")} ${colors.primary((commit.suggested_tags || []).join(", ") || "none")}
2336
+ ${theme.label("Tags")} ${colors.primary((currentBrag.suggested_tags || []).join(", ") || "none")}
2320
2337
 
2321
- ${theme.label("Impact Score")} ${colors.highlight(commit.impact_score?.toString() || "N/A")}`;
2322
- console.log(boxen4(bragDetails, boxStyles.info));
2323
- console.log("");
2324
- const action = await select({
2325
- message: `What would you like to do with this brag?`,
2326
- choices: [
2327
- { name: "\u2713 Accept", value: "accept", description: "Add this brag as-is" },
2328
- { name: "\u270E Edit title", value: "edit-title", description: "Modify the title" },
2329
- { name: "\u270E Edit description", value: "edit-desc", description: "Modify the description" },
2330
- { name: "\u270E Edit both", value: "edit-both", description: "Modify title and description" },
2331
- { name: "\u2717 Skip", value: "skip", description: "Skip this brag" },
2332
- ...current < total ? [
2338
+ ${theme.label("Impact Score")} ${colors.highlight(impactScore)}`;
2339
+ if (prUrl) {
2340
+ bragDetails += `
2341
+
2342
+ ${theme.label("PR Link")} ${colors.link(prUrl)}`;
2343
+ }
2344
+ console.log(boxen4(bragDetails, boxStyles.info));
2345
+ console.log("");
2346
+ const action = await select({
2347
+ message: `What would you like to do with this brag?`,
2348
+ choices: [
2349
+ { name: "\u2713 Accept", value: "accept", description: "Add this brag as-is" },
2350
+ { name: "\u270E Edit title", value: "edit-title", description: "Modify the title" },
2333
2351
  {
2334
- name: "\u2713 Accept all remaining",
2335
- value: "accept-all",
2336
- description: "Accept this and all remaining brags"
2337
- }
2338
- ] : [],
2339
- { name: "\u2717 Cancel", value: "cancel", description: "Cancel and discard all brags" }
2340
- ]
2341
- });
2342
- if (action === "cancel") {
2343
- return [];
2344
- }
2345
- if (action === "accept-all") {
2346
- acceptedBrags.push(commit);
2347
- for (let j = i + 1; j < refinedCommits.length; j++) {
2348
- acceptedBrags.push(refinedCommits[j]);
2349
- }
2350
- break;
2351
- }
2352
- if (action === "skip") {
2353
- continue;
2354
- }
2355
- let editedCommit = { ...commit };
2356
- if (action === "edit-title" || action === "edit-both") {
2357
- const newTitle = await input({
2358
- message: "Enter new title:",
2359
- default: commit.refined_title
2360
- });
2361
- editedCommit.refined_title = newTitle;
2362
- }
2363
- if (action === "edit-desc" || action === "edit-both") {
2364
- const newDesc = await editor({
2365
- message: "Edit description (will open your default editor):",
2366
- default: commit.refined_description
2352
+ name: "\u270E Edit description",
2353
+ value: "edit-desc",
2354
+ description: "Modify the description"
2355
+ },
2356
+ { name: "\u270E Edit both", value: "edit-both", description: "Modify title and description" },
2357
+ { name: "\u2717 Skip", value: "skip", description: "Skip this brag" },
2358
+ ...current < total ? [
2359
+ {
2360
+ name: "\u2713 Accept all remaining",
2361
+ value: "accept-all",
2362
+ description: "Accept this and all remaining brags"
2363
+ }
2364
+ ] : [],
2365
+ { name: "\u2717 Cancel", value: "cancel", description: "Cancel and discard all brags" }
2366
+ ]
2367
2367
  });
2368
- editedCommit.refined_description = newDesc;
2368
+ if (action === "cancel") {
2369
+ return [];
2370
+ }
2371
+ if (action === "accept-all") {
2372
+ acceptedBrags.push(currentBrag);
2373
+ for (let j = i + 1; j < refinedBrags.length; j++) {
2374
+ acceptedBrags.push(refinedBrags[j]);
2375
+ }
2376
+ reviewingBrag = false;
2377
+ i = refinedBrags.length - 1;
2378
+ break;
2379
+ }
2380
+ if (action === "skip") {
2381
+ reviewingBrag = false;
2382
+ continue;
2383
+ }
2384
+ if (action === "accept") {
2385
+ acceptedBrags.push(currentBrag);
2386
+ reviewingBrag = false;
2387
+ continue;
2388
+ }
2389
+ let editedBrag = { ...currentBrag };
2390
+ if (action === "edit-title" || action === "edit-both") {
2391
+ console.log("");
2392
+ const newTitle = await input({
2393
+ message: "Enter new title:",
2394
+ default: currentBrag.refined_title
2395
+ });
2396
+ editedBrag.refined_title = newTitle;
2397
+ }
2398
+ if (action === "edit-desc" || action === "edit-both") {
2399
+ console.log("");
2400
+ const newDesc = await editor({
2401
+ message: "Edit description (will open your default editor):",
2402
+ default: currentBrag.refined_description
2403
+ });
2404
+ editedBrag.refined_description = newDesc;
2405
+ }
2406
+ currentBrag = editedBrag;
2407
+ console.log("\n" + theme.success("\u2713 Changes saved. Review your edits:") + "\n");
2369
2408
  }
2370
- acceptedBrags.push(editedCommit);
2371
2409
  }
2372
2410
  return acceptedBrags;
2373
2411
  }
@@ -2961,7 +2999,7 @@ var __dirname6 = dirname5(__filename6);
2961
2999
  var packageJsonPath = join7(__dirname6, "../../package.json");
2962
3000
  var packageJson = JSON.parse(readFileSync5(packageJsonPath, "utf-8"));
2963
3001
  var program = new Command();
2964
- program.name("bragduck").description("CLI tool for managing developer achievements and brags").version(packageJson.version, "-v, --version", "Display version number").helpOption("-h, --help", "Display help information").option("--skip-version-check", "Skip automatic version check on startup").option("--debug", "Enable debug mode (shows detailed logs)");
3002
+ program.name("bragduck").description("CLI tool for managing developer achievements and brags\nAliases: bd, duck, brag").version(packageJson.version, "-v, --version", "Display version number").helpOption("-h, --help", "Display help information").option("--skip-version-check", "Skip automatic version check on startup").option("--debug", "Enable debug mode (shows detailed logs)");
2965
3003
  program.command("init").description("Authenticate with Bragduck").action(async () => {
2966
3004
  try {
2967
3005
  await initCommand();