Files
shared/README.md
T

236 lines
13 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# jsc — 跨 AI 助理 Plugin 模板
一個可同時被 **Claude Code、Codex、Antigravity、OpenCode** 安裝的 plugin 模板。
核心是以 [Agent Skills`SKILL.md`](https://agentskills.io) 標準撰寫的共用 skills(唯一真實來源放在 `skills/`),
搭配各助理各自的 plugin manifest,讓**同一個 repo** 可用各家**原生 plugin CLI** 安裝。
在 Claude Code 與 Antigravity 中,skill 以 **`/jsc:` 前綴**呼叫(例如 `/jsc:spec-output`)。
---
## 前綴與呼叫方式
| 助理 | 安裝方式 | 呼叫 | `/jsc:` 前綴 |
| --- | --- | --- | --- |
| Claude Code | `claude plugin`marketplace | `/jsc:<name>` 或自動觸發 | ✅ |
| Codex | `codex plugin`marketplace | `$<name>``/skills` 選單 | ❌(用 `$name` |
| Antigravity | `agy plugin install` | `/jsc:<name>` 或自動觸發 | ✅ |
| OpenCode | skills 目錄(複製/clone) | 描述需求自動觸發 | ❌(依名稱) |
> Codex 不支援自訂前綴(skill 以 `$name` 呼叫);OpenCode 由模型依描述自動呼叫。兩者皆**不強制**前綴。
---
## 目錄結構
同一個 repo 同時帶四種 manifest,彼此以路徑隔離、互不干擾;四家都讀同一份 `skills/`
```
generic/
├── .claude-plugin/
│ ├── plugin.json # Claude 外掛定義(name: "jsc"
│ └── marketplace.json # Claude marketplacename: "generic"source 指向本 repo
├── .codex-plugin/
│ └── plugin.json # Codex 外掛定義(name: "jsc"skills: "./skills"
├── .agents/plugins/
│ └── marketplace.json # Codex marketplacename: "generic"url source 指向本 repo
├── plugin.json # Antigravity 外掛定義(name: "jsc"skills: "./skills/"
├── hooks/
│ └── hooks.json # Claude Code hooksStop → worklog;其他助理不吃此檔)
├── scripts/
│ └── worklog/ # worklog 自動記錄的可執行元件(skill 與 hook 共用)
│ ├── worklog.sh # 主流程:抽本輪 → 濃縮 → 遮蔽 → 追加到 wiki
│ ├── wiki_api.py # Gitea wiki 讀寫、token 解析、append 重試、週頁命名
│ └── transcript.py # transcript 本輪抽取與機密遮蔽
├── skills/ # ★ 唯一真實來源:所有 skills
│ ├── spec-*/SKILL.md # 共用規範 skills(一規範一目錄)
│ └── worklog/SKILL.md # 工作證明自動記錄的操作與維護
├── AGENTS.md # 跨助理共用指引
└── README.md
```
> generic 的定位是「**共用規範 全域自動化**」:`skills/spec-*` 是純規範文件(四家助理通用),`hooks/` 與 `scripts/` 是可執行元件。
### 元件對各助理的適用範圍
| 元件 | Claude Code | Codex | Antigravity | OpenCode |
| --- | --- | --- | --- | --- |
| `skills/spec-*`(十個共用規範) | ✅ | ✅ | ✅ | ✅ |
| `skills/worklog` 的手動模式 | ✅ | ⚠️ 需安裝後保留 `scripts/`(請實測一次) | ⚠️ 同左 | ❌ 不支援 |
| `hooks/hooks.json``Stop` 自動記錄) | ✅ | ❌ | ❌ | ❌ |
- **`hooks/hooks.json` 只有 Claude Code 會讀**。且 `scripts/worklog/worklog.sh` 解析的是 **Claude Code 專屬的 transcript JSONL 結構**,即使其他助理提供等效 hook,自動記錄也不能直接沿用。
- **OpenCode 不支援 worklog**OpenCode 以「複製 `skills/` 目錄」安裝,不會帶入 `scripts/`,worklog 的所有模式都無法執行(已在該 skill 的 `description` 標明)。
- Claude Code 的 plugin cache 是完整 repo clone`scripts/`(含 `100755` 執行權限)與 `hooks/` 都會帶入;CodexAntigravity 的安裝目錄是否同樣保留 `scripts/` 尚未實測,第一次安裝後請跑 `/jsc:worklog --diagnose` 確認。
---
## 安裝 / 更新 / 移除(各家原生 plugin CLI
> 指令中的 repo 網址換成你的:`https://gitea.jsc.idv.tw/plugins/generic.git`
>
> **Claude / Codex 從 git URL 安裝(會 clone 遠端),請先把本 repo `push` 到 gitea。**
> **Antigravity 的 `agy plugin install <url>` 目前只支援 github.com**gitea 請改用「clone + 本地路徑」(見 Antigravity 節)。
> 本機/離線:Claude 可用本地路徑加 marketplaceAntigravity 用本地路徑安裝。
### Claude Code
```bash
# 安裝
claude plugin marketplace add https://gitea.jsc.idv.tw/plugins/generic.git
claude plugin install jsc@generic
# 更新
claude plugin marketplace update generic
claude plugin update jsc@generic
# 移除
claude plugin uninstall jsc@generic
claude plugin marketplace remove generic
```
- 工作階段內 slash 版(等價):把 `claude plugin` 換成 `/plugin`
- 本機開發(免 push):`claude plugin marketplace add C:\Users\h3285\source\repos.plugins\generic`(本地路徑)後再 install。
- **呼叫**`/jsc:<name>`(例 `/jsc:spec-output`)。
### Codex
```bash
# 安裝
codex plugin marketplace add https://gitea.jsc.idv.tw/plugins/generic.git
codex plugin add jsc@generic
# 更新(重新抓取 marketplace 的 git 快照)
codex plugin marketplace upgrade generic
# 移除
codex plugin remove jsc@generic
codex plugin marketplace remove generic
```
- 安裝 token `jsc@generic` = plugin 名(`.codex-plugin/plugin.json``name`@ marketplace 名(`.agents/plugins/marketplace.json``name`)。
- 本 repo 的 Codex marketplace 以 `url` 來源指向自己,故 Codex **一律從 gitea 安裝**(需先 push);安裝後重啟 Codex。
- **呼叫**`$<name>`(例 `$spec-output`),或用 `/skills` 選單。
### Antigravity`agy`
> `agy plugin install <url>` 目前**只支援 github.com**gitea 等自架 git 不支援 URL 安裝,請先 `git clone` 再用**本地路徑**安裝。
```bash
# 安裝:clone 後用本地路徑
git clone https://gitea.jsc.idv.tw/plugins/generic.git ~/plugins/generic
agy plugin install ~/plugins/generic
# 更新(agy 無 update 子指令 → git pull 後重裝)
git -C ~/plugins/generic pull
agy plugin uninstall jsc
agy plugin install ~/plugins/generic
# 移除
agy plugin uninstall jsc
```
- 若把 skills 放到 GitHub,則可直接 `agy plugin install https://github.com/<owner>/<repo>`
- 其他:`agy plugin list``agy plugin enable jsc` / `disable jsc``agy plugin validate <path>`。安裝後重啟工作階段。
- **呼叫**`/jsc:<name>`(例 `/jsc:spec-output`)或依描述自動觸發。
### OpenCode
OpenCode 的「plugin」是 TypeScript/npm 套件,不適用於 skill 包;skills 改用**目錄安裝**。
OpenCode 會讀 `~/.config/opencode/skills/`(也會讀 `~/.claude/skills/``~/.agents/skills/`)。
```bash
# 安裝
git clone https://gitea.jsc.idv.tw/plugins/generic.git ~/plugins/generic
mkdir -p ~/.config/opencode/skills
cp -r ~/plugins/generic/skills/* ~/.config/opencode/skills/
# 更新
git -C ~/plugins/generic pull
cp -r ~/plugins/generic/skills/* ~/.config/opencode/skills/
# 移除(逐一移除本 plugin 帶入的 skill 目錄;勿只清 spec-*,否則其他 skill 會殘留)
for s in ~/plugins/generic/skills/*/; do rm -rf "$HOME/.config/opencode/skills/$(basename "$s")"; done
```
> **worklog 在 OpenCode 不可用**:上面的複製只帶 `skills/`,不含 `scripts/`worklog 的所有模式都會失敗。請不要在 OpenCode 觸發該 skill(其 `description` 已標明不支援)。
> **Windows PowerShell**`cp -r A B` → `Copy-Item A B -Recurse -Force`、`rm -rf X` → `Remove-Item X -Recurse -Force`、`~` → `$HOME`。
- **呼叫**:直接描述需求,模型會依 skill 描述自動透過 skill 工具呼叫。
---
## 用 CLI 直接執行 skillheadless / 一次性)
安裝好之後,不必進互動介面,一行指令就能叫某個 skill 跑完並印出結果:
| 助理 | headless 指令 | 執行 `spec-output` skill |
| --- | --- | --- |
| Claude Code | `claude -p "<prompt>"` | `claude -p "/jsc:spec-output"` |
| Codex | `codex exec "<prompt>"` | `codex exec '$spec-output'` |
| Antigravity | `agy -p "<prompt>"` | `agy -p "/jsc:spec-output"` |
| OpenCode | `opencode run "<message>"` | `opencode run "說明 JSC 共用輸出規範的內容"` |
- Claude / Antigravity 支援 `/jsc:` 前綴,直接 `-p "/jsc:<name>"` 即可。
- Codex 以 `$<name>` 觸發;在 shell 請用**單引號**避免 `$` 被展開:`codex exec '$spec-output'`
- OpenCode 沒有前綴,用自然語言描述需求,模型會自動透過 skill 工具呼叫。
- 帶引數就接在後面,例如 `claude -p "/jsc:spec-output 參數"``codex exec '$spec-output 參數'`
---
## Skills 目錄
> 此區塊列出本 plugin 內含的所有 skills(名稱/描述/使用方法)。
> 新增或修改 skill 後,請同步手動更新標記之間的內容。
<!-- JSC-SKILLS:START -->
### 共用規範(spec-*
以下 skills 是 **codedoc plugins 各 skill 引用的共用規範**:其他 skill 內文以 `/jsc:spec-<name>` 引用時載入;也可單獨呼叫查看規範內容。
| Skill | 類型 | 內容 |
| --- | --- | --- |
| `spec-output` | 輸出規範 | 繁體中文(台灣用語)、UTF-8 無 BOM 無亂碼、表格與 Mermaid 呈現、subagent 提示需帶入本規範 |
| `spec-execution` | 執行原則 | 自動執行原則(必要決策才中斷、已知資訊跳過詢問)、不臆測/需人工確認、不擴及無關檔案 |
| `spec-gitea` | Gitea 工具 | teaAPI 工具選擇與檢查、GITEA_TOKEN 機密保護、不依賴 jq、API 分頁與 UTF-8 JSON body、host 決定順序 |
| `spec-git-safety` | Git 安全 | 不破壞既有工作(絕不 reset --hardclean)、git mv 保留歷史、develop → master 後備、pull --ff-only、保守解衝突 |
| `spec-time-log` | 時間與訊息 | Asia/Taipei `yyyy/MM/dd HH:mm:ss` 更新時間與統一同步、`[時間][階段][等級]: 訊息` log 格式、一行一則 |
| `spec-action-params` | Action 參數 | action 參數來源優先序(context/環境變數 → inputs)、secretsvars 一律視為不可用 |
| `spec-dockerfile` | Dockerfile | 六步流程(參數→安裝→複製→執行→縮小→入口)、多階段建置、固定版號、對外契約不動、自我檢查 |
| `spec-project-board` | Gitea 看板 | 進度欄位語意對應、建議欄位規則、GET 探測(404/501 不支援)、不往回移、不得新建欄位 |
| `spec-doc-funcs-handoff` | 文件化串接 | code 類 skill 完成後完整執行 /jsc:doc-funcs 的標準流程與統一時間戳 |
| `spec-plugin-version` | 版號規則 | 三 manifest 同步 bump、對照 master 確保單調遞增、新 plugin 首發 0.0.1、chore(plugin 版本) commit |
### 全域自動化
| Skill | 類型 | 內容 |
| --- | --- | --- |
| `worklog` | 工作證明記錄 | 每輪工作濃縮成條目追加到 Gitea wiki 當週頁(`Worklog-yyyy-MM-W<週>`);`--init``--tune`Claude Code 專屬)/`--diagnose``--append``--show` 五個模式;自動記錄由 Claude Code `Stop` hook 完成,**OpenCode 不支援**(見上方適用範圍表) |
<!-- JSC-SKILLS:END -->
---
## 新增一個 skill
1. 複製既有 skill 作範本:`cp -r skills/spec-output skills/<your-skill-name>`
2. 編輯 `skills/<your-skill-name>/SKILL.md` 的 frontmatter
- `name`:小寫、數字、連字號(`-`),最長 64 字元。**這就是 Claude Code / Antigravity 的 `/jsc:<name>`**。
- `description`:第三人稱,寫清楚「何時用、何時不用」與觸發關鍵字 — 這是各助理自動載入的唯一依據。
3. 在內文寫下 skill 的具體步驟。
4. 手動把這個 skill 補進上方「Skills 目錄」區塊。
5. **bump 版本並 push**:四家都以 git 內容/版本判斷更新,請把 `.claude-plugin/plugin.json``.codex-plugin/plugin.json``plugin.json` 三個 manifest 的 `version` 一起 bump(規則見 `skills/spec-plugin-version/`),commit 後 push 到 gitea。
6. 讓各助理更新:
- Claude`claude plugin update jsc@generic`
- Codex`codex plugin marketplace upgrade generic`
- Antigravity`git -C ~/plugins/generic pull && agy plugin uninstall jsc && agy plugin install ~/plugins/generic`(路徑與上方 Antigravity 安裝節一致)
- OpenCode`git pull` 後重新複製 `skills/`
> **skill 帶可執行元件時**(腳本、hook)額外注意:
>
> - 腳本放 `scripts/<skill-name>/`**不要**放進 `skills/`hook 定義放 `hooks/hooks.json`command 用 `${CLAUDE_PLUGIN_ROOT}/...` 絕對路徑。
> - 腳本要有執行權限並確實入 git`git ls-files -s` 應顯示 `100755`)。
> - `SKILL.md` **不可用相對路徑呼叫腳本** —— skill 執行時的工作目錄是使用者的專案目錄;請以 `${CLAUDE_PLUGIN_ROOT}`(其他助理用 skill base directory 往上兩層)組出絕對路徑。
> - 在 `SKILL.md` 的 `description` 與上方適用範圍表標明支援哪幾家;OpenCode 因只複製 `skills/`,凡依賴 `scripts/` 的 skill 一律不支援。