依 todo.md 執行的規範治理專案:新增 spec-preflight 等 14 個共用規範(含 conventional-commit/pull-request/git-push/issue-read/todo-list/ask-user/ subagent/no-scratch-files/skill-invocation/script-path/action-scaffold/ node-src-layout/plugin-cli/model),擴充 spec-git-safety 與 spec-gitea(token 優先序、機密遮蔽、Wiki 頁名轉義規則);新增可執行 skill `models`(模型能力 查詢與標籤)與 `todo`(依指定模型產生/附加 todo.md);新增 plugin.meta.json 單一事實來源與 gen-plugin-files.mjs 樣板產生器,統一四個 repo 的 manifest/ README/AGENTS.md 並移除寫死的本機使用者路徑;新增 shared/scripts/lib 的 log/機密遮蔽三語言參考實作。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
31 lines
1.4 KiB
Python
31 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
||
# ==============================================================================
|
||
# 用途:時間戳與 log 格式的參考實作(Python 版)。對應 /jsc-shared:spec-time-log
|
||
# 規範:更新時間一律 Asia/Taipei、固定 yyyy/MM/dd HH:mm:ss(以
|
||
# zoneinfo.ZoneInfo 取得,不硬編 +8 offset,正確處理 DST/歷史時區變更);
|
||
# 輸出訊息一律 [時間][階段][等級]: 訊息、一行一則、走 stderr。本檔案不會
|
||
# 被其他 repo 跨 repo 直接 import,純供其他 repo 的腳本對照複製或標註
|
||
# 對應關係(原始寫法見 doc/scripts/worklog/wiki_api.py 的 now_str()/log())。
|
||
# 更新時間:2026/08/11 00:00:00
|
||
# 相依:Python 3 標準庫(zoneinfo、datetime)。
|
||
# ==============================================================================
|
||
|
||
import sys
|
||
from datetime import datetime
|
||
from zoneinfo import ZoneInfo
|
||
|
||
TAIPEI = ZoneInfo("Asia/Taipei")
|
||
|
||
|
||
def now_taipei():
|
||
"""取得台灣時區的 yyyy/MM/dd HH:mm:ss 時間字串。"""
|
||
return datetime.now(TAIPEI).strftime("%Y/%m/%d %H:%M:%S")
|
||
|
||
|
||
def log(level, message, stage=""):
|
||
"""輸出統一格式訊息([時間][階段][等級]: 訊息,一行一則),一律走 stderr 不污染 stdout。"""
|
||
if stage:
|
||
print(f"[{now_taipei()}][{stage}][{level}]: {message}", file=sys.stderr)
|
||
else:
|
||
print(f"[{now_taipei()}][{level}]: {message}", file=sys.stderr)
|