The best way to control Claude Code, Codex and more from any computer or phone

main
ts 87 lines 3.27 KB
Raw
1 import { describe, expect, it } from "vite-plus/test";
2 import { removeAgentCredits } from "./mergeMessage.ts";
3
4 describe("removeAgentCredits", () => {
5 it("removes recognized agent trailers and generated footers, keeping human co-authors", () => {
6 expect(
7 removeAgentCredits(
8 [
9 "Details about Claude support.",
10 "",
11 "",
12 "Co-authored-by: Alice <alice@example.com>",
13 "Co-authored-by: Claude <noreply@anthropic.com>",
14 "* Co-authored-by: Codex <noreply@openai.com>",
15 "co-authored-by: Cursor <cursoragent@cursor.com>",
16 "Co-authored-by: Copilot <copilot@github.com>",
17 "Co-Authored-By:\tGitHub Copilot <NOREPLY@GITHUB.COM>",
18 "",
19 "🤖 Generated with [Claude Code](https://claude.ai/code)",
20 ].join("\n"),
21 ),
22 ).toBe("Details about Claude support.\n\n\nCo-authored-by: Alice <alice@example.com>");
23 });
24
25 it("removes the footer Claude Code writes today, which links to claude.com", () => {
26 expect(
27 removeAgentCredits(
28 [
29 "Details",
30 "",
31 "🤖 Generated with [Claude Code](https://claude.com/claude-code)",
32 "",
33 "Co-Authored-By: Claude <noreply@anthropic.com>",
34 ].join("\n"),
35 ),
36 ).toBe("Details");
37 });
38
39 it("preserves unknown identities, humans named after agents, and ordinary prose", () => {
40 const message = [
41 "Co-authored-by: Claude <claude@example.com>",
42 "Co-authored-by: Alice <noreply@github.com>",
43 "Co-authored-by: Release Bot <release@example.com>",
44 "Generated by our new Claude integration.",
45 "Generated with [Claude Code](https://example.com)",
46 "",
47 ].join("\n");
48 expect(removeAgentCredits(message)).toBe(message);
49 });
50
51 it("preserves code fences and block quotes containing attribution examples", () => {
52 const example = "Co-authored-by: Claude <noreply@anthropic.com>";
53 const message = `Example:\n\n\`\`\`text\n${example}\n\`\`\`\n\n> ${example}\n\n${example}`;
54 expect(removeAgentCredits(message)).toBe(
55 `Example:\n\n\`\`\`text\n${example}\n\`\`\`\n\n> ${example}`,
56 );
57 });
58
59 it.each(["``` text ```", " ```", "\t~~~"])(
60 "removes trailers after a line that cannot open a fence: %s",
61 (line) => {
62 expect(removeAgentCredits(`${line}\n\nCo-authored-by: Claude <noreply@anthropic.com>`)).toBe(
63 line,
64 );
65 },
66 );
67
68 it.each(["```", "~~~"])("keeps examples after a false closing fence: %s", (fence) => {
69 const example = "Co-authored-by: Claude <noreply@anthropic.com>";
70 const content = `${fence}text\n${fence} trailing text\n${example}\n ${fence}\n${example}\n${fence.slice(0, 2)}\n${example}\n ${fence}${fence[0]} \t`;
71 expect(removeAgentCredits(`${content}\n\n${example}`)).toBe(content);
72 });
73
74 it("preserves CRLF line endings", () => {
75 expect(
76 removeAgentCredits(
77 "Details\r\n\r\nCo-authored-by: Claude <noreply@anthropic.com>\r\nCo-authored-by: Alice <alice@example.com>",
78 ),
79 ).toBe("Details\r\n\r\nCo-authored-by: Alice <alice@example.com>");
80 });
81
82 it("returns an empty body when only agent credits remain", () => {
83 expect(
84 removeAgentCredits("Co-authored-by: Claude <noreply@anthropic.com>\n\nGenerated by Codex\n"),
85 ).toBe("");
86 });
87 });