继续完善代码

This commit is contained in:
2026-06-07 11:51:23 +08:00
parent 1bbcc65cf3
commit 45cf1741e1
12 changed files with 415 additions and 19 deletions

View File

@@ -7,9 +7,10 @@
from __future__ import annotations
import json
import os
from typing import Optional
from jiangchang_skill_core import collect_runtime_diagnostics, format_runtime_health_lines
from jiangchang_skill_core import collect_runtime_diagnostics, config, format_runtime_health_lines
from db import task_logs_repository as tlr
from service.entitlement_service import check_entitlement
@@ -90,15 +91,41 @@ def cmd_log_get(log_id: str) -> int:
return 0
def cmd_config_path() -> int:
example_path = os.path.join(get_skill_root(), ".env.example")
env_path = config.get_env_file_path() or ""
print(
json.dumps(
{
"skill": SKILL_SLUG,
"env_path": env_path,
"example_path": os.path.abspath(example_path),
},
ensure_ascii=False,
)
)
return 0
def cmd_health() -> int:
runtime = collect_runtime_diagnostics(
skill_slug=SKILL_SLUG,
platform_kit_min_version=PLATFORM_KIT_MIN_VERSION,
skill_root=get_skill_root(),
)
status = "failed" if runtime.has_fatal_issues else "ok"
print(f"{SKILL_SLUG} health: {status}")
for line in format_runtime_health_lines(runtime):
example_path = os.path.join(get_skill_root(), ".env.example")
env_path = config.get_env_file_path() or ""
env_exists = bool(env_path and os.path.isfile(env_path))
health_status = "failed" if runtime.has_fatal_issues else "ok"
lines = [
f"{SKILL_SLUG} health: {health_status}",
*format_runtime_health_lines(runtime),
f"env_path: {env_path}",
f"env_exists: {env_exists}",
f"example_path: {os.path.abspath(example_path)}",
]
for line in lines:
print(line)
return 1 if runtime.has_fatal_issues else 0