Files
shared/README.md
T

182 lines
15 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-shared — 跨 AI 助理共用規範 Plugin
一個可同時被 **Claude Code、Codex、Antigravity、OpenCode、GitHub Copilot** 使用的共用規範 plugin。
核心是以 [Agent Skills(`SKILL.md`)](https://agentskills.io) 標準撰寫的共用 skills(唯一真實來源放在 `skills/`),
搭配各助理各自的 plugin manifest,讓**同一個 repo** 可用各家**原生 plugin CLI** 安裝。
在 Claude Code 與 Antigravity 中,skill 以 **`/jsc-shared:` 前綴**呼叫(例如 `/jsc-shared:spec-output`)。
---
## 前綴與呼叫方式
| 助理 | 安裝方式 | 呼叫 | `/jsc-shared:` 前綴 |
| --- | --- | --- | --- |
| Claude Code | `claude plugin`(marketplace) | `/jsc-shared:<name>` 或自動觸發 | ✅ |
| Codex | `codex plugin`(marketplace) | `$<name>` 或 `/skills` 選單 | ❌(用 `$name`) |
| Antigravity | `agy plugin install` | `/jsc-shared:<name>` 或自動觸發 | ✅ |
| OpenCode | skills 目錄(先 clone 到工具專屬資料夾,再依 README 匯入) | 描述需求自動觸發 | ❌(依名稱) |
| GitHub Copilot CLI | `copilot plugin`(marketplace) | 自然語言或 plugin skills | ❌(無 `/jsc-shared:` 前綴) |
> Codex 不支援自訂前綴(skill 以 `$name` 呼叫);OpenCode 由模型依描述自動呼叫;Copilot CLI 透過原生 plugin 安裝後以自然語言或 plugin skills 使用。三者皆**不強制**前綴。
---
## 目錄結構
同一個 repo 同時帶四種 manifest,彼此以路徑隔離、互不干擾;各助理都讀同一份 `skills/`。
```
shared/
├── .claude-plugin/
│ ├── plugin.json # Claude 外掛定義(name: "jsc-shared")
│ └── marketplace.json # Claude marketplace(name: "shared",source 指向本 repo)
├── .codex-plugin/
│ └── plugin.json # Codex 外掛定義(name: "jsc-shared",skills: "./skills")
├── .agents/plugins/
│ └── marketplace.json # Codex marketplace(name: "shared",url source 指向本 repo)
├── plugin.json # Antigravity 外掛定義(name: "jsc-shared",skills: "./skills/")
├── skills/ # ★ 唯一真實來源:所有 skills
│ ├── spec-*/SKILL.md # 共用規範 skills(一規範一目錄)
│ ├── plugins-install/ # 一次安裝/更新 jsc-code、jsc-doc、jsc-persona
│ └── plugins-uninstall/ # 一次移除 jsc-code、jsc-doc、jsc-persona、jsc-shared
├── AGENTS.md # 跨助理共用指引
└── README.md
```
> shared 的定位是「**共用規範**」:`skills/spec-*` 是 code/doc plugins 共用的流程與安全規範。工作紀錄自動化 `worklog` 已移到 `doc` plugin。
> 例外只有 `plugins-install`/`plugins-uninstall` 兩類:它們是**整組 plugin 的安裝管理**,一次處理所有 JSC plugin,不必逐個 repo 翻 README。
---
## 安裝 / 更新 / 移除(各助理)
> 本 repo 的安裝/更新/移除流程一律以 Gitea 遠端檔案為準,不依賴既有本機存取庫。
>
> 完整的安裝/更新/移除指令(Claude Code、Codex、Antigravity、OpenCode、GitHub Copilot CLI 五種助理),一律以 [`/jsc-shared:spec-plugin-cli`](https://gitea.jsc.idv.tw/plugins/shared/src/branch/master/skills/spec-plugin-cli/SKILL.md) 為唯一權威版本,套用時代入下列佔位符:
>
> | 佔位符 | 值 |
> | --- | --- |
> | `<host>` | `gitea.jsc.idv.tw` |
> | `<name>` | `shared` |
> | `<plugin>` | `jsc-shared` |
> | `<marketplace>` | `shared` |
> | `<token>`(= `<plugin>@<marketplace>`) | `jsc-shared@shared` |
> | `<url>` | `https://gitea.jsc.idv.tw/plugins/shared.git` |
---
## 用 CLI 直接執行 skill(headless / 一次性)
安裝好之後,不必進互動介面,一行指令就能叫某個 skill 跑完並印出結果:
| 助理 | headless 指令 | 執行 `spec-output` skill |
| --- | --- | --- |
| Claude Code | `claude -p "<prompt>"` | `claude -p "/jsc-shared:spec-output"` |
| Codex | `codex exec "<prompt>"` | `codex exec '$spec-output'` |
| Antigravity | `agy -p "<prompt>"` | `agy -p "/jsc-shared:spec-output"` |
| OpenCode | `opencode run "<message>"` | `opencode run "說明 JSC 共用輸出規範的內容"` |
| GitHub Copilot CLI | `copilot -p "<message>"` | `copilot -p "說明 JSC 共用輸出規範的內容"` |
- Claude / Antigravity 支援 `/jsc-shared:` 前綴,直接 `-p "/jsc-shared:<name>"` 即可。
- Codex 以 `$<name>` 觸發;在 shell 請用**單引號**避免 `$` 被展開:`codex exec '$spec-output'`。
- OpenCode 與 Copilot 沒有前綴,用自然語言描述需求;Copilot CLI 會讀取已安裝 plugin 提供的 skills。
- 帶引數就接在後面,例如 `claude -p "/jsc-shared:spec-output 參數"`、`codex exec '$spec-output 參數'`。
---
## Skills 目錄
> 此區塊列出本 plugin 內含的所有 skills(名稱/描述/使用方法)。
> 新增或修改 skill 後,請同步手動更新標記之間的內容。
<!-- JSC-SKILLS:START -->
### 共用規範(spec-*)
以下 skills 是 **code/doc/persona plugins 各 skill 引用的共用規範**:其他 skill 內文以 `/jsc-shared:spec-<name>` 引用時載入;也可單獨呼叫查看規範內容。
| Skill | 類型 | 內容 |
| --- | --- | --- |
| `spec-output` | 輸出規範 | 繁體中文(台灣用語)、UTF-8 無 BOM 無亂碼、表格與 Mermaid 呈現、subagent 提示需帶入本規範 |
| `spec-execution` | 執行原則 | 自動執行原則(必要決策才中斷、已知資訊跳過詢問)、不臆測/需人工確認、不擴及無關檔案 |
| `spec-gitea` | Gitea 工具 | tea/API 工具選擇與檢查、GITEA_TOKEN 機密保護、不依賴 jq、API 分頁與 UTF-8 JSON body、host 決定順序 |
| `spec-git-safety` | Git 安全 | 不破壞既有工作(絕不 reset --hard/clean)、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)、secrets/vars 一律視為不可用 |
| `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 為基準計算同一 PR 的最終版本、新 plugin 首發 0.0.1、patch 到 9 後進位 minor、chore(plugin 版本) commit |
| `spec-preflight` | 前置載入 | 每個 skill 執行前先載入本規範自身再依序載入其他 spec、任一載入不到即詢問是否安裝 shared、拒絕就中斷、絕不憑摘要繼續 |
| `spec-conventional-commit` | Commit 分類 | `git status --porcelain=v1 -uall` 完整盤點、9 種 commit 類型對照、`type(範圍):一句總結` 格式、逐組精準 `git add` 分類提交 |
| `spec-pull-request` | PR 建立 | 目標分支不得臆測、解析 origin 座標決定 owner/repo、full/simple 兩種描述模式、body 以 UTF-8 檔帶入、已有相同 head→base 開啟中 PR 就沿用 |
| `spec-git-push` | Push 憑證 | credential helper → token(遮蔽、用完即棄)→ 詢問使用者三段式,與 `spec-gitea` 的 token 解析優先序用途不同、不可互相取代 |
| `spec-issue-read` | 議題讀取 | 必須含描述、所有留言與所有附件、分頁完整讀取、彙整需求不得臆測缺漏部分,須詢問使用者或標記「未提及」 |
| `spec-todo-list` | TODO 清單 | Markdown checklist 格式、每項具體可驗收、依影響範圍由小到大排序、對應 `path:line` 或議題描述、完成一項就勾選並回報 |
| `spec-ask-user` | 詢問使用者 | 單選/多選時機判斷、選項上限 4(超過改列文字)、每組含「其他」自訂輸入、已知答案跳過詢問、絕不要求貼 token/密碼 |
| `spec-subagent` | Subagent 派工 | 一個明確目標派一個 subagent、subagent 只讀不寫、回傳結構化結果、派工提示帶入 `spec-output`、不得改動原始碼或直接寫外部系統 |
| `spec-no-scratch-files` | 不落地 | 全程不建立任何草稿檔/暫存檔、中間成果留在對話或議題內容,唯一例外是議題附件唯讀暫存下載、讀完即刪 |
| `spec-skill-invocation` | 呼叫方式 | 各助理呼叫一個 skill 的統一表格:Claude Code/Antigravity 斜線指令、Codex `$name`、OpenCode 依 description 自動觸發 |
| `spec-script-path` | 腳本路徑 | plugin 內腳本絕不可用相對路徑:Claude Code 用 `${CLAUDE_PLUGIN_ROOT}`、其他助理由載入時的 base directory 往上兩層推導 |
| `spec-action-scaffold` | Action 骨架 | 目錄無 action manifest 時判斷 action 根目錄並觸發問答式從零建立,固定三題骨架(名稱/用途、輸入輸出、執行目標) |
| `spec-node-src-layout` | Node src 收攏 | 主程式入口及其依賴鏈的 `.js`/`.mjs`/`.cjs` 收進 `src/`、排除設定檔與 test 目錄、搬移後同步更新所有引用路徑 |
| `spec-plugin-cli` | Plugin CLI 指令 | 五種助理(Claude Code/Codex/Antigravity/OpenCode/Copilot CLI)的 install/update/uninstall 完整指令語法與佔位符,唯一權威版本 |
| `spec-model` | 模型標籤與檢查 | 固定標籤體系(能力等級/成本/延遲/上下文/用途/可用性)、任務→必要標籤對映表、取得模型清單的權威來源優先序、`~/.claude/jsc/models.json` 快取設計(30 天過期)、強制切換規則、讀到帶 `model:` frontmatter 清單檔時的模型檢查義務 |
### 規範相關工具
以下 skills 不是 `spec-*` 規範本身,而是**依規範實際做事的可執行工具**:
| Skill | 用途 | 使用方法 |
| --- | --- | --- |
| `models` | 查詢目前可用哪些模型並依 `spec-model` 的標籤體系標註,維護 `~/.claude/jsc/models.json` 快取,依任務類型推薦模型或檢查當前模型是否符合指定模型。是 `spec-model` 的唯一可執行入口——其他 skill 需要模型清單或推薦時一律呼叫本 skill,不自行重寫探測或推薦邏輯 | `/jsc-shared:models`;可帶 `--refresh`(重跑探測與 smoke test)、`--task <analysis\|implement\|review\|summary\|persona>`(依對映表推薦模型)、`--check <model>`(比對指定模型與當前模型)、`--json` |
| `plan-wiki` | 逐步詢問使用者計畫內容,並把每一輪已確認的計畫草稿直接同步到指定 Gitea wiki 的目錄頁與計畫頁;全程不建立本機計畫檔、草稿檔、暫存 JSON body 或 wiki clone | `/jsc-shared:plan-wiki`;可帶 `--wiki-repo <owner/repo>`、`--index <目錄頁title>`、`--project <計畫名稱>`、`--page <計畫頁title>`、`--host <gitea主機>`、`--yes` |
| `todo-wiki` | 把「需求 → 分析 → 產生鎖定模型的 TODO 清單 → 同步到 Gitea wiki 目錄與頁面」固定成不落地檔案的流程;不產生本機 `todo.md`,只寫入指定 wiki 目錄頁與 todo 頁 | `/jsc-shared:todo-wiki`;可帶 `--source <需求描述\|檔案路徑\|議題編號>`、`--impl-model <id\|alias>`、`--wiki-repo <owner/repo>`、`--wiki-index <目錄頁title>`、`--wiki-project <計畫名稱>`、`--wiki-page <todo頁title>`、`--append\|--overwrite`、`--yes` |
### 整組 plugin 安裝管理
一次操作所有 JSC plugin,不必逐個 repo 翻 README 的安裝章節。四家原生 plugin CLI(`claude`/`codex`/`copilot`/`agy`)都支援,OpenCode 走複製/刪除 skills 目錄。
| Skill | 用途 | 使用方法 |
| --- | --- | --- |
| `plugins-install` | 一次**安裝或更新** `jsc-code`、`jsc-doc`、`jsc-persona`、`jsc-shared`:先盤點每個 plugin 已安裝或未安裝,未安裝就安裝、已安裝就更新到最新,最後以表格回報動作、位置、結果與版本。`agy` 走 clone+本地路徑安裝;OpenCode 這類**沒有 plugin 匯入指令、但可使用 skill** 的助理先把技能組 clone 到工具專屬資料夾,再依技能組 `README.md` 匯入到指定位置,**已安裝就在該路徑就地更新、未安裝才放進工具的全域資料夾** | `/jsc-shared:plugins-install`;可帶 `--assistant claude\|codex\|copilot\|agy\|opencode`、`--plugins code,doc,persona,shared`、`--host <gitea 主機>`、`--clone-dir <目錄>`、`--yes` |
| `plugins-uninstall` | 一次**移除** `jsc-code`、`jsc-doc`、`jsc-persona`、`jsc-shared`:動手前先列出將被移除的項目與不會被碰的資料請使用者確認,移除順序固定把 `jsc-shared` 放最後(本 skill 就住在裡面)。人格倉庫與記憶目錄一律不刪;OpenCode 這類**沒有 plugin 匯入指令、但可使用 skill** 的助理則依技能組 `README.md` 反向刪除匯入位置 | `/jsc-shared:plugins-uninstall`;可帶 `--assistant …`、`--plugins code,doc,persona,shared`、`--keep-marketplace`、`--yes` |
> `plugins-install` 與 `plugins-uninstall` 都會處理 `jsc-shared`;移除時一定放最後一步。
<!-- JSC-SKILLS:END -->
---
## 跨助理支援度
`skills/` 各助理都能用。
| 元件 | Claude Code | Codex | Antigravity | OpenCode | GitHub Copilot |
| --- | --- | --- | --- | --- | --- |
| `skills/spec-*`(純規範) | ✅ | ✅ | ✅ | ✅ | ✅ |
| `skills/plugins-install`、`plugins-uninstall` | ✅ | ✅ | ✅ | ⚠️ 只能操作 OpenCode 自己 | ✅ |
| cron 睡眠整理(系統排程) | ✅ | ✅ | ✅ | ✅ | ✅ |
> **OpenCode 以複製 `skills/` 目錄安裝**。
---
## 新增一個 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-shared:<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-shared@shared`
- Codex:`codex plugin marketplace upgrade shared`
- Antigravity:重新從 Gitea 遠端抓取到暫存目錄後再 `agy plugin uninstall jsc-shared && agy plugin install <temp-dir>/shared`
- OpenCode:重新從 Gitea 遠端抓取到暫存目錄後再複製 `skills/`
- Copilot:`copilot plugin marketplace update shared && copilot plugin update jsc-shared@shared`
> 本 repo 只放純 `SKILL.md` 內容,不含可執行腳本或 hook。