50 lines
1.8 KiB
Python
50 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""待办事项 demo CLI 入口(结构对齐 skill-template 的 main.py)。
|
||
|
||
分层:cli(argv)→ service(业务编排)→ db(持久化)→ util(通用工具)。
|
||
|
||
独立运行说明:
|
||
真实技能依赖宿主共享 Python runtime 的 ``jiangchang_skill_core``。
|
||
本 demo 自带一份最小 mock(``scripts/_mock_platform/``),在没有宿主时
|
||
由本文件自动注入 sys.path,使 demo 在任意 Python 3.10+ 环境可直接跑通。
|
||
设置环境变量 ``JIANGCHANG_DATA_ROOT`` 即可切到真实平台 runtime 模式。
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
import os
|
||
import sys
|
||
|
||
# Windows 终端 UTF-8(对齐模板)
|
||
if sys.platform == "win32":
|
||
import io
|
||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
|
||
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace")
|
||
|
||
_scripts_dir = os.path.dirname(os.path.abspath(__file__))
|
||
if _scripts_dir not in sys.path:
|
||
sys.path.insert(0, _scripts_dir)
|
||
|
||
# 没有真实平台库时启用 mock(demo 自带,便于脱离宿主独立运行);
|
||
# 设环境变量 ``TODO_SKILL_USE_REAL_PLATFORM=1`` 可强制走真实 runtime。
|
||
if not os.environ.get("TODO_SKILL_USE_REAL_PLATFORM"):
|
||
try:
|
||
import jiangchang_skill_core # noqa: F401
|
||
except ImportError:
|
||
_mock_platform = os.path.join(_scripts_dir, "_mock_platform")
|
||
if _mock_platform not in sys.path:
|
||
sys.path.insert(0, _mock_platform)
|
||
|
||
from jiangchang_skill_core.runtime_env import apply_cli_local_defaults # noqa: E402
|
||
|
||
apply_cli_local_defaults()
|
||
|
||
from util.config_bootstrap import bootstrap_skill_config # noqa: E402
|
||
|
||
bootstrap_skill_config()
|
||
|
||
from cli.app import main # noqa: E402
|
||
|
||
if __name__ == "__main__":
|
||
raise SystemExit(main())
|