--- 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`. - 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.