Drop Advanced › Other rules from the agent form, so an agent's gates are the fetch gate's four parts: a stored gate the parts cannot say is named in a note under the fetch gate and sent back unchanged on Save, and the card still says it in words
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
136047023e
commit
1913101061
7 files changed
+193
-125
No files matched your search
+54
-83
@@ -9,13 +9,15 @@
|
||||
* ADR's order: the world (the scope select), the location (a short list of
|
||||
* lines a role passes by matching any one of: countries, towns, remote), the
|
||||
* role exclusion (the titles to leave out) and the role fetch (the fetch
|
||||
* terms), over a row per remaining rule under Advanced; a gate the four parts
|
||||
* cannot say lands in a row, so a load and a save lose nothing. A gate is a
|
||||
* field, values and a mode (must, one of, not), with no weight. After it come
|
||||
* the analytics filter (the best N by prompt closeness and the best M by CV
|
||||
* closeness, each with a minimum level), the want feed score weights (prompt
|
||||
* closeness, newness, company like, job like), the CV match weights and the
|
||||
* size of summarise. Edit turns a card
|
||||
* terms), and nothing else: seniority, pay and the like are filters on Roles.
|
||||
* A gate is a field, values and a mode (must, one of, not), with no weight.
|
||||
* A stored gate the four parts cannot say, which only the config or the API
|
||||
* writes, is named in a note under the fetch gate and sent back as it came,
|
||||
* so a load and a save lose nothing. After the fetch gate come the analytics
|
||||
* filter (the best N by prompt closeness and the best M by CV closeness, each
|
||||
* with a minimum level), the want feed score weights (prompt closeness,
|
||||
* newness, company like, job like), the CV match weights and the size of
|
||||
* summarise. Edit turns a card
|
||||
* into the form from the page's `<template>`, in place, and New agent puts a
|
||||
* blank card on top in the same state. One card edits at a time, so the
|
||||
* form's ids stay unique. Votes, liked companies and scores are the agent's,
|
||||
@@ -61,9 +63,8 @@
|
||||
const NEW = "new";
|
||||
// Europe as the starter agents spell it (static/remote.js).
|
||||
const EUROPE = rh.EUROPE;
|
||||
const FIELDS = ["place", "country", "remote", "remote_from", "seniority", "function", "salary_min",
|
||||
"currency", "permit", "languages", "company", "title"];
|
||||
const MODES = [["require", "must"], ["any", "one of"], ["exclude", "not"]];
|
||||
// A gate's mode in the words of the note on the gates the form keeps.
|
||||
const MODES = { require: "must", any: "one of", exclude: "not" };
|
||||
|
||||
/** @type {object[]} every agent, as the server lists them */
|
||||
let agents = [];
|
||||
@@ -263,8 +264,8 @@
|
||||
}
|
||||
|
||||
// The region and place in words, one sentence led by the region, then the lines a
|
||||
// role may match, with the one-of rows among them since they are the same
|
||||
// group: "Within Europe: keeps roles anywhere in Denmark, in Malmö, Lund or
|
||||
// role may match, with any other one-of gates among them since they are the
|
||||
// same group: "Within Europe: keeps roles anywhere in Denmark, in Malmö, Lund or
|
||||
// Helsingborg, or remote, and leaves out the rest." The lines add up, which
|
||||
// the first wording ("Roles in ...") left the owner to guess.
|
||||
function whereSentence(where, others) {
|
||||
@@ -381,7 +382,7 @@
|
||||
// ---------------------------------------------------------------- the form
|
||||
|
||||
// Tell the form something changed that no field typed: a chip or a row
|
||||
// added or removed. It marks the form dirty and redraws the gates view.
|
||||
// added or removed. It marks the form dirty and redraws the gates' sentence.
|
||||
function changed(node) {
|
||||
node.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
}
|
||||
@@ -556,9 +557,9 @@
|
||||
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.
|
||||
// A language as a row: 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");
|
||||
@@ -584,32 +585,32 @@
|
||||
return { node: row, read: () => ({ language: code.value.trim().toLowerCase(), level: level.value }) };
|
||||
}
|
||||
|
||||
// A gate as a row: field, mode, values and Remove. Values untouched since the load are sent as they came, so a
|
||||
// value with a comma in it survives a save.
|
||||
function ruleRow(gate, remove) {
|
||||
const row = el("div", "rule-row");
|
||||
const field = select(FIELDS.map((f) => [f, f.replace("_", " ")]), gate.field, "Field");
|
||||
const mode = select(MODES, gate.mode, "Mode");
|
||||
const values = el("input");
|
||||
values.type = "text";
|
||||
values.required = true;
|
||||
values.spellcheck = false;
|
||||
values.placeholder = "senior, staff";
|
||||
values.value = gate.values.join(", ");
|
||||
values.setAttribute("aria-label", "Values, separated by commas");
|
||||
const loaded = values.value;
|
||||
const drop = linky("Remove");
|
||||
drop.addEventListener("click", () => remove(row));
|
||||
row.append(field, mode, values, drop);
|
||||
// The gates the fetch gate's four parts say, in the order the starter
|
||||
// agents have them: the world, the location lines and the titles left out,
|
||||
// then `kept`, the stored gates the parts cannot say, as they came. `parts`
|
||||
// holds what the form reads: `scope` (europe, countries, everywhere) and
|
||||
// its `scoped` countries, the `within` countries, the `towns`, `remote`
|
||||
// (none, scope, from) and its `from` areas, and the `titles`.
|
||||
function formGates(parts, kept = []) {
|
||||
const out = [];
|
||||
const { scope, scoped, within, towns: lines, remote, from, titles } = parts;
|
||||
if (scope === "europe") out.push({ field: "country", values: rh.europeWith(within), mode: "require" });
|
||||
if (scope === "countries" && scoped.length) out.push({ field: "country", values: scoped, mode: "require" });
|
||||
if (within.length) out.push({ field: "country", values: within, mode: "any" });
|
||||
if (remote === "scope") out.push({ field: "remote", values: ["remote"], mode: "any" });
|
||||
if (remote === "from" && from.length) out.push({ field: "remote_from", values: from, mode: "any" });
|
||||
if (lines.length) out.push({ field: "place", values: lines, mode: "any" });
|
||||
if (titles.length) out.push({ field: "title", values: titles, mode: "exclude" });
|
||||
return out.concat(kept);
|
||||
}
|
||||
|
||||
function read() {
|
||||
const parts = values.value === loaded
|
||||
? gate.values
|
||||
: values.value.split(",").map((v) => v.trim()).filter(Boolean)
|
||||
.map((v) => (field.value === "salary_min" ? Number(v) : v));
|
||||
return { field: field.value, values: parts, mode: mode.value };
|
||||
}
|
||||
return { node: row, read };
|
||||
// The note on the gates the form keeps: "The form cannot edit these rules,
|
||||
// and Save keeps them as stored: must: with seniority senior; not: at Acme."
|
||||
function keptNote(kept) {
|
||||
if (!kept.length) return "";
|
||||
const said = kept.map((g) => `${MODES[g.mode] || g.mode}: ${phrase(g)}`).join("; ");
|
||||
return `The form cannot edit ${kept.length > 1 ? "these rules" : "this rule"}, and Save keeps `
|
||||
+ `${kept.length > 1 ? "them" : "it"} as stored: ${said}.`;
|
||||
}
|
||||
|
||||
function form(row) {
|
||||
@@ -710,51 +711,18 @@
|
||||
remoteFrom.node.hidden = remoteMode.value !== "from";
|
||||
};
|
||||
offer();
|
||||
$("details.advanced", f).open = rest.length > 0;
|
||||
const kept = $("#a-kept", f);
|
||||
kept.textContent = keptNote(rest);
|
||||
kept.hidden = !rest.length;
|
||||
|
||||
const rules = [];
|
||||
const dropRule = (node) => {
|
||||
rules.splice(rules.findIndex((r) => r.node === node), 1);
|
||||
node.remove();
|
||||
changed(f);
|
||||
};
|
||||
const addRule = (gate) => {
|
||||
const entry = ruleRow(gate, dropRule);
|
||||
rules.push(entry);
|
||||
$("#a-rules", f).appendChild(entry.node);
|
||||
return entry;
|
||||
};
|
||||
rest.forEach(addRule);
|
||||
$("#a-add-rule", f).addEventListener("click", () => {
|
||||
$("select", addRule({ field: "seniority", values: [], mode: "require" }).node).focus();
|
||||
changed(f);
|
||||
});
|
||||
|
||||
// The gates the fetch gate's three parts say, in the order the starter
|
||||
// agents have them: the region, the place lines, and the titles left out.
|
||||
function whereGates() {
|
||||
const out = [];
|
||||
const within = countries.values();
|
||||
const towns = places.values();
|
||||
const from = remoteFrom.values();
|
||||
if (scope.value === "europe") out.push({ field: "country", values: rh.europeWith(within), mode: "require" });
|
||||
if (scope.value === "countries" && scoped.values().length) {
|
||||
out.push({ field: "country", values: scoped.values(), mode: "require" });
|
||||
}
|
||||
if (within.length) out.push({ field: "country", values: within, mode: "any" });
|
||||
if (remoteMode.value === "scope") out.push({ field: "remote", values: ["remote"], mode: "any" });
|
||||
if (remoteMode.value === "from" && from.length) out.push({ field: "remote_from", values: from, mode: "any" });
|
||||
if (towns.length) out.push({ field: "place", values: towns, mode: "any" });
|
||||
const left = titles.values();
|
||||
if (left.length) out.push({ field: "title", values: left, mode: "exclude" });
|
||||
return out;
|
||||
}
|
||||
// The gates Save sends: the fetch gate's, then the rows. The sentence
|
||||
// under it says them all, as the card will, rows included.
|
||||
const gates = () => whereGates().concat(rules.map((r) => r.read()));
|
||||
// The gates Save sends: the four parts', then the kept ones. The sentence
|
||||
// under them says them all, as the card will, the kept ones included.
|
||||
const gates = () => formGates({
|
||||
scope: scope.value, scoped: scoped.values(), within: countries.values(), towns: places.values(),
|
||||
remote: remoteMode.value, from: remoteFrom.values(), titles: titles.values(),
|
||||
}, rest);
|
||||
const view = () => {
|
||||
offer();
|
||||
$("#a-gates", f).value = JSON.stringify(gates(), null, 2);
|
||||
$("#a-where-sum", f).textContent = rulesLine(gates()) || "Passes every role.";
|
||||
};
|
||||
view();
|
||||
@@ -978,6 +946,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
// For tests/js/agents.test.mjs: what Save sends and how it is said.
|
||||
window.agentGates = { formGates, keptNote, rulesLine };
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
if (!$("#agents-list")) return;
|
||||
$("#a-new").addEventListener("click", () => open(null));
|
||||
|
||||
Reference in new issue
Block a user