@lightupai/polaris 0.0.37 → 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.37",
3
+ "version": "0.0.39",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "polaris": "bin/polaris",
@@ -267,17 +267,22 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
267
267
  try {
268
268
  const res = await daemonGet("/team");
269
269
  if (res.ok) {
270
- const body = await res.json() as { members: Array<{ name: string; participant_id: string | null; slack_id: string | null; slack_handle: string | null; slack_display: string | null; polaris_user: boolean }> };
270
+ const body = await res.json() as { members: Array<{ name: string; participant_id: string | null; slack_id: string | null; slack_handle: string | null; slack_display: string | null; polaris_user: boolean; alias: string | null }> };
271
271
  if (body.members.length === 0) {
272
272
  return { content: [{ type: "text", text: "No team members found." }] };
273
273
  }
274
274
  const taggable = body.members.filter((m) => m.slack_id && m.slack_handle);
275
275
  const list = taggable
276
- .map((m) => ` @${m.slack_handle} — ${m.name}${m.polaris_user ? " ✓" : ""} [${m.slack_id}]`)
276
+ .map((m) => {
277
+ const shortAlias = m.alias && m.alias !== m.slack_handle ? `@${m.alias}` : "";
278
+ const handle = `@${m.slack_handle}`;
279
+ const display = shortAlias ? `${shortAlias} (${handle})` : handle;
280
+ return ` ${display} — ${m.name}${m.polaris_user ? " ✓" : ""} [${m.slack_id}]`;
281
+ })
277
282
  .join("\n");
278
283
  const notTaggable = body.members.filter((m) => !m.slack_id);
279
284
  const note = notTaggable.length > 0 ? `\n\nNot on Slack: ${notTaggable.map(m => m.name).join(", ")}` : "";
280
- return { content: [{ type: "text", text: `Team members (use @handle to tag, ✓ = Polaris user):\n${list}${note}` }] };
285
+ return { content: [{ type: "text", text: `Team (use @alias or @handle to tag, ✓ = Polaris user):\n${list}${note}` }] };
281
286
  }
282
287
  return { content: [{ type: "text", text: "Failed to fetch team list." }] };
283
288
  } catch {
@@ -502,6 +502,48 @@ export async function startServer(opts: {
502
502
  }
503
503
  }
504
504
 
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
+
528
+ const aliasCounts = new Map<string, number>();
529
+ for (const m of team) {
530
+ const alias = deriveAlias(m);
531
+ if (alias) aliasCounts.set(alias, (aliasCounts.get(alias) ?? 0) + 1);
532
+ }
533
+ for (const m of team) {
534
+ const alias = deriveAlias(m);
535
+ if (!alias) {
536
+ (m as Record<string, unknown>).alias = null;
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;
542
+ } else {
543
+ (m as Record<string, unknown>).alias = alias;
544
+ }
545
+ }
546
+
505
547
  return json({ members: team });
506
548
  }
507
549