Files
loki/scripts/test/project-display.ts
T
CatoandClaude Opus 5.5 921081d51e fix(projects): the header says what the project is, and one door takes it public (#915)
Found on Skif's page, live (2026-09-25):
- The headline read "…freedom. From the owner: Who is this for, and who
  pays for it? Year one pays per booking…". The interview appends the
  owner's answers to the description ON PURPOSE (kickoff, dispatch and
  search read the brief), but header, project row, public profile and the
  OrangeCat listing showed the transcript. projectHeadline() cuts at the
  brief heading for display surfaces only; agent briefs keep it all.
- The action row laid four ways of going public (List publicly, Publish,
  Govern, Share) beside Live and Repository with nothing saying how they
  differ. They are now one "Share & publish" door with a line each. The
  "Live site set" chip went (the Live link says it, and does something).
- BRIEF_HEADING has one home (project-display) and the interview imports
  it, so the dependency stays one-way.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 08:31:56 -07:00

95 lines
3.5 KiB
TypeScript

import assert from "node:assert/strict";
import { mergeInterviewIntoDescription } from "@/lib/project-interview";
import { PROJECT_ATTR } from "@/config/project-attrs";
import {
answer,
cleanDescription,
projectHeadline,
isPublicTestArtifact,
publicHeroNote,
summarizeDescription,
} from "../../src/lib/project-display";
assert.equal(cleanDescription("Local repository imported from loki-ui"), null);
assert.equal(
cleanDescription("A weatherproof capsule you leave somewhere."),
"A weatherproof capsule you leave somewhere.",
);
assert.equal(isPublicTestArtifact("smoke-1783188931860-gh"), true);
assert.equal(isPublicTestArtifact("orangecat"), false);
const dumpAfterPitch =
"Life OS + AI agent fleet command center. MUTUAL DOGFOOD WITH ORANGECAT: KNOWN BUG — v1 entity-create from bearer-token callers hits RLS 42501.";
const pitch = publicHeroNote(dumpAfterPitch);
assert.ok(pitch);
assert.ok(!/known bug|mutual dogfood|42501/i.test(pitch), pitch);
const dumpFirst =
"KNOWN BUG — v1 entity-create hits RLS 42501 and the ORANGECAT_WEBHOOK_SECRET is unset.";
assert.equal(publicHeroNote(dumpFirst), null, "a dump that starts as a dump stays hidden");
const short = "Zeitkastli is a weatherproof capsule you leave somewhere.";
assert.equal(publicHeroNote(short), short);
const essay =
"Prime tower is a project generated by Loki, a command center for AI agent fleets, using Next.js, Tailwind CSS, and TypeScript. Extra sentences should not reach the hero.";
const summarized = publicHeroNote(essay);
assert.ok(summarized);
assert.ok(summarized!.length <= 80, summarized);
assert.equal(summarized, summarizeDescription(essay, 72));
// A phone report from 2026-08-18: "Suggested next (profile): Keep
// projects/<name>.md accu…" — an enrichment template's own placeholder,
// leaked verbatim as if it were a real next step.
assert.equal(
answer("Keep projects/<name>.md accurate and current."),
null,
"an unsubstituted <name> placeholder is not a real answer",
);
assert.equal(
answer("Wire up the <repo> CI badge"),
null,
"any bare <word> placeholder, not just <name>",
);
assert.equal(
answer("Ship the parser rewrite for datacat."),
"Ship the parser rewrite for datacat.",
"real prose with no placeholder passes through unchanged",
);
assert.equal(
answer("Support generics like List<T> in the parser"),
"Support generics like List<T> in the parser",
"a real generic-type mention is not mistaken for a placeholder (no bare <word>)",
);
// A header shows what the project IS, not the owner's interview transcript.
// Skif, 2026-09-25: "…freedom. From the owner: Who is this for, and who pays…"
const withBrief = mergeInterviewIntoDescription(
"Holistic safety for people and the places they live.",
{ [PROJECT_ATTR.CUSTOMERS]: "People in Zürich who want a calm person with them" },
);
assert.match(withBrief, /From the owner:/, "fixture: the brief really is appended");
assert.equal(
projectHeadline(withBrief),
"Holistic safety for people and the places they live.",
"the headline stops before the owner's answers",
);
assert.equal(
projectHeadline("Just a line."),
"Just a line.",
"no brief: the description is the headline",
);
assert.match(
projectHeadline(mergeInterviewIntoDescription("", { [PROJECT_ATTR.CUSTOMERS]: "Cafés" })) ?? "",
/Cafés/,
"only a brief: show it rather than nothing",
);
assert.equal(
projectHeadline("Local repository imported from loki-ui"),
null,
"placeholders stay hidden",
);
console.log("✓ project-display tests passed");