mirror of
https://github.com/bitbaum/causius.git
synced 2026-12-04 04:27:36 +01:00
* Build out Causius: case intake, case file, helper marketplace Replace the day-zero page with the product: a landing page, letter intake with env-gated AI analysis, a case view (deadline, checklist, translations, draft reply), browser-only case storage with export/import, and the helper marketplace rules for legal assistants and licensed lawyers. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012EJFFkKhmaVnnH8E3mHnaZ * Put Causius on the fleet's stack and its three planes - AI: replace the hand-rolled single-vendor fetch with @bitbaum/ai-kit complete() over the shared free chain; no pinned model id. Add the fleet's own-model flow (ai-kit byok + probe), key kept in the browser. - Validation with zod, rate limits with limitkit, tests with Vitest. - Identity rendered from the Loki fleet map; ROADMAP.md and CHANGELOG.md as the public record, shown through bip-kit. - Helpers live on OrangeCat as services; OrangeCat and Solon links appear only when the fleet map reports the profiles exist. - Nav contract: routes constant, aria-current, 44px targets. Beta label. - CI and auto-merge from the current site template; TypeScript 6, ESLint 10, Node 24; AGENTS.md from the fleet template. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012EJFFkKhmaVnnH8E3mHnaZ * Speak English, German and French; make intake work end to end - next-intl with locale routing (en unprefixed, /de, /fr), every string in the message catalogues, a parity test, Swiss German spelling. - The analysis is written in the reader's language. - Several pages per letter; photos are shrunk in the browser so a phone picture fits. - The deadline is shown with the sentence it was read from, and the model is told never to compute a date the letter does not state. - /api/health, and the intake page says up front what the free models can do. `pnpm run check:analyze` runs the sample letter through a real model. - A down fleet map no longer stalls on-demand pages. - Refuse the two build scripts next-intl brought, so installs stay clean. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012EJFFkKhmaVnnH8E3mHnaZ --------- Co-authored-by: Claude <noreply@anthropic.com>
93 lines
3.6 KiB
TypeScript
93 lines
3.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { daysUntil, formatDate, parseCase } from "./case";
|
|
import { sampleCase } from "./sample";
|
|
|
|
describe("parseCase", () => {
|
|
it.each(["en", "de", "fr"] as const)("round-trips the exported %s sample unchanged", (locale) => {
|
|
const sample = sampleCase(locale);
|
|
const exported: unknown = JSON.parse(JSON.stringify(sample));
|
|
expect(parseCase(exported)).toEqual(sample);
|
|
});
|
|
|
|
it("keeps the sentence a deadline was read from", () => {
|
|
const c = parseCase({ title: "t", deadline: "2026-03-23", deadlineQuote: " bis am 23. März 2026 " });
|
|
expect(c?.deadlineQuote).toBe("bis am 23. März 2026");
|
|
expect(parseCase({ title: "t", deadlineQuote: 7 })?.deadlineQuote).toBeUndefined();
|
|
});
|
|
|
|
it("refuses anything without a title", () => {
|
|
expect(parseCase(null)).toBeNull();
|
|
expect(parseCase("a letter")).toBeNull();
|
|
expect(parseCase({ summary: "no title" })).toBeNull();
|
|
expect(parseCase({ title: " " })).toBeNull();
|
|
});
|
|
|
|
it("fills what is missing instead of rendering undefined", () => {
|
|
const c = parseCase({ title: "Tax office letter" });
|
|
expect(c).toMatchObject({
|
|
version: 1,
|
|
title: "Tax office letter",
|
|
summary: "",
|
|
asks: [],
|
|
texts: [],
|
|
notes: [],
|
|
recommendedTier: "assistant",
|
|
});
|
|
expect(c?.id).toMatch(/^c_/);
|
|
expect(c?.deadline).toBeUndefined();
|
|
// Unknown stays unknown: the page hides the row instead of printing a filler.
|
|
expect(c?.jurisdiction).toBeUndefined();
|
|
expect(c?.authority).toBeUndefined();
|
|
});
|
|
|
|
it("drops a deadline that is not a real ISO date", () => {
|
|
for (const deadline of ["30.10.2026", "2026-13-45", "soon", 20261030, null]) {
|
|
expect(parseCase({ title: "t", deadline })?.deadline).toBeUndefined();
|
|
}
|
|
expect(parseCase({ title: "t", deadline: "2026-10-30" })?.deadline).toBe("2026-10-30");
|
|
});
|
|
|
|
it("drops bad list members and keeps the good ones", () => {
|
|
const c = parseCase({
|
|
title: "t",
|
|
asks: [{ text: "Send your passport", evidence: ["All pages", 7, ""] }, { text: "" }, "junk", null],
|
|
texts: [{ lang: "de", text: "Guten Tag" }, { lang: "fr" }],
|
|
notes: ["Keep a copy", 3, ""],
|
|
});
|
|
expect(c?.asks).toEqual([
|
|
{ id: "a1", text: "Send your passport", evidence: ["All pages"], done: false },
|
|
]);
|
|
expect(c?.texts).toEqual([{ lang: "de", label: "de", text: "Guten Tag" }]);
|
|
expect(c?.notes).toEqual(["Keep a copy"]);
|
|
});
|
|
|
|
it("does not let an unknown tier through", () => {
|
|
expect(parseCase({ title: "t", recommendedTier: "notary" })?.recommendedTier).toBe("assistant");
|
|
expect(parseCase({ title: "t", recommendedTier: "lawyer" })?.recommendedTier).toBe("lawyer");
|
|
});
|
|
|
|
it("cuts over-long text rather than refusing the case", () => {
|
|
const c = parseCase({ title: "x".repeat(500), summary: "y".repeat(9000) });
|
|
expect(c?.title).toHaveLength(200);
|
|
expect(c?.summary).toHaveLength(3000);
|
|
});
|
|
});
|
|
|
|
describe("dates", () => {
|
|
it("counts whole days to a deadline, negative once passed", () => {
|
|
expect(daysUntil("2026-10-30", "2026-10-10")).toBe(20);
|
|
expect(daysUntil("2026-10-30", "2026-10-30")).toBe(0);
|
|
expect(daysUntil("2026-10-30", "2026-11-02")).toBe(-3);
|
|
});
|
|
|
|
it("formats a date without shifting it across time zones", () => {
|
|
expect(formatDate("2026-10-30")).toBe("30 October 2026");
|
|
expect(formatDate("2026-01-01")).toBe("1 January 2026");
|
|
});
|
|
|
|
it("formats a date in the reader's language", () => {
|
|
expect(formatDate("2026-03-23", "de")).toBe("23. März 2026");
|
|
expect(formatDate("2026-03-23", "fr")).toBe("23 mars 2026");
|
|
});
|
|
});
|