diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 1c8a9d3..d8f0f52 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "jsc-log", - "version": "0.0.1", - "description": "工作日誌(LOG_* wiki 頁)與技能使用統計", + "version": "0.0.2", + "description": "工作日誌(LOG_{HASH} wiki 頁)與技能使用統計", "skills": "./skills", "author": { "name": "JSC" diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json index b14deb9..7b7c716 100644 --- a/.codex-plugin/plugin.json +++ b/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "jsc-log", - "version": "0.0.1", - "description": "工作日誌(LOG_* wiki 頁)與技能使用統計", + "version": "0.0.2", + "description": "工作日誌(LOG_{HASH} wiki 頁)與技能使用統計", "skills": "./skills" } diff --git a/AGENTS.md b/AGENTS.md index f763764..2b45841 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ # jsc-log — 給 AI 助理的指引 -本 repo 是 jsc 技能組的 `log` domain(工作日誌與技能使用統計,寫入 LOG_* wiki 頁),Claude Code / Codex / Copilot / Antigravity / Kiro 都能安裝使用。 +本 repo 是 jsc 技能組的 `log` domain(工作日誌與技能使用統計,寫入 `LOG_{HASH}` wiki 頁),Claude Code / Codex / Copilot / Antigravity / Kiro 都能安裝使用。 ## 規則 diff --git a/README.md b/README.md index a67fb6f..2020976 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # jsc-log — 工作日誌與統計 -jsc 技能組的 log domain:工作完成後把十項資訊寫入 wiki 日誌頁(`LOG_{yyyyMM}_W{週數}`,週數依週五日期計算),並統計技能使用次數與呼叫鏈次數。 +jsc 技能組的 log domain:工作完成後把十項資訊寫入 wiki 日誌頁(`LOG_{HASH}`,`HASH` 依共享規則計算;首碼若是數字或 `A`/`B`/`C`,改成 `H` 加上原前 7 碼;頁內仍按工作週週五整理),並統計技能使用次數與呼叫鏈次數。 ## 安裝、更新、移除 @@ -21,6 +21,7 @@ Marketplace 統一為 `jsc`(https://gitea.jsc.idv.tw/plugins/jsc.git),安 | 工具 | 用途 | | --- | --- | | `tools/usage-stats.sh` | 聚合 `$JSC_HOME/usage/*.jsonl`:`skills` 列技能使用次數、`chains` 列呼叫鏈次數(皆降冪),`--cli ` 過濾 | +| `tools/worklog-target.sh` | 依 `{owner}/{repo}` 產生 `LOG_{HASH}`、`LOG_CONTENTS` 與符合共享規則的 `HASH` | ## Skills 目錄 @@ -30,7 +31,7 @@ Marketplace 統一為 `jsc`(https://gitea.jsc.idv.tw/plugins/jsc.git),安 ### `worklog` -工作完成後蒐集十項資訊(存取庫、分支、計畫連結、工作包連結、花費時間、token 用量、任務狀態、執行細節、困難與解決、PR 目標分支),套範本附加到 `LOG_{yyyyMM}_W{週數}` 與 `LOG_CONTENTS`。 +工作完成後蒐集十項資訊(存取庫、分支、計畫連結、工作包連結、花費時間、token 用量、任務狀態、執行細節、困難與解決、PR 目標分支),用 `tools/worklog-target.sh` 產生目標頁,再套範本附加到 `LOG_{HASH}` 與 `LOG_CONTENTS`。 ### `stats` diff --git a/plugin.json b/plugin.json index d3c5978..f6ed7ea 100644 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "name": "jsc-log", - "version": "0.0.1", - "description": "工作日誌(LOG_* wiki 頁)與技能使用統計", + "version": "0.0.2", + "description": "工作日誌(LOG_{HASH} wiki 頁)與技能使用統計", "skills": "./skills/" } diff --git a/skills/worklog/SKILL.md b/skills/worklog/SKILL.md index 2c9c041..d52c831 100644 --- a/skills/worklog/SKILL.md +++ b/skills/worklog/SKILL.md @@ -1,6 +1,6 @@ --- name: worklog -description: After finishing a work package, collect ten facts (repo, branch, plan link, work package link, elapsed time from session-timer, token usage per CLI, status, details, difficulties, PR target) and append a templated entry to wiki LOG_{yyyyMM}_W{week} plus LOG_CONTENTS. Week number is derived from the Friday of the work week. Trigger at the end of implement or maintain; not for planning notes. +description: After finishing a work package, collect ten facts (repo, branch, plan link, work package link, elapsed time from session-timer, token usage per CLI, status, details, difficulties, PR target) and append a templated entry to wiki LOG_{HASH} plus LOG_CONTENTS. HASH follows the shared 8-char rule with the H-prefix fallback, and the work-week Friday still drives the page content. Trigger at the end of implement or maintain; not for planning notes. --- # worklog — work log @@ -13,8 +13,8 @@ After work completes, collect the ten items below and append a `templates/log-en | --- | --- | --- | | 1 | Repository name | Parse `{owner}/{repo}` from `git remote get-url origin` | | 2 | Branch name | `git branch --show-current` | -| 3 | Plan name | Link to the plan page `[[PLAN_{...}]]` | -| 4 | Work package id | Link to the work package heading on the analyze page `[[ANALYZE_{...}#WP-xx]]` | +| 3 | Plan name | Link to the plan page `[[PLAN_{HASH}]]` | +| 4 | Work package id | Link to the work package heading on the analyze page `[[ANALYZE_{HASH}#WP-xx]]` | | 5 | Elapsed time | `jsc-hooks/hooks/session-timer.sh report {session_id}` (seconds; convert to h/m) | | 6 | Token usage | See the table below; per-CLI methods differ. Fill `N/A` when unavailable | | 7 | Task status | One of the literal values 「完成」、「部分完成」、「阻塞」 (with reason when blocked) | @@ -32,14 +32,10 @@ After work completes, collect the ten items below and append a `templates/log-en | antigravity | Value shown in the UI; `N/A` when unreadable | | kiro | No public source; fill `N/A` | -## Target page and week number +## Target page and work week -- Page name: `LOG_{yyyyMM}_W{週數}`. Both values come from the Friday of the current work week: - ```sh - dow=$(date +%u) - if [ "$dow" -ge 6 ]; then f=$(date -d 'last friday' +%Y%m%d); else f=$(date -d 'friday' +%Y%m%d); fi - yyyyMM=$(printf '%s' "$f" | cut -c1-6) - W=$(( ( $(printf '%s' "$f" | cut -c7-8 | sed 's/^0//') - 1 ) / 7 + 1 )) # which Friday of the month - ``` +- Page name: `LOG_{HASH}`. +- Compute the target page by running `tools/worklog-target.sh "{owner}/{repo}" all`. Use `PAGE` for `LOG_{HASH}` and `CONTENTS` for `LOG_CONTENTS`. +- The work-week Friday still drives the page content and the row dates. - Read the page via `jsc-gitea:wiki`. If it does not exist, create it with the structure described in `templates/log-contents.md`; otherwise APPEND the new entry at the end. -- Update `LOG_CONTENTS` in the same pass (apply `templates/log-contents.md`; add the week's row if missing). +- Update `LOG_CONTENTS` in the same pass (apply `templates/log-contents.md`; add the row if missing). diff --git a/templates/log-contents.md b/templates/log-contents.md index 46dedcc..7fd5cbd 100644 --- a/templates/log-contents.md +++ b/templates/log-contents.md @@ -1,7 +1,7 @@ # 日誌目錄 -> 由 `jsc-log:worklog` 維護。每個日誌頁一列;週數 = 該週五是當月第幾個週五。 +> 由 `jsc-log:worklog` 維護。每個日誌頁一列;頁名使用共享 `HASH` 規則,頁內仍依該週五日期整理。 | 日誌頁 | 週五日期 | 條目數 | 最後更新 | | --- | --- | --- | --- | -| [[LOG_{yyyyMM}_W{週數}]] | {yyyy-MM-dd} | {n} | {yyyy-MM-dd HH:mm} | +| [[LOG_{HASH}]] | {yyyy-MM-dd} | {n} | {yyyy-MM-dd HH:mm} | diff --git a/templates/log-entry.md b/templates/log-entry.md index f9aaaeb..27c6969 100644 --- a/templates/log-entry.md +++ b/templates/log-entry.md @@ -1,7 +1,7 @@ -# 工作日誌頁 — LOG_{yyyyMM}_W{週數} +# 工作日誌頁 — LOG_{HASH} > 由 `jsc-log:worklog` 維護。每完成一項工作附加一個條目在文末。 -> `{yyyyMM}` 與 `{週數}` 取自本工作週的週五:週數 = 該週五是當月第幾個週五。 +> `HASH` 依共享規則計算;頁名不再寫入年月週數,但頁內仍依本工作週的週五整理內容。 --- @@ -11,8 +11,8 @@ | --- | --- | | 存取庫名稱 | {owner}/{repo} | | 分支名稱 | {branch} | -| 計畫名稱 | [[PLAN_{yyyyMMdd}_{HHmmss}_{HASH}|{計畫名稱}]] | -| 工作包編號 | [[ANALYZE_{yyyyMMdd}_{HHmmss}_{HASH}#wp-{編號}|WP-{編號} {工作包標題}]] | +| 計畫名稱 | [[PLAN_{HASH}|{計畫名稱}]] | +| 工作包編號 | [[ANALYZE_{HASH}#wp-{編號}|WP-{編號} {工作包標題}]] | | 花費時間 | {h} 小時 {m} 分(session-timer report) | | token 用量 | {CLI}: {input}/{output}(不可得填 N/A) | | 任務狀態 | 完成、部分完成、阻塞({原因})三選一 | diff --git a/tools/worklog-target.sh b/tools/worklog-target.sh new file mode 100755 index 0000000..0e0028b --- /dev/null +++ b/tools/worklog-target.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env sh +# worklog-target.sh: 產生 worklog wiki 目標頁。 +# 用法: +# worklog-target.sh [hash|page|contents|all] +set -eu + +usage() { + echo 'usage: worklog-target.sh [hash|page|contents|all]' >&2 + exit 2 +} + +[ "$#" -ge 1 ] || usage +[ "$#" -le 2 ] || usage + +repo=$1 +field=${2:-page} + +if [ -z "$repo" ]; then + usage +fi + +if command -v sha1sum >/dev/null 2>&1; then + raw=$(printf '%s' "$repo" | sha1sum | awk '{print $1}') +elif command -v shasum >/dev/null 2>&1; then + raw=$(printf '%s' "$repo" | shasum -a 1 | awk '{print $1}') +else + echo 'no SHA-1 helper found' >&2 + exit 1 +fi + +hash=$(printf '%s' "$raw" | cut -c1-8 | tr a-f A-F) +case "$hash" in + [0-9ABC]*) hash="H$(printf '%s' "$hash" | cut -c1-7)" ;; +esac + +page="LOG_${hash}" +contents='LOG_CONTENTS' + +case "$field" in + hash) printf '%s\n' "$hash" ;; + page) printf '%s\n' "$page" ;; + contents) printf '%s\n' "$contents" ;; + all) + printf 'HASH=%s\n' "$hash" + printf 'PAGE=%s\n' "$page" + printf 'CONTENTS=%s\n' "$contents" + ;; + *) usage ;; +esac