Skip to content

duyunzhoudyz/dyz-gongwen-skills / skills/gongwen-review

gongwen-review

Verified

按“八关”审核公文和材料,输出分级问题清单和批注用 JSON,含机检、提法风险、保密隐私扫描、本单位禁用词比对;默认只提意见,用户说“直接改”才按 P0、P1 改。用于“帮我核一下稿”“把把关”“送签前过一遍”“看看报告里是不是夹带请示”“查查格式标点”“审一下报来的材料”。大幅改写转 gongwen-polish 或原起草 skill;去 AI 腔转 gongwen-humanize;去免责对冲转 gongwen-direct;排版、写批注转 gongwen-format;信息能不能被采用的评估交 gongwen-brief;装有行业包时,本行业专用文书只查行业问题的交对应行业包。

FileKindSize
README.mdmarkdown5.6 KB
SKILL.mdskill md17.8 KB
evals/evals.jsonconfig20.7 KB
evals/files/党支部学习交流材料.txtmarkdown774 B
evals/files/医院公众号推文稿.txtmarkdown665 B
evals/files/医院季度质量分析.txtmarkdown966 B
evals/files/国企食堂改造请示.txtmarkdown615 B
evals/files/城管局年度工作总结.txtmarkdown1.1 KB
evals/files/子公司增资议题签报.txtmarkdown1.1 KB
evals/files/学院助学金评审结果公示.txtmarkdown857 B
evals/files/居民垃圾分类通知.txtmarkdown802 B
evals/files/报告夹带请示.txtmarkdown1.4 KB
evals/files/期中家长通知.txtmarkdown689 B
evals/files/社区救助对象申报材料.txtmarkdown974 B
evals/files/禁用词.mdmarkdown528 B
evals/files/经费请示.txtmarkdown573 B
evals/files/街道迎检汇报材料.txtmarkdown710 B
evals/files/规范通知.txtmarkdown2.2 KB
evals/files/问题密集通知.txtmarkdown2.0 KB
evals/files/骨科年度工作总结.txtmarkdown982 B
evals/trigger.jsonconfig1.9 KB
manifest.jsonconfig1.5 KB
references/_shared/README.mdmarkdown110 B
references/_shared/guardrails.mdmarkdown12.6 KB
references/_shared/profiles/roles.mdmarkdown16.1 KB
references/_shared/profiles/units/dangzheng.mdmarkdown7.9 KB
references/_shared/profiles/units/gaoxiao.mdmarkdown11.2 KB
references/_shared/profiles/units/guoqi.mdmarkdown12.7 KB
references/_shared/profiles/units/jiceng.mdmarkdown9.3 KB
references/_shared/profiles/units/shequ.mdmarkdown8.8 KB
references/_shared/profiles/units/yiyuan.mdmarkdown13.2 KB
references/_shared/profiles/units/zhongxiaoxue.mdmarkdown10.6 KB
references/_shared/rules/doc-types.mdmarkdown28.1 KB
references/_shared/rules/gbt15834.mdmarkdown13.3 KB
references/_shared/rules/gbt15835.mdmarkdown10.6 KB
references/_shared/rules/gbt9704.mdmarkdown17.2 KB
references/_shared/rules/jianfu.mdmarkdown12.5 KB
references/_shared/rules/tiaoli.mdmarkdown15.3 KB
references/_shared/style/ai-tone.mdmarkdown10.2 KB
references/_shared/style/baseline.jsonconfig246.4 KB
references/_shared/style/baseline.mdmarkdown26.9 KB
references/_shared/style/defensive.mdmarkdown8.1 KB
references/_shared/style/output-format.mdmarkdown9.0 KB
references/checklist-8gates.mdmarkdown11.3 KB
references/opinion-template.mdmarkdown6.4 KB
references/tifa-risk.mdmarkdown5.5 KB
references/unit-checks.mdmarkdown6.4 KB
scripts/change_guard.pyscript24.6 KB
scripts/fact_diff.pyscript57.4 KB
scripts/gongwen_lint.pyscript156.2 KB
scripts/lint_rules.jsonconfig108.7 KB
scripts/secret_check.pyscript8.9 KB
scripts/style_patterns.jsonconfig77.4 KB

scripts/secret_check.py

View on GitHub
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""保密标识检查:扫描 txt、md、docx、xlsx 中的密级标识和内部标注,命中即退出码 1。

用法:python secret_check.py <文件...>

docx 读取范围:正文段落、表格、页眉、页脚(含首页、奇偶页)、文本框、脚注、尾注、批注,
输出位置带来源标签,如“[页眉(首页)]”“[文本框]”“[表格]”。xlsx 读取单元格文字、批注、
工作表名、页眉页脚。只依赖标准库。

检出:“秘密★”“机密★”“绝密★”(含 5年 等保密期限写法)、“工作秘密”“内部资料”
“不得外传”“内部使用”等。“保密工作”“涉密人员管理”之类业务用语不算。
输出只给位置和命中词,不复述材料内容。

退出码:0 未发现;1 发现标识;2 文件无法读取。
"""
from __future__ import annotations

import argparse
import re
import sys
import zipfile
import xml.etree.ElementTree as ET
from pathlib import Path
from typing import Dict, List, Tuple

W = "{http://schemas.openxmlformats.org/wordprocessingml/2006/main}"
R = "{http://schemas.openxmlformats.org/officeDocument/2006/relationships}"
S = "{http://schemas.openxmlformats.org/spreadsheetml/2006/main}"
MAX_XML = 50 * 1024 * 1024

LEVEL = "绝密|机密|秘密"
STAR = "[★☆**]"
PATTERNS = [
    ("密级标识", re.compile("(?:%s)\\s*%s" % (LEVEL, STAR))),
    ("密级与保密期限", re.compile("(?:%s)\\s*%s?\\s*[\\d一二三四五六七八九十]+\\s*(?:年|个月)" % (LEVEL, STAR))),
    ("密级与保密期限", re.compile("(?:%s)\\s*%s?\\s*(?:长期|永久)" % (LEVEL, STAR))),
    ("保密期限", re.compile("保密期限")),
    ("内部标注", re.compile("工作秘密|内部资料|不得外传|严禁外传|内部使用|仅供内部参考|内部参阅|注意保密")),
]

Item = Tuple[str, str]  # (位置标签, 文字)


def _root(zf: zipfile.ZipFile, name: str) -> ET.Element:
    if zf.getinfo(name).file_size > MAX_XML:
        raise ValueError("部件过大:" + name)
    return ET.fromstring(zf.read(name))


def _para_text(p: ET.Element) -> str:
    """段落文字:含修订删除的文字(保守起见一并检查)。"""
    parts = []
    for e in p.iter():
        if e.tag in (W + "t", W + "delText"):
            parts.append(e.text or "")
        elif e.tag == W + "tab":
            parts.append("\t")
    return "".join(parts)


def _paragraphs(root: ET.Element, base: str) -> List[Item]:
    """遍历部件内全部段落;文本框、表格内的段落单独标注来源。"""
    out: List[Item] = []
    counter = [0]

    def walk(el: ET.Element, ctx: str) -> None:
        for ch in el:
            if ch.tag == W + "txbxContent":
                walk(ch, "文本框")
            elif ch.tag == W + "tbl":
                walk(ch, ctx if ctx == "文本框" else "表格")
            elif ch.tag == W + "p":
                counter[0] += 1
                text = _para_text(ch)
                if text.strip():
                    if ctx == "正文":
                        label = "%s第%d段" % (base, counter[0]) if base == "正文" else base
                    else:
                        label = ctx if base == "正文" else base + ctx
                    out.append((label, text))
                walk(ch, ctx)
            else:
                walk(ch, ctx)

    walk(root, "正文")
    seen = set()  # mc:AlternateContent 中文本框常有两份相同内容,去重
    uniq = []
    for item in out:
        if item not in seen:
            seen.add(item)
            uniq.append(item)
    return uniq


def _hf_labels(zf: zipfile.ZipFile) -> Dict[str, str]:
    """部件路径 -> 页眉/页脚标签(区分首页、偶数页)。"""
    labels: Dict[str, str] = {}
    names = set(zf.namelist())
    if "word/document.xml" not in names:
        return labels
    rels = {}
    rp = "word/_rels/document.xml.rels"
    if rp in names:
        for r in _root(zf, rp):
            rels[r.get("Id")] = r.get("Target", "")
    kinds = {"default": "", "first": "(首页)", "even": "(偶数页)"}
    for el in _root(zf, "word/document.xml").iter():
        if el.tag in (W + "headerReference", W + "footerReference"):
            tgt = rels.get(el.get(R + "id"), "").lstrip("/")
            path = tgt if tgt.startswith("word/") else "word/" + tgt
            word = "页眉" if el.tag == W + "headerReference" else "页脚"
            labels.setdefault(path, word + kinds.get(el.get(W + "type", "default"), ""))
    return labels


def extract_docx(path: Path) -> List[Item]:
    """抽取 docx 全部文字,返回 [(位置标签, 文字)]。"""
    items: List[Item] = []
    with zipfile.ZipFile(path) as zf:
        labels = _hf_labels(zf)
        for name in zf.namelist():
            if not re.fullmatch(r"word/[^/]+\.xml", name):
                continue
            base = name[5:-4]
            if name == "word/document.xml":
                items.extend(_paragraphs(_root(zf, name), "正文"))
            elif re.fullmatch(r"(header|footer)\d*", base):
                default = "页眉" if base.startswith("header") else "页脚"
                items.extend(_paragraphs(_root(zf, name), labels.get(name, default)))
            elif base in ("footnotes", "endnotes", "comments"):
                tag = {"footnotes": "脚注", "endnotes": "尾注", "comments": "批注"}[base]
                items.extend(_paragraphs(_root(zf, name), tag))
    return items


def _stext(el: ET.Element) -> str:
    return "".join(t.text or "" for t in el.iter(S + "t"))


def extract_xlsx(path: Path) -> List[Item]:
    items: List[Item] = []
    with zipfile.ZipFile(path) as zf:
        for name in zf.namelist():
            if not name.startswith("xl/") or not name.endswith(".xml"):
                continue
            if name == "xl/workbook.xml":
                for sh in _root(zf, name).iter(S + "sheet"):
                    items.append(("工作表名", sh.get("name", "")))
            elif name == "xl/sharedStrings.xml":
                for si in _root(zf, name).iter(S + "si"):
                    items.append(("单元格", _stext(si)))
            elif re.fullmatch(r"xl/comments\d*\.xml", name):
                for c in _root(zf, name).iter(S + "comment"):
                    items.append(("批注", _stext(c)))
            elif re.fullmatch(r"xl/worksheets/sheet\d+\.xml", name):
                sheet = name.rsplit("/", 1)[1][:-4]
                for el in _root(zf, name).iter():
                    tag = el.tag.replace(S, "")
                    if tag in ("oddHeader", "evenHeader", "firstHeader"):
                        items.append(("页眉(%s)" % sheet, el.text or ""))
                    elif tag in ("oddFooter", "evenFooter", "firstFooter"):
                        items.append(("页脚(%s)" % sheet, el.text or ""))
                    elif tag == "is":  # 内联字符串
                        items.append(("单元格(%s)" % sheet, _stext(el)))
    return items


def extract(path: Path) -> List[Item]:
    suffix = path.suffix.lower()
    if suffix == ".docx":
        return extract_docx(path)
    if suffix == ".xlsx":
        return extract_xlsx(path)
    data = path.read_bytes()
    try:
        text = data.decode("utf-8-sig")
    except UnicodeDecodeError:
        text = data.decode("gb18030", errors="replace")
    return [("第%d行" % i, line) for i, line in enumerate(text.splitlines(), 1) if line.strip()]


def scan(items: List[Item]) -> List[Tuple[str, str, str]]:
    """返回 [(位置, 类型, 命中词)]。"""
    hits = []
    for label, text in items:
        flat = re.sub(r"\s+", " ", text)
        for kind, rx in PATTERNS:
            for m in rx.finditer(flat):
                hits.append((label, kind, m.group(0)))
    return hits


def main(argv=None) -> int:
    for stream in (sys.stdout, sys.stderr):
        try:
            stream.reconfigure(encoding="utf-8")
        except Exception:
            pass
    ap = argparse.ArgumentParser(description="检查文件中的保密标识(含页眉页脚、文本框、表格),命中退出码 1。")
    ap.add_argument("files", nargs="+", help="txt、md、docx、xlsx 文件")
    args = ap.parse_args(argv)
    code = 0
    for f in args.files:
        path = Path(f)
        try:
            items = extract(path)
        except (OSError, zipfile.BadZipFile, ET.ParseError, ValueError, KeyError) as exc:
            print("[读取失败] %s:%s" % (path.name, exc))
            code = 2
            continue
        hits = scan(items)
        if not hits:
            print("[未发现保密标识] " + path.name)
            continue
        if code == 0:
            code = 1
        print("[发现保密标识] %s:共 %d 处,请立即停止处理并按保密红线告知用户" % (path.name, len(hits)))
        seen = set()
        for label, kind, word in hits:
            if (label, word) not in seen:
                seen.add((label, word))
                print("  [%s] %s:%s" % (label, kind, word))
    return code


if __name__ == "__main__":
    sys.exit(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