Add docs, scripts, skills, commands, and taskmaster config to repo
Includes: - docs/: architecture, block-schema, migration-plan, product-specification - scripts/: bidi_table, decompose-decisions, extract-claims, seed-knowledge, etc. - skill-legal-decision/: SKILL.md + references + block-schema - skill-legal-assistant/: SKILL.md - skill-legal-docx/: SKILL.md + references - .claude/commands/: bidi-table skill - .taskmaster/: task config + PRDs - .gitignore: exclude legacy/, kiryat-yearim/, node_modules/, memory/ Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
58
.taskmaster/docs/prd-fixes.txt
Normal file
58
.taskmaster/docs/prd-fixes.txt
Normal file
@@ -0,0 +1,58 @@
|
||||
# תיקוני איפיון מוצר — ממצאי סקירת מומחה
|
||||
|
||||
## 4 ממצאים קריטיים
|
||||
|
||||
### תיקון 1: הוספת שלב 6 (הגהת דפנה) לדרישות הפונקציונליות
|
||||
Priority: critical.
|
||||
שלב 6 חסר מסעיף הדרישות הפונקציונליות. צריך להגדיר: איך דפנה מקבלת את הטיוטה (DOCX), איך מחזירה הערות/תיקונים, מי מעלה את הגרסה הסופית ללולאת הלמידה.
|
||||
|
||||
### תיקון 2: שינוי "אפס הזיות" למנגנון grounding + ולידציה
|
||||
Priority: critical.
|
||||
אף LLM לא יכול להבטיח 0 הזיות. צריך להחליף את הדרישה ב: (1) מנגנון grounding שמקשר כל הפניה למסמך מקור, (2) ולידציה אוטומטית שבודקת כל ציטוט/הפניה מול המסמכים שסופקו, (3) מדד: שיעור הפניות שלא עוברות ולידציה = 0 (לא שאין הזיות, אלא שכל הזיה נתפסת).
|
||||
|
||||
### תיקון 3: הוספת סיכון context window overflow
|
||||
Priority: critical.
|
||||
תיק מורכב עם 50+ מסמכים יחרוג מ-context window. צריך: דרישה למדידת גודל חומרים, אסטרטגיית chunking/summarization, סף התראה.
|
||||
|
||||
### תיקון 4: הגדרה מתמטית של "אחוז שינוי"
|
||||
Priority: critical.
|
||||
צריך להגדיר בדיוק: edit distance על מילים? תווים? סעיפים? מה נספר כ"שינוי"? הגדרה ברורה עם דוגמאות.
|
||||
|
||||
## 9 ממצאים חשובים
|
||||
|
||||
### תיקון 5: הוספת דרישות לבלוקים א-ד ויב
|
||||
Priority: high. בלוקים א-ד (כותרת, הרכב, צדדים) ויב (חתימות) חסרים מהדרישות.
|
||||
|
||||
### תיקון 6: דרישת שמירת מצב ביניים (persistence)
|
||||
Priority: high. מה קורה אם חיים רוצה להמשיך מחר? recovery מנפילה?
|
||||
|
||||
### תיקון 7: תיקון ספירת שלבים בטבלת מעקב
|
||||
Priority: high. טבלה כותבת "7 שלבים" אבל דרישות מכסות רק 6.
|
||||
|
||||
### תיקון 8: הכרה ב-MVP de facto לרישוי והשבחה
|
||||
Priority: high. אין נתוני אימון לפיצויים — צריך להכיר שגרסה ראשונה מכסה רק רישוי+השבחה.
|
||||
|
||||
### תיקון 9: בחינה מחדש של יעד 98%
|
||||
Priority: high. לפי Endsley מומחים תמיד משנים — 98% אולי לא ריאלי מסיבות פסיכולוגיות.
|
||||
|
||||
### תיקון 10: הגדרת מנגנון לולאת למידה
|
||||
Priority: high. מה מעדכנים? fine-tuning? prompt engineering? RAG? few-shot?
|
||||
|
||||
### תיקון 11: הוספת סיכון prompt injection ממסמכי מקור
|
||||
Priority: high. מסמכים מצדדים חיצוניים יכולים להכיל טקסט שמשפיע על ה-LLM.
|
||||
|
||||
### תיקון 12: הוספת מנגנון back-flows (חזרה אחורה בתהליך)
|
||||
Priority: high. מה אם חיים רוצה לשכתב בלוק קודם? מה אם דפנה משנה כיוון?
|
||||
|
||||
### תיקון 13: הוספת שלב QA/ולידציה לפני שליחה לדפנה
|
||||
Priority: high. checklist אוטומטי לפני הפלט הסופי.
|
||||
|
||||
## 7 הערות
|
||||
|
||||
### תיקון 14: ניהול גרסאות של בלוקים
|
||||
### תיקון 15: טיפול באיחוד תיקים (כמו אריאלי 1078+1083)
|
||||
### תיקון 16: תיקון LOA של סיעור מוחות (ב ולא ג)
|
||||
### תיקון 17: סיעור מוחות אופציונלי גם כשיש נימוק
|
||||
### תיקון 18: ניטרליות מבנית (לא רק לקסיקלית)
|
||||
### תיקון 19: מיפוי פרסורמן 4 stages (לא רק LOA)
|
||||
### תיקון 20: דרישת ביצועים per-block וסינכרוני/אסינכרוני
|
||||
46
.taskmaster/docs/prd-paperclip-workflow.txt
Normal file
46
.taskmaster/docs/prd-paperclip-workflow.txt
Normal file
@@ -0,0 +1,46 @@
|
||||
# PRD — אינטגרציית Paperclip AI + תהליך תיק חדש
|
||||
|
||||
## הקשר
|
||||
שתי משימות מחוברות שנגזרות מאיפיון המוצר (docs/product-specification.md) ומניתוח הפלאגין הקיים (/home/chaim/plugin-legal-ai/).
|
||||
|
||||
## משימות
|
||||
|
||||
### משימה: הרחבת DB schema לתהליך מלא
|
||||
Priority: critical. Dependencies: none.
|
||||
הוספת שדות וטבלאות חסרים: direction_doc JSONB ו-outcome_reasoning TEXT בטבלת decisions. הרחבת status בטבלת cases ל-13 ערכים (new, uploading, processing, documents_ready, outcome_set, brainstorming, direction_approved, drafting, qa_review, drafted, exported, reviewed, final). יצירת טבלת qa_results. כל זה ב-db.py כ-migration.
|
||||
|
||||
### משימה: הוספת 5 API endpoints חדשים ב-MCP server
|
||||
Priority: critical. Dependencies: DB schema.
|
||||
POST /api/cases/{case_number}/outcome — הזנת תוצאה + נימוק. GET /api/cases/{case_number}/claims — טענות מחולצות. POST /api/cases/{case_number}/direction — שמירת מסמך כיוון. POST /api/cases/{case_number}/qa — הרצת QA ולידציה. POST /api/cases/{case_number}/learn — הפעלת לולאת למידה.
|
||||
|
||||
### משימה: הוספת 8 tools חדשים לפלאגין Paperclip
|
||||
Priority: high. Dependencies: API endpoints.
|
||||
בקובץ src/worker.ts: legal_document_upload, legal_document_list, legal_document_text, legal_search_case, legal_find_similar, legal_set_outcome, legal_get_claims, legal_style_guide. בקובץ src/legal-api.ts: 8 methods חדשים. בקובץ plugin.json: עדכון רשימת tools.
|
||||
|
||||
### משימה: שיפור status sync ב-Paperclip
|
||||
Priority: high. Dependencies: DB schema.
|
||||
מיפוי 13 סטטוסים (במקום 5→3). הוספת comments מפורטים ב-Paperclip בכל מעבר סטטוס. עדכון job sync-case-status.
|
||||
|
||||
### משימה: כתיבת SOUL.md לסוכנים
|
||||
Priority: high. Dependencies: none.
|
||||
CEO Agent: הוראות בעברית — ניהול תהליך החלטה, מתי להתריע לחיים, מיפוי סטטוסים. Case Analyst Agent: הוראות בעברית — ניתוח מסמכים, חילוץ טענות, חיפוש תקדימים.
|
||||
|
||||
### משימה: יישום skill /brainstorm
|
||||
Priority: critical. Dependencies: API endpoints.
|
||||
Skill חדש ב-Claude Code: מציג טענות מרכזיות (ס-1), מציע 2-3 כיוונים (ס-2), מנהל שיח עם חיים (ס-3), מייצר מסמך כיוון JSON (ס-4), שומר ב-DB. כלל: לא מתחילים דיון בלי כיוון מאושר (ס-5).
|
||||
|
||||
### משימה: שיפור skill /draft-decision לכתיבה בלוק-אחרי-בלוק
|
||||
Priority: critical. Dependencies: brainstorm skill, DB schema.
|
||||
עכשיו הוא stub. צריך: כתיבה בלוק-אחרי-בלוק (ה→ו→ז→ח→ט→י→יא), שמירה ב-DB אחרי כל בלוק (כ-12), recovery ממצב שנפל (כ-13), חזרה אחורה (כ-14). בלוק י: CREAC + Opus + thinking + מסמך כיוון. פרמטרי עיבוד (temperature, model) לפי block-schema.
|
||||
|
||||
### משימה: יישום skill /qa-validate
|
||||
Priority: critical. Dependencies: draft-decision.
|
||||
Skill חדש: grounding check (כל הפניה מול מסמכים), מענה לכל טענה, רקע ניטרלי, משקלות בטווח, מספור רציף, הגדרות להלן. אם נכשל — חוסם ייצוא. דוח שגיאות מפורט.
|
||||
|
||||
### משימה: אינטגרציה E2E וחיבור Paperclip events
|
||||
Priority: high. Dependencies: all skills.
|
||||
חיבור Paperclip events ל-Claude Code (trigger כתיבה דרך issue comment). E2E test על תיק הכט: העלאת חומרים → הזנת תוצאה (דחייה) → כתיבה → QA → DOCX. השוואה להחלטה הסופית.
|
||||
|
||||
### משימה: מבחן הסמכה
|
||||
Priority: critical. Dependencies: E2E integration.
|
||||
שלב ב מסעיף 8 באיפיון: המערכת כותבת החלטה לתיק שכבר יש לו החלטה סופית. השוואת טיוטה להחלטה — פער ≤10%. שלב ג: תיק חי — דפנה בודקת.
|
||||
47
.taskmaster/docs/prd-phase2.txt
Normal file
47
.taskmaster/docs/prd-phase2.txt
Normal file
@@ -0,0 +1,47 @@
|
||||
# PRD Phase 2 — משימות חסרות שנלמדו במהלך ההקמה
|
||||
|
||||
## הקשר
|
||||
המשימות הבאות חסרות ב-TaskMaster הנוכחי. חלקן כבר בוצעו (צריך לסמן done), חלקן עתידיות.
|
||||
|
||||
## משימות שכבר בוצעו (לתיעוד בלבד)
|
||||
|
||||
### משימה: הקמת תשתית DB
|
||||
16 טבלאות ב-4 שכבות (Core, Decision, Knowledge, RAG) + טבלת appeal_type_rules + טבלת decision_definitions. כולל pgvector, indexes, migrations. סטטוס: done.
|
||||
|
||||
### משימה: ייבוא ידע ראשוני מ-vault
|
||||
75 רשומות: 15 לקחים, 44 ביטויי מעבר, 9 תקדימים (הורחב ל-49), 7 הוראות חוק. סקריפטים: seed-knowledge.py, seed-appeals.py. סטטוס: done.
|
||||
|
||||
### משימה: ייבוא 20 תיקי ערר
|
||||
מטאדטה של 20 תיקים מהvault (3 פעילים, 17 ארכיון). כולל appeal_type classification. סטטוס: done.
|
||||
|
||||
### משימה: הפרדת סוגי עררים ב-DB
|
||||
הוספת appeal_type לטבלאות cases, decisions, lessons_learned, transition_phrases. יצירת appeal_type_rules עם 30 כללים + 23 יחסי זהב. כולל הבדלי טון, מבנה, משקלות. סטטוס: done.
|
||||
|
||||
### משימה: התקנת שרתי MCP
|
||||
Infisical MCP (גלובלי), TaskMaster AI (פרויקט). סטטוס: done.
|
||||
|
||||
## משימות עתידיות חדשות
|
||||
|
||||
### משימה: ייבוא חומרי מקור מלאים
|
||||
Priority: medium. Dependencies: task 2.
|
||||
ייבוא כל חומרי המקור מה-vault ל-DB — לא רק החלטות סופיות אלא גם כתבי ערר, כתבי תשובה, פרוטוקולים, שומות, חוות דעת. לכל 20 תיקים. כולל חילוץ טקסט מ-MD שכבר קיימים ו-OCR ל-PDF סרוקים. ~444 קבצים סה"כ.
|
||||
|
||||
### משימה: חשיפת פונקציות חיפוש וולידציה כ-MCP tools
|
||||
Priority: high. Dependencies: tasks 7, 9.
|
||||
להוסיף ל-MCP server tools חדשים: search_precedents (חיפוש סמנטי בפסיקה והחלטות), validate_decision (בדיקת החלטה מול כללי block-schema), get_golden_ratios (קבלת יחסי זהב לפי סוג ערר ותוצאה), get_appeal_type_rules (כללים לפי סוג). כולל סינון לפי appeal_type.
|
||||
|
||||
### משימה: יישום סגנון כתיבה מותאם לסוג ערר
|
||||
Priority: high. Dependencies: appeal_type_rules.
|
||||
לוודא שכל כלי הכתיבה (draft_section ב-MCP) משתמש ב-appeal_type_rules כדי להתאים: טון (חם/קר), מבנה פתיחה (רחב/ישיר), מספור (כותרות/אותיות), פתיחת דיון (שכבות/נושאי/ישיר), סיום (חם/יבש), משקלות בלוקים.
|
||||
|
||||
### משימה: עדכון PRD ו-CLAUDE.md עם מצב נוכחי
|
||||
Priority: low.
|
||||
לעדכן את CLAUDE.md עם: 18 טבלאות ב-DB, 7 החלטות מפורקות, 212 טענות, 49 פסיקות, 131 embeddings, 30 כללי סוג ערר, 23 יחסי זהב. לעדכן את docs/architecture.md עם הטבלאות והסקריפטים החדשים.
|
||||
|
||||
### משימה: שיפור parser להחלטות עם כיסוי נמוך
|
||||
Priority: medium. Dependencies: task 4.
|
||||
שטרית (167% חפיפה) ומבורך (133%) מראים חפיפה בין בלוקים. צריך לשפר את decompose-decisions-v2.py: טיפול בחפיפה, זיהוי טוב יותר של גבולות בלוקים כשאין כותרות מפורשות, הוספת סוג ערר פיצויים (9xxx) ל-parser.
|
||||
|
||||
### משימה: Gitea — push קוד לrepository
|
||||
Priority: medium. Dependencies: none.
|
||||
לדחוף את כל הקוד (scripts, MCP server, docs) ל-Gitea repository שכבר מוגדר ב-gitea.nautilus.marcusgroup.org/Chaim/ezer-mishpati. כולל .gitignore מתאים (לא legacy vault, לא .env, לא node_modules).
|
||||
132
.taskmaster/docs/prd.txt
Normal file
132
.taskmaster/docs/prd.txt
Normal file
@@ -0,0 +1,132 @@
|
||||
# PRD — Legal Decision Assistant (עוזר משפטי)
|
||||
|
||||
## Project Overview
|
||||
|
||||
AI-powered system to assist the Chair of the Jerusalem District Planning Appeals Committee (Adv. Dafna Tamir) in writing formal legal decisions. The system migrates knowledge from a legacy Obsidian vault to a structured PostgreSQL + pgvector + n8n platform on the Nautilus server.
|
||||
|
||||
## Current State (What Already Exists)
|
||||
|
||||
### Infrastructure (Completed)
|
||||
- PostgreSQL with pgvector on Nautilus (legal-ai-postgres)
|
||||
- 16 database tables in 4 layers: Core, Decision, Knowledge, RAG
|
||||
- MCP server (legal-ai) with document upload, case management, search, style analysis
|
||||
- Web upload interface (ezer-mishpati-web) at legal-ai.nautilus.marcusgroup.org
|
||||
- Voyage AI embeddings (voyage-3-large, dim=1024) — 323 existing embeddings from 4 training decisions
|
||||
- Coolify, Gitea, Redis, n8n (empty), Infisical on Nautilus
|
||||
|
||||
### Data Already Imported
|
||||
- 19 appeal cases with basic metadata (case numbers, titles, parties, addresses, status)
|
||||
- 15 lessons learned from 3 analyzed decisions (הכט, בית הכרם, קרית יערים)
|
||||
- 44 transition phrases from Dafna's writing style
|
||||
- 9 case law references (precedents)
|
||||
- 7 statutory provisions
|
||||
- 4 training decisions in style corpus with 90 style patterns
|
||||
|
||||
### Legacy Vault (Read-Only Reference)
|
||||
Located at legacy/dafna-tamir/. Contains:
|
||||
- 16 archived case folders with source materials (~280 documents total)
|
||||
- 3 active case folders
|
||||
- 9 completed decisions (PDF/DOCX)
|
||||
- Original SKILL.md style guide
|
||||
- Original Claude Code skills
|
||||
|
||||
## What Needs to Be Done
|
||||
|
||||
### Phase 1: Full Case Audit (Priority: HIGH)
|
||||
Systematically audit all 19 case folders in the legacy vault:
|
||||
- For each case folder: list every document, classify by type (appeal/response/decision/exhibit/protocol/expert-opinion), record dates and page counts
|
||||
- Identify completed decisions vs. in-progress vs. not-started
|
||||
- Identify gaps (missing documents, incomplete metadata)
|
||||
- Produce audit report per case
|
||||
|
||||
### Phase 2: Document Import (Priority: HIGH)
|
||||
Import all documents from legacy vault to the database:
|
||||
- Register each document in the `documents` table with correct case_id, doc_type, title, file_path
|
||||
- Track which documents have been imported vs. pending
|
||||
- Priority: completed cases first (הכט, בית הכרם, אפרים אבי, etc.)
|
||||
|
||||
### Phase 3: Text Extraction (Priority: HIGH)
|
||||
Extract text from all imported documents:
|
||||
- PDF extraction using PyMuPDF (already in MCP server dependencies)
|
||||
- DOCX extraction
|
||||
- Hebrew OCR for scanned PDFs (Claude Vision or Tesseract)
|
||||
- Store extracted text in documents.extracted_text
|
||||
- Update extraction_status for each document
|
||||
|
||||
### Phase 4: Decision Decomposition (Priority: HIGH)
|
||||
Parse the 9 completed decisions into the 12-block structure:
|
||||
- For each completed decision: create a `decisions` record
|
||||
- Identify and extract each of the 12 blocks (alef through yod-bet)
|
||||
- Store blocks in `decision_blocks` with correct block_id, content, word counts, weights
|
||||
- Extract individual paragraphs to `decision_paragraphs` with paragraph numbers
|
||||
- Track citations within paragraphs (case law references)
|
||||
- This is critical training data for the system
|
||||
|
||||
### Phase 5: Claims Extraction (Priority: MEDIUM)
|
||||
Extract party claims from appeal documents and responses:
|
||||
- Parse appeal letters (כתבי ערר) to extract appellant claims
|
||||
- Parse responses (כתבי תשובה) to extract respondent/committee claims
|
||||
- Store in `claims` table with party_role, claim_text, source_document
|
||||
- Link claims to paragraphs in discussion blocks where they are addressed (addressed_in_paragraph)
|
||||
|
||||
### Phase 6: Embeddings & RAG (Priority: MEDIUM)
|
||||
Generate embeddings for all extracted content:
|
||||
- Chunk extracted document text (600 tokens, 100 overlap — already configured)
|
||||
- Generate Voyage embeddings for document chunks
|
||||
- Generate embeddings for decision paragraphs → paragraph_embeddings
|
||||
- Generate embeddings for case law summaries → case_law_embeddings
|
||||
- Build semantic search functions in MCP server
|
||||
- Test: "find similar precedents for this case"
|
||||
|
||||
### Phase 7: n8n Workflow Automation (Priority: LOW)
|
||||
Create automated workflows:
|
||||
- Document upload → classify document type → store in DB → generate embeddings
|
||||
- New appeal creation → auto-create 12-block structure → generate DOCX template
|
||||
- Precedent search → RAG query → return ranked results
|
||||
- Draft validation → check against block-schema constraints
|
||||
|
||||
### Phase 8: Enhanced Web UI (Priority: LOW)
|
||||
Extend ezer-mishpati-web:
|
||||
- Case management dashboard (list all cases, status, documents)
|
||||
- Decision writing interface (block-by-block with live preview)
|
||||
- Precedent search interface with semantic results
|
||||
- Style guide reference panel
|
||||
- DOCX export from decision blocks
|
||||
|
||||
## Technical Architecture
|
||||
|
||||
### Database: 4 Layers, 16 Tables
|
||||
Layer 1 (Core): cases, documents, document_chunks, style_corpus, style_patterns
|
||||
Layer 2 (Decision): decisions, decision_blocks, decision_paragraphs, claims
|
||||
Layer 3 (Knowledge): case_law, case_law_citations, statutory_provisions, transition_phrases, lessons_learned
|
||||
Layer 4 (RAG): paragraph_embeddings, case_law_embeddings
|
||||
|
||||
### Key Design Decisions
|
||||
- Embedding model: Voyage voyage-3-large (1024 dimensions)
|
||||
- Chunk size: 600 tokens with 100 overlap
|
||||
- Decision structure: 12 blocks based on CREAC/DITA/Akoma Ntoso/Federal Judicial Center
|
||||
- All Hebrew content — RTL support required in DOCX export
|
||||
- Style guide: SKILL.md (Dafna's writing patterns, tone per appeal type, transition phrases)
|
||||
|
||||
### MCP Server Stack
|
||||
- Python asyncpg for PostgreSQL
|
||||
- FastMCP for tool registration
|
||||
- PyMuPDF for PDF extraction
|
||||
- Anthropic API for Claude Vision OCR (scanned PDFs)
|
||||
|
||||
## Critical Rules
|
||||
1. "Judge Test" — every decision readable by a judge unfamiliar with the case
|
||||
2. "Neutral Background" — Block ו contains only objective facts, no party quotes or value judgments
|
||||
3. "No Duplication" — Block י references previous blocks, doesn't repeat them
|
||||
4. "Original Claims Only" — Block ז uses only original appeal/response documents; supplements go to Block ח
|
||||
5. 12-Block Architecture — see docs/block-schema.md for full specification
|
||||
6. Work methodically — audit before import, validate after each step, no shortcuts
|
||||
|
||||
## File Locations
|
||||
- Project root: /home/chaim/legal-ai/
|
||||
- Legacy vault: legacy/dafna-tamir/ (read-only)
|
||||
- MCP server: mcp-server/src/legal_mcp/
|
||||
- Documentation: docs/ (architecture.md, block-schema.md, migration-plan.md)
|
||||
- Scripts: scripts/ (seed-knowledge.py, seed-appeals.py)
|
||||
- Style guide: skill-legal-decision/SKILL.md
|
||||
- Lessons: memory/legal-decision-lessons.md
|
||||
Reference in New Issue
Block a user