Skip to content

duyunzhoudyz/dyz-gongwen-skills / skills/gongwen-brief

gongwen-brief

Verified

起草和改写信息宣传稿件,包括政务信息(含紧急信息)、工作简报、新闻稿、新闻发布会发布词和答问口径、官方公众号推文,从长材料提炼经验做法信息,评估信息和新闻稿能不能报、能不能被采用。先建素材台账、选准角度,开头即结论,数据和原话只用用户材料,对外稿核对授权和敏感信息。用户说写信息、报个政务信息、编一期简报、写篇新闻稿、写发布词、发公众号、把材料压成800字信息、这篇信息能不能被采用时使用。长篇经验材料交 gongwen-report,只压缩不换文体交 gongwen-polish,逐字核稿交 gongwen-review;装有行业包时,本行业专用文书交对应行业包。

FileKindSize
README.mdmarkdown8.2 KB
SKILL.mdskill md25.9 KB
evals/evals.jsonconfig25.7 KB
evals/files/某公司三季度经营情况通报.txtmarkdown517 B
evals/files/某公司安全生产月活动情况.txtmarkdown791 B
evals/files/某区信息初稿.txtmarkdown1.1 KB
evals/files/某区市场监管局校园周边食品安全检查情况.txtmarkdown827 B
evals/files/某医院义诊活动情况.txtmarkdown1003 B
evals/files/某医院胸痛中心救治记录.txtmarkdown990 B
evals/files/某县乡镇报表负担调研记录.txtmarkdown1.3 KB
evals/files/某学院迎评工作简报素材.txtmarkdown1.1 KB
evals/files/某小学科技节活动记录.txtmarkdown910 B
evals/files/某局优化营商环境经验材料.txtmarkdown8.1 KB
evals/files/某社区老年助餐点运行情况.txtmarkdown937 B
evals/files/某街道网格化服务工作情况.txtmarkdown654 B
evals/files/某镇人居环境整治现场推进会记录.txtmarkdown1.3 KB
evals/files/某镇强降雨情况.txtmarkdown769 B
evals/trigger.jsonconfig2.1 KB
manifest.jsonconfig1.5 KB
references/_shared/README.mdmarkdown110 B
references/_shared/guardrails.mdmarkdown12.6 KB
references/_shared/profiles/calendar.mdmarkdown9.4 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/data-expression.mdmarkdown13.1 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/defensive.mdmarkdown8.1 KB
references/_shared/style/output-format.mdmarkdown9.0 KB
references/checklist.mdmarkdown4.9 KB
references/condense.mdmarkdown3.8 KB
references/external-check.mdmarkdown5.7 KB
references/ledger.mdmarkdown6.4 KB
references/type-cards.mdmarkdown3.0 KB
references/types/gongzhonghao.mdmarkdown6.1 KB
references/types/jianbao.mdmarkdown6.0 KB
references/types/xinwengao.mdmarkdown8.4 KB
references/types/xinxi.mdmarkdown6.9 KB
references/units.mdmarkdown6.7 KB
scripts/brief_check.pyscript53.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())
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 323kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 323kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 323kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 323kUpdated Claude CodeCodexVerifiedInstall