Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/app/src/linear-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import Mustache from "mustache";
import type { WorkItem } from "./types";

const object = (value: unknown): Record<string, any> => value !== null && typeof value === "object" && !Array.isArray(value) ? value as Record<string, any> : {};
const text = (value: unknown): string => typeof value === "string" ? value : "";
const decodeHtmlEntities = (value: string): string => value.replace(/&(?:#(\d+)|#x([\da-f]+)|([a-z][\da-z]+));/gi, (entity, decimal, hexadecimal, named) => {
if (decimal) return String.fromCodePoint(Number(decimal));
if (hexadecimal) return String.fromCodePoint(parseInt(hexadecimal, 16));
return ({ amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' } as Record<string, string>)[named.toLowerCase()] ?? entity;
});
const text = (value: unknown): string => typeof value === "string" ? decodeHtmlEntities(value) : "";

export const DEFAULT_CONTEXT_TEMPLATE = `---
pipe: "{{{flow.name}}}"
Expand Down
10 changes: 10 additions & 0 deletions packages/app/test/ticket-prompt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@ Create \`WHOA.md\` with \`it works!\`.`);
}, "bug-fixes");
expect(prompt).toBe("bug-fixes: GEN-1979 — Use `extra` context. (2026.09)");
});

it("decodes HTML entities in ticket content before rendering the prompt", () => {
const prompt = linearTicketPrompt({
identifier: "GEN-2063", title: "Run prompt formatting",
description: "Fix the merge conflicts in https:&#x2F;&#x2F;github.com&#x2F;GenerationSoftware&#x2F;factorize&#x2F;pull&#x2F;100 &amp; keep the link.",
}, "flow");

expect(prompt).toContain("https://github.com/GenerationSoftware/factorize/pull/100 & keep the link.");
expect(prompt).not.toContain("&#x2F;");
});
});