Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; | |
| 3 | ||
| Merge branch 'worktree-agent-a8385d293d42c913a' | 4 | import { G1T_MENTION_HREF, rehypeReferences } from "./markdown-plugins.ts"; |
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 5 | |
| 6 | type Node = { type: string; value?: string; tagName?: string; properties?: Record<string, unknown>; children?: Node[] }; | |
| 7 | ||
| 8 | /** The links a paragraph of `text` gets: each one's href and text. */ | |
| 9 | function links(text: string): [string, string][] { | |
| 10 | const tree: Node = { type: "root", children: [{ type: "element", tagName: "p", properties: {}, children: [{ type: "text", value: text }] }] }; | |
| 11 | rehypeReferences({ repo: { namespace: "acme", name: "web" } })(tree as never); | |
| 12 | return (tree.children![0]!.children ?? []) | |
| 13 | .filter((node) => node.tagName === "a") | |
| 14 | .map((node) => [String(node.properties!.href), node.children![0]!.value!]); | |
| 15 | } | |
| 16 | ||
| 17 | test("@name links to the person or workspace", () => { | |
| 18 | assert.deepEqual(links("thanks @Ana."), [["/ana", "@Ana"]]); | |
| 19 | assert.deepEqual(links("me@example.com"), []); | |
| 20 | }); | |
| 21 | ||
| Merge branch 'worktree-agent-a8385d293d42c913a' | 22 | test("@g1t is g1t's agent, never the workspace alias at /g1t", () => { |
| 23 | assert.deepEqual(links("@g1t fix this, then ask @G1T again"), [ | |
| 24 | [G1T_MENTION_HREF, "@g1t"], | |
| 25 | [G1T_MENTION_HREF, "@G1T"], | |
| 26 | ]); | |
| 27 | assert.ok(!G1T_MENTION_HREF.startsWith("/")); | |
| 28 | // Names that only start with g1t are anyone's. | |
| 29 | assert.deepEqual(links("@g1t-fans"), [["/g1t-fans", "@g1t-fans"]]); | |
| 30 | }); | |
| 31 | ||
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 32 | test("@workspace/team links to the team", () => { |
| 33 | assert.deepEqual(links("cc @acme/backend, @ana"), [ | |
| 34 | ["/acme/-/teams/backend", "@acme/backend"], | |
| 35 | ["/ana", "@ana"], | |
| 36 | ]); | |
| 37 | assert.deepEqual(links("(@Acme/Web-Platform)"), [["/acme/-/teams/web-platform", "@Acme/Web-Platform"]]); | |
| 38 | }); | |
| 39 | ||
| 40 | test("issues and pull requests still link", () => { | |
| 41 | assert.deepEqual(links("see #12 and other/repo#3"), [ | |
| 42 | ["/acme/web/issues/12", "#12"], | |
| 43 | ["/other/repo/issues/3", "other/repo#3"], | |
| 44 | ]); | |
| 45 | }); |
This file's history is long; its oldest lines are credited to the oldest commit read.