Files
loki/scripts/test/inject-prompt.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

45 lines
1.7 KiB
TypeScript

// Verify cloud-safe inject prompt assembly includes project context markers.
// Run: npx tsx scripts/test/inject-prompt.ts
import { config } from "dotenv";
config({ path: ".env.local" });
async function main() {
const { db } = await import("../../src/db");
const { entities } = await import("../../src/db/schema");
const { eq, and } = await import("drizzle-orm");
const { assembleInjectPrompt } = await import("../../src/lib/inject-prompt");
const [project] = await db
.select({ id: entities.id, userId: entities.userId, name: entities.name })
.from(entities)
.where(and(eq(entities.type, "project"), eq(entities.name, process.argv[2] ?? "loki")))
.limit(1);
if (!project) throw new Error("No project found — pass name as argv[2]");
const result = await assembleInjectPrompt({
userId: project.userId,
projectKey: project.name,
projectPath: `/home/g/dev/${project.name}`,
projectId: project.id,
adapter: "claude",
promptKey: "next_best",
});
if (!result.ok) throw new Error(`assemble failed: ${result.error}`);
if (!result.prompt.includes("Project context & goals")) {
throw new Error("assembled prompt missing project context block");
}
if (result.prompt.includes("next_best") && result.prompt.length < 200) {
throw new Error("assembled prompt looks like a bare promptKey, not a full template");
}
console.log("OK — inject prompt assembly");
console.log("label:", result.promptLabel);
console.log("length:", result.prompt.length);
console.log("preview:", result.prompt.slice(0, 280).replace(/\n/g, " "));
process.exit(0);
}
main().catch((e) => {
console.error("FAIL:", e);
process.exit(1);
});