Edit an agent's CV, languages, avoid and must-have texts and the judge limits on the Search agents page

A Your CV fieldset in the edit form: the CV as text or read from a .md/.txt
file, language rows of a code and a level with Suggest languages from the
CV, and the Avoid / drains me and Must-haves and deal-breakers texts. The
judge limits sit beside extract and summarise, the card's limits line gets a
judge clause and one more line says whether a CV is set and its languages.
Save sends all four fields, and the card switch re-posts the row with them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Sonnet 5.5 committed 2026-10-03 22:18:32 +02:00
1 parent 84262978e9
commit 8f5c4666bc
2 files changed
+176 -11

No files matched your search

+152 -10
View File
@@ -18,6 +18,12 @@
* narrow what big boards read with the wide reach send (app/jobs/reach.py).
* The card says them in a line of their own, or that boards send every role.
*
* The CV fieldset holds what the judge stage reads a role against: the CV as
* text (typed, or read from a .md/.txt file by the browser), the languages it
* states as rows of a code and a level, and the avoid and must-have texts.
* Every save sends all four, and the card's switch re-posts the row as the
* server gave it, so neither drops them.
*
* Every request goes through `api()` from app.js, so a failure is one toast
* carrying the server's own sentence.
*/
@@ -31,7 +37,12 @@
// What the model reads after a pull, per agent: the best `extract_top`
// roles scoring at least `extract_min` get their gate columns filled, the
// best `summarise_top` at `summarise_min` or more a summary.
const DEFAULT_LIMITS = { extract_top: 500, extract_min: 0.55, summarise_top: 30, summarise_min: 0.65 };
const DEFAULT_LIMITS = { extract_top: 500, extract_min: 0.55, summarise_top: 30, summarise_min: 0.65,
judge_top: 150, judge_min: 0.55 };
// The levels of a language, the order of the server's ladder, and how big a
// CV file the browser reads into the box.
const LEVELS = ["basic", "conversational", "professional", "fluent", "native"];
const MAX_CV_BYTES = 1_000_000;
const NEW = "new";
// Europe as the starter agents spell it (static/remote.js).
const EUROPE = rh.EUROPE;
@@ -42,7 +53,7 @@
/** @type {object[]} every agent, as the server lists them */
let agents = [];
/** @type {Object<string, boolean>} whether extract and summarise run, from
/** @type {Object<string, boolean>} whether extract, summarise and judge run, from
* `/api/stages`; empty when that did not answer, and then a card says
* nothing about them */
let stageOn = {};
@@ -93,6 +104,13 @@
regionNames = null;
}
let languageNames = null;
try {
languageNames = new Intl.DisplayNames(["en"], { type: "language" });
} catch (err) {
languageNames = null;
}
// A country code in words, the code itself where the browser has no name.
function countryName(code) {
if (code === "EU") return "anywhere in Europe";
@@ -278,6 +296,7 @@
const clauses = [
["extract", `reads ${l.extract_top} at ${l.extract_min}`, `${l.extract_top} at ${l.extract_min}`],
["summarise", `summarises ${l.summarise_top} at ${l.summarise_min}`, `${l.summarise_top} at ${l.summarise_min}`],
["judge", `judges ${l.judge_top} at ${l.judge_min}`, `${l.judge_top} at ${l.judge_min}`],
];
clauses.forEach(([name, on, would], i) => {
if (i) p.append(" · ");
@@ -322,6 +341,7 @@
div.appendChild(el("p", "agent-weights", weightsLine(row)));
div.appendChild(limitsLine(row));
div.appendChild(termsLine(row));
div.appendChild(cvLine(row));
const actions = el("div", "agent-card-actions");
const edit = el("button", "secondary", "Edit");
@@ -476,6 +496,15 @@
: "Big boards send every role: no fetch terms.");
}
// The CV on a card: whether the judge has one to read roles against, and
// the languages it states, as "da fluent, en native".
function cvLine(row) {
const langs = row.cv_languages || [];
const said = langs.length ? `Languages: ${langs.map((l) => `${l.language} ${l.level}`).join(", ")}.` : "No languages stated.";
const has = Boolean((row.cv_text || "").trim());
return el("p", "agent-terms", has ? `CV set. ${said}` : `No CV, so roles are not judged against one. ${said}`);
}
// A prompt as a row: its name and Remove on a line, its text under them.
function promptRow(prompt, remove) {
const row = el("div", "prompt-row");
@@ -507,6 +536,34 @@
return box;
}
// A language as a row, after the rule rows: a code, a level, Remove. The
// code is two letters, which the server turns into the language; its name
// is the row's title where the browser knows it.
function languageRow(language, remove) {
const row = el("div", "rule-row");
const code = el("input");
code.type = "text";
code.maxLength = 2;
code.spellcheck = false;
code.placeholder = "en";
code.value = language.language;
code.setAttribute("aria-label", "Language code");
const level = select(LEVELS.map((l) => [l, l]), language.level, "Level");
const named = () => {
try {
code.title = (languageNames && languageNames.of(code.value.trim().toLowerCase())) || "";
} catch (err) {
code.title = "";
}
};
code.addEventListener("input", named);
named();
const drop = linky("Remove");
drop.addEventListener("click", () => remove(row));
row.append(code, level, drop);
return { node: row, read: () => ({ language: code.value.trim().toLowerCase(), level: level.value }) };
}
// A gate as a row: field, mode, values, the weight while it is prefer, and
// Remove. Values untouched since the load are sent as they came, so a
// value with a comma in it survives a save.
@@ -579,6 +636,53 @@
changed(f);
});
// The CV: its text, the file that can fill it, the languages as rows and
// the two soft texts. All four are always sent, so what is cleared here
// is cleared in the store.
const cvText = $("#a-cv-text", f);
cvText.value = row ? row.cv_text || "" : "";
$("#a-avoid-text", f).value = row ? row.avoid_text || "" : "";
$("#a-must-text", f).value = row ? row.must_text || "" : "";
const languages = [];
const dropLanguage = (node) => {
languages.splice(languages.findIndex((l) => l.node === node), 1);
node.remove();
changed(f);
};
const addLanguage = (language) => {
const entry = languageRow(language, dropLanguage);
languages.push(entry);
$("#a-cv-languages", f).appendChild(entry.node);
return entry;
};
(row ? row.cv_languages || [] : []).forEach(addLanguage);
$("#a-add-language", f).addEventListener("click", () => {
$("input", addLanguage({ language: "", level: "professional" }).node).focus();
changed(f);
});
$("#a-cv-file", f).addEventListener("change", (event) => readCvFile(event.target, cvText, f));
$("#a-suggest-languages", f).addEventListener("click", async (event) => {
const button = event.currentTarget;
if (!cvText.value.trim()) {
window.toast.error("Paste a CV first.");
return;
}
button.disabled = true;
try {
const { languages: found } = await api("/api/agents/cv-languages", {
method: "POST", body: { cv_text: cvText.value },
});
languages.splice(0).forEach((l) => l.node.remove());
found.forEach(addLanguage);
changed(f);
if (!found.length) window.toast.info("The CV states no language.");
} catch (err) {
// `api()` toasted the server's sentence; the rows stay as they were.
} finally {
button.disabled = false;
}
});
const { where, rest } = rh.distribute(row ? row.gates : []);
const scope = $("#a-scope", f);
scope.value = where.scope.kind;
@@ -669,10 +773,17 @@
$("#a-extract-min", f).value = limits.extract_min;
$("#a-summarise-top", f).value = limits.summarise_top;
$("#a-summarise-min", f).value = limits.summarise_min;
$("#a-judge-top", f).value = limits.judge_top;
$("#a-judge-min", f).value = limits.judge_min;
$("#a-delete", f).hidden = !row;
f.addEventListener("input", () => { f.dataset.dirty = "true"; view(); });
f.addEventListener("change", view);
f.addEventListener("submit", (event) => save(event, row, () => prompts.map((p) => p.read()), gates, terms.values));
f.addEventListener("submit", (event) => save(event, row, {
prompts: () => prompts.map((p) => p.read()),
gates,
terms: terms.values,
languages: () => languages.map((l) => l.read()),
}));
$("#a-cancel", f).addEventListener("click", () => { close(); render(); });
$("#a-delete", f).addEventListener("click", () => row && removeAgent(row));
div.appendChild(f);
@@ -718,18 +829,43 @@
: "No search agents yet. New agent describes one.";
}
// `readPrompts`, `readGates` and `readTerms` are the form's rows and chips
// as the API takes them.
// A prompt with neither name nor text is an empty row, left out.
async function save(event, row, readPrompts, readGates, readTerms) {
// Read a .md or .txt file into the CV box, replacing what is there. The file
// stays in the browser; Save sends the text like any typed one.
function readCvFile(input, box, f) {
const file = input.files && input.files[0];
input.value = "";
if (!file) return;
if (file.size > MAX_CV_BYTES) {
window.toast.error(`${file.name} is over 1 MB, too big for a CV. Paste the part that matters.`);
return;
}
const reader = new FileReader();
reader.onload = () => {
box.value = String(reader.result || "");
changed(f);
};
reader.onerror = () => window.toast.error(`Could not read ${file.name}.`);
reader.readAsText(file);
}
// `read` holds the form's rows and chips as the API takes them: `prompts`,
// `gates`, `terms` and `languages`.
// A prompt with neither name nor text is an empty row, left out, as is a
// language row with no code.
async function save(event, row, read) {
event.preventDefault();
const f = event.target;
const prompts = readPrompts().filter((p) => p.name || p.text.trim());
const prompts = read.prompts().filter((p) => p.name || p.text.trim());
if (prompts.some((p) => !p.name)) {
window.toast.error("Every prompt needs a name.");
return;
}
const gates = readGates();
const cvLanguages = read.languages().filter((l) => l.language);
if (cvLanguages.some((l) => !/^[a-z]{2}$/.test(l.language))) {
window.toast.error("A language is a two-letter code such as en or da.");
return;
}
const gates = read.gates();
const body = {
name: $("#a-name", f).value.trim(),
prompts,
@@ -745,8 +881,14 @@
extract_min: Number($("#a-extract-min", f).value),
summarise_top: Number($("#a-summarise-top", f).value),
summarise_min: Number($("#a-summarise-min", f).value),
judge_top: Number($("#a-judge-top", f).value),
judge_min: Number($("#a-judge-min", f).value),
},
fetch_terms: readTerms(),
fetch_terms: read.terms(),
cv_text: $("#a-cv-text", f).value,
cv_languages: cvLanguages,
avoid_text: $("#a-avoid-text", f).value,
must_text: $("#a-must-text", f).value,
// Saving an agent means it is wanted, so a new one starts on; the
// card's switch is where an existing one is switched.
enabled: row ? row.enabled : true,