diff --git a/app/nullius/standard/recipe.py b/app/nullius/standard/recipe.py index 2e2369de..edb2b133 100644 --- a/app/nullius/standard/recipe.py +++ b/app/nullius/standard/recipe.py @@ -171,13 +171,13 @@ def _bench_page(b: dict) -> dict: def protocol(o: dict) -> str: - """How Nullius talks to it, in a word or two for a page.""" + """How Nullius talks to it, in a word or two for a page, in sentence case as its filter names it.""" if o["_kind"] == "control": - return "no agent" + return "No agent" if o["_kind"] == "capability": return "JSON lines" st = o.get("start") or {} - return "ACP" if "acp" in st else "its own script" if "driver" in st else "a command" + return "ACP" if "acp" in st else "Its own script" if "driver" in st else "A command" def skills_of(port: str, record: Optional[dict]) -> List[dict]: @@ -213,6 +213,61 @@ def _other_page(o: dict) -> dict: if isinstance((o.get("proven") or {}).get("fidelity"), dict) else {})} +def _install_words(o: dict) -> list: + """What a definition installs, in a few words each.""" + inst, up = o.get("install") or {}, o.get("upstream") or {} + out = [f"npm {p}" for p in inst.get("npm") or []] + [f"pip {p}" for p in inst.get("pip") or []] + if inst.get("project"): + extras = "[" + ",".join(inst["extras"]) + "]" if inst.get("extras") else "" + out.append(f"{inst['project']}{extras} from {up.get('repository', '').removeprefix('https://')} at {(up['tag'] + ' (' + str(up.get('tested', ''))[:12] + ')') if up.get('tag') else str(up.get('tested', ''))[:12]}") + if inst.get("python"): + out.append(f"on Python {inst['python']}") + out += [f"{', '.join(x['packages'])} from {x['url'].removeprefix('https://')}" for x in inst.get("indexes") or []] + out += [f"the model {m}" for m in inst.get("prefetch") or []] + return out + + +def entries(kind: str, benches: Optional[List[dict]] = None, every: bool = False, own: bool = False, jobs=()) -> dict: + """The agents (or capabilities) as the Agents page and the builder's Agent step list them, each with its ports + and its fits (``match.fit``) on ``benches`` (default: every benchmark of its family, default versions), and + the definitions with problems. ``own``: and the benchmarks' own agents (``definitions.benchmark_agents``); + ``jobs``: the job ids whose proof links to its job.""" + from nullius.standard import conform + others, bad = definitions.load(kind, every=every) + loaded = definitions.load("benchmark")[0] + benches = [b for b in loaded if b["family"] == kind] if benches is None else benches + if own and kind == "agent": + others = others + definitions.benchmark_agents(loaded) + out = [] + for o in others: + driver = "driver" in (o.get("start") or {}) # a benchmark's own: its driver runs it, it speaks no port + cand = set() if driver else set(conform.candidates(o)) + rows = [] + for p, spec in ports.PORTS.items() if not driver else (): + if ports.family(p) != kind or (kind == "capability" and p.split(".", 1)[1].split("/")[0] != o.get("kind")): + continue + rec = (o.get("proven") or {}).get(p) if p in (o.get("offers") or []) else None + state = "proven" if rec else ("not offered" if p in cand else ("no kit yet" if not spec["kit"] else "not for it")) + kit = definitions.kit(p) if spec["kit"] else None + rows.append({"port": p, "label": spec.get("label") or p, "summary": spec["summary"], "state": state, "record": rec, + "proof_kit": definitions.proof_kit(rec) if rec else None, + "kit": {"says": kit["summary"], "checks": kit["datasets"][0]["units"], "key": kit["key"], "version": definitions.kit_version(kit)} if kit else None, + "job": rec["job"] if rec and rec.get("job") in jobs else None, + "older_kit": definitions.older_kit(p, rec), + "skills": skills_of(p, rec)}) + fits = [{"key": b["key"], "ref": definitions.ref_of(b) if "_version" in b else b["key"], "label": b["label"], "needs": b["needs"], "why": match.fit(b, o)} for b in benches] + fid = (o.get("proven") or {}).get("fidelity") + out.append({"d": o, "protocol": protocol(o), "ports": rows, "fits": fits, + "install": _install_words(o), + # its options, each with its default and what else it takes; its fidelity proof, when it has one + "options": [{"name": n, "summary": x.get("summary", ""), "default": x.get("default"), + "values": list(x.get("values") or []), "pattern": x.get("pattern", ""), "example": x.get("example", "")} + for n, x in (o.get("options") or {}).items()], + "fidelity": fid if isinstance(fid, dict) else None}) + out.sort(key=lambda e: (not e["d"].get("example", False), definitions.title(e["d"]).casefold())) + return {"entries": out, "problems": bad} + + def choices() -> dict: """What the page offers - choices and the reasons a pair does not fit, never a command.""" diff --git a/app/static/builder/command-builder-core.js b/app/static/builder/command-builder-core.js index a76008d3..25fe1b83 100644 --- a/app/static/builder/command-builder-core.js +++ b/app/static/builder/command-builder-core.js @@ -48,7 +48,7 @@ const own = ownAgentsOf(b).map(o => ({...o, why: why[o.key] || [], setup: true, own: true})); const setups = own.length ? [] : (b.setups || []).map(x => ({...x, protocol: 'its own code', version: '', offers: [], proven: {}, options: {}, setup: true, why: []})); const rest = b.family === 'agent' ? standard().agents.filter(o => o.benchmark !== b.key) : standard().capabilities; - return own.concat(rest.map(o => ({...o, why: why[o.key] || [], elsewhere: !!o.benchmark})), setups, controls); + return own.concat(rest.map(o => ({...o, why: why[o.key] || []})), setups, controls); } // the chosen ones of a benchmark's own agents, and what each choice runs as: its own agent, its Original setup const ownChosen = r => ownAgentsOf(standardBench(r)).filter(a => chosenOf(r).includes(a.key)); diff --git a/app/static/builder/command-builder.css b/app/static/builder/command-builder.css index 769c48da..3f34f999 100644 --- a/app/static/builder/command-builder.css +++ b/app/static/builder/command-builder.css @@ -291,3 +291,13 @@ #nullius-builder .std-isolation small:empty { display: none; } #nullius-builder .std-boat-sizes .nb-tile { min-height: 60px; } #nullius-builder .std-boat-sizes .nb-tile-note { font-size: 13px; line-height: 1.4; } +/* the Agent step's grid: the card toolkit's (catalogue.css), fitted to the form */ +#nullius-builder .nb-step { border-radius: 0; margin: 0; } /* catalogue.css has a .nb-step of its own */ +#nullius-builder #nb-agent-grid { margin-bottom: 20px; } +#nullius-builder #nb-agent-grid .bench-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 12px; } +#nullius-builder #nb-agent-grid .bench-card { padding: 16px; gap: 10px; } +#nullius-builder #nb-agent-grid .bench-card-title { font-size: 15px; } +#nullius-builder #nb-agent-grid .std-tag { white-space: nowrap; } +#nullius-builder #nb-agent-grid .card-link:focus-visible { outline: none; } +/* its outlined pills (Protocol, Proven) want more air than snug's text beside text; a phone keeps snug's, for the pinned name */ +@media (min-width: 641px) { #nullius-builder #nb-agent-grid .grid.snug :is(th, td):not(.pick-col) { padding-left: .6rem; padding-right: .6rem; } } /* the card's ring (catalogue.css), not a box round the name */ diff --git a/app/static/builder/command-builder.js b/app/static/builder/command-builder.js index 7d4fd188..87a5dec3 100644 --- a/app/static/builder/command-builder.js +++ b/app/static/builder/command-builder.js @@ -93,14 +93,6 @@ const schema = JSON.parse(document.getElementById('nb-schema').textContent); const C = window.NulliusRecipe(schema), $ = s => root.querySelector(s); const esc = value => String(value ?? '').replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); - const agentMarks = JSON.parse(root.dataset.agentMarks || '{}'); - const agentMark = (key, label) => { - const source = agentMarks[String(key).split('@')[0]]; - if (!source) return esc(label[0]); - return source.includes('#') - ? `` - : ``; - }; const steps = C.STEPS, S = C.STEP, REVIEW = S.review; const query = Object.fromEntries(new URLSearchParams(location.search)); let recipe = C.prefill(query); @@ -646,7 +638,7 @@ return !t.length ? '' : t.every(n => n === t[0]) && t.length > 1 ? `${t[0]} tasks each` : `${t.reduce((a, n) => a + n, 0)} tasks`; }; const pickChip = (attr, v, label, on) => ``; // one tile: {attr, key, on, title, mark, cat, origin, line, meta, foot, find, fam, data (more attributes), tip (its title)} - const tile = t => `