Files
loki/scripts/test/verify-project-brief.ts
CatoandClaude Fable 5.1 95c40a9cd8 refactor: rename the product from FleetCrown to Loki (#695)
The product, its assistant, the repo, the host and every unit on the box now
share one name. 638 files, ~3,000 mentions: UI copy, config, env keys
(FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs,
articles, the deploy workflow other repos reuse, and nine file names.

- Three article slugs carried the old name and had been shared; permanent
  redirects keep those links alive (next.config.ts).
- test-no-retired-name.sh now also forbids the old product name across the
  whole repo, so the rename cannot creep back through templates and examples.
- ASSISTANT_STACK collapses the product and the assistant into one entry,
  because they are now the same name.

Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki`
database and role, loki.orangecat.ch (old host 308s to it; /api, /widget,
/embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases.
The Resend sending domain stays fleetcrown.orangecat.ch until the new domain
is verified in DNS.


Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 16:13:10 -07:00

62 lines
2.4 KiB
TypeScript

// One-shot verification of the AI profile pipeline (lib/project-brief) against
// the local dev DB: picks the user's Loki project, runs a real Groq
// extraction from a short brief, applies it, and reads the attrs back.
// Run: npx tsx scripts/test/verify-project-brief.ts
import { config } from "dotenv";
config({ path: ".env.local" });
async function main() {
const { db } = await import("../../src/db");
const { entities, attributes } = await import("../../src/db/schema");
const { and, eq } = await import("drizzle-orm");
const { extractProjectProfile, applyProjectProfile } =
await import("../../src/lib/project-brief");
const [project] = await db
.select({
id: entities.id,
userId: entities.userId,
name: entities.name,
description: entities.description,
})
.from(entities)
.where(and(eq(entities.type, "project"), eq(entities.name, process.argv[2] ?? "loki")))
.limit(1);
if (!project) {
const all = await db
.select({ name: entities.name })
.from(entities)
.where(eq(entities.type, "project"));
throw new Error(`project not found locally. Available: ${all.map((r) => r.name).join(", ")}`);
}
console.log("project:", project.name, project.id);
const brief = `Loki is a life operating system and AI agent fleet commander.
You sign in, register projects, press one play button and all your projects get
built by AI agents without supervision; the same button pauses everything.
It serves builders running many projects at once. Built with Next.js 16,
TypeScript, Tailwind 4, Drizzle, Postgres 17. Currently in production at
loki.orangecat.ch. Next step: make project profiles self-filling from
free-form text and repos so the fleet always has full context.`;
const profile = await extractProjectProfile(project.name, brief);
console.log("extracted:", JSON.stringify(profile, null, 2));
const applied = await applyProjectProfile(project.userId, project.id, profile);
if (!applied) throw new Error("applyProjectProfile returned null (ownership check failed)");
console.log("applied keys:", Object.keys(applied).join(", "));
const rows = await db
.select({ key: attributes.key, value: attributes.value })
.from(attributes)
.where(eq(attributes.entityId, project.id));
console.log("attrs now in DB:");
for (const r of rows) console.log(` ${r.key} = ${r.value.slice(0, 90)}`);
process.exit(0);
}
main().catch((e) => {
console.error("FAIL:", e);
process.exit(1);
});