diff --git a/.claude/agents/HEARTBEAT.md b/.claude/agents/HEARTBEAT.md index 1a500fa..d5aa856 100644 --- a/.claude/agents/HEARTBEAT.md +++ b/.claude/agents/HEARTBEAT.md @@ -87,7 +87,7 @@ VALUES ( '752cebdd-6748-4a04-aacd-c7ab0294ef33', 'agent_completion', 'סוכן סיים משימה — נדרשת בדיקה והחלטה על הצעד הבא', - 'pending', + 'queued', 'agent' );" ``` diff --git a/.claude/agents/legal-exporter.md b/.claude/agents/legal-exporter.md index ae43d44..386aac5 100644 --- a/.claude/agents/legal-exporter.md +++ b/.claude/agents/legal-exporter.md @@ -90,7 +90,7 @@ VALUES ( '752cebdd-6748-4a04-aacd-c7ab0294ef33', 'agent_completion', 'מייצא טיוטה סיים משימה — נדרשת בדיקה', - 'pending', 'agent' + 'queued', 'agent' );" ``` diff --git a/.claude/agents/legal-proofreader.md b/.claude/agents/legal-proofreader.md index 4205d7f..9276cf0 100644 --- a/.claude/agents/legal-proofreader.md +++ b/.claude/agents/legal-proofreader.md @@ -116,6 +116,6 @@ VALUES ( '752cebdd-6748-4a04-aacd-c7ab0294ef33', 'agent_completion', 'מגיה מסמכים סיים משימה — נדרשת בדיקה', - 'pending', 'agent' + 'queued', 'agent' );" ``` diff --git a/.claude/agents/legal-qa.md b/.claude/agents/legal-qa.md index c3985b9..7f96336 100644 --- a/.claude/agents/legal-qa.md +++ b/.claude/agents/legal-qa.md @@ -121,6 +121,6 @@ VALUES ( '752cebdd-6748-4a04-aacd-c7ab0294ef33', 'agent_completion', 'בודק איכות סיים משימה — נדרשת בדיקה', - 'pending', 'agent' + 'queued', 'agent' );" ``` diff --git a/.claude/agents/legal-researcher.md b/.claude/agents/legal-researcher.md index 71810d0..4c91199 100644 --- a/.claude/agents/legal-researcher.md +++ b/.claude/agents/legal-researcher.md @@ -110,7 +110,7 @@ VALUES ( '752cebdd-6748-4a04-aacd-c7ab0294ef33', 'agent_completion', 'חוקר תקדימים סיים משימה — נדרשת בדיקה', - 'pending', 'agent' + 'queued', 'agent' );" ``` diff --git a/.claude/agents/legal-writer.md b/.claude/agents/legal-writer.md index 136b113..ee56e39 100644 --- a/.claude/agents/legal-writer.md +++ b/.claude/agents/legal-writer.md @@ -159,7 +159,7 @@ VALUES ( '752cebdd-6748-4a04-aacd-c7ab0294ef33', 'agent_completion', 'כותב החלטה סיים משימה — נדרשת בדיקה', - 'pending', 'agent' + 'queued', 'agent' );" ``` diff --git a/Dockerfile b/Dockerfile index c346aee..861edf8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,7 @@ WORKDIR /app # Install Node.js 20.x RUN apt-get update && apt-get install -y --no-install-recommends \ - curl ca-certificates \ + curl ca-certificates git \ && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ && apt-get install -y --no-install-recommends nodejs \ && rm -rf /var/lib/apt/lists/* diff --git a/mcp-server/src/legal_mcp/tools/cases.py b/mcp-server/src/legal_mcp/tools/cases.py index a5b71cb..9d531a5 100644 --- a/mcp-server/src/legal_mcp/tools/cases.py +++ b/mcp-server/src/legal_mcp/tools/cases.py @@ -106,17 +106,20 @@ async def case_create( notes_file = case_dir / "notes.md" notes_file.write_text(f"# הערות - תיק {case_number}\n\n{notes}\n") - # Initialize git repo - subprocess.run(["git", "init"], cwd=case_dir, capture_output=True) - subprocess.run(["git", "add", "."], cwd=case_dir, capture_output=True) - subprocess.run( - ["git", "commit", "-m", f"אתחול תיק {case_number}: {title}"], - cwd=case_dir, - capture_output=True, - env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local", - "GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local", - "PATH": "/usr/bin:/bin"}, - ) + # Initialize git repo (best-effort) + try: + subprocess.run(["git", "init"], cwd=case_dir, capture_output=True) + subprocess.run(["git", "add", "."], cwd=case_dir, capture_output=True) + subprocess.run( + ["git", "commit", "-m", f"אתחול תיק {case_number}: {title}"], + cwd=case_dir, + capture_output=True, + env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local", + "GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local", + "PATH": "/usr/bin:/bin"}, + ) + except Exception: + pass # git not available — non-critical return json.dumps(case, default=str, ensure_ascii=False, indent=2) @@ -199,20 +202,23 @@ async def case_update( updated = await db.update_case(UUID(case["id"]), **fields) - # Git commit the update - case_dir = config.find_case_dir(case_number) - if case_dir.exists(): - case_json = case_dir / "case.json" - case_json.write_text(json.dumps(updated, default=str, ensure_ascii=False, indent=2)) - subprocess.run(["git", "add", "case.json"], cwd=case_dir, capture_output=True) - subprocess.run( - ["git", "commit", "-m", f"עדכון תיק: {', '.join(fields.keys())}"], - cwd=case_dir, - capture_output=True, - env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local", - "GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local", - "PATH": "/usr/bin:/bin"}, - ) + # Git commit the update (best-effort) + try: + case_dir = config.find_case_dir(case_number) + if case_dir.exists(): + case_json = case_dir / "case.json" + case_json.write_text(json.dumps(updated, default=str, ensure_ascii=False, indent=2)) + subprocess.run(["git", "add", "case.json"], cwd=case_dir, capture_output=True) + subprocess.run( + ["git", "commit", "-m", f"עדכון תיק: {', '.join(fields.keys())}"], + cwd=case_dir, + capture_output=True, + env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local", + "GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local", + "PATH": "/usr/bin:/bin"}, + ) + except Exception: + pass # git not available — non-critical return json.dumps(updated, default=str, ensure_ascii=False, indent=2) diff --git a/mcp-server/src/legal_mcp/tools/documents.py b/mcp-server/src/legal_mcp/tools/documents.py index 258d792..d514144 100644 --- a/mcp-server/src/legal_mcp/tools/documents.py +++ b/mcp-server/src/legal_mcp/tools/documents.py @@ -67,31 +67,34 @@ async def document_upload( await db.update_document(UUID(doc["id"]), doc_type=classified_type) doc["doc_type"] = classified_type - # Git commit - repo_dir = config.find_case_dir(case_number) - if repo_dir.exists(): - subprocess.run(["git", "add", "."], cwd=repo_dir, capture_output=True) - doc_type_hebrew = { - "appeal": "כתב ערר", - "response": "תשובה", - "protocol": "פרוטוקול", - "plan": "תכנית", - "permit": "היתר", - "court_decision": "פסק דין", - "decision": "החלטה", - "appraisal": "שומה", - "objection": "התנגדות", - "exhibit": "נספח", - "reference": "מסמך עזר", - }.get(actual_doc_type, actual_doc_type) - subprocess.run( - ["git", "commit", "-m", f"הוספת {doc_type_hebrew}: {title}"], - cwd=repo_dir, - capture_output=True, - env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local", - "GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local", - "PATH": "/usr/bin:/bin"}, - ) + # Git commit (best-effort — don't fail upload on git errors) + try: + repo_dir = config.find_case_dir(case_number) + if repo_dir.exists(): + subprocess.run(["git", "add", "."], cwd=repo_dir, capture_output=True) + doc_type_hebrew = { + "appeal": "כתב ערר", + "response": "תשובה", + "protocol": "פרוטוקול", + "plan": "תכנית", + "permit": "היתר", + "court_decision": "פסק דין", + "decision": "החלטה", + "appraisal": "שומה", + "objection": "התנגדות", + "exhibit": "נספח", + "reference": "מסמך עזר", + }.get(actual_doc_type, actual_doc_type) + subprocess.run( + ["git", "commit", "-m", f"הוספת {doc_type_hebrew}: {title}"], + cwd=repo_dir, + capture_output=True, + env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local", + "GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local", + "PATH": "/usr/bin:/bin"}, + ) + except Exception: + pass # git not available in container — non-critical return json.dumps({ "document": doc, diff --git a/web/app.py b/web/app.py index d006975..1882ab9 100644 --- a/web/app.py +++ b/web/app.py @@ -2565,25 +2565,28 @@ async def _process_tagged_document(task_id: str, dest: Path, case_number: str, c _progress[task_id] = {"status": "processing", "filename": display_name, "step": "extracting"} result = await processor.process_document(doc_id, case_id) - # Git commit + push - repo_dir = config.find_case_dir(case_number) - if repo_dir.exists(): - env = { - "GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local", - "GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local", - "PATH": "/usr/bin:/bin", - } - doc_type_hebrew = DOC_TYPE_NAMES.get(doc_type, doc_type) - subprocess.run(["git", "add", "."], cwd=repo_dir, capture_output=True) - subprocess.run( - ["git", "commit", "-m", f"הוספת {doc_type_hebrew}: {display_name}"], - cwd=repo_dir, capture_output=True, env=env, - ) - # Try to push to Gitea (non-blocking) - subprocess.run(["git", "push"], cwd=repo_dir, capture_output=True, env={ - **env, - "GIT_TERMINAL_PROMPT": "0", - }) + # Git commit + push (best-effort — don't fail upload on git errors) + try: + repo_dir = config.find_case_dir(case_number) + if repo_dir.exists(): + env = { + "GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local", + "GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local", + "PATH": "/usr/bin:/bin", + } + doc_type_hebrew = DOC_TYPE_NAMES.get(doc_type, doc_type) + subprocess.run(["git", "add", "."], cwd=repo_dir, capture_output=True) + subprocess.run( + ["git", "commit", "-m", f"הוספת {doc_type_hebrew}: {display_name}"], + cwd=repo_dir, capture_output=True, env=env, + ) + # Try to push to Gitea (non-blocking) + subprocess.run(["git", "push"], cwd=repo_dir, capture_output=True, env={ + **env, + "GIT_TERMINAL_PROMPT": "0", + }) + except Exception: + logger.warning("Git commit/push failed for %s (non-critical)", display_name) _progress[task_id] = { "status": "completed", @@ -2821,21 +2824,24 @@ async def _process_case_document(task_id: str, source: Path, req: ClassifyReques _progress[task_id] = {"status": "processing", "filename": req.filename, "step": "extracting"} result = await processor.process_document(UUID(doc["id"]), case_id) - # Git commit - repo_dir = config.find_case_dir(req.case_number) - if repo_dir.exists(): - subprocess.run(["git", "add", "."], cwd=repo_dir, capture_output=True) - doc_type_hebrew = { - "appeal": "כתב ערר", "response": "תשובה", "decision": "החלטה", - "reference": "מסמך עזר", "exhibit": "נספח", - }.get(req.doc_type, req.doc_type) - subprocess.run( - ["git", "commit", "-m", f"הוספת {doc_type_hebrew}: {title}"], - cwd=repo_dir, capture_output=True, - env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local", - "GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local", - "PATH": "/usr/bin:/bin"}, - ) + # Git commit (best-effort) + try: + repo_dir = config.find_case_dir(req.case_number) + if repo_dir.exists(): + subprocess.run(["git", "add", "."], cwd=repo_dir, capture_output=True) + doc_type_hebrew = { + "appeal": "כתב ערר", "response": "תשובה", "decision": "החלטה", + "reference": "מסמך עזר", "exhibit": "נספח", + }.get(req.doc_type, req.doc_type) + subprocess.run( + ["git", "commit", "-m", f"הוספת {doc_type_hebrew}: {title}"], + cwd=repo_dir, capture_output=True, + env={"GIT_AUTHOR_NAME": "Ezer Mishpati", "GIT_AUTHOR_EMAIL": "legal@local", + "GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local", + "PATH": "/usr/bin:/bin"}, + ) + except Exception: + logger.warning("Git commit failed for %s (non-critical)", req.filename) # Remove from uploads source.unlink(missing_ok=True)