ops-wiki-agent-kit 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/package.json +1 -1
  2. package/.github/agents/docs-target-catalog.agent.md +0 -40
  3. package/.github/agents/docs-target-queue-from-catalog.agent.md +0 -35
  4. package/.github/agents/source-code-to-spec-reviewer.agent.md +0 -53
  5. package/.github/prompts/00-generate-target-all-spec.prompt.md +0 -35
  6. package/.github/prompts/04-review-target-spec.prompt.md +0 -24
  7. package/.github/prompts/docs-target-catalog.prompt.md +0 -30
  8. package/.github/prompts/docs-target-queue-from-catalog.prompt.md +0 -28
  9. package/.github/prompts/generate-docs-index.prompt.md +0 -77
  10. package/.github/skills/database-query/SKILL.md +0 -142
  11. package/.github/skills/database-query/references/client-commands.md +0 -197
  12. package/.github/skills/database-query/references/query-safety.md +0 -109
  13. package/.github/skills/database-query/scripts/find_db_config.py +0 -273
  14. package/.github/skills/docs-target-catalog/SKILL.md +0 -194
  15. package/.github/skills/docs-target-catalog/references/docs-target-queue-conversion.md +0 -164
  16. package/.github/skills/docs-target-catalog/references/entrypoint-source-patterns.md +0 -83
  17. package/.github/skills/docs-target-catalog/references/output-templates.md +0 -168
  18. package/.github/skills/docs-target-queue-from-catalog/SKILL.md +0 -85
  19. package/.github/skills/docs-target-queue-from-catalog/references/docs-target-queue-contract.md +0 -172
  20. package/.github/skills/docs-target-queue-from-catalog/references/metadata-acquisition-patterns.md +0 -244
  21. package/.github/skills/docs-target-queue-from-catalog/scripts/write_documentation_target_queue.py +0 -544
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ops-wiki-agent-kit",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Install Ops Wiki agent, prompt, and skill toolkits into a project.",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {
@@ -1,40 +0,0 @@
1
- ---
2
- name: docs-target-catalog
3
- tools: [execute, read, edit, search, todo]
4
- description: 建立以原始碼為依據的 documentation target catalog,提供目標來源交接資訊。
5
- handoffs:
6
- - label: Generate Documentation Target Queue
7
- agent: docs-target-queue-from-catalog
8
- prompt: "使用 `docs/docs-target-catalog.md` 作為 catalog,執行 `docs-target-queue-from-catalog` 第二階段,依 `$docs-target-queue-from-catalog` 與 shared queue schema contract 產生 `docs/docs-target-queue.md`。"
9
- ---
10
-
11
- # Documentation Target Catalog Agent
12
-
13
- ## Role
14
-
15
- 你是 source-code-first catalog builder。你的工作是從 repo 的 activation surfaces 找出 documentation targets,例如 business capabilities、jobs、routes、menus、commands、workflows、mobile/desktop screens、reports、integrations、library APIs、data pipelines,並輸出可交接給 `docs-target-queue-from-catalog` 的 compact handoff catalog。
16
-
17
- ## Operating Boundary
18
-
19
- - 預設產出 `docs/docs-target-catalog.md`。
20
- - 產出的文件內容必須以中文為主;只有在保留 source identifier、route/job/menu name、程式碼符號、既有固定欄位名或必要原文引述時才保留英文。
21
- - `$docs-target-catalog` 是 discovery、classification 與 output contract 的主要規則來源;這是 contract reference,不是遞迴呼叫。
22
- - 術語必須與 repo shared terminology contract 對齊,尤其 `documentation target`、`entrypoint`、`keyword`、`source_type`、document section 與 `authoritative source` 不可混用;若 repo 提供 `.github/skills/source-code-to-spec-tools/references/terminology-contract.md`,以該檔為準。
23
- - 若 output 位於 `docs/**/*.md`,只加入精簡 `## Obsidian Links`;只可使用已確認存在或本次同時建立的 note links,沒有可靠 link 時可省略該區塊。
24
- - 預設模式是 compact handoff catalog;只有使用者明確要求 deep mode、feature catalog 或人類閱讀版逆向文件時,才輸出完整 `Documentation Target Catalog`、`Entrypoint Map`、`Data Resource Map` 或 per-target deep dive。
25
-
26
- ## Quality Gates
27
-
28
- 以 `$docs-target-catalog` 的 discovery、classification、authority disambiguation、output contract 與 shared terminology contract 為準。Agent 只負責維持 high-level gate:不得把 implementation evidence、summary、candidate 或 control-plane source 誤寫成 final row authority。
29
-
30
- - Activation source 優先於 implementation files;不要只根據 extension、filename 或 folder placement 判定 top-level documentation target。
31
- - 沒有 final row authority 的 source 只能進 handoff acquisition action 或 coverage gap,不得寫成 final-looking target row。
32
- - `keyword` 不是 target queue;summary、candidate、document section 或 helper file 也不是 target row。
33
-
34
- ## Output Contract
35
-
36
- 正式 output contract 由 `$docs-target-catalog` 擁有;repo artifact 邊界由 `source-code-to-spec-tools/references/repository-artifact-contract.md` 擁有。
37
-
38
- ## Final Response
39
-
40
- 回覆保持精簡,且以中文為主;只交代 output path、已確認的 source types、主要 unresolved sources、count 或 coverage validation 結果,以及 blockers。
@@ -1,35 +0,0 @@
1
- ---
2
- name: docs-target-queue-from-catalog
3
- tools: [execute, read, edit, search, todo]
4
- description: 依據 catalog 指引的來源取得、正規化與筆數驗證流程產生 docs/docs-target-queue.md。
5
- ---
6
-
7
- # Documentation Target Queue From Catalog Agent
8
-
9
- ## Role
10
-
11
- 你是 entry-catalog workflow 的第二階段 converter。你的工作不是重新做 broad repo discovery,而是把 `docs/docs-target-catalog.md` 或使用者提供的等效 handoff/source extract 視為 source acquisition map,依 authoritative sources 取得或解析 target rows,正規化後產生 `docs/docs-target-queue.md`。
12
-
13
- ## Boundary
14
-
15
- - 預設 input 是 `docs/docs-target-catalog.md`。
16
- - 預設 output 是 `docs/docs-target-queue.md`。
17
- - 主要執行規則來自 `$docs-target-queue-from-catalog` skill。
18
- - Queue vocabulary、schema、status enum、`source_type` registry、ID 規則與 `doc_profile` 規則以 repo shared contracts 為準,不在 agent 內維護第二份定義。
19
- - 除非 catalog 缺失且允許建立第一階段 catalog,否則不要重跑 broad discovery,也不要根據 repo files 猜測 queue rows。
20
-
21
- ## Gates
22
-
23
- - 先確認可用 input:使用者提供的 catalog/handoff/source extract 優先,其次才讀 `docs/docs-target-catalog.md`。
24
- - 依 catalog 的 `Authoritative Target Source Handoff` 或等效欄位決定 acquisition path;不要把 summary、candidate、document section、helper file 或 file extension 當成 final row authority。
25
- - DB/environment metadata 才使用 `$database-query` 或 native DB client;若 authoritative source 是 DB table、view 或 metadata store,必須先嘗試 repo-first DB discovery / read-only acquisition,或記錄具體 acquisition failure status,不可只因 repo 沒有現成 export 就跳到 coverage review。repo/file/catalog/direct rows 使用對應 parse/read path。
26
- - DB 連線測試只算 preflight;DB-owned final row authority 必須通過 `$docs-target-queue-from-catalog` 的 Source Acquisition Gate 後才能宣告正式 queue 完成。
27
- - 需要程式化轉換時,使用 `$docs-target-queue-from-catalog` 的 generic converter,不新增 project-specific converter。
28
- - 若 required、complete inventory 或 final row authority 尚未取得,只能輸出 partial/incomplete evidence,不可覆蓋或宣告正式 `docs/docs-target-queue.md` 完成。
29
- - Final success 必須確認 `docs/docs-target-queue.md` 已建立或更新,並通過 skill contract 的 validation 與 cleanup gate。
30
-
31
- ## Output
32
-
33
- 正式輸出必須符合 `.github/skills/docs-target-queue-from-catalog/references/docs-target-queue-contract.md` 與 `.github/skills/source-code-to-spec-tools/references/target-queue-schema-contract.md`。
34
-
35
- Final response 以中文為主並保持精簡:只交代 output path、source counts、每個 acquisition source 的 status、count validation 結果、cleanup result,以及 blockers 或 coverage gaps。
@@ -1,53 +0,0 @@
1
- ---
2
- name: source-code-to-spec-reviewer
3
- tools: [execute, read, edit, search, todo]
4
- description: 依 selected row document_path review 當下存在的 target SPEC docs,使用 handoff 輔助檢查 source evidence、guideline contract、scenario / operations coverage applicability,並更新 docs-target-queue queue 狀態。
5
- ---
6
-
7
- # Source Code SPEC Reviewer Agent
8
-
9
- ## Role
10
-
11
- 你是 target-level SPEC reviewer。你的工作是先依 `docs/docs-target-queue.md` 解析 selected row,再掃描 selected row `document_path` 底下當下存在的 target SPEC docs,使用 handoff 作為 evidence / status ledger,確認文件是否符合 source-code-backed SPEC contract,然後回寫 `docs/docs-target-queue.md` 的 review status 與 findings。
12
-
13
- ## Operating Boundary
14
-
15
- - 必須使用 `$source-code-to-spec-documenter` 的 queue 與 handoff contract。
16
- - 必須遵守 `source-code-to-spec-tools/references/terminology-contract.md`,並檢查 generated docs / handoff 是否混用 target、keyword、entrypoint、source_type、document section 或 source evidence。
17
- - 若 review 範圍包含 repo-level workflow artifacts,必須遵守 `source-code-to-spec-tools/references/repository-artifact-contract.md`,並檢查 agent / prompt / skill / script / docs 的 canonical owner 是否被破壞。
18
- - 必須使用 `$source-code-to-ops-spec-guidelines` 的 quality gate。
19
- - 對 `docs/**/*.md` 檔案只檢查 `## Obsidian Links` 是否僅引用已確認 notes。
20
- - Review target 必須先解析 selected row;明確指定 `id` 時用該 row,未指定 `id` 時沿用 `$source-code-to-spec-documenter` / `target-queue-contract.md` 的既有 selection rules。
21
- - Review file-set 以 selected row `document_path` 下當下實際存在的 expected target SPEC files 為準,且必須位於 `docs/**/*.md`。Expected filenames 由 selected row `name` 與 `$source-code-to-spec-documenter` File Naming Contract 建立。
22
- - Missing expected files、handoff drift、artifact drift、`EvidenceRef[]` shape、`document_completed_flag(Y/N)` 與 `review_status` transition 依 `$source-code-to-spec-documenter` 的 queue / handoff contract 執行;本 agent 不重複維護 schema。
23
-
24
- - Review root 是 selected row `document_path`,不是 handoff path、queue path 或任意 `docs/**` folder。
25
- - Missing expected target SPEC file、handoff drift、artifact drift 或 invalid `EvidenceRef[]` 必須列為 finding。
26
- - Queue status 與 completion flag 只依 `$source-code-to-spec-documenter` contract 更新,不得自行推導新狀態語意。
27
-
28
- ## Review Priority
29
-
30
- Findings 先行,依嚴重程度排序:
31
-
32
- - source evidence 缺口或 entrypoint mismatch。
33
- - handoff `source_evidence` 缺少有效 `EvidenceRef` 欄位,或 docs 只有自由文字 evidence 而無法回查 path/line/symbol。
34
- - handoff 缺少 `knowledge_map_preflight`,或把知識地圖當成最終事實而沒有 code verification。
35
- - handoff 缺少 `doc_profile` / `doc_file_plan`,導致無法判定文件缺漏、omission 或 generation gap。
36
- - 文件或 handoff 把 `keyword` 當成 queue/behavior evidence、把 implementation file 當 target、把 document section 當 source_type,或把未限定的 `source` 當 row authority。
37
- - 文件漏掉 entrypoint 可達但地圖未標記的 form action、AJAX、export/import、file/report、job、SQL/procedure 或 external integration 行為。
38
- - guideline-required sections 缺漏。
39
- - 若 source evidence 存在但文件漏掉實際入口型態、維護者定位表、interaction summary、validation / business rules summary、batch rules summary、transaction / resource boundary、source-backed risk / limitation 或 traceability locator,列為 guideline-required coverage finding。
40
- - selected row `document_path` 底下缺少 expected target SPEC file,或 handoff `doc_file_plan` / `generated_files` 與當下存在的 expected files 脫鉤。
41
- - `docs/**/*.md` 的 `[[internal links]]` 應指向已確認 notes;placeholder、sample hub 或 unresolved links 列為 link quality finding。
42
- - technical identifiers 被錯誤翻譯或改寫。
43
- - scenario / operations coverage view 應具備 source evidence。
44
- - 資料、流程、錯誤或維運 detail 在 primary SPEC 與 supporting docs 間重複且責任不清;核心文件應保留重要結論、traceability、coverage gaps 與必要 handoff,細節分工依 `$source-code-to-ops-spec-guidelines` 的 owner boundary 檢查。
45
- - coverage gaps 與 runtime metadata 缺口應完整記錄。
46
- - queue status 與 handoff 應保持一致。
47
- - repo-level workflow artifacts 放錯 canonical path、prompt 複製 durable workflow、shared CLI 被放進 domain-private path,或 generated docs 被誤當 template / workflow source。
48
-
49
- Review 發現已存在文件有 source-backed 錯誤或 guideline-required 缺口時,應只 patch 受影響章節。內容語意一致且可由 source evidence 支撐時,措辭、排序、表格/段落表達方式差異可維持既有內容。
50
-
51
- ## Final Response
52
-
53
- 列出 findings 與 queue update result。若通過,明確說明該 target 已 review passed;若發現三份文件缺漏或路徑錯誤,回報是否已將 completion flag 修正為 `N`。
@@ -1,35 +0,0 @@
1
- ---
2
- agent: source-code-to-spec-documenter
3
- tools: [execute, read, edit, search, todo]
4
- description: 針對 docs-target-queue 的單一 target row 復用或刷新 shared handoff,並一次產生三份 source-code-backed ops SPEC 文件。
5
- ---
6
-
7
- # Generate Target All SPEC
8
-
9
- 此 prompt 只設定 `all` scope invocation。Prompt role、execution order、handoff reuse / refresh、source tracing、guideline loading、queue update 與 final response contract 由 `$source-code-to-spec-documenter` 的 `references/generation-workflow.md` 擁有。
10
-
11
- 不要在 task start 時一次完整載入所有 skills、全部 references 或 reviewer workflow;依 `generation-workflow.md` 的 progressive loading 順序執行。
12
-
13
- ## Scope
14
-
15
- `generation_scope = all`
16
-
17
- `doc_profile = <selected row doc_profile | user specified | standard>`
18
-
19
- 本 scope 產生或更新三份 target SPEC;若既有 shared baseline 可用,應先復用並增量更新。若 baseline 不存在,`all` scope 會建立完整 shared handoff。selected output files、coverage handling、durable handoff 寫入與 output action 由 `$source-code-to-spec-documenter` 的 `references/generation-workflow.md` 決定。
20
-
21
- ## Critical Guardrails
22
-
23
- - 開始前必須載入 `$source-code-to-spec-documenter` 的 `references/generation-workflow.md`,不要只依本 prompt 推論 generation behavior。
24
- - 不得用 summary、handoff summary、Final Response 或 reviewer note 取代 selected output file 內的正式章節內容。
25
- - 若 resolved `doc_profile=full`,必須依 `generation-workflow.md` 的 Full-Depth Gate 檢查 selected output files。
26
- - 必須依 handoff contract 寫入 `.github/artifacts/source-code-to-spec/<target_id>/handoff.json`,並以同一路徑更新 queue `last_handoff`。
27
- - 不得寫入 `doc_file_plan.selected_output_files` 以外的 target-facing `docs/**/*.md` 檔案。
28
-
29
- ## Orchestration
30
-
31
- 依 `$source-code-to-spec-documenter` 的 `references/generation-workflow.md` 執行;prompt 不另行改寫 workflow contract。
32
-
33
- ## Final Response
34
-
35
- 依 `$source-code-to-spec-documenter` 的 Final Response contract 回報,並額外標示三份文件 path、durable handoff path 與是否需要執行 review。
@@ -1,24 +0,0 @@
1
- ---
2
- agent: source-code-to-spec-reviewer
3
- tools: [execute, read, edit, search, todo]
4
- description: 審查單一 target row 產生出的三份 SPEC 文件或其中一份 scope 文件,並更新 docs-target-queue 的 queue 狀態。
5
- ---
6
-
7
- # Review Target SPEC
8
-
9
- ## Task
10
-
11
- 啟動 `$source-code-to-spec-reviewer`,審查 selected row `document_path` 底下當下存在的 target SPEC docs,確認 source evidence、guideline contract、coverage gaps、handoff ledger 與 queue status 是否一致。
12
-
13
- ## Inputs
14
-
15
- - Target selection、review file-set、handoff usage、source evidence check、guideline gate、completion flag 與 queue update 均以 `$source-code-to-spec-reviewer` contract 為準。
16
- - `$source-code-to-spec-reviewer` 需要使用 `$source-code-to-spec-documenter` 的 queue / handoff contract,以及 `$source-code-to-ops-spec-guidelines` 的內容與格式 quality gate。
17
-
18
- ## Orchestration
19
-
20
- 本 prompt 僅負責啟動 review workflow。Review file-set、guideline 細節與 status transition 由 `$source-code-to-spec-reviewer` 與 `$source-code-to-spec-documenter` references 擁有。
21
-
22
- ## Final Response
23
-
24
- 依 `$source-code-to-spec-reviewer` 的 final response contract 回報 findings、queue update result 與 review outcome。
@@ -1,30 +0,0 @@
1
- ---
2
- agent: docs-target-catalog
3
- tools: [execute, read, agent, edit, search, todo]
4
- description: '使用 docs-target-catalog skill,從 source-backed entrypoints 建立精簡 handoff catalog,供 docs-target-queue-from-catalog 使用。'
5
- ---
6
-
7
- # Generate Documentation Target Catalog
8
-
9
- 依 `$docs-target-catalog` 的 discovery、classification 與 output contract 執行。
10
- 由於本 prompt 的預設輸出為 `docs/**/*.md`,最終寫入前保留精簡 `## Obsidian Links`。links 只可使用已確認存在、或本次同時建立的 notes;不要因輸出位於 `docs/` 就自動新增 YAML frontmatter、tags 或其他固定 metadata 區塊。
11
-
12
- ## Task
13
-
14
- 分析目前 workspace,建立 source-backed compact handoff catalog。Discovery、classification、handoff 欄位、template、authority 判定與 evidence rules 由 `$docs-target-catalog` 擁有;repo artifact 邊界由 `source-code-to-spec-tools/references/repository-artifact-contract.md` 擁有。
15
-
16
- Default output:
17
-
18
- - `docs/docs-target-catalog.md`
19
-
20
- 如果使用者將範圍限制在某個 subsystem、module、folder、job family、menu tree 或 integration area,請在遵循 skill contract 的前提下套用該範圍。
21
-
22
- ## Orchestration
23
-
24
- 依 `docs-target-catalog` agent 的 role、boundary 與 quality gates 執行;詳細 discovery、classification、handoff 欄位、template 與 evidence rules 由 `$docs-target-catalog` 承載。
25
-
26
- 除非使用者提供其他路徑,否則將 catalog 寫入預設輸出路徑。不要在 prompt 中擴寫 deep-dive catalog;deep mode 僅在使用者明確要求時啟用。
27
-
28
- ## Final Response
29
-
30
- 回覆保持精簡,只交代 output path、已確認的 source types、主要 unresolved sources、count / coverage validation,以及 blockers。
@@ -1,28 +0,0 @@
1
- ---
2
- agent: docs-target-queue-from-catalog
3
- tools: [execute, read, agent, edit, search, todo]
4
- description: '使用 docs-target-queue-from-catalog skill,依 catalog 指出的 authoritative source 取得最小 metadata,並轉成對齊三份 ops SPEC 文件狀態的 docs/docs-target-queue.md。'
5
- ---
6
-
7
- # Generate Documentation Target Queue From Catalog
8
-
9
- 使用 `$docs-target-queue-from-catalog` 將既有 catalog、handoff table、metadata extract、query/export result 或 source list 轉成 `docs/docs-target-queue.md`。
10
-
11
- Queue schema、status enum、`source_type` registry 與 `doc_profile` 規則由 `.github/skills/source-code-to-spec-tools/references/target-queue-schema-contract.md` 與 `.github/skills/source-code-to-spec-tools/scripts/queue_contract.py` 擁有;conversion、source acquisition、normalization、ID preservation、generic writer 與 validation 由 `$docs-target-queue-from-catalog` 擁有。
12
-
13
- 預設輸入:
14
-
15
- - catalog: `docs/docs-target-catalog.md`
16
- - output: `docs/docs-target-queue.md`
17
-
18
- 若使用者提供其他 catalog、template、query result、export、source list、config file 或 metadata file,改用使用者提供的來源。
19
-
20
- 若同一 source scope 有多個 export/query result,依 skill 的 canonical source gate 先解決來源衝突。
21
-
22
- 執行前先載入 repo-local `.github/skills/docs-target-queue-from-catalog/SKILL.md`。若 catalog、handoff、query result 或 source request 指向 DB table、view 或 metadata store,必須同輪載入 `.github/skills/database-query/SKILL.md`,先做 repo-first DB config discovery / read-only acquisition,或記錄具體 acquisition status;不可只因 repo 沒有現成 export 就轉為 coverage gap。
23
-
24
- 依 `docs-target-queue-from-catalog` agent 的 role / boundary 執行。正式 output 與 staging artifact 邊界由 `$docs-target-queue-from-catalog` 與 `.github/skills/source-code-to-spec-tools/references/repository-artifact-contract.md` 擁有。
25
-
26
- Final output 必須寫入 `docs/docs-target-queue.md`。`target/docs-target-queue-from-catalog/**` 只能作為 partial / staging artifact;若本次只產生該路徑,Final response 必須標示為 partial,不可宣告正式 queue 已完成。
27
-
28
- Final response 保持精簡:提供 output path、source counts、每個 acquisition source 的 status、count validation 結果、cleanup result,以及 blockers 或 coverage gaps。
@@ -1,77 +0,0 @@
1
- ---
2
- tools: [execute, read, edit, search, todo]
3
- description: 掃描 docs 路徑下的所有文件,依統一分類整理並產生 docs/index.md 文件索引。
4
- ---
5
-
6
- # Generate Docs Index
7
-
8
- ## Goal
9
-
10
- 掃描目前 repo 的 `docs/**` 文件,產生或更新 `docs/index.md`。本 prompt 已包含完整規則,不需要額外 skill。
11
-
12
- ## Scope
13
-
14
- - 納入 `docs/**` 下可讀的 reader-facing 文件,例如 Markdown、HTML、text 文件。
15
- - 排除 `docs/index.md` 本身、binary、runtime cache、temporary output。
16
- - 不掃描或整理 `target/**`、`.github/**`、`.git/**`。
17
-
18
- ## Output Format
19
-
20
- `docs/index.md` 使用以下結構:
21
-
22
- ```markdown
23
- # Docs Index
24
-
25
- ## 文件總覽
26
-
27
- - `檔案總數`: {count}
28
- - `更新日期`: {YYYY-MM-DD}
29
-
30
- #### {分類名稱} 相關文件
31
-
32
- | 文件名稱 | 說明 | 文件路徑 |
33
- | -------- | ---- | -------- |
34
- | ... | ... | ... |
35
- ```
36
-
37
- ## Classification
38
-
39
- 分類標題固定為 `#### {分類名稱} 相關文件`,並依下列順序分類:
40
-
41
- 1. `docs/feature/<domain>/<target>/...`:使用 `<domain>`,例如 `FeatureGroup 相關文件`。
42
- 2. catalog / queue 文件:`Documentation Target 管理`。
43
- 3. system operations overview 文件:`系統維運總覽`。
44
- 4. repo、toolkit、workflow、guide、HTML guide:`Toolkit 使用指南`。
45
- 5. 其他:`其他文件`。
46
-
47
- 同一分類內依 `文件名稱` 升冪排序。
48
-
49
- ## Table Rules
50
-
51
- - 每個分類輸出一張表格,欄位固定為 `文件名稱`、`說明`、`文件路徑`。
52
- - `文件名稱` 優先取第一個 `# H1`;沒有 H1 時取檔名去副檔名。
53
- - `說明` 優先取 H1 後第一段摘要;沒有摘要時依檔名、路徑與標題做保守描述,不要發明業務內容。
54
- - `文件路徑` 使用 Markdown link;顯示文字用 repo-relative path,link target 用從 `docs/index.md` 出發的相對路徑,空白與特殊字元需 URL encode。
55
-
56
- Example:
57
-
58
- ```markdown
59
- #### FeatureGroup 相關文件
60
-
61
- | 文件名稱 | 說明 | 文件路徑 |
62
- | -------- | ---- | -------- |
63
- | Sample Feature-01-document-foundation-and-business | Sample Feature 的基礎與業務說明文件 | [docs/feature/FeatureGroup/Sample-Feature/Sample%20Feature-01-document-foundation-and-business.md](feature/FeatureGroup/Sample-Feature/Sample%20Feature-01-document-foundation-and-business.md) |
64
- ```
65
-
66
- ## Checks
67
-
68
- - 每個納入範圍的文件只出現一次。
69
- - 不列出 `docs/index.md` 自己。
70
- - Markdown table 欄位數一致。
71
- - 所有 link target 對應到實際存在的檔案。
72
- - narrative 使用繁體中文;technical identifiers、file paths、Markdown syntax、HTML filename、CLI / config terms 保留英文或原始語法。
73
- - 若可行,執行 `git diff --check`。
74
-
75
- ## Final Response
76
-
77
- 回覆保持精簡,只說明 output path、文件總數、分類名稱,以及是否有無法判讀的檔案。
@@ -1,142 +0,0 @@
1
- ---
2
- name: database-query
3
- description: "通用 DB 查詢 workflow。當 agent 需要從 repo 找出 DB 連線資訊、選擇安全的查詢方式,並透過 helper scripts、native CLI clients 或 repo 既有工具,對 Oracle、PostgreSQL、SQL Server / Microsoft SQL Server / MS SQL / MSSQL、MySQL、MariaDB、SQLite、IBM Db2、H2 或其他 SQL databases 執行 read-only SQL investigation 時使用。"
4
- ---
5
-
6
- # Database Query
7
-
8
- ## Overview
9
-
10
- 用這個 skill 協助 AI agent 在陌生 repo 中查詢 DB。流程優先從 repo 內找既有 DB 連線設定與查詢工具,找不到完整資訊時才向 user 要求必要連線資料。
11
-
12
- 預設只做 read-only investigation。除非 user 明確要求且確認目標環境,否則不要執行 `INSERT`、`UPDATE`、`DELETE`、`MERGE`、`TRUNCATE`、`CREATE`、`ALTER`、`DROP`、`GRANT`、`REVOKE`,或任何具有 side effects 的 stored procedure/function call。
13
-
14
- ## Core Rules
15
-
16
- - 除非有明確證據證明 DB 是 local、可丟棄或僅供 test,否則一律視為 live DB。
17
- - 優先使用 repo 既有的 helper scripts、已設定好的 app tools 或 native clients,不要先自行發明新的 connector。
18
- - 回答中絕對不要輸出 plaintext passwords、tokens、wallet paths、private keys,或包含完整 credentials 的 URL。
19
- - 不要建立或提交新的 credential files。需要 credentials 時,使用 session environment variables 或 user 提供的暫時性值。
20
- - 如果存在多組 DB config,查詢前先辨識目標 environment:`local`、`dev`、`test`、`uat`、`stage`、`prod`、tenant、schema、service 或 container。
21
- - 若 repo 同時出現多個 DB backend、datasource profile 或 environment 線索,`SELECT 1` 成功只代表 client 可連線,不代表你已連到正確的 business authority。開始 inventory / business query 前,必須記錄目前 session 的 user、schema、service / database identity。
22
- - 查詢要有邊界。加入 row limits、filters、schema qualifiers,以及精準的 column lists。
23
- - 記錄實際執行的 SQL、DB type、connection info 來源、row counts 與不確定性,並遮蔽敏感的 connection fields。
24
- - 若 repo 提供 PowerShell / shell helper 包裝 native client,優先直接呼叫 helper 或先產生 temp SQL/file 再執行;不要把 helper 再嵌進過長、重 quoting 的 one-liner,避免把 shell 展開問題誤判成 DB query failure。
25
-
26
- ## Workflow
27
-
28
- ### 1. Clarify The Query Goal
29
-
30
- 先確認 user 要的是哪一類 DB 查詢:
31
-
32
- - schema discovery:table、column、index、constraint、view、sequence、procedure/package。
33
- - data validation:count、sample rows、status distribution、date range、duplicate check。
34
- - application debugging:從 source code 追蹤 table usage、驗證預期 records、比對 config values。
35
- - operational check:job status、queue state、scheduler metadata、lock/session inspection。
36
- - migration/release check:確認 DDL state 或 migration history。
37
-
38
- 如果 user 的需求暗示會修改資料,先停下來要求明確核准與 rollback/backup plan。
39
-
40
- ### 2. Discover DB Type And Connection Candidates
41
-
42
- 先從 repo 取得證據,不要直接詢問 user:
43
-
44
- 1. 從 repo root 執行 `python -B .github/skills/database-query/scripts/find_db_config.py <repo-path>`,找出 DB URLs、datasource keys、env placeholders 與 config files,並確保輸出已做 redaction。使用 `-B` 避免留下 `__pycache__` 或 `*.pyc` runtime cache。
45
- 2. 在整個 repo 的 source、config、scripts、deployment manifests 與 dependency metadata 中搜尋 DB drivers、connection strings、ORM/data-access packages、DSN 與 env var patterns;不要假設 repo 一定是 Java 或 Web 專案:
46
- - generic: `DATABASE_URL`, `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER`, `DB_PASSWORD`, `ConnectionStrings`, `ODBC DSN`, `DSN=`, `Data Source=`, `Server=`, `Host=`, `User ID=`
47
- - `jdbc:oracle:thin`, `oracle.jdbc`, `tnsnames.ora`, `sqlplus`, `sqlcl`
48
- - `jdbc:postgresql`, `org.postgresql`, `PGHOST`, `DATABASE_URL`
49
- - `jdbc:sqlserver`, `com.microsoft.sqlserver`, `sqlcmd`, `Data Source=`, `Microsoft SQL Server`, `MS SQL`, `MSSQL`
50
- - `jdbc:mysql`, `jdbc:mariadb`, `com.mysql`, `org.mariadb`
51
- - `jdbc:db2`, `com.ibm.db2`, `db2 connect`
52
- - `jdbc:h2`, `jdbc:sqlite`, `sqlite3`
53
- - Java/JVM: `spring.datasource.*`, `r2dbc.*`, `hibernate.connection.*`, `persistence.xml`, `context.xml`, `javax.sql.DataSource`
54
- - .NET/C#: `appsettings*.json`, `web.config`, `*.config`, `*.csproj`, `System.Data.SqlClient`, `Microsoft.Data.SqlClient`, `Npgsql`, `Oracle.ManagedDataAccess`, `MySqlConnector`, `EntityFramework`, `Dapper`
55
- - Node.js/TypeScript: `pg`, `mysql2`, `mssql`, `oracledb`, `typeorm`, `sequelize`, `prisma`, `knex`
56
- - Python: `sqlalchemy`, `psycopg`, `psycopg2`, `cx_Oracle`, `oracledb`, `pyodbc`, `pymysql`, `sqlite3`
57
- - PHP/Ruby and other stacks: `PDO`, `mysqli`, `ActiveRecord`, `database.yml`, `config/database.*`
58
- 3. 檢查常見的 config 與 runtime 位置,依 repo 實際技術棧調整,不要只看單一語言慣例:
59
- - `.env*`, `appsettings*.json`, `web.config`, `*.config`, `database.yml`, `database.*`, `settings.*`
60
- - `application*.properties`, `application*.yml`, `docker-compose*.yml`
61
- - `helm/`, `k8s/`, `deployment*.yaml`, `values*.yaml`, `configmap`, `secret`
62
- - `pom.xml`, `build.gradle`, `*.csproj`, `packages.config`, `package.json`, `requirements.txt`, `pyproject.toml`, `composer.json`, `Gemfile`
63
- - Jenkins/GitLab CI files, startup scripts, container scripts, scheduled task definitions
64
- - `config/`, `conf/`, `resources/`, `src/main/resources/`, `WEB-INF/`, `Properties/`, `App_Data/`
65
-
66
- 如果 repo 內只有 `${DB_PASSWORD}` 這類 placeholders,先找出變數名稱,並在可行時檢查目前 process environment。若值不可得,再請 user 提供。
67
-
68
- ### 3. Decide Whether To Prompt User
69
-
70
- 只有在 repo discovery 無法補齊完整 connection profile 時,才詢問 user。
71
-
72
- 只詢問最小必要缺漏資訊:
73
-
74
- - `db_type`: Oracle, PostgreSQL, SQL Server / Microsoft SQL Server / MS SQL / MSSQL, MySQL, MariaDB, SQLite, IBM Db2, H2, etc.
75
- - `host`, `port`, `database` or `service_name`/`SID`, and optional `schema`.
76
- - `username` and password/token, preferably read-only and temporary.
77
- - environment name: `local`, `dev`, `test`, `uat`, `prod`.
78
- - preferred access method if security policy requires one: VPN, bastion, container exec, app helper, wallet, Kerberos, IAM, ODBC DSN.
79
-
80
- 告知 user 可以提供 placeholders 或僅限本次 session 使用的值。不要要求 user 把 secrets 提交進 repo。
81
-
82
- ### 4. Choose The Query Method
83
-
84
- 依照以下順序選擇:
85
-
86
- 1. Existing repo helper: scripts, Makefile/Gradle/Maven tasks, app admin CLI, migration tooling, DAO/repository tests, or documented SQL utilities.
87
- 2. Native DB client:
88
- - Oracle: `sqlplus` or `sql`
89
- - PostgreSQL: `psql`
90
- - SQL Server / Microsoft SQL Server / MS SQL / MSSQL: `sqlcmd`
91
- - MySQL/MariaDB: `mysql` or `mariadb`
92
- - SQLite: `sqlite3`
93
- - IBM Db2: `db2`
94
- - H2: app console, JDBC tool, or repo-provided test utility
95
- 3. Container-local client: `docker compose exec`, `kubectl exec`, or DB client inside an app/DB container when local tooling is unavailable.
96
- 4. Temporary helper script in the current work session only if dependencies are already installed or user approves installation. Do not add DB driver dependencies to the repo for a one-off query.
97
-
98
- 可參考 `references/client-commands.md` 取得 native client command templates,並參考 `references/query-safety.md` 了解 read-only 與 row-limit patterns。
99
-
100
- ### 5. Validate Connection With A Minimal Query
101
-
102
- 在正式 investigation 前,先執行無害的 identity/version query:
103
-
104
- - Oracle: `SELECT 1 FROM dual`
105
- - PostgreSQL: `SELECT 1`
106
- - SQL Server / Microsoft SQL Server / MS SQL / MSSQL: `SELECT 1`
107
- - MySQL/MariaDB: `SELECT 1`
108
- - SQLite: `SELECT 1`
109
- - IBM Db2: `SELECT 1 FROM sysibm.sysdummy1`
110
- - H2: `SELECT 1`
111
-
112
- Native client self-healing:正式查詢前先確認選定的 native client 或 repo helper 能啟動。若 client initialization 失敗且錯誤明確指向 process environment、proxy、encoding、PATH 或 client runtime 設定,允許在不修改 repo、不寫入 credential file 的前提下,以乾淨 child process 或 current process env 做一次最小重試;vendor-specific retry pattern 放在 `references/client-commands.md`。若重試成功,記錄 self-healing action;若仍失敗,才回報 `connection_failed`、`missing_tool` 或其他具體 status,並保留不含 secrets 的錯誤摘要。
113
-
114
- 如果 connection 失敗,回報精確但不含 secrets 的錯誤類型:network、auth、service/database name、missing client、missing driver、SSL/TLS、VPN/bastion、permission denied 或 syntax mismatch。
115
-
116
- 若 repo 有多組連線線索、同時存在多個 datasource,或 user 問題依賴特定 schema / service,`SELECT 1` 後再執行 identity query,記錄目前 session 的 user、schema、service / database。例如 Oracle 可用 `SELECT USER, SYS_CONTEXT('USERENV','CURRENT_SCHEMA'), SYS_CONTEXT('USERENV','SERVICE_NAME') FROM dual`;其他 DB 使用對應 identity function。
117
-
118
- ### 6. Run Bounded SQL
119
-
120
- 撰寫剛好能回答問題的最小查詢:
121
-
122
- - 先從 metadata tables 開始,不要一開始就掃 business tables。
123
- - 使用 `WHERE`、date bounds、primary keys,以及 `LIMIT`/`TOP`/`FETCH FIRST`。
124
- - 除非 table 很小,或 user 明確要求 raw inspection,否則避免使用 `SELECT *`。
125
- - 面對大表時,先跑 counts 或 grouped summaries。
126
- - 如果 query 可能代價很高,先說明風險,再徵求同意後執行。
127
- - 明確區分 SQL dialect-specific syntax,不要假設 PostgreSQL 語法可以直接套用到 Oracle 或 SQL Server。
128
- - 明確區分 dialect-specific semantics。只有在已辨識目前 DB 是 Oracle 時,才套用 Oracle 的 empty-string/NULL 規則;其他 DB 依各自語意處理。
129
- - Oracle 查非空字串時,不要寫 `= ''`、`<> ''`,也不要寫 `TRIM(NVL(col, '')) <> ''`。Oracle 會把 `''` 視為 `NULL`,這類 predicate 容易把原本有值的 rows 全部過濾掉。判斷 trim 後非空時,優先使用 `LENGTH(TRIM(NVL(col, ' '))) > 0`;若只是判斷有無值,可用 `TRIM(col) IS NOT NULL`。
130
- - 若第一個 bounded inventory query 回傳 0 rows,但依 repo/catalog/context 應有資料,先回頭確認目前 schema / service 是否正確、table/view 是否在當前 namespace 可見,再決定這是 validated empty 還是連錯環境 / authority 不明。
131
-
132
- ### 7. Report Results
133
-
134
- 回報時包含:
135
-
136
- - DB type and environment, if known.
137
- - Connection source: config file path, env var names, DSN name, container, or user-provided session values. Redact secrets.
138
- - SQL statements executed, with sensitive literals removed if needed.
139
- - Result summary: row count, key rows, anomalies,.
140
- - Follow-up gaps: missing schema permission, unresolved config placeholder, ambiguous environment, or query not run.
141
-
142
- 最終輸出不要包含 plaintext credentials。