Commit Graph
19 Commits
Author SHA1 Message Date
mstfyldzandClaude Sonnet 5 982f908bf9 feat: persist generated petition drafts
generateDraft now inserts into a new drafts table (case_id, content,
petition_type, template_id) so drafts survive navigating away, and
show up in both the "Dilekçelerim" list and the originating case's own
"Dilekçeler" section. Read/update/delete go straight through Supabase
from the frontend (same pattern as events/clients).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 22:15:59 +03:00
mstfyldzandClaude Sonnet 5 2c28cdbf9e fix: forbid markdown formatting in AI-generated petition drafts
The draft prompt didn't say anything about output format, so the model
would sometimes emit **bold**/## headers like it does elsewhere -
wrong for a document meant to go straight into a court filing. Now
explicitly instructed to use plain text with conventional Turkish
petition section labels (AÇIKLAMALAR:, SONUÇ VE İSTEM: etc.) instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 22:05:37 +03:00
mstfyldzandClaude Sonnet 5 79b2bad396 fix: never auto-rename real case files from chat's first-message title
chatMessage() was auto-generating and overwriting cases.title from the
first chat message for ANY case_id, including real UYAP-imported dava
dosyaları (kind='case') — not just the chat-only "Yeni Sohbet" threads
(kind='chat') this was built for. Asking a real case a single question
in Sohbet silently destroyed its court-derived title. Now gated on
kind === 'chat'.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 20:25:35 +03:00
mstfyldzandClaude Sonnet 5 fa01432ffe feat: use firm's own templates as style guide for AI-drafted petitions
Belge Şablonları uploads now also get extracted_text (same OCR/office
pipeline as documents), and a new POST /api/drafting/generate builds
a real AI draft from the case's actual data (title, UYAP parties,
latest Dosya Özeti) — if the lawyer picks one of their own templates,
its extracted text is passed as a style/format reference only (the
prompt explicitly forbids copying the template's old case facts).
Dilekçe Hazırlama no longer fakes a draft with setTimeout.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 20:20:47 +03:00
mstfyldzandClaude Sonnet 5 50f6cbb1b2 feat: narrative "Dosya Özeti" report instead of field-by-field JSON
summarizeCase now produces a full Markdown narrative report (Olayın
Özeti, Yargılama Süreci ve Kararlar, Taraf İddia/Savunmaları, Önemli
Bulgular ve Belgeler, Sonuç) instead of short structured fields - the
iddianame pre-analysis (when found) still runs first and is fed in as
context. The raw AI text is stored as {ozet: string} rather than
JSON-parsed, since asking the model to escape a multi-paragraph report
inside JSON was fragile.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 20:09:31 +03:00
mstfyldzandClaude Sonnet 5 c939dcf564 feat: iddianame-first case summary + remove hardcoded AI endpoint
- summarizeCase: if an iddianame is among the case's documents, run a
  narrow first-pass analysis on it alone (isnatEdilenSuc, iddiaOzeti,
  onemliTarihler), then feed that as context into the general
  case-wide evaluation instead of treating every document equally.
- ANALYSIS_SYSTEM_PROMPT no longer asks the AI to guess "taraflar" -
  that now comes from real UYAP data (cases.parties) instead.
- Removed the hardcoded RunPod proxy URL fallback from every call
  site (document/chat/precedent controllers + lib/openai.ts) - it was
  a real infra endpoint checked into source. New lib/aiConfig.ts
  throws if RUNPOD_API_BASE_URL isn't set rather than silently
  falling back to it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 20:00:06 +03:00
mstfyldzandClaude Sonnet 5 af5a03db92 feat: add template upload/download/delete endpoints
Belge Şablonları now stores real files: POST /api/templates/upload
(multer -> Supabase Storage under templates/<user>/, then a templates
row), GET /api/templates/:id/download-url (short-lived signed URL),
and DELETE /api/templates/:id. Mounted at /api/templates.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 19:50:46 +03:00
mstfyldzandClaude Sonnet 5 99d4d770d5 feat: add POST /api/cases/parties to store UYAP taraf bilgileri
The UYAP extension now captures the davaci/davali/sanik + vekil data
from the "Taraf Bilgileri" tab and sends it once per case. This
endpoint finds/creates the matching case by title (same lookup used
by registerLocalDocument, now shared via lib/caseLookup.ts) and stores
it in a new cases.parties column - a much more reliable source for
the case detail screen's "Taraflar" info than the AI's own guess from
OCR'd document text.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 19:29:53 +03:00
mstfyldzandClaude Sonnet 5 9f5c5c1e45 feat: add case-level AI summary endpoint
POST /api/cases/:caseId/summarize combines extracted text from all of
a case's documents and runs the existing AI analysis prompt, storing
the result as a case-level analysis (document_id: null). Powers the
"Özet Hazırla" button on the case detail screen.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 16:14:41 +03:00
mstfyldzandClaude Sonnet 5 5ddf6ce0cf feat: distinguish chat-only cases from real case files via kind column
New chat threads created from the Sohbet screen were creating rows in
the same cases table that Dava Dosyaları lists, so every new chat
showed up there too. createCase now accepts an optional kind
('case'|'chat', default 'case') so chat-only threads can be excluded.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 12:09:32 +03:00
mstfyldz 67b0398b8c feat: add POST /api/documents/register-local for extension import
Accepts pre-extracted text (no raw file) from the AyrisLegal Electron
app's local OCR pipeline, matches/creates a case by title, and runs
the existing AI analysis flow. Also fixes a bug in uploadDocument:
officeparser@7.x's parseOffice() now returns a result object with
.toText() instead of a plain string, which was breaking PDF/DOCX
manual uploads.
2026-08-09 11:26:36 +03:00
mstfyldz d213d68e0f feat: add POST /api/precedent-analysis for research "Analiz modu"
Takes the user's described situation plus the top search results and
asks the AI model for a short legal assessment. Auth-protected since
it's a paid AI call.
2026-08-09 10:47:59 +03:00
mstfyldz 0e40aaef96 feat: add case creation endpoint and auto-title from first message
POST /api/cases lets the frontend actually create a new dava dosyası
(no working "Yeni Dosya" flow existed before). chatMessage now
generates a short title from a case's first message (like Claude/
ChatGPT auto-titling) and renames the case, returned as `newTitle`.
2026-08-09 10:34:55 +03:00
mstfyldz 7b354d4f96 feat: add DELETE /api/cases/:caseId to fully delete a case
Chat panel's trash icon should remove the whole case (not just clear
its chat history) — documents/analyses/chat_messages cascade-delete
via the existing ON DELETE CASCADE foreign keys.
2026-08-09 10:26:36 +03:00
mstfyldz 0831ebb25b feat: add DELETE /api/chat/:caseId to clear a case's chat history
Frontend's chat history trash icon was calling this endpoint but it
didn't exist yet, causing a JSON-parse error on the default 404 page.

Also renames the LegalOS health-check message to AyrisLegal.
2026-08-09 10:09:15 +03:00
mstfyldz b030bdaa60 fix: allow case-less ("general") chat without ownership check
requireAuth treated every chat caseId as a real cases row and rejected
"general" (the no-file chat sentinel) with 403. general chat now skips
the ownership check and is answered without touching chat_messages,
since that table's case_id is a NOT NULL FK to cases.
2026-08-09 01:52:53 +03:00
mstfyldz afbfb413ce fix: set trust proxy for rate limiter 2026-08-08 17:48:45 +03:00
mstfyldz 633f66b09b Fix TypeScript error for officeparser 2026-08-08 17:22:39 +03:00
mstfyldz df70520ede Initial commit 2026-08-08 17:19:28 +03:00