@lightupai/polaris 0.0.38 → 0.0.39

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightupai/polaris",
3
- "version": "0.0.38",
3
+ "version": "0.0.39",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "polaris": "bin/polaris",
@@ -502,23 +502,45 @@ export async function startServer(opts: {
502
502
  }
503
503
  }
504
504
 
505
- // Generate short aliases from first name, disambiguate collisions
505
+ // Generate short aliases: prefer display_name, fall back to name, then handle
506
+ // Filter out slackbot
507
+ const filtered = team.filter((m) => m.slack_handle !== "slackbot");
508
+ team.length = 0;
509
+ team.push(...filtered);
510
+
511
+ function deriveAlias(m: typeof team[0]): string {
512
+ // Best source: display name (what the person chose)
513
+ const displayName = m.slack_display?.trim();
514
+ if (displayName) {
515
+ const first = displayName.split(/\s+/)[0]?.toLowerCase().replace(/[^a-z]/g, "") || "";
516
+ if (first.length >= 2) return first;
517
+ }
518
+ // Next: real name, but skip short/initial-only first names
519
+ const parts = m.name.split(/\s+/);
520
+ for (const part of parts) {
521
+ const clean = part.toLowerCase().replace(/[^a-z]/g, "");
522
+ if (clean.length >= 2) return clean;
523
+ }
524
+ // Fall back to slack handle
525
+ return m.slack_handle || "";
526
+ }
527
+
506
528
  const aliasCounts = new Map<string, number>();
507
529
  for (const m of team) {
508
- const firstName = m.name.split(/\s+/)[0]?.toLowerCase().replace(/[^a-z]/g, "") || "";
509
- if (firstName) aliasCounts.set(firstName, (aliasCounts.get(firstName) ?? 0) + 1);
530
+ const alias = deriveAlias(m);
531
+ if (alias) aliasCounts.set(alias, (aliasCounts.get(alias) ?? 0) + 1);
510
532
  }
511
533
  for (const m of team) {
512
- const parts = m.name.split(/\s+/);
513
- const firstName = parts[0]?.toLowerCase().replace(/[^a-z]/g, "") || "";
514
- if (!firstName) {
534
+ const alias = deriveAlias(m);
535
+ if (!alias) {
515
536
  (m as Record<string, unknown>).alias = null;
516
- } else if ((aliasCounts.get(firstName) ?? 0) > 1 && parts.length > 1) {
517
- // Collision — append first letter of last name
518
- const lastInitial = parts[parts.length - 1]?.[0]?.toLowerCase() ?? "";
519
- (m as Record<string, unknown>).alias = `${firstName}${lastInitial}`;
537
+ } else if ((aliasCounts.get(alias) ?? 0) > 1) {
538
+ // Collision — append first letter of last name or use handle
539
+ const parts = m.name.split(/\s+/);
540
+ const lastInitial = parts.length > 1 ? parts[parts.length - 1]?.[0]?.toLowerCase() ?? "" : "";
541
+ (m as Record<string, unknown>).alias = lastInitial ? `${alias}${lastInitial}` : m.slack_handle || alias;
520
542
  } else {
521
- (m as Record<string, unknown>).alias = firstName;
543
+ (m as Record<string, unknown>).alias = alias;
522
544
  }
523
545
  }
524
546