CSlawyer1985/legal-skillhub / skills/appeal-docs-generator
appeal-docs-generator
Verified民事二审上诉文本成套生成技能。上传一审判决书后,以民诉法为尺子逐条审查原审判决是否错误(期限/主体程序/诉请判项比对/三段论/说理/新要素六诊),结合元典连接器检索现行有效法条与类案,并做一次「当事人是否已逐条确认事实认定错误、有无新证据」的事实核对互动,最终一次生成民事上诉状、二审证据清单、支持上诉请求的法条与类案检索报告、二审授权委托书、所函、二审接待笔录、待确认事实清单等全套文本。上诉状严格套用德恒格式母版(黑体18pt居中标题/仿宋14pt正文/1.5倍行距),格式100%保留。另提供 scan 轻出口,只做上诉可行性评估与上诉费测算,不出全套文书。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 25.4 KB |
| _meta.json | config | 114 B |
| references/templates-b64.json | config | 148.9 KB |
| references/yuandian_tools_guide.md | markdown | 2.2 KB |
| references/上诉状填充字段表.md | markdown | 4.6 KB |
| references/二审风险告知要点.md | markdown | 2.2 KB |
| references/元典检索姿势.md | markdown | 4.1 KB |
| references/判决书解剖清单.md | markdown | 8.4 KB |
| references/当事人事实核对清单.md | markdown | 4.0 KB |
| references/所函模板.md | markdown | 1.2 KB |
| references/授权委托书模板.md | markdown | 1.7 KB |
| references/接待笔录模板.md | markdown | 4.1 KB |
| references/文件清单及盖章指引模板.md | markdown | 3.3 KB |
| references/检索报告模板.md | markdown | 3.1 KB |
| references/模板与排版规范.md | markdown | 5.5 KB |
| references/民诉法审查尺子表.md | markdown | 9.1 KB |
| scripts/appeal_fee_calc.py | script | 6.3 KB |
| scripts/build_pending_facts_docx.py | script | 6.9 KB |
| scripts/deadline_check.py | script | 5.0 KB |
| scripts/fill_appeal_docx.py | script | 9.8 KB |
| scripts/generate_file_list.py | script | 7.8 KB |
| scripts/render_docx.py | script | 8.6 KB |
| scripts/restore_templates.py | script | 5.7 KB |
scripts/render_docx.py
View on GitHub# Maintained by Lu Lingyan, Deheng (Wuxi) Law Firm.
#!/usr/bin/env python3
"""
诉讼文书模板渲染引擎 v2
读取 YAML 格式模板 → 解析格式规则 → 替换变量 → 生成 .docx
"""
import re, os, yaml, sys
from pathlib import Path
from datetime import datetime
from docx import Document
from docx.shared import Cm, Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.oxml.ns import qn
# ========================= 格式解析 =========================
def parse_template(md_path):
with open(md_path, "r", encoding="utf-8") as f:
content = f.read()
# 跳过开头的 HTML 注释(如 <!-- Maintained by ... -->),避免其位于文件最前时
# 导致 YAML frontmatter 的 `---` 不在行首而无法解析
m_pre = re.match(r'^\s*<!--.*?-->\s*', content, re.DOTALL)
if m_pre:
content = content[m_pre.end():]
# 分离 frontmatter 和 body
m = re.match(r'^---\s*\n(.*?)\n---\s*\n(.*)', content, re.DOTALL)
if not m:
raise ValueError(f"模板缺少 YAML frontmatter: {md_path}")
config = yaml.safe_load(m.group(1))
body = m.group(2)
return config, body
def parse_units(config):
"""将 pt、cm 等字符串转为 Pt/Cm 对象"""
for section in ["styles"]:
if section not in config:
continue
for key, style in config[section].items():
if isinstance(style, dict):
for prop in ["size", "space_before", "space_after", "gap_before"]:
if prop in style and isinstance(style[prop], str):
val = style[prop]
if "cm" in val:
style[prop] = Cm(float(val.replace("cm", "")))
elif "pt" in val:
style[prop] = Pt(float(val.replace("pt", "")))
if "indent" in style and isinstance(style["indent"], str):
style["indent"] = Pt(float(style["indent"].replace("pt", "")))
return config
# ========================= 渲染引擎 =========================
def render_docx(config, body, variables, output_path):
"""根据模板渲染生成 Word 文档"""
page = config.get("page", {})
styles = config.get("styles", {})
doc = Document()
section = doc.sections[0]
_apply_page(section, page)
# 获取样式定义
style_h1 = styles.get("#", {})
style_h2 = styles.get("##", {})
style_body = styles.get("body", {})
style_sign = styles.get("sign", {})
style_date = styles.get("date", {})
style_note = styles.get("note", {})
# "此致" 样式 = body + gap_before
style_cizhi = style_body.copy()
if "cizhi" in styles:
style_cizhi.update({k: v for k, v in styles["cizhi"].items() if k != "from"})
# 内联样式标签
INLINE_TAGS = {
"meta": "meta",
"qa_gap": "qa_gap",
"sign": "sign",
"date": "date",
"note": "note",
"court": "court",
"center": "center",
}
lines = body.strip().split("\n")
for line in lines:
stripped = line.strip()
# 空行 → 跳过
if not stripped:
continue
# 分隔线 --- → 跳过
if stripped == "---":
continue
# 检测内联样式标签 [tag]
inline_style = None
tag_content = stripped
for tag in INLINE_TAGS:
if stripped.startswith(f"[{tag}]"):
inline_style = tag
tag_content = stripped[len(f"[{tag}]"):].strip()
break
# 变量替换
text = _sub_vars(tag_content, variables)
# 按内联标签分发
if inline_style == "meta":
_add_para(doc, text, styles.get("meta", style_body), indent=False)
elif inline_style == "qa_gap":
_add_para(doc, "", styles.get("qa_gap", {}), indent=False)
elif inline_style == "sign":
_add_para(doc, text, style_sign)
elif inline_style == "date":
year = variables.get("year", datetime.now().year)
tmpl = style_date.get("template", "{year}年 月 日")
_add_para(doc, tmpl.format(year=year), style_date)
elif inline_style == "note":
_add_para(doc, text, style_note)
elif inline_style == "court":
_add_para(doc, text, styles.get("court", style_body), indent=False)
elif inline_style == "center":
_add_para(doc, text,
styles.get("center", {"font": "宋体", "size": Pt(14),
"align": "center", "indent": False}),
indent=False)
# 标题 #
elif stripped.startswith("# ") and not stripped.startswith("## "):
_add_para(doc, text[2:], style_h1)
# 段落标题 ##
elif stripped.startswith("## "):
_add_para(doc, text[3:], style_h2, indent=False)
# "此致"
elif stripped == "此致":
_add_para(doc, text, style_cizhi)
# 普通 body
else:
_add_para(doc, text, style_body)
doc.save(output_path)
return output_path
def _apply_page(section, page_config):
if "width" in page_config:
section.page_width = _parse_size(page_config["width"])
if "height" in page_config:
section.page_height = _parse_size(page_config["height"])
if "margin" in page_config:
m = page_config["margin"]
if isinstance(m, list) and len(m) == 4:
section.top_margin, section.bottom_margin = _parse_size(m[0]), _parse_size(m[1])
section.left_margin, section.right_margin = _parse_size(m[2]), _parse_size(m[3])
def _parse_size(val):
if isinstance(val, (Cm, Pt)):
return val
s = str(val)
if "cm" in s:
return Cm(float(s.replace("cm", "")))
if "pt" in s:
return Pt(float(s.replace("pt", "")))
return Cm(float(s))
def _sub_vars(text, variables):
"""替换 [变量] 为实际值"""
def replacer(m):
key = m.group(1)
val = variables.get(key, m.group(0))
if isinstance(val, (int, float)):
return f"{val:,}"
return str(val)
return re.sub(r'\[([^\[\]]+)\]', replacer, text)
def _add_para(doc, text, style_dict, indent=True):
p = doc.add_paragraph()
# space
p.paragraph_format.space_before = style_dict.get("space_before", Pt(0))
p.paragraph_format.space_after = style_dict.get("space_after", Pt(0))
# gap_before (used for "此致")
if "gap_before" in style_dict:
p.paragraph_format.space_before = style_dict["gap_before"]
# line spacing
ls = style_dict.get("line_spacing", 1.5)
if ls == 1.0:
p.paragraph_format.line_spacing = 1.0
else:
p.paragraph_format.line_spacing = ls
# alignment
align_map = {"left": WD_ALIGN_PARAGRAPH.LEFT, "center": WD_ALIGN_PARAGRAPH.CENTER,
"right": WD_ALIGN_PARAGRAPH.RIGHT, "justify": WD_ALIGN_PARAGRAPH.JUSTIFY}
if "align" in style_dict:
p.alignment = align_map.get(style_dict["align"], WD_ALIGN_PARAGRAPH.LEFT)
# indent: false=无缩进, true=使用默认 28pt, 具体值=使用该值
if "indent" in style_dict:
val = style_dict["indent"]
if val is False:
p.paragraph_format.first_line_indent = 0
elif val is True:
p.paragraph_format.first_line_indent = Pt(28) # 默认缩进
elif isinstance(val, (int, float)) and val > 0:
p.paragraph_format.first_line_indent = Pt(val) if not isinstance(val, (Cm, Pt)) else val
# font
run = p.add_run(text)
font_name = style_dict.get("font", "仿宋")
run.font.name = font_name
run._element.rPr.rFonts.set(qn("w:eastAsia"), font_name)
if "size" in style_dict:
run.font.size = style_dict["size"]
if style_dict.get("bold"):
run.bold = True
return p
def _add_empty(doc, size):
p = doc.add_paragraph()
p.paragraph_format.space_before = Pt(0)
p.paragraph_format.space_after = Pt(0)
p.paragraph_format.line_spacing = 1.5
run = p.add_run("")
run.font.size = size
# ========================= CLI =========================
if __name__ == "__main__":
import argparse, json
p = argparse.ArgumentParser()
p.add_argument("template", help="模板 .md 文件路径")
p.add_argument("output", help="输出 .docx 文件路径")
p.add_argument("--vars", default="{}", help="变量 JSON")
args = p.parse_args()
config, body = parse_template(args.template)
config = parse_units(config)
variables = json.loads(args.vars)
render_docx(config, body, variables, args.output)
print(f"✅ {args.output}")
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file). | Stars: 198k | Updated | Claude CodeCodex | Unverified | Install |
| doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |