@bragduck/cli 2.1.0 → 2.2.1

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.
@@ -1166,11 +1166,19 @@ var init_api_service = __esm({
1166
1166
  * Refine brags using AI
1167
1167
  */
1168
1168
  async refineBrags(request) {
1169
- logger.debug(`Refining ${request.brags.length} brags`);
1169
+ const MAX_TEXT_LENGTH = 1e4;
1170
+ const trimmedRequest = {
1171
+ ...request,
1172
+ brags: request.brags.map((brag) => ({
1173
+ ...brag,
1174
+ text: brag.text && brag.text.length > MAX_TEXT_LENGTH ? brag.text.substring(0, MAX_TEXT_LENGTH) : brag.text
1175
+ }))
1176
+ };
1177
+ logger.debug(`Refining ${trimmedRequest.brags.length} brags`);
1170
1178
  try {
1171
1179
  const response = await this.makeRequest(API_ENDPOINTS.BRAGS.REFINE, {
1172
1180
  method: "POST",
1173
- body: request
1181
+ body: trimmedRequest
1174
1182
  });
1175
1183
  logger.debug(`Successfully refined ${response.refined_brags.length} brags`);
1176
1184
  return response;
@@ -1921,6 +1929,7 @@ ${truncatedBody}` : title;
1921
1929
  authorEmail: "",
1922
1930
  // Not available from gh PR API
1923
1931
  date: pr.mergedAt,
1932
+ url: pr.url,
1924
1933
  diffStats: {
1925
1934
  filesChanged: pr.changedFiles,
1926
1935
  insertions: pr.additions,
@@ -1979,7 +1988,9 @@ var colors = {
1979
1988
  dim: chalk5.dim,
1980
1989
  // Special purpose
1981
1990
  white: chalk5.white,
1982
- gray: chalk5.gray
1991
+ gray: chalk5.gray,
1992
+ // Links and URLs
1993
+ link: chalk5.blue.underline
1983
1994
  };
1984
1995
  var theme = {
1985
1996
  /**
@@ -2158,12 +2169,12 @@ function formatRefinedCommitsTable(brags, selectedCommits) {
2158
2169
  });
2159
2170
  brags.forEach((brag, index) => {
2160
2171
  const isNewBragType = !("sha" in brag);
2161
- let displaySha;
2172
+ let displaySha = `#${index + 1}`;
2162
2173
  if (isNewBragType && selectedCommits) {
2163
2174
  const commit = selectedCommits[index];
2164
- if (commit.sha.startsWith("pr-")) {
2175
+ if (commit && commit.sha.startsWith("pr-")) {
2165
2176
  displaySha = commit.sha.replace("pr-", "#");
2166
- } else {
2177
+ } else if (commit) {
2167
2178
  displaySha = commit.sha.substring(0, 7);
2168
2179
  }
2169
2180
  } else if (!isNewBragType) {
@@ -2303,80 +2314,108 @@ async function promptReviewBrags(refinedBrags, selectedCommits) {
2303
2314
  const acceptedBrags = [];
2304
2315
  console.log("\n" + theme.info("Review each brag before creation:") + "\n");
2305
2316
  for (let i = 0; i < refinedBrags.length; i++) {
2306
- const brag = refinedBrags[i];
2317
+ let currentBrag = refinedBrags[i];
2307
2318
  const current = i + 1;
2308
2319
  const total = refinedBrags.length;
2309
- const isNewBragType = !("sha" in brag);
2310
- let displaySha;
2311
- if (isNewBragType && selectedCommits) {
2312
- const commit = selectedCommits[i];
2313
- displaySha = commit.sha.startsWith("pr-") ? commit.sha.replace("pr-", "#") : commit.sha.substring(0, 7);
2314
- } else if (!isNewBragType) {
2315
- const commit = brag;
2316
- displaySha = commit.sha.startsWith("pr-") ? commit.sha.replace("pr-", "#") : commit.sha.substring(0, 7);
2317
- } else {
2318
- displaySha = `#${i + 1}`;
2319
- }
2320
- const impactScore = isNewBragType ? brag.suggested_impactLevel?.toString() || "N/A" : brag.impact_score?.toString() || "N/A";
2321
- const bragDetails = `${theme.step(current, total)} ${colors.highlight(displaySha)}
2320
+ let reviewingBrag = true;
2321
+ while (reviewingBrag) {
2322
+ const isNewBragType = !("sha" in currentBrag);
2323
+ let displaySha = `#${i + 1}`;
2324
+ let prUrl;
2325
+ if (isNewBragType && selectedCommits) {
2326
+ const commit = selectedCommits[i];
2327
+ if (commit) {
2328
+ displaySha = commit.sha.startsWith("pr-") ? commit.sha.replace("pr-", "#") : commit.sha.substring(0, 7);
2329
+ prUrl = commit.url;
2330
+ }
2331
+ } else if (!isNewBragType) {
2332
+ const commit = currentBrag;
2333
+ displaySha = commit.sha.startsWith("pr-") ? commit.sha.replace("pr-", "#") : commit.sha.substring(0, 7);
2334
+ prUrl = commit.commit_url;
2335
+ } else {
2336
+ displaySha = `#${i + 1}`;
2337
+ }
2338
+ const impactScore = isNewBragType ? currentBrag.suggested_impactLevel?.toString() || "N/A" : currentBrag.impact_score?.toString() || "N/A";
2339
+ let bragDetails = `${theme.step(current, total)} ${colors.highlight(displaySha)}
2322
2340
 
2323
- ${theme.label("Title")} ${colors.white(brag.refined_title)}
2341
+ ${theme.label("Title")} ${colors.white(currentBrag.refined_title)}
2324
2342
 
2325
2343
  ${theme.label("Description")}
2326
- ${colors.white(brag.refined_description)}
2344
+ ${colors.white(currentBrag.refined_description)}
2327
2345
 
2328
- ${theme.label("Tags")} ${colors.primary((brag.suggested_tags || []).join(", ") || "none")}
2346
+ ${theme.label("Tags")} ${colors.primary((currentBrag.suggested_tags || []).join(", ") || "none")}
2329
2347
 
2330
2348
  ${theme.label("Impact Score")} ${colors.highlight(impactScore)}`;
2331
- console.log(boxen4(bragDetails, boxStyles.info));
2332
- console.log("");
2333
- const action = await select({
2334
- message: `What would you like to do with this brag?`,
2335
- choices: [
2336
- { name: "\u2713 Accept", value: "accept", description: "Add this brag as-is" },
2337
- { name: "\u270E Edit title", value: "edit-title", description: "Modify the title" },
2338
- { name: "\u270E Edit description", value: "edit-desc", description: "Modify the description" },
2339
- { name: "\u270E Edit both", value: "edit-both", description: "Modify title and description" },
2340
- { name: "\u2717 Skip", value: "skip", description: "Skip this brag" },
2341
- ...current < total ? [
2349
+ if (prUrl) {
2350
+ bragDetails += `
2351
+
2352
+ ${theme.label("PR Link")} ${colors.link(prUrl)}`;
2353
+ }
2354
+ console.log(boxen4(bragDetails, boxStyles.info));
2355
+ console.log("");
2356
+ const action = await select({
2357
+ message: `What would you like to do with this brag?`,
2358
+ choices: [
2359
+ { name: "\u2713 Accept", value: "accept", description: "Add this brag as-is" },
2360
+ { name: "\u270E Edit title", value: "edit-title", description: "Modify the title" },
2342
2361
  {
2343
- name: "\u2713 Accept all remaining",
2344
- value: "accept-all",
2345
- description: "Accept this and all remaining brags"
2346
- }
2347
- ] : [],
2348
- { name: "\u2717 Cancel", value: "cancel", description: "Cancel and discard all brags" }
2349
- ]
2350
- });
2351
- if (action === "cancel") {
2352
- return [];
2353
- }
2354
- if (action === "accept-all") {
2355
- acceptedBrags.push(brag);
2356
- for (let j = i + 1; j < refinedBrags.length; j++) {
2357
- acceptedBrags.push(refinedBrags[j]);
2358
- }
2359
- break;
2360
- }
2361
- if (action === "skip") {
2362
- continue;
2363
- }
2364
- let editedBrag = { ...brag };
2365
- if (action === "edit-title" || action === "edit-both") {
2366
- const newTitle = await input({
2367
- message: "Enter new title:",
2368
- default: brag.refined_title
2369
- });
2370
- editedBrag.refined_title = newTitle;
2371
- }
2372
- if (action === "edit-desc" || action === "edit-both") {
2373
- const newDesc = await editor({
2374
- message: "Edit description (will open your default editor):",
2375
- default: brag.refined_description
2362
+ name: "\u270E Edit description",
2363
+ value: "edit-desc",
2364
+ description: "Modify the description"
2365
+ },
2366
+ { name: "\u270E Edit both", value: "edit-both", description: "Modify title and description" },
2367
+ { name: "\u2717 Skip", value: "skip", description: "Skip this brag" },
2368
+ ...current < total ? [
2369
+ {
2370
+ name: "\u2713 Accept all remaining",
2371
+ value: "accept-all",
2372
+ description: "Accept this and all remaining brags"
2373
+ }
2374
+ ] : [],
2375
+ { name: "\u2717 Cancel", value: "cancel", description: "Cancel and discard all brags" }
2376
+ ]
2376
2377
  });
2377
- editedBrag.refined_description = newDesc;
2378
+ if (action === "cancel") {
2379
+ return [];
2380
+ }
2381
+ if (action === "accept-all") {
2382
+ acceptedBrags.push(currentBrag);
2383
+ for (let j = i + 1; j < refinedBrags.length; j++) {
2384
+ acceptedBrags.push(refinedBrags[j]);
2385
+ }
2386
+ reviewingBrag = false;
2387
+ i = refinedBrags.length - 1;
2388
+ break;
2389
+ }
2390
+ if (action === "skip") {
2391
+ reviewingBrag = false;
2392
+ continue;
2393
+ }
2394
+ if (action === "accept") {
2395
+ acceptedBrags.push(currentBrag);
2396
+ reviewingBrag = false;
2397
+ continue;
2398
+ }
2399
+ let editedBrag = { ...currentBrag };
2400
+ if (action === "edit-title" || action === "edit-both") {
2401
+ console.log("");
2402
+ const newTitle = await input({
2403
+ message: "Enter new title:",
2404
+ default: currentBrag.refined_title
2405
+ });
2406
+ editedBrag.refined_title = newTitle;
2407
+ }
2408
+ if (action === "edit-desc" || action === "edit-both") {
2409
+ console.log("");
2410
+ const newDesc = await editor({
2411
+ message: "Edit description (will open your default editor):",
2412
+ default: currentBrag.refined_description
2413
+ });
2414
+ editedBrag.refined_description = newDesc;
2415
+ }
2416
+ currentBrag = editedBrag;
2417
+ console.log("\n" + theme.success("\u2713 Changes saved. Review your edits:") + "\n");
2378
2418
  }
2379
- acceptedBrags.push(editedBrag);
2380
2419
  }
2381
2420
  return acceptedBrags;
2382
2421
  }
@@ -2970,7 +3009,7 @@ var __dirname6 = dirname5(__filename6);
2970
3009
  var packageJsonPath = join7(__dirname6, "../../package.json");
2971
3010
  var packageJson = JSON.parse(readFileSync5(packageJsonPath, "utf-8"));
2972
3011
  var program = new Command();
2973
- 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)");
3012
+ 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)");
2974
3013
  program.command("init").description("Authenticate with Bragduck").action(async () => {
2975
3014
  try {
2976
3015
  await initCommand();