feat/learn-page-type #6

Merged
admin merged 3 commits from feat/learn-page-type into develop 2026-08-24 03:47:40 +00:00
7 changed files with 18 additions and 10 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "jsc-gitea", "name": "jsc-gitea",
"version": "0.0.3", "version": "0.0.4",
"description": "Gitea API 工具、Wiki 讀寫與存取庫批次同步", "description": "Gitea API 工具、Wiki 讀寫與存取庫批次同步",
"skills": "./skills", "skills": "./skills",
"author": { "author": {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "jsc-gitea", "name": "jsc-gitea",
"version": "0.0.3", "version": "0.0.4",
"description": "Gitea API 工具、Wiki 讀寫與存取庫批次同步", "description": "Gitea API 工具、Wiki 讀寫與存取庫批次同步",
"skills": "./skills" "skills": "./skills"
} }
+3 -3
View File
@@ -26,7 +26,7 @@ gitea.sh repos <owner> # 列出 owner 的 repo 全名
gitea.sh default-branch <owner>/<repo> gitea.sh default-branch <owner>/<repo>
gitea.sh clone-url <owner>/<repo> gitea.sh clone-url <owner>/<repo>
gitea.sh hash-id <text> # 產生 8 碼大寫 SHA-1;首碼 0-9/A/B/C 時改成 Hxxxxxxx gitea.sh hash-id <text> # 產生 8 碼大寫 SHA-1;首碼 0-9/A/B/C 時改成 Hxxxxxxx
gitea.sh wiki-repo <TYPE> # 解析頁面類型的 wiki 位置(TYPE = QUESTION / PLAN / ANALYZE / MAINTAIN / REPO / LOG / ERROR) gitea.sh wiki-repo <TYPE> # 解析頁面類型的 wiki 位置(TYPE = QUESTION / PLAN / ANALYZE / MAINTAIN / REPO / LOG / LEARN / ERROR)
gitea.sh wiki-list <owner>/<repo> gitea.sh wiki-list <owner>/<repo>
gitea.sh wiki-get <owner>/<repo> <page> # 不存在 exit 4 gitea.sh wiki-get <owner>/<repo> <page> # 不存在 exit 4
gitea.sh wiki-put <owner>/<repo> <page> <file> # 自動判斷新建或更新 gitea.sh wiki-put <owner>/<repo> <page> <file> # 自動判斷新建或更新
@@ -44,7 +44,7 @@ check-wiki-rules.sh # 驗證 wiki repo 解析與 ha
### `wiki` ### `wiki`
Gitea wiki 頁讀寫的統一入口:依頁面類型(QUESTION / PLAN / ANALYZE / MAINTAIN / REPO / LOG / ERROR)解析 wiki 所在的 `{owner}/{repo}`,先讀對應的 `JSC_WIKI_REPO_{TYPE}`,再退回 `JSC_WIKI_REPO`,不同類型不可互相代用。頁面內容以圖表優先(mermaid 圖、markdown 表格),純文字為最後手段。 Gitea wiki 頁讀寫的統一入口:依頁面類型(QUESTION / PLAN / ANALYZE / MAINTAIN / REPO / LOG / LEARN / ERROR)解析 wiki 所在的 `{owner}/{repo}`,先讀對應的 `JSC_WIKI_REPO_{TYPE}`,再退回 `JSC_WIKI_REPO`,不同類型不可互相代用。頁面內容以圖表優先(mermaid 圖、markdown 表格),純文字為最後手段。
### `repo-sync` ### `repo-sync`
@@ -58,7 +58,7 @@ Gitea wiki 頁讀寫的統一入口:依頁面類型(QUESTION / PLAN / ANALYZ
| --- | --- | --- | | --- | --- | --- |
| `GITEA_HOST` | Gitea 站台(可省略 scheme,預設 https) | 詢問使用者 | | `GITEA_HOST` | Gitea 站台(可省略 scheme,預設 https) | 詢問使用者 |
| `GITEA_TOKEN` | Gitea API token;缺少或遇 401/403 時自動退回 tea CLI 登入 token | 詢問使用者 | | `GITEA_TOKEN` | Gitea API token;缺少或遇 401/403 時自動退回 tea CLI 登入 token | 詢問使用者 |
| `JSC_WIKI_REPO_{TYPE}` | 各類型 wiki 頁的 `{owner}/{repo}`;TYPE = QUESTION / PLAN / ANALYZE / MAINTAIN / REPO / LOG / ERROR | 退回 `JSC_WIKI_REPO`,不做跨類型代用 | | `JSC_WIKI_REPO_{TYPE}` | 各類型 wiki 頁的 `{owner}/{repo}`;TYPE = QUESTION / PLAN / ANALYZE / MAINTAIN / REPO / LOG / LEARN / ERROR | 退回 `JSC_WIKI_REPO`,不做跨類型代用 |
| `JSC_WIKI_REPO` | 共用預設的 wiki `{owner}/{repo}` | 詢問使用者 | | `JSC_WIKI_REPO` | 共用預設的 wiki `{owner}/{repo}` | 詢問使用者 |
## Hash 規則 ## Hash 規則
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "jsc-gitea", "name": "jsc-gitea",
"version": "0.0.3", "version": "0.0.4",
"description": "Gitea API 工具、Wiki 讀寫與存取庫批次同步", "description": "Gitea API 工具、Wiki 讀寫與存取庫批次同步",
"skills": "./skills/" "skills": "./skills/"
} }
+2 -2
View File
@@ -9,10 +9,10 @@ Every wiki operation in the jsc skill set goes through this skill. One entry poi
## Resolve the wiki location ## Resolve the wiki location
Different page types can live in different `{owner}/{repo}` repos, classified by page-name prefix: `QUESTION`, `PLAN`, `ANALYZE`, `MAINTAIN`, `REPO`, `LOG`, `ERROR`. Different page types can live in different `{owner}/{repo}` repos, classified by page-name prefix: `QUESTION`, `PLAN`, `ANALYZE`, `MAINTAIN`, `REPO`, `LOG`, `LEARN`, `ERROR`.
1. Before asking the user, inspect the current shell environment for the needed repo variables and Gitea connection variables: `JSC_WIKI_REPO_{TYPE}`, `JSC_WIKI_REPO`, `GITEA_HOST`, and `GITEA_TOKEN`. Use inherited shell values first; only ask when the needed repo cannot be resolved after that check. 1. Before asking the user, inspect the current shell environment for the needed repo variables and Gitea connection variables: `JSC_WIKI_REPO_{TYPE}`, `JSC_WIKI_REPO`, `GITEA_HOST`, and `GITEA_TOKEN`. Use inherited shell values first; only ask when the needed repo cannot be resolved after that check.
2. Run `tools/gitea.sh wiki-repo {TYPE}` (TYPE = the page-name prefix). Allowed types are `QUESTION`, `PLAN`, `ANALYZE`, `MAINTAIN`, `REPO`, `LOG`, and `ERROR`. Resolution order is `JSC_WIKI_REPO_{TYPE}` first, then `JSC_WIKI_REPO`. Never borrow another type's repo. 2. Run `tools/gitea.sh wiki-repo {TYPE}` (TYPE = the page-name prefix). Allowed types are `QUESTION`, `PLAN`, `ANALYZE`, `MAINTAIN`, `REPO`, `LOG`, `LEARN`, and `ERROR`. Resolution order is `JSC_WIKI_REPO_{TYPE}` first, then `JSC_WIKI_REPO`. Never borrow another type's repo.
3. On exit 3 (neither is set after env inspection), ask the user for that page type's `{owner}/{repo}` per the `jsc-ask:ask` rules, and suggest setting `JSC_WIKI_REPO_{TYPE}` (can differ per type) or `JSC_WIKI_REPO` (shared default). 3. On exit 3 (neither is set after env inspection), ask the user for that page type's `{owner}/{repo}` per the `jsc-ask:ask` rules, and suggest setting `JSC_WIKI_REPO_{TYPE}` (can differ per type) or `JSC_WIKI_REPO` (shared default).
## Operations ## Operations
+8
View File
@@ -52,6 +52,14 @@ check_repo ANALYZE 'ANALYZE falls back to shared only' 'shared/wiki' \
JSC_WIKI_REPO_REPO='records/REPO' \ JSC_WIKI_REPO_REPO='records/REPO' \
JSC_WIKI_REPO='shared/wiki' JSC_WIKI_REPO='shared/wiki'
check_repo LEARN 'LEARN specific wins' 'lessons/LEARN' \
JSC_WIKI_REPO_LEARN='lessons/LEARN' \
JSC_WIKI_REPO='shared/wiki'
check_repo LEARN 'LEARN falls back to shared only' 'shared/wiki' \
JSC_WIKI_REPO_LOG='records/LOG' \
JSC_WIKI_REPO='shared/wiki'
check_repo ERROR 'ERROR uses its own repo' 'errors/wiki' \ check_repo ERROR 'ERROR uses its own repo' 'errors/wiki' \
JSC_WIKI_REPO_ERROR='errors/wiki' \ JSC_WIKI_REPO_ERROR='errors/wiki' \
JSC_WIKI_REPO='shared/wiki' JSC_WIKI_REPO='shared/wiki'
+2 -2
View File
@@ -7,7 +7,7 @@
# gitea.sh clone-url <owner>/<repo> # 印出 clone URL # gitea.sh clone-url <owner>/<repo> # 印出 clone URL
# gitea.sh hash-id <text> # 產生 8 碼大寫 SHA-1 hash;首碼為 0-9/A/B/C 時改成 Hxxxxxxx # gitea.sh hash-id <text> # 產生 8 碼大寫 SHA-1 hash;首碼為 0-9/A/B/C 時改成 Hxxxxxxx
# gitea.sh wiki-repo <TYPE> # 解析頁面類型的 wiki 位置: # gitea.sh wiki-repo <TYPE> # 解析頁面類型的 wiki 位置:
# TYPE = QUESTION|PLAN|ANALYZE|MAINTAIN|REPO|LOG|ERROR(即頁名前綴) # TYPE = QUESTION|PLAN|ANALYZE|MAINTAIN|REPO|LOG|LEARN|ERROR(即頁名前綴)
# 依序取 JSC_WIKI_REPO_{TYPE} > JSC_WIKI_REPO;不得跨類型代用;都未設定 exit 3 # 依序取 JSC_WIKI_REPO_{TYPE} > JSC_WIKI_REPO;不得跨類型代用;都未設定 exit 3
# gitea.sh wiki-list <owner>/<repo> # 列出 wiki 頁名 # gitea.sh wiki-list <owner>/<repo> # 列出 wiki 頁名
# gitea.sh wiki-get <owner>/<repo> <page> # 印出 wiki 頁 markdown;不存在時 exit 4 # gitea.sh wiki-get <owner>/<repo> <page> # 印出 wiki 頁 markdown;不存在時 exit 4
@@ -27,7 +27,7 @@ script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
resolve_wiki_repo() { # TYPE -> JSC_WIKI_REPO_{TYPE} -> JSC_WIKI_REPO resolve_wiki_repo() { # TYPE -> JSC_WIKI_REPO_{TYPE} -> JSC_WIKI_REPO
type=$(printf '%s' "${1:?TYPE required}" | tr a-z A-Z) type=$(printf '%s' "${1:?TYPE required}" | tr a-z A-Z)
case "$type" in case "$type" in
QUESTION|PLAN|ANALYZE|MAINTAIN|REPO|LOG|ERROR) ;; QUESTION|PLAN|ANALYZE|MAINTAIN|REPO|LOG|LEARN|ERROR) ;;
*) echo "unknown wiki type: $type" >&2; exit 2 ;; *) echo "unknown wiki type: $type" >&2; exit 2 ;;
esac esac
eval "v=\${JSC_WIKI_REPO_${type}:-}" eval "v=\${JSC_WIKI_REPO_${type}:-}"