From fac3285ca787bdf3aa97bc0a93ddaf9b7b5f45ef Mon Sep 17 00:00:00 2001 From: Jeffery Date: Mon, 24 Aug 2026 11:36:45 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat(learn):=20=E6=96=B0=E5=A2=9E=E6=8A=80?= =?UTF-8?q?=E8=83=BD=E6=95=99=E8=A8=93=E7=B4=80=E9=8C=84=E8=88=87=E6=9F=A5?= =?UTF-8?q?=E9=96=B1=E6=8A=80=E8=83=BD=E5=8F=8A=20LEARN=20wiki=20=E9=A0=81?= =?UTF-8?q?=E7=AF=84=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit What:新增 skills/learn/SKILL.md(record/consult 兩種模式)與 templates/learn-page.md、templates/learn-contents.md 兩份 wiki 頁範本。 Why:參考 oh-my-pi 的 learn 工具,讓技能執行後能把教訓沉澱下來、執行前能先查閱套用,避免同樣的問題重複發生。 How:教訓以六欄表格(日期、技能、CLI、情境、教訓、下次做法)逐列附加到 LEARN_{HASH},並同步更新 LEARN_CONTENTS 目錄;HASH 依共用 8 碼 wiki hash 規則(含 H 前綴退回),wiki 位置依 JSC_WIKI_REPO_LEARN → JSC_WIKI_REPO 解析,讀寫皆透過 jsc-gitea:wiki。 Who:jsc-log domain 的 learn 技能(教訓紀錄與查閱功能)。 Co-Authored-By: Claude Fable 5 --- skills/learn/SKILL.md | 44 +++++++++++++++++++++++++++++++++++++ templates/learn-contents.md | 7 ++++++ templates/learn-page.md | 7 ++++++ 3 files changed, 58 insertions(+) create mode 100644 skills/learn/SKILL.md create mode 100644 templates/learn-contents.md create mode 100644 templates/learn-page.md diff --git a/skills/learn/SKILL.md b/skills/learn/SKILL.md new file mode 100644 index 0000000..a0e3610 --- /dev/null +++ b/skills/learn/SKILL.md @@ -0,0 +1,44 @@ +--- +name: learn +description: Record a lesson learned after a skill run to wiki LEARN_{HASH} plus LEARN_CONTENTS, or consult past lessons before a skill run. Each entry is one table row with date, skill, CLI, situation, lesson, and next-time approach. HASH follows the shared 8-char rule with the H-prefix fallback. Use when a skill run produced a reusable lesson, or before running a skill to consult past lessons; not for work-time logs (see worklog). +--- + +# learn — lessons learned + +Close the loop on skill runs: record what a run taught you, consult it before the next run. Two modes — `record` and `consult`. Page content is chart-first Traditional Chinese (STE100): markdown table entries, prose as the last resort. + +## Target pages + +- Directory page: `LEARN_CONTENTS`. Content page: `LEARN_{HASH}`, one page per repository. +- 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`). +- Wiki repo resolution: `JSC_WIKI_REPO_LEARN` first, then `JSC_WIKI_REPO`. Inspect the inherited shell environment variables first; ask the user per the `jsc-ask:ask` rules only when neither resolves. Never borrow another type's `JSC_WIKI_REPO_{TYPE}`. +- All wiki reads and writes go through `jsc-gitea:wiki`. + +## Mode: record + +Run after a skill run that produced a reusable lesson. + +1. Collect the six facts below. Done when every field has a value. + + | # | Field (page column) | Source | + | --- | --- | --- | + | 1 | 日期 | Today, `yyyy-MM-dd` | + | 2 | 技能 | The skill that ran, as `jsc-{domain}:{name}` | + | 3 | CLI | One of claude / codex / copilot / antigravity / kiro | + | 4 | 情境 | What was happening when the lesson appeared, one sentence | + | 5 | 教訓 | What the run taught, one sentence | + | 6 | 下次做法 | How to apply it on the next run, one sentence | + +2. Resolve `{owner}/{repo}` from `git remote get-url origin` and compute `{HASH}` with `jsc-gitea/tools/hash-id`. Done when the page name `LEARN_{HASH}` is known. +3. Write the entry. This step MUST run as a sub agent; the main agent only confirms the write succeeded. + - Read `LEARN_{HASH}` via `jsc-gitea:wiki`. If it does not exist, create it from `templates/learn-page.md`; otherwise APPEND the new row at the end of the table. Never overwrite existing rows. + - Update `LEARN_CONTENTS` in the same pass (apply `templates/learn-contents.md`; add the repo row if missing, otherwise refresh its 最後更新時間). + - Done when the sub agent reports both pages written and the main agent has confirmed the row exists on `LEARN_{HASH}`. + +## Mode: consult + +Run before a skill run, to apply past lessons. + +1. Resolve `{owner}/{repo}` and compute `{HASH}` as in record mode. Done when `LEARN_{HASH}` is known. +2. Read `LEARN_CONTENTS` and the repo's `LEARN_{HASH}` via `jsc-gitea:wiki`. When either page is missing (exit 4), report 「無教訓紀錄」 and let the caller proceed. Done when both pages are read or reported missing. +3. Surface every row whose 技能 matches the skill about to run, and summarize each matched 下次做法 for the caller to apply. Done when the matched rows (or 「無相符教訓」) are reported. diff --git a/templates/learn-contents.md b/templates/learn-contents.md new file mode 100644 index 0000000..3b84991 --- /dev/null +++ b/templates/learn-contents.md @@ -0,0 +1,7 @@ +# 教訓目錄 + +> 由 `jsc-log:learn` 維護。這是教訓目錄頁 `LEARN_CONTENTS`。每個存取庫一列;`LEARN_{HASH}` 的 `{HASH}` 依共用 wiki hash 規則產生:先取 `{owner}/{repo}` 的 SHA-1 前 8 碼並轉成大寫;首碼若是 `0-9`、`A`、`B`、`C`,改用 `H` 加上原前 7 碼,總長維持 8 碼。 + +| 存取庫名稱 | 教訓紀錄 | 最後更新時間 | +| --- | --- | --- | +| {owner}/{repo} | [[LEARN_{HASH}]] | {yyyy-MM-dd HH:mm} | diff --git a/templates/learn-page.md b/templates/learn-page.md new file mode 100644 index 0000000..4b603b0 --- /dev/null +++ b/templates/learn-page.md @@ -0,0 +1,7 @@ +# 教訓紀錄 — {owner}/{repo} + +> 由 `jsc-log:learn` 維護。這是教訓紀錄頁 `LEARN_{HASH}`;`HASH` 依共用 wiki hash 規則產生。新教訓**附加**一列在表尾,不覆蓋舊列。執行技能前先查這頁,套用「下次做法」。 + +| 日期 | 技能 | CLI | 情境 | 教訓 | 下次做法 | +| --- | --- | --- | --- | --- | --- | +| {yyyy-MM-dd} | {jsc-domain:name} | {claude、codex、copilot、antigravity、kiro 五選一} | {當時發生什麼事} | {這次學到什麼} | {下次怎麼做} | -- 2.53.0 From 1b0d4595c1165c82e7b10996ee3d6f37805c6686 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Mon, 24 Aug 2026 11:36:59 +0800 Subject: [PATCH 2/5] =?UTF-8?q?docs(readme):=20=E8=AA=AA=E6=98=8E=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=A3=9C=E4=B8=8A=20learn=20=E6=8A=80=E8=83=BD?= =?UTF-8?q?=E8=88=87=20LEARN=20=E9=A0=81=E8=B3=87=E8=A8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit What:README.md 補上 learn 技能介紹、範本表新增 learn-page.md 與 learn-contents.md 兩列、環境變數一節加入 JSC_WIKI_REPO_LEARN 解析順序;AGENTS.md 的 domain 描述同步加入教訓紀錄與 LEARN_{HASH}。 Why:新技能加入後,安裝者與 AI 助理讀到的文件必須與實際技能清單一致,否則無從得知教訓紀錄功能的存在與 wiki 位置解析規則。 How:沿用既有文件結構,於技能清單、範本表、環境變數與 domain 簡介處逐段補述,並註明先讀 shell 繼承的環境變數、缺值才詢問。 Who:jsc-log domain 的說明文件(learn 教訓紀錄功能)。 Co-Authored-By: Claude Fable 5 --- AGENTS.md | 2 +- README.md | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 2b45841..d0d76cc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ # jsc-log — 給 AI 助理的指引 -本 repo 是 jsc 技能組的 `log` domain(工作日誌與技能使用統計,寫入 `LOG_{HASH}` wiki 頁),Claude Code / Codex / Copilot / Antigravity / Kiro 都能安裝使用。 +本 repo 是 jsc 技能組的 `log` domain(工作日誌、技能使用統計與教訓紀錄,寫入 `LOG_{HASH}`、`LEARN_{HASH}` wiki 頁),Claude Code / Codex / Copilot / Antigravity / Kiro 都能安裝使用。 ## 規則 diff --git a/README.md b/README.md index 2020976..10e11a6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # jsc-log — 工作日誌與統計 -jsc 技能組的 log domain:工作完成後把十項資訊寫入 wiki 日誌頁(`LOG_{HASH}`,`HASH` 依共享規則計算;首碼若是數字或 `A`/`B`/`C`,改成 `H` 加上原前 7 碼;頁內仍按工作週週五整理),並統計技能使用次數與呼叫鏈次數。 +jsc 技能組的 log domain:工作完成後把十項資訊寫入 wiki 日誌頁(`LOG_{HASH}`,`HASH` 依共享規則計算;首碼若是數字或 `A`/`B`/`C`,改成 `H` 加上原前 7 碼;頁內仍按工作週週五整理),統計技能使用次數與呼叫鏈次數,並把技能執行的教訓記到 `LEARN_{HASH}`,供下次執行前查閱。 ## 安裝、更新、移除 @@ -37,6 +37,10 @@ Marketplace 統一為 `jsc`(https://gitea.jsc.idv.tw/plugins/jsc.git),安 統計本技能組各技能的使用次數與呼叫鏈使用次數,資料來源為 jsc-hooks 記錄的 `skills.jsonl` 與 `chains.jsonl`。 +### `learn` + +技能執行後把教訓(日期、技能、CLI、情境、教訓、下次做法)附加到 `LEARN_{HASH}` 並更新 `LEARN_CONTENTS`;技能執行前查閱同兩頁,套用相符的「下次做法」。 + ## 範本 @@ -45,10 +49,12 @@ Marketplace 統一為 `jsc`(https://gitea.jsc.idv.tw/plugins/jsc.git),安 | --- | --- | | `templates/log-entry.md` | 單筆工作日誌(十欄位) | | `templates/log-contents.md` | 日誌目錄 `LOG_CONTENTS` | +| `templates/learn-page.md` | 教訓紀錄頁 `LEARN_{HASH}`(六欄表格,逐列附加) | +| `templates/learn-contents.md` | 教訓目錄 `LEARN_CONTENTS` | ## 環境變數 -Wiki 位置:`JSC_WIKI_REPO_LOG`,未設定退回 `JSC_WIKI_REPO`,再未設定就詢問(見 `jsc-gitea`)。 +Wiki 位置:日誌頁用 `JSC_WIKI_REPO_LOG`、教訓頁用 `JSC_WIKI_REPO_LEARN`,未設定退回 `JSC_WIKI_REPO`,再未設定就詢問(見 `jsc-gitea`)。先讀目前 shell 繼承的環境變數,缺值才詢問。 ## 相關 domain -- 2.53.0 From bc4f2c6f25295e4d77ba2c3b21bc67a7d39d436c Mon Sep 17 00:00:00 2001 From: Jeffery Date: Mon, 24 Aug 2026 11:37:13 +0800 Subject: [PATCH 3/5] =?UTF-8?q?chore(manifest):=20=E4=B8=89=E4=BB=BD=20plu?= =?UTF-8?q?gin=20=E8=B3=87=E8=A8=8A=E6=B8=85=E5=96=AE=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8D=87=E8=87=B3=200.0.3=20=E4=B8=A6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit What:plugin.json、.claude-plugin/plugin.json、.codex-plugin/plugin.json 版本由 0.0.2 升至 0.0.3,描述加入教訓紀錄(LEARN_{HASH} wiki 頁)。 Why:本次新增 learn 技能屬功能擴充,三份資訊清單須同步升版並反映新功能,安裝端才能辨識更新。 How:三份檔案的 version 與 description 欄位一致修改,維持各 CLI 入口內容同步。 Who:jsc-log plugin 的資訊清單(learn 教訓紀錄功能)。 Co-Authored-By: Claude Fable 5 --- .claude-plugin/plugin.json | 4 ++-- .codex-plugin/plugin.json | 4 ++-- plugin.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index d8f0f52..b4c54fe 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "jsc-log", - "version": "0.0.2", - "description": "工作日誌(LOG_{HASH} wiki 頁)與技能使用統計", + "version": "0.0.3", + "description": "工作日誌(LOG_{HASH} wiki 頁)、技能使用統計與教訓紀錄(LEARN_{HASH} wiki 頁)", "skills": "./skills", "author": { "name": "JSC" diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json index 7b7c716..a5ed236 100644 --- a/.codex-plugin/plugin.json +++ b/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "jsc-log", - "version": "0.0.2", - "description": "工作日誌(LOG_{HASH} wiki 頁)與技能使用統計", + "version": "0.0.3", + "description": "工作日誌(LOG_{HASH} wiki 頁)、技能使用統計與教訓紀錄(LEARN_{HASH} wiki 頁)", "skills": "./skills" } diff --git a/plugin.json b/plugin.json index f6ed7ea..e46824f 100644 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "name": "jsc-log", - "version": "0.0.2", - "description": "工作日誌(LOG_{HASH} wiki 頁)與技能使用統計", + "version": "0.0.3", + "description": "工作日誌(LOG_{HASH} wiki 頁)、技能使用統計與教訓紀錄(LEARN_{HASH} wiki 頁)", "skills": "./skills/" } -- 2.53.0 From d8769ec76a5e143e4967607b4568856feb16a08a Mon Sep 17 00:00:00 2001 From: Jeffery Date: Mon, 24 Aug 2026 14:47:08 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix(marketplace):=20=E5=90=8C=E6=AD=A5=20ma?= =?UTF-8?q?rketplace.json=20=E8=87=B3=20plugins/jsc=20=E6=A8=99=E6=BA=96?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 什麼:為 .agents/plugins/marketplace.json 補上 description、owner 欄位,並為所有 plugin 項目補上各自的 description;同時修正 .claude-plugin/marketplace.json 中 jsc-meta 描述的標點(斜線改為頓號)。 為什麼:兩份 marketplace.json 與 plugins/jsc 的標準格式不同步,缺少的欄位會讓其他 CLI(antigravity 等)讀到的 marketplace metadata 不完整。 如何:對照 plugins/jsc 的 canonical marketplace.json,逐一補齊頂層 description、owner 物件,以及每個 plugin 的 description 欄位;統一標點用字。 誰:jsc-meta:skill-check 例行合規稽核。 --- .agents/plugins/marketplace.json | 34 ++++++++++++++++++++++---------- .claude-plugin/marketplace.json | 2 +- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.agents/plugins/marketplace.json b/.agents/plugins/marketplace.json index 12df680..a9b4e66 100644 --- a/.agents/plugins/marketplace.json +++ b/.agents/plugins/marketplace.json @@ -1,75 +1,89 @@ { "name": "jsc", + "description": "jsc 跨 AI 助理技能組的統一 marketplace(claude / codex / copilot / antigravity / kiro)。", + "owner": { + "name": "JSC" + }, "plugins": [ { "name": "jsc-ask", "source": { "source": "url", "url": "https://gitea.jsc.idv.tw/plugins/ask.git" - } + }, + "description": "決策樹問詢與問詢紀錄(QUESTION_* wiki 頁)" }, { "name": "jsc-cli", "source": { "source": "url", "url": "https://gitea.jsc.idv.tw/plugins/cli.git" - } + }, + "description": "CLI 偵測、模型能力標籤與技能庫批次部署" }, { "name": "jsc-git", "source": { "source": "url", "url": "https://gitea.jsc.idv.tw/plugins/git.git" - } + }, + "description": "Commit 分組認可與 Push Request 建立" }, { "name": "jsc-gitea", "source": { "source": "url", "url": "https://gitea.jsc.idv.tw/plugins/gitea.git" - } + }, + "description": "Gitea API 工具、Wiki 讀寫與存取庫批次同步" }, { "name": "jsc-hooks", "source": { "source": "url", "url": "https://gitea.jsc.idv.tw/plugins/hooks.git" - } + }, + "description": "跨 CLI hooks:STE100 語言強制、工時計時、技能用量記錄" }, { "name": "jsc-log", "source": { "source": "url", "url": "https://gitea.jsc.idv.tw/plugins/log.git" - } + }, + "description": "工作日誌(LOG_* wiki 頁)與技能使用統計" }, { "name": "jsc-meta", "source": { "source": "url", "url": "https://gitea.jsc.idv.tw/plugins/meta.git" - } + }, + "description": "技能組自我管理:新建、更新、刪除技能與技能準則" }, { "name": "jsc-pkg", "source": { "source": "url", "url": "https://gitea.jsc.idv.tw/plugins/pkg.git" - } + }, + "description": "套件批次更新(nodejs/python/dotnet),失敗還原" }, { "name": "jsc-review", "source": { "source": "url", "url": "https://gitea.jsc.idv.tw/plugins/review.git" - } + }, + "description": "程式碼審查:Refactoring 壞味道六組 + 註解規範 + 淺模組" }, { "name": "jsc-sdlc", "source": { "source": "url", "url": "https://gitea.jsc.idv.tw/plugins/sdlc.git" - } + }, + "description": "開發生命週期:規劃/分析/實作/維護(wiki 追蹤)" } ] } diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 28bb223..a9b4e66 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -59,7 +59,7 @@ "source": "url", "url": "https://gitea.jsc.idv.tw/plugins/meta.git" }, - "description": "技能組自我管理:新建/更新/刪除技能與技能準則" + "description": "技能組自我管理:新建、更新、刪除技能與技能準則" }, { "name": "jsc-pkg", -- 2.53.0 From b1a04182110a929e08e11ec7a64d0acd9aaeb2c5 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Mon, 24 Aug 2026 14:47:26 +0800 Subject: [PATCH 5/5] =?UTF-8?q?refactor(worklog):=20worklog-target.sh=20?= =?UTF-8?q?=E6=94=B9=E7=82=BA=E6=8E=A5=E6=94=B6=E5=B7=B2=E7=AE=97=E5=A5=BD?= =?UTF-8?q?=E7=9A=84=20hash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 什麼: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 技能)。 --- .claude-plugin/plugin.json | 2 +- .codex-plugin/plugin.json | 2 +- README.md | 2 +- plugin.json | 2 +- skills/worklog/SKILL.md | 3 ++- tools/worklog-target.sh | 27 ++++++--------------------- 6 files changed, 12 insertions(+), 26 deletions(-) diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index b4c54fe..51a0132 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "jsc-log", - "version": "0.0.3", + "version": "0.0.4", "description": "工作日誌(LOG_{HASH} wiki 頁)、技能使用統計與教訓紀錄(LEARN_{HASH} wiki 頁)", "skills": "./skills", "author": { diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json index a5ed236..c3fdd64 100644 --- a/.codex-plugin/plugin.json +++ b/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "jsc-log", - "version": "0.0.3", + "version": "0.0.4", "description": "工作日誌(LOG_{HASH} wiki 頁)、技能使用統計與教訓紀錄(LEARN_{HASH} wiki 頁)", "skills": "./skills" } diff --git a/README.md b/README.md index 10e11a6..c9e1151 100644 --- a/README.md +++ b/README.md @@ -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 ` 過濾 | -| `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 目錄 diff --git a/plugin.json b/plugin.json index e46824f..449fce1 100644 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "name": "jsc-log", - "version": "0.0.3", + "version": "0.0.4", "description": "工作日誌(LOG_{HASH} wiki 頁)、技能使用統計與教訓紀錄(LEARN_{HASH} wiki 頁)", "skills": "./skills/" } diff --git a/skills/worklog/SKILL.md b/skills/worklog/SKILL.md index d52c831..b08c2c7 100644 --- a/skills/worklog/SKILL.md +++ b/skills/worklog/SKILL.md @@ -35,7 +35,8 @@ After work completes, collect the ten items below and append a `templates/log-en ## Target page and work week - 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. - 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). diff --git a/tools/worklog-target.sh b/tools/worklog-target.sh index 0e0028b..f8b102f 100755 --- a/tools/worklog-target.sh +++ b/tools/worklog-target.sh @@ -1,47 +1,32 @@ #!/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 [hash|page|contents|all] +# worklog-target.sh [page|contents|all] set -eu usage() { - echo 'usage: worklog-target.sh [hash|page|contents|all]' >&2 + echo 'usage: worklog-target.sh [page|contents|all]' >&2 exit 2 } [ "$#" -ge 1 ] || usage [ "$#" -le 2 ] || usage -repo=$1 +hash=$1 field=${2:-page} -if [ -z "$repo" ]; then +if [ -z "$hash" ]; 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" ;; -- 2.53.0