Skip to content

duyunzhoudyz/dyz-gongwen-skills / skills/gongwen-profile

gongwen-profile

Verified

建立和维护单位画像,即 .gongwen/ 下的单位画像、领导偏好卡、禁用词、文风参数四个文件:分轮问卷或从本单位公文处理办法、已发文件中提取,完成完整建档;读本单位历史稿学文风参数;对比原稿和领导改稿(或带修订痕迹的 docx)归纳领导偏好,录入口述偏好;增删禁用词;给画像做体检。用户说建个完整的单位画像、把我们的公文处理办法录进去、学学我们单位的文风、领导改过的稿子你学一下、记住领导不爱用“打造”、加个禁用词、看看画像缺什么时使用。只建档不写稿:起草交对应起草 skill,按批注改稿交 gongwen-polish,3 问简版建档由 gongwen 完成。

FileKindSize
README.mdmarkdown7.2 KB
SKILL.mdskill md26.7 KB
evals/evals.jsonconfig31.6 KB
evals/files/原稿-期中家长会讲话.txtmarkdown738 B
evals/files/已有单位画像(某镇).mdmarkdown1.4 KB
evals/files/已有禁用词(某局).mdmarkdown481 B
evals/files/已有领导偏好卡(总经理).mdmarkdown1016 B
evals/files/已有领导偏好卡(校长).mdmarkdown898 B
evals/files/待体检单位画像(某学院).mdmarkdown1007 B
evals/files/改稿-期中家长会讲话(校长修改).txtmarkdown624 B
evals/files/某公司历史稿/某公司2025年经营工作总结.txtmarkdown699 B
evals/files/某公司历史稿/某公司董事会经营情况报告(内部资料).txtmarkdown486 B
evals/files/某公司花脸稿/原稿-三季度经营分析汇报.txtmarkdown1.2 KB
evals/files/某公司花脸稿/改稿-三季度经营分析汇报(总经理修改).txtmarkdown983 B
evals/files/某医院公文处理办法和议事规则节选.txtmarkdown1.2 KB
evals/files/某医院护理部三季度工作汇报(院长修订稿).docxbinary2.7 KB
evals/files/某局历史稿/某局2025年工作总结.txtmarkdown1.6 KB
evals/files/某局历史稿/某局2026年上半年工作总结.txtmarkdown1.3 KB
evals/files/某局历史稿/某局关于优化营商环境工作情况的汇报.txtmarkdown985 B
evals/files/某局历史稿/某局迎接市委督查工作汇报.txtmarkdown924 B
evals/files/某局已发文件(2025年).txtmarkdown808 B
evals/files/某社区历史通知/关于2026年高龄津贴发放对象的公示.txtmarkdown614 B
evals/files/某社区历史通知/关于开展燃气安全入户检查的通知.txtmarkdown618 B
evals/files/某社区历史通知/致辖区居民的一封信.txtmarkdown795 B
evals/files/某街道政务信息/某街道三色预警破解老旧小区物业难题.txtmarkdown645 B
evals/files/某街道政务信息/某街道网格+志愿守护独居老人.txtmarkdown523 B
evals/trigger.jsonconfig2.4 KB
manifest.jsonconfig1.3 KB
references/_shared/README.mdmarkdown110 B
references/_shared/guardrails.mdmarkdown12.6 KB
references/_shared/profiles/profile-template.mdmarkdown10.8 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/defensive.mdmarkdown8.1 KB
references/_shared/style/output-format.mdmarkdown9.0 KB
references/edit-patterns.mdmarkdown5.0 KB
references/intake.mdmarkdown7.3 KB
references/maintenance.mdmarkdown7.1 KB
references/style-params.mdmarkdown4.5 KB
scripts/draft_diff.pyscript42.0 KB
scripts/gongwen_lint.pyscript156.2 KB
scripts/lint_rules.jsonconfig108.7 KB
scripts/secret_check.pyscript8.9 KB
scripts/secret_marks.pyscript7.7 KB
scripts/style_patterns.jsonconfig77.4 KB
scripts/style_profile.pyscript42.5 KB

scripts/secret_marks.py

View on GitHub
# -*- coding: utf-8 -*-
"""密级和内部标注识别:style_profile.py、draft_diff.py 共用,不单独运行(gongwen-profile)。

规则来源:
    1. 优先读同目录 lint_rules.json 中 PRI-005(密级标识)、PRI-006(内部资料等标注)、
       PRI-007(未公开、未披露)的 pattern,与共享机检 gongwen_lint.py 保持一致;
    2. 读不到、缺条目或无法编译时,用本文件内置的副本;
    3. 另加本模块的补充规则("严禁外传""不得翻印""不得复制"等后缀,后缀可带括号;"内部参阅""内部参考"
       "仅供内部参考";"此件……";"本报告数据尚未公开披露"一类不带"为、系、属"的说明),始终检查。

判定:
    逐行匹配;命中位置在引号内的视为举例或引述,不算稿件本身的标注(与机检 skip_in_quotes 一致)。
    正文中提到"保密工作""涉密人员管理"之类的词语不算。
    只返回命中的类别,不返回命中内容。

docx:正文(含修订中删除的文字)、页眉、页脚都检查,标注常放在页眉。
只依赖标准库。
"""
from __future__ import annotations

import json
import re
import zipfile
from pathlib import Path
from typing import Dict, List, Optional, Pattern, Sequence, Tuple
from xml.etree import ElementTree as ET

RULES_FILE = Path(__file__).resolve().parent / "lint_rules.json"
RULE_IDS = ("PRI-005", "PRI-006", "PRI-007")
LABELS = {
    "PRI-005": "密级标识",
    "PRI-006": "内部标注",
    "PRI-007": "未公开或未披露信息",
}

# 内置副本:与 shared/scripts/lint_rules.json 同编号规则一致(核对日期 2026-10-16)
BUILTIN: Dict[str, str] = {
    "PRI-005": (r"(?:绝密|机密|秘密)\s*★|^\s*(?:绝密|机密|秘密)\s*$|密级\s*[::]\s*(?:绝密|机密|秘密)|"
                r"^\s*(?:绝密|机密|秘密)\s*[((]?\s*\d+\s*年\s*[))]?\s*$"),
    "PRI-006": (r"^\s*[((【\[]?\s*(?:内部资料|内部文件|内部材料|内部参阅|工作秘密|内部使用|不得外传|注意保密|"
                r"仅限内部(?:使用|传阅)?|内部传阅)\s*[,,、 \s]*(?:注意保存|妥善保管|不得外传|请勿外传|注意保密)?"
                r"\s*[))】\]]?\s*$|(?:本|此|该)(?:材料|文件|稿件|稿|资料|报告|件)[^。\n]{0,6}"
                r"(?:内部资料|工作秘密|内部文件|内部材料|内部使用|不得外传|仅供内部)"),
    "PRI-007": (r"(?:上述|以上|本|该|这些|此)[^。;!?\n]{0,12}(?:为|系|属于?|均为|均系)"
                r"(?:未公开|未披露|尚未公开|尚未披露)"),
}

# 补充规则:机检词表之外的常见写法
_HEAD = (r"(?:内部资料|内部文件|内部材料|内部参阅|内部参考|内部传阅|工作秘密|内部使用|不得外传|严禁外传|不得翻印|"
         r"注意保密|仅限内部(?:使用|传阅)?|仅供内部(?:参考|使用|参阅|传阅)?)")
_TAIL = (r"(?:注意保存|妥善保管|注意保管|不得外传|请勿外传|严禁外传|不得翻印|严禁翻印|不得复制|严禁复制|"
         r"不得转发|注意保密)")
_OPEN, _CLOSE = r"[((【\[]", r"[))】\]]"
EXTRA: Tuple[Tuple[str, Pattern[str]], ...] = (
    # 整行只有标注,如"内部资料,严禁外传""(内部资料 不得翻印)""内部资料(注意保存)""仅供内部参考"
    ("内部标注", re.compile(r"^\s*" + _OPEN + r"?\s*" + _HEAD + r"\s*" + _CLOSE + r"?"
                           + r"(?:\s*[,,、;; ]?\s*" + _OPEN + r"?\s*" + _TAIL + r"\s*" + _CLOSE + r"?)*"
                           r"\s*[。.]?\s*$")),
    # "本材料属工作秘密""此件为内部参阅"
    ("内部标注", re.compile(r"(?:本|此|该)(?:材料|文件|稿件|稿|资料|报告|件)[^。\n]{0,6}"
                           r"(?:内部资料|工作秘密|内部文件|内部材料|内部使用|内部参阅|不得外传|严禁外传|"
                           r"不得翻印|仅供内部)")),
    # "本报告数据尚未公开披露""以上指标未对外公开":主语须是材料、数据一类的词,避免"该企业未披露……"误报
    ("未公开或未披露信息", re.compile(r"(?:上述|以上|本|该|这些|此)[^。;!?\n]{0,4}"
                                    r"(?:报告|材料|文件|数据|指标|信息|内容|稿件|资料|情况)[^。;!?\n]{0,6}"
                                    r"(?:尚)?未(?:对外)?(?:公开|披露)")),
)

W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
W = "{%s}" % W_NS
DOCX_PART_RE = re.compile(r"^word/(?:document|header\d*|footer\d*)\.xml$")

_cache: Optional[List[Tuple[str, Pattern[str]]]] = None


def load_rules(rules_file: Optional[Path] = None) -> List[Tuple[str, Pattern[str]]]:
    """返回 [(类别, 正则)]:PRI-005/006/007(优先取 lint_rules.json)加补充规则。"""
    patterns = dict(BUILTIN)
    path = rules_file or RULES_FILE
    try:
        data = json.loads(path.read_text(encoding="utf-8"))
        for item in data.get("rules", []):
            if not isinstance(item, dict):
                continue
            rid, pattern = item.get("id"), item.get("pattern")
            if rid in RULE_IDS and isinstance(pattern, str):
                try:
                    re.compile(pattern)
                except re.error:
                    continue  # 无法编译的保留内置副本
                patterns[rid] = pattern
    except (OSError, ValueError, AttributeError):
        pass  # 读不到或格式不对:用内置副本
    rules = [(LABELS[rid], re.compile(patterns[rid])) for rid in RULE_IDS]
    rules.extend(EXTRA)
    return rules


def _rules() -> List[Tuple[str, Pattern[str]]]:
    global _cache
    if _cache is None:
        _cache = load_rules()
    return _cache


def _inside_quote(text: str, pos: int) -> bool:
    before = text[:pos]
    return before.count("“") > before.count("”") or before.count("\"") % 2 == 1


def find_marks(lines: Sequence[str]) -> List[str]:
    """逐行检查,返回命中的类别(去重,按规则顺序);没有命中返回空列表。"""
    found: List[str] = []
    for label, regex in _rules():
        if label in found:
            continue
        for line in lines:
            hit = False
            for match in regex.finditer(line):
                if match.start() == match.end():
                    continue
                if _inside_quote(line, match.start()):
                    continue
                hit = True
                break
            if hit:
                found.append(label)
                break
    return found


def _local(tag: str) -> str:
    return tag.rsplit("}", 1)[-1]


def docx_mark_lines(path: Path) -> List[str]:
    """docx 中用于查标注的文字,每段一行:正文(含修订中删除的文字)、页眉、页脚。

    读取失败返回空列表,由调用方的正常读取流程报错。
    """
    lines: List[str] = []
    try:
        with zipfile.ZipFile(str(path)) as zf:
            parts = sorted(n for n in zf.namelist() if DOCX_PART_RE.match(n))
            for name in parts:
                root = ET.fromstring(zf.read(name))
                for p in root.iter(W + "p"):
                    pieces = []
                    for node in p.iter():
                        tag = _local(node.tag)
                        if tag in ("t", "delText") and node.text:
                            pieces.append(node.text)
                        elif tag == "tab":
                            pieces.append("\t")
                    lines.append("".join(pieces))
    except (zipfile.BadZipFile, KeyError, OSError, ET.ParseError):
        return []
    return lines


def describe(labels: Sequence[str]) -> str:
    """命中类别的说明文字,用于提示用户。"""
    return "、".join(labels) if labels else ""
canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall