Skip to content
57 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import type { AgentTemplate } from "@g1t/contracts";
5
6import { roleLine, routingWords, startPath, templateListings, templatePath, templatesPath } from "./agent-templates.ts";
7
8const template = (id: string, title: string): AgentTemplate => ({
9 id,
10 display_name: title.split(" ")[0]!,
11 handle: id,
12 name_ideas: [],
13 role: title,
14 title,
15 responsibilities: ["Do the work"],
16 subagents: [],
17 instructions: "",
18 personality_preset: "crisp",
19 routing: { floor: null, ceiling: null, providers: [], pinned: null },
20});
21
22test("templates live under Agents, and starting one opens the new-agent form with it chosen", () => {
23 assert.equal(templatesPath("acme"), "/acme/-/agents/templates");
24 assert.equal(templatePath("acme", "qa"), "/acme/-/agents/templates/qa");
25 assert.equal(startPath("acme", "qa"), "/acme/-/agents/new?template=qa");
26});
27
28test("a template counts the agents started from it, not archived ones", () => {
29 const [eng, qa] = templateListings(
30 [template("engineering", "Software Engineer"), template("qa", "QA Engineer")],
31 [
32 { id: "a1", handle: "otto", display_name: "Otto", template: "engineering", archived_at: null },
33 { id: "a2", handle: "bolt", display_name: "Bolt", template: "engineering", archived_at: "2026-10-01T00:00:00Z" },
34 { id: "a3", handle: "g1t", display_name: "g1t", template: null, archived_at: null },
35 ],
36 );
37 assert.deepEqual(eng!.agents.map((a) => a.handle), ["otto"]);
38 assert.equal(qa!.agents.length, 0);
39});
40
41test("without the agents service, no agent is counted", () => {
42 const [eng] = templateListings([template("engineering", "Software Engineer")], null);
43 assert.deepEqual(eng!.agents, []);
44});
45
46test("templates list in the order they come, each a role and never a team", () => {
47 const listed = templateListings([template("a", "A One"), template("b", "B Two")], null);
48 assert.deepEqual(listed.map((l) => l.template.id), ["a", "b"]);
49 for (const { template: t } of listed) assert.ok(!("department" in t) && !("team" in t));
50});
51
52test("a role and its model limits read as words", () => {
53 assert.equal(roleLine({ title: "QA Engineer", display_name: "Margo" }), "QA Engineer · Suggests Margo");
54 assert.equal(routingWords({ floor: null, ceiling: null }), "Any model the work needs");
55 assert.equal(routingWords({ floor: "large", ceiling: null }), "Large models or better");
56 assert.equal(routingWords({ floor: null, ceiling: "large" }), "Up to large models");
57});