Skip to content

pa1nrui1/enterprise-legal-ops / skills/enterprise-legal-ops

enterprise-legal-ops

Verified

中小企业本地法务运营管理 Skill。用于企业内部管理合同、员工/劳动合同/年假/制度、公章证照、章程权限、股东出资、提醒和本地自然语言问库。用户要初始化企业法务工作区、上传历史合同/员工花名册/劳动制度/证照/章程/授权/用印记录、生成本地台账、查询到期提醒、做企业内部合同审查 Word 修订稿、合同起草、HR 风险预判、制度冲突检查、旧制度合法性审查、公章用印权限校验、股东出资提醒、飞书日历提醒配置时触发。

FileKindSize
SKILL.mdskill md5.2 KB
agents/openai.yamlconfig330 B
references/contracts.mdmarkdown4.4 KB
references/hr.mdmarkdown5.5 KB
references/local-query.mdmarkdown2.5 KB
references/reminders.mdmarkdown2.8 KB
references/seals-licenses-governance.mdmarkdown5.3 KB
references/strict-review.mdmarkdown2.3 KB
references/workspace-data-standard.mdmarkdown2.7 KB
scripts/archive_record.pyscript19.7 KB
scripts/contract_redline_review.pyscript4.1 KB
scripts/import_document.pyexecutablescript11.3 KB
scripts/import_roster.pyscript11.9 KB
scripts/init_workspace.pyexecutablescript11.4 KB
scripts/ledger.pyexecutablescript7.4 KB
scripts/query_workspace.pyexecutablescript5.8 KB
scripts/reminders.pyexecutablescript20.9 KB
scripts/strict_review_record.pyscript5.3 KB
tests/test_enterprise_legal_ops.pyexecutablescript19.3 KB

scripts/query_workspace.py

View on GitHub
#!/usr/bin/env python3
"""Lightweight local CSV/Markdown query for Enterprise Legal Ops workspaces."""

from __future__ import annotations

import argparse
import csv
from pathlib import Path


CSV_TARGETS = [
    "01-合同管理/contracts.csv",
    "02-人力资源/employees.csv",
    "02-人力资源/employment-contracts.csv",
    "02-人力资源/annual-leave.csv",
    "03-公章证照/licenses.csv",
    "03-公章证照/seals.csv",
    "03-公章证照/authorizations.csv",
    "03-公章证照/seal-use.csv",
    "03-公章证照/governance-documents.csv",
    "03-公章证照/authority-checks.csv",
    "03-公章证照/capital-contributions.csv",
    "04-提醒中心/reminders.csv",
    "05-本地问库/source-map.csv",
    "05-本地问库/extracted-text-index.csv",
]


LEGAL_JUDGMENT_HINTS = [
    "能不能", "是否合法", "风险", "辞退", "解除", "调岗", "降薪", "处分",
    "盖章", "担保", "借款", "融资", "有效", "补偿", "违约", "怎么改",
]


def search_csv(path: Path, query: str) -> list[tuple[Path, dict[str, str]]]:
    if not path.exists():
        return []
    hits = []
    with path.open(newline="", encoding="utf-8") as f:
        for row in csv.DictReader(f):
            haystack = " ".join(str(v) for v in row.values())
            if query.lower() in haystack.lower():
                hits.append((path, row))
    return hits


def search_markdown(workspace: Path, query: str, limit: int) -> list[tuple[Path, str]]:
    hits = []
    for path in workspace.rglob("*.md"):
        if len(hits) >= limit:
            break
        try:
            text = path.read_text(encoding="utf-8")
        except UnicodeDecodeError:
            continue
        idx = text.lower().find(query.lower())
        if idx >= 0:
            start = max(0, idx - 80)
            end = min(len(text), idx + 180)
            snippet = text[start:end].replace("\n", " ")
            hits.append((path, snippet))
    return hits


def classify_query(query: str) -> str:
    if any(hint in query for hint in LEGAL_JUDGMENT_HINTS):
        return "法律判断型问题"
    if any(word in query for word in ["以前", "上次", "历史", "审查过", "变更", "记录"]):
        return "历史记录查询"
    return "管理型查询"


def append_log(workspace: Path, question: str, csv_hits: int, md_hits: int, strict: bool) -> None:
    log = workspace / "05-本地问库" / "qa-log.md"
    log.parent.mkdir(parents=True, exist_ok=True)
    with log.open("a", encoding="utf-8") as f:
        f.write("\n## 查询记录\n")
        f.write(f"- 查询问题:{question}\n")
        f.write(f"- CSV 命中:{csv_hits}\n")
        f.write(f"- Markdown 命中:{md_hits}\n")
        f.write(f"- 是否需要严审:{'是' if strict else '否'}\n")


def main() -> int:
    parser = argparse.ArgumentParser(description="Search local Enterprise Legal Ops ledgers and records.")
    parser.add_argument("--workspace", required=True)
    parser.add_argument("--query", required=True)
    parser.add_argument("--limit", type=int, default=10)
    args = parser.parse_args()

    workspace = Path(args.workspace).expanduser().resolve()
    query = args.query.strip()
    if not query:
        raise SystemExit("--query cannot be empty")

    strict = any(hint in query for hint in LEGAL_JUDGMENT_HINTS)
    query_type = classify_query(query)
    csv_hits = []
    for rel in CSV_TARGETS:
        csv_hits.extend(search_csv(workspace / rel, query))
        if len(csv_hits) >= args.limit:
            csv_hits = csv_hits[: args.limit]
            break
    md_hits = search_markdown(workspace, query, args.limit)
    append_log(workspace, query, len(csv_hits), len(md_hits), strict)

    if strict:
        print("## 需要进入严审")
        print()
        print("这个问题涉及实质法律判断,不能仅根据台账直接回答。")
        print()
    elif query_type == "历史记录查询":
        print("## 历史记录查询结果")
        print()
    else:
        print("## 查询结果")
        print()

    print(f"- 查询问题:{query}")
    print(f"- 查询类型:{query_type}")
    print("- 查询范围:CSV 台账、Markdown 记录")
    print()
    if csv_hits:
        print("### CSV 命中")
        for path, row in csv_hits:
            summary = "; ".join(f"{k}={v}" for k, v in row.items() if v)
            print(f"- 来源:{path}")
            print(f"  摘要:{summary[:500]}")
    if md_hits:
        print("\n### Markdown 命中")
        for path, snippet in md_hits:
            print(f"- 来源:{path}")
            print(f"  摘要:{snippet[:500]}")
    if not csv_hits and not md_hits:
        unresolved = workspace / "05-本地问库" / "unresolved-queries.md"
        unresolved.parent.mkdir(parents=True, exist_ok=True)
        with unresolved.open("a", encoding="utf-8") as f:
            f.write(f"\n- 未查询到:{query}\n")
        print("未查询到结果。")
        print(f"已记录:{unresolved}")
    print()
    print(f"- 是否需要进入严审:{'是' if strict else '否'}")
    if strict:
        module = "合同/HR/公章证照模块"
        if any(word in query for word in ["合同", "签", "违约", "续约", "解除"]):
            module = "合同管理模块"
        elif any(word in query for word in ["员工", "辞退", "调岗", "降薪", "处分", "年假", "工资", "制度"]):
            module = "人力资源法务管理模块"
        elif any(word in query for word in ["盖章", "担保", "借款", "融资", "章程", "授权", "出资", "证照"]):
            module = "公章证照与章程权限模块"
        print(f"- 建议进入模块:{module}")
    print("- 下一步建议:如涉及法律判断,请进入对应模块严审;如只是管理查询,可打开上述来源文件核对。")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 323kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 323kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 323kUpdated Claude CodeCodexVerifiedInstall