refactor(doc): 接上 shared 共用規範,去除重抄段落並修正時區/機密遮蔽引用

依 todo.md 執行的規範治理專案:worklog/funcs/issues-analyze/
issues-analyze-to-file/issues-sync/notifications/docker 七個 skill 改為
引用 shared 新增的 14 個共用 spec(token 優先序、issue 讀取、TODO list、
ask-user、subagent、no-scratch-files、skill-invocation、script-path 等),
不再重抄內容;wiki_api.py 改用 zoneinfo 而非硬編 +8 offset,並補上與
shared/scripts/lib/redact-patterns.json 的對應註記;worklog 的 --tune 改為
呼叫 /jsc-shared:models --task summary。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-11 06:03:35 +00:00
co-authored by Claude Sonnet 5
parent 59426af440
commit ed7f29c10f
14 changed files with 169 additions and 241 deletions
+4 -1
View File
@@ -3,7 +3,9 @@
# 用途:worklog 的 transcript 處理工具。負責 (1) 從 Claude Code/Codex
# JSONL 抽出「本輪」對話片段(最後一筆使用者訊息之後的全部內容),
# (2) 估算本輪花費時間,(3) 對文字做機密遮蔽(token/密碼/PII),
# 作為寫入 wiki 前的第二道防線。
# 作為寫入 wiki 前的第二道防線。本檔 REDACT_PATTERNS 現為
# /jsc-shared:spec-gitea『機密遮蔽實作』章節的來源依據(其他工具的
# 機密遮蔽規則以該章節為準)。
# 更新時間:2026/07/27 22:16:00
# 相依:Python 3 標準庫。全程僅走 stdin/stdout,不寫任何檔案。
# ==============================================================================
@@ -21,6 +23,7 @@ TOTAL_LIMIT = 24000
# ------------------------------------------------------------------------------
# 機密遮蔽規則:命中一律換成 ***
# ------------------------------------------------------------------------------
# 本檔遮蔽規則對應 shared/scripts/lib/redact-patterns.json(經 /jsc-shared:spec-gitea 收斂)
REDACT_PATTERNS = [
(r"[A-Za-z0-9_\-]*:[A-Za-z0-9_\-]{16,}@", "***@"), # URL 內嵌憑證 user:token@
(r"\b[0-9a-f]{40}\b", "***"), # Gitea 40 字元 token
+19 -3
View File
@@ -3,6 +3,8 @@
# 用途:Gitea Wiki 讀寫工具(worklog 專用)。提供 token 解析、頁面讀取、
# 建立、append 追加(read-modify-write + 寫後驗證重試),供 worklog.sh
# 與 /jsc-doc:worklog skill 共用,避免兩份實作漂移。
# resolve_token() 的優先序實作對應 /jsc-shared:spec-gitea『token 解析
# 優先序』章節。
# 更新時間:2026/07/29 19:03:29
# 相依:Python 3 標準庫(urllib、base64、json、re)。不需 requests、不需 jq。
# 機密:token 一律從環境變數或本機憑證檔讀取,絕不輸出、絕不寫入任何檔案。
@@ -18,8 +20,9 @@ import urllib.error
import urllib.parse
import urllib.request
from datetime import datetime, timedelta, timezone
from zoneinfo import ZoneInfo
TAIPEI = timezone(timedelta(hours=8))
TAIPEI = ZoneInfo("Asia/Taipei")
def _ssl_context():
@@ -128,7 +131,12 @@ def resolve_token(host, repo):
# ------------------------------------------------------------------------------
def _request(method, url, token, payload):
"""發出 Gitea API 請求,回傳 (HTTP 狀態碼, 回應內文字串)。網路層錯誤以 0 表示。"""
"""
發出 Gitea API 請求,回傳 (HTTP 狀態碼, 回應內文字串)。網路層錯誤以 0 表示。
本函式實作 /jsc-shared:spec-gitea 的『API 呼叫慣例』章節:
Authorization 標頭帶 `token <token>`、payload 以 UTF-8 JSON 編碼。
"""
data = json.dumps(payload, ensure_ascii=False).encode("utf-8") if payload is not None else None
req = urllib.request.Request(url, data=data, method=method)
req.add_header("Authorization", f"token {token}")
@@ -145,7 +153,12 @@ def _request(method, url, token, payload):
def _api_base(host, repo):
"""組出 repo 層級的 wiki API base URL。"""
"""
組出 repo 層級的 wiki API base URL。
本函式實作 /jsc-shared:spec-gitea 的『API 呼叫慣例』章節:base 為
`https://<host>/api/v1/repos/<owner>/<repo>` 之下的 wiki 路徑。
"""
return f"https://{host}/api/v1/repos/{repo}/wiki"
@@ -188,6 +201,9 @@ def resolve_sub_url(host, repo, token, title):
Gitea wiki 會對 title 做轉義(`-` 代表空格,實際 dash 另有轉義形式,例如
title `Worklog-2026-07-W4` 的 sub_url 為 `Worklog-2026-07-W4.-`),因此讀寫
一律以查表得到的 sub_url 為準,不自行猜測轉義規則。
本函式實作 /jsc-shared:spec-gitea 的『Wiki 頁名轉義規則』第 2 點:
以 `GET /wiki/pages` 查表找 sub_url,不用字串取代規則反推。
找不到回 None。
"""
status, pages = list_pages(host, repo, token)