refactor(worklog): worklog-target.sh 改為接收已算好的 hash
什麼:tools/worklog-target.sh 不再自行重算 SHA-1,改為直接接收呼叫端算好的 hash 參數;skills/worklog/SKILL.md、README.md 同步更新呼叫方式與工具說明;plugin.json、.claude-plugin/plugin.json、.codex-plugin/plugin.json 版本號由 0.0.3 升至 0.0.4。
為什麼:原本 worklog-target.sh 重複實作了共享的 SHA-1 wiki-hash 演算法,與 jsc-gitea/tools/hash-id 的邏輯重複,違反單一事實來源原則,也和 learn 技能已採用的正確呼叫模式不一致。
如何:移除腳本內建的 sha1sum/shasum 計算與 hash 前綴修正邏輯,改為直接使用傳入的 hash 參數組出 LOG_{HASH}、LOG_CONTENTS;SKILL.md 改為先呼叫 jsc-gitea/tools/hash-id 算出 HASH 再傳給 worklog-target.sh;輸出行為與結果不變。
誰:jsc-meta:skill-check 例行合規稽核(worklog 技能)。
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "jsc-log",
|
"name": "jsc-log",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"description": "工作日誌(LOG_{HASH} wiki 頁)、技能使用統計與教訓紀錄(LEARN_{HASH} wiki 頁)",
|
"description": "工作日誌(LOG_{HASH} wiki 頁)、技能使用統計與教訓紀錄(LEARN_{HASH} wiki 頁)",
|
||||||
"skills": "./skills",
|
"skills": "./skills",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "jsc-log",
|
"name": "jsc-log",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"description": "工作日誌(LOG_{HASH} wiki 頁)、技能使用統計與教訓紀錄(LEARN_{HASH} wiki 頁)",
|
"description": "工作日誌(LOG_{HASH} wiki 頁)、技能使用統計與教訓紀錄(LEARN_{HASH} wiki 頁)",
|
||||||
"skills": "./skills"
|
"skills": "./skills"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ Marketplace 統一為 `jsc`(https://gitea.jsc.idv.tw/plugins/jsc.git),安
|
|||||||
| 工具 | 用途 |
|
| 工具 | 用途 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `tools/usage-stats.sh` | 聚合 `$JSC_HOME/usage/*.jsonl`:`skills` 列技能使用次數、`chains` 列呼叫鏈次數(皆降冪),`--cli <name>` 過濾 |
|
| `tools/usage-stats.sh` | 聚合 `$JSC_HOME/usage/*.jsonl`:`skills` 列技能使用次數、`chains` 列呼叫鏈次數(皆降冪),`--cli <name>` 過濾 |
|
||||||
| `tools/worklog-target.sh` | 依 `{owner}/{repo}` 產生 `LOG_{HASH}`、`LOG_CONTENTS` 與符合共享規則的 `HASH` |
|
| `tools/worklog-target.sh` | 接收已由 `jsc-gitea/tools/hash-id` 算好的 `HASH`,組出 `LOG_{HASH}`、`LOG_CONTENTS`(本身不再計算 SHA-1) |
|
||||||
|
|
||||||
## Skills 目錄
|
## Skills 目錄
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "jsc-log",
|
"name": "jsc-log",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"description": "工作日誌(LOG_{HASH} wiki 頁)、技能使用統計與教訓紀錄(LEARN_{HASH} wiki 頁)",
|
"description": "工作日誌(LOG_{HASH} wiki 頁)、技能使用統計與教訓紀錄(LEARN_{HASH} wiki 頁)",
|
||||||
"skills": "./skills/"
|
"skills": "./skills/"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ After work completes, collect the ten items below and append a `templates/log-en
|
|||||||
## Target page and work week
|
## Target page and work week
|
||||||
|
|
||||||
- Page name: `LOG_{HASH}`.
|
- 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`.
|
- Compute `{HASH}` from `{owner}/{repo}` with `jsc-gitea/tools/hash-id` (shared wiki hash rule: first 8 uppercase SHA-1 hex chars; `H` plus the first 7 chars when the raw hash starts with `0-9`, `A`, `B`, or `C`).
|
||||||
|
- Compute the target page by running `tools/worklog-target.sh "{HASH}" all`. Use `PAGE` for `LOG_{HASH}` and `CONTENTS` for `LOG_CONTENTS`.
|
||||||
- The work-week Friday still drives the page content and the row dates.
|
- 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.
|
- 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 row if missing).
|
- Update `LOG_CONTENTS` in the same pass (apply `templates/log-contents.md`; add the row if missing).
|
||||||
|
|||||||
+6
-21
@@ -1,47 +1,32 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# worklog-target.sh: 產生 worklog wiki 目標頁。
|
# worklog-target.sh: 由已算好的 hash 組出 worklog wiki 目標頁名稱。
|
||||||
|
# hash 一律由 jsc-gitea/tools/hash-id 算出後傳入,本腳本不再自行計算 SHA-1。
|
||||||
# 用法:
|
# 用法:
|
||||||
# worklog-target.sh <owner/repo> [hash|page|contents|all]
|
# worklog-target.sh <hash> [page|contents|all]
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo 'usage: worklog-target.sh <owner/repo> [hash|page|contents|all]' >&2
|
echo 'usage: worklog-target.sh <hash> [page|contents|all]' >&2
|
||||||
exit 2
|
exit 2
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "$#" -ge 1 ] || usage
|
[ "$#" -ge 1 ] || usage
|
||||||
[ "$#" -le 2 ] || usage
|
[ "$#" -le 2 ] || usage
|
||||||
|
|
||||||
repo=$1
|
hash=$1
|
||||||
field=${2:-page}
|
field=${2:-page}
|
||||||
|
|
||||||
if [ -z "$repo" ]; then
|
if [ -z "$hash" ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
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}"
|
page="LOG_${hash}"
|
||||||
contents='LOG_CONTENTS'
|
contents='LOG_CONTENTS'
|
||||||
|
|
||||||
case "$field" in
|
case "$field" in
|
||||||
hash) printf '%s\n' "$hash" ;;
|
|
||||||
page) printf '%s\n' "$page" ;;
|
page) printf '%s\n' "$page" ;;
|
||||||
contents) printf '%s\n' "$contents" ;;
|
contents) printf '%s\n' "$contents" ;;
|
||||||
all)
|
all)
|
||||||
printf 'HASH=%s\n' "$hash"
|
|
||||||
printf 'PAGE=%s\n' "$page"
|
printf 'PAGE=%s\n' "$page"
|
||||||
printf 'CONTENTS=%s\n' "$contents"
|
printf 'CONTENTS=%s\n' "$contents"
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user