chore: auto release commit (2026-09-14 16:40:24)

This commit is contained in:
2026-09-14 16:40:24 +08:00
parent cd71f49709
commit 1d1f1ba322
6 changed files with 514 additions and 4 deletions

View File

@@ -4,8 +4,10 @@
import sys
from pathlib import Path
# 占位:开发者后续接入 jiangchang_skill_core
# from jiangchang_skill_core import ...
# 让 scripts/ 下的子包(util/db/service/cli)可作为顶级包导入
_SCRIPTS_DIR = Path(__file__).resolve().parent
if str(_SCRIPTS_DIR) not in sys.path:
sys.path.insert(0, str(_SCRIPTS_DIR))
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -19,7 +21,8 @@ def health():
def version():
"""查看版本(占位)。"""
print("detect-policy-conflict-gs v1.0.1")
from util.constants import SKILL_VERSION
print(f"detect-policy-conflict-gs v{SKILL_VERSION}")
return 0
@@ -55,6 +58,10 @@ def export_review_report(draft_id: str, fmt: str = "pdf"):
def mark_policy_status(draft_id: str, target_status: str):
"""标记送审稿状态(占位)。"""
from util.constants import POLICY_DRAFT_STATUSES
if target_status not in POLICY_DRAFT_STATUSES:
print(f"ERROR: 未知状态 {target_status!r},允许:{POLICY_DRAFT_STATUSES}", file=sys.stderr)
return 1
print(f"mark-policy-status: {draft_id} -> {target_status} (待开发者实现)")
return 0

View File

@@ -0,0 +1,87 @@
"""冲突严重程度分级纯函数。
依据:
- 高(high):相似度 >= HIGH_CONFLICT_THRESHOLD → 制度文件核心条款直接冲突
- 中(medium):相似度 >= MEDIUM_CONFLICT_THRESHOLD → 程序/用词层歧义
- 低(low):其它(如命名相似但实质无关)
"""
from __future__ import annotations
from typing import Tuple
def classify_conflict_severity(
similarity: float,
thresholds: Tuple[float, float] = (0.85, 0.92),
) -> str:
"""根据条款相似度返回冲突等级。
thresholds = (medium_min, high_min),须 0 <= medium_min <= high_min <= 1。
返回:'high' / 'medium' / 'low'。
"""
medium_min, high_min = thresholds
if similarity >= high_min:
return "high"
if similarity >= medium_min:
return "medium"
return "low"
def normalize_policy_text(s: str) -> str:
"""规范化制度文本:去空白 + 中文/英文标点统一。
用于语义比对前的预处理,确保章节编号差异不干扰相似度计算。
转换规则:
- 全角空格 → 半角空格
- 全角 ASCII(数字 0-9 / 字母 A-Z a-z / 常见标点)→ 半角
- 合并连续空白为单空格
"""
if s is None:
return ""
# 全角 ASCII 标点 → 半角(覆盖冒号/逗号/句号/分号/问号/感叹号/括号/方括号/引号)
full_to_half_punct = {
",": ",", "。": ".", ":": ":", ";": ";",
"?": "?", "!": "!", "(": "(", ")": ")",
"【": "[", "】": "]", "『": "'", "』": "'",
"「": "'", "」": "'",
}
out_chars = []
for ch in str(s):
code = ord(ch)
# 全角空格
if ch == " ":
out_chars.append(" ")
continue
# 已映射的标点
if ch in full_to_half_punct:
out_chars.append(full_to_half_punct[ch])
continue
# 全角数字 0xFF10-0xFF19 → 0x30-0x39
if 0xFF10 <= code <= 0xFF19:
out_chars.append(chr(code - 0xFEE0))
continue
# 全角字母 0xFF21-0xFF3A / 0xFF41-0xFF5A → 半角
if 0xFF21 <= code <= 0xFF3A:
out_chars.append(chr(code - 0xFEE0))
continue
if 0xFF41 <= code <= 0xFF5A:
out_chars.append(chr(code - 0xFEE0))
continue
out_chars.append(ch)
text = "".join(out_chars)
# 合并连续空白为单空格
return " ".join(text.split())
def parse_policy_draft_id(s: str) -> str:
"""解析送审稿 ID:去空白 + 校验非空。
占位骨架的轻量校验,业务层后续接入更严格规则。
"""
if s is None:
raise ValueError("policy_draft_id 不能为空")
s = str(s).strip()
if not s:
raise ValueError("policy_draft_id 不能为空")
return s

43
scripts/util/constants.py Normal file
View File

@@ -0,0 +1,43 @@
"""技能标识、版本与阈值常量。
复制到新 skill 时必须修改:
- SKILL_SLUG 与 SKILL.md metadata.openclaw.slug 保持一致
- SKILL_VERSION 与 SKILL.md version 保持一致
"""
SKILL_SLUG = "detect-policy-conflict-gs"
SKILL_VERSION = "1.0.2"
LOG_LOGGER_NAME = "openclaw.skill.detect_policy_conflict_gs"
PLATFORM_KIT_MIN_VERSION = "1.2.11"
# 送审稿状态机:可送审 → 审查中 → 已通过 / 冲突中 / 驳回
POLICY_DRAFT_STATUSES = (
"可送审",
"审查中",
"已通过",
"冲突中",
"驳回",
)
# 冲突类型分类(用于 service 层判断冲突严重程度)
CONFLICT_TYPES = (
"条款直接冲突",
"程序不合规",
"疑似重复发文",
"用词歧义",
)
# 冲突严重等级(与 thresholds 顺序一一对应)
CONFLICT_SEVERITY_LEVELS = ("low", "medium", "high")
CONFLICT_SEVERITY_LABELS = {
"low": "轻微",
"medium": "中等",
"high": "严重",
}
# 制度库语义比对阈值(命中即视为相关)
DEFAULT_SIMILARITY_THRESHOLD = 0.85
# AI 续聘建议规则阈值(与 conflict 类比:相似度高于阈值则升级冲突等级)
HIGH_CONFLICT_THRESHOLD = 0.92
MEDIUM_CONFLICT_THRESHOLD = 0.85