Merge the agent form without Advanced rules: the gates are the four parts of the fetch gate, a stored gate the form cannot say is named and kept (wp-advanced)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-10-06 14:34:11 +02:00
commit 2262cda8f1
7 files changed
+193 -125

No files matched your search

+54 -83
View File
@@ -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));
+3 -9
View File
@@ -1300,8 +1300,6 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
background: var(--bg); border: 1px solid var(--line);
border-radius: .3rem; padding: .35rem .5rem; width: 100%;
}
/* Prose in a textarea is read in the page face; JSON is in the mono one. */
.agent-form textarea.code { font-family: var(--mono); font-size: .85rem; }
.agent-form .hint { color: var(--dim); font-size: .8rem; overflow-wrap: anywhere; }
.weights { display: flex; gap: .75rem; flex-wrap: wrap; border: 1px solid var(--line); border-radius: .3rem; }
/* A label that wraps to two lines pushes its box down; the boxes stay in line. */
@@ -1316,14 +1314,13 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
}
/* The fieldsets that hold rows: a column, the Add button under the rows. */
.agent-form fieldset.prompts, .agent-form fieldset.where, .agent-form fieldset.titles,
.agent-form fieldset.terms,
.agent-form fieldset.rules {
.agent-form fieldset.terms {
display: flex; flex-direction: column; align-items: stretch; gap: .5rem; min-width: 0;
border: 1px solid var(--line); border-radius: .3rem;
}
.agent-form fieldset > button { align-self: flex-start; }
/* A prompt or a rule as a row of a list, after `.crow`: the name and Remove
on line one, the text spanning the row under them. A rule row wraps like
/* A prompt or a language as a row of a list, after `.crow`: the name and Remove
on line one, the text spanning the row under them. A language row wraps like
`.crow .board-edit`, so a phone takes it in two lines rather than scrolling. */
.prompt-row {
display: grid; grid-template-columns: 1fr auto; align-items: center;
@@ -1353,9 +1350,6 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
.agent-form .chips input[type="text"] { flex: 1 1 6rem; width: auto; min-width: 0; }
.agent-form .chips select { flex: 0 1 12rem; min-width: 0; max-width: 100%; }
.chips .tag span { color: var(--faint); }
.agent-form details summary { cursor: pointer; color: var(--dim); font-size: .9rem; }
.agent-form details[open] summary { margin-bottom: .5rem; }
.agent-form .advanced-body { display: flex; flex-direction: column; gap: .6rem; }
/* ================================================================ */
/* companies and sources — the Sources page's sections, */
+12 -10
View File
@@ -1,7 +1,8 @@
/* Where a remote role may be worked from, as the pages say it: the words of
* the badge, the picks of the agent's "Remote, open to someone in" chips, and
* how an agent's gates share out between the fetch gate's blocks and Other rules. No
* DOM in it, so `tests/js/remote.test.mjs` can walk it without a browser.
* how an agent's gates share out between the fetch gate's blocks and the rest
* the form keeps as stored. No DOM in it, so `tests/js/remote.test.mjs` can
* walk it without a browser.
*
* The area is a place token in three spellings, one per layer: `remote:<place
* token>` on the Roles rail and in the address, `<place token>` in a
@@ -61,18 +62,19 @@
}
/** Share out an agent's gates between the fetch gate's blocks (region,
place, titles to leave out) and Other rules. Each line takes the first
gate it can say whole; the rest are rows. A gate has a field, values and
a mode (require, any, exclude) and no weight; a gate with a mode the
form does not know, such as an old prefer, stays a row.
place, titles to leave out) and the rest, which the form cannot edit
and keeps as stored. Each line takes the first gate it can say whole.
A gate has a field, values and a mode (require, any, exclude) and no
weight; a gate with a mode the form does not know, such as an old
prefer, is in the rest.
The scope line is the first plain require gate on country: `europe`
when it is exactly Europe and the countries line (`europeWith`),
`countries` with its codes as chips otherwise, `everywhere` when there
is none. Any other require gate on country is a row. The remote line is
`scope` for the one-of on `remote: [remote]` (remote, within the
scope), `from` for a one-of on `remote_from`, else `none`; when both
are there `remote_from` wins and the plain one stays a row. */
is none. Any other require gate on country is in the rest. The remote
line is `scope` for the one-of on `remote: [remote]` (remote, within
the scope), `from` for a one-of on `remote_from`, else `none`; when
both are there `remote_from` wins and the plain one is in the rest. */
function distribute(gates) {
const where = { scope: null, countries: null, places: null, remote: { mode: "none", values: [] }, titles: null };
const rest = [];
+2 -15
View File
@@ -74,6 +74,7 @@
</div>
<span class="hint">Fetch terms, separated by a comma or Enter: <code>machine learning, data science</code> is two terms, and <code>machine learning</code> is searched as one. A host that takes a query sends only roles with one of the terms anywhere in the ad, but only for boards of 300 or more roles; smaller boards and other hosts are read whole. The terms are ignored after the fetch, since prompt closeness is the finer filter. Empty means no narrowing.</span>
<p id="a-where-sum" class="where-sum" role="status"></p>
<p id="a-kept" class="hint" hidden></p>
</fieldset>
<fieldset class="terms cv">
<legend>Your CV</legend>
@@ -94,7 +95,7 @@
<textarea id="a-like-text" rows="4" placeholder="Building a team from scratch, close work with the product side, small companies, a say in the roadmap"></textarea></label>
<label>What I don't like
<textarea id="a-avoid-text" rows="4" placeholder="Constant on-call, sales targets, large consultancies, open-plan offices"></textarea></label>
<span class="hint">The work, the workplace, situations; read by the judge for the career rating. Rules that must hold go under the fetch gate or Other rules instead.</span>
<span class="hint">The work, the workplace, situations; read by the judge for the career rating. Rules that must hold go under the fetch gate instead.</span>
</fieldset>
<fieldset class="weights limits">
<legend>Analytics filter</legend>
@@ -124,20 +125,6 @@
<label>Summarise the top <input type="number" id="a-summarise-top" min="0" step="5" value="30"> of each feed order</label>
</fieldset>
<span class="hint">Summarise writes a short summary and tags for the top N of What I'm looking for and the top N of What fits me, at most twice N roles, and for every role you liked or saved. It is no part of any score.</span>
<details class="advanced">
<summary>Advanced</summary>
<div class="advanced-body">
<fieldset class="rules">
<legend>Other rules</legend>
<div id="a-rules" class="rule-rows"></div>
<button type="button" id="a-add-rule" class="secondary">Add rule</button>
<span class="hint">Must: a role must meet it. One of: a role must meet one of these or a Place line. Not: a role that meets it is left out. Values are separated by commas; salary is a number.</span>
</fieldset>
<label>Rules as sent
<textarea id="a-gates" class="code" rows="6" spellcheck="false" readonly>[]</textarea>
<span class="hint">Read only: what Save sends as the agent's gates, from the fetch gate and Other rules.</span></label>
</div>
</details>
<div class="agent-actions">
<button type="submit">Save and score</button>
<button type="button" id="a-cancel" class="secondary">Cancel</button>