新增(scripts/ 分层完整实现):
- scripts/util/{constants,date_util,runtime_paths,logging_setup}.py
- scripts/db/{connection,seed_data,repository}.py(SQLite + 5 张表 + 50 份样例合同)
- scripts/service/{scanner,task_generator,dispatcher,html_renderer}.py
- scripts/cli/app.py(argparse 子命令)
- scripts/templates/task.html.j2(Jinja2 渲染,无 jinja2 时降级到 str.replace)
- examples/{contracts_sample,performance_sample}.csv(本地样例数据)
修改:
- scripts/main.py:argparse + jiangchang_skill_core 降级
- SKILL.md:version 1.0.1 → 1.1.0
- CHANGELOG.md:加 v1.1.0 条目
- .env.example:加 DB_PATH / HTML_OUTPUT_DIR / JIANGCHANG_DATA_DIR
本地验证(9 个 CLI 命令全部 exit code = 0):
- health / version / config-path / init-db:基础 4 命令
- scan-expiring-contracts --thresholds 90,60,30:42 份可续聘 → 红 10 / 橙 10 / 黄 10,生成 30 任务
- render-html:写 output/<task_id>.html(4.9 KB)
- generate-renewal-task:单份合同任务书生成
- mark-contract-renewed:状态机更新 + 关闭 open alerts
- dispatch-task-notice:按单位/月份派发 payload(dry-run 模式)
业务规则(AI 续聘建议本地版,规则顺序判断):
1. 师德 < 60 → non_renew
2. 近 3 年考核有不合格(< 60)→ observe
3. 全部 >= 80 且逐年上升 → renew
4. 其他 → observe
Co-Authored-By: Claude Code <noreply@anthropic.com>
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""合同到期智能预警与续聘辅助 - CLI 入口。
|
||
|
||
v1.1.0 实现:
|
||
- argparse 子命令分发
|
||
- jiangchang_skill_core 降级(宿主环境用完整版,本地用自包含实现)
|
||
- UTF-8 输出兼容(Windows cmd)
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import io
|
||
import os
|
||
import sys
|
||
|
||
# UTF-8 输出兼容(Windows)
|
||
if sys.platform == "win32":
|
||
if hasattr(sys.stdout, "buffer"):
|
||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
|
||
if hasattr(sys.stderr, "buffer"):
|
||
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace")
|
||
|
||
# scripts/main.py → scripts/ → 加进 sys.path
|
||
_scripts_dir = os.path.dirname(os.path.abspath(__file__))
|
||
if _scripts_dir not in sys.path:
|
||
sys.path.insert(0, _scripts_dir)
|
||
|
||
|
||
def _apply_host_runtime() -> None:
|
||
"""宿主共享 runtime 集成(本地无 jiangchang_skill_core 时跳过)。"""
|
||
try:
|
||
from jiangchang_skill_core.runtime_env import apply_cli_local_defaults
|
||
|
||
apply_cli_local_defaults()
|
||
except ImportError:
|
||
pass # 本地环境没有宿主 runtime,跳过
|
||
|
||
|
||
_apply_host_runtime()
|
||
|
||
from cli.app import main
|
||
|
||
if __name__ == "__main__":
|
||
raise SystemExit(main())
|