fix(jobdanmark-search): drop presentation-only keys from search output

coverImage, companyLogo, companyLogoSvgMarkup, overlayColor, and
silhouetteLogo were ~40% of a live payload - image keys, focal points
and overlay colours an agent can never act on, paid into context on
every /scrape query. A live 30-result response drops from ~30k to ~20k
chars. The #340 compatibility duplicates and slug (the detail command's
input) are kept deliberately. Review finding F3 (2026-08-19), decision
approved by Mads.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mads Lorentzen
2026-08-19 20:33:16 +02:00
co-authored by Claude Opus 5
parent 48965960d3
commit 56f679e5c0
4 changed files with 27 additions and 42 deletions
+2 -17
View File
@@ -129,13 +129,6 @@ bun run src/cli.ts search --text "sygeplejerske" --zip 8000 --limit 10
{
"title": "IT-chef søges til RAH",
"companyName": "Rah Service A/S",
"companyLogo": {
"key": "71f1c950-abcd-1234-efgh-000000000000",
"url": "https://jobdanmark.dk/media/k1epc2kk/rah-service-logo.jpg",
"focalPoint": null
},
"companyLogoSvgMarkup": null,
"overlayColor": "#FFFFFF1F",
"companyAddress": "Ndr Ringvej 4 6950 Ringkøbing",
"jobTypes": ["fuldtid"],
"boostJob": true,
@@ -143,12 +136,6 @@ bun run src/cli.ts search --text "sygeplejerske" --zip 8000 --limit 10
"applicationDeadline": "10-04-2026",
"url": "https://jobdanmark.dk/job/it-chef-soeges-til-rah",
"slug": "it-chef-soeges-til-rah",
"coverImage": {
"key": "cf06eb46-abcd-1234-efgh-000000000000",
"url": "https://jobdanmark.dk/media/idvbnt4y/rah-service-as-billede.png",
"focalPoint": { "top": 0.488, "left": 0.499 }
},
"silhouetteLogo": false,
"company": "Rah Service A/S",
"location": "Ringkøbing",
"date": "2026-03-12",
@@ -162,9 +149,8 @@ bun run src/cli.ts search --text "sygeplejerske" --zip 8000 --limit 10
> - `url` is normalized to a full URL (CLI prepends `https://jobdanmark.dk` to the relative path from the API).
> - `slug` is extracted from the relative `url` field (the path segment after `/job/`).
> - `applicationDeadline` can be `null`.
> - `companyLogo` can be `null`.
> - `publishedDate` format: `"DD-MM-YYYY"`.
> - `coverImage` can be `null`.
> - Presentation-only keys the API sends (`coverImage`, `companyLogo`, `companyLogoSvgMarkup`, `overlayColor`, `silhouetteLogo`) are dropped from search output — they were ~40% of a live payload and an agent can never use them.
> - Every result also carries the cross-portal contract fields `company`, `location`, `date` and `deadline`, derived from `companyName`, the city after the postal code in `companyAddress`, and the day-first dates converted to `YYYY-MM-DD` — `/scrape` Step 2 expects search output to include title, company, location, date, and URL. Native fields are preserved unchanged.
---
@@ -454,5 +440,4 @@ All errors are written to **stderr** in JSON format and exit with code `1`:
## URL construction
- Job detail pages: `https://jobdanmark.dk/job/{slug}`
- Company logo images: `https://jobdanmark.dk{companyLogo.url}` (prepend base URL to relative path)
- Cover images: `https://jobdanmark.dk{coverImage.url}` (prepend base URL to relative path)
- Image URLs from the raw API (`companyLogo.url`, `coverImage.url`) are relative; prepend `https://jobdanmark.dk` if you consume the API directly (the CLI drops these keys)
@@ -59,32 +59,14 @@ export function normalizeItem(item: ApiSearchItem): Record<string, unknown> {
// Extract slug from url path: /job/<slug>
const slug = relativeUrl.replace(/^\/job\//, "")
const companyLogo = item.companyLogo
? {
key: item.companyLogo.key,
url: item.companyLogo.url.startsWith("http")
? item.companyLogo.url
: `${BASE_URL}${item.companyLogo.url}`,
focalPoint: item.companyLogo.focalPoint,
}
: null
const coverImage = item.coverImage
? {
key: item.coverImage.key,
url: item.coverImage.url.startsWith("http")
? item.coverImage.url
: `${BASE_URL}${item.coverImage.url}`,
focalPoint: item.coverImage.focalPoint,
}
: null
// Presentation-only keys (coverImage, companyLogo, companyLogoSvgMarkup,
// overlayColor, silhouetteLogo) are dropped: they were ~40% of a live
// payload and the /scrape agent can never use an image or overlay colour.
// The #340 compatibility duplicates (companyName, publishedDate,
// applicationDeadline) stay.
return {
title: item.title,
companyName: item.companyName,
companyLogo,
companyLogoSvgMarkup: item.companyLogoSvgMarkup ?? null,
overlayColor: item.overlayColor ?? null,
companyAddress: item.companyAddress,
jobTypes: item.jobTypes,
boostJob: item.boostJob,
@@ -92,8 +74,6 @@ export function normalizeItem(item: ApiSearchItem): Record<string, unknown> {
applicationDeadline: item.applicationDeadline ?? null,
url: fullUrl,
slug,
coverImage,
silhouetteLogo: item.silhouetteLogo,
company: item.companyName,
location: extractCity(item.companyAddress),
date: toContractDate(item.publishedDate),
@@ -88,4 +88,18 @@ describe("Jobdanmark search normalization", () => {
expect(result.publishedDate).toBe("27-07-2026");
expect(result.applicationDeadline).toBe("17-08-2026");
});
test("omits presentation-only keys the agent can never use", () => {
// coverImage/companyLogo/companyLogoSvgMarkup/overlayColor/silhouetteLogo
// were ~40% of a live search payload, fed into agent context on every
// /scrape query (review finding F3, 2026-08-19). The #340 compatibility
// duplicates (companyName, publishedDate, applicationDeadline) stay.
const result = normalizeItem(item());
expect(result).not.toHaveProperty("coverImage");
expect(result).not.toHaveProperty("companyLogo");
expect(result).not.toHaveProperty("companyLogoSvgMarkup");
expect(result).not.toHaveProperty("overlayColor");
expect(result).not.toHaveProperty("silhouetteLogo");
});
});